Explorar o código

数据采集告警信息触发001

qiangxuan hai 7 meses
pai
achega
93c5f5e332
Modificáronse 18 ficheiros con 936 adicións e 1 borrados
  1. 26 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/common/enums/EDeviceInformationType.java
  2. 98 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/events/controller/LeanEventsHostController.java
  3. 73 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/events/entity/LeanEventsHost.java
  4. 18 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/events/mapper/LeanEventsHostMapper.java
  5. 13 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/events/mapper/xml/LeanEventsHostMapper.xml
  6. 17 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/events/service/ILeanEventsHostService.java
  7. 30 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/events/service/impl/LeanEventsHostServiceImpl.java
  8. 30 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/entity/LeanEventWarnInfo.java
  9. 10 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/ILeanEventWarnInfoService.java
  10. 317 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/service/impl/LeanEventWarnInfoServiceImpl.java
  11. 36 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/controller/PeaksAndValleysTimeConfigController.java
  12. 70 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/entity/PeaksAndValleysTimeConfig.java
  13. 37 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/entity/PeaksAndValleysTimeConfigParam.java
  14. 15 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/mapper/PeaksAndValleysTimeConfigMapper.java
  15. 5 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/mapper/xml/PeaksAndValleysTimeConfigMapper.xml
  16. 18 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/service/IPeaksAndValleysTimeConfigService.java
  17. 39 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/service/impl/PeaksAndValleysTimeConfigServiceImpl.java
  18. 84 1
      jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java

+ 26 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/common/enums/EDeviceInformationType.java

@@ -0,0 +1,26 @@
+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", "主设备关闭");
+
+    private final String code;
+    private final String description;
+
+
+    EDeviceInformationType(String code, String description) {
+        this.code = code;
+        this.description = description;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+}

+ 98 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/events/controller/LeanEventsHostController.java

@@ -0,0 +1,98 @@
+package org.jeecg.modules.events.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+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.events.entity.LeanEventsHost;
+import org.jeecg.modules.events.service.ILeanEventsHostService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+ /**
+ * @Description: 精益事件设备启停配置表
+ * @Author: jeecg-boot
+ * @Date:   2024-09-20
+ * @Version: V1.0
+ */
+@Api(tags="精益事件设备启停配置表")
+@RestController
+@RequestMapping("/events/leanEventsHost")
+@Slf4j
+public class LeanEventsHostController extends JeecgController<LeanEventsHost, ILeanEventsHostService> {
+	@Autowired
+	private ILeanEventsHostService leanEventsHostService;
+	
+	/**
+	 * 分页列表查询
+	 *
+	 * @param leanEventsHost
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	//@AutoLog(value = "精益事件设备启停配置表-分页列表查询")
+	@ApiOperation(value="精益事件设备启停配置表-分页列表查询", notes="精益事件设备启停配置表-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<LeanEventsHost>> queryPageList(LeanEventsHost leanEventsHost,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<LeanEventsHost> queryWrapper = QueryGenerator.initQueryWrapper(leanEventsHost, req.getParameterMap());
+		Page<LeanEventsHost> page = new Page<LeanEventsHost>(pageNo, pageSize);
+		IPage<LeanEventsHost> pageList = leanEventsHostService.page(page, queryWrapper);
+		return Result.OK(pageList);
+	}
+	
+	/**
+	 * 通过id查询
+	 *
+	 * @param id
+	 * @return
+	 */
+	//@AutoLog(value = "精益事件设备启停配置表-通过id查询")
+	@ApiOperation(value="精益事件设备启停配置表-通过id查询", notes="精益事件设备启停配置表-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<LeanEventsHost> queryById(@RequestParam(name="id",required=true) String id) {
+		LeanEventsHost leanEventsHost = leanEventsHostService.getById(id);
+		if(leanEventsHost==null) {
+			return Result.error("未找到对应数据");
+		}
+		return Result.OK(leanEventsHost);
+	}
+
+    /**
+    * 导出excel
+    *
+    * @param request
+    * @param leanEventsHost
+    */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, LeanEventsHost leanEventsHost) {
+        return super.exportXls(request, leanEventsHost, LeanEventsHost.class, "精益事件设备启停配置表");
+    }
+
+    /**
+      * 通过excel导入数据
+    *
+    * @param request
+    * @param response
+    * @return
+    */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+	@ApiOperation(value="精益事件设备启停配置表-导入", notes="精益事件设备启停配置表-导入")
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, LeanEventsHost.class);
+    }
+
+}

