瀏覽代碼

Merge branch 'master' into fpg-master

guoqiang 6 月之前
父節點
當前提交
b85923a35b

+ 16 - 0
jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -814,4 +814,20 @@ public class DateUtils extends PropertyEditorSupport {
         return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR);
     }
 
+    /**
+     * 日期加 8小时
+     * @param date
+     * @param hours
+     * @return
+     */
+    public static Date addHours(Date date, int hours) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.HOUR, hours);
+        return calendar.getTime();
+    }
+
+    public static void main(String[] args) {
+        System.out.println(addHours(new Date(), 8));;
+    }
 }

+ 32 - 10
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,11 @@ 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.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -36,21 +42,23 @@ public class LeanEventTriggerWarnTask {
     @Autowired
     ILeanEventWarnInfoService leanEventWarnInfoService;
 
-    @Scheduled(cron = "0 */1 * * * *")
+    @Scheduled(cron = "0 */2 * * * *")
     public void leanEventTriggerWarnHandle(){
         LambdaQueryWrapper<FpgGatherData> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(FpgGatherData::getEventWarnState, "0").isNotNull(FpgGatherData::getDeviceInformationId).orderByDesc(FpgGatherData::getCreateTime);
+        queryWrapper.isNull(FpgGatherData::getEventWarnUpdatetime).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.setEventWarnUpdatetime(new Date())).collect(Collectors.toList());
+            if (oConvertUtils.listIsNotEmpty(updateFpgGatherDataList)){
+                log.info("{}{}", "FPG采集表数据使用结束总数:", fpgGatherDataList.size());
+                fpgGatherDataService.updateBatchById(updateFpgGatherDataList);
+            }
         }
     }
 
@@ -70,6 +78,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 +100,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())){
@@ -114,13 +130,19 @@ public class LeanEventTriggerWarnTask {
     /**
      * 峰平谷采集数据 过期数据定时删除
      */
-    @Scheduled(cron = "0 0/60 * * * ?")
+    @Scheduled(cron = "0 0 3 * * *")
     public void removeFpgGatherDataHandle(){
         LambdaQueryWrapper<FpgGatherData> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(FpgGatherData::getEventWarnState, "1").eq(FpgGatherData::getFpgModelState, "1");
+        // 获取当前时间并减去一周的时间
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime oneWeekAgo = now.minusWeeks(1);
+        // 将LocalDateTime转换为Date类型(因为数据库字段是Date类型)
+        Date oneWeekAgoAsDate = Date.from(oneWeekAgo.atZone(ZoneId.systemDefault()).toInstant());
+        // 设置查询条件,查询eventWarnUpdatetime一周之前的数据
+        queryWrapper.lt(FpgGatherData::getEventWarnUpdatetime, oneWeekAgoAsDate);
         List<FpgGatherData>  fpgGatherDataList = fpgGatherDataService.list(queryWrapper);
         if (oConvertUtils.listIsNotEmpty(fpgGatherDataList)){
-            fpgGatherDataService.updateBatchById(fpgGatherDataList);
+            fpgGatherDataService.removeBatchByIds(fpgGatherDataList);
         }
     }
 }

+ 3 - 5
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -180,7 +180,7 @@ public class LeanModelStatistics {
                     // 功率
                     BigDecimal runPower = fpgGatherData.getActivePower();
                     // 运行时常
-                    BigDecimal runTime = new BigDecimal("3000");
+                    BigDecimal runTime = new BigDecimal("300");
                     // 电流
                     BigDecimal selectricCurrent = fpgGatherData.getRunCurrent();
                     // 设备启停统计 start
@@ -401,7 +401,7 @@ public class LeanModelStatistics {
                         BigDecimal activePower = fpgGatherData.getActivePower() == null ? new BigDecimal("0.00") : fpgGatherData.getActivePower().divide(new BigDecimal("12"));
                         // 电流
                         BigDecimal selectricCurrent = fpgGatherData.getRunCurrent() == null ? new BigDecimal("0.00") : fpgGatherData.getRunCurrent();
-                        BigDecimal runTime = new BigDecimal("3000");
+                        BigDecimal runTime = new BigDecimal("300");
                         BigDecimal oldPower = fpgStatiscsModelMongo.getPower() == null ? new BigDecimal("0.00") : fpgStatiscsModelMongo.getPower();
                         BigDecimal oldingTime = fpgStatiscsModelMongo.getIngTime() == null ? new BigDecimal("0.00") : fpgStatiscsModelMongo.getIngTime();
                         // 总运行时间处理
@@ -505,9 +505,7 @@ public class LeanModelStatistics {
             });
         });
         // 数据处理完成标记已完成信息,以免重复处理
