南昌市物联网技防平台-后台
zengh
2021-04-09 6971c195601ecc91b2b7b52af83efed9956dcfe0
blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/healthcode/mapper/healthcodeMapper.xml
@@ -3,7 +3,7 @@
<mapper namespace="org.springblade.jfpt.healthcode.mapper.healthcodeMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="healthcodeResultMap" type="org.springblade.jfpt.healthcode.entity.healthcode">
    <resultMap id="healthcodeResultMap" type="org.springblade.jfpt.healthcode.entity.Healthcode">
        <id column="id" property="id"/>
        <result column="type" property="type"/>
        <result column="sex" property="sex"/>
@@ -118,6 +118,74 @@
       ) b
       on
       a.click_date = b.datetime
       order by a.click_date asc
    </select>
    <!--自定义健康码分页/健康码统计图表点击事件-->
    <select id="selectHealthcodeListPage" resultType="org.springblade.jfpt.healthcode.entity.Healthcode">
        SELECT * FROM healthcode
        where 1=1
        <if test="healthcodeVO.status==0">
            and to_days(dtime)=to_days(now())
        </if>
        <if test="healthcodeVO.status==1">
            and YEARWEEK(date_format(dtime,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
        </if>
        <if test="healthcodeVO.status==2">
            and date_format(dtime,'%Y%m') = date_format(now(),'%Y%m')
        </if>
        <if test="healthcodeVO.type!=null">
            and type=#{healthcodeVO.type}
        </if>
        <if test="healthcodeVO.province!=null">
            and province like concat('%',#{healthcodeVO.province},'%')
        </if>
        <if test="healthcodeVO.city!=null">
            and city like concat('%',#{healthcodeVO.city},'%')
        </if>
        <if test="healthcodeVO.district!=null">
            and district like concat('%',#{healthcodeVO.district},'%')
        </if>
        <if test="healthcodeVO.begTime!=null and healthcodeVO.begTime!='' and healthcodeVO.endTime!=null and healthcodeVO.endTime!='' ">
            and date(dtime) between #{healthcodeVO.begTime} and #{healthcodeVO.endTime}
        </if>
        ORDER BY dtime desc
    </select>
    <!--查询当前时间段红色健康码总个数-->
    <select id="selHealthcodeTimeCount" resultType="java.lang.Integer">
        select count(*) from healthcode
        where type = 3
        <if test="conditionVo.startTime!=null and conditionVo.startTime!='' and conditionVo.endTime!=null and conditionVo.endTime!=''">
            and dtime between #{conditionVo.startTime} and #{conditionVo.endTime}
        </if>
    </select>
    <!--查询当前时间段区间时间红色健康码个数-->
    <select id="selRedCodeTimeData" resultType="org.springblade.jfpt.healthcode.entity.Healthcode">
        SELECT type,dtime FROM healthcode
            where type =3
        and dtime between #{conditionVo.startTime} and #{conditionVo.endTime}
    </select>
    <!--统计时间段内红色健康码人数数量数据-->
    <select id="selectHealthcodeTimeData" resultType="java.lang.Integer">
        select ifnull(count,0) count from
        (
            SELECT @date := DATE_ADD( @date, INTERVAL + 1 DAY ) days FROM
            (
                SELECT @date := DATE_ADD( #{conditionVo.startTime}, INTERVAL - 1 DAY ) FROM sys_date
            ) time
            WHERE to_days( @date ) &lt; to_days( #{conditionVo.endTime} )
        ) a
        left join
        (
            select DATE_FORMAT(dtime,'%Y-%m-%d') as datetime, count(*) as count from healthcode
            where type=3
            group by DATE_FORMAT(dtime,'%Y-%m-%d')
        ) b
        on
        a.days = b.datetime
    </select>
</mapper>