Kaynağa Gözat

日志添加

qiangxuan 7 ay önce
ebeveyn
işleme
e764b233f5

+ 18 - 5
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanEventTriggerWarnTask.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.fpgJob;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.oConvertUtils;
@@ -15,6 +16,8 @@ import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -41,16 +44,18 @@ public class LeanEventTriggerWarnTask {
         LambdaQueryWrapper<FpgGatherData> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(FpgGatherData::getEventWarnState, "0").isNotNull(FpgGatherData::getDeviceInformationId).orderByDesc(FpgGatherData::getCreateTime);
         List<FpgGatherData> fpgGatherDataList = fpgGatherDataService.list(queryWrapper);
+        log.info("{}{}", "FPG采集表数据总数:", fpgGatherDataList.size());
         if (oConvertUtils.listIsNotEmpty(fpgGatherDataList)){
             fpgGatherDataList.forEach(x ->{
                 // 触发告警信息逻辑处理
                 leanEventsHostTriggerWarnHandle(x);
             });
-        }
-        // 逻辑删除已校验完精益事件告警的采集数据,事件告警使用状态0:使用中1:使用结束
-        List<FpgGatherData> updateFpgGatherDataList = fpgGatherDataList.stream().map(s -> s.setEventWarnState("1")).collect(Collectors.toList());
-        if (oConvertUtils.listIsNotEmpty(updateFpgGatherDataList)){
-            fpgGatherDataService.updateBatchById(updateFpgGatherDataList);
+            // 逻辑删除已校验完精益事件告警的采集数据,事件告警使用状态0:使用中1:使用结束
+            List<FpgGatherData> updateFpgGatherDataList = fpgGatherDataList.stream().map(s -> s.setEventWarnState("1")).collect(Collectors.toList());
+            if (oConvertUtils.listIsNotEmpty(updateFpgGatherDataList)){
+                log.info("{}{}", "FPG采集表数据使用结束总数:", fpgGatherDataList.size());
+                fpgGatherDataService.updateBatchById(updateFpgGatherDataList);
+            }
         }
     }
 