-        fpgGatherUpdateList.forEach(fpgGatherData -> {
-            fpgGatherDataService.updateById(fpgGatherData);
-        });
+        fpgGatherDataService.updateBatchById(fpgGatherUpdateList);
     }
 
     /**

+ 4 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/entity/FpgLeanModel.java

@@ -118,4 +118,8 @@ public class FpgLeanModel implements Serializable {
     @Excel(name = "设备ID集合", width = 15)
     @ApiModelProperty(value = "设备ID集合")
     private String deviceInformationIds;
+    /**大屏编码*/
+    @Excel(name = "大屏编码", width = 15)
+    @ApiModelProperty(value = "大屏编码")
+    private String largeScreenCode;
 }

+ 4 - 3
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgGatherData.java

@@ -96,8 +96,9 @@ public class FpgGatherData implements Serializable {
     @ApiModelProperty(value = "峰平谷模型使用完成更新")
     private java.util.Date fpgModelUpdatetime;
 
+
     /**峰平谷类型*/
-    @Excel(name = "事件告警使用状态", width = 15, dicCode = "event_warn_state")
-    @ApiModelProperty(value = "事件告警使用状态0:使用中1:使用结束")
-    private java.lang.String eventWarnState;
+    @Excel(name = "事件告警使用状态", width = 15)
+    @ApiModelProperty(value = "事件告警使用状态")
+    private Date eventWarnUpdatetime;
 }

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

@@ -1,5 +1,8 @@
 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.common.util.DateUtils;
 import org.jeecg.modules.common.enums.EDeviceInformationType;
 import org.jeecg.modules.events.entity.LeanEventsHost;
 import org.jeecg.modules.gatherData.entity.FpgStatiscsModelMongodb;
