瀏覽代碼

冲突处理01

qiangxuan 7 月之前
父節點
當前提交
ec5cc08615
共有 31 個文件被更改,包括 1603 次插入333 次删除
  1. 6 4
      jeecg-module-gather/src/main/java/org/jeecg/modules/common/enums/EDeviceInformationType.java
  2. 1 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/dataRepository/entity/PointData.java
  3. 5 3
      jeecg-module-gather/src/main/java/org/jeecg/modules/events/mapper/xml/LeanEventsHostMapper.xml
  4. 145 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanEventTriggerWarnTask.java
  5. 281 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java
  6. 113 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/entity/FpgLeanModel.java
  7. 14 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/mapper/FpgLeanModelMapper.java
  8. 5 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/mapper/xml/FpgLeanModelMapper.xml
  9. 14 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/service/IFpgLeanModelService.java
  10. 18 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/service/impl/FpgLeanModelServiceImpl.java
  11. 0 39
      jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/controller/FpgGatherDataController.java
  12. 37 25
      jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgGatherData.java
  13. 167 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgStatiscsModelData.java
  14. 118 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgStatiscsModelMongodb.java
  15. 25 30
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/entity/LeanEventWarnInfo.java
  16. 78 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/entity/LeanEventsHostConfig.java
  17. 15 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/mapper/LeanEventsHostConfigMapper.java
  18. 5 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/mapper/xml/LeanEventsHostConfigMapper.xml
  19. 8 5
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/ILeanEventWarnInfoService.java
  20. 14 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/ILeanEventsHostConfigService.java
  21. 374 167
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/impl/LeanEventWarnInfoServiceImpl.java
  22. 19 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/impl/LeanEventsHostConfigServiceImpl.java
  23. 81 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/entity/SystemVariable.java
  24. 15 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/mapper/SystemVariableMapper.java
  25. 5 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/mapper/xml/SystemVariableMapper.xml
  26. 14 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/service/ISystemVariableService.java
  27. 19 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/service/impl/SystemVariableServiceImpl.java
  28. 1 1
      jeecg-module-gather/src/main/java/org/jeecg/modules/watch/DbWatch.java
  29. 3 58
      jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java
  30. 1 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/watch/modBusGatherWatch.java
  31. 2 1
      jeecg-module-gather/src/main/java/org/jeecg/modules/watch/s7gatherWatch.java

+ 6 - 4
jeecg-module-gather/src/main/java/org/jeecg/modules/common/enums/EDeviceInformationType.java

