TBoardStatisticMapper.xml 3.56 KB
Newer Older
yangtianyou's avatar
yangtianyou committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wisenergy.chnmuseum.party.mapper.TBoardStatisticMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.wisenergy.chnmuseum.party.model.TBoardStatistic">
        <id column="id" property="id" />
        <result column="board_id" property="boardId" />
        <result column="board_name" property="boardName" />
        <result column="organ_id" property="organId" />
        <result column="area_id" property="areaId" />
        <result column="play_number" property="playNumber" />
        <result column="play_date" property="playDate" />
    </resultMap>

    <!-- 播放排行结果 -->
    <resultMap id="rankMap" type="cn.wisenergy.chnmuseum.party.model.TBoardPlayRank">
        <id column="id" property="id"/>
        <result column="board_id" property="boardId"/>
        <result column="board_name" property="boardName"/>
        <result column="play_number" property="playNumber"/>
        <result column="play_date" property="playDate"/>
    </resultMap>

    <resultMap id="trendMap" type="cn.wisenergy.chnmuseum.party.model.TBoardPlayTrend">
        <result column="play_number" property="playNumber"/>
        <result column="play_date" property="playDate"/>
    </resultMap>

    <!-- 地区看板统计 -->
    <resultMap id="districtMap" type="cn.wisenergy.chnmuseum.party.model.TDistrictBoardStatistic">
        <result column="area_name" property="areaName"/>
        <result column="play_number" property="playNumber"/>
        <result column="board_cnt" property="boardCnt"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, board_id, board_name, organ_id, area_id, play_number, play_date
    </sql>

    <!-- 展板播放量统计 -->
    <select id="getBoardRankPageList" parameterType="cn.wisenergy.chnmuseum.party.model.TBoardPlayRank" resultMap="rankMap">
        SELECT board_id,board_name,sum(play_number) play_number from t_board_statistic
        <where>
            <if test="rank.playDate != null">
                and play_date like concat( #{rank.playDate}, '%')
            </if>
            <if test="rank.organId != null">
                and organ_id = #{rank.organId}
            </if>
        </where>
        GROUP BY board_id,board_name
        ORDER BY sum(play_number) desc
    </select>

    <!-- 播放趋势统计 -->
    <select id="getBoardTrendPageList" parameterType="cn.wisenergy.chnmuseum.party.model.TBoardPlayTrend" resultMap="trendMap">
        <if test="trend.playDate != null and trend.playDate.length() == 4">
            SELECT sum(play_number) play_number,left(play_date,6) play_date from t_board_statistic
            where left(play_date,4) = ${trend.playDate}
            GROUP BY left(play_date,6)
            ORDER BY left(play_date,6)
        </if>
        <if test="trend.playDate != null and trend.playDate.length() == 6">
            SELECT sum(play_number) play_number,play_date from t_board_statistic
            where left(play_date,6) = ${trend.playDate}
            GROUP BY play_date
            ORDER BY play_date
        </if>
    </select>

    <!-- 地区展板播放统计 -->
    <select id="getBoardDistrictPageList" resultMap="districtMap">
        SELECT a.name area_name,sum(play_number) play_number,count(board_id) board_cnt from t_board_statistic s
        left join t_area a on s.area_id = a.id
        GROUP BY area_id
        order by sum(play_number) desc,count(board_id) desc
    </select>


</mapper>