From 4d4e6c810d99235e97beab7a8cbdbe8706a5e505 Mon Sep 17 00:00:00 2001
From: huangzhen <867217663@qq.com>
Date: Tue, 05 Sep 2023 13:57:25 +0800
Subject: [PATCH] 新增一些功能
---
src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java | 40 +++++++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java
index e7b2837..2cc0b35 100644
--- a/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java
+++ b/src/main/java/com/gkhy/fourierSpecialGasMonitor/service/impl/DataReceiveServiceImpl.java
@@ -127,7 +127,7 @@
return gasCategory;
}).collect(Collectors.toList());
}
- logger.info("【气体异常map】init完成");
+ logger.info("[GasExcMap] init complete");
}
@PostConstruct
@@ -143,7 +143,7 @@
}
}
}
- logger.info("【预警阈值】init完成");
+ logger.info("[WarningThreshold] init complete");
}
@Override
@@ -164,6 +164,7 @@
GasFlux save = gasFluxService.save(gasFlux);
if (save == null)
throw new DataReceiveException(this.getClass(), ForeignResultCode.SYSTEM_ERROR_DATABASE_FAIL.getCode(),"气体通量数据保存失败");
+ gasFluxDataCacheAndPush();
return ForeignResult.success();
}
@@ -193,13 +194,21 @@
push = true;
descs.add(GasFluxStateEnum.INVERSION_FAILED_10_MINUTES_NO_DATA.getDesc());
}
- if (push == true){
- String message = JSON.toJSONString(reqDTO);
- try {
- GasDeviceExcWebsocketServer.sendInfo(message,null);
- } catch (IOException e) {
- logger.info("【警告】设备异常提醒推送>>>>>>>>>>>>>>>>>>失败");
- }
+ String message = JSON.toJSONString(reqDTO);
+ //todo 暂时改为实时推送给前端
+ try {
+ GasDeviceExcWebsocketServer.sendInfo(message,null);
+ } catch (IOException e) {
+ logger.info("【警告】设备异常提醒推送>>>>>>>>>>>>>>>>>>失败");
+ }
+ if (push){
+ //todo 线上环境还是异常才向前端推送
+ //String message = JSON.toJSONString(reqDTO);
+ //try {
+ // GasDeviceExcWebsocketServer.sendInfo(message,null);
+ //} catch (IOException e) {
+ // logger.info("【警告】设备异常提醒推送>>>>>>>>>>>>>>>>>>失败");
+ //}
String execInfo = JSON.toJSONString(descs);
logger.info("【警告】设备异常,异常原因: "+ execInfo);
DeviceExceptionLog log = new DeviceExceptionLog();
@@ -212,7 +221,7 @@
return ForeignResult.success();
}
- private void gasFluxDataCacheAndPush(GasFlux save){
+ private void gasFluxDataCacheAndPush(){
LocalDateTime time = LocalDateTime.now();
LocalDateTime startTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
List<GasFlux> gasFluxes = gasFluxService.listTodayGasFluxData(startTime,time);
@@ -231,7 +240,7 @@
@Override
@Transactional
public ForeignResult uploadGasConcentration(UploadGasConcentrationReqDTO reqDto) {
- //gasConcentrationParameterVerification(reqDto);
+ gasConcentrationParameterVerification(reqDto);
GasConcentration gasConcentration = new GasConcentration();
BeanUtils.copyProperties(reqDto,gasConcentration);
gasConcentration.setDataReceivingTime(LocalDateTime.now());
@@ -279,7 +288,6 @@
Integer count= integer + 1;
gasExcCountMap.put(i,count);
if (yellowWarningThreshold.equals(count)) {
- System.out.println("超过次数: "+count);
warnLogGenerateAndExecPush(WarningThresholdEnum.YELLOW.getCode(), gasCategory.get(i),value);
}
if (redWarningThreshold.equals(count)) {
@@ -356,13 +364,19 @@
}
private void dataCacheAndPush(GasConcentration save){
+ LocalDateTime startTime = LocalDateTime.now().withHour(0).withMinute(0).withSecond(0).withNano(0);
LocalDateTime time = LocalDateTime.now();
String cacheName = time.format(formatter);
RBucket<String> bucket = redissonClient.getBucket(gasConcentrationCachePrefix+cacheName);
String cache = bucket.get();
List<GasConcentration> gasConcentrations = JSON.parseArray(cache,GasConcentration.class);
if (CollectionUtils.isEmpty(gasConcentrations)){
- gasConcentrations = new ArrayList<>();
+ List<GasConcentration> concentrations = gasConcentrationService.listDatabyTimeSlot(startTime, time);
+ if (CollectionUtils.isEmpty(concentrations)){
+ gasConcentrations = new ArrayList<>();
+ }else {
+ gasConcentrations = concentrations;
+ }
gasConcentrations.add(save);
}else {
gasConcentrations.add(save);
--
Gitblit v1.9.2