+ 73 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/events/entity/LeanEventsHost.java

@@ -0,0 +1,73 @@
+package org.jeecg.modules.events.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.util.Date;
+
+/**
+ * @Description: 精益事件设备启停配置表
+ * @Author: jeecg-boot
+ * @Date:   2024-09-20
+ * @Version: V1.0
+ */
+@Data
+@TableName("lean_events_host")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="lean_events_host对象", description="精益事件设备启停配置表")
+public class LeanEventsHost 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 deviceInformationId;
+	/**辅设备配置*/
+	@Excel(name = "辅设备配置", width = 15)
+    @ApiModelProperty(value = "辅设备配置")
+    private String deviceInformationList;
+	/**设备事件*/
+	@Excel(name = "设备事件", width = 15, dicCode = "lean_events_host")
+	@Dict(dicCode = "lean_events_host")
+    @ApiModelProperty(value = "设备事件")
+    private String deviceInformationType;
+    /**精益事件id*/
+    @Excel(name = "精益事件id", width = 15)
+    @ApiModelProperty(value = "精益事件id")
+    private String eventsId;
+}

+ 18 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/events/mapper/LeanEventsHostMapper.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.events.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.lettuce.core.dynamic.annotation.Param;
+import org.jeecg.modules.events.entity.LeanEventsHost;
+
+import java.util.List;
+
+/**
+ * @Description: 精益事件设备启停配置表
+ * @Author: jeecg-boot
+ * @Date:   2024-09-20
+ * @Version: V1.0
+ */
+public interface LeanEventsHostMapper extends BaseMapper<LeanEventsHost> {
+
+    List<LeanEventsHost> getFpgLeanEventsHostList(@Param("deviceInformationList") String deviceInformationList);
+}

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

@@ -0,0 +1,13 @@
+<?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.events.mapper.LeanEventsHostMapper">
+
+    <select id="getFpgLeanEventsHostList" resultType="org.jeecg.modules.events.entity.LeanEventsHost">
+        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';
+    </select>
+</mapper>

+ 17 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/events/service/ILeanEventsHostService.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.events.service;
+
+import org.jeecg.modules.events.entity.LeanEventsHost;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * @Description: 精益事件设备启停配置表
+ * @Author: jeecg-boot
+ * @Date:   2024-09-20
+ * @Version: V1.0
+ */
+public interface ILeanEventsHostService extends IService<LeanEventsHost> {
+
+    List<LeanEventsHost> getFpgLeanEventsHostList(String deviceInformationList);
+}

+ 30 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/events/service/impl/LeanEventsHostServiceImpl.java

@@ -0,0 +1,30 @@
+package org.jeecg.modules.events.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.events.entity.LeanEventsHost;
+import org.jeecg.modules.events.mapper.LeanEventsHostMapper;
+import org.jeecg.modules.events.service.ILeanEventsHostService;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @Description: 精益事件设备启停配置表
+ * @Author: jeecg-boot
+ * @Date:   2024-09-20
+ * @Version: V1.0
+ */
+@Service
+public class LeanEventsHostServiceImpl extends ServiceImpl<LeanEventsHostMapper, LeanEventsHost> implements ILeanEventsHostService {
+
+    @Autowired
+    private LeanEventsHostMapper leanEventsHostMapper;
+
+    @Override
+    public List<LeanEventsHost> getFpgLeanEventsHostList(String deviceInformationList) {
+        return leanEventsHostMapper.getFpgLeanEventsHostList(deviceInformationList);
+    }
+}

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