@@ -70,6 +75,10 @@ public class LeanEventTriggerWarnTask {
                 // 根据主设备ID查询多条精益事件设备启停信息 处理事件类型为host_open、host_stop
                 LambdaQueryWrapper<LeanEventsHost> queryLeanEventsHost = new LambdaQueryWrapper<LeanEventsHost>().eq(LeanEventsHost::getDeviceInformationId, fpgGatherData.getDeviceInformationId()).isNotNull(LeanEventsHost::getDeviceInformationType);
                 List<LeanEventsHost> leanEventsHostList =  leanEventsHostService.list(queryLeanEventsHost);
+                if (oConvertUtils.listIsEmpty(leanEventsHostList)){
+                    log.info("{}{}", "deviceInformationMainIds精益事件设备启停配置信息为空:", fpgGatherData.getDeviceInformationId());
+                    return;
+                }
                 leanEventsHostList.forEach(y ->{
                     // 事件类型为host_stop、host_open
                     if (EDeviceInformationType.HOST_OPEN.getCode().equals(y.getDeviceInformationType())){
@@ -88,6 +97,10 @@ public class LeanEventTriggerWarnTask {
             if (exists){
                 // 根据辅设备ID模糊查询多条关于FPG精益事件设备启停信息 处理事件类型为fpg_open、fpg_close、fpg_ing_time、fpg_power_limit
                 List<LeanEventsHost> leanEventsHostList = leanEventsHostService.getFpgLeanEventsHostList(fpgGatherData.getDeviceInformationId());
+                if (oConvertUtils.listIsEmpty(leanEventsHostList)){
+                    log.info("{}{}", "deviceInformationSubIds精益事件设备启停配置信息为空:", fpgGatherData.getDeviceInformationId());
+                    return;
+                }
                 leanEventsHostList.forEach(s ->{
                     // 事件类型为 fpg_open
                     if (EDeviceInformationType.FPG_OPEN.getCode().equals(s.getDeviceInformationType())){

+ 18 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/impl/LeanEventWarnInfoServiceImpl.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.leanEventWarn.service.impl;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
 import org.jeecg.modules.common.enums.EDeviceInformationType;
 import org.jeecg.modules.events.entity.LeanEventsHost;
 import org.jeecg.modules.gatherData.entity.FpgStatiscsModelMongodb;
@@ -23,6 +25,7 @@ import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -44,6 +47,7 @@ import java.util.stream.Collectors;
  * @Date:   2024-10-29
  * @Version: V1.0
  */
+@Slf4j
 @Service
 public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoMapper, LeanEventWarnInfo> implements ILeanEventWarnInfoService {
 
@@ -60,6 +64,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
     ISystemVariableService systemVariableService;
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void openDeviceTriggerWarnInfo(FpgGatherData fpgGatherData) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
@@ -73,6 +78,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         queryWrapper.eq("status",  0);
         SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
         if (systemVariable == null){
+            log.info("{}{}", "host_open系统变量未配置正常状态的运行电流限制!", JSON.toJSON(fpgGatherData));
             return;
         }
         BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
@@ -88,6 +94,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void stopDeviceTriggerWarnInfo(FpgGatherData fpgGatherData) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
@@ -100,6 +107,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         queryWrapper.eq("status",  0);
         SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
         if (systemVariable == null){
+            log.info("{}{}", "host_stop系统变量未配置正常状态的运行电流限制!", JSON.toJSON(fpgGatherData));
             return;
         }
         BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
@@ -114,6 +122,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void openFpgTriggerWarnInfo(FpgGatherData fpgGatherData) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
@@ -135,6 +144,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         queryWrapper.eq("status",  0);
         SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
         if (systemVariable == null){
+            log.info("{}{}", "fpg_open系统变量未配置正常状态的运行电流限制!", JSON.toJSON(fpgGatherData));
             return;
         }
         BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
@@ -202,6 +212,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void closeFpgTriggerWarnInfo(FpgGatherData fpgGatherData) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
@@ -225,6 +236,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         queryWrapper.eq("status",  0);
         SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
         if (systemVariable == null){
+            log.info("{}{}", "fpg_close系统变量未配置正常状态的运行电流限制!", JSON.toJSON(fpgGatherData));
             return;
         }
         BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
@@ -270,6 +282,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void runTimeTriggerWarnInfo(FpgGatherData fpgGatherData, LeanEventsHost leanEventsHost) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
@@ -283,6 +296,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
                 .eq(LeanEventsHostConfig::getEventsId, leanEventsHost.getEventsId()).eq(LeanEventsHostConfig::getLimitType, "0");
         LeanEventsHostConfig leanEventsHostConfig = leanEventsHostConfigService.list(queryWrapper).stream().findFirst().orElse(null);
         if (leanEventsHostConfig == null){
+            log.info("{}{}", "fpg_ing_time精益事件配置关联表查询为空!", "设备ID:" +fpgGatherData.getDeviceInformationId() + "事件ID:" + leanEventsHost.getEventsId());
             return;
         }
         // 获取峰平谷配置的时段
@@ -301,6 +315,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         // 根据类型、采集点ID、设备ID、区域ID、峰平谷配置时间范围查询mongoDB
         List<FpgStatiscsModelMongodb> fpgStatiscsModelDataList = queryByTimeRanges(mongoTemplate, timeRanges, fpgGatherData.getDevicePointId(), fpgGatherData.getDeviceInformationId(), fpgGatherData.getDeviceRegionId());
         if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList) ){
+            log.info("{}{}", "fpg_ing_time峰平谷数据采集FpgStatiscsModelMongodb查询为空!", "设备ID:" +fpgGatherData.getDeviceInformationId() + "采集点ID:" + fpgGatherData.getDevicePointId()+ "区域ID:" + fpgGatherData.getDevicePointId());
             return;
         }
         // 判断MongoDB中的累加运行时长是否大于 LeanEventsHostConfig中的尖峰平谷运行限制时长
@@ -353,6 +368,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void powerLimitTriggerWarnInfo(FpgGatherData fpgGatherData, LeanEventsHost leanEventsHost) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
@@ -366,6 +382,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
                 .eq(LeanEventsHostConfig::getEventsId, leanEventsHost.getEventsId()).eq(LeanEventsHostConfig::getLimitType, "1");
         LeanEventsHostConfig leanEventsHostConfig = leanEventsHostConfigService.list(queryWrapper).stream().findFirst().orElse(null);
         if (leanEventsHostConfig == null){
+            log.info("{}{}", "fpg_power_limit精益事件配置关联表查询为空!", "设备ID:" +fpgGatherData.getDeviceInformationId() + "事件ID:" + leanEventsHost.getEventsId());
             return;
         }
         // 获取峰平谷配置的时段
@@ -384,6 +401,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         // 根据类型、采集点ID、设备ID、区域ID、峰平谷配置时间范围查询mongoDB
         List<FpgStatiscsModelMongodb> fpgStatiscsModelDataList = queryByTimeRanges(mongoTemplate, timeRanges, fpgGatherData.getDevicePointId(), fpgGatherData.getDeviceInformationId(), fpgGatherData.getDeviceRegionId());
         if (oConvertUtils.listIsEmpty(fpgStatiscsModelDataList) ){
+            log.info("{}{}", "fpg_power_limit峰平谷数据采集FpgStatiscsModelMongodb查询为空!", "设备ID:" +fpgGatherData.getDeviceInformationId() + "采集点ID:" + fpgGatherData.getDevicePointId()+ "区域ID:" + fpgGatherData.getDevicePointId());
             return;
         }
         // 判断MongoDB中的累加运行时长是否大于 LeanEventsHostConfig中的尖峰平谷运行限制时长