kangwei: 重构电耗分析相关接口,数据查询将pg数据改为日报报数
正在显示
9 个修改的文件
包含
1071 行增加
和
443 行删除
1 | package com.skua.common.report.vo; | ||
2 | |||
3 | import io.swagger.annotations.ApiModelProperty; | ||
4 | import lombok.Data; | ||
5 | |||
6 | import java.math.BigDecimal; | ||
7 | |||
8 | /** | ||
9 | * 水质水量报表 | ||
10 | * @auther kangwei | ||
11 | * @create 2024-11-27-9:10 | ||
12 | */ | ||
13 | @Data | ||
14 | public class DataViewVO { | ||
15 | @ApiModelProperty(value = "时间") | ||
16 | private String time; | ||
17 | |||
18 | @ApiModelProperty(value = "水厂") | ||
19 | private String departId; | ||
20 | |||
21 | @ApiModelProperty(value = "负荷率") | ||
22 | private String fhl; | ||
23 | |||
24 | @ApiModelProperty(value = "进水量") | ||
25 | private BigDecimal JSL; | ||
26 | @ApiModelProperty(value = "出水量") | ||
27 | private BigDecimal CSL; | ||
28 | |||
29 | @ApiModelProperty(value = "处理水量") | ||
30 | private BigDecimal CLSL; | ||
31 | |||
32 | @ApiModelProperty(value = "进水总磷") | ||
33 | private String JSZL; | ||
34 | @ApiModelProperty(value = "进水总磷") | ||
35 | private String CSZL; | ||
36 | |||
37 | @ApiModelProperty(value = "进水COD") | ||
38 | private String JSCOD; | ||
39 | @ApiModelProperty(value = "进水COD") | ||
40 | private String CSCOD; | ||
41 | |||
42 | |||
43 | @ApiModelProperty(value = "进水氨氮") | ||
44 | private String JSAD; | ||
45 | @ApiModelProperty(value = "出水氨氮") | ||
46 | private String CSAD; | ||
47 | |||
48 | |||
49 | @ApiModelProperty(value = "进水总氮") | ||
50 | private String JSZD; | ||
51 | |||
52 | |||
53 | @ApiModelProperty(value = "出水总氮") | ||
54 | private String CSTN; | ||
55 | |||
56 | |||
57 | @ApiModelProperty(value = "进水PH") | ||
58 | private String JSPH; | ||
59 | @ApiModelProperty(value = "出水PH") | ||
60 | private String CSPH; | ||
61 | |||
62 | @ApiModelProperty(value = "进水SS") | ||
63 | private String JSSS; | ||
64 | @ApiModelProperty(value = "出水SS") | ||
65 | private String CSSS; | ||
66 | |||
67 | public DataViewVO(){ | ||
68 | |||
69 | } | ||
70 | public void initData(){ | ||
71 | this.JSL = BigDecimal.ZERO; | ||
72 | this.CSL= BigDecimal.ZERO; | ||
73 | this.JSZL = "0.0"; | ||
74 | this.JSAD = "0.0"; | ||
75 | this.CSSS="0.0"; | ||
76 | this.JSSS="0.0"; | ||
77 | this.CSPH="0.0"; | ||
78 | this.JSPH = "0.0"; | ||
79 | this.JSZL="0.0"; | ||
80 | this.CSZL="0.0"; | ||
81 | this.JSCOD="0.0"; | ||
82 | this.CSCOD="0.0"; | ||
83 | this.JSAD="0.0"; | ||
84 | this.CSAD="0.0"; | ||
85 | this.JSZD="0.0"; | ||
86 | this.CSTN="0.0"; | ||
87 | } | ||
88 | |||
89 | //计算一组数据的标准差 | ||
90 | public void calculateStandardDeviation(){ | ||
91 | |||
92 | } | ||
93 | |||
94 | } |
1 | package com.skua.common.report.vo; | ||
2 | |||
3 | import com.skua.core.util.ConvertUtils; | ||
4 | import com.skua.tool.util.JSUtils; | ||
5 | import io.swagger.annotations.ApiModel; | ||
6 | import io.swagger.annotations.ApiModelProperty; | ||
7 | import lombok.Data; | ||
8 | |||
9 | import java.util.ArrayList; | ||
10 | import java.util.List; | ||
11 | |||
12 | /** | ||
13 | * @auther kangwei | ||
14 | * @create 2024-11-26-15:21 | ||
15 | */ | ||
16 | @Data | ||
17 | @ApiModel(value="折线图对象", description="折线图对象") | ||
18 | public class DrugChartsVO { | ||
19 | @ApiModelProperty(value = "时间参数") | ||
20 | private List<String> timeList; | ||
21 | |||
22 | @ApiModelProperty(value = "value:数值数组") | ||
23 | private List<String> valueList; | ||
24 | |||
25 | @ApiModelProperty(value = "同比:数值数组") | ||
26 | private List<String> valueTBList; | ||
27 | |||
28 | |||
29 | @ApiModelProperty(value = "总电耗数值数组") | ||
30 | private List<String> dhDataList; | ||
31 | |||
32 | @ApiModelProperty(value = "吨水电耗数值数组") | ||
33 | private List<String> dsdhDataList; | ||
34 | |||
35 | @ApiModelProperty(value = "(负荷率)数值数组") | ||
36 | private List<String> fhlDataList; | ||
37 | |||
38 | @ApiModelProperty(value = "(COD)数值数组") | ||
39 | private List<String> codDataList; | ||
40 | |||
41 | @ApiModelProperty(value = "(氨氮)数值数组") | ||
42 | private List<String> adDataList; | ||
43 | |||
44 | @ApiModelProperty(value = "(总磷)数值数组") | ||
45 | private List<String> zlDataList; | ||
46 | |||
47 | |||
48 | |||
49 | public DrugChartsVO(){ | ||
50 | |||
51 | } | ||
52 | public void setDsdhData(String time ,String dsdh){ | ||
53 | this.getTimeList().add(time); | ||
54 | this.getDsdhDataList().add(ConvertUtils.getString(dsdh,"0.0")); | ||
55 | } | ||
56 | public void setDsdhData(String time ,String dsdh,String fhl){ | ||
57 | this.getTimeList().add(time); | ||
58 | this.getDsdhDataList().add(ConvertUtils.getString(dsdh,"0.0")); | ||
59 | this.getFhlDataList().add(ConvertUtils.getString(fhl,"0.0") ); | ||
60 | } | ||
61 | public void setFhlData(String time ,String fhl){ | ||
62 | this.getTimeList().add(time); | ||
63 | this.getFhlDataList().add(ConvertUtils.getString(fhl,"0.0") ); | ||
64 | } | ||
65 | |||
66 | //设置污染物 | ||
67 | public void setCodAdZlData(String time ,String cod,String ad,String zl){ | ||
68 | this.getTimeList().add(time); | ||
69 | this.getCodDataList().add(ConvertUtils.getString(cod,"0.0") ); | ||
70 | this.getAdDataList().add(ConvertUtils.getString(ad,"0.0")); | ||
71 | this.getZlDataList().add(ConvertUtils.getString(zl,"0.0") ); | ||
72 | } | ||
73 | |||
74 | //设置污染物去除率 | ||
75 | public void setCodAdZlRateData(DataViewVO dataViewVO2119){ | ||
76 | this.getTimeList().add(dataViewVO2119.getTime()); | ||
77 | String expressionCod ="(" +dataViewVO2119.getJSCOD() +"-"+ dataViewVO2119.getCSAD() +") *100/ "+dataViewVO2119.getJSCOD(); | ||
78 | this.getCodDataList().add(JSUtils.executeExpression( expressionCod ,"0.0")); | ||
79 | String expressionAD ="(" +dataViewVO2119.getJSAD() +"-"+ dataViewVO2119.getCSAD() +") *100/ "+dataViewVO2119.getJSAD(); | ||
80 | this.getAdDataList().add(JSUtils.executeExpression( expressionAD ,"0.0")); | ||
81 | String expressionZL ="(" +dataViewVO2119.getJSZL() +"-"+ dataViewVO2119.getCSZL() +") *100/ "+dataViewVO2119.getJSZL(); | ||
82 | this.getZlDataList().add(JSUtils.executeExpression( expressionZL ,"0.0")); | ||
83 | } | ||
84 | //设置进水浓度 | ||
85 | public void setJSCodAdZlData(DataViewVO dataViewVO2119){ | ||
86 | this.getTimeList().add(dataViewVO2119.getTime()); | ||
87 | this.getCodDataList().add( dataViewVO2119.getJSCOD() ); | ||
88 | this.getAdDataList().add(dataViewVO2119.getJSAD()); | ||
89 | this.getZlDataList().add( dataViewVO2119.getJSZL()); | ||
90 | } | ||
91 | //设置出水浓度 | ||
92 | public void setCSCodAdZlData(DataViewVO dataViewVO2119){ | ||
93 | this.getTimeList().add(dataViewVO2119.getTime()); | ||
94 | this.getCodDataList().add( dataViewVO2119.getCSCOD() ); | ||
95 | this.getAdDataList().add(dataViewVO2119.getCSCOD()); | ||
96 | this.getZlDataList().add( dataViewVO2119.getCSZL()); | ||
97 | } | ||
98 | |||
99 | public List<String> getValueList() { | ||
100 | if(valueList == null ) valueList = new ArrayList<>(); | ||
101 | return valueList; | ||
102 | } | ||
103 | |||
104 | public List<String> getValueTBList() { | ||
105 | if(valueTBList == null ) valueTBList = new ArrayList<>(); | ||
106 | return valueTBList; | ||
107 | } | ||
108 | public List<String> getTimeList() { | ||
109 | if(timeList == null ) timeList = new ArrayList<>(); | ||
110 | return timeList; | ||
111 | } | ||
112 | |||
113 | public List<String> getDsdhDataList() { | ||
114 | if(dsdhDataList == null ) dsdhDataList = new ArrayList<>(); | ||
115 | return dsdhDataList; | ||
116 | } | ||
117 | |||
118 | public List<String> getFhlDataList() { | ||
119 | if(fhlDataList == null ) fhlDataList = new ArrayList<>(); | ||
120 | return fhlDataList; | ||
121 | } | ||
122 | |||
123 | public List<String> getCodDataList() { | ||
124 | if(codDataList == null ) codDataList = new ArrayList<>(); | ||
125 | return codDataList; | ||
126 | } | ||
127 | |||
128 | public List<String> getAdDataList() { | ||
129 | if(adDataList == null ) adDataList = new ArrayList<>(); | ||
130 | return adDataList; | ||
131 | } | ||
132 | |||
133 | public List<String> getZlDataList() { | ||
134 | if(zlDataList == null ) zlDataList = new ArrayList<>(); | ||
135 | return zlDataList; | ||
136 | } | ||
137 | |||
138 | } |
... | @@ -7,10 +7,9 @@ import javax.script.ScriptEngineManager; | ... | @@ -7,10 +7,9 @@ import javax.script.ScriptEngineManager; |
7 | import javax.script.ScriptException; | 7 | import javax.script.ScriptException; |
8 | import java.math.BigDecimal; | 8 | import java.math.BigDecimal; |
9 | import java.text.DecimalFormat; | 9 | import java.text.DecimalFormat; |
10 | import java.util.HashMap; | 10 | import java.text.ParseException; |
11 | import java.util.Map; | 11 | import java.text.SimpleDateFormat; |
12 | import java.util.Scanner; | 12 | import java.util.*; |
13 | import java.util.Stack; | ||
14 | import java.util.regex.Matcher; | 13 | import java.util.regex.Matcher; |
15 | import java.util.regex.Pattern; | 14 | import java.util.regex.Pattern; |
16 | 15 | ||
... | @@ -377,6 +376,28 @@ public class JSUtils { | ... | @@ -377,6 +376,28 @@ public class JSUtils { |
377 | return str; | 376 | return str; |
378 | } | 377 | } |
379 | 378 | ||
379 | /*** | ||
380 | * 计算时间的前几个月的月份 | ||
381 | * @param month | ||
382 | * @param time | ||
383 | * @return | ||
384 | */ | ||
385 | public static String getMonthBytime(int month,String time) { | ||
386 | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); | ||
387 | Calendar calendar = Calendar.getInstance(); | ||
388 | try { | ||
389 | calendar.setTime(format.parse(time)); | ||
390 | } catch (ParseException e) { | ||
391 | e.printStackTrace(); | ||
392 | } | ||
393 | calendar.add(Calendar.MONTH, month); | ||
394 | return format.format(calendar.getTime()); | ||
395 | } | ||
396 | |||
397 | public static void main(String[] args) { | ||
398 | System.out.println(getMonthBytime(-12,"2024-12")); | ||
399 | } | ||
400 | |||
380 | /* ScriptEngine se = new ScriptEngineManager().getEngineByName("JavaScript"); | 401 | /* ScriptEngine se = new ScriptEngineManager().getEngineByName("JavaScript"); |
381 | Object eval = null; | 402 | Object eval = null; |
382 | try { | 403 | try { | ... | ... |
... | @@ -10,4 +10,13 @@ public class TonOfWaterAndLoadRateDto { | ... | @@ -10,4 +10,13 @@ public class TonOfWaterAndLoadRateDto { |
10 | private String dsdh; | 10 | private String dsdh; |
11 | 11 | ||
12 | private String fhl; | 12 | private String fhl; |
13 | |||
14 | public TonOfWaterAndLoadRateDto(){ | ||
15 | |||
16 | } | ||
17 | public TonOfWaterAndLoadRateDto(String time, String dsdh, String fhl) { | ||
18 | this.time = time; | ||
19 | this.dsdh = dsdh; | ||
20 | this.fhl = fhl; | ||
21 | } | ||
13 | } | 22 | } | ... | ... |
... | @@ -7,4 +7,12 @@ public class TonOfWaterTrendDto { | ... | @@ -7,4 +7,12 @@ public class TonOfWaterTrendDto { |
7 | private String time; | 7 | private String time; |
8 | 8 | ||
9 | private String v; | 9 | private String v; |
10 | |||
11 | public TonOfWaterTrendDto(){ | ||
12 | |||
13 | } | ||
14 | public TonOfWaterTrendDto(String time, String v) { | ||
15 | this.time = time; | ||
16 | this.v = v; | ||
17 | } | ||
10 | } | 18 | } | ... | ... |
... | @@ -73,28 +73,6 @@ public interface ComprehensiveSupervisionMapper { | ... | @@ -73,28 +73,6 @@ public interface ComprehensiveSupervisionMapper { |
73 | String selectMetricNameById(String id); | 73 | String selectMetricNameById(String id); |
74 | 74 | ||
75 | 75 | ||
76 | /** | ||
77 | * 月度电耗水耗统计 | ||
78 | * | ||
79 | * @return | ||
80 | */ | ||
81 | ConsumptionDto selectMonthlyPowerConsumption(@Param("dataStr") String dataStr, @Param("departIds") List<String> departIds); | ||
82 | |||
83 | |||
84 | /** | ||
85 | * 月度药耗统计 | ||
86 | * | ||
87 | * @return | ||
88 | */ | ||
89 | DrugConsumptionDto selectMonthlyDrugConsumptionStatistics(@Param("dataStr") String dataStr, @Param("departIds") List<String> departIds); | ||
90 | |||
91 | |||
92 | /** | ||
93 | * 天出水量统计 | ||
94 | * | ||
95 | * @return | ||
96 | */ | ||
97 | Integer selectShByDay(@Param("date") String date, @Param("departIds") List<String> departIds); | ||
98 | 76 | ||
99 | 77 | ||
100 | /** | 78 | /** | ... | ... |
... | @@ -230,144 +230,8 @@ | ... | @@ -230,144 +230,8 @@ |
230 | select metric_name from sys_monitor_metric_info | 230 | select metric_name from sys_monitor_metric_info |
231 | where id=#{id} | 231 | where id=#{id} |
232 | </select> | 232 | </select> |
233 | <select id="selectMonthlyPowerConsumption" resultType="com.skua.modules.equipment.dto.ConsumptionDto"> | ||
234 | SELECT | ||
235 | dateStr AS TIME, | ||
236 | sum( dh ) AS dh, | ||
237 | FORMAT( | ||
238 | sum( dh )/ sum( csl ),2) AS dsdh | ||
239 | FROM | ||
240 | ( | ||
241 | SELECT | ||
242 | v.item_value AS dh, | ||
243 | DATE_FORMAT( v.data_time, '%Y-%m' ) AS dateStr, | ||
244 | 0 AS csl | ||
245 | FROM | ||
246 | f_report_item i | ||
247 | LEFT JOIN f_report_itemv v ON i.id = v.reit_id | ||
248 | WHERE | ||
249 | i.report_id = '07079703413c58fd96d79298f23af854' | ||
250 | AND i.item_code = 'dhkwh64bc' | ||
251 | and v.depart_id in | ||
252 | <foreach collection="departIds" item="departId" open="(" separator="," close=")"> | ||
253 | #{departId} | ||
254 | </foreach> | ||
255 | AND DATE_FORMAT( v.data_time, '%Y-%m' ) = #{dataStr} UNION ALL | ||
256 | SELECT | ||
257 | 0 AS dh, | ||
258 | DATE_FORMAT( v.data_time, '%Y-%m' ) AS dateStr, | ||
259 | v.item_value AS csl | ||
260 | FROM | ||
261 | f_report_item i | ||
262 | LEFT JOIN f_report_itemv v ON i.id = v.reit_id | ||
263 | WHERE | ||
264 | 233 | ||
265 | i.report_id = '2044b09220b8413eeda84ce4c861305b' | ||
266 | AND i.item_code = 'csl50c' | ||
267 | and v.depart_id in | ||
268 | <foreach collection="departIds" item="departId" open="(" separator="," close=")"> | ||
269 | #{departId} | ||
270 | </foreach> | ||
271 | AND DATE_FORMAT( v.data_time, '%Y-%m' ) = #{dataStr} | ||
272 | ) AS d | ||
273 | GROUP BY | ||
274 | dateStr | ||
275 | </select> | ||
276 | <select id="selectMonthlyDrugConsumptionStatistics" | ||
277 | resultType="com.skua.modules.equipment.dto.DrugConsumptionDto"> | ||
278 | 234 | ||
279 | |||
280 | SELECT dateStr AS TIME, | ||
281 | sum(yh) AS yh, | ||
282 | FORMAT( | ||
283 | sum(yh) / sum(csl),2) AS dsyh | ||
284 | FROM (SELECT DATE_FORMAT(v.data_time, '%Y-%m') as dateStr, | ||
285 | v.item_value AS yh, | ||
286 | 0 AS csl | ||
287 | FROM f_report_item i | ||
288 | LEFT JOIN f_report_itemv v ON i.id = v.reit_id | ||
289 | WHERE i.report_id = '07079703413c58fd96d79298f23af854' | ||
290 | AND i.item_code IN ( | ||
291 | 'lsytgtxhldc44', | ||
292 | 'lsytytxhlda760', | ||
293 | 'sysytxhld95e', | ||
294 | 'pamylzgtxhldb77', | ||
295 | 'pamylzgtxhldb0f', | ||
296 | 'fmhxtgtxhldc0', | ||
297 | 'klhxtgtxhldfc1d', | ||
298 | 'jhlytxhld4f41', | ||
299 | 'jhlgtxhld17d', | ||
300 | 'lygtxhldf2d5', | ||
301 | 'fhtyytxhld55ce', | ||
302 | 'fhtygtxhld046f', | ||
303 | 'pttgtxhlda01c', | ||
304 | 'pttytxhldea55', | ||
305 | 'clsnnacloytxhld09ea', | ||
306 | 'qljgtxhldf9e1', | ||
307 | 'yyytxhld84d', | ||
308 | 'gyygtxhlde2ca', | ||
309 | 'nmsytxhld245a', | ||
310 | 'zgjytxhld49a5', | ||
311 | 'qyhnnaohgtxhld2fde', | ||
312 | 'qyhnnaohytxhld8bae', | ||
313 | 'tsnna2cogtxhld6e21', | ||
314 | 'jhlstytxhld29d8', | ||
315 | 'nlsytxhld6dff', | ||
316 | 'xpjgtxhldc22', | ||
317 | 'cfjytxhlda2a1', | ||
318 | 'hyjnahsogtxhlde7e', | ||
319 | 'fyhsjjytxhld959', | ||
320 | 'chjcyyxhldbcd6', | ||
321 | 'jzytxhldea44', | ||
322 | 'mzyqxjytxhld52f', | ||
323 | 'lsqengtxhlde976', | ||
324 | 'edta4nagtxhld06e2', | ||
325 | 'qthxyj1xhldf66f', | ||
326 | 'qthxyj2xhld2f0a', | ||
327 | 'qthxyjxhldb97b', | ||
328 | 'qthxyj4xhld2645', | ||
329 | 'qthxyj5xhldaf94', | ||
330 | 'qthxyj6xhld2152' | ||
331 | ) | ||
332 | AND v.depart_id in | ||
333 | <foreach collection="departIds" item="departId" open="(" separator="," close=")"> | ||
334 | #{departId} | ||
335 | </foreach> | ||
336 | AND DATE_FORMAT(v.data_time, '%Y-%m') = #{dataStr} | ||
337 | |||
338 | UNION ALL | ||
339 | |||
340 | SELECT DATE_FORMAT(v.data_time, '%Y-%m') as dateStr, | ||
341 | 0 AS yh, | ||
342 | v.item_value AS csl | ||
343 | FROM f_report_item i | ||
344 | LEFT JOIN f_report_itemv v ON i.id = v.reit_id | ||
345 | WHERE i.report_id = '2044b09220b8413eeda84ce4c861305b' | ||
346 | AND i.item_code = 'csl50c' | ||
347 | AND v.depart_id in | ||
348 | <foreach collection="departIds" item="departId" open="(" separator="," close=")"> | ||
349 | #{departId} | ||
350 | </foreach> | ||
351 | AND DATE_FORMAT(v.data_time, '%Y-%m') = #{dataStr}) d | ||
352 | GROUP BY dateStr | ||
353 | |||
354 | </select> | ||
355 | <select id="selectShByDay" resultType="java.lang.Integer"> | ||
356 | SELECT sum(b.item_value) | ||
357 | FROM (SELECT v.item_value, | ||
358 | DATE_FORMAT(v.data_time, '%Y-%m-%d') AS dateStr | ||
359 | FROM f_report_item i | ||
360 | LEFT JOIN f_report_itemv v ON i.id = v.reit_id | ||
361 | WHERE-- 今日出水 | ||
362 | i.report_id = '2044b09220b8413eeda84ce4c861305b' | ||
363 | AND i.item_code = 'csl50c' | ||
364 | AND v.depart_id in | ||
365 | <foreach collection="departIds" item="departId" open="(" separator="," close=")"> | ||
366 | #{departId} | ||
367 | </foreach> | ||
368 | AND DATE_FORMAT(v.data_time, '%Y-%m-%d') = #{date}) AS b | ||
369 | GROUP BY dateStr | ||
370 | </select> | ||
371 | <select id="selectCountAlarmByYearForDay" resultType="com.skua.modules.equipment.dto.AlarmCountDto"> | 235 | <select id="selectCountAlarmByYearForDay" resultType="com.skua.modules.equipment.dto.AlarmCountDto"> |
372 | select count(1), | 236 | select count(1), |
373 | DATE_FORMAT(create_time, '%Y-%m-%d') as dateStr | 237 | DATE_FORMAT(create_time, '%Y-%m-%d') as dateStr |
... | @@ -416,9 +280,9 @@ | ... | @@ -416,9 +280,9 @@ |
416 | </select> | 280 | </select> |
417 | 281 | ||
418 | <select id="selectClslByMonths" resultType="java.util.HashMap"> | 282 | <select id="selectClslByMonths" resultType="java.util.HashMap"> |
419 | select sum(item_value) as v,DATE_FORMAT(data_time, '%Y-%m') as time from f_report_itemv a | 283 | select round(sum(item_value),2) as v,DATE_FORMAT(data_time, '%Y-%m') as time from f_report_itemv a |
420 | left join f_report_item b on b.id=a.reit_id | 284 | left join f_report_item b on b.id=a.reit_id |
421 | where b.item_code='csl503c' | 285 | where b.item_code='CSL' |
422 | and a.depart_id = #{factoryId} | 286 | and a.depart_id = #{factoryId} |
423 | <if test="list!=null and list.size>0"> | 287 | <if test="list!=null and list.size>0"> |
424 | and DATE_FORMAT(data_time, '%Y-%m') in | 288 | and DATE_FORMAT(data_time, '%Y-%m') in | ... | ... |
... | @@ -3,8 +3,10 @@ package com.skua.modules.equipment.service.impl; | ... | @@ -3,8 +3,10 @@ package com.skua.modules.equipment.service.impl; |
3 | import com.google.common.collect.Maps; | 3 | import com.google.common.collect.Maps; |
4 | import com.skua.common.constant.ReportConstant; | 4 | import com.skua.common.constant.ReportConstant; |
5 | import com.skua.common.report.ReportViewUtil; | 5 | import com.skua.common.report.ReportViewUtil; |
6 | import com.skua.common.report.vo.DataViewVO; | ||
6 | import com.skua.common.report.vo.ReportItemVO; | 7 | import com.skua.common.report.vo.ReportItemVO; |
7 | import com.skua.core.context.SpringContextUtils; | 8 | import com.skua.core.context.SpringContextUtils; |
9 | import com.skua.core.util.ConvertUtils; | ||
8 | import com.skua.modules.equipment.dto.*; | 10 | import com.skua.modules.equipment.dto.*; |
9 | import com.skua.modules.equipment.mapper.ComprehensiveSupervisionMapper; | 11 | import com.skua.modules.equipment.mapper.ComprehensiveSupervisionMapper; |
10 | import com.skua.modules.equipment.service.IPowerConsumptionAnalysisService; | 12 | import com.skua.modules.equipment.service.IPowerConsumptionAnalysisService; |
... | @@ -13,6 +15,7 @@ import com.skua.modules.equipment.vo.MetricVo; | ... | @@ -13,6 +15,7 @@ import com.skua.modules.equipment.vo.MetricVo; |
13 | import com.skua.tool.util.JSUtils; | 15 | import com.skua.tool.util.JSUtils; |
14 | import lombok.extern.slf4j.Slf4j; | 16 | import lombok.extern.slf4j.Slf4j; |
15 | import org.apache.shiro.dao.DataAccessException; | 17 | import org.apache.shiro.dao.DataAccessException; |
18 | import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
16 | import org.springframework.jdbc.core.JdbcTemplate; | 19 | import org.springframework.jdbc.core.JdbcTemplate; |
17 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
18 | 21 | ||
... | @@ -134,7 +137,7 @@ public class PowerConsumptionAnalusisServiceImpl implements IPowerConsumptionAna | ... | @@ -134,7 +137,7 @@ public class PowerConsumptionAnalusisServiceImpl implements IPowerConsumptionAna |
134 | }*/ | 137 | }*/ |
135 | return result; | 138 | return result; |
136 | } | 139 | } |
137 | 140 | //总电耗趋势 | |
138 | @Override | 141 | @Override |
139 | public Map<String, Object> powerConsumptionTrend(AnysisParamsVO anysisParamsVO) { | 142 | public Map<String, Object> powerConsumptionTrend(AnysisParamsVO anysisParamsVO) { |
140 | String time = anysisParamsVO.getTime(); | 143 | String time = anysisParamsVO.getTime(); |
... | @@ -178,305 +181,301 @@ public class PowerConsumptionAnalusisServiceImpl implements IPowerConsumptionAna | ... | @@ -178,305 +181,301 @@ public class PowerConsumptionAnalusisServiceImpl implements IPowerConsumptionAna |
178 | return result; | 181 | return result; |
179 | } | 182 | } |
180 | 183 | ||
184 | //吨水电耗趋势 | ||
181 | @Override | 185 | @Override |
182 | public Map<String, Object> tonOfWaterTrend(AnysisParamsVO anysisParamsVO) { | 186 | public Map<String, Object> tonOfWaterTrend(AnysisParamsVO anysisParamsVO) { |
183 | List<TonOfWaterTrendDto> dtos=new ArrayList<>();//封装数据 | 187 | List<TonOfWaterTrendDto> dtos=new ArrayList<>();//封装数据 |
184 | String time = anysisParamsVO.getTime(); | 188 | String time = anysisParamsVO.getTime(); |
189 | |||
190 | String startDate = JSUtils.getMonthBytime(-12,time)+"-01"; | ||
191 | String endDate = JSUtils.getMonthBytime(-0,time)+"-31"; | ||
192 | /* String startTime = time+"-01" ; | ||
193 | String endTime = time + "-31";*/ | ||
194 | |||
185 | //查询前推十二个月的数据 | 195 | //查询前推十二个月的数据 |
186 | List<String> months=this.getTwelve(time); | 196 | List<String> monthList = this.getTwelve(time); |
187 | Map<String, Object> result = Maps.newHashMap(); | 197 | Map<String, Object> result = Maps.newHashMap(); |
188 | String factoryId = anysisParamsVO.getFactoryId(); | 198 | String factoryId = anysisParamsVO.getFactoryId(); |
189 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | 199 | |
190 | for (String month : months) { | 200 | //查询数据 |
191 | TonOfWaterTrendDto dto=new TonOfWaterTrendDto(); | 201 | List<ReportItemVO> dsdhTrendListList =queryDSDHTrendList( factoryId, startDate, endDate,false); |
192 | dto.setTime(month); | 202 | |
193 | dtos.add(dto); | 203 | for (String dateTime : monthList) { |
194 | } | 204 | String dsValue = null; |
195 | result.put("data",dtos); | 205 | //String yesmonth = this.getMonthBytime(-12, dateTime);//同比 |
196 | return result; | 206 | if (dsdhTrendListList != null) { |
197 | }else{ | 207 | for (ReportItemVO reportItemVO : dsdhTrendListList) { |
198 | factoryId = anysisParamsVO.getFactoryId(); | 208 | if (dateTime.equals(reportItemVO.getTime())) { |
199 | } | 209 | dsValue = reportItemVO.getDsValue(); |
200 | List<AlarmDto> CSList=new ArrayList<>(); | 210 | break; |
201 | List<Map<String, Object>> monitorList2 = comprehensiveSupervisionMapper.selectClslByMonths(months,factoryId); | 211 | } |
202 | if (monitorList2.size()>0){ | ||
203 | for (Map<String, Object> map : monitorList2) { | ||
204 | AlarmDto dto=new AlarmDto(); | ||
205 | dto.setV(map.get("v").toString()); | ||
206 | dto.setTime(map.get("time").toString()); | ||
207 | CSList.add(dto); | ||
208 | } | ||
209 | } | ||
210 | List<AlarmDto> DHList=comprehensiveSupervisionMapper.selectDhByMonths(months,factoryId); | ||
211 | Map<String,String> csMap=CSList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
212 | Map<String,String> dhMap=DHList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
213 | for (String month : months) { | ||
214 | TonOfWaterTrendDto dto=new TonOfWaterTrendDto(); | ||
215 | dto.setTime(month); | ||
216 | if (dhMap.get(month)!=null){ | ||
217 | String v=dhMap.get(month); | ||
218 | if (csMap.get(month)!=null){ | ||
219 | //本月累计电耗量[kW·h]/本月累计处理水量[吨] | ||
220 | dto.setV(this.getValue((Double.parseDouble(v)/(Double.parseDouble(csMap.get(month)))))+""); | ||
221 | } | 212 | } |
222 | } | 213 | } |
223 | dtos.add(dto); | 214 | |
215 | dtos.add( new TonOfWaterTrendDto(dateTime, ConvertUtils.getString(dsValue,"0.0"))); | ||
224 | } | 216 | } |
225 | result.put("data",dtos); | 217 | result.put("data",dtos); |
226 | return result; | 218 | return result; |
227 | } | 219 | } |
228 | 220 | ||
221 | //吨水电耗与负荷率对比 | ||
229 | @Override | 222 | @Override |
230 | public Map<String, Object> tonOfWaterAndLoadRate(AnysisParamsVO anysisParamsVO) throws Exception{ | 223 | public Map<String, Object> tonOfWaterAndLoadRate(AnysisParamsVO anysisParamsVO) throws Exception{ |
231 | //封装数据 | 224 | //封装数据 |
232 | List<TonOfWaterAndLoadRateDto> dtos = new ArrayList<>(); | 225 | List<TonOfWaterAndLoadRateDto> dtos = new ArrayList<>(); |
233 | String time = anysisParamsVO.getTime(); | 226 | String time = anysisParamsVO.getTime(); |
227 | String startTime = JSUtils.getMonthBytime(-12,time)+"-01"; | ||
228 | String endTime = JSUtils.getMonthBytime(-0,time)+"-31"; | ||
234 | //查询前推十二个月的数据 | 229 | //查询前推十二个月的数据 |
235 | List<String> months=this.getTwelve(time); | 230 | List<String> months=this.getTwelve(time); |
236 | //查询吨水电耗 | 231 | //查询吨水电耗 |
237 | Map<String, Object> result = Maps.newHashMap(); | 232 | Map<String, Object> result = Maps.newHashMap(); |
238 | String factoryId = anysisParamsVO.getFactoryId(); | 233 | String factoryId = anysisParamsVO.getFactoryId(); |
239 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | 234 | |
240 | for (String month : months) { | 235 | // {time: "2023-11", dsdh: null, fhl: null} |
241 | TonOfWaterAndLoadRateDto dto=new TonOfWaterAndLoadRateDto(); | 236 | |
242 | dto.setTime(month); | 237 | //查询数据 |
243 | dtos.add(dto); | 238 | List<ReportItemVO> dsdhTrendListList =queryDSDHTrendList( factoryId, startTime, endTime,false); |
244 | } | 239 | List<ReportItemVO> fhlTrendList = queryFhlTrendList( factoryId, startTime, endTime);// 负荷率 |
245 | result.put("data",dtos); | 240 | //获取12个月时间集合 |
246 | return result; | 241 | String dsValue = null;String fhl = null; |
247 | }else{ | 242 | List<String> monthList=this.getTwelve(time); |
248 | factoryId = anysisParamsVO.getFactoryId(); | 243 | for (String dateTime : monthList) { |
249 | } | 244 | //String yesmonth = this.getMonthBytime(-12, dateTime);//同比 |
250 | List<Map<String, Object>> monitorList2 = comprehensiveSupervisionMapper.selectClslByMonths(months,factoryId); | 245 | if (dsdhTrendListList != null) { |
251 | List<AlarmDto> CSList=new ArrayList<>(); | 246 | for (ReportItemVO reportItemVO : dsdhTrendListList) { |
252 | if (monitorList2.size()>0){ | 247 | if (dateTime.equals(reportItemVO.getTime())) { |
253 | for (Map<String, Object> map : monitorList2) { | 248 | dsValue = reportItemVO.getDsValue(); |
254 | AlarmDto dto=new AlarmDto(); | 249 | break; |
255 | dto.setV(map.get("v").toString()); | 250 | } |
256 | dto.setTime(map.get("time").toString()); | 251 | } |
257 | CSList.add(dto); | ||
258 | } | 252 | } |
259 | } | 253 | if (fhlTrendList != null) { |
260 | //查询设计规模 | 254 | for (ReportItemVO reportItemVO : fhlTrendList) { |
261 | String sjgm=comprehensiveSupervisionMapper.selectSJGM(factoryId); | 255 | if (dateTime.equals(reportItemVO.getTime())) { |
262 | //封装数据 | 256 | fhl = reportItemVO.getValue(); |
263 | List<AlarmDto> DHList=comprehensiveSupervisionMapper.selectDhByMonths(months,factoryId); | 257 | break; |
264 | Map<String,String> csMap=CSList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | 258 | } |
265 | Map<String,String> dhMap=DHList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
266 | for (String month : months) { | ||
267 | TonOfWaterAndLoadRateDto dto=new TonOfWaterAndLoadRateDto(); | ||
268 | dto.setTime(month); | ||
269 | if (dhMap.get(month)!=null){ | ||
270 | String v=dhMap.get(month); | ||
271 | if (csMap.get(month)!=null){ | ||
272 | //本月累计电耗量[kW·h]/本月累计处理水量[吨] | ||
273 | dto.setDsdh(this.getValue((Double.parseDouble(v)/(Double.parseDouble(csMap.get(month))))).toString()); | ||
274 | //负荷率 | ||
275 | Calendar calendar = Calendar.getInstance(); | ||
276 | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM"); | ||
277 | calendar.setTime(sdf.parse(time)); | ||
278 | Integer num = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); | ||
279 | //负荷率=该月的日均处理水量/设计规模 | ||
280 | dto.setFhl(this.getValue(Double.parseDouble(csMap.get(month))/(Double.valueOf(sjgm)*num*10000)).toString()); | ||
281 | } | 259 | } |
282 | } | 260 | } |
283 | dtos.add(dto); | 261 | dtos.add( new TonOfWaterAndLoadRateDto(dateTime, ConvertUtils.getString(dsValue,"0.0"), ConvertUtils.getString(fhl,"0.0"))); |
284 | } | 262 | } |
263 | |||
264 | |||
265 | |||
285 | result.put("data",dtos); | 266 | result.put("data",dtos); |
286 | return result; | 267 | return result; |
287 | } | 268 | } |
288 | 269 | ||
270 | //吨水电耗与污染物浓度 | ||
289 | @Override | 271 | @Override |
290 | public Map<String, Object> tonOfWaterAndPollutantConcentration(AnysisParamsVO anysisParamsVO) { | 272 | public Map<String, Object> tonOfWaterAndPollutantConcentration(AnysisParamsVO anysisParamsVO) { |
291 | String time = anysisParamsVO.getTime(); | 273 | String time = anysisParamsVO.getTime(); |
274 | String startTime = JSUtils.getMonthBytime(-12,time)+"-01"; | ||
275 | String endTime = JSUtils.getMonthBytime(-0,time)+"-31"; | ||
292 | //查询前推十二个月的数据 | 276 | //查询前推十二个月的数据 |
293 | List<String> months = this.getTwelve(time); | 277 | List<String> monthList = this.getTwelve(time); |
294 | Map<String, Object> result = Maps.newHashMap(); | 278 | Map<String, Object> result = Maps.newHashMap(); |
295 | String[] strings={"JSCOD","CSCOD","CSNH3N","JSNH3N","JSTP","CSTP"}; | ||
296 | String factoryId = anysisParamsVO.getFactoryId(); | 279 | String factoryId = anysisParamsVO.getFactoryId(); |
297 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | 280 | //吨水电耗数据 |
298 | List<PollutantConcentrationDto> dtodsdh = new ArrayList<>(); | 281 | List<ReportItemVO> dsdhTrendListList =queryDSDHTrendList( factoryId, startTime, endTime,false); |
299 | for (String month :months) { | 282 | //查询数据:水质水量报表 |
300 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | 283 | List<DataViewVO> dataViewVO2119List = queryDataView2119( factoryId, startTime, endTime); |
301 | dto.setTime(month); | 284 | |
302 | dtodsdh.add(dto); | ||
303 | } | ||
304 | result.put("DSDH", dtodsdh); | ||
305 | for (String string : strings) { | ||
306 | List<PollutantConcentrationDto> dtos1 = new ArrayList<>(); | ||
307 | for (String month :months) { | ||
308 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | ||
309 | dto.setTime(month); | ||
310 | dtos1.add(dto); | ||
311 | } | ||
312 | result.put(string, dtos1); | ||
313 | } | ||
314 | return result; | ||
315 | }else{ | ||
316 | factoryId = anysisParamsVO.getFactoryId(); | ||
317 | } | ||
318 | //查询吨水电耗 | ||
319 | String device=comprehensiveSupervisionMapper.selectDeviceName(factoryId); | ||
320 | JdbcTemplate pgDb = (JdbcTemplate) SpringContextUtils.getBean("pg-db"); | ||
321 | String tableName=device+"_count"; | ||
322 | //吨水电耗 | 285 | //吨水电耗 |
323 | result.put("DSDH",this.tonOfWaterTrend(anysisParamsVO).get("data")); | 286 | List<TonOfWaterTrendDto> trend_dsdh = new ArrayList<>(); |
324 | for (String string : strings) { | 287 | //进水 |
325 | MetricVo metricVo = comprehensiveSupervisionMapper.selectMetric(string,factoryId); | 288 | List<TonOfWaterTrendDto> trend_JSCOD = new ArrayList<>(); |
326 | List<PollutantConcentrationDto> dtos1 = new ArrayList<>(); | 289 | List<TonOfWaterTrendDto> trend_JSNH3N = new ArrayList<>(); |
327 | if(metricVo==null){ | 290 | List<TonOfWaterTrendDto> trend_JSTP = new ArrayList<>(); |
328 | for (String month :months) { | 291 | //出水 |
329 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | 292 | List<TonOfWaterTrendDto> trend_CSCOD = new ArrayList<>(); |
330 | dto.setTime(month); | 293 | List<TonOfWaterTrendDto> trend_CSNH3N = new ArrayList<>(); |
331 | dtos1.add(dto); | 294 | List<TonOfWaterTrendDto> trend_CSTP = new ArrayList<>(); |
332 | } | 295 | |
333 | result.put(string, dtos1); | 296 | if (monthList != null) { |
334 | }else { | 297 | for (String month : monthList) { |
335 | StringBuilder str = new StringBuilder(); | 298 | String dsdh = null; |
336 | str.append("'" + metricVo.getId() + "'"); | 299 | String js_cod = null; |
337 | String sql1 = "select avg(cast(v as float8)) as v,substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8) as time\n" + | 300 | String js_nh3n = null; |
338 | " FROM " + tableName + "\n" + | 301 | String jd_tp = null; |
339 | "where nm in (" + str.toString() + ") \n" + | 302 | String cs_cod = null; |
340 | "and substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)<='" + months.get(11) + "'\n" + | 303 | String cs_nh3n = null; |
341 | "and substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)>='" + months.get(0) + "'\n" + | 304 | String cs_tp = null; |
342 | "GROUP BY substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)"; | 305 | //遍历吨水电耗 |
343 | List<Map<String, Object>> monitorList = null; | 306 | if(dsdhTrendListList != null ){ |
344 | try { | 307 | for(ReportItemVO reportItemVO : dsdhTrendListList){ |
345 | monitorList = pgDb.queryForList(sql1); | 308 | if (month.equals(reportItemVO.getTime())) { |
346 | Map<String, Object> monitorMap = new HashMap<>(); | 309 | dsdh = reportItemVO.getDsValue(); |
347 | if (monitorList.size() > 0) { | 310 | break; |
348 | for (Map<String, Object> map : monitorList) { | ||
349 | monitorMap.put(map.get("time").toString(),this.getValue(Double.parseDouble(map.get("v").toString())).toString()); | ||
350 | } | ||
351 | for (String month : months) { | ||
352 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | ||
353 | if(monitorMap.get(month)!=null){ | ||
354 | dto.setV(monitorMap.get(month).toString()); | ||
355 | } | ||
356 | dto.setTime(month); | ||
357 | dtos1.add(dto); | ||
358 | } | 311 | } |
359 | }else{ | 312 | } |
360 | for (String month :months) { | 313 | } |
361 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | 314 | if (dataViewVO2119List != null) { //遍历集合 |
362 | dto.setTime(month); | 315 | for (DataViewVO dataView : dataViewVO2119List) { |
363 | dtos1.add(dto); | 316 | if (month.equals(dataView.getTime())) { |
317 | js_cod = dataView.getJSCOD(); | ||
318 | js_nh3n = dataView.getJSAD(); | ||
319 | jd_tp = dataView.getJSZL(); | ||
320 | cs_cod = dataView.getCSCOD(); | ||
321 | cs_nh3n = dataView.getCSAD(); | ||
322 | cs_tp = dataView.getCSZL(); | ||
323 | break; | ||
364 | } | 324 | } |
365 | } | 325 | } |
366 | result.put(string, dtos1); | ||
367 | } catch (DataAccessException e) { | ||
368 | e.printStackTrace(); | ||
369 | } | 326 | } |
327 | trend_dsdh.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( dsdh, "0.0")) ) ; | ||
328 | trend_JSCOD.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( js_cod, "0.0")) ) ; | ||
329 | trend_JSNH3N.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( js_nh3n, "0.0")) ) ; | ||
330 | trend_JSTP.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( jd_tp, "0.0")) ) ; | ||
331 | trend_CSCOD.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( cs_cod, "0.0")) ) ; | ||
332 | trend_CSNH3N.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( cs_nh3n, "0.0")) ) ; | ||
333 | trend_CSTP.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( cs_tp, "0.0")) ) ; | ||
370 | } | 334 | } |
371 | } | 335 | } |
336 | result.put("DSDH",trend_dsdh); | ||
337 | result.put("JSCOD",trend_JSCOD); | ||
338 | result.put("JSNH3N",trend_JSNH3N); | ||
339 | result.put("JSTP",trend_JSTP); | ||
340 | result.put("CSCOD",trend_CSCOD); | ||
341 | result.put("CSNH3N",trend_CSNH3N); | ||
342 | result.put("CSTP",trend_CSTP); | ||
372 | return result; | 343 | return result; |
373 | } | 344 | } |
374 | 345 | ||
346 | //吨水电耗与污染物去除率对比 | ||
375 | @Override | 347 | @Override |
376 | public Map<String, Object> tonOfWaterAndPollutantRemovalRate(AnysisParamsVO anysisParamsVO) { | 348 | public Map<String, Object> tonOfWaterAndPollutantRemovalRate(AnysisParamsVO anysisParamsVO) { |
377 | String time = anysisParamsVO.getTime(); | 349 | String time = anysisParamsVO.getTime(); |
350 | String startTime = JSUtils.getMonthBytime(-12,time)+"-01"; | ||
351 | String endTime = JSUtils.getMonthBytime(-0,time)+"-31"; | ||
378 | //查询近12个月的数据 | 352 | //查询近12个月的数据 |
379 | List<String> months=this.getTwelve(time); | 353 | List<String> monthList = this.getTwelve(time); |
380 | Map<String, Object> result = Maps.newHashMap(); | 354 | Map<String, Object> result = Maps.newHashMap(); |
381 | String factoryId = anysisParamsVO.getFactoryId(); | 355 | String factoryId = anysisParamsVO.getFactoryId(); |
382 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | 356 | //吨水电耗数据 |
383 | result.put("DSDH",this.tonOfWaterTrend(anysisParamsVO).get("data"));//吨水电耗 | 357 | List<ReportItemVO> dsdhTrendListList =queryDSDHTrendList( factoryId, startTime, endTime,false); |
384 | result.put("COD",this.getRemovalRate("","",null,null,months,factoryId)); | 358 | //查询数据:水质水量报表 |
385 | result.put("NH3N",this.getRemovalRate("","",null,null,months,factoryId)); | 359 | List<DataViewVO> dataViewVO2119List = queryDataView2119( factoryId, startTime, endTime); |
386 | result.put("TP",this.getRemovalRate("","",null,null,months,factoryId)); | 360 | |
387 | return result; | ||
388 | }else{ | ||
389 | factoryId = anysisParamsVO.getFactoryId(); | ||
390 | } | ||
391 | String device=comprehensiveSupervisionMapper.selectDeviceName(factoryId); | ||
392 | JdbcTemplate pgDb = (JdbcTemplate) SpringContextUtils.getBean("pg-db"); | ||
393 | String tableName=device+"_count"; | ||
394 | //吨水电耗 | 361 | //吨水电耗 |
395 | result.put("DSDH",this.tonOfWaterTrend(anysisParamsVO).get("data")); | 362 | List<TonOfWaterTrendDto> trend_dsdh = new ArrayList<>(); |
396 | //计算去除率 | 363 | //计算去除率 |
397 | List<TonOfWaterTrendDto> analyVos=this.getRemovalRate("JSCOD","CSCOD",pgDb,tableName,months,factoryId); | 364 | List<TonOfWaterTrendDto> trend_cod = new ArrayList<>(); |
398 | result.put("COD",analyVos); | 365 | List<TonOfWaterTrendDto> trend_nh3n = new ArrayList<>(); |
399 | List<TonOfWaterTrendDto> analyVos1=this.getRemovalRate("JSNH3N","CSNH3N",pgDb,tableName,months,factoryId); | 366 | List<TonOfWaterTrendDto> trend_tp = new ArrayList<>(); |
400 | result.put("NH3N",analyVos1); | ||
401 | List<TonOfWaterTrendDto> analyVos2=this.getRemovalRate("JSTP","CSTP",pgDb,tableName,months,factoryId); | ||
402 | result.put("TP",analyVos2); | ||
403 | return result; | ||
404 | } | ||
405 | 367 | ||
406 | private List<TonOfWaterTrendDto> getRemovalRate(String jscod, String cscod, JdbcTemplate pgDb, String tableName, List<String> months, String factoryId) { | 368 | if (monthList != null) { |
407 | List<TonOfWaterTrendDto> dtos=new ArrayList<>(); | 369 | for (String month : monthList) { |
408 | MetricVo metricVo1 = comprehensiveSupervisionMapper.selectMetric(jscod,factoryId); | 370 | String dsdh = null; |
409 | if(metricVo1==null){ | 371 | String cod = null; |
410 | for (String month :months) { | 372 | String nh3n = null; |
411 | TonOfWaterTrendDto dto=new TonOfWaterTrendDto(); | 373 | String tp = null; |
412 | dto.setTime(month); | 374 | //遍历吨水电耗 |
413 | dtos.add(dto); | 375 | if(dsdhTrendListList != null ){ |
414 | } | 376 | for(ReportItemVO reportItemVO : dsdhTrendListList){ |
415 | return dtos; | 377 | if (month.equals(reportItemVO.getTime())) { |
416 | } | 378 | dsdh = reportItemVO.getDsValue(); |
417 | StringBuilder str1 = new StringBuilder(); | 379 | break; |
418 | MetricVo metricVo2 = comprehensiveSupervisionMapper.selectMetric(cscod,factoryId); | 380 | } |
419 | if(metricVo2==null){ | 381 | } |
420 | str1.append("'" + metricVo1.getId() + "'"); | ||
421 | }else{ | ||
422 | str1.append("'" + metricVo1.getId() + "'"+","+"'" + metricVo2.getId() + "'"); | ||
423 | } | ||
424 | String sql="select avg(cast(v as float8)) as v,nm,\n" + | ||
425 | "substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8) as time\n" + | ||
426 | " FROM " + tableName + "\n" + | ||
427 | "where nm in (" + str1.toString() + ") \n" + | ||
428 | "and substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)<='"+months.get(11)+"'\n" + | ||
429 | "and substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)>='"+months.get(0)+"'\n" + | ||
430 | "GROUP BY substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8),nm"; | ||
431 | List<Map<String, Object>> monitorList1 = null; | ||
432 | List<AlarmDto> alarmDtos=new ArrayList<>(); | ||
433 | try { | ||
434 | monitorList1 = pgDb.queryForList(sql); | ||
435 | if (monitorList1.size()>0){ | ||
436 | for (Map<String, Object> map : monitorList1) { | ||
437 | AlarmDto dto=new AlarmDto(); | ||
438 | dto.setName(map.get("nm").toString()); | ||
439 | dto.setTime(map.get("time").toString()); | ||
440 | dto.setV(map.get("v").toString()); | ||
441 | alarmDtos.add(dto); | ||
442 | } | ||
443 | } | ||
444 | } catch (DataAccessException e) { | ||
445 | e.printStackTrace(); | ||
446 | } | ||
447 | //封装数据 | ||
448 | Map<String,List<AlarmDto>> map=alarmDtos.stream().collect(Collectors.groupingBy(AlarmDto::getTime)); | ||
449 | List<String> stringList=map.keySet().stream().collect(Collectors.toList()); | ||
450 | Collections.sort(stringList); | ||
451 | Map<String, Object> qclMap = new HashMap<>(); | ||
452 | for (String s : stringList) { | ||
453 | List<AlarmDto> dtoList=map.get(s); | ||
454 | Double jsV=0d; | ||
455 | Double csV=0d; | ||
456 | for (AlarmDto dto : dtoList) { | ||
457 | if (dto.getName().equals(metricVo1.getId())){ | ||
458 | jsV=Double.valueOf(dto.getV()); | ||
459 | } | 382 | } |
460 | if (dto.getName().equals(metricVo2.getId())){ | 383 | if (dataViewVO2119List != null) { //遍历集合 |
461 | csV=Double.valueOf(dto.getV()); | 384 | for (DataViewVO dataView : dataViewVO2119List) { |
385 | if (month.equals(dataView.getTime())) { | ||
386 | String expressionCod ="(" +dataView.getJSCOD() +"-"+ dataView.getCSAD() +") *100/ "+dataView.getJSCOD(); | ||
387 | cod = JSUtils.executeExpression( expressionCod ,"0.0"); | ||
388 | String expressionAD ="(" +dataView.getJSAD() +"-"+ dataView.getCSAD() +") *100/ "+dataView.getJSAD(); | ||
389 | nh3n = JSUtils.executeExpression( expressionAD ,"0.0"); | ||
390 | String expressionZL ="(" +dataView.getJSZL() +"-"+ dataView.getCSZL() +") *100/ "+dataView.getJSZL(); | ||
391 | tp = JSUtils.executeExpression( expressionZL ,"0.0"); | ||
392 | break; | ||
393 | } | ||
394 | } | ||
462 | } | 395 | } |
396 | |||
397 | trend_dsdh.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( dsdh, "0.0")) ) ; | ||
398 | trend_cod.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( cod, "0.0")) ) ; | ||
399 | trend_nh3n.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( nh3n, "0.0")) ) ; | ||
400 | trend_tp.add( new TonOfWaterTrendDto(month ,ConvertUtils.getString( tp, "0.0")) ) ; | ||
463 | } | 401 | } |
464 | TonOfWaterTrendDto vo1=new TonOfWaterTrendDto(); | ||
465 | vo1.setTime(s); | ||
466 | //污染物去除率=(进水指标(mg/L)-出水指标(mg/L))/进水指标(mg/L)*100%。 | ||
467 | double result=(double)(Math.round((jsV-csV)*100/jsV)/100.0); | ||
468 | vo1.setV(this.getValue(result)+""); | ||
469 | qclMap.put(s,this.getValue(result)+""); | ||
470 | } | 402 | } |
471 | for (String month : months) { | 403 | |
472 | TonOfWaterTrendDto dto=new TonOfWaterTrendDto(); | 404 | |
473 | if(qclMap.get(month)!=null){ | 405 | result.put("DSDH",trend_dsdh); |
474 | dto.setV(qclMap.get(month).toString()); | 406 | result.put("NH3N",trend_nh3n); |
475 | } | 407 | result.put("TP",trend_tp); |
476 | dto.setTime(month); | 408 | result.put("COD",trend_cod); |
477 | dtos.add(dto); | 409 | return result; |
410 | } | ||
411 | |||
412 | |||
413 | |||
414 | /**************************************/ | ||
415 | // 水质水量报表 | ||
416 | private List<DataViewVO> queryDataView2119(String departIds, String startTime, String endTime) { | ||
417 | //ReportConstant.fieldSz = JSZL,CSZL,JSCOD,CSCOD,JSAD,CSAD,JSZD,CSTN,JSPH,JSSS,CSPH,CSSS"; | ||
418 | String dataViewName2119 = ReportViewUtil.buildView(ReportConstant.view2119, ReportConstant.fieldSz, departIds, startTime, endTime); | ||
419 | String sql = " select DATE_FORMAT(aaa.time,'%Y-%m') 'time' , ROUND( SUM( IFNULL(aaa.JSCOD,0) ), 2 ) AS JSCOD, ROUND( SUM( IFNULL(aaa.CSCOD,0) ), 2 ) AS CSCOD,"; | ||
420 | sql += " ROUND( SUM( IFNULL(aaa.JSZL,0) ), 2 ) AS JSZL, ROUND( SUM( IFNULL(aaa.CSZL,0) ), 2 ) AS CSZL,"; | ||
421 | sql += "ROUND( SUM( IFNULL(aaa.JSAD,0) ), 2 ) AS JSAD, ROUND( SUM( IFNULL(aaa.CSAD,0) ), 2 ) AS CSAD "; | ||
422 | sql += "from "+ dataViewName2119 +" aaa "; | ||
423 | sql += " group by DATE_FORMAT(aaa.time,'%Y-%m') "; | ||
424 | |||
425 | //查询数据 | ||
426 | List<DataViewVO> dataViewVO2119List = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<DataViewVO>(DataViewVO.class)); | ||
427 | return dataViewVO2119List; | ||
428 | } | ||
429 | // 负荷率 | ||
430 | private List<ReportItemVO> queryFhlTrendList(String departIds, String startTime, String endTime) { | ||
431 | String dataViewName3a24 = ReportViewUtil.buildView(ReportConstant.view2119,ReportConstant.field_CSL, departIds, startTime, endTime); | ||
432 | String sql = " select bbb.time,ROUND(avg(bbb.wsfhl),2) 'value' from ( "; | ||
433 | sql += " select DATE_FORMAT(aaa.time,'%Y-%m') 'time' ,aaa.depart_id , sum(aaa.CSL) CSL, ROUND( IFNULL( 100 * ( sum(aaa.CSL)/( f.pro_scale * 31*10000 ) ),0), 2 ) AS wsfhl from "+ dataViewName3a24 +" aaa "; | ||
434 | sql += " LEFT JOIN sys_factory_info f ON f.depart_id = aaa.depart_id " ; | ||
435 | sql += " group by DATE_FORMAT(aaa.time,'%Y-%m') , aaa.depart_id "; | ||
436 | sql += ")bbb group by bbb.time "; | ||
437 | //查询数据 | ||
438 | List<ReportItemVO> trendVOList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<ReportItemVO>(ReportItemVO.class)); | ||
439 | |||
440 | return trendVOList; | ||
441 | } | ||
442 | |||
443 | |||
444 | /*** | ||
445 | * 时间 + 吨水电耗处理集合 | ||
446 | * @param departIds | ||
447 | * @param startTime | ||
448 | * @param endTime | ||
449 | * @param isLowFlag true 只显示一条最小吨水电耗、 false显示所有 | ||
450 | * @return | ||
451 | */ | ||
452 | private List<ReportItemVO> queryDSDHTrendList(String departIds, String startTime, String endTime,boolean isLowFlag ) { | ||
453 | String sql = getDSDHSql(departIds, startTime, endTime, isLowFlag); | ||
454 | List<ReportItemVO> trendVOList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<ReportItemVO>(ReportItemVO.class)); | ||
455 | return trendVOList; | ||
456 | } | ||
457 | |||
458 | /*** | ||
459 | * 获取吨水电耗sql语句 | ||
460 | * @return | ||
461 | */ | ||
462 | private String getDSDHSql(String departIds, String startTime, String endTime,boolean isLowFlag){ | ||
463 | String dataViewName2119 = ReportViewUtil.buildView(ReportConstant.view2119,ReportConstant.field_CSL, departIds, startTime, endTime); | ||
464 | String dataViewName3a24 = ReportViewUtil.buildView(ReportConstant.view3a24,ReportConstant.fieldDl, departIds, startTime,endTime); | ||
465 | String sql = " select bbb.time,round(IFNULL( bbb.DLHJ /ddd.CSL,0 ),2) as 'dsValue' ,round(IFNULL( bbb.DLHJ,0 ),2) as 'value' from ( "; | ||
466 | sql += " select DATE_FORMAT(aaa.time,'%Y-%m') 'time' , ROUND(sum(aaa.DLHJ),2) DLHJ from "+dataViewName3a24 +" aaa group by DATE_FORMAT(aaa.time,'%Y-%m') "; | ||
467 | sql += " )bbb "; | ||
468 | sql += " left join ( "; | ||
469 | sql += " select DATE_FORMAT(ccc.time,'%Y-%m') 'time' , ROUND(sum(ccc.CSL),2) CSL from "+dataViewName2119 +" ccc group by DATE_FORMAT(ccc.time,'%Y-%m') "; | ||
470 | sql += " )ddd on bbb.time = ddd.time "; | ||
471 | if(isLowFlag ){ | ||
472 | sql += " order by (bbb.DLHJ - ddd.CSL) limit 1"; | ||
478 | } | 473 | } |
479 | return dtos; | 474 | return sql; |
475 | } | ||
476 | private JdbcTemplate getJdbcTemplate(){ | ||
477 | JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master"); | ||
478 | return masterDB; | ||
480 | } | 479 | } |
481 | 480 | ||
482 | private List<String> getTwelve(String time) { | 481 | private List<String> getTwelve(String time) { |
... | @@ -487,47 +486,6 @@ public class PowerConsumptionAnalusisServiceImpl implements IPowerConsumptionAna | ... | @@ -487,47 +486,6 @@ public class PowerConsumptionAnalusisServiceImpl implements IPowerConsumptionAna |
487 | return list; | 486 | return list; |
488 | } | 487 | } |
489 | 488 | ||
490 | private Map<String, Object> getLower(String factoryId){ | ||
491 | //查询历史最低吨水电耗 | ||
492 | Map<String, Object> result = Maps.newHashMap(); | ||
493 | //查询所有月份的出水流量 v time | ||
494 | List<AlarmDto> csList = comprehensiveSupervisionMapper.selectAllClsl(factoryId); | ||
495 | //查询所有月份的耗电量 | ||
496 | List<AlarmDto> dhList=comprehensiveSupervisionMapper.selectAllDh(factoryId); | ||
497 | Map<String,String> csMap=csList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
498 | Map<String,String> dhMap=dhList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
499 | List<String> list=csMap.keySet().stream().collect(Collectors.toList()); | ||
500 | Double mindsdh=null; | ||
501 | String mintime=new String(); | ||
502 | for (String s : list) { | ||
503 | //查询当前吨水电耗 | ||
504 | String cs=csMap.get(s); | ||
505 | if (dhMap.get(s)!=null){ | ||
506 | String dh=dhMap.get(s); | ||
507 | Double dsdh=Double.parseDouble(dh)/Double.parseDouble(cs); | ||
508 | if (mindsdh==null){ | ||
509 | mindsdh=dsdh; | ||
510 | mintime=s; | ||
511 | }else { | ||
512 | if (mindsdh>dsdh){ | ||
513 | mindsdh=dsdh; | ||
514 | mintime=s; | ||
515 | } | ||
516 | } | ||
517 | } | ||
518 | } | ||
519 | result.put("mindsdh",mindsdh); | ||
520 | result.put("mintime",mintime); | ||
521 | return result; | ||
522 | } | ||
523 | |||
524 | |||
525 | private Double getValue(Double d) { | ||
526 | BigDecimal two = new BigDecimal(d); | ||
527 | double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); | ||
528 | return three; | ||
529 | } | ||
530 | |||
531 | private String getMonthBytime(int i,String time) { | 489 | private String getMonthBytime(int i,String time) { |
532 | SimpleDateFormat format=new SimpleDateFormat("yyyy-MM"); | 490 | SimpleDateFormat format=new SimpleDateFormat("yyyy-MM"); |
533 | Calendar calendar = Calendar.getInstance(); | 491 | Calendar calendar = Calendar.getInstance(); |
... | @@ -539,4 +497,10 @@ public class PowerConsumptionAnalusisServiceImpl implements IPowerConsumptionAna | ... | @@ -539,4 +497,10 @@ public class PowerConsumptionAnalusisServiceImpl implements IPowerConsumptionAna |
539 | calendar.add(Calendar.MONTH, i); | 497 | calendar.add(Calendar.MONTH, i); |
540 | return format.format(calendar.getTime()); | 498 | return format.format(calendar.getTime()); |
541 | } | 499 | } |
500 | private Double getValue(Double d) { | ||
501 | BigDecimal two = new BigDecimal(d); | ||
502 | double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); | ||
503 | return three; | ||
504 | } | ||
505 | |||
542 | } | 506 | } | ... | ... |
1 | /* | ||
2 | package com.skua.modules.equipment.service.impl; | ||
3 | |||
4 | import com.google.common.collect.Maps; | ||
5 | import com.skua.common.constant.ReportConstant; | ||
6 | import com.skua.common.report.ReportViewUtil; | ||
7 | import com.skua.common.report.vo.ReportItemVO; | ||
8 | import com.skua.core.context.SpringContextUtils; | ||
9 | import com.skua.modules.equipment.dto.*; | ||
10 | import com.skua.modules.equipment.mapper.ComprehensiveSupervisionMapper; | ||
11 | import com.skua.modules.equipment.service.IPowerConsumptionAnalysisService; | ||
12 | import com.skua.modules.equipment.vo.AnysisParamsVO; | ||
13 | import com.skua.modules.equipment.vo.MetricVo; | ||
14 | import com.skua.tool.util.JSUtils; | ||
15 | import lombok.extern.slf4j.Slf4j; | ||
16 | import org.apache.shiro.dao.DataAccessException; | ||
17 | import org.springframework.jdbc.core.JdbcTemplate; | ||
18 | import org.springframework.stereotype.Service; | ||
19 | |||
20 | import javax.annotation.Resource; | ||
21 | import java.math.BigDecimal; | ||
22 | import java.text.ParseException; | ||
23 | import java.text.SimpleDateFormat; | ||
24 | import java.util.*; | ||
25 | import java.util.stream.Collectors; | ||
26 | |||
27 | @Slf4j | ||
28 | @Service | ||
29 | public class PowerConsumptionAnalusisServiceImplBak implements IPowerConsumptionAnalysisService { | ||
30 | |||
31 | @Resource | ||
32 | private ComprehensiveSupervisionMapper comprehensiveSupervisionMapper; | ||
33 | @Override | ||
34 | public Map<String, Object> dataDisplay(AnysisParamsVO anysisParamsVO) { | ||
35 | String time = anysisParamsVO.getTime(); | ||
36 | String factoryId = anysisParamsVO.getFactoryId(); | ||
37 | String startTime = time+"-01" ; | ||
38 | String endTime = time + "-31"; | ||
39 | Map<String, Object> result = Maps.newHashMap(); | ||
40 | //目标吨水电耗 | ||
41 | result.put("mbdsdh","0.65"); | ||
42 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | ||
43 | result.put("zhdl","-"); | ||
44 | result.put("dsdh","-"); | ||
45 | result.put("tbqnzhdl","-"); | ||
46 | result.put("hbsyzhdl","-"); | ||
47 | result.put("mindsdh","-"); | ||
48 | result.put("mindsdhyf","-"); | ||
49 | result.put("tbqnzhdlsl","-"); | ||
50 | result.put("tbqnzhdlbl","-"); | ||
51 | result.put("hbsyzhdlsl","-"); | ||
52 | result.put("hbsyzhdlbl","-"); | ||
53 | result.put("tbqndsdhsl","-"); | ||
54 | result.put("tbqndsdhbl","-"); | ||
55 | result.put("hbsydsdhsl","-"); | ||
56 | result.put("hbsydsdhbl","-"); | ||
57 | return result; | ||
58 | }else{ | ||
59 | factoryId = anysisParamsVO.getFactoryId(); | ||
60 | } | ||
61 | //总耗电量 | ||
62 | List<String> months=new ArrayList<>(); | ||
63 | months.add(time); | ||
64 | //String dataViewName3a24_value = ReportViewUtil.buildViewLike(ReportConstant.view2119,fields, departIds, startTime,endTime); | ||
65 | ReportItemVO dlhjReportVO = ReportViewUtil.getSumValueByTBHB(ReportConstant.view3a24,ReportConstant.fieldDl, factoryId, startTime,endTime); | ||
66 | result.put("zhdl", JSUtils.divide(dlhjReportVO.getValue(),10000)); | ||
67 | result.put("tbqnzhdl",JSUtils.divide(dlhjReportVO.getValueTb(),10000)); | ||
68 | result.put("hbsyzhdl",JSUtils.divide(dlhjReportVO.getValueHb(),10000)); | ||
69 | |||
70 | //吨水电耗 | ||
71 | ReportItemVO cslReportVO = ReportViewUtil.getSumValueByTBHB(ReportConstant.view2119,ReportConstant.field_CSL, factoryId, startTime,endTime);//出水量 | ||
72 | result.put("dsdh", JSUtils.divide(dlhjReportVO.getValue(),cslReportVO.getValue())); | ||
73 | result.put("tbqndsdh", JSUtils.divide(dlhjReportVO.getValue(),cslReportVO.getValueTb())); | ||
74 | result.put("hbsydsdh", JSUtils.divide(dlhjReportVO.getValue(),cslReportVO.getValueHb())); | ||
75 | |||
76 | |||
77 | //4 历史最低吨水电耗 | ||
78 | List<ReportItemVO> dsdhList = ReportViewUtil.getDateValueByDS(ReportConstant.view3a24,ReportConstant.fieldDl, factoryId, startTime,endTime,1,true);//吨水电耗集合 | ||
79 | if(dsdhList != null && !dsdhList.isEmpty()){ | ||
80 | result.put("mindsdh",dsdhList.get(0).getDsValue()); | ||
81 | result.put("mindsdhyf",dsdhList.get(0).getTime()); | ||
82 | } | ||
83 | result.put("tbqnzhdlsl", JSUtils.subtract(result.get("zhdl"),result.get("tbqnzhdl"))); | ||
84 | result.put("tbqnzhdlbl",JSUtils.divide( result.get("tbqnzhdlsl") , result.get("tbqnzhdl"))); | ||
85 | |||
86 | */ | ||
87 | /*if (result.get("zhdl")!=null&&result.get("tbqnzhdl")!=null){ | ||
88 | Double dsdh=Double.parseDouble(result.get("zhdl")+""); | ||
89 | Double tbqnzhdl=Double.parseDouble(result.get("tbqnzhdl")+""); | ||
90 | result.put("tbqnzhdlsl",this.getValue(dsdh-tbqnzhdl)); | ||
91 | if (Double.compare(tbqnzhdl, 0.0) == 0) { | ||
92 | result.put("tbqnzhdlbl", 0.0); | ||
93 | } else { | ||
94 | result.put("tbqnzhdlbl",this.getValue(((dsdh-tbqnzhdl)/tbqnzhdl)*100)); | ||
95 | } | ||
96 | }*//* | ||
97 | |||
98 | result.put("hbsyzhdlsl", JSUtils.subtract(result.get("zhdl"),result.get("hbsyzhdl"))); | ||
99 | result.put("hbsyzhdlbl",JSUtils.divide( result.get("hbsyzhdlbl") , result.get("hbsyzhdl"))); | ||
100 | |||
101 | */ | ||
102 | /*if (result.get("zhdl")!=null&&result.get("hbsyzhdl")!=null){ | ||
103 | Double dsdh=Double.parseDouble(result.get("zhdl")+""); | ||
104 | Double hbsyzhdl=Double.parseDouble(result.get("hbsyzhdl")+""); | ||
105 | result.put("hbsyzhdlsl",this.getValue(dsdh-hbsyzhdl)); | ||
106 | if (Double.compare(hbsyzhdl, 0.0) == 0) { | ||
107 | result.put("hbsyzhdlbl", 0.0); | ||
108 | } else { | ||
109 | result.put("hbsyzhdlbl",this.getValue(((dsdh-hbsyzhdl)/hbsyzhdl)*100)); | ||
110 | } | ||
111 | }*//* | ||
112 | |||
113 | |||
114 | result.put("tbqndsdhsl", JSUtils.subtract(result.get("dsdh"),result.get("tbqndsdh"))); | ||
115 | result.put("tbqndsdhbl",JSUtils.multiply(JSUtils.divide( result.get("tbqndsdhsl") , result.get("tbqndsdh")),100)); | ||
116 | |||
117 | */ | ||
118 | /*if (result.get("dsdh")!=null&&result.get("tbqndsdh")!=null){ | ||
119 | Double dsdh=Double.parseDouble(result.get("dsdh")+""); | ||
120 | Double tbqndsdh=Double.parseDouble(result.get("tbqndsdh")+""); | ||
121 | result.put("tbqndsdhsl",this.getValue(dsdh-tbqndsdh)); | ||
122 | if (Double.compare(tbqndsdh, 0.0) == 0) { | ||
123 | result.put("tbqndsdhbl", 0.0); | ||
124 | } else { | ||
125 | result.put("tbqndsdhbl",this.getValue(((dsdh-tbqndsdh)/tbqndsdh)*100)); | ||
126 | } | ||
127 | }*//* | ||
128 | |||
129 | |||
130 | result.put("hbsydsdhsl", JSUtils.subtract(result.get("dsdh"),result.get("hbsydsdh"))); | ||
131 | result.put("hbsydsdhbl",JSUtils.multiply(JSUtils.divide( result.get("hbsydsdhsl") , result.get("hbsydsdh")),100)); | ||
132 | */ | ||
133 | /*if (result.get("dsdh")!=null&&result.get("hbsydsdh")!=null){ | ||
134 | Double dsdh=Double.parseDouble(result.get("dsdh")+""); | ||
135 | Double hbqndsdh=Double.parseDouble(result.get("hbsydsdh")+""); | ||
136 | result.put("hbsydsdhsl",this.getValue(dsdh-hbqndsdh)); | ||
137 | if (Double.compare(hbqndsdh, 0.0) == 0) { | ||
138 | result.put("hbsydsdhbl", 0.0); | ||
139 | } else { | ||
140 | result.put("hbsydsdhbl",this.getValue(((dsdh-hbqndsdh)/hbqndsdh)*100)); | ||
141 | } | ||
142 | }*//* | ||
143 | |||
144 | return result; | ||
145 | } | ||
146 | |||
147 | @Override | ||
148 | public Map<String, Object> powerConsumptionTrend(AnysisParamsVO anysisParamsVO) { | ||
149 | String time = anysisParamsVO.getTime(); | ||
150 | List<String> months=this.getTwelve(time); | ||
151 | List<powerConsumptionTrendDto> dtos=new ArrayList<>();//封装数据 | ||
152 | Map<String, Object> result = Maps.newHashMap(); | ||
153 | String factoryId = anysisParamsVO.getFactoryId(); | ||
154 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | ||
155 | for (String month : months) { | ||
156 | powerConsumptionTrendDto dto=new powerConsumptionTrendDto(); | ||
157 | dto.setTime(month); | ||
158 | dtos.add(dto); | ||
159 | } | ||
160 | result.put("data", dtos); | ||
161 | return result; | ||
162 | }else{ | ||
163 | factoryId = anysisParamsVO.getFactoryId(); | ||
164 | } | ||
165 | //查询当前时间往前推12个月的数据 | ||
166 | String startTime=this.getMonthBytime(-12,time); | ||
167 | String endTime=this.getMonthBytime(-1,time); | ||
168 | List<AlarmDto> current=comprehensiveSupervisionMapper.selectDhByStartAndEnd(startTime,endTime,factoryId); | ||
169 | Map<String,String> currMap=current.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
170 | String yesStartTime=this.getMonthBytime(-12,startTime); | ||
171 | String yesEndTime=this.getMonthBytime(-1,startTime); | ||
172 | List<AlarmDto> yes=comprehensiveSupervisionMapper.selectDhByStartAndEnd(yesStartTime,yesEndTime,factoryId); | ||
173 | Map<String,String> yesMap=yes.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
174 | for (String month : months) { | ||
175 | String yesmonth=this.getMonthBytime(-12,month); | ||
176 | powerConsumptionTrendDto dto=new powerConsumptionTrendDto(); | ||
177 | dto.setTime(month); | ||
178 | if (currMap.get(month)!=null){ | ||
179 | dto.setZdh(this.getValue(Double.parseDouble(currMap.get(month))/10000).toString()); | ||
180 | } | ||
181 | if (yesMap.get(yesmonth)!=null){ | ||
182 | dto.setTbzdh(this.getValue(Double.parseDouble(yesMap.get(yesmonth))/10000).toString()); | ||
183 | } | ||
184 | dtos.add(dto); | ||
185 | } | ||
186 | result.put("data",dtos); | ||
187 | return result; | ||
188 | } | ||
189 | |||
190 | @Override | ||
191 | public Map<String, Object> tonOfWaterTrend(AnysisParamsVO anysisParamsVO) { | ||
192 | List<TonOfWaterTrendDto> dtos=new ArrayList<>();//封装数据 | ||
193 | String time = anysisParamsVO.getTime(); | ||
194 | //查询前推十二个月的数据 | ||
195 | List<String> months=this.getTwelve(time); | ||
196 | Map<String, Object> result = Maps.newHashMap(); | ||
197 | String factoryId = anysisParamsVO.getFactoryId(); | ||
198 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | ||
199 | for (String month : months) { | ||
200 | TonOfWaterTrendDto dto=new TonOfWaterTrendDto(); | ||
201 | dto.setTime(month); | ||
202 | dtos.add(dto); | ||
203 | } | ||
204 | result.put("data",dtos); | ||
205 | return result; | ||
206 | }else{ | ||
207 | factoryId = anysisParamsVO.getFactoryId(); | ||
208 | } | ||
209 | List<AlarmDto> CSList=new ArrayList<>(); | ||
210 | List<Map<String, Object>> monitorList2 = comprehensiveSupervisionMapper.selectClslByMonths(months,factoryId); | ||
211 | if (monitorList2.size()>0){ | ||
212 | for (Map<String, Object> map : monitorList2) { | ||
213 | AlarmDto dto=new AlarmDto(); | ||
214 | dto.setV(map.get("v").toString()); | ||
215 | dto.setTime(map.get("time").toString()); | ||
216 | CSList.add(dto); | ||
217 | } | ||
218 | } | ||
219 | List<AlarmDto> DHList=comprehensiveSupervisionMapper.selectDhByMonths(months,factoryId); | ||
220 | Map<String,String> csMap=CSList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
221 | Map<String,String> dhMap=DHList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
222 | for (String month : months) { | ||
223 | TonOfWaterTrendDto dto=new TonOfWaterTrendDto(); | ||
224 | dto.setTime(month); | ||
225 | if (dhMap.get(month)!=null){ | ||
226 | String v=dhMap.get(month); | ||
227 | if (csMap.get(month)!=null){ | ||
228 | //本月累计电耗量[kW·h]/本月累计处理水量[吨] | ||
229 | dto.setV(this.getValue((Double.parseDouble(v)/(Double.parseDouble(csMap.get(month)))))+""); | ||
230 | } | ||
231 | } | ||
232 | dtos.add(dto); | ||
233 | } | ||
234 | result.put("data",dtos); | ||
235 | return result; | ||
236 | } | ||
237 | |||
238 | @Override | ||
239 | public Map<String, Object> tonOfWaterAndLoadRate(AnysisParamsVO anysisParamsVO) throws Exception{ | ||
240 | //封装数据 | ||
241 | List<TonOfWaterAndLoadRateDto> dtos = new ArrayList<>(); | ||
242 | String time = anysisParamsVO.getTime(); | ||
243 | //查询前推十二个月的数据 | ||
244 | List<String> months=this.getTwelve(time); | ||
245 | //查询吨水电耗 | ||
246 | Map<String, Object> result = Maps.newHashMap(); | ||
247 | String factoryId = anysisParamsVO.getFactoryId(); | ||
248 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | ||
249 | for (String month : months) { | ||
250 | TonOfWaterAndLoadRateDto dto=new TonOfWaterAndLoadRateDto(); | ||
251 | dto.setTime(month); | ||
252 | dtos.add(dto); | ||
253 | } | ||
254 | result.put("data",dtos); | ||
255 | return result; | ||
256 | }else{ | ||
257 | factoryId = anysisParamsVO.getFactoryId(); | ||
258 | } | ||
259 | List<Map<String, Object>> monitorList2 = comprehensiveSupervisionMapper.selectClslByMonths(months,factoryId); | ||
260 | List<AlarmDto> CSList=new ArrayList<>(); | ||
261 | if (monitorList2.size()>0){ | ||
262 | for (Map<String, Object> map : monitorList2) { | ||
263 | AlarmDto dto=new AlarmDto(); | ||
264 | dto.setV(map.get("v").toString()); | ||
265 | dto.setTime(map.get("time").toString()); | ||
266 | CSList.add(dto); | ||
267 | } | ||
268 | } | ||
269 | //查询设计规模 | ||
270 | String sjgm=comprehensiveSupervisionMapper.selectSJGM(factoryId); | ||
271 | //封装数据 | ||
272 | List<AlarmDto> DHList=comprehensiveSupervisionMapper.selectDhByMonths(months,factoryId); | ||
273 | Map<String,String> csMap=CSList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
274 | Map<String,String> dhMap=DHList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
275 | for (String month : months) { | ||
276 | TonOfWaterAndLoadRateDto dto=new TonOfWaterAndLoadRateDto(); | ||
277 | dto.setTime(month); | ||
278 | if (dhMap.get(month)!=null){ | ||
279 | String v=dhMap.get(month); | ||
280 | if (csMap.get(month)!=null){ | ||
281 | //本月累计电耗量[kW·h]/本月累计处理水量[吨] | ||
282 | dto.setDsdh(this.getValue((Double.parseDouble(v)/(Double.parseDouble(csMap.get(month))))).toString()); | ||
283 | //负荷率 | ||
284 | Calendar calendar = Calendar.getInstance(); | ||
285 | SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM"); | ||
286 | calendar.setTime(sdf.parse(time)); | ||
287 | Integer num = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); | ||
288 | //负荷率=该月的日均处理水量/设计规模 | ||
289 | dto.setFhl(this.getValue(Double.parseDouble(csMap.get(month))/(Double.valueOf(sjgm)*num*10000)).toString()); | ||
290 | } | ||
291 | } | ||
292 | dtos.add(dto); | ||
293 | } | ||
294 | result.put("data",dtos); | ||
295 | return result; | ||
296 | } | ||
297 | |||
298 | @Override | ||
299 | public Map<String, Object> tonOfWaterAndPollutantConcentration(AnysisParamsVO anysisParamsVO) { | ||
300 | String time = anysisParamsVO.getTime(); | ||
301 | //查询前推十二个月的数据 | ||
302 | List<String> months = this.getTwelve(time); | ||
303 | Map<String, Object> result = Maps.newHashMap(); | ||
304 | String[] strings={"JSCOD","CSCOD","CSNH3N","JSNH3N","JSTP","CSTP"}; | ||
305 | String factoryId = anysisParamsVO.getFactoryId(); | ||
306 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | ||
307 | List<PollutantConcentrationDto> dtodsdh = new ArrayList<>(); | ||
308 | for (String month :months) { | ||
309 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | ||
310 | dto.setTime(month); | ||
311 | dtodsdh.add(dto); | ||
312 | } | ||
313 | result.put("DSDH", dtodsdh); | ||
314 | for (String string : strings) { | ||
315 | List<PollutantConcentrationDto> dtos1 = new ArrayList<>(); | ||
316 | for (String month :months) { | ||
317 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | ||
318 | dto.setTime(month); | ||
319 | dtos1.add(dto); | ||
320 | } | ||
321 | result.put(string, dtos1); | ||
322 | } | ||
323 | return result; | ||
324 | }else{ | ||
325 | factoryId = anysisParamsVO.getFactoryId(); | ||
326 | } | ||
327 | //查询吨水电耗 | ||
328 | String device=comprehensiveSupervisionMapper.selectDeviceName(factoryId); | ||
329 | JdbcTemplate pgDb = (JdbcTemplate) SpringContextUtils.getBean("pg-db"); | ||
330 | String tableName=device+"_count"; | ||
331 | //吨水电耗 | ||
332 | result.put("DSDH",this.tonOfWaterTrend(anysisParamsVO).get("data")); | ||
333 | for (String string : strings) { | ||
334 | MetricVo metricVo = comprehensiveSupervisionMapper.selectMetric(string,factoryId); | ||
335 | List<PollutantConcentrationDto> dtos1 = new ArrayList<>(); | ||
336 | if(metricVo==null){ | ||
337 | for (String month :months) { | ||
338 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | ||
339 | dto.setTime(month); | ||
340 | dtos1.add(dto); | ||
341 | } | ||
342 | result.put(string, dtos1); | ||
343 | }else { | ||
344 | StringBuilder str = new StringBuilder(); | ||
345 | str.append("'" + metricVo.getId() + "'"); | ||
346 | String sql1 = "select avg(cast(v as float8)) as v,substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8) as time\n" + | ||
347 | " FROM " + tableName + "\n" + | ||
348 | "where nm in (" + str.toString() + ") \n" + | ||
349 | "and substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)<='" + months.get(11) + "'\n" + | ||
350 | "and substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)>='" + months.get(0) + "'\n" + | ||
351 | "GROUP BY substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)"; | ||
352 | List<Map<String, Object>> monitorList = null; | ||
353 | try { | ||
354 | monitorList = pgDb.queryForList(sql1); | ||
355 | Map<String, Object> monitorMap = new HashMap<>(); | ||
356 | if (monitorList.size() > 0) { | ||
357 | for (Map<String, Object> map : monitorList) { | ||
358 | monitorMap.put(map.get("time").toString(),this.getValue(Double.parseDouble(map.get("v").toString())).toString()); | ||
359 | } | ||
360 | for (String month : months) { | ||
361 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | ||
362 | if(monitorMap.get(month)!=null){ | ||
363 | dto.setV(monitorMap.get(month).toString()); | ||
364 | } | ||
365 | dto.setTime(month); | ||
366 | dtos1.add(dto); | ||
367 | } | ||
368 | }else{ | ||
369 | for (String month :months) { | ||
370 | PollutantConcentrationDto dto = new PollutantConcentrationDto(); | ||
371 | dto.setTime(month); | ||
372 | dtos1.add(dto); | ||
373 | } | ||
374 | } | ||
375 | result.put(string, dtos1); | ||
376 | } catch (DataAccessException e) { | ||
377 | e.printStackTrace(); | ||
378 | } | ||
379 | } | ||
380 | } | ||
381 | return result; | ||
382 | } | ||
383 | |||
384 | @Override | ||
385 | public Map<String, Object> tonOfWaterAndPollutantRemovalRate(AnysisParamsVO anysisParamsVO) { | ||
386 | String time = anysisParamsVO.getTime(); | ||
387 | //查询近12个月的数据 | ||
388 | List<String> months=this.getTwelve(time); | ||
389 | Map<String, Object> result = Maps.newHashMap(); | ||
390 | String factoryId = anysisParamsVO.getFactoryId(); | ||
391 | if(anysisParamsVO.getFactoryId()==null||"".equals(anysisParamsVO.getFactoryId())){ | ||
392 | result.put("DSDH",this.tonOfWaterTrend(anysisParamsVO).get("data"));//吨水电耗 | ||
393 | result.put("COD",this.getRemovalRate("","",null,null,months,factoryId)); | ||
394 | result.put("NH3N",this.getRemovalRate("","",null,null,months,factoryId)); | ||
395 | result.put("TP",this.getRemovalRate("","",null,null,months,factoryId)); | ||
396 | return result; | ||
397 | }else{ | ||
398 | factoryId = anysisParamsVO.getFactoryId(); | ||
399 | } | ||
400 | String device=comprehensiveSupervisionMapper.selectDeviceName(factoryId); | ||
401 | JdbcTemplate pgDb = (JdbcTemplate) SpringContextUtils.getBean("pg-db"); | ||
402 | String tableName=device+"_count"; | ||
403 | //吨水电耗 | ||
404 | result.put("DSDH",this.tonOfWaterTrend(anysisParamsVO).get("data")); | ||
405 | //计算去除率 | ||
406 | List<TonOfWaterTrendDto> analyVos=this.getRemovalRate("JSCOD","CSCOD",pgDb,tableName,months,factoryId); | ||
407 | result.put("COD",analyVos); | ||
408 | List<TonOfWaterTrendDto> analyVos1=this.getRemovalRate("JSNH3N","CSNH3N",pgDb,tableName,months,factoryId); | ||
409 | result.put("NH3N",analyVos1); | ||
410 | List<TonOfWaterTrendDto> analyVos2=this.getRemovalRate("JSTP","CSTP",pgDb,tableName,months,factoryId); | ||
411 | result.put("TP",analyVos2); | ||
412 | return result; | ||
413 | } | ||
414 | |||
415 | private List<TonOfWaterTrendDto> getRemovalRate(String jscod, String cscod, JdbcTemplate pgDb, String tableName, List<String> months, String factoryId) { | ||
416 | List<TonOfWaterTrendDto> dtos=new ArrayList<>(); | ||
417 | MetricVo metricVo1 = comprehensiveSupervisionMapper.selectMetric(jscod,factoryId); | ||
418 | if(metricVo1==null){ | ||
419 | for (String month :months) { | ||
420 | TonOfWaterTrendDto dto=new TonOfWaterTrendDto(); | ||
421 | dto.setTime(month); | ||
422 | dtos.add(dto); | ||
423 | } | ||
424 | return dtos; | ||
425 | } | ||
426 | StringBuilder str1 = new StringBuilder(); | ||
427 | MetricVo metricVo2 = comprehensiveSupervisionMapper.selectMetric(cscod,factoryId); | ||
428 | if(metricVo2==null){ | ||
429 | str1.append("'" + metricVo1.getId() + "'"); | ||
430 | }else{ | ||
431 | str1.append("'" + metricVo1.getId() + "'"+","+"'" + metricVo2.getId() + "'"); | ||
432 | } | ||
433 | String sql="select avg(cast(v as float8)) as v,nm,\n" + | ||
434 | "substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8) as time\n" + | ||
435 | " FROM " + tableName + "\n" + | ||
436 | "where nm in (" + str1.toString() + ") \n" + | ||
437 | "and substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)<='"+months.get(11)+"'\n" + | ||
438 | "and substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8)>='"+months.get(0)+"'\n" + | ||
439 | "GROUP BY substring(to_char ( to_timestamp ( to_number ( ts, '9999999999' ) ), 'yyyy-MM-dd HH24:MI:SS' ),0,8),nm"; | ||
440 | List<Map<String, Object>> monitorList1 = null; | ||
441 | List<AlarmDto> alarmDtos=new ArrayList<>(); | ||
442 | try { | ||
443 | monitorList1 = pgDb.queryForList(sql); | ||
444 | if (monitorList1.size()>0){ | ||
445 | for (Map<String, Object> map : monitorList1) { | ||
446 | AlarmDto dto=new AlarmDto(); | ||
447 | dto.setName(map.get("nm").toString()); | ||
448 | dto.setTime(map.get("time").toString()); | ||
449 | dto.setV(map.get("v").toString()); | ||
450 | alarmDtos.add(dto); | ||
451 | } | ||
452 | } | ||
453 | } catch (DataAccessException e) { | ||
454 | e.printStackTrace(); | ||
455 | } | ||
456 | //封装数据 | ||
457 | Map<String,List<AlarmDto>> map=alarmDtos.stream().collect(Collectors.groupingBy(AlarmDto::getTime)); | ||
458 | List<String> stringList=map.keySet().stream().collect(Collectors.toList()); | ||
459 | Collections.sort(stringList); | ||
460 | Map<String, Object> qclMap = new HashMap<>(); | ||
461 | for (String s : stringList) { | ||
462 | List<AlarmDto> dtoList=map.get(s); | ||
463 | Double jsV=0d; | ||
464 | Double csV=0d; | ||
465 | for (AlarmDto dto : dtoList) { | ||
466 | if (dto.getName().equals(metricVo1.getId())){ | ||
467 | jsV=Double.valueOf(dto.getV()); | ||
468 | } | ||
469 | if (dto.getName().equals(metricVo2.getId())){ | ||
470 | csV=Double.valueOf(dto.getV()); | ||
471 | } | ||
472 | } | ||
473 | TonOfWaterTrendDto vo1=new TonOfWaterTrendDto(); | ||
474 | vo1.setTime(s); | ||
475 | //污染物去除率=(进水指标(mg/L)-出水指标(mg/L))/进水指标(mg/L)*100%。 | ||
476 | double result=(double)(Math.round((jsV-csV)*100/jsV)/100.0); | ||
477 | vo1.setV(this.getValue(result)+""); | ||
478 | qclMap.put(s,this.getValue(result)+""); | ||
479 | } | ||
480 | for (String month : months) { | ||
481 | TonOfWaterTrendDto dto=new TonOfWaterTrendDto(); | ||
482 | if(qclMap.get(month)!=null){ | ||
483 | dto.setV(qclMap.get(month).toString()); | ||
484 | } | ||
485 | dto.setTime(month); | ||
486 | dtos.add(dto); | ||
487 | } | ||
488 | return dtos; | ||
489 | } | ||
490 | |||
491 | private List<String> getTwelve(String time) { | ||
492 | List<String> list=new ArrayList<>(); | ||
493 | for (int i=12;i>=1;i--){ | ||
494 | list.add(this.getMonthBytime(-i,time)); | ||
495 | } | ||
496 | return list; | ||
497 | } | ||
498 | |||
499 | private Map<String, Object> getLower(String factoryId){ | ||
500 | //查询历史最低吨水电耗 | ||
501 | Map<String, Object> result = Maps.newHashMap(); | ||
502 | //查询所有月份的出水流量 v time | ||
503 | List<AlarmDto> csList = comprehensiveSupervisionMapper.selectAllClsl(factoryId); | ||
504 | //查询所有月份的耗电量 | ||
505 | List<AlarmDto> dhList=comprehensiveSupervisionMapper.selectAllDh(factoryId); | ||
506 | Map<String,String> csMap=csList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
507 | Map<String,String> dhMap=dhList.stream().collect(Collectors.toMap(AlarmDto::getTime, AlarmDto::getV,(k1, k2)->k1)); | ||
508 | List<String> list=csMap.keySet().stream().collect(Collectors.toList()); | ||
509 | Double mindsdh=null; | ||
510 | String mintime=new String(); | ||
511 | for (String s : list) { | ||
512 | //查询当前吨水电耗 | ||
513 | String cs=csMap.get(s); | ||
514 | if (dhMap.get(s)!=null){ | ||
515 | String dh=dhMap.get(s); | ||
516 | Double dsdh=Double.parseDouble(dh)/Double.parseDouble(cs); | ||
517 | if (mindsdh==null){ | ||
518 | mindsdh=dsdh; | ||
519 | mintime=s; | ||
520 | }else { | ||
521 | if (mindsdh>dsdh){ | ||
522 | mindsdh=dsdh; | ||
523 | mintime=s; | ||
524 | } | ||
525 | } | ||
526 | } | ||
527 | } | ||
528 | result.put("mindsdh",mindsdh); | ||
529 | result.put("mintime",mintime); | ||
530 | return result; | ||
531 | } | ||
532 | |||
533 | |||
534 | private Double getValue(Double d) { | ||
535 | BigDecimal two = new BigDecimal(d); | ||
536 | double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); | ||
537 | return three; | ||
538 | } | ||
539 | |||
540 | private String getMonthBytime(int i,String time) { | ||
541 | SimpleDateFormat format=new SimpleDateFormat("yyyy-MM"); | ||
542 | Calendar calendar = Calendar.getInstance(); | ||
543 | try { | ||
544 | calendar.setTime(format.parse(time)); | ||
545 | } catch (ParseException e) { | ||
546 | e.printStackTrace(); | ||
547 | } | ||
548 | calendar.add(Calendar.MONTH, i); | ||
549 | return format.format(calendar.getTime()); | ||
550 | } | ||
551 | } | ||
552 | */ |
-
请 注册 或 登录 后发表评论