@@ -1,9 +1,14 @@
 package org.jeecg.modules.leanEventWarn.entity;
 
 import java.io.Serializable;
+<<<<<<<< HEAD:jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/entity/LeanEventWarnInfo.java
 import java.io.UnsupportedEncodingException;
 import java.util.Date;
 import java.math.BigDecimal;
+========
+import java.math.BigDecimal;
+
+>>>>>>>> f7c25db (数据采集告警信息触发001):jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgGatherData.java
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -58,6 +63,7 @@ public class LeanEventWarnInfo implements Serializable {
 	/**区域ID*/
 	@Excel(name = "区域ID", width = 15)
     @ApiModelProperty(value = "区域ID")
+<<<<<<<< HEAD:jeecg-module-gather/src/main/java/org/jeecg/modules/leanEventWarn/entity/LeanEventWarnInfo.java
     private String deviceRegionId;
 	/**设备ID*/
 	@Excel(name = "设备ID", width = 15)
@@ -83,4 +89,28 @@ public class LeanEventWarnInfo implements Serializable {
 	@Excel(name = "拓展字段", width = 15)
     @ApiModelProperty(value = "拓展字段")
     private String remark;
+========
+    private java.lang.String deviceRegionId;
+	/**设备id*/
+	@Excel(name = "设备id", width = 15)
+    @ApiModelProperty(value = "设备id")
+    private java.lang.String deviceInformationId;
+	/**运行电流*/
+	@Excel(name = "运行电流", width = 15)
+    @ApiModelProperty(value = "运行电流")
+    private BigDecimal current;
+	/**有功功率*/
+	@Excel(name = "有功功率", width = 15)
+    @ApiModelProperty(value = "有功功率")
+    private BigDecimal activePower;
+	/**电压*/
+	@Excel(name = "电压", width = 15)
+    @ApiModelProperty(value = "电压")
+    private BigDecimal voltage;
+	/**峰平谷类型*/
+	@Excel(name = "峰平谷类型", width = 15, dicCode = "fpg_type")
+	@Dict(dicCode = "fpg_type")
+    @ApiModelProperty(value = "峰平谷类型")
+    private java.lang.String fpgType;
+>>>>>>>> f7c25db (数据采集告警信息触发001):jeecg-module-gather/src/main/java/org/jeecg/modules/gatherData/entity/FpgGatherData.java
 }

+ 10 - 0
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.gatherData.entity.FpgGatherData;
 import org.jeecg.modules.leanEventWarn.entity.LeanEventWarnInfo;
 
 /**
@@ -11,4 +12,13 @@ import org.jeecg.modules.leanEventWarn.entity.LeanEventWarnInfo;
  */
 public interface ILeanEventWarnInfoService extends IService<LeanEventWarnInfo> {
 
+    void insertWarnInfo(LeanEventWarnInfo leanEventWarnInfo);
+
+    void openDeviceTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData);
+
+    void stopDeviceTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData);
+
+    void openFpgTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData);
+
+    void closeFpgTriggerWarnInfo(String deviceInformationList, FpgGatherData fpgGatherData);
 }

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

@@ -3,10 +3,34 @@ package org.jeecg.modules.leanEventWarn.service.impl;
 import org.jeecg.modules.leanEventWarn.entity.LeanEventWarnInfo;
 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.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfigParam;
+import org.jeecg.modules.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import java.math.BigDecimal;
+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.Date;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * @Description: 精益事件告警信息表
  * @Author: jeecg-boot
