e8480097 康伟

kangwei: 重构电耗分析相关接口,数据查询将pg数据改为日报报数

1 个父辈 4914a3cd
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
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!