瀏覽代碼

Merge branch 'master' into fpg-master

# Conflicts:
#	jeecg-module-gather/src/main/java/org/jeecg/modules/common/enums/EDeviceInformationType.java
#	jeecg-module-gather/src/main/java/org/jeecg/modules/events/mapper/xml/LeanEventsHostMapper.xml
#	jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgGatherData.java
#	jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/entity/LeanEventWarnInfo.java
#	jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/ILeanEventWarnInfoService.java
#	jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/impl/LeanEventWarnInfoServiceImpl.java
#	jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java
guoqiang 7 月之前
父節點
當前提交
7ecae59fe1

+ 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;

+ 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>

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

@@ -119,148 +119,148 @@ public class LeanModelStatistics {
         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());
+            // 处理数据业务逻辑
+            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";
                         }
-                        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;
                         }
-                        // 定义尖峰平谷
-                        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));
+                    });
+                    // 重组对象
+                    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));
                         }
-                        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));
                             }
-                            // 总功率处理
-                            ((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()));
-                                }
+                            // 金额处理
+                            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());
+                        mongoTemplate.updateFirst(query, update, FpgStatiscsModelMongodb.class, "leanmodel_" + fpgLeanModeInfo.getLeanModelCode());
+                    } else { // 为空直接插入
+                        // 将点位数据存入mongo中
+                        mongoTemplate.insert(fpgStatiscsModelData, "leanmodel_" + fpgLeanModeInfo.getLeanModelCode());
                     }
-                });
+                }catch (Exception e) {
+                    log.error(e.getMessage());
+                }
+            });
         });
     }
 

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

@@ -31,82 +31,82 @@ import java.util.Date;
 public class FpgLeanModel 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;
-	/**名称*/
-	@Excel(name = "名称", width = 15)
+    /**名称*/
+    @Excel(name = "名称", width = 15)
     @ApiModelProperty(value = "名称")
     private String title;
-	/**模型编号*/
-	@Excel(name = "模型编号", width = 15)
+    /**模型编号*/
+    @Excel(name = "模型编号", width = 15)
     @ApiModelProperty(value = "模型编号")
     private String leanModelCode;
-	/**功率 1: 开启 2: 关闭*/
-	@Excel(name = "功率 1: 开启 2: 关闭", width = 15)
+    /**功率 1: 开启 2: 关闭*/
+    @Excel(name = "功率 1: 开启 2: 关闭", width = 15)
     @ApiModelProperty(value = "功率 1: 开启 2: 关闭")
     private Integer power;
-	/**统计单位*/
-	@Excel(name = "统计单位", width = 15)
+    /**统计单位*/
+    @Excel(name = "统计单位", width = 15)
     @Dict(dicCode = "lean_model_unit")
     @ApiModelProperty(value = "统计单位")
     private String totalUnit;
-	/**班次 1*/
-	@Excel(name = "班次 1", width = 15)
+    /**班次 1*/
+    @Excel(name = "班次 1", width = 15)
     @Dict(dicCode = "lean_model_class")
     @ApiModelProperty(value = "班次 1")
     private Integer classUnit;
-	/**尖计费单价(元)*/
-	@Excel(name = "尖计费单价(元)", width = 15)
+    /**尖计费单价(元)*/
+    @Excel(name = "尖计费单价(元)", width = 15)
     @ApiModelProperty(value = "尖计费单价(元)")
     private BigDecimal topsPrice;
-	/**状态*/
-	@Excel(name = "状态", width = 15)
+    /**状态*/
+    @Excel(name = "状态", width = 15)
     @ApiModelProperty(value = "状态")
     private String status;
-	/**备注*/
-	@Excel(name = "备注", width = 15)
+    /**备注*/
+    @Excel(name = "备注", width = 15)
     @ApiModelProperty(value = "备注")
     private String remark;
-	/**峰计费单价(元)*/
-	@Excel(name = "峰计费单价(元)", width = 15)
+    /**峰计费单价(元)*/
+    @Excel(name = "峰计费单价(元)", width = 15)
     @ApiModelProperty(value = "峰计费单价(元)")
     private BigDecimal peaksPrice;
-	/**平计费单价(元)*/
-	@Excel(name = "平计费单价(元)", width = 15)
+    /**平计费单价(元)*/
+    @Excel(name = "平计费单价(元)", width = 15)
     @ApiModelProperty(value = "平计费单价(元)")
     private BigDecimal flatPrice;
-	/**谷计费单价(元)*/
-	@Excel(name = "谷计费单价(元)", width = 15)
+    /**谷计费单价(元)*/
+    @Excel(name = "谷计费单价(元)", width = 15)
     @ApiModelProperty(value = "谷计费单价(元)")
     private BigDecimal valleysPrice;
-	/**核算占比% 1:开启 2: 关闭*/
-	@Excel(name = "核算占比% 1:开启 2: 关闭", width = 15)
+    /**核算占比% 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)
+    /**运行时长 1:开启 2: 关闭*/
+    @Excel(name = "运行时长 1:开启 2: 关闭", width = 15)
     @Dict(dicCode = "proportion_run_status")
     @ApiModelProperty(value = "运行时长 1:开启 2: 关闭")
     private Integer runTime;

+ 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;
 }

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

@@ -18,22 +18,22 @@ public class FpgStatiscsModelData{
 
     @ApiModelProperty(value = "更新日期")
     private Date updateTime;
-	/**采集点ID*/
+    /**采集点ID*/
     @ApiModelProperty(value = "采集点ID")
     private String devicePointId;
-	/**区域ID*/
+    /**区域ID*/
     @ApiModelProperty(value = "区域ID")
     private String deviceRegionId;
-	/**设备id*/
+    /**设备id*/
     @ApiModelProperty(value = "设备id")
     private String deviceInformationId;
     /**产生费用*/
     @ApiModelProperty(value = "产生费用")
     private BigDecimal amount;
-	/**运行时长*/
+    /**运行时长*/
     @ApiModelProperty(value = "运行时长")
     private BigDecimal ingTime;
-	/**运行总功率*/
+    /**运行总功率*/
     @ApiModelProperty(value = "运行总功率")
     private BigDecimal power;
     /**尖总功率*/

+ 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;
 }

+ 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);
 }

+ 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;

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

@@ -26,6 +26,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import java.util.Arrays;
+
 import java.util.Date;
 import java.util.List;
 
@@ -33,6 +34,7 @@ import java.util.List;
 @EnableAsync
 @Component
 //@EnableScheduling
+
 public class OpcGatherWatch {
 
     @Autowired
@@ -58,6 +60,7 @@ public class OpcGatherWatch {
 
     @Autowired
     ILeanEventWarnInfoService leanEventWarnInfoService;
+
     // 采集频率设置值(数据库字典匹配,否则不执行查询不到设备)
     @Scheduled(fixedDelay = 500)
     public void t1(){
@@ -148,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) {
@@ -169,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);
-                    }
-                });
-            }
-        }
-    }
 }