@@ -16,4 +40,297 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoMapper, LeanEventWarnInfo> implements ILeanEventWarnInfoService {
 
+
+    @Autowired
+    ILeanEventWarnInfoService leanEventWarnInfoService;
+
+    @Autowired
+    IFpgGatherDataService fpgGatherDataService;
+
+    @Autowired
+    IPeaksAndValleysTimeConfigService peaksAndValleysTimeConfigService;
+
+    @Override
+    public void insertWarnInfo(LeanEventWarnInfo leanEventWarnInfo) {
+        baseMapper.insert(leanEventWarnInfo);
+    }
+
+    @Override
+    public void openDeviceTriggerWarnInfo(String deviceInformationList, 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)){
+            // 上报告警信息
+            leanEventWarnInfo.setDeviceWarnInfo("HOST_OPEN状态下,查询采集数据为空,主设备未开启,触发精益事件告警!");
+            leanEventWarnInfo.setWarnType("1");
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+            return;
+        }
+        // 根据采集点的运行电流,判断是否需要上报告警信息 (辅设备电流小于等于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) {
+        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)){
+            // 上报告警信息
+            leanEventWarnInfo.setDeviceWarnInfo("HOST_CLOSE状态下,查询采集数据为空,主设备未开启,触发精益事件告警!");
+            leanEventWarnInfo.setWarnType("1");
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+            return;
+        }
+        // 根据采集点的电流,判断是否需要上报告警信息 (辅设备电流大于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) {
+        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);
+            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_OPEN状态下,尖时段采集到的数据电流小于5A,触发精益事件告警!");
+                leanEventWarnInfo.setWarnType("1");
+                leanEventWarnInfo.setDeviceWarnLevel("0");
+                leanEventWarnInfoService.insertWarnInfo(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");
+                leanEventWarnInfo.setDeviceWarnLevel("0");
+                leanEventWarnInfoService.insertWarnInfo(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");
+                leanEventWarnInfo.setDeviceWarnLevel("0");
+                leanEventWarnInfoService.insertWarnInfo(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");
+                leanEventWarnInfo.setDeviceWarnLevel("0");
+                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+            }
+        });
+    }
+
+    @Override
+    public void closeFpgTriggerWarnInfo(String deviceInformationList, 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_CLOSE状态下,查询采集数据为空,触发精益事件告警!");
+            leanEventWarnInfo.setWarnType("1");
+            leanEventWarnInfo.setDeviceWarnLevel("0");
+            leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+            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");
+                leanEventWarnInfo.setDeviceWarnLevel("0");
+                leanEventWarnInfoService.insertWarnInfo(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");
+                leanEventWarnInfo.setDeviceWarnLevel("0");
+                leanEventWarnInfoService.insertWarnInfo(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");
+                leanEventWarnInfo.setDeviceWarnLevel("0");
+                leanEventWarnInfoService.insertWarnInfo(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");
+                leanEventWarnInfo.setDeviceWarnLevel("0");
+                leanEventWarnInfoService.insertWarnInfo(leanEventWarnInfo);
+            }
+        });
+    }
+
+    /**
+     * 处理峰平谷的配置,并拼接开始时间和结束时间
+     * @param peaksAndValleysTimeConfigParam
+     * @param type
+     * @return
+     */
+    public List<PeaksAndValleysTimeConfig> getPeaksAndValleysTimeConfigByType(PeaksAndValleysTimeConfigParam peaksAndValleysTimeConfigParam, String type){
+        // 定义日期格式
+        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();
+                t.setStartTime(newStartTime);
+                t.setEndTime(newEndTime);
+                return t;
+            }).collect(Collectors.toList());
+            return topsNewPeaksAndValleysTimeConfigList;
+        }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();
+                t.setStartTime(newStartTime);
+                t.setEndTime(newEndTime);
+                return t;
+            }).collect(Collectors.toList());
+            return peaksNewPeaksAndValleysTimeConfigList;
+        }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();
+                t.setStartTime(newStartTime);
+                t.setEndTime(newEndTime);
+                return t;
+            }).collect(Collectors.toList());
+            return flatNewPeaksAndValleysTimeConfigList;
+        }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();
+                t.setStartTime(newStartTime);
+                t.setEndTime(newEndTime);
+                return t;
+            }).collect(Collectors.toList());
+            return valleysNewPeaksAndValleysTimeConfigList;
+        }
+        return null;
+    }
+
+    /**
+     * 判断创建时间是否在开始时间和结束时间范围内
+     * @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));
+    }
 }

+ 36 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/controller/PeaksAndValleysTimeConfigController.java

@@ -0,0 +1,36 @@
+package org.jeecg.modules.peaksAndValleysTimeConfig.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfigParam;
+import org.jeecg.modules.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+
+ /**
+ * @Description: 峰平谷时段配置
+ * @Author: jeecg-boot
+ * @Date:   2024-09-25
+ * @Version: V1.0
+ */
+@Api(tags="峰平谷时段配置")
+@RestController
+@RequestMapping("/systemConfig/peaksAndValleysTimeConfig")
+@Slf4j
+public class PeaksAndValleysTimeConfigController extends JeecgController<PeaksAndValleysTimeConfig, IPeaksAndValleysTimeConfigService> {
+
+}

