From 1eecc1f678668ba11b15198be4f0057cf886e7f6 Mon Sep 17 00:00:00 2001 From: zmc <zmc_li@foxmail.com> Date: 星期二, 29 八月 2023 08:48:40 +0800 Subject: [PATCH] 扬尘监测后端代码 --- src/main/resources/com/job/zsc/mapper/AnalysisDataMapper.xml | 119 ++++++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 84 insertions(+), 35 deletions(-) diff --git a/src/main/resources/com/job/zsc/mapper/AnalysisDataMapper.xml b/src/main/resources/com/job/zsc/mapper/AnalysisDataMapper.xml index 08973d1..6a602ed 100644 --- a/src/main/resources/com/job/zsc/mapper/AnalysisDataMapper.xml +++ b/src/main/resources/com/job/zsc/mapper/AnalysisDataMapper.xml @@ -6,7 +6,7 @@ <select id="findByDevId" resultType="com.job.zsc.pojo.AnalysisData"> - select * from analysis_data + select * from fm_web_analysis_data <where> <if test="devId != null and devId != '' "> fume_dev_id=#{devId} @@ -18,72 +18,121 @@ </where> </select> +<!--淇℃伅鍜屾暟鎹湭鍒嗗紑鐨勬暟鎹〃鍒嗘瀽 ed_data--> +<!-- <select id="find" resultType="com.job.zsc.pojo.AnalysisData">--> +<!-- SELECT--> +<!-- equipment_number as fume_dev_id,--> +<!-- DATE(reporting_time) as fume_date,--> +<!-- MIN(smoke_pop_density) as fume_day_min,--> + +<!-- MAX(smoke_pop_density) as fume_day_max,--> + +<!-- AVG(smoke_pop_density) as fume_day_average,--> + +<!-- CONCAT(ROUND(SUM(CASE WHEN smoke_pop_density > 0 and purifier > 0 THEN 1 ELSE 0 END)/144 * 100, 2), '%') as purifier_open_rate,--> +<!-- SUM(CASE WHEN smoke_push_density >= 1 OR smoke_pop_density >= 1 THEN 1 ELSE 0 END) AS fume_minute_exceeding_num,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN smoke_push_density >= 1 OR smoke_pop_density >= 1 THEN 1 ELSE 0 END)/COUNT(*) * 100, 2), '%') as fume_over_standard_rate,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN smoke_push_density > 0 OR smoke_pop_density > 0 THEN 1 ELSE 0 END)/COUNT(*) * 100, 2), '%') as fume_data_efficiency,--> + +<!-- CONCAT(ROUND(COUNT(*)/144 * 100, 2), '%') as daily_online_rate,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59' THEN 1 ELSE 0 END)/24 * 100, 2), '%') as noon_online_rate,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59' THEN 1 ELSE 0 END)/24 * 100, 2), '%') as night_online_rate,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN (TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59') THEN 1 ELSE 0 END)/48 * 100, 2), '%') as key_online_rate,--> + +<!-- CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59' AND (smoke_push_density > 0 OR smoke_pop_density > 0) THEN 1 ELSE 0 END)/24 * 100, 2), '%') as noon_valid_rate,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59' AND (smoke_push_density > 0 OR smoke_pop_density > 0) THEN 1 ELSE 0 END)/24* 100, 2), '%') as night_valid_rate,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN ((TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59')) AND (smoke_push_density > 0 OR smoke_pop_density > 0) THEN 1 ELSE 0 END)/48* 100, 2), '%') as key_valid_rate,--> + +<!-- CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59' THEN 1 ELSE 0 END) /24 * 100, 2), '%') as noon_opening_count,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59' THEN 1 ELSE 0 END) /24 * 100, 2), '%') as night_opening_count,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN (TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59') THEN 1 ELSE 0 END)/48 * 100, 2), '%') as 'key_opening_rate',--> + +<!-- SUM(CASE WHEN (TIME(attribution_time) BETWEEN '10:00:00' and '14:00:00') and (smoke_push_density >= 1 OR smoke_pop_density >= 1) THEN 1 ELSE 0 END) as noon_exceeding_num,--> +<!-- SUM(CASE WHEN (TIME(attribution_time) BETWEEN '17:00:00' and '21:00:00') and (smoke_push_density >= 1 OR smoke_pop_density >= 1) THEN 1 ELSE 0 END) as night_exceeding_num,--> +<!-- CONCAT(ROUND(SUM(CASE WHEN ((TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59'))and (smoke_push_density >= 1 OR smoke_pop_density >= 1) THEN 1 ELSE 0 END)/48 * 100, 2), '%') as key_exceeding_rate--> +<!-- FROM--> +<!-- ed_data--> +<!-- <where>--> +<!-- <if test="shopname != null and shopname != '' ">--> +<!-- shop_name like concat('%',#{shopname},'%')--> +<!-- </if>--> +<!-- <if test="value != null and value != '' ">--> +<!-- or shop_name like concat('%',#{value},'%')--> +<!-- </if>--> +<!-- <if test="begin != null and end != null">--> +<!-- and reporting_time between #{begin} and #{end}--> +<!-- </if>--> +<!-- </where>--> +<!-- GROUP BY equipment_number, DATE(reporting_time)--> +<!-- limit 0,500--> +<!-- </select>--> +<!--鏂拌〃--> <select id="find" resultType="com.job.zsc.pojo.AnalysisData"> SELECT - equipment_number as fume_dev_id, - DATE(reporting_time) as fume_date, - MIN(smoke_pop_density) as fume_day_min, + a.MV_Stat_Code as fume_dev_id, - MAX(smoke_pop_density) as fume_day_max, + DATE(a.MV_Data_Time) as fume_date, + MIN(a.MV_Fume_Concentration2) as fume_day_min, - AVG(smoke_pop_density) as fume_day_average, + MAX(a.MV_Fume_Concentration2) as fume_day_max, - CONCAT(ROUND(SUM(CASE WHEN smoke_pop_density > 0 and purifier > 0 THEN 1 ELSE 0 END)/144 * 100, 2), '%') as purifier_open_rate, - SUM(CASE WHEN smoke_push_density >= 1 OR smoke_pop_density >= 1 THEN 1 ELSE 0 END) AS fume_minute_exceeding_num, - CONCAT(ROUND(SUM(CASE WHEN smoke_push_density >= 1 OR smoke_pop_density >= 1 THEN 1 ELSE 0 END)/COUNT(*) * 100, 2), '%') as fume_over_standard_rate, - CONCAT(ROUND(SUM(CASE WHEN smoke_push_density > 0 OR smoke_pop_density > 0 THEN 1 ELSE 0 END)/COUNT(*) * 100, 2), '%') as fume_data_efficiency, + AVG(a.MV_Fume_Concentration2) as fume_day_average, + + CONCAT(ROUND(SUM(CASE WHEN a.MV_Fume_Concentration2 > 0 and a.MV_Purifier_Electricity > 0 THEN 1 ELSE 0 END)/144 * 100, 2), '%') as purifier_open_rate, + SUM(CASE WHEN a.MV_Fume_Concentration >= 1 OR a.MV_Fume_Concentration2 >= 1 THEN 1 ELSE 0 END) AS fume_minute_exceeding_num, + CONCAT(ROUND(SUM(CASE WHEN a.MV_Fume_Concentration >= 1 OR a.MV_Fume_Concentration2 >= 1 THEN 1 ELSE 0 END)/COUNT(*) * 100, 2), '%') as fume_over_standard_rate, + CONCAT(ROUND(SUM(CASE WHEN a.MV_Fume_Concentration > 0 OR a.MV_Fume_Concentration2 > 0 THEN 1 ELSE 0 END)/COUNT(*) * 100, 2), '%') as fume_data_efficiency, CONCAT(ROUND(COUNT(*)/144 * 100, 2), '%') as daily_online_rate, - CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59' THEN 1 ELSE 0 END)/24 * 100, 2), '%') as noon_online_rate, - CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59' THEN 1 ELSE 0 END)/24 * 100, 2), '%') as night_online_rate, - CONCAT(ROUND(SUM(CASE WHEN (TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59') THEN 1 ELSE 0 END)/48 * 100, 2), '%') as key_online_rate, + CONCAT(ROUND(SUM(CASE WHEN TIME(a.MV_Data_Time) BETWEEN '10:00:00' and '13:59:59' THEN 1 ELSE 0 END)/24 * 100, 2), '%') as noon_online_rate, + CONCAT(ROUND(SUM(CASE WHEN TIME(a.MV_Data_Time) BETWEEN '17:00:00' and '20:59:59' THEN 1 ELSE 0 END)/24 * 100, 2), '%') as night_online_rate, + CONCAT(ROUND(SUM(CASE WHEN (TIME(a.MV_Data_Time) BETWEEN '10:00:00' and '13:59:59') or (TIME(a.MV_Data_Time) BETWEEN '17:00:00' and '20:59:59') THEN 1 ELSE 0 END)/48 * 100, 2), '%') as key_online_rate, - CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59' AND (smoke_push_density > 0 OR smoke_pop_density > 0) THEN 1 ELSE 0 END)/24 * 100, 2), '%') as noon_valid_rate, - CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59' AND (smoke_push_density > 0 OR smoke_pop_density > 0) THEN 1 ELSE 0 END)/24* 100, 2), '%') as night_valid_rate, - CONCAT(ROUND(SUM(CASE WHEN ((TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59')) AND (smoke_push_density > 0 OR smoke_pop_density > 0) THEN 1 ELSE 0 END)/48* 100, 2), '%') as key_valid_rate, + CONCAT(ROUND(SUM(CASE WHEN TIME(a.MV_Data_Time) BETWEEN '10:00:00' and '13:59:59' AND (a.MV_Fume_Concentration > 0 OR a.MV_Fume_Concentration2 > 0) THEN 1 ELSE 0 END)/24 * 100, 2), '%') as noon_valid_rate, + CONCAT(ROUND(SUM(CASE WHEN TIME(a.MV_Data_Time) BETWEEN '17:00:00' and '20:59:59' AND (a.MV_Fume_Concentration > 0 OR a.MV_Fume_Concentration2 > 0) THEN 1 ELSE 0 END)/24* 100, 2), '%') as night_valid_rate, + CONCAT(ROUND(SUM(CASE WHEN ((TIME(a.MV_Data_Time) BETWEEN '10:00:00' and '13:59:59') or (TIME(a.MV_Data_Time) BETWEEN '17:00:00' and '20:59:59')) AND (a.MV_Fume_Concentration > 0 OR a.MV_Fume_Concentration2 > 0) THEN 1 ELSE 0 END)/48* 100, 2), '%') as key_valid_rate, - CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59' THEN 1 ELSE 0 END) /24 * 100, 2), '%') as noon_opening_count, - CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59' THEN 1 ELSE 0 END) /24 * 100, 2), '%') as night_opening_count, - CONCAT(ROUND(SUM(CASE WHEN (TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59') THEN 1 ELSE 0 END)/48 * 100, 2), '%') as 'key_opening_rate', + CONCAT(ROUND(SUM(CASE WHEN TIME(a.MV_Data_Time) BETWEEN '10:00:00' and '13:59:59' THEN 1 ELSE 0 END) /24 * 100, 2), '%') as noon_opening_count, + CONCAT(ROUND(SUM(CASE WHEN TIME(a.MV_Data_Time) BETWEEN '17:00:00' and '20:59:59' THEN 1 ELSE 0 END) /24 * 100, 2), '%') as night_opening_count, + CONCAT(ROUND(SUM(CASE WHEN (TIME(a.MV_Data_Time) BETWEEN '10:00:00' and '13:59:59') or (TIME(a.MV_Data_Time) BETWEEN '17:00:00' and '20:59:59') THEN 1 ELSE 0 END)/48 * 100, 2), '%') as 'key_opening_rate', - SUM(CASE WHEN (TIME(attribution_time) BETWEEN '10:00:00' and '14:00:00') and (smoke_push_density >= 1 OR smoke_pop_density >= 1) THEN 1 ELSE 0 END) as noon_exceeding_num, - SUM(CASE WHEN (TIME(attribution_time) BETWEEN '17:00:00' and '21:00:00') and (smoke_push_density >= 1 OR smoke_pop_density >= 1) THEN 1 ELSE 0 END) as night_exceeding_num, - CONCAT(ROUND(SUM(CASE WHEN ((TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59'))and (smoke_push_density >= 1 OR smoke_pop_density >= 1) THEN 1 ELSE 0 END)/48 * 100, 2), '%') as key_exceeding_rate + SUM(CASE WHEN (TIME(a.MV_Data_Time) BETWEEN '10:00:00' and '14:00:00') and (a.MV_Fume_Concentration >= 1 OR a.MV_Fume_Concentration2 >= 1) THEN 1 ELSE 0 END) as noon_exceeding_num, + SUM(CASE WHEN (TIME(a.MV_Data_Time) BETWEEN '17:00:00' and '21:00:00') and (a.MV_Fume_Concentration >= 1 OR a.MV_Fume_Concentration2 >= 1) THEN 1 ELSE 0 END) as night_exceeding_num, + CONCAT(ROUND(SUM(CASE WHEN ((TIME(a.MV_Data_Time) BETWEEN '10:00:00' and '13:59:59') or (TIME(a.MV_Data_Time) BETWEEN '17:00:00' and '20:59:59'))and (a.MV_Fume_Concentration >= 1 OR a.MV_Fume_Concentration2 >= 1) THEN 1 ELSE 0 END)/48 * 100, 2), '%') as key_exceeding_rate FROM - ed_data + fd_t_minutevalue as a + JOIN ea_t_device_info AS b ON a.MV_Stat_Code = b.DI_Code <where> <if test="shopname != null and shopname != '' "> - shop_name like concat('%',#{shopname},'%') + b.DI_Name like concat('%',#{shopname},'%') </if> <if test="value != null and value != '' "> - or shop_name like concat('%',#{value},'%') + or b.DI_Name like concat('%',#{value},'%') </if> <if test="begin != null and end != null"> - and reporting_time between #{begin} and #{end} + and a.MV_Data_Time between #{begin} and #{end} </if> </where> - GROUP BY equipment_number, DATE(reporting_time) + GROUP BY a.MV_Stat_Code, DATE(a.MV_Data_Time) limit 0,500 </select> <!-- 鍘婚噸--> - <select id="search" resultType="Integer"> - select count(*) from fm_web_analysis_data + <select id="search" resultType="com.job.zsc.pojo.AnalysisData"> + select a.*,b.DI_Name,b.DI_Supplier + from fm_web_analysis_data as a join ea_t_device_info as b on a.fume_dev_id = b.DI_Code <where> <if test="shopname != null and shopname != '' "> - fume_dev_id=(select fume_dev_id - from shopname_data - where shop_name like concat('%',#{shopname},'%')) + a.fume_dev_id like concat('%',#{shopname},'%') </if> <if test="value != null and value != null"> - or shop_name like concat('%',#{value},'%') + and b.DI_Name = #{value} </if> <if test="begin != null and end != null"> - and (fume_date between #{begin} and #{end}) + and a.fume_date between #{begin} and #{end} </if> </where> - group by fume_dev_id </select> </mapper> \ No newline at end of file -- Gitblit v1.9.3