@@ -2,10 +2,12 @@ package org.jeecg.modules.common.enums;
 
 public enum EDeviceInformationType {
 
-    HOST_OPEN("host_open", "峰平谷开启"),
-    HOST_STOP("host_stop", "峰平谷关闭"),
-    FPG_OPEN("fpg_open", "主设备开启"),
-    FPG_CLOSE("fpg_close", "主设备关闭");
+    HOST_OPEN("host_open", "主设备开启"),
+    HOST_STOP("host_stop", "主设备关闭"),
+    FPG_OPEN("fpg_open", "峰平谷开启"),
+    FPG_CLOSE("fpg_close", "峰平谷关闭"),
+    FPG_ING_TIME("fpg_ing_time", "峰平谷运行时间"),
+    FPG_POWER_LIMIT("fpg_power_limit", "峰平谷功率限制");
 
     private final String code;
     private final String description;

+ 1 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/dataRepository/entity/PointData.java

@@ -54,6 +54,7 @@ public class PointData  implements Serializable {
     public PointData() {
     }
 
+    // 采集存储数据
     public PointData(DevicePoint point, String freq, String dataText, Date time) {
         this.pointId = point.getId();
         this.deviceId = point.getDeviceId();

+ 5 - 3
jeecg-module-gather/src/main/java/org/jeecg/modules/events/mapper/xml/LeanEventsHostMapper.xml

@@ -6,8 +6,10 @@
         SELECT * FROM
             lean_events_host
         WHERE
-            FIND_IN_SET(#{deviceInformationList}, device_information_list)
-            AND device_information_type = 'fpg_open'
-            OR device_information_type = 'fpg_close';
+                FIND_IN_SET(#{deviceInformationList}, device_information_list)
+                AND device_information_type = 'fpg_open'
+           OR device_information_type = 'fpg_close'
+           OR device_information_type = 'fpg_ing_time'
+           OR device_information_type = 'fpg_power_limit';
     </select>
 </mapper>

+ 145 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanEventTriggerWarnTask.java

@@ -0,0 +1,145 @@
+package org.jeecg.modules.fpgJob;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.common.enums.EDeviceInformationType;
+import org.jeecg.modules.device.service.IDeviceInformationService;
+import org.jeecg.modules.devicePoint.service.IDevicePointService;
+import org.jeecg.modules.events.entity.LeanEventsHost;
+import org.jeecg.modules.events.service.ILeanEventsHostService;
+import org.jeecg.modules.gatherData.entity.FpgGatherData;
+import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
+import org.jeecg.modules.leanEventWarn.entity.LeanEventsHostConfig;
+import org.jeecg.modules.leanEventWarn.service.ILeanEventWarnInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Slf4j
+@EnableAsync
+@Component
+@EnableScheduling
+public class LeanEventTriggerWarnTask {
+
+    @Autowired
+    IDeviceInformationService deviceInformationService;
+
+    @Autowired
+    IDevicePointService devicePointService;
+
+    @Autowired
+    IFpgGatherDataService fpgGatherDataService;
+
+    @Autowired
+    MongoTemplate mongoTemplate;
+
+    @Autowired
+    RedisTemplate redisTemplate;
+
+    @Autowired
+    ILeanEventsHostService leanEventsHostService;
+
+    @Autowired
+    ILeanEventWarnInfoService leanEventWarnInfoService;
+
+    @Scheduled(cron = "0 */1 * * * *")
+    public void leanEventTriggerWarnHandle(){
+        LambdaQueryWrapper<FpgGatherData> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(FpgGatherData::getEventWarnState, "0").isNotNull(FpgGatherData::getDeviceInformationId).orderByDesc(FpgGatherData::getCreateTime);
+        List<FpgGatherData> fpgGatherDataList = fpgGatherDataService.list(queryWrapper);
+        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);
+        }
+    }
+
+
+    /**
+     * 根据采集过来的数据、运行电流、精益事件配置(设备开启、设备关闭、FPG开启、FPG关闭《峰平谷的时间区间配置》),来触发告警信息,并保存
+     * @param fpgGatherData
+     */
+    public void leanEventsHostTriggerWarnHandle(FpgGatherData fpgGatherData){
+        String keyMainString = String.format("sys:opcSynData::%s","deviceInformationMainIds");
+        String keySubString = String.format("sys:opcSynData::%s","deviceInformationSubIds");
+        // 1、根据采集过来的数据,根据主设备ID,处理精益事件配置信息(host_open;host_stop)
+        if (redisTemplate.hasKey(keyMainString)){
+            List<String> deviceInformationIdIds = (List<String>) redisTemplate.opsForValue().get(keyMainString);
+            boolean exists = deviceInformationIdIds.stream().anyMatch(x -> x.contains(fpgGatherData.getDeviceInformationId()));
+            if (exists){
+                // 根据主设备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);
+                leanEventsHostList.forEach(y ->{
+                    // 事件类型为host_stop、host_open
+                    if (EDeviceInformationType.HOST_OPEN.getCode().equals(y.getDeviceInformationType())){
+                        leanEventWarnInfoService.openDeviceTriggerWarnInfo(fpgGatherData);
+                    }
+                    if (EDeviceInformationType.HOST_STOP.getCode().equals(y.getDeviceInformationType())){
+                        leanEventWarnInfoService.stopDeviceTriggerWarnInfo(fpgGatherData);
+                    }
+                });
+            }
+        }
+        // 2、根据采集过来的数据,根据辅设备ID,处理精益事件配置信息3:FPG开,4:FPG关
+        if (redisTemplate.hasKey(keySubString)){
+            List<String> deviceInformationIdList = (List<String>) redisTemplate.opsForValue().get(keySubString);
+            boolean exists = deviceInformationIdList.stream().anyMatch(x -> x.contains(fpgGatherData.getDeviceInformationId()));
+            if (exists){
+                // 根据辅设备ID模糊查询多条关于FPG精益事件设备启停信息 处理事件类型为fpg_open、fpg_close、fpg_ing_time、fpg_power_limit
+                List<LeanEventsHost> leanEventsHostList = leanEventsHostService.getFpgLeanEventsHostList(fpgGatherData.getDeviceInformationId());
+                leanEventsHostList.forEach(s ->{
+                    // 事件类型为 fpg_open
+                    if (EDeviceInformationType.FPG_OPEN.getCode().equals(s.getDeviceInformationType())){
+                        leanEventWarnInfoService.openFpgTriggerWarnInfo(fpgGatherData);
+                    }
+                    // 事件类型为 fpg_close
+                    if (EDeviceInformationType.FPG_CLOSE.getCode().equals(s.getDeviceInformationType())){
+                        leanEventWarnInfoService.closeFpgTriggerWarnInfo(fpgGatherData);
+                    }
+                    // 事件类型为 fpg_ing_time
+                    if (EDeviceInformationType.FPG_ING_TIME.getCode().equals(s.getDeviceInformationType())){
+                        leanEventWarnInfoService.runTimeTriggerWarnInfo(fpgGatherData, s);
+                    }
+                    // 事件类型为 fpg_power_limit
+                    if (EDeviceInformationType.FPG_POWER_LIMIT.getCode().equals(s.getDeviceInformationType())){
+                        leanEventWarnInfoService.powerLimitTriggerWarnInfo(fpgGatherData, s);
+                    }
+                });
+            }
+        }
+    }
+
+
+    /**
+     * 峰平谷采集数据 过期数据定时删除
+     */
+    @Scheduled(cron = "0 0/60 * * * ?")
+    public void removeFpgGatherDataHandle(){
+        LambdaQueryWrapper<FpgGatherData> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(FpgGatherData::getEventWarnState, "1").eq(FpgGatherData::getFpgModelState, "1");
+        List<FpgGatherData>  fpgGatherDataList = fpgGatherDataService.list(queryWrapper);
+        if (oConvertUtils.listIsNotEmpty(fpgGatherDataList)){
+            fpgGatherDataService.updateBatchById(fpgGatherDataList);
+        }
+    }
+}

+ 281 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/LeanModelStatistics.java

@@ -0,0 +1,281 @@
+package org.jeecg.modules.fpgJob;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
+import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
+import org.jeecg.modules.gatherData.entity.FpgGatherData;
+import org.jeecg.modules.gatherData.entity.FpgStatiscsModelData;
+import org.jeecg.modules.gatherData.entity.FpgStatiscsModelMongodb;
+import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
+import org.jeecg.modules.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
+import org.springframework.data.mongodb.core.query.UpdateDefinition;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.time.*;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+@Slf4j
+@EnableAsync
+@Component
+//@EnableScheduling
+public class LeanModelStatistics {
+
+    @Autowired
+    IFpgLeanModelService fpgLeanModelService;
+
+    @Autowired
+    IFpgGatherDataService fpgGatherDataService;
+
+    @Autowired
+    private IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
+
+    @Autowired
+    MongoTemplate mongoTemplate;
+
+    @Autowired
+    RedisTemplate redisTemplate;
+
+    // 每日3点执行 测试期间1ms一次
+//    @Scheduled(cron = "0 0 03 * * *")
+    @Scheduled(fixedDelay = 1000)
+    public void t2(){
+        changeProportion("1000");
+    } // 1ms
+    public void changeProportion(String freq){
+        log.info("变更占比");
+        // 峰平谷精益模型配置获取
+        LambdaQueryWrapper<FpgLeanModel> leanmodelQuery = new LambdaQueryWrapper<FpgLeanModel>().eq(FpgLeanModel::getStatus, "1");
+        List<FpgLeanModel> fpgLeanModellist = fpgLeanModelService.list(leanmodelQuery);
+        LocalDate today = LocalDate.now(); // 获取今天的日期
+        LocalDate yesterday = today.minusDays(1); // 减去一天,得到昨天的日期
+       /* Criteria criteria = new Criteria();
+        criteria.orOperator(Criteria.where("status").is(0),
+                Criteria.where("status").is(1));*/
+        // 处理数据业务逻辑
+        fpgLeanModellist.stream().filter(fpgLeanModeInfo -> fpgLeanModeInfo.getProportion() != null && fpgLeanModeInfo.getProportion() == 1).forEach(fpgLeanModeInfo -> {
+            Query query = new Query();
+            query.addCriteria(Criteria.where("proportion").is(1)).addCriteria(Criteria.where("dates").is(String.valueOf(yesterday)));
+            List<FpgStatiscsModelMongodb> fpgStatiscsModelMongoList = mongoTemplate.find(query, FpgStatiscsModelMongodb.class, "leanmodel_" + fpgLeanModeInfo.getLeanModelCode());
+            BigDecimal zb = new BigDecimal("100");
+            fpgStatiscsModelMongoList.forEach(fpgStatiscsModelMongoInfo -> { // 循环处理采集数据处理
+                BigDecimal proportion = fpgStatiscsModelMongoInfo.getPower();
+                BigDecimal topsProportion = fpgStatiscsModelMongoInfo.getTopsPower();
+                BigDecimal peaksProportion = fpgStatiscsModelMongoInfo.getPeaksPower();
+                BigDecimal flatProportion = fpgStatiscsModelMongoInfo.getFlatPower();
+                BigDecimal valleysProportion = fpgStatiscsModelMongoInfo.getValleysPower();
+                // 核算占比
+                UpdateDefinition update = new Update();
+                ((Update) update).set("proportion", 2);
+                if(topsProportion.compareTo(new BigDecimal("0.00")) > 0) { // 尖
+                    ((Update) update).set("topsProportion", topsProportion.divide(proportion, 2, RoundingMode.HALF_UP).multiply(zb));
+                }
+                if(peaksProportion.compareTo(new BigDecimal("0.00")) > 0) { // 峰
+                    ((Update) update).set("peaksProportion", peaksProportion.divide(proportion, 2, RoundingMode.HALF_UP).multiply(zb));
+                }
+                if(flatProportion.compareTo(new BigDecimal("0.00")) > 0) { // 平
+                    ((Update) update).set("flatProportion", flatProportion.divide(proportion, 2, RoundingMode.HALF_UP).multiply(zb));
+                }
+                if(valleysProportion.compareTo(new BigDecimal("0.00")) > 0) { // 谷
+                    ((Update) update).set("valleysProportion", valleysProportion.divide(proportion, 2, RoundingMode.HALF_UP).multiply(zb));
+                }
+                // 保存
+                mongoTemplate.updateFirst(query, update, FpgStatiscsModelMongodb.class, "leanmodel_" + fpgLeanModeInfo.getLeanModelCode());
+            });
+        });
+    }
+
+    @Scheduled(fixedDelay = 1000)
+    public void t1(){
+        leanModel("1000");
+    } // 1ms
+
+    // 精益模型统计数据
+    public void leanModel(String freq){
+        // 峰平谷精益模型配置获取
+        LambdaQueryWrapper<FpgLeanModel> leanmodelQuery = new LambdaQueryWrapper<FpgLeanModel>().eq(FpgLeanModel::getStatus, "1");
+        List<FpgLeanModel> fpgLeanModellist = fpgLeanModelService.list(leanmodelQuery);
+        log.info("峰平谷模型");
+        // 获取当前时间
+        Date curentDate = new Date(new Date().getTime() + 8 * 60 * 60 * 1000);
+        // 尖峰平谷时段配置
+        List<PeaksAndValleysTimeConfig>  peaksAndValleysTimeConfiglist = peaksAndValleysTimeConfigService.list();
+        //遍历设备集合
+        fpgLeanModellist.forEach(fpgLeanModeInfo -> {
+            LambdaQueryWrapper<FpgGatherData> fpgGatherQuery = new LambdaQueryWrapper<FpgGatherData>().eq(FpgGatherData::getFpgModelState, "0");
+            List<FpgGatherData> fpgGatherList = fpgGatherDataService.list(fpgGatherQuery);
+            // 处理数据业务逻辑
+            fpgGatherList.forEach(fpgGatherData -> { // 循环处理采集数据处理
+                try {
+                    // 变更记录状态
+                    fpgGatherData.setFpgModelState("1");
+                    fpgGatherDataService.updateById(fpgGatherData);
+                    String finalDatestr = "";
+                    // 统计单位
+                    if("minute". equals(fpgLeanModeInfo.getTotalUnit())){ // 分钟
+                        finalDatestr = new SimpleDateFormat("HH:mm").format(fpgGatherData.getCreateTime());
+                    } else if("hour". equals(fpgLeanModeInfo.getTotalUnit())){ // 小时
+                        finalDatestr = new SimpleDateFormat("HH:00").format(fpgGatherData.getCreateTime());
+                    } else if("day". equals(fpgLeanModeInfo.getTotalUnit())){ //
+                        finalDatestr = new SimpleDateFormat("yyyy-MM-dd").format(fpgGatherData.getCreateTime());
+                    } else if("week". equals(fpgLeanModeInfo.getTotalUnit())){ //
+                        Calendar calendar = Calendar.getInstance();
+                        finalDatestr = String.valueOf(calendar.get(Calendar.WEEK_OF_MONTH));
+                    } else if("month". equals(fpgLeanModeInfo.getTotalUnit())){ //
+                        finalDatestr = new SimpleDateFormat("yyyy-MM").format(fpgGatherData.getCreateTime());
+                    }
+                    String dayDate = new SimpleDateFormat("yyyy-MM-dd").format(fpgGatherData.getCreateTime());
+                    String classs = "";
+                    // 采集时间
+                    Instant instant = fpgGatherData.getCreateTime().toInstant();
+                    LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+                    // 班次处理
+                    if (fpgLeanModeInfo.getClassUnit() != null && fpgLeanModeInfo.getClassUnit() == 1) { // 开启了班次统计
+                        if (containsCreateTime(localDateTime, dayDate + " 00:00:00", dayDate + " 07:59:59")) { // 夜班
+                            classs = "night";
+                        } else if (containsCreateTime(localDateTime, dayDate + " 08:00:00", dayDate + " 15:59:59")) { // 白班
+                            classs = "white";
+                        } else if (containsCreateTime(localDateTime, dayDate + " 16:00:00", dayDate + " 23:59:59")) { // 中班
+                            classs = "center";
+                        }
+                    }
+                    // 定义尖峰平谷
+                    AtomicReference<String> jfpgStr = new AtomicReference<>("");
+                    // 判断尖峰平谷时段
+                    peaksAndValleysTimeConfiglist.forEach(peaksAndValleysTimeConfig -> {
+                        if (containsCreateTime(localDateTime, dayDate + " " + peaksAndValleysTimeConfig.getStartTime(), dayDate + " " + peaksAndValleysTimeConfig.getEndTime())) {
+                            jfpgStr.set(peaksAndValleysTimeConfig.getType());
+                            return;
+                        }
+                    });
+                    // 重组对象
+                    FpgStatiscsModelData fpgStatiscsModelData = new FpgStatiscsModelData(fpgGatherData, fpgLeanModeInfo, finalDatestr, dayDate, classs, curentDate, curentDate);
+                    Query query = new Query();
+                    query.addCriteria(Criteria.where("deviceRegionId").is(fpgGatherData.getDeviceRegionId())).addCriteria(Criteria.where("deviceInformationId").is(fpgGatherData.getDeviceInformationId())).addCriteria(Criteria.where("devicePointId").is(fpgGatherData.getDevicePointId())).addCriteria(Criteria.where("dates").is(dayDate)).addCriteria(Criteria.where("datestr").is(finalDatestr));
+                    if(!classs.isEmpty()){ // 增加班次条件
+                        query.addCriteria(Criteria.where("classs").is(classs));
+                    }
+                    FpgStatiscsModelMongodb FpgStatiscsModelMongo = mongoTemplate.findOne(query, FpgStatiscsModelMongodb.class, "leanmodel_" + fpgLeanModeInfo.getLeanModelCode());
+                    if(FpgStatiscsModelMongo != null){ // 不为空处理
+                        // 基础数据变更不受条件影响
+                        UpdateDefinition update = new Update();
+                        ((Update) update).set("updateTime", curentDate);
+                        // 功率
+                        BigDecimal activePower = new BigDecimal(String.valueOf(fpgGatherData.getActivePower()));
+                        BigDecimal runTime = new BigDecimal("1");
+                        BigDecimal oldPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getPower()));
+                        BigDecimal oldingTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getIngTime()));
+                        // 总运行时间处理
+                        if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1) { // 运行时长统计
+                            ((Update) update).set("ingTime", oldingTime.add(runTime));
+                        }
+                        // 总功率处理
+                        ((Update) update).set("power", oldPower.add(activePower));
+                        // 尖峰平谷判定
+                        if("tops".equals(jfpgStr.get())){ // 尖
+                            // 功率处理
+                            BigDecimal oldtopsPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getTopsPower()));
+                            ((Update) update).set("topsPower", oldtopsPower.add(activePower));
+                            // 运行时常处理
+                            if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1){ // 运行时长统计
+                                BigDecimal oldtopsIngTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getTopsIngTime()));
+                                ((Update) update).set("topsIngTime", oldtopsIngTime.add(runTime));
+                            }
+                            // 金额处理
+                            if(fpgLeanModeInfo.getTopsPrice() != null && fpgLeanModeInfo.getTopsPrice().compareTo(new BigDecimal("0.00")) > 0) {
+                                // 总金额
+                                BigDecimal totalAmount = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getAmount()));
+                                ((Update) update).set("amount", activePower.multiply(fpgLeanModeInfo.getTopsPrice()).add(totalAmount));
+                                ((Update) update).set("topsAmount", oldtopsPower.add(activePower).multiply(fpgLeanModeInfo.getTopsPrice()));
+                            }
+                        } else if("peaks".equals(jfpgStr.get())){ // 峰
+                            // 功率处理
+                            BigDecimal oldpeaksPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getPeaksPower()));
+                            ((Update) update).set("peaksPower", oldpeaksPower.add(activePower));
+                            // 运行时常处理
+                            if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1){ // 运行时长统计
+                                BigDecimal oldpeaksIngTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getPeaksIngTime()));
+                                ((Update) update).set("peaksIngTime", oldpeaksIngTime.add(runTime));
+                            }
+                            // 金额处理
+                            if(fpgLeanModeInfo.getPeaksPrice() != null && fpgLeanModeInfo.getPeaksPrice().compareTo(new BigDecimal("0.00")) > 0) {
+                                // 总金额
+                                BigDecimal totalAmount = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getAmount()));
+                                ((Update) update).set("amount", activePower.multiply(fpgLeanModeInfo.getPeaksPrice()).add(totalAmount));
+                                ((Update) update).set("topsAmount", oldpeaksPower.add(activePower).multiply(fpgLeanModeInfo.getPeaksPrice()));
+                            }
+                        } else if("flat".equals(jfpgStr.get())){ // 平
+                            // 功率处理
+                            BigDecimal oldflatPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getFlatPower()));
+                            ((Update) update).set("flatPower", oldflatPower.add(activePower));
+                            // 运行时常处理
+                            if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1){
+                                BigDecimal oldflatIngTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getTopsIngTime()));
+                                ((Update) update).set("topsIngTime", oldflatIngTime.add(runTime));
+                            }
+                            // 金额处理
+                            if(fpgLeanModeInfo.getFlatPrice() != null && fpgLeanModeInfo.getFlatPrice().compareTo(new BigDecimal("0.00")) > 0) {
+                                // 总金额
+                                BigDecimal totalAmount = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getAmount()));
+                                ((Update) update).set("amount", activePower.multiply(fpgLeanModeInfo.getFlatPrice()).add(totalAmount));
+                                ((Update) update).set("flatAmount", oldflatPower.add(activePower).multiply(fpgLeanModeInfo.getFlatPrice()));
+                            }
+                        } else if("valleys".equals(jfpgStr.get())){ // 谷
+                            // 功率处理
+                            BigDecimal oldvalleysPower = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getValleysPower()));
+                            ((Update) update).set("valleysPower", oldvalleysPower.add(activePower));
+                            // 运行时常处理
+                            if(fpgLeanModeInfo.getRunTime() != null && fpgLeanModeInfo.getRunTime() == 1){
+                                BigDecimal oldvalleysIngTime = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getValleysIngTime()));
+                                ((Update) update).set("valleysIngTime", oldvalleysIngTime.add(runTime));
+                            }
+                            // 金额处理
+                            if(fpgLeanModeInfo.getValleysPrice() != null && fpgLeanModeInfo.getValleysPrice().compareTo(new BigDecimal("0.00")) > 0) {
+                                // 总金额
+                                BigDecimal totalAmount = new BigDecimal(String.valueOf(FpgStatiscsModelMongo.getAmount()));
+                                ((Update) update).set("amount", activePower.multiply(fpgLeanModeInfo.getValleysPrice()).add(totalAmount));
+                                ((Update) update).set("valleysAmount", oldvalleysPower.add(activePower).multiply(fpgLeanModeInfo.getValleysPrice()));
+                            }
+                        }
+                        mongoTemplate.updateFirst(query, update, FpgStatiscsModelMongodb.class, "leanmodel_" + fpgLeanModeInfo.getLeanModelCode());
+                    } else { // 为空直接插入
+                        // 将点位数据存入mongo中
+                        mongoTemplate.insert(fpgStatiscsModelData, "leanmodel_" + fpgLeanModeInfo.getLeanModelCode());
+                    }
+                }catch (Exception e) {
+                    log.error(e.getMessage());
+                }
+            });
+        });
+    }
+
+    /**
+     * 判断创建时间是否在开始时间和结束时间范围内
+     * @param createTime
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public static boolean containsCreateTime(LocalDateTime createTime, String startTime, String endTime) {
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        LocalDateTime start_time = LocalDateTime.parse(startTime, formatter);
+        LocalDateTime end_time = LocalDateTime.parse(endTime, formatter);
+        return createTime!= null && (createTime.isAfter(start_time) || createTime.equals(start_time)) &&
+                (createTime.isBefore(end_time) || createTime.equals(end_time));
+    }
+}

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

@@ -0,0 +1,113 @@
+package org.jeecg.modules.fpgJob.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @Description: 峰平谷模型
+ * @Author: jeecg-boot
+ * @Date:   2024-10-31
+ * @Version: V1.0
+ */
+@Data
+@TableName("fpg_lean_model")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="fpg_lean_model对象", description="峰平谷模型")
+public class FpgLeanModel implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**主键*/
+    @TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private String id;
+    /**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    /**创建日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+    private Date createTime;
+    /**更新人*/
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+    /**更新日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+    private Date updateTime;
+    /**所属部门*/
+    @ApiModelProperty(value = "所属部门")
+    private String sysOrgCode;
+    /**名称*/
+    @Excel(name = "名称", width = 15)
+    @ApiModelProperty(value = "名称")
+    private String title;
+    /**模型编号*/
+    @Excel(name = "模型编号", width = 15)
+    @ApiModelProperty(value = "模型编号")
+    private String leanModelCode;
+    /**功率 1: 开启 2: 关闭*/
+    @Excel(name = "功率 1: 开启 2: 关闭", width = 15)
+    @ApiModelProperty(value = "功率 1: 开启 2: 关闭")
+    private Integer power;
+    /**统计单位*/
+    @Excel(name = "统计单位", width = 15)
+    @Dict(dicCode = "lean_model_unit")
+    @ApiModelProperty(value = "统计单位")
+    private String totalUnit;
+    /**班次 1*/
+    @Excel(name = "班次 1", width = 15)
+    @Dict(dicCode = "lean_model_class")
+    @ApiModelProperty(value = "班次 1")
+    private Integer classUnit;
+    /**尖计费单价(元)*/
+    @Excel(name = "尖计费单价(元)", width = 15)
+    @ApiModelProperty(value = "尖计费单价(元)")
+    private BigDecimal topsPrice;
+    /**状态*/
+    @Excel(name = "状态", width = 15)
+    @ApiModelProperty(value = "状态")
+    private String status;
+    /**备注*/
+    @Excel(name = "备注", width = 15)
+    @ApiModelProperty(value = "备注")
+    private String remark;
+    /**峰计费单价(元)*/
+    @Excel(name = "峰计费单价(元)", width = 15)
+    @ApiModelProperty(value = "峰计费单价(元)")
+    private BigDecimal peaksPrice;
+    /**平计费单价(元)*/
+    @Excel(name = "平计费单价(元)", width = 15)
+    @ApiModelProperty(value = "平计费单价(元)")
+    private BigDecimal flatPrice;
+    /**谷计费单价(元)*/
+    @Excel(name = "谷计费单价(元)", width = 15)
+    @ApiModelProperty(value = "谷计费单价(元)")
+    private BigDecimal valleysPrice;
+    /**核算占比% 1:开启 2: 关闭*/
+    @Excel(name = "核算占比% 1:开启 2: 关闭", width = 15)
+    @Dict(dicCode = "proportion_run_status")
+    @ApiModelProperty(value = "核算占比% 1:开启 2: 关闭")
+    private Integer proportion;
+    /**运行时长 1:开启 2: 关闭*/
+    @Excel(name = "运行时长 1:开启 2: 关闭", width = 15)
+    @Dict(dicCode = "proportion_run_status")
+    @ApiModelProperty(value = "运行时长 1:开启 2: 关闭")
+    private Integer runTime;
+}