+ 70 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/entity/PeaksAndValleysTimeConfig.java

@@ -0,0 +1,70 @@
+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.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 峰平谷时段配置
+ * @Author: jeecg-boot
+ * @Date:   2024-09-25
+ * @Version: V1.0
+ */
+@Data
+@TableName("peaks_and_valleys_time_config")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="peaks_and_valleys_time_config对象", description="峰平谷时段配置")
+public class PeaksAndValleysTimeConfig 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 = 20, format = "HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "HH:mm:ss")
+    @DateTimeFormat(pattern="HH:mm:ss")
+    @ApiModelProperty(value = "开始时间")
+    private String startTime;
+	/**结束时间*/
+	@Excel(name = "结束时间", width = 20, format = "HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "HH:mm:ss")
+    @DateTimeFormat(pattern="HH:mm:ss")
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+	/**峰平谷类型*/
+	@Excel(name = "峰平谷类型", width = 15)
+    @ApiModelProperty(value = "峰平谷类型(0:峰 1:平 2:谷)")
+    private String type;
+}

+ 37 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/entity/PeaksAndValleysTimeConfigParam.java

@@ -0,0 +1,37 @@
+package org.jeecg.modules.peaksAndValleysTimeConfig.entity;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @Description: 峰平谷时段配置
+ * @Author: jeecg-boot
+ * @Date:   2024-09-25
+ * @Version: V1.0
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="峰平谷时段配置请求参数", description="峰平谷时段配置请求参数")
+public class PeaksAndValleysTimeConfigParam implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "尖")
+    private List<PeaksAndValleysTimeConfig> tops;
+
+    @ApiModelProperty(value = "峰")
+    private List<PeaksAndValleysTimeConfig> peaks;
+
+    @ApiModelProperty(value = "平")
+    private List<PeaksAndValleysTimeConfig> flat;
+
+    @ApiModelProperty(value = "谷")
+    private List<PeaksAndValleysTimeConfig> valleys;
+
+}

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

@@ -0,0 +1,15 @@
+package org.jeecg.modules.peaksAndValleysTimeConfig.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
+
+/**
+ * @Description: 峰平谷时段配置
+ * @Author: jeecg-boot
+ * @Date:   2024-09-25
+ * @Version: V1.0
+ */
+public interface PeaksAndValleysTimeConfigMapper extends BaseMapper<PeaksAndValleysTimeConfig> {
+
+}

+ 5 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/mapper/xml/PeaksAndValleysTimeConfigMapper.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.PeaksAndValleysTimeConfigMapper">
+
+</mapper>

+ 18 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/peaksAndValleysTimeConfig/service/IPeaksAndValleysTimeConfigService.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.peaksAndValleysTimeConfig.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfigParam;
+
+
+/**
+ * @Description: 峰平谷时段配置
+ * @Author: jeecg-boot
+ * @Date:   2024-09-25
+ * @Version: V1.0
+ */
+public interface IPeaksAndValleysTimeConfigService extends IService<PeaksAndValleysTimeConfig> {
+
+    PeaksAndValleysTimeConfigParam get();
+
+}

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