@@ -23,6 +26,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;
@@ -32,10 +36,7 @@ import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -44,6 +45,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 +62,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 +76,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 +92,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,12 +105,13 @@ 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());
         if (fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
             // 上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("HOST_CLOSE状态下,辅设备电流大于5A,触发告警!");
+            leanEventWarnInfo.setDeviceWarnInfo("HOST_CLOSE状态下,辅设备电流大于" + limitCurrent + "A,触发告警!");
             leanEventWarnInfo.setWarnType(EDeviceInformationType.HOST_STOP.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
             // 更新或者新增逻辑处理
@@ -114,6 +120,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 +142,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());
@@ -146,7 +154,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         boolean topsIsExit = topsNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
         if (topsIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) < 0){
             // 采集到的数据电流小于5A,上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,尖时段采集到的数据电流小于5A,触发告警!");
+            leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,尖时段采集到的数据电流小于" + limitCurrent + "A,触发告警!");
             leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
             // 更新或者新增逻辑处理
@@ -155,7 +163,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         boolean peaksIsExit = peaksNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
         if (peaksIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) < 0){
             // 采集到的数据电流小于5A,上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,峰时段采集到的数据电流小于5A,触发告警!");
+            leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,峰时段采集到的数据电流小于" + limitCurrent + "A,触发告警!");
             leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
             // 更新或者新增逻辑处理
@@ -164,7 +172,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         boolean flatIsExit = flatNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
         if (flatIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) < 0){
             // 采集到的数据电流小于5A,上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,平时段采集到的数据电流小于5A,触发告警!");
+            leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,平时段采集到的数据电流小于" + limitCurrent + "A,触发告警!");
             leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
             // 更新或者新增逻辑处理
@@ -173,7 +181,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         boolean valleysIsExit = valleysNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
         if (valleysIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) < 0){
             // 采集到的数据电流小于5A,上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,谷时段采集到的数据电流小于5A,触发告警!");
+            leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,谷时段采集到的数据电流小于" + limitCurrent + "A,触发告警!");
             leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
             // 更新或者新增逻辑处理
@@ -202,6 +210,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 +234,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());
@@ -234,7 +244,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         boolean topsIsExit = topsNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
         if (topsIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
             // 采集到的数据电流大于5A,上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发告警!");
+            leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,尖采集到的数据电流大于" + limitCurrent + "A,触发告警!");
             leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
             // 更新或者新增逻辑处理
@@ -243,7 +253,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         boolean peaksIsExit = peaksNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
         if (peaksIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
             // 采集到的数据电流大于5A,上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发告警!");
+            leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,峰采集到的数据电流大于" + limitCurrent + "A,触发告警!");
             leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
             // 更新或者新增逻辑处理
@@ -252,7 +262,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         boolean flatIsExit = flatNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
         if (flatIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
             // 采集到的数据电流大于5A,上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发告警!");
+            leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,平采集到的数据电流大于" + limitCurrent + "A,触发告警!");
             leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
             // 更新或者新增逻辑处理
@@ -261,7 +271,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         boolean valleysIsExit = valleysNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
         if (valleysIsExit && fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
             // 采集到的数据电流大于5A,上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发精益事件告警!");
+            leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,谷采集到的数据电流大于" + limitCurrent + "A,触发告警!");
             leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
             // 更新或者新增逻辑处理
@@ -270,6 +280,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 +294,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 +313,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中的尖峰平谷运行限制时长
@@ -310,7 +323,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
                     .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
             if (topsIngTimeSum.intValue() > runTimeLimit){
                 // 尖——累加运行时长超过限制时长,触发告警
-                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,尖运行时长超过限制时长,触发告警!");
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,尖运行时长超过限制时长" + runTimeLimit + ",触发告警!");
                 leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
                 // 更新或者新增逻辑处理
@@ -321,7 +334,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
                     .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
             if (peaksIngTimeSum.intValue() > runTimeLimit){
                 // 峰——累加运行时长超过限制时长,触发告警
-                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,峰运行时长超过限制时长,触发告警!");
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,峰运行时长超过限制时长" + runTimeLimit + ",触发告警!");
                 leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
                 // 更新或者新增逻辑处理
@@ -332,7 +345,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
                     .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
             if (flatIngTimeSum.intValue() > runTimeLimit){
                 // 平——累加运行时长超过限制时长,触发告警
-                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,平运行时长超过限制时长,触发告警!");
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,平运行时长超过限制时长" + runTimeLimit + ",触发告警!");
                 leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
                 // 更新或者新增逻辑处理
@@ -343,7 +356,7 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
                     .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
             if (valleysIngTimeSum.intValue() > runTimeLimit){
                 // 谷——累加运行时长超过限制时长,触发告警
-                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,谷运行时长超过限制时长,触发告警!");
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,谷运行时长超过限制时长" + runTimeLimit + ",触发告警!");
                 leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
                 // 更新或者新增逻辑处理
@@ -353,6 +366,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 +380,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,49 +399,46 @@ 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中的尖峰平谷运行限制时长
         int powerLimit = Integer.parseInt(leanEventsHostConfig.getPowerLimit());
         if("tops".equals(leanEventsHost.getDeviceInformationId())){
-            BigDecimal topsPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getTopsPower)
-                    .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
+            BigDecimal topsPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getTopsPower).reduce(BigDecimal.ZERO, BigDecimal::add);
             if (topsPowerLimitSum.intValue() > powerLimit){
                 // 尖——累加累计功率超过功率限制,触发告警
-                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,尖累计功率超过功率限制,触发告警!");
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,尖累计功率超过功率限制" + powerLimit +"A,触发告警!");
                 leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
                 // 更新或者新增逻辑处理
                 saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
         }else if ("peaks".equals(leanEventsHost.getDeviceInformationId())){
-            BigDecimal peaksPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getPeaksPower)
-                    .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
+            BigDecimal peaksPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getPeaksPower).reduce(BigDecimal.ZERO, BigDecimal::add);
             if (peaksPowerLimitSum.intValue() > powerLimit){
                 // 峰——累加累计功率超过功率限制,触发告警
-                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,峰累计功率超过功率限制,触发告警!");
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,峰累计功率超过功率限制" + powerLimit +"A,触发告警!");
                 leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
                 // 更新或者新增逻辑处理
                 saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
         }else if ("flat".equals(leanEventsHost.getDeviceInformationId())){
-            BigDecimal flatPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getFlatPower)
-                    .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
+            BigDecimal flatPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getFlatPower).reduce(BigDecimal.ZERO, BigDecimal::add);
             if (flatPowerLimitSum.intValue() > powerLimit){
                 // 平——累加累计功率超过功率限制,触发告警
-                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,平累计功率超过功率限制,触发告警!");
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,平累计功率超过功率限制" + powerLimit +"A,触发告警!");
                 leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
                 // 更新或者新增逻辑处理
                 saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
         } else if ("valleys".equals(leanEventsHost.getDeviceInformationId())) {
-            BigDecimal valleysPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getValleysPower)
-                    .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
+            BigDecimal valleysPowerLimitSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getValleysPower).reduce(BigDecimal.ZERO, BigDecimal::add);
             if (valleysPowerLimitSum.intValue() > powerLimit){
                 // 谷——累加累计功率超过功率限制,触发告警
-                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,谷累计功率超过功率限制,触发精益事件告警!");
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,谷累计功率超过功率限制" + powerLimit +"A,触发告警!");
                 leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
                 // 更新或者新增逻辑处理
@@ -446,29 +458,25 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
      */
     public List<FpgStatiscsModelMongodb> queryByTimeRanges(MongoTemplate mongoTemplate, List<Date[]> timeRanges, String devicePointId, String deviceInformationId, String deviceRegionId) {
         Query query = new Query();
-        query.addCriteria(Criteria.where("devicePointId").is(devicePointId));
+        String devicePointIds = Arrays.stream(devicePointId.split(",")).collect(Collectors.joining("|"));
+        // 设置devicePointId的查询条件,使用正则表达式
+        query.addCriteria(Criteria.where("devicePointId").regex(devicePointIds));
         query.addCriteria(Criteria.where("deviceInformationId").is(deviceInformationId));
         query.addCriteria(Criteria.where("deviceRegionId").is(deviceRegionId));
         // 使用Criteria添加多个时间范围条件
         for (int i = 0; i < timeRanges.size(); i++) {
             Date startTime = timeRanges.get(i)[0];
-            // 加8小时
-            Calendar calendar1 = Calendar.getInstance();
-            calendar1.setTime(startTime);
-            calendar1.add(Calendar.HOUR, 8);
-            Date specifiedTimePlus8HoursStartTime = calendar1.getTime();
             Date endTime = timeRanges.get(i)[1];
-            Calendar calendar2 = Calendar.getInstance();
-            calendar2.setTime(endTime);
-            calendar2.add(Calendar.HOUR, 8);
-            Date specifiedTimePlus8HoursStartEndTime = calendar2.getTime();
+            // 加8小时
+            Date specifiedTimePlus8HoursStartTime = DateUtils.addHours(startTime, 8);
+            Date specifiedTimePlus8HoursStartEndTime = DateUtils.addHours(endTime, 8);
             query.addCriteria(Criteria.where("createTime").gte(specifiedTimePlus8HoursStartTime).lt(specifiedTimePlus8HoursStartEndTime));
         }
+        log.info("{}{}", "查询FpgStatiscsModelMongodb模型参数:", query);
         // 执行查询
         List<FpgStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, FpgStatiscsModelMongodb.class, "leanmodel_run_power_current_minute");
         return fpgStatiscsModelDataList;
     }
-
     /**
      * 处理峰平谷的配置,并拼接开始时间和结束时间
      * @param peaksAndValleysTimeConfigParam

+ 0 - 2
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java

@@ -160,8 +160,6 @@ public class OpcGatherWatch {
                         fpgGatherData.setVoltage(new BigDecimal(10)); // 电压
                         fpgGatherData.setActivePower(new BigDecimal(10)); // 有功功率
                         fpgGatherData.setRunCurrent(new BigDecimal(10)); // 运行电流
-                        fpgGatherData.setFpgModelState("0"); // 尖峰平谷模型使用状态
-                        fpgGatherData.setEventWarnState("0"); // 事件触发使用状态
                         fpgGatherData.setCreateTime(curentDate); // 创建时间
                         fpgGatherDataService.save(fpgGatherData);
                     }