+ 14 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/mapper/FpgLeanModelMapper.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.fpgJob.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
+
+/**
+ * @Description: 峰平谷模型
+ * @Author: jeecg-boot
+ * @Date:   2024-10-31
+ * @Version: V1.0
+ */
+public interface FpgLeanModelMapper extends BaseMapper<FpgLeanModel> {
+
+}

+ 5 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/mapper/xml/FpgLeanModelMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.fpgJob.mapper.FpgLeanModelMapper">
+
+</mapper>

+ 14 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/fpgJob/service/IFpgLeanModelService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.fpgJob.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
+
+/**
+ * @Description: 峰平谷模型
+ * @Author: jeecg-boot
+ * @Date:   2024-10-31
+ * @Version: V1.0
+ */
+public interface IFpgLeanModelService extends IService<FpgLeanModel> {
+
+}

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

@@ -0,0 +1,18 @@
+package org.jeecg.modules.fpgJob.service.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
+import org.jeecg.modules.fpgJob.mapper.FpgLeanModelMapper;
+import org.jeecg.modules.fpgJob.service.IFpgLeanModelService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Description: 峰平谷模型
+ * @Author: jeecg-boot
+ * @Date:   2024-10-31
+ * @Version: V1.0
+ */
+@Service
+public class FpgLeanModelServiceImpl extends ServiceImpl<FpgLeanModelMapper, FpgLeanModel> implements IFpgLeanModelService {
+}

+ 0 - 39
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/controller/FpgGatherDataController.java

@@ -1,39 +0,0 @@
-package org.jeecg.modules.gatherData.controller;
-
-import java.util.Arrays;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.base.controller.JeecgController;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.modules.gatherData.entity.FpgGatherData;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import lombok.extern.slf4j.Slf4j;
-
-import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-import org.springframework.web.servlet.ModelAndView;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.jeecg.common.aspect.annotation.AutoLog;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
-
- /**
- * @Description: 峰平谷数据采集
- * @Author: jeecg-boot
- * @Date:   2024-10-28
- * @Version: V1.0
- */
-@Api(tags="峰平谷数据采集")
-@RestController
-@RequestMapping("/jeecgModuleLesm/fpgGatherData")
-@Slf4j
-public class FpgGatherDataController extends JeecgController<FpgGatherData, IFpgGatherDataService> {
-	@Autowired
-	private IFpgGatherDataService fpgGatherDataService;
-
-}

+ 37 - 25
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgGatherData.java

@@ -2,12 +2,14 @@ package org.jeecg.modules.gatherData.entity;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.util.Date;
 
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import org.jeecg.modules.devicePoint.entity.DevicePoint;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.jeecg.common.aspect.annotation.Dict;
@@ -30,56 +32,66 @@ import lombok.experimental.Accessors;
 public class FpgGatherData implements Serializable {
     private static final long serialVersionUID = 1L;
 
-	/**主键*/
-	@TableId(type = IdType.ASSIGN_ID)
+    /**主键*/
+    @TableId(type = IdType.ASSIGN_ID)
     @ApiModelProperty(value = "主键")
     private java.lang.String id;
-	/**创建人*/
+    /**创建人*/
     @ApiModelProperty(value = "创建人")
     private java.lang.String createBy;
-	/**创建日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    /**创建日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "创建日期")
     private java.util.Date createTime;
-	/**更新人*/
+    /**更新人*/
     @ApiModelProperty(value = "更新人")
     private java.lang.String updateBy;
-	/**更新日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    /**更新日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "更新日期")
     private java.util.Date updateTime;
-	/**所属部门*/
+    /**所属部门*/
     @ApiModelProperty(value = "所属部门")
     private java.lang.String sysOrgCode;
-	/**采集点ID*/
-	@Excel(name = "采集点ID", width = 15)
+    /**采集点ID*/
+    @Excel(name = "采集点ID", width = 15)
     @ApiModelProperty(value = "采集点ID")
     private java.lang.String devicePointId;
-	/**区域ID*/
-	@Excel(name = "区域ID", width = 15)
+    /**区域ID*/
+    @Excel(name = "区域ID", width = 15)
     @ApiModelProperty(value = "区域ID")
     private java.lang.String deviceRegionId;
-	/**设备id*/
-	@Excel(name = "设备id", width = 15)
+    /**设备id*/
+    @Excel(name = "设备id", width = 15)
     @ApiModelProperty(value = "设备id")
     private java.lang.String deviceInformationId;
-	/**运行电流*/
-	@Excel(name = "运行电流", width = 15)
+    /**运行电流*/
+    @Excel(name = "运行电流", width = 15)
     @ApiModelProperty(value = "运行电流")
-    private BigDecimal current;
-	/**有功功率*/
-	@Excel(name = "有功功率", width = 15)
+    private BigDecimal runCurrent;
+    /**有功功率*/
+    @Excel(name = "有功功率", width = 15)
     @ApiModelProperty(value = "有功功率")
     private BigDecimal activePower;
-	/**电压*/
-	@Excel(name = "电压", width = 15)
+    /**电压*/
+    @Excel(name = "电压", width = 15)
     @ApiModelProperty(value = "电压")
     private BigDecimal voltage;
-	/**峰平谷类型*/
-	@Excel(name = "峰平谷类型", width = 15, dicCode = "fpg_type")
-	@Dict(dicCode = "fpg_type")
+    /**峰平谷类型*/
+    @Excel(name = "峰平谷类型", width = 15, dicCode = "fpg_type")
+    @Dict(dicCode = "fpg_type")
     @ApiModelProperty(value = "峰平谷类型")
     private java.lang.String fpgType;
+
+    /**峰平谷模型使用状态*/
+    @Excel(name = "峰平谷模型使用状态", width = 15, dicCode = "fpg_model_state")
+    @ApiModelProperty(value = "峰平谷模型使用状态0:使用中1:使用结束")
+    private java.lang.String fpgModelState;
+
+    /**峰平谷类型*/
+    @Excel(name = "事件告警使用状态", width = 15, dicCode = "event_warn_state")
+    @ApiModelProperty(value = "事件告警使用状态0:使用中1:使用结束")
+    private java.lang.String eventWarnState;
 }