@@ -0,0 +1,39 @@
+package org.jeecg.modules.peaksAndValleysTimeConfig.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
+import org.jeecg.modules.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfigParam;
+import org.jeecg.modules.peaksAndValleysTimeConfig.mapper.PeaksAndValleysTimeConfigMapper;
+import org.jeecg.modules.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Description: 峰平谷时段配置
+ * @Author: jeecg-boot
+ * @Date:   2024-09-25
+ * @Version: V1.0
+ */
+@Service
+public class PeaksAndValleysTimeConfigServiceImpl extends ServiceImpl<PeaksAndValleysTimeConfigMapper, PeaksAndValleysTimeConfig> implements IPeaksAndValleysTimeConfigService {
+
+    @Override
+    public PeaksAndValleysTimeConfigParam get() {
+        PeaksAndValleysTimeConfigParam res = new PeaksAndValleysTimeConfigParam();
+        //获取尖
+        res.setTops(baseMapper.selectList(new LambdaQueryWrapper<PeaksAndValleysTimeConfig>()
+                .eq(PeaksAndValleysTimeConfig::getType,"tops").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
+        //获取峰
+        res.setPeaks(baseMapper.selectList(new LambdaQueryWrapper<PeaksAndValleysTimeConfig>()
+                .eq(PeaksAndValleysTimeConfig::getType,"peaks").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
+        //获取平
+        res.setFlat(baseMapper.selectList(new LambdaQueryWrapper<PeaksAndValleysTimeConfig>()
+                .eq(PeaksAndValleysTimeConfig::getType,"flat").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
+        //获取谷
+        res.setValleys(baseMapper.selectList(new LambdaQueryWrapper<PeaksAndValleysTimeConfig>()
+                .eq(PeaksAndValleysTimeConfig::getType,"valleys").orderByAsc(PeaksAndValleysTimeConfig::getStartTime)));
+        return res;
+    }
+}
+
+

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

@@ -4,19 +4,30 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.common.entity.LogTopic;
+import org.jeecg.modules.common.enums.EDeviceInformationType;
 import org.jeecg.modules.dataRepository.entity.PointData;
 import org.jeecg.modules.device.entity.DeviceInformation;
 import org.jeecg.modules.device.service.IDeviceInformationService;
 import org.jeecg.modules.deviceConn.opc.utils.OpcUaServerUtils;
 import org.jeecg.modules.devicePoint.entity.DevicePoint;
 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.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.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
@@ -35,6 +46,14 @@ public class OpcGatherWatch {
     @Autowired
     MongoTemplate mongoTemplate;
 
+    @Autowired
+    RedisTemplate redisTemplate;
+
+    @Autowired
+    ILeanEventsHostService leanEventsHostService;
+
+    @Autowired
+    ILeanEventWarnInfoService leanEventWarnInfoService;
     // 采集频率设置值(数据库字典匹配,否则不执行查询不到设备)
     @Scheduled(fixedDelay = 500)
     public void t1(){
@@ -116,6 +135,19 @@ public class OpcGatherWatch {
                         mongoTemplate.insert(new PointData(opcPoint, freq, readText, curentDate),  opcPoint.getId());
                         //更新数据库点位信息
                         devicePointService.updateById(opcPoint);
+                        // 存入采集设备
+                        FpgGatherData fpgGatherData = new FpgGatherData();
+                        fpgGatherData.setDeviceInformationId(opcConn.getId()); // 设备ID
+                        fpgGatherData.setDeviceRegionId(opcConn.getDeviceRegionId()); // 区域id
+                        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) {
@@ -124,8 +156,59 @@ public class OpcGatherWatch {
                 //更新数据库设备信息
                 deviceInformationService.updateById(opcConn);
                 //关闭连接
-                if(opcUaClient != null)opcUaClient.disconnect();
+                if(opcUaClient != null) {
+                    opcUaClient.disconnect();
+                }
             }
         });
     }
+
+    /**
+     * 根据采集过来的数据、运行电流、精益事件配置(设备开启、设备关闭、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);
+                    }
+                });
+            }
+        }
+    }
 }