zmc
2023-10-12 48959b0b908dd57bf9dd991b75756ac2698f2b4d
src/main/resources/com/job/zsc/mapper/FugitiveDustMapper.xml
@@ -73,30 +73,34 @@
    <select id="analysisByTime" resultType="com.job.zsc.pojo.AnalysisDustData">
        select  c.name,d.*
        from ja_t_dust_site_info as c  join
        (select
        a.mn_code as mn_code,
        DATE(a.lst) as lst,
        ROUND(AVG(a.dust_value),3)  as day_avg,
        min(a.dust_value) as min,
        max(a.dust_value) as max,
        (
        select
        mn_code as mn_code,
        DATE(lst) as lst,
        ROUND(AVG(dust_value),3)  as day_avg,
        min(dust_value) as min,
        max(dust_value) as max,
        CONCAT(ROUND(COUNT(*)/96*100, 2), '%')  as day_online,
        CONCAT(ROUND(SUM(CASE WHEN a.dust_value >0 THEN 1 ELSE 0 END)/96 *100, 2), '%') as day_valid,
        CONCAT(ROUND(SUM(CASE WHEN a.dust_value >= 1  THEN 1 ELSE 0 END)/96*100,2),'%') as  day_exceeding
        from ja_t_dust_site_data_info as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
        CONCAT(ROUND(SUM(CASE WHEN dust_value >0 THEN 1 ELSE 0 END)/96 *100, 2), '%') as day_valid,
        CONCAT(ROUND(SUM(CASE WHEN dust_value >= 1  THEN 1 ELSE 0 END)/96*100,2),'%') as  day_exceeding
        from ja_t_dust_site_data_info
        <where>
            <if test="siteName !=null and siteName != ''">
                b.name = #{siteName}
            </if>
<!--            <if test="siteName !=null and siteName != ''">-->
<!--                b.name = #{siteName}-->
<!--            </if>-->
            <if test="beginTime != null and endTime != null">
                and  a.lst between #{beginTime} and #{endTime}
                lst between #{beginTime} and #{endTime}
            </if>
        </where>
        GROUP BY a.mn_code,DATE(a.lst)
        GROUP BY mn_code,DATE(lst)
        order by lst asc ) as d  on c.mn_code = d.mn_code
    </select>
    <!--条件查询异常数据-->
    <!--条件查询异常数据  加上了审计信息-->
    <select id="getExceptionData" resultType="com.job.zsc.pojo.DustExceptionData">
        select *
        from (select a.* ,b.name,b.typename,b.address,b.duty_company
@@ -113,6 +117,7 @@
                </foreach>
            </if>
            <if test="beginTime != null and endTime != null">
                and (a.begin_time between #{beginTime} and #{endTime} or a.end_time between #{beginTime} and  #{endTime})
            </if>
@@ -122,10 +127,12 @@
    </select>
    <!--   根据某段时间内某个异常类型查询对应的店铺名称和设备编号-->
    <select id="getExceptionSitenameAndCode" resultType="com.job.zsc.pojo.DustExceptionData">
        select DISTINCT b.name,a.mn_code
        from dust_exception_data as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
        <where>
            <if test="exceptionType !=null and exceptionType != ''">
                a.exception_type  = #{exceptionType}
@@ -152,6 +159,7 @@
        </where>
        order by a.lst asc
    </select>
    <select id="getHasAuditedData" resultType="com.job.zsc.pojo.DustExceptionData">
        select *
        from dust_exception_data as a left join audit_info as b on a.id = b.exception_id
@@ -163,4 +171,48 @@
        </where>
    </select>
    <select id="getSiteNameByTimeAndExceptionType" resultType="com.job.zsc.pojo.DustExceptionData">
        select DISTINCT b.name
        from dust_exception_data as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
        <where>
            <if test="exceptionType != null and exceptionType != '' ">
                a.exception_type in
                <foreach item="item" collection="exceptionType" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
            <if test="beginTime != null and endTime != null">
                and (a.begin_time between #{beginTime} and #{endTime} or a.end_time between #{beginTime} and  #{endTime})
            </if>
        </where>
    </select>
    <select id="analysisdataByType" resultType="com.job.zsc.pojo.AnalysisDustData">
        select a.*,b.name,b.duty_company from dust_statistics_value as a join ja_t_dust_site_info as b on a.mn_code = b. mn_code
        <where>
            <if test="month != null and month != null">
               a.lst  = #{month}
            </if>
            <if test="type != null and type != ''">
                and a.type  = #{type}
            </if>
        </where>
    </select>
    <select id="analysisdataByTimeAndType" resultType="com.job.zsc.pojo.AnalysisDustData">
        select a.*,b.name,b.duty_company from dust_statistics_value as a join ja_t_dust_site_info as b on a.mn_code = b. mn_code
        <where>
            <if test="beginTime != null and endTime != null">
                a.Lst between #{beginTime} and #{endTime}
            </if>
            <if test="type != null and type != ''">
                and a.type  = #{type}
            </if>
        </where>
    </select>
</mapper>