From c6842e8498c2d9b469890b38cd9f0d714392c445 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期五, 01 十二月 2023 13:22:02 +0800
Subject: [PATCH] 1. 修改优化日统计和风险统计的逻辑

---
 src/main/resources/mapper/FugitiveDustMapper.xml |  151 +++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 125 insertions(+), 26 deletions(-)

diff --git a/src/main/resources/mapper/FugitiveDustMapper.xml b/src/main/resources/mapper/FugitiveDustMapper.xml
index de696eb..6b8ed8c 100644
--- a/src/main/resources/mapper/FugitiveDustMapper.xml
+++ b/src/main/resources/mapper/FugitiveDustMapper.xml
@@ -35,7 +35,8 @@
         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 like concat('%',#{siteName},'%')
+<!--                b.name like concat('%',#{siteName},'%')-->
+                b.name = #{siteName}
             </if>
             <if test="mnCode !=null and mnCode != ''">
                 and a.mn_code = #{mnCode}
@@ -63,41 +64,52 @@
             </if>
 
             <if test="beginTime != null and endTime != null">
-                and a.Lst between #{beginTime} and #{endTime}
+                and a.Lst between #{beginTime} and #{endTime} and a.type = #{type}
             </if>
         </where>
     </select>
 
+
+<!--    &lt;!&ndash;    鏍规嵁绔欑偣鍚嶅瓧鍜屾椂娈佃繘琛岀粺璁″垎鏋�&ndash;&gt;-->
+<!--    <select id="analysisByTime" resultType="com.flightfeather.monitor.pojo.AnalysisDustData">-->
+<!--        select  c.name,d.*-->
+<!--        from ja_t_dust_site_info as c  join-->
+<!--        (-->
+<!--        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 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>-->
+<!--&lt;!&ndash;            <if test="siteName !=null and siteName != ''">&ndash;&gt;-->
+<!--&lt;!&ndash;                b.name = #{siteName}&ndash;&gt;-->
+<!--&lt;!&ndash;            </if>&ndash;&gt;-->
+
+<!--            <if test="beginTime != null and endTime != null">-->
+<!--                lst between #{beginTime} and #{endTime}-->
+<!--            </if>-->
+
+<!--        </where>-->
+<!--        GROUP BY mn_code,DATE(lst)-->
+<!--        order by lst asc ) as d  on c.mn_code = d.mn_code-->
+<!--    </select>-->
 
     <!--    鏍规嵁绔欑偣鍚嶅瓧鍜屾椂娈佃繘琛岀粺璁″垎鏋�-->
     <select id="analysisByTime" resultType="com.flightfeather.monitor.pojo.AnalysisDustData">
         select  c.name,d.*
-        from ja_t_dust_site_info as c  join
-        (
-        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 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
+        from ja_t_dust_site_info as c  join dust_statistics_value as d  on c.mn_code = d.mn_code
         <where>
-<!--            <if test="siteName !=null and siteName != ''">-->
-<!--                b.name = #{siteName}-->
-<!--            </if>-->
-
             <if test="beginTime != null and endTime != null">
-                lst between #{beginTime} and #{endTime}
+                d.lst between #{beginTime} and #{endTime} and d.type = 'day'
             </if>
-
         </where>
-        GROUP BY mn_code,DATE(lst)
-        order by lst asc ) as d  on c.mn_code = d.mn_code
+        order by d.day_avg desc
     </select>
-
 
 
     <!--鏉′欢鏌ヨ寮傚父鏁版嵁  鍔犱笂浜嗗璁′俊鎭�-->
@@ -107,7 +119,7 @@
         from dust_exception_data 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}
+                b.name like concat('%',#{siteName},'%')
             </if>
 
             <if test="exceptionType != null and exceptionType != '' ">
@@ -134,12 +146,27 @@
         from dust_exception_data 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="exceptionType !=null and exceptionType != ''">
-                a.exception_type  = #{exceptionType}
+                and a.exception_type  = #{exceptionType}
             </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>
+            <if test="street != null and street != '' ">
+                and b.address in
+                <foreach item="item" collection="street" separator="," open="("  close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="dutyCompany != null and dutyCompany != '' ">
+                and b.duty_company in
+                <foreach item="item" collection="dutyCompany" separator="," open="("  close=")">
+                    #{item}
+                </foreach>
             </if>
         </where>
     </select>
@@ -199,8 +226,9 @@
                 and a.type  = #{type}
             </if>
         </where>
-
     </select>
+
+
     <select id="analysisdataByTimeAndType" resultType="com.flightfeather.monitor.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>
@@ -212,7 +240,78 @@
                 and a.type  = #{type}
             </if>
         </where>
+    </select>
 
+    <select id="getExceptionData2" resultType="com.flightfeather.monitor.pojo.DustExceptionData">
+
+       select a.* ,b.*
+        from dust_exception_data as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
+        <where>
+            <if test="street != null and street != '' ">
+                 b.address in
+                <foreach item="item" collection="street" separator="," open="("  close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="dutyCompany != null and dutyCompany != '' ">
+                and b.duty_company in
+                <foreach item="item" collection="dutyCompany" separator="," open="("  close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="siteName !=null and siteName != ''">
+                and b.name like concat('%',#{siteName},'%')
+            </if>
+
+            <if test="exceptionType != null and exceptionType != '' ">
+                and 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="exceptionNum" resultType="java.lang.Integer">
+        select count(*)
+        from dust_exception_data 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="exceptionType != null and exceptionType != '' ">
+                and a.exception_type = #{exceptionType}
+            </if>
+
+            <if test="street != null and street != '' ">
+                and b.address in
+                <foreach item="item" collection="street" separator="," open="("  close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="dutyCompany != null and dutyCompany != '' ">
+                and b.duty_company in
+                <foreach item="item" collection="dutyCompany" 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>
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.9.3