+ 167 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgStatiscsModelData.java

@@ -0,0 +1,167 @@
+package org.jeecg.modules.gatherData.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @Description: 峰平谷数据采集
+ * @Author: jeecg-boot
+ * @Date:   2024-10-28
+ * @Version: V1.0
+ */
+@Data
+public class FpgStatiscsModelData{
+
+    @ApiModelProperty(value = "更新日期")
+    private Date updateTime;
+    /**采集点ID*/
+    @ApiModelProperty(value = "采集点ID")
+    private String devicePointId;
+    /**区域ID*/
+    @ApiModelProperty(value = "区域ID")
+    private String deviceRegionId;
+    /**设备id*/
+    @ApiModelProperty(value = "设备id")
+    private String deviceInformationId;
+    /**产生费用*/
+    @ApiModelProperty(value = "产生费用")
+    private BigDecimal amount;
+    /**运行时长*/
+    @ApiModelProperty(value = "运行时长")
+    private BigDecimal ingTime;
+    /**运行总功率*/
+    @ApiModelProperty(value = "运行总功率")
+    private BigDecimal power;
+    /**尖总功率*/
+    @ApiModelProperty(value = "尖总功率")
+    private BigDecimal topsPower;
+    /**峰总功率*/
+    @ApiModelProperty(value = "峰总功率")
+    private BigDecimal peaksPower;
+    /**平总功率*/
+    @ApiModelProperty(value = "平总功率")
+    private BigDecimal flatPower;
+    /**谷总功率*/
+    @ApiModelProperty(value = "谷总功率")
+    private BigDecimal valleysPower;
+    /**尖运行时长*/
+    @ApiModelProperty(value = "尖运行时长")
+    private BigDecimal topsIngTime;
+    /**峰运行时长*/
+    @ApiModelProperty(value = "峰运行时长")
+    private BigDecimal peaksIngTime;
+    /**平运行时长*/
+    @ApiModelProperty(value = "平运行时长")
+    private BigDecimal flatIngTime;
+    /**谷运行时长*/
+    @ApiModelProperty(value = "谷运行时长")
+    private BigDecimal valleysIngTime;
+    /**尖运行时长*/
+    @ApiModelProperty(value = "尖产生费用")
+    private BigDecimal topsAmount;
+    /**峰运行时长*/
+    @ApiModelProperty(value = "峰产生费用")
+    private BigDecimal peaksAmount;
+    /**平运行时长*/
+    @ApiModelProperty(value = "平产费用")
+    private BigDecimal flatAmount;
+    /**产生费用*/
+    @ApiModelProperty(value = "谷产费用")
+    private BigDecimal valleysAmount;
+    /**尖单价电费*/
+    @ApiModelProperty(value = "尖单价电费")
+    private BigDecimal topsPrice;
+    /**峰单价电费*/
+    @ApiModelProperty(value = "峰单价电费")
+    private BigDecimal peaksPrice;
+    /**平单价电费*/
+    @ApiModelProperty(value = "平单价电费")
+    private BigDecimal flatPrice;
+    /**谷单价电费*/
+    @ApiModelProperty(value = "谷单价电费")
+    private BigDecimal valleysPrice;
+    /**尖占比%*/
+    @ApiModelProperty(value = "尖占比%")
+    private BigDecimal topsProportion;
+    /**峰占比%*/
+    @ApiModelProperty(value = "峰占比%")
+    private BigDecimal peaksProportion;
+    /**平占比%*/
+    @ApiModelProperty(value = "平占比%")
+    private BigDecimal flatProportion;
+    /**谷占比%*/
+    @ApiModelProperty(value = "谷占比%")
+    private BigDecimal valleysProportion;
+    /**占比处理%*/
+    @ApiModelProperty(value = "占比处理")
+    private Integer proportion;
+    /**班次*/
+    @ApiModelProperty(value = "班次")
+    private String classs;
+    /**日期*/
+    @ApiModelProperty(value = "日期")
+    private String dates;
+    /**统计单位存储对应时间格式*/
+    @ApiModelProperty(value = "统计单位存储对应时间格式")
+    private String datestr;
+    /**创建时间*/
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    // 峰平谷精益模型数据统计
+    public FpgStatiscsModelData(FpgGatherData fpgGather, FpgLeanModel fpgLeanModel, String datestr, String dates, String classs, Date createTime, Date updateTime) {
+        // 基础信息配置
+        this.deviceRegionId = fpgGather.getDeviceRegionId(); // 区域id
+        this.deviceInformationId = fpgGather.getDeviceInformationId(); // 设备id
+        this.devicePointId = fpgGather.getDevicePointId(); // 采集点id
+        this.ingTime = new BigDecimal("0.00"); // 累计时长
+        this.power = new BigDecimal("0.00"); // 累计功率
+        this.topsPower = new BigDecimal("0.00"); // 尖功率
+        this.peaksPower = new BigDecimal("0.00"); // 峰功率
+        this.flatPower = new BigDecimal("0.00"); // 平功率
+        this.valleysPower = new BigDecimal("0.00"); // 谷功率
+        if(fpgLeanModel.getClassUnit() != null && fpgLeanModel.getClassUnit() == 1){ // 班次统计
+            this.classs = classs;
+        }
+        if(fpgLeanModel.getProportion() != null && fpgLeanModel.getProportion() == 1){ // 占比统计
+            this.proportion = 1;
+            this.topsProportion = new BigDecimal("0.00");
+            this.peaksProportion = new BigDecimal("0.00");
+            this.flatProportion = new BigDecimal("0.00");
+            this.valleysProportion = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getRunTime() != null && fpgLeanModel.getRunTime() == 1){ // 运行时长统计
+            this.topsIngTime = new BigDecimal("0.00");
+            this.peaksIngTime = new BigDecimal("0.00");
+            this.flatIngTime = new BigDecimal("0.00");
+            this.valleysIngTime = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getTopsPrice() != null){ // 尖单价电费
+            this.topsPrice = fpgLeanModel.getTopsPrice();
+            this.topsAmount = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getPeaksPrice() != null){ // 峰单价电费
+            this.peaksPrice = fpgLeanModel.getPeaksPrice();
+            this.peaksAmount = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getFlatPrice() != null){ // 平单价电费
+            this.flatPrice = fpgLeanModel.getFlatPrice();
+            this.flatAmount = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getValleysPrice() != null){ // 谷单价电费
+            this.valleysPrice = fpgLeanModel.getValleysPrice();
+            this.valleysAmount = new BigDecimal("0.00");
+        }
+        if(fpgLeanModel.getTopsPrice() != null || fpgLeanModel.getPeaksPrice() != null || fpgLeanModel.getFlatPrice() != null || fpgLeanModel.getValleysPrice() != null){
+            this.amount = new BigDecimal("0.00");
+        }
+        this.dates = dates;
+        this.datestr = datestr;
+        this.createTime = createTime;
+        this.updateTime = updateTime;
+    }
+}

+ 118 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgStatiscsModelMongodb.java

@@ -0,0 +1,118 @@
+package org.jeecg.modules.gatherData.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecg.modules.fpgJob.entity.FpgLeanModel;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @Description: 峰平谷数据采集
+ * @Author: jeecg-boot
+ * @Date:   2024-10-28
+ * @Version: V1.0
+ */
+@Data
+public class FpgStatiscsModelMongodb {
+
+    @ApiModelProperty(value = "更新日期")
+    private Date updateTime;
+	/**采集点ID*/
+    @ApiModelProperty(value = "采集点ID")
+    private String devicePointId;
+	/**区域ID*/
+    @ApiModelProperty(value = "区域ID")
+    private String deviceRegionId;
+	/**设备id*/
+    @ApiModelProperty(value = "设备id")
+    private String deviceInformationId;
+    /**产生费用*/
+    @ApiModelProperty(value = "产生费用")
+    private BigDecimal amount;
+	/**运行时长*/
+    @ApiModelProperty(value = "运行时长")
+    private BigDecimal ingTime;
+	/**运行总功率*/
+    @ApiModelProperty(value = "运行总功率")
+    private BigDecimal power;
+    /**尖总功率*/
+    @ApiModelProperty(value = "尖总功率")
+    private BigDecimal topsPower;
+    /**峰总功率*/
+    @ApiModelProperty(value = "峰总功率")
+    private BigDecimal peaksPower;
+    /**平总功率*/
+    @ApiModelProperty(value = "平总功率")
+    private BigDecimal flatPower;
+    /**谷总功率*/
+    @ApiModelProperty(value = "谷总功率")
+    private BigDecimal valleysPower;
+    /**尖运行时长*/
+    @ApiModelProperty(value = "尖运行时长")
+    private BigDecimal topsIngTime;
+    /**峰运行时长*/
+    @ApiModelProperty(value = "峰运行时长")
+    private BigDecimal peaksIngTime;
+    /**平运行时长*/
+    @ApiModelProperty(value = "平运行时长")
+    private BigDecimal flatIngTime;
+    /**谷运行时长*/
+    @ApiModelProperty(value = "谷运行时长")
+    private BigDecimal valleysIngTime;
+    /**尖运行时长*/
+    @ApiModelProperty(value = "尖产生费用")
+    private BigDecimal topsAmount;
+    /**峰运行时长*/
+    @ApiModelProperty(value = "峰产生费用")
+    private BigDecimal peaksAmount;
+    /**平运行时长*/
+    @ApiModelProperty(value = "平产费用")
+    private BigDecimal flatAmount;
+    /**产生费用*/
+    @ApiModelProperty(value = "谷产费用")
+    private BigDecimal valleysAmount;
+    /**尖单价电费*/
+    @ApiModelProperty(value = "尖单价电费")
+    private BigDecimal topsPrice;
+    /**峰单价电费*/
+    @ApiModelProperty(value = "峰单价电费")
+    private BigDecimal peaksPrice;
+    /**平单价电费*/
+    @ApiModelProperty(value = "平单价电费")
+    private BigDecimal flatPrice;
+    /**谷单价电费*/
+    @ApiModelProperty(value = "谷单价电费")
+    private BigDecimal valleysPrice;
+    /**尖占比%*/
+    @ApiModelProperty(value = "尖占比%")
+    private BigDecimal topsProportion;
+    /**峰占比%*/
+    @ApiModelProperty(value = "峰占比%")
+    private BigDecimal peaksProportion;
+    /**平占比%*/
+    @ApiModelProperty(value = "平占比%")
+    private BigDecimal flatProportion;
+    /**谷占比%*/
+    @ApiModelProperty(value = "谷占比%")
+    private BigDecimal valleysProportion;
+    /**占比处理%*/
+    @ApiModelProperty(value = "占比处理")
+    private Integer proportion;
+    /**班次*/
+    @ApiModelProperty(value = "班次")
+    private String classs;
+    /**日期*/
+    @ApiModelProperty(value = "日期")
+    private String dates;
+    /**统计单位存储对应时间格式*/
+    @ApiModelProperty(value = "统计单位存储对应时间格式")
+    private String datestr;
+    /**创建时间*/
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    public FpgStatiscsModelMongodb() {
+
+    }
+}

+ 25 - 30
jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/entity/LeanEventWarnInfo.java

@@ -1,22 +1,17 @@
 package org.jeecg.modules.leanEventWarn.entity;
