|
@@ -44,14 +44,13 @@ public class MonitorBusiness {
|
44
|
44
|
@Autowired
|
45
|
45
|
private RedisTemplate<String, Object> redisTemplate;
|
46
|
46
|
|
47
|
|
- private List<OutletAndFactorVo> dataAcquisitionInstruments = new ArrayList<>();
|
48
|
47
|
|
49
|
48
|
|
50
|
49
|
@PostConstruct
|
51
|
50
|
public void loadData() {
|
52
|
|
- dataAcquisitionInstruments =
|
53
|
|
- dataAcquisitionInstrumentService.selectlist();
|
54
|
|
- System.out.println(dataAcquisitionInstruments);
|
|
51
|
+
|
|
52
|
+ List<OutletAndFactorVo> selectlist = dataAcquisitionInstrumentService.selectlist();
|
|
53
|
+ redisTemplate.opsForValue().set("dataAcquisitionInstruments", JSON.toJSONString(selectlist));
|
55
|
54
|
// 处理读取到的数据
|
56
|
55
|
}
|
57
|
56
|
|
|
@@ -116,52 +115,54 @@ public class MonitorBusiness {
|
116
|
115
|
listData.add(airMonitorMinuteRecord);
|
117
|
116
|
});
|
118
|
117
|
airMonitorMinuteRecordService.saveBatch(listData);
|
119
|
|
- } else if (factorModel.getCN().equals(Constant.REAL)) {
|
120
|
|
- // 分钟数据入库
|
121
|
|
- List<AirMonitorMinuteRecord> listData = new ArrayList<>();
|
122
|
|
- cp.forEach(x -> {
|
123
|
|
- AirMonitorMinuteRecord airMonitorMinuteRecord = new AirMonitorMinuteRecord();
|
124
|
|
- airMonitorMinuteRecord.setQn(factorModel.getQN());
|
125
|
|
- airMonitorMinuteRecord.setSt(factorModel.getST());
|
126
|
|
- airMonitorMinuteRecord.setCn(factorModel.getCN());
|
127
|
|
- airMonitorMinuteRecord.setPw(factorModel.getPW());
|
128
|
|
- airMonitorMinuteRecord.setMn(factorModel.getMN());
|
129
|
|
- airMonitorMinuteRecord.setFlag(factorModel.getFlag());
|
130
|
|
- airMonitorMinuteRecord.setDataTime(factorModel.getDataTime());
|
131
|
|
- airMonitorMinuteRecord.setFactor(x.getFactor());
|
132
|
|
- airMonitorMinuteRecord.setMin(x.getMin());
|
133
|
|
- airMonitorMinuteRecord.setMax(x.getMax());
|
134
|
|
- airMonitorMinuteRecord.setAvg(x.getAvg());
|
135
|
|
- airMonitorMinuteRecord.setCou(x.getCou());
|
136
|
|
- airMonitorMinuteRecord.setFactorFlag(x.getFlag());
|
137
|
|
- airMonitorMinuteRecord.setZsAvg(x.getZsAvg());
|
138
|
|
- airMonitorMinuteRecord.setZsMax(x.getZsMax());
|
139
|
|
- airMonitorMinuteRecord.setZsMin(x.getZsMin());
|
140
|
|
- airMonitorMinuteRecord.setRtd(x.getRtd());
|
141
|
|
- try {
|
142
|
|
- airMonitorMinuteRecord.setWorkCondition(sendMessage(factorModel.getDataTime(),factorModel.getMN()));
|
143
|
|
- } catch (ParseException e) {
|
144
|
|
- throw new RuntimeException(e);
|
145
|
|
- }
|
146
|
|
- try {
|
147
|
|
- airMonitorMinuteRecord.setIsExceed(exceptionDataDispose.ExceedData(factorModel.getMN(), x.getFactor(), x.getAvg()!=null?x.getAvg().doubleValue():x.getRtd().doubleValue()));
|
148
|
|
- airMonitorMinuteRecord.setIsLose(exceptionDataDispose.LoseData(x.getMax()!=null?x.getMax().doubleValue():0,
|
149
|
|
- x.getMin()!=null?x.getMin().doubleValue():0,
|
150
|
|
- x.getAvg()!=null?x.getAvg().doubleValue():0));
|
151
|
|
- if ((airMonitorMinuteRecord.getIsExceed()!=null && !airMonitorMinuteRecord.getIsExceed().equals("Y") )||
|
152
|
|
- (airMonitorMinuteRecord.getIsLose()!=null && !airMonitorMinuteRecord.getIsLose().equals("Y") )||
|
153
|
|
- (airMonitorMinuteRecord.getIsSix()!=null && !airMonitorMinuteRecord.getIsSix().equals("Y"))){
|
154
|
|
- saveExcepLog(x, airMonitorMinuteRecord);
|
155
|
|
- }
|
156
|
|
- } catch (Exception e) {
|
157
|
|
- log.error("调用 ExceptionDataDispose2 方法异常{} 当前参数为:{}",e,airMonitorMinuteRecord);
|
158
|
|
- }
|
159
|
|
- listData.add(airMonitorMinuteRecord);
|
160
|
|
- });
|
161
|
|
- if (!listData.isEmpty()) {
|
162
|
|
- airMonitorMinuteRecordService.saveBatch(listData);
|
163
|
|
- }
|
164
|
|
- } else if (factorModel.getCN().equals(Constant.HOUR)) {
|
|
118
|
+ }
|
|
119
|
+// else if (factorModel.getCN().equals(Constant.REAL)) {
|
|
120
|
+// // 分钟数据入库
|
|
121
|
+// List<AirMonitorMinuteRecord> listData = new ArrayList<>();
|
|
122
|
+// cp.forEach(x -> {
|
|
123
|
+// AirMonitorMinuteRecord airMonitorMinuteRecord = new AirMonitorMinuteRecord();
|
|
124
|
+// airMonitorMinuteRecord.setQn(factorModel.getQN());
|
|
125
|
+// airMonitorMinuteRecord.setSt(factorModel.getST());
|
|
126
|
+// airMonitorMinuteRecord.setCn(factorModel.getCN());
|
|
127
|
+// airMonitorMinuteRecord.setPw(factorModel.getPW());
|
|
128
|
+// airMonitorMinuteRecord.setMn(factorModel.getMN());
|
|
129
|
+// airMonitorMinuteRecord.setFlag(factorModel.getFlag());
|
|
130
|
+// airMonitorMinuteRecord.setDataTime(factorModel.getDataTime());
|
|
131
|
+// airMonitorMinuteRecord.setFactor(x.getFactor());
|
|
132
|
+// airMonitorMinuteRecord.setMin(x.getMin());
|
|
133
|
+// airMonitorMinuteRecord.setMax(x.getMax());
|
|
134
|
+// airMonitorMinuteRecord.setAvg(x.getAvg());
|
|
135
|
+// airMonitorMinuteRecord.setCou(x.getCou());
|
|
136
|
+// airMonitorMinuteRecord.setFactorFlag(x.getFlag());
|
|
137
|
+// airMonitorMinuteRecord.setZsAvg(x.getZsAvg());
|
|
138
|
+// airMonitorMinuteRecord.setZsMax(x.getZsMax());
|
|
139
|
+// airMonitorMinuteRecord.setZsMin(x.getZsMin());
|
|
140
|
+// airMonitorMinuteRecord.setRtd(x.getRtd());
|
|
141
|
+// try {
|
|
142
|
+// airMonitorMinuteRecord.setWorkCondition(sendMessage(factorModel.getDataTime(),factorModel.getMN()));
|
|
143
|
+// } catch (ParseException e) {
|
|
144
|
+// throw new RuntimeException(e);
|
|
145
|
+// }
|
|
146
|
+// try {
|
|
147
|
+// airMonitorMinuteRecord.setIsExceed(exceptionDataDispose.ExceedData(factorModel.getMN(), x.getFactor(), x.getAvg()!=null?x.getAvg().doubleValue():x.getRtd().doubleValue()));
|
|
148
|
+// airMonitorMinuteRecord.setIsLose(exceptionDataDispose.LoseData(x.getMax()!=null?x.getMax().doubleValue():0,
|
|
149
|
+// x.getMin()!=null?x.getMin().doubleValue():0,
|
|
150
|
+// x.getAvg()!=null?x.getAvg().doubleValue():0));
|
|
151
|
+// if ((airMonitorMinuteRecord.getIsExceed()!=null && !airMonitorMinuteRecord.getIsExceed().equals("Y") )||
|
|
152
|
+// (airMonitorMinuteRecord.getIsLose()!=null && !airMonitorMinuteRecord.getIsLose().equals("Y") )||
|
|
153
|
+// (airMonitorMinuteRecord.getIsSix()!=null && !airMonitorMinuteRecord.getIsSix().equals("Y"))){
|
|
154
|
+// saveExcepLog(x, airMonitorMinuteRecord);
|
|
155
|
+// }
|
|
156
|
+// } catch (Exception e) {
|
|
157
|
+// log.error("调用 ExceptionDataDispose2 方法异常{} 当前参数为:{}",e,airMonitorMinuteRecord);
|
|
158
|
+// }
|
|
159
|
+// listData.add(airMonitorMinuteRecord);
|
|
160
|
+// });
|
|
161
|
+// if (!listData.isEmpty()) {
|
|
162
|
+// airMonitorMinuteRecordService.saveBatch(listData);
|
|
163
|
+// }
|
|
164
|
+// }
|
|
165
|
+ else if (factorModel.getCN().equals(Constant.HOUR)) {
|
165
|
166
|
// 小时数据入库
|
166
|
167
|
List<AirMonitorHourRecord> listData = new ArrayList<>();
|
167
|
168
|
cp.forEach(x -> {
|
|
@@ -244,50 +245,52 @@ public class MonitorBusiness {
|
244
|
245
|
listData.add(waterMonitorMinuteRecord);
|
245
|
246
|
});
|
246
|
247
|
waterMonitorMinuteRecordService.saveBatch(listData);
|
247
|
|
- } else if (factorModel.getCN().equals(Constant.REAL)) {
|
248
|
|
- // 分钟数据入库
|
249
|
|
- List<WaterMonitorMinuteRecord> listData = new ArrayList<>();
|
250
|
|
- cp.forEach(x -> {
|
251
|
|
- WaterMonitorMinuteRecord waterMonitorMinuteRecord = new WaterMonitorMinuteRecord();
|
252
|
|
- waterMonitorMinuteRecord.setQn(factorModel.getQN());
|
253
|
|
- waterMonitorMinuteRecord.setSt(factorModel.getST());
|
254
|
|
- waterMonitorMinuteRecord.setCn(factorModel.getCN());
|
255
|
|
- waterMonitorMinuteRecord.setPw(factorModel.getPW());
|
256
|
|
- waterMonitorMinuteRecord.setMn(factorModel.getMN());
|
257
|
|
- waterMonitorMinuteRecord.setFlag(factorModel.getFlag());
|
258
|
|
- waterMonitorMinuteRecord.setDataTime(factorModel.getDataTime());
|
259
|
|
- waterMonitorMinuteRecord.setFactor(x.getFactor());
|
260
|
|
- waterMonitorMinuteRecord.setMin(x.getMin());
|
261
|
|
- waterMonitorMinuteRecord.setMax(x.getMax());
|
262
|
|
- waterMonitorMinuteRecord.setAvg(x.getAvg());
|
263
|
|
- waterMonitorMinuteRecord.setCou(x.getCou());
|
264
|
|
- waterMonitorMinuteRecord.setFactorFlag(x.getFlag());
|
265
|
|
- waterMonitorMinuteRecord.setRtd(x.getRtd());
|
266
|
|
- try {
|
267
|
|
- waterMonitorMinuteRecord.setWorkCondition(sendMessage(factorModel.getDataTime(),factorModel.getMN()));
|
268
|
|
- } catch (ParseException e) {
|
269
|
|
- throw new RuntimeException(e);
|
270
|
|
- }
|
271
|
|
- try {
|
272
|
|
- waterMonitorMinuteRecord.setIsExceed(exceptionDataDispose.ExceedData(factorModel.getMN(), x.getFactor(), x.getAvg()!=null?x.getAvg().doubleValue():x.getRtd().doubleValue()));
|
273
|
|
- waterMonitorMinuteRecord.setIsLose(exceptionDataDispose.LoseData(x.getMax()!=null?x.getMax().doubleValue():0,
|
274
|
|
- x.getMin()!=null?x.getMin().doubleValue():0,
|
275
|
|
- x.getAvg()!=null?x.getAvg().doubleValue():0));
|
276
|
|
- if ((waterMonitorMinuteRecord.getIsExceed()!=null && !waterMonitorMinuteRecord.getIsExceed().equals("Y") )||
|
277
|
|
- (waterMonitorMinuteRecord.getIsLose()!=null && !waterMonitorMinuteRecord.getIsLose().equals("Y") )||
|
278
|
|
- (waterMonitorMinuteRecord.getIsSix()!=null && !waterMonitorMinuteRecord.getIsSix().equals("Y"))){
|
279
|
|
- saveExcepLog(x, waterMonitorMinuteRecord);
|
280
|
|
- }
|
281
|
|
- } catch (Exception e) {
|
282
|
|
- log.error("调用 ExceptionDataDispose5 方法异常{} 当前参数为:{}",e,waterMonitorMinuteRecord);
|
283
|
|
- }
|
284
|
|
-
|
285
|
|
- listData.add(waterMonitorMinuteRecord);
|
286
|
|
- });
|
287
|
|
- if (!listData.isEmpty()) {
|
288
|
|
- waterMonitorMinuteRecordService.saveBatch(listData);
|
289
|
|
- }
|
290
|
|
- } else if
|
|
248
|
+ }
|
|
249
|
+// else if (factorModel.getCN().equals(Constant.REAL)) {
|
|
250
|
+// // 分钟数据入库
|
|
251
|
+// List<WaterMonitorMinuteRecord> listData = new ArrayList<>();
|
|
252
|
+// cp.forEach(x -> {
|
|
253
|
+// WaterMonitorMinuteRecord waterMonitorMinuteRecord = new WaterMonitorMinuteRecord();
|
|
254
|
+// waterMonitorMinuteRecord.setQn(factorModel.getQN());
|
|
255
|
+// waterMonitorMinuteRecord.setSt(factorModel.getST());
|
|
256
|
+// waterMonitorMinuteRecord.setCn(factorModel.getCN());
|
|
257
|
+// waterMonitorMinuteRecord.setPw(factorModel.getPW());
|
|
258
|
+// waterMonitorMinuteRecord.setMn(factorModel.getMN());
|
|
259
|
+// waterMonitorMinuteRecord.setFlag(factorModel.getFlag());
|
|
260
|
+// waterMonitorMinuteRecord.setDataTime(factorModel.getDataTime());
|
|
261
|
+// waterMonitorMinuteRecord.setFactor(x.getFactor());
|
|
262
|
+// waterMonitorMinuteRecord.setMin(x.getMin());
|
|
263
|
+// waterMonitorMinuteRecord.setMax(x.getMax());
|
|
264
|
+// waterMonitorMinuteRecord.setAvg(x.getAvg());
|
|
265
|
+// waterMonitorMinuteRecord.setCou(x.getCou());
|
|
266
|
+// waterMonitorMinuteRecord.setFactorFlag(x.getFlag());
|
|
267
|
+// waterMonitorMinuteRecord.setRtd(x.getRtd());
|
|
268
|
+// try {
|
|
269
|
+// waterMonitorMinuteRecord.setWorkCondition(sendMessage(factorModel.getDataTime(),factorModel.getMN()));
|
|
270
|
+// } catch (ParseException e) {
|
|
271
|
+// throw new RuntimeException(e);
|
|
272
|
+// }
|
|
273
|
+// try {
|
|
274
|
+// waterMonitorMinuteRecord.setIsExceed(exceptionDataDispose.ExceedData(factorModel.getMN(), x.getFactor(), x.getAvg()!=null?x.getAvg().doubleValue():x.getRtd().doubleValue()));
|
|
275
|
+// waterMonitorMinuteRecord.setIsLose(exceptionDataDispose.LoseData(x.getMax()!=null?x.getMax().doubleValue():0,
|
|
276
|
+// x.getMin()!=null?x.getMin().doubleValue():0,
|
|
277
|
+// x.getAvg()!=null?x.getAvg().doubleValue():0));
|
|
278
|
+// if ((waterMonitorMinuteRecord.getIsExceed()!=null && !waterMonitorMinuteRecord.getIsExceed().equals("Y") )||
|
|
279
|
+// (waterMonitorMinuteRecord.getIsLose()!=null && !waterMonitorMinuteRecord.getIsLose().equals("Y") )||
|
|
280
|
+// (waterMonitorMinuteRecord.getIsSix()!=null && !waterMonitorMinuteRecord.getIsSix().equals("Y"))){
|
|
281
|
+// saveExcepLog(x, waterMonitorMinuteRecord);
|
|
282
|
+// }
|
|
283
|
+// } catch (Exception e) {
|
|
284
|
+// log.error("调用 ExceptionDataDispose5 方法异常{} 当前参数为:{}",e,waterMonitorMinuteRecord);
|
|
285
|
+// }
|
|
286
|
+//
|
|
287
|
+// listData.add(waterMonitorMinuteRecord);
|
|
288
|
+// });
|
|
289
|
+// if (!listData.isEmpty()) {
|
|
290
|
+// waterMonitorMinuteRecordService.saveBatch(listData);
|
|
291
|
+// }
|
|
292
|
+// }
|
|
293
|
+ else if
|
291
|
294
|
(factorModel.getCN().equals(Constant.HOUR)) {
|
292
|
295
|
// 小时数据入库
|
293
|
296
|
List<WaterMonitorHourRecord> listData = new ArrayList<>();
|
|
@@ -333,7 +336,7 @@ public class MonitorBusiness {
|
333
|
336
|
|
334
|
337
|
private void saveExcepLog(CP x, AirMonitorMinuteRecord record) {
|
335
|
338
|
ExcepLog excepLog = new ExcepLog();
|
336
|
|
- Optional<OutletAndFactorVo> first = dataAcquisitionInstruments.stream().filter(d ->d.getFactor()!=null && d.getFactor().equals(x.getFactor())).findFirst();
|
|
339
|
+ Optional<OutletAndFactorVo> first = getloadData().stream().filter(d ->d.getFactor()!=null && d.getFactor().equals(x.getFactor())).findFirst();
|
337
|
340
|
if (first.isPresent()) {
|
338
|
341
|
excepLog.setOutletName(first.get().getOutletName());
|
339
|
342
|
excepLog.setOutletCode(first.get().getOutletCode());
|
|
@@ -349,7 +352,7 @@ public class MonitorBusiness {
|
349
|
352
|
|
350
|
353
|
private void saveExcepLog(CP x, AirMonitorHourRecord record) {
|
351
|
354
|
ExcepLog excepLog = new ExcepLog();
|
352
|
|
- Optional<OutletAndFactorVo> first = dataAcquisitionInstruments.stream().filter(d -> d.getFactor()!=null && d.getFactor().equals(x.getFactor())).findFirst();
|
|
355
|
+ Optional<OutletAndFactorVo> first = getloadData().stream().filter(d -> d.getFactor()!=null && d.getFactor().equals(x.getFactor())).findFirst();
|
353
|
356
|
if (first.isPresent()) {
|
354
|
357
|
excepLog.setOutletName(first.get().getOutletName());
|
355
|
358
|
excepLog.setOutletCode(first.get().getOutletCode());
|
|
@@ -364,7 +367,7 @@ public class MonitorBusiness {
|
364
|
367
|
|
365
|
368
|
private void saveExcepLog(CP x, WaterMonitorMinuteRecord record) {
|
366
|
369
|
ExcepLog excepLog = new ExcepLog();
|
367
|
|
- Optional<OutletAndFactorVo> first = dataAcquisitionInstruments.stream().filter(d ->d.getFactor()!=null && d.getFactor().equals(x.getFactor())).findFirst();
|
|
370
|
+ Optional<OutletAndFactorVo> first = getloadData().stream().filter(d ->d.getFactor()!=null && d.getFactor().equals(x.getFactor())).findFirst();
|
368
|
371
|
if (first.isPresent()) {
|
369
|
372
|
excepLog.setOutletName(first.get().getOutletName());
|
370
|
373
|
excepLog.setOutletCode(first.get().getOutletCode());
|
|
@@ -378,7 +381,7 @@ public class MonitorBusiness {
|
378
|
381
|
}
|
379
|
382
|
private void saveExcepLog(CP x, WaterMonitorHourRecord record) {
|
380
|
383
|
ExcepLog excepLog = new ExcepLog();
|
381
|
|
- Optional<OutletAndFactorVo> first = dataAcquisitionInstruments.stream().filter(d -> d.getFactor()!=null && d.getFactor().equals(x.getFactor())).findFirst();
|
|
384
|
+ Optional<OutletAndFactorVo> first = getloadData().stream().filter(d -> d.getFactor()!=null && d.getFactor().equals(x.getFactor())).findFirst();
|
382
|
385
|
if (first.isPresent()) {
|
383
|
386
|
excepLog.setOutletName(first.get().getOutletName());
|
384
|
387
|
excepLog.setOutletCode(first.get().getOutletCode());
|
|
@@ -403,4 +406,19 @@ public class MonitorBusiness {
|
403
|
406
|
}
|
404
|
407
|
return 1;
|
405
|
408
|
}
|
|
409
|
+ /**
|
|
410
|
+ * 获取工厂排口信息
|
|
411
|
+ */
|
|
412
|
+ private List<OutletAndFactorVo> getloadData() {
|
|
413
|
+ List<OutletAndFactorVo> dataAcquisitionInstruments = new ArrayList<>();
|
|
414
|
+ Object o = redisTemplate.opsForValue().get("dataAcquisitionInstruments");
|
|
415
|
+ if (o != null){
|
|
416
|
+ dataAcquisitionInstruments = JSON.parseArray(o.toString(), OutletAndFactorVo.class);
|
|
417
|
+ }else {
|
|
418
|
+ dataAcquisitionInstruments = dataAcquisitionInstrumentService.selectlist();
|
|
419
|
+ redisTemplate.opsForValue().set("dataAcquisitionInstruments", JSON.toJSONString(dataAcquisitionInstruments));
|
|
420
|
+ }
|
|
421
|
+ return dataAcquisitionInstruments;
|
|
422
|
+ }
|
|
423
|
+
|
406
|
424
|
}
|