zmc
2023-08-14 9376436cdd6e3986cc4af4b4a6aa9e78e2b32de0
src/main/resources/com/job/zsc/mapper/FugitiveDustMapper.xml
@@ -30,7 +30,7 @@
<!--分析数据-->
    <select id="analysisdata" resultType="com.job.zsc.pojo.AnalysisDustData">
        select a.* from avg_dust_value as a join ja_t_dust_site_info as b on a.mn_code = b. mn_code
        select a.* from dust_statistics_value as a join ja_t_dust_site_info as b on a.mn_code = b. mn_code
        <where>
            <if test="siteName !=null and siteName != ''">
                b.name = #{siteName}
@@ -41,4 +41,52 @@
            </if>
        </where>
    </select>
<!--    根据站点名字和时段进行统计分析-->
<!--    <select id="analysisByTime" resultType="com.job.zsc.pojo.AnalysisDustData">-->
<!--        select-->
<!--        a.mn_code as mn_code,-->
<!--        DATE(a.lst) as lst,-->
<!--        ROUND(AVG(a.dust_value),3)  as day_avg,-->
<!--        CONCAT(ROUND(COUNT(*)/96*100, 2), '%')  as day_online,-->
<!--        CONCAT(ROUND(SUM(CASE WHEN a.dust_value >0 THEN 1 ELSE 0 END)/COUNT(*) *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-->
<!--        <where>-->
<!--            <if test="siteName !=null and siteName != ''">-->
<!--                b.name = #{siteName}-->
<!--            </if>-->
<!--            <if test="beginTime != null and endTime != null">-->
<!--              and  a.lst between #{beginTime} and #{endTime}-->
<!--            </if>-->
<!--        </where>-->
<!--        group by a.mn_code,DATE(a.lst)-->
<!--        order by lst asc-->
<!--    </select>-->
    <!--    根据站点名字和时段进行统计分析-->
    <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,
        CONCAT(ROUND(COUNT(*)/96*100, 2), '%')  as day_online,
        CONCAT(ROUND(SUM(CASE WHEN a.dust_value >0 THEN 1 ELSE 0 END)/COUNT(*) *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
        <where>
            <if test="siteName !=null and siteName != ''">
                b.name = #{siteName}
            </if>
            <if test="beginTime != null and endTime != null">
                and  a.lst between #{beginTime} and #{endTime}
            </if>
        </where>
        GROUP BY a.mn_code,DATE(a.lst)
        order by lst asc ) as d  on c.mn_code = d.mn_code
    </select>
</mapper>