-
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-import java.util.Date;
-import java.math.BigDecimal;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableLogic;
 import lombok.Data;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
-import org.jeecg.common.aspect.annotation.Dict;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.util.Date;
 
 /**
  * @Description: 精益事件告警信息表
@@ -32,55 +27,55 @@ import lombok.experimental.Accessors;
 public class LeanEventWarnInfo implements Serializable {
     private static final long serialVersionUID = 1L;
 
-	/**主键*/
-	@TableId(type = IdType.ASSIGN_ID)
+    /**主键*/
+    @TableId(type = IdType.ASSIGN_ID)
     @ApiModelProperty(value = "主键")
     private String id;
-	/**创建人*/
+    /**创建人*/
     @ApiModelProperty(value = "创建人")
     private String createBy;
-	/**创建日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    /**创建日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "创建日期")
     private Date createTime;
-	/**更新人*/
+    /**更新人*/
     @ApiModelProperty(value = "更新人")
     private String updateBy;
-	/**更新日期*/
-	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    /**更新日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value = "更新日期")
     private Date updateTime;
-	/**所属部门*/
+    /**所属部门*/
     @ApiModelProperty(value = "所属部门")
     private String sysOrgCode;
-	/**区域ID*/
-	@Excel(name = "区域ID", width = 15)
+    /**区域ID*/
+    @Excel(name = "区域ID", width = 15)
     @ApiModelProperty(value = "区域ID")
     private String deviceRegionId;
-	/**设备ID*/
-	@Excel(name = "设备ID", width = 15)
+    /**设备ID*/
+    @Excel(name = "设备ID", width = 15)
     @ApiModelProperty(value = "设备ID")
     private String deviceInformationId;
-	/**采集点ID*/
-	@Excel(name = "采集点ID", width = 15)
+    /**采集点ID*/
+    @Excel(name = "采集点ID", width = 15)
     @ApiModelProperty(value = "采集点ID")
     private String devicePointId;
-	/**告警类型*/
-	@Excel(name = "告警类型", width = 15)
+    /**告警类型*/
+    @Excel(name = "告警类型", width = 15)
     @ApiModelProperty(value = "告警类型")
     private String warnType;
-	/**设备预警信息*/
-	@Excel(name = "设备预警信息", width = 15)
+    /**设备预警信息*/
+    @Excel(name = "设备预警信息", width = 15)
     @ApiModelProperty(value = "设备预警信息")
     private String deviceWarnInfo;
-	/**设备预警级别(0:重度,1:中度,2:轻度)*/
-	@Excel(name = "设备预警级别(0:重度,1:中度,2:轻度)", width = 15)
+    /**设备预警级别(0:重度,1:中度,2:轻度)*/
+    @Excel(name = "设备预警级别(0:重度,1:中度,2:轻度)", width = 15)
     @ApiModelProperty(value = "设备预警级别(0:重度,1:中度,2:轻度)")
     private String deviceWarnLevel;
-	/**拓展字段*/
-	@Excel(name = "拓展字段", width = 15)
+    /**拓展字段*/
+    @Excel(name = "拓展字段", width = 15)
     @ApiModelProperty(value = "拓展字段")
     private String remark;
 }

+ 78 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/entity/LeanEventsHostConfig.java

@@ -0,0 +1,78 @@
+package org.jeecg.modules.leanEventWarn.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Description: 精益事件配置关联表
+ * @Author: jeecg-boot
+ * @Date:   2024-10-30
+ * @Version: V1.0
+ */
+@Data
+@TableName("lean_events_host_config")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="lean_events_host_config对象", description="精益事件配置关联表")
+public class LeanEventsHostConfig implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**主键*/
+	@TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private String id;
+	/**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+	/**创建日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+    private Date createTime;
+	/**更新人*/
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+	/**更新日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+    private Date updateTime;
+	/**所属部门*/
+    @ApiModelProperty(value = "所属部门")
+    private String sysOrgCode;
+	/**辅设备ID*/
+	@Excel(name = "辅设备ID", width = 15)
+    @ApiModelProperty(value = "辅设备ID")
+    private String deviceInformationListId;
+	/**运行时间*/
+	@Excel(name = "运行时间", width = 15)
+    @ApiModelProperty(value = "运行时间")
+    private String runTime;
+	/**功率限制*/
+	@Excel(name = "功率限制", width = 15)
+    @ApiModelProperty(value = "功率限制")
+    private String powerLimit;
+	/**限制类型*/
+	@Excel(name = "限制类型", width = 15)
+    @ApiModelProperty(value = "限制类型")
+    private String limitType;
+	/**拓展字段*/
+	@Excel(name = "拓展字段", width = 15)
+    @ApiModelProperty(value = "拓展字段")
+    private String remark;
+    @Excel(name = "精益事件id", width = 15)
+    @ApiModelProperty(value = "精益事件id")
+    private String eventsId;
+}

+ 15 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/mapper/LeanEventsHostConfigMapper.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.leanEventWarn.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.leanEventWarn.entity.LeanEventsHostConfig;
+
+
+/**
+ * @Description: 精益事件配置关联表
+ * @Author: jeecg-boot
+ * @Date:   2024-10-30
+ * @Version: V1.0
+ */
+public interface LeanEventsHostConfigMapper extends BaseMapper<LeanEventsHostConfig> {
+
+}

+ 5 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/mapper/xml/LeanEventsHostConfigMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.leanEventWarn.mapper.LeanEventsHostConfigMapper">
+
+</mapper>

+ 8 - 5
jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/ILeanEventWarnInfoService.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.leanEventWarn.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.events.entity.LeanEventsHost;
 import org.jeecg.modules.gatherData.entity.FpgGatherData;
 import org.jeecg.modules.leanEventWarn.entity.LeanEventWarnInfo;
 
@@ -12,13 +13,15 @@ import org.jeecg.modules.leanEventWarn.entity.LeanEventWarnInfo;
  */
 public interface ILeanEventWarnInfoService extends IService<LeanEventWarnInfo> {
 
-    void insertWarnInfo(LeanEventWarnInfo leanEventWarnInfo);
+    void openDeviceTriggerWarnInfo(FpgGatherData fpgGatherData);
 
-    void openDeviceTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData);
+    void stopDeviceTriggerWarnInfo(FpgGatherData fpgGatherData);
 
-    void stopDeviceTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData);
+    void openFpgTriggerWarnInfo(FpgGatherData fpgGatherData);
 
-    void openFpgTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData);
+    void closeFpgTriggerWarnInfo(FpgGatherData fpgGatherData);
 
-    void closeFpgTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData);
+    void runTimeTriggerWarnInfo(FpgGatherData fpgGatherData, LeanEventsHost leanEventsHost);
+
+    void powerLimitTriggerWarnInfo(FpgGatherData fpgGatherData, LeanEventsHost leanEventsHost);
 }

+ 14 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/ILeanEventsHostConfigService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.leanEventWarn.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.leanEventWarn.entity.LeanEventsHostConfig;
+
+/**
+ * @Description: 精益事件配置关联表
+ * @Author: jeecg-boot
+ * @Date:   2024-10-30
+ * @Version: V1.0
+ */
+public interface ILeanEventsHostConfigService extends IService<LeanEventsHostConfig> {
+
+}

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

@@ -1,32 +1,40 @@
 package org.jeecg.modules.leanEventWarn.service.impl;
-
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.jeecg.modules.common.enums.EDeviceInformationType;
+import org.jeecg.modules.events.entity.LeanEventsHost;
+import org.jeecg.modules.gatherData.entity.FpgStatiscsModelMongodb;
 import org.jeecg.modules.leanEventWarn.entity.LeanEventWarnInfo;
+import org.jeecg.modules.leanEventWarn.entity.LeanEventsHostConfig;
 import org.jeecg.modules.leanEventWarn.mapper.LeanEventWarnInfoMapper;
 import org.jeecg.modules.leanEventWarn.service.ILeanEventWarnInfoService;
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.gatherData.entity.FpgGatherData;
 import org.jeecg.modules.gatherData.service.IFpgGatherDataService;
-import org.jeecg.modules.leanEventWarn.entity.LeanEventWarnInfo;
-import org.jeecg.modules.leanEventWarn.mapper.LeanEventWarnInfoMapper;
-import org.jeecg.modules.leanEventWarn.service.ILeanEventWarnInfoService;
+import org.jeecg.modules.leanEventWarn.service.ILeanEventsHostConfigService;
 import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
 import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfigParam;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.SystemVariable;
 import org.jeecg.modules.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
+import org.jeecg.modules.peaksAndValleysTimeConfig.service.ISystemVariableService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -40,230 +48,429 @@ import java.util.stream.Collectors;
 @Service
 public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoMapper, LeanEventWarnInfo> implements ILeanEventWarnInfoService {
 
+    @Autowired
+    IFpgGatherDataService fpgGatherDataService;
 
     @Autowired
-    ILeanEventWarnInfoService leanEventWarnInfoService;
+    IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
 
     @Autowired
-    IFpgGatherDataService fpgGatherDataService;
+    ILeanEventsHostConfigService leanEventsHostConfigService;
 
     @Autowired
-    IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
+    MongoTemplate mongoTemplate;
 
-    @Override
-    public void insertWarnInfo(LeanEventWarnInfo leanEventWarnInfo) {
-        baseMapper.insert(leanEventWarnInfo);
-    }
+    @Autowired
+    ISystemVariableService systemVariableService;
 
     @Override
-    public void openDeviceTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData) {
+    public void openDeviceTriggerWarnInfo(FpgGatherData fpgGatherData) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
         leanEventWarnInfo.setDeviceInformationId(fpgGatherData.getDeviceInformationId());
         leanEventWarnInfo.setDevicePointId(fpgGatherData.getDevicePointId());
         leanEventWarnInfo.setCreateTime(new Date());
-        // 通过主设备ID、设备区域ID、采集点ID查询采集信息 fpg_gather_data
-        List<String> deviceChildTites = Arrays.asList(deviceInformationList.split(","));
-        LambdaQueryWrapper<FpgGatherData> fpgGatherDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        fpgGatherDataLambdaQueryWrapper.in(FpgGatherData::getDeviceInformationId, deviceChildTites).eq(FpgGatherData::getDevicePointId, fpgGatherData.getDevicePointId()).eq(FpgGatherData::getDeviceRegionId, fpgGatherData.getDeviceRegionId());
-        List<FpgGatherData> gatherDataList = fpgGatherDataService.list(fpgGatherDataLambdaQueryWrapper);
-        if (!oConvertUtils.listIsNotEmpty(gatherDataList)){
+
+        // 根据采集点的运行电流,判断是否需要上报告警信息 (辅设备电流小于等于5,上报告警信息)
+        QueryWrapper<SystemVariable> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("variable_address", "sys_run_current_limit");
+        queryWrapper.eq("status",  0);
+        SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
+        if (systemVariable == null){
+            return;
+        }
+        BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
+
+        if (fpgGatherData.getRunCurrent().compareTo(limitCurrent) < 0){
             // 上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("HOST_OPEN状态下,查询采集数据为空,主设备未开启,触发精益事件告警!");
-            leanEventWarnInfo.setWarnType("1");
+            leanEventWarnInfo.setDeviceWarnInfo("HOST_OPEN状态下,辅设备电流小于5A,触发告警!");
+            leanEventWarnInfo.setWarnType(EDeviceInformationType.HOST_OPEN.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
-            leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
-            return;
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
         }
-        // 根据采集点的运行电流,判断是否需要上报告警信息 (辅设备电流小于等于5,上报告警信息)
-        BigDecimal limitVoltage = new BigDecimal("5");
-        gatherDataList.forEach(x ->{
-            if (x.getCurrent().compareTo(limitVoltage) < 0){
-                // 上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("HOST_OPEN状态下,辅设备电流大于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
-                leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
-            }
-        });
     }
 
     @Override
-    public void stopDeviceTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData) {
+    public void stopDeviceTriggerWarnInfo(FpgGatherData fpgGatherData) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
         leanEventWarnInfo.setDeviceInformationId(fpgGatherData.getDeviceInformationId());
         leanEventWarnInfo.setDevicePointId(fpgGatherData.getDevicePointId());
         leanEventWarnInfo.setCreateTime(new Date());
-        // 通过主设备ID、设备区域ID、采集点ID查询采集信息 fpg_gather_data
-        List<String> deviceChildTites = Arrays.asList(deviceInformationList.split(","));
-        LambdaQueryWrapper<FpgGatherData> fpgGatherDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        fpgGatherDataLambdaQueryWrapper.in(FpgGatherData::getDeviceInformationId, deviceChildTites).eq(FpgGatherData::getDevicePointId, fpgGatherData.getDevicePointId()).eq(FpgGatherData::getDeviceRegionId, fpgGatherData.getDeviceRegionId());
-        List<FpgGatherData> gatherDataList = fpgGatherDataService.list(fpgGatherDataLambdaQueryWrapper);
-        if (!oConvertUtils.listIsNotEmpty(gatherDataList)){
+        // 根据采集点的电流,判断是否需要上报告警信息 (辅设备电流大于5,上报告警信息)
+        QueryWrapper<SystemVariable> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("variable_address", "sys_run_current_limit");
+        queryWrapper.eq("status",  0);
+        SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
+        if (systemVariable == null){
+            return;
+        }
+        BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
+        if (fpgGatherData.getRunCurrent().compareTo(limitCurrent) > 0){
             // 上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("HOST_CLOSE状态下,查询采集数据为空,主设备未开启,触发精益事件告警!");
-            leanEventWarnInfo.setWarnType("1");
+            leanEventWarnInfo.setDeviceWarnInfo("HOST_CLOSE状态下,辅设备电流大于5A,触发告警!");
+            leanEventWarnInfo.setWarnType(EDeviceInformationType.HOST_STOP.getCode());
             leanEventWarnInfo.setDeviceWarnLevel("0");
-            leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
-            return;
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
         }
-        // 根据采集点的电流,判断是否需要上报告警信息 (辅设备电流大于5,上报告警信息)
-        BigDecimal limitVoltage = new BigDecimal("5");
-        gatherDataList.forEach(x ->{
-            if (x.getCurrent().compareTo(limitVoltage) > 0){
-                // 上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("HOST_CLOSE状态下,辅设备电流大于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
-                leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
-            }
-        });
     }
 
     @Override
-    public void openFpgTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData) {
+    public void openFpgTriggerWarnInfo(FpgGatherData fpgGatherData) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
         leanEventWarnInfo.setDeviceInformationId(fpgGatherData.getDeviceInformationId());
         leanEventWarnInfo.setDevicePointId(fpgGatherData.getDevicePointId());
         leanEventWarnInfo.setCreateTime(new Date());
         PeaksAndValleysTimeConfigParam peaksAndValleysTimeConfigParam = peaksAndValleysTimeConfigService.get();
-        // 通过主设备ID、设备区域ID、采集点ID查询采集信息 fpg_gather_data
-        List<String> deviceChildTites = Arrays.asList(deviceInformationList.split(","));
-        LambdaQueryWrapper<FpgGatherData> fpgGatherDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        fpgGatherDataLambdaQueryWrapper.in(FpgGatherData::getDeviceInformationId, deviceChildTites).eq(FpgGatherData::getDevicePointId, fpgGatherData.getDevicePointId()).eq(FpgGatherData::getDeviceRegionId, fpgGatherData.getDeviceRegionId());
-        List<FpgGatherData> gatherDataList = fpgGatherDataService.list(fpgGatherDataLambdaQueryWrapper);
-        if (!oConvertUtils.listIsNotEmpty(gatherDataList)){
-            // 上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,查询采集数据为空,触发精益事件告警!");
-            leanEventWarnInfo.setWarnType("1");
-            leanEventWarnInfo.setDeviceWarnLevel("0");
-            leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+        // 获取尖、峰、平、谷配置信息并拼接开始时间、结束时间
+        List<PeaksAndValleysTimeConfig> topsNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "tops", fpgGatherData.getCreateTime());
+
+        List<PeaksAndValleysTimeConfig> peaksNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "peaks", fpgGatherData.getCreateTime());
+
+        List<PeaksAndValleysTimeConfig> flatNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "flat", fpgGatherData.getCreateTime());
+
+        List<PeaksAndValleysTimeConfig> valleysNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "valleys", fpgGatherData.getCreateTime());
+
+        QueryWrapper<SystemVariable> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("variable_address", "sys_run_current_limit");
+        queryWrapper.eq("status",  0);
+        SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
+        if (systemVariable == null){
             return;
         }
+        BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
+
+        // 根据采集到的数据 创建时间,跟峰平谷配置的时间,判断属于哪个时段(尖、峰、平、谷)
+        Instant instant = fpgGatherData.getCreateTime().toInstant();
+        LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+
+        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.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
+        }
+        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.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
+        }
+        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.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
+        }
+        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.setWarnType(EDeviceInformationType.FPG_OPEN.getCode());
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
+        }
+    }
+
+    /**
+     * 先根据设备区域ID、设备ID、采集点ID查询告警信息是否存在,
+     * 存在:更新原来的告警信息的更新时间
+     * 不存在:保存告警信息
+     * @param fpgGatherData
+     * @param leanEventWarnInfo
+     */
+    private void saveOrUpdateLeanEventWarnInfo(FpgGatherData fpgGatherData, LeanEventWarnInfo leanEventWarnInfo) {
+        LambdaQueryWrapper<LeanEventWarnInfo> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(LeanEventWarnInfo::getDeviceRegionId, fpgGatherData.getDeviceRegionId()).eq(LeanEventWarnInfo::getDevicePointId, fpgGatherData.getDevicePointId()).
+                eq(LeanEventWarnInfo::getDeviceInformationId, fpgGatherData.getDeviceInformationId());
+        LeanEventWarnInfo leanEventWarnInfoObj = baseMapper.selectOne(wrapper);
+        if (leanEventWarnInfoObj == null){
+            baseMapper.insert(leanEventWarnInfo);
+        }else {
+            leanEventWarnInfoObj.setUpdateTime(new Date());
+            baseMapper.updateById(leanEventWarnInfoObj);
+        }
+    }
+
+    @Override
+    public void closeFpgTriggerWarnInfo(FpgGatherData fpgGatherData) {
+        LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
+        leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
+        leanEventWarnInfo.setDeviceInformationId(fpgGatherData.getDeviceInformationId());
+        leanEventWarnInfo.setDevicePointId(fpgGatherData.getDevicePointId());
+        leanEventWarnInfo.setCreateTime(new Date());
+        PeaksAndValleysTimeConfigParam peaksAndValleysTimeConfigParam = peaksAndValleysTimeConfigService.get();
+
         // 获取尖、峰、平、谷配置信息并拼接开始时间、结束时间
-        List<PeaksAndValleysTimeConfig> topsNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "tops");
+        List<PeaksAndValleysTimeConfig> topsNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "tops", fpgGatherData.getCreateTime());
 
-        List<PeaksAndValleysTimeConfig> peaksNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "peaks");
+        List<PeaksAndValleysTimeConfig> peaksNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "peaks", fpgGatherData.getCreateTime());
 
-        List<PeaksAndValleysTimeConfig> flatNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "flat");
+        List<PeaksAndValleysTimeConfig> flatNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "flat", fpgGatherData.getCreateTime());
 
-        List<PeaksAndValleysTimeConfig> valleysNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "valleys");
+        List<PeaksAndValleysTimeConfig> valleysNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "valleys", fpgGatherData.getCreateTime());
 
-        BigDecimal limitVoltage = new BigDecimal("5");
         // 根据采集到的数据 创建时间,跟峰平谷配置的时间,判断属于哪个时段(尖、峰、平、谷)
-        gatherDataList.forEach(x ->{
-            Instant instant = x.getCreateTime().toInstant();
-            LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
-
-            boolean topsIsExit = topsNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
-            if (topsIsExit && x.getCurrent().compareTo(limitVoltage) < 0){
-                // 采集到的数据电流小于5A,上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,尖时段采集到的数据电流小于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
+        QueryWrapper<SystemVariable> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("variable_address", "sys_run_current_limit");
+        queryWrapper.eq("status",  0);
+        SystemVariable systemVariable = systemVariableService.getOne(queryWrapper);
+        if (systemVariable == null){
+            return;
+        }
+        BigDecimal limitCurrent = new BigDecimal(systemVariable.getDefaultValue());
+
+        Instant instant = fpgGatherData.getCreateTime().toInstant();
+        LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+        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.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
+        }
+        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.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
+        }
+        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.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
+        }
+        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.setWarnType(EDeviceInformationType.FPG_CLOSE.getCode());
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            // 更新或者新增逻辑处理
+            saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
+        }
+    }
+
+    @Override
+    public void runTimeTriggerWarnInfo(FpgGatherData fpgGatherData, LeanEventsHost leanEventsHost) {
+        LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
+        leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
+        leanEventWarnInfo.setDeviceInformationId(fpgGatherData.getDeviceInformationId());
+        leanEventWarnInfo.setDevicePointId(fpgGatherData.getDevicePointId());
+        leanEventWarnInfo.setCreateTime(new Date());
+
+        // 根据辅设备ID、事件ID、限制类型,获取精益时间配置关联信息
+        LambdaQueryWrapper<LeanEventsHostConfig> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(LeanEventsHostConfig::getDeviceInformationListId, fpgGatherData.getDeviceInformationId())
+                .eq(LeanEventsHostConfig::getEventsId, leanEventsHost.getEventsId()).eq(LeanEventsHostConfig::getLimitType, "0");
+        LeanEventsHostConfig leanEventsHostConfig = leanEventsHostConfigService.list(queryWrapper).stream().findFirst().orElse(null);
+        if (leanEventsHostConfig == null){
+            return;
+        }
+        // 获取峰平谷配置的时段
+        PeaksAndValleysTimeConfigParam peaksAndValleysTimeConfigParam = peaksAndValleysTimeConfigService.get();
+        // 处理开始时间、
+        List<Date[]> timeRanges = new ArrayList<>();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        List<PeaksAndValleysTimeConfig> newPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, leanEventsHost.getDeviceInformationId(), new Date());
+        newPeaksAndValleysTimeConfigList.forEach(x ->{
+            try {
+                timeRanges.add(new Date[]{dateFormat.parse(x.getStartTime()), dateFormat.parse(x.getEndTime())});
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+        });
+        // 根据类型、采集点ID、设备ID、区域ID、峰平谷配置时间范围查询mongoDB
+        List<FpgStatiscsModelMongodb> fpgStatiscsModelDataList = queryByTimeRanges(mongoTemplate, timeRanges, fpgGatherData.getDevicePointId(), fpgGatherData.getDeviceInformationId(), fpgGatherData.getDeviceRegionId());
+        if (!oConvertUtils.listIsNotEmpty(fpgStatiscsModelDataList) ){
+            return;
+        }
+        // 判断MongoDB中的累加运行时长是否大于 LeanEventsHostConfig中的尖峰平谷运行限制时长
+        int runTimeLimit = Integer.parseInt(leanEventsHostConfig.getRunTime());
+        if("tops".equals(leanEventsHost.getDeviceInformationId())){
+            BigDecimal topsIngTimeSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getTopsIngTime)
+                    .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
+            if (topsIngTimeSum.intValue() > runTimeLimit){
+                // 尖——累加运行时长超过限制时长,触发告警
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,尖运行时长超过限制时长,触发告警!");
+                leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+                // 更新或者新增逻辑处理
+                saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
-            boolean peaksIsExit = peaksNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
-            if (peaksIsExit && x.getCurrent().compareTo(limitVoltage) < 0){
-                // 采集到的数据电流小于5A,上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,峰采集到的数据电流小于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
+        }else if ("peaks".equals(leanEventsHost.getDeviceInformationId())){
+            BigDecimal peaksIngTimeSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getPeaksIngTime)
+                    .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
+            if (peaksIngTimeSum.intValue() > runTimeLimit){
+                // 峰——累加运行时长超过限制时长,触发告警
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,峰运行时长超过限制时长,触发告警!");
+                leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+                // 更新或者新增逻辑处理
+                saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
-            boolean flatIsExit = flatNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
-            if (flatIsExit && x.getCurrent().compareTo(limitVoltage) < 0){
-                // 采集到的数据电流小于5A,上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,平时段采集到的数据电流小于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
+        }else if ("flat".equals(leanEventsHost.getDeviceInformationId())){
+            BigDecimal flatIngTimeSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getFlatIngTime)
+                    .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
+            if (flatIngTimeSum.intValue() > runTimeLimit){
+                // 平——累加运行时长超过限制时长,触发告警
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,平运行时长超过限制时长,触发告警!");
+                leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+                // 更新或者新增逻辑处理
+                saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
-            boolean valleysIsExit = valleysNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
-            if (valleysIsExit && x.getCurrent().compareTo(limitVoltage) < 0){
-                // 采集到的数据电流小于5A,上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("FPG_OPEN状态下,谷时段采集到的数据电流小于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
+        } else if ("valleys".equals(leanEventsHost.getDeviceInformationId())) {
+            BigDecimal valleysIngTimeSum = fpgStatiscsModelDataList.stream().map(FpgStatiscsModelMongodb::getValleysIngTime)
+                    .reduce(BigDecimal.ZERO, BigDecimal::add).divide(new BigDecimal(60), 0, RoundingMode.CEILING);
+            if (valleysIngTimeSum.intValue() > runTimeLimit){
+                // 谷——累加运行时长超过限制时长,触发告警
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_ING_TIME,谷运行时长超过限制时长,触发告警!");
+                leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_ING_TIME.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+                // 更新或者新增逻辑处理
+                saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
-        });
+        }
     }
 
     @Override
-    public void closeFpgTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData) {
+    public void powerLimitTriggerWarnInfo(FpgGatherData fpgGatherData, LeanEventsHost leanEventsHost) {
         LeanEventWarnInfo leanEventWarnInfo = new LeanEventWarnInfo();
         leanEventWarnInfo.setDeviceRegionId(fpgGatherData.getDeviceRegionId());
         leanEventWarnInfo.setDeviceInformationId(fpgGatherData.getDeviceInformationId());
         leanEventWarnInfo.setDevicePointId(fpgGatherData.getDevicePointId());
         leanEventWarnInfo.setCreateTime(new Date());
+
+        // 根据辅设备ID、事件ID、限制类型,获取精益时间配置关联信息
+        LambdaQueryWrapper<LeanEventsHostConfig> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(LeanEventsHostConfig::getDeviceInformationListId, fpgGatherData.getDeviceInformationId())
+                .eq(LeanEventsHostConfig::getEventsId, leanEventsHost.getEventsId()).eq(LeanEventsHostConfig::getLimitType, "1");
+        LeanEventsHostConfig leanEventsHostConfig = leanEventsHostConfigService.list(queryWrapper).stream().findFirst().orElse(null);
+        if (leanEventsHostConfig == null){
+            return;
+        }
+        // 获取峰平谷配置的时段
         PeaksAndValleysTimeConfigParam peaksAndValleysTimeConfigParam = peaksAndValleysTimeConfigService.get();
-        // 通过主设备ID、设备区域ID、采集点ID查询采集信息 fpg_gather_data
-        List<String> deviceChildTites = Arrays.asList(deviceInformationList.split(","));
-        LambdaQueryWrapper<FpgGatherData> fpgGatherDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        fpgGatherDataLambdaQueryWrapper.in(FpgGatherData::getDeviceInformationId, deviceChildTites).eq(FpgGatherData::getDevicePointId, fpgGatherData.getDevicePointId()).eq(FpgGatherData::getDeviceRegionId, fpgGatherData.getDeviceRegionId());
-        List<FpgGatherData> gatherDataList = fpgGatherDataService.list(fpgGatherDataLambdaQueryWrapper);
-        if (!oConvertUtils.listIsNotEmpty(gatherDataList)){
-            // 上报告警信息
-            leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,查询采集数据为空,触发精益事件告警!");
-            leanEventWarnInfo.setWarnType("1");
-            leanEventWarnInfo.setDeviceWarnLevel("0");
-            leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+        // 处理开始时间、
+        List<Date[]> timeRanges = new ArrayList<>();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        List<PeaksAndValleysTimeConfig> newPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, leanEventsHost.getDeviceInformationId(), new Date());
+        newPeaksAndValleysTimeConfigList.forEach(x ->{
+            try {
+                timeRanges.add(new Date[]{dateFormat.parse(x.getStartTime()), dateFormat.parse(x.getEndTime())});
+            } catch (ParseException e) {
+                throw new RuntimeException(e);
+            }
+        });
+        // 根据类型、采集点ID、设备ID、区域ID、峰平谷配置时间范围查询mongoDB
+        List<FpgStatiscsModelMongodb> fpgStatiscsModelDataList = queryByTimeRanges(mongoTemplate, timeRanges, fpgGatherData.getDevicePointId(), fpgGatherData.getDeviceInformationId(), fpgGatherData.getDeviceRegionId());
+        if (!oConvertUtils.listIsNotEmpty(fpgStatiscsModelDataList) ){
             return;
         }
-        // 获取尖、峰、平、谷配置信息并拼接开始时间、结束时间
-        List<PeaksAndValleysTimeConfig> topsNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "tops");
-
-        List<PeaksAndValleysTimeConfig> peaksNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "peaks");
-
-        List<PeaksAndValleysTimeConfig> flatNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "flat");
-
-        List<PeaksAndValleysTimeConfig> valleysNewPeaksAndValleysTimeConfigList = getPeaksAndValleysTimeConfigByType(peaksAndValleysTimeConfigParam, "valleys");
-
-        // 根据采集到的数据 创建时间,跟峰平谷配置的时间,判断属于哪个时段(尖、峰、平、谷)
-        BigDecimal limitVoltage = new BigDecimal("5");
-        gatherDataList.forEach(x ->{
-            Instant instant = x.getCreateTime().toInstant();
-            LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
-            boolean topsIsExit = topsNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
-            if (topsIsExit && x.getCurrent().compareTo(limitVoltage) > 0){
-                // 采集到的数据电流大于5A,上报告警信息
-                // 上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
+        // 判断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);
+            if (topsPowerLimitSum.intValue() > powerLimit){
+                // 尖——累加累计功率超过功率限制,触发告警
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,尖累计功率超过功率限制,触发告警!");
+                leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+                // 更新或者新增逻辑处理
+                saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
-            boolean peaksIsExit = peaksNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
-            if (peaksIsExit && x.getCurrent().compareTo(limitVoltage) > 0){
-                // 采集到的数据电流大于5A,上报告警信息
-                // 上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
+        }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);
+            if (peaksPowerLimitSum.intValue() > powerLimit){
+                // 峰——累加累计功率超过功率限制,触发告警
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,峰累计功率超过功率限制,触发告警!");
+                leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+                // 更新或者新增逻辑处理
+                saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
-            boolean flatIsExit = flatNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
-            if (flatIsExit && x.getCurrent().compareTo(limitVoltage) > 0){
-                // 采集到的数据电流大于5A,上报告警信息
-                // 上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
+        }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);
+            if (flatPowerLimitSum.intValue() > powerLimit){
+                // 平——累加累计功率超过功率限制,触发告警
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,平累计功率超过功率限制,触发告警!");
+                leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+                // 更新或者新增逻辑处理
+                saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
-            boolean valleysIsExit = valleysNewPeaksAndValleysTimeConfigList.stream().anyMatch(a -> containsCreateTime(localDateTime, a.getStartTime(), a.getEndTime()));
-            if (valleysIsExit && x.getCurrent().compareTo(limitVoltage) > 0){
-                // 采集到的数据电流大于5A,上报告警信息
-                // 上报告警信息
-                leanEventWarnInfo.setDeviceWarnInfo("FPG_CLOSE状态下,采集到的数据电流大于5A,触发精益事件告警!");
-                leanEventWarnInfo.setWarnType("1");
+        } 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);
+            if (valleysPowerLimitSum.intValue() > powerLimit){
+                // 谷——累加累计功率超过功率限制,触发告警
+                leanEventWarnInfo.setDeviceWarnInfo("事件类型为FPG_POWER_LIMIT,谷累计功率超过功率限制,触发精益事件告警!");
+                leanEventWarnInfo.setWarnType(EDeviceInformationType.FPG_POWER_LIMIT.getCode());
                 leanEventWarnInfo.setDeviceWarnLevel("0");
-                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+                // 更新或者新增逻辑处理
+                saveOrUpdateLeanEventWarnInfo(fpgGatherData, leanEventWarnInfo);
             }
-        });
+        }
+    }
+
+    /**
+     * 基于采集点ID、设备ID、区域ID、峰平谷配置时间范围 动态查询mongoDB
+     * @param mongoTemplate
+     * @param timeRanges
+     * @param devicePointId
+     * @param deviceInformationId
+     * @param deviceRegionId
+     * @return
+     */
+    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));
+        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();
+            query.addCriteria(Criteria.where("createTime").gte(specifiedTimePlus8HoursStartTime).lt(specifiedTimePlus8HoursStartEndTime));
+        }
+        // 执行查询
+        List<FpgStatiscsModelMongodb> fpgStatiscsModelDataList = mongoTemplate.find(query, FpgStatiscsModelMongodb.class, "leanmodel_run_power_minute");
+        return fpgStatiscsModelDataList;
     }
 
     /**
@@ -272,14 +479,14 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
      * @param type
      * @return
      */
-    public List<PeaksAndValleysTimeConfig> getPeaksAndValleysTimeConfigByType(PeaksAndValleysTimeConfigParam peaksAndValleysTimeConfigParam, String type){
+    public List<PeaksAndValleysTimeConfig> getPeaksAndValleysTimeConfigByType(PeaksAndValleysTimeConfigParam peaksAndValleysTimeConfigParam, String type, Date createTime){
         // 定义日期格式
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
         if ("tops".equals(type)){
             List<PeaksAndValleysTimeConfig> topsPeaksAndValleysTimeConfigList = peaksAndValleysTimeConfigParam.getTops();
             List<PeaksAndValleysTimeConfig> topsNewPeaksAndValleysTimeConfigList = topsPeaksAndValleysTimeConfigList.stream().map(t->{
-                String newStartTime = sdf.format(new Date())+ " " + t.getStartTime();
-                String newEndTime = sdf.format(new Date())+ " " + t.getEndTime();
+                String newStartTime = sdf.format(createTime)+ " " + t.getStartTime();
+                String newEndTime = sdf.format(createTime)+ " " + t.getEndTime();
                 t.setStartTime(newStartTime);
                 t.setEndTime(newEndTime);
                 return t;
@@ -288,8 +495,8 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         }else if ("peaks".equals(type)){
             List<PeaksAndValleysTimeConfig> peaksPeaksAndValleysTimeConfigList = peaksAndValleysTimeConfigParam.getPeaks();
             List<PeaksAndValleysTimeConfig> peaksNewPeaksAndValleysTimeConfigList = peaksPeaksAndValleysTimeConfigList.stream().map(t->{
-                String newStartTime = sdf.format(new Date())+ " " + t.getStartTime();
-                String newEndTime = sdf.format(new Date())+ " " + t.getEndTime();
+                String newStartTime = sdf.format(createTime)+ " " + t.getStartTime();
+                String newEndTime = sdf.format(createTime)+ " " + t.getEndTime();
                 t.setStartTime(newStartTime);
                 t.setEndTime(newEndTime);
                 return t;
@@ -298,8 +505,8 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         }else if ("flat".equals(type)){
             List<PeaksAndValleysTimeConfig> flatPeaksAndValleysTimeConfigList = peaksAndValleysTimeConfigParam.getFlat();
             List<PeaksAndValleysTimeConfig> flatNewPeaksAndValleysTimeConfigList = flatPeaksAndValleysTimeConfigList.stream().map(t->{
-                String newStartTime = sdf.format(new Date())+ " " + t.getStartTime();
-                String newEndTime = sdf.format(new Date())+ " " + t.getEndTime();
+                String newStartTime = sdf.format(createTime)+ " " + t.getStartTime();
+                String newEndTime = sdf.format(createTime)+ " " + t.getEndTime();
                 t.setStartTime(newStartTime);
                 t.setEndTime(newEndTime);
                 return t;
@@ -308,8 +515,8 @@ public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoM
         }else if ("valleys".equals(type)){
             List<PeaksAndValleysTimeConfig> valleysPeaksAndValleysTimeConfigList = peaksAndValleysTimeConfigParam.getValleys();
             List<PeaksAndValleysTimeConfig> valleysNewPeaksAndValleysTimeConfigList = valleysPeaksAndValleysTimeConfigList.stream().map(t->{
-                String newStartTime = sdf.format(new Date())+ " " + t.getStartTime();
-                String newEndTime = sdf.format(new Date())+ " " + t.getEndTime();
+                String newStartTime = sdf.format(createTime)+ " " + t.getStartTime();
+                String newEndTime = sdf.format(createTime)+ " " + t.getEndTime();
                 t.setStartTime(newStartTime);
                 t.setEndTime(newEndTime);
                 return t;

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

@@ -0,0 +1,19 @@
+package org.jeecg.modules.leanEventWarn.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import org.jeecg.modules.leanEventWarn.entity.LeanEventsHostConfig;
+import org.jeecg.modules.leanEventWarn.mapper.LeanEventsHostConfigMapper;
+import org.jeecg.modules.leanEventWarn.service.ILeanEventsHostConfigService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Description: 精益事件配置关联表
+ * @Author: jeecg-boot
+ * @Date:   2024-10-30
+ * @Version: V1.0
+ */
+@Service
+public class LeanEventsHostConfigServiceImpl extends ServiceImpl<LeanEventsHostConfigMapper, LeanEventsHostConfig> implements ILeanEventsHostConfigService {
+
+}

+ 81 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/entity/SystemVariable.java

@@ -0,0 +1,81 @@
+package org.jeecg.modules.peaksAndValleysTimeConfig.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 系统变量表
+ * @Author: jeecg-boot
+ * @Date:   2024-09-11
+ * @Version: V1.0
+ */
+@Data
+@TableName("system_variable")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="system_variable对象", description="系统变量表")
+public class SystemVariable implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**主键*/
+    @TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private String id;
+    /**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    /**创建日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+    private java.util.Date createTime;
+    /**更新人*/
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+    /**更新日期*/
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+    private java.util.Date updateTime;
+    /**所属部门*/
+    @ApiModelProperty(value = "所属部门")
+    private String sysOrgCode;
+    /**变量名称*/
+    @Excel(name = "变量名称", width = 15)
+    @ApiModelProperty(value = "变量名称")
+    private String variableName;
+    /**变量地址*/
+    @Excel(name = "变量地址", width = 15)
+    @ApiModelProperty(value = "变量地址")
+    private String variableAddress;
+    /**数据类型*/
+    @Excel(name = "数据类型", width = 15)
+    @ApiModelProperty(value = "数据类型")
+    @Dict(dicCode = "sysvariable_datatype")
+    private String dataType;
+    /**默认值*/
+    @Excel(name = "默认值", width = 15)
+    @ApiModelProperty(value = "默认值")
+    private String defaultValue;
+    /**描述*/
+    @Excel(name = "描述", width = 15)
+    @ApiModelProperty(value = "描述")
+    private String description;
+    /**状态*/
+    @Excel(name = "状态", width = 15)
+    @ApiModelProperty(value = "状态")
+    @Dict(dicCode = "sysvariable_status")
+    private String status;
+}

+ 15 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/mapper/SystemVariableMapper.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.peaksAndValleysTimeConfig.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.SystemVariable;
+
+
+/**
+ * @Description: 系统变量表
+ * @Author: jeecg-boot
+ * @Date:   2024-09-11
+ * @Version: V1.0
+ */
+public interface SystemVariableMapper extends BaseMapper<SystemVariable> {
+
+}

+ 5 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/mapper/xml/SystemVariableMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.peaksAndValleysTimeConfig.mapper.SystemVariableMapper">
+
+</mapper>

+ 14 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/service/ISystemVariableService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.peaksAndValleysTimeConfig.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.SystemVariable;
+
+/**
+ * @Description: 系统变量表
+ * @Author: jeecg-boot
+ * @Date:   2024-09-11
+ * @Version: V1.0
+ */
+public interface ISystemVariableService extends IService<SystemVariable> {
+
+}

+ 19 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/service/impl/SystemVariableServiceImpl.java

@@ -0,0 +1,19 @@
+package org.jeecg.modules.peaksAndValleysTimeConfig.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.SystemVariable;
+import org.jeecg.modules.peaksAndValleysTimeConfig.mapper.SystemVariableMapper;
+import org.jeecg.modules.peaksAndValleysTimeConfig.service.ISystemVariableService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Description: 系统变量表
+ * @Author: jeecg-boot
+ * @Date:   2024-09-11
+ * @Version: V1.0
+ */
+@Service
+public class SystemVariableServiceImpl extends ServiceImpl<SystemVariableMapper, SystemVariable> implements ISystemVariableService {
+
+}

+ 1 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/DbWatch.java

@@ -16,10 +16,10 @@ import org.springframework.stereotype.Component;
 
 import java.util.Calendar;
 
-//@EnableScheduling
 @EnableAsync
 @Component
 @Slf4j
+//@EnableScheduling
 public class DbWatch {
 
 

+ 3 - 58
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java

@@ -22,13 +22,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.util.Arrays;
+
 import java.util.Date;
 import java.util.List;
 
@@ -36,6 +34,7 @@ import java.util.List;
 @EnableAsync
 @Component
 //@EnableScheduling
+
 public class OpcGatherWatch {
 
     @Autowired
@@ -61,6 +60,7 @@ public class OpcGatherWatch {
 
     @Autowired
     ILeanEventWarnInfoService leanEventWarnInfoService;
+
     // 采集频率设置值(数据库字典匹配,否则不执行查询不到设备)
     @Scheduled(fixedDelay = 500)
     public void t1(){
@@ -151,12 +151,6 @@ public class OpcGatherWatch {
                         fpgGatherData.setDevicePointId(opcPoint.getId()); // 采集点ID
                         fpgGatherData.setCreateTime(curentDate); // 创建时间
                         fpgGatherDataService.addC(fpgGatherData);
-                        if(oConvertUtils.isEmpty(opcConn.getId())){
-                            return;
-                        }
-                        String deviceInformationId = opcConn.getId();
-                        // 告警信息上报处理
-                        leanEventsHostTriggerWarnHandle(fpgGatherData, deviceInformationId);
                     }
                 }
             } catch (Exception e) {
@@ -172,53 +166,4 @@ public class OpcGatherWatch {
             }
         });
     }
-
-    /**
-     * 根据采集过来的数据、运行电流、精益事件配置(设备开启、设备关闭、FPG开启、FPG关闭《峰平谷的时间区间配置》),来触发告警信息,并保存
-     * @param fpgGatherData
-     * @param deviceInformationId
-     */
-    public void leanEventsHostTriggerWarnHandle(FpgGatherData fpgGatherData, String deviceInformationId){
-        String keyMainString = String.format("sys:opcData:syn::%s:%s", "leanEventsHost","deviceInformationMainIds");
-        String keySubString = String.format("sys:opcSynData::%s","deviceInformationSubIds");
-        // 1、根据采集过来的数据,根据主设备ID,处理精益事件配置信息(host_open;host_stop)
-        if (redisTemplate.hasKey(keyMainString)){
-            String text = oConvertUtils.getString(redisTemplate.opsForValue().get(keyMainString));
-            List<String> deviceInformationIdIds = Arrays.asList(text.split(","));
-            boolean exists = deviceInformationIdIds.stream().allMatch(x -> x.equals(deviceInformationId));
-            if (exists){
-                // 根据主设备ID查询多条精益事件设备启停信息 处理事件类型为host_open、host_stop
-                LambdaQueryWrapper<LeanEventsHost> queryLeanEventsHost = new LambdaQueryWrapper<LeanEventsHost>().eq(LeanEventsHost::getDeviceInformationId, deviceInformationId).isNotNull(LeanEventsHost::getDeviceInformationType);
-                List<LeanEventsHost> leanEventsHostList =  leanEventsHostService.list(queryLeanEventsHost);
-                leanEventsHostList.forEach(y ->{
-                    // 事件类型为host_stop、host_open,fpg_open、fpg_close
-                    if (EDeviceInformationType.HOST_OPEN.getCode().equals(y.getDeviceInformationType())){
-                        leanEventWarnInfoService.openDeviceTriggerWarnInfo(y.getDeviceInformationList(), fpgGatherData);
-                    }
-                    if (EDeviceInformationType.HOST_STOP.getCode().equals(y.getDeviceInformationType())){
-                        leanEventWarnInfoService.stopDeviceTriggerWarnInfo(y.getDeviceInformationList(), fpgGatherData);
-                    }
-                });
-            }
-        }
-        // 2、根据采集过来的数据,根据辅设备ID,处理精益事件配置信息3:FPG开,4:FPG关
-        if (redisTemplate.hasKey(keySubString)){
-            String text = oConvertUtils.getString(redisTemplate.opsForValue().get(keySubString));
-            List<String> deviceInformationIdList = Arrays.asList(text.split(","));
-            boolean exists = deviceInformationIdList.stream().allMatch(x -> x.equals(deviceInformationId));
-            if (exists){
-                // 根据辅设备ID模糊查询多条关于FPG精益事件设备启停信息 处理事件类型为fpg_open、fpg_close
-                List<LeanEventsHost> leanEventsHostList = leanEventsHostService.getFpgLeanEventsHostList(deviceInformationId);
-                leanEventsHostList.forEach(s ->{
-                    // 事件类型为fpg_open、fpg_close
-                    if (EDeviceInformationType.FPG_OPEN.getCode().equals(s.getDeviceInformationType())){
-                        leanEventWarnInfoService.openFpgTriggerWarnInfo(s.getDeviceInformationList(), fpgGatherData);
-                    }
-                    if (EDeviceInformationType.FPG_CLOSE.getCode().equals(s.getDeviceInformationType())){
-                        leanEventWarnInfoService.closeFpgTriggerWarnInfo(s.getDeviceInformationList(), fpgGatherData);
-                    }
-                });
-            }
-        }
-    }
 }

+ 1 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/modBusGatherWatch.java

@@ -25,6 +25,7 @@ import java.util.List;
 @EnableAsync
 @Component
 //@EnableScheduling
+
 public class modBusGatherWatch {
 
     @Autowired

+ 2 - 1
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/s7gatherWatch.java

@@ -23,10 +23,11 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
-@EnableScheduling
 @EnableAsync
 @Component
 @Slf4j
+//@EnableScheduling
+
 public class s7gatherWatch {
 
     @Autowired