浏览代码

历史数据查询加上时间;fix仪表状态第三种(通过判断原始模拟量位号突变超过某阈值)

LLL 5 月之前
父节点
当前提交
2dfe694568

+ 3 - 2
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/controller/InterlockDetailHistoryController.java

@@ -13,6 +13,7 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.detail.dto.InterlockDetailQueryDTO;
+import org.jeecg.modules.history.dto.InterlockHistoryQueryDTO;
 import org.jeecg.modules.history.entity.InterlockDetailHistory;
 import org.jeecg.modules.history.service.IInterlockDetailHistoryService;
 
@@ -58,12 +59,12 @@ public class InterlockDetailHistoryController extends JeecgController<InterlockD
 	 */
 	@ApiOperation(".联锁历史数据——各种逻辑状态分页查询")
 	@GetMapping("/list1")
-	public Result<IPage<InterlockSummaryHistoryVO>> list(InterlockSummaryHistoryVO vo,
+	public Result<IPage<InterlockSummaryHistoryVO>> list(InterlockHistoryQueryDTO dto,
 														 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
 														 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
 														 HttpServletRequest req){
 		Page<InterlockSummaryHistoryVO> page = new Page<>(pageNo,pageSize);
-		IPage<InterlockSummaryHistoryVO> pageList = interlockDetailHistoryService.getPage(page, vo);
+		IPage<InterlockSummaryHistoryVO> pageList = interlockDetailHistoryService.getPage(page, dto);
 		return Result.OK(pageList);
 	}
 

+ 86 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/dto/InterlockHistoryQueryDTO.java

@@ -0,0 +1,86 @@
+package org.jeecg.modules.history.dto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+/**
+ * 功能描述
+ *
+ * @author: nn
+ * @date: 2024年06月06日 14:25
+ */
+@Data
+public class InterlockHistoryQueryDTO {
+
+    /**id*/
+    @TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "id")
+    private java.lang.String id;
+    /**联锁总表id*/
+    @Excel(name = "联锁总表id", width = 15)
+    @ApiModelProperty(value = "联锁总表id")
+    private java.lang.String summaryid;
+    /**联锁名称*/
+    @Excel(name = "联锁名称", width = 15)
+    @ApiModelProperty(value = "联锁名称")
+    private java.lang.String interlockname;
+    /**联锁条件值*/
+    @Excel(name = "联锁条件值", width = 15)
+    @ApiModelProperty(value = "联锁条件值")
+    private java.lang.String interlockCondition;
+    /**联锁条件点位*/
+    @Excel(name = "联锁条件点位", width = 15)
+    @ApiModelProperty(value = "联锁条件点位")
+    private java.lang.String interlockConditionTag;
+    /**仪表状态*/
+    @Excel(name = "仪表状态", width = 15)
+    @ApiModelProperty(value = "仪表状态")
+    @Dict(dicCode = "instrument_status")
+    private java.lang.String instrumentStatus;
+    /**控制系统状态*/
+    @Excel(name = "控制系统状态", width = 15)
+    @ApiModelProperty(value = "控制系统状态")
+    @Dict(dicCode = "control_system_status")
+    private java.lang.String controlSystemStatus;
+    /**联锁状态*/
+    @Excel(name = "联锁状态", width = 15)
+    @ApiModelProperty(value = "联锁状态")
+    @Dict(dicCode = "interlock_status")
+    private java.lang.String interlockStatus;
+    /**回路健康级别*/
+    @Excel(name = "回路健康级别", width = 15)
+    @ApiModelProperty(value = "回路健康级别")
+    private java.lang.String loopHealthLevel;
+    /**旁路状态*/
+    @Dict(dicCode = "bypass")
+    @ApiModelProperty(value = "旁路状态")
+    private java.lang.String bypass;
+
+    /**开始时间*/
+    @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 beginTime;
+    /**结束时间*/
+    @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 endTime;
+
+
+    /**系统id*/
+    @Excel(name = "系统id", width = 15)
+    @ApiModelProperty(value = "系统id")
+    private java.lang.String interlockSystemId;
+    /**装置id*/
+    @Excel(name = "装置id", width = 15)
+    @ApiModelProperty(value = "装置id")
+    private java.lang.String interlockApparatusId;
+
+}

+ 2 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/InterlockDetailHistoryMapper.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.detail.dto.InterlockDetailQueryDTO;
+import org.jeecg.modules.history.dto.InterlockHistoryQueryDTO;
 import org.jeecg.modules.history.entity.InterlockDetailHistory;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.history.vo.InterlockDetailHistoryQueryVO;
@@ -27,6 +28,6 @@ public interface InterlockDetailHistoryMapper extends BaseMapper<InterlockDetail
     /**
      * 联锁历史数据——各种逻辑状态分页查询
      */
-    IPage<InterlockSummaryHistoryVO> getPage(Page<InterlockSummaryHistoryVO> page, InterlockSummaryHistoryVO vo);
+    IPage<InterlockSummaryHistoryVO> getPage(Page<InterlockSummaryHistoryVO> page, InterlockHistoryQueryDTO dto);
 
 }

+ 11 - 9
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/mapper/xml/InterlockDetailHistoryMapper.xml

@@ -16,18 +16,20 @@
     </select>
 
     <!-- 联锁总历史数据表-分页列表查询(各种逻辑状态)-->
-    <select id="getPage" parameterType="org.jeecg.modules.history.vo.InterlockSummaryHistoryVO" resultType="org.jeecg.modules.history.vo.InterlockSummaryHistoryVO">
+    <select id="getPage" parameterType="org.jeecg.modules.history.dto.InterlockHistoryQueryDTO" resultType="org.jeecg.modules.history.vo.InterlockSummaryHistoryVO">
         select d.id, d.summaryid, d.interlockname, d.interlock_condition, d.interlock_condition_tag, d.instrument_status, d.control_system_status,
-        s.interlock_status, s.loop_health_level, d.bypass
+        s.interlock_status, s.loop_health_level, d.bypass, s.tag_time
         from interlock_detail_history d left join interlock_summary_history s on d.summaryid = s.id
         <where>
-            <if test="vo.interlockname != null and vo.interlockname != ''"> and d.interlockname like concat('%', #{vo.interlockname}, '%')</if>
-            <if test="vo.interlockCondition != null and vo.interlockCondition != ''"> and d.interlock_condition = #{vo.interlockCondition}</if>
-            <if test="vo.interlockConditionTag != null and vo.interlockConditionTag != ''"> and d.interlock_condition_tag like concat('%',#{vo.interlockConditionTag},'%')</if>
-            <if test="vo.instrumentStatus != null and vo.instrumentStatus != ''"> and d.instrument_status = #{vo.instrumentStatus}</if>
-            <if test="vo.controlSystemStatus != null and vo.controlSystemStatus != ''"> and d.control_system_status = #{vo.controlSystemStatus}</if>
-            <if test="vo.interlockStatus != null and vo.interlockStatus != ''"> and s.interlock_status = #{vo.interlockStatus}</if>
-            <if test="vo.loopHealthLevel != null and vo.loopHealthLevel != ''"> and s.loop_health_level = #{vo.loopHealthLevel}</if>
+            <if test="dto.interlockname != null and dto.interlockname != ''"> and d.interlockname like concat('%', #{dto.interlockname}, '%')</if>
+            <if test="dto.interlockCondition != null and dto.interlockCondition != ''"> and d.interlock_condition = #{dto.interlockCondition}</if>
+            <if test="dto.interlockConditionTag != null and dto.interlockConditionTag != ''"> and d.interlock_condition_tag like concat('%',#{dtodtodto.interlockConditionTag},'%')</if>
+            <if test="dto.instrumentStatus != null and dtodto.instrumentStatus != ''"> and d.instrument_status = #{dto.instrumentStatus}</if>
+            <if test="dto.controlSystemStatus != null and dto.controlSystemStatus != ''"> and d.control_system_status = #{dto.controlSystemStatus}</if>
+            <if test="dto.interlockStatus != null and dto.interlockStatus != ''"> and s.interlock_status = #{dto.interlockStatus}</if>
+            <if test="dto.loopHealthLevel != null and dto.loopHealthLevel != ''"> and s.loop_health_level = #{dto.loopHealthLevel}</if>
+            <if test="dto.beginTime != null "> and STR_TO_DATE(s.tag_time, '%Y-%m-%d %H:%i:%s')  &gt; #{dto.beginTime} </if>
+            <if test="dto.endTime != null "> and STR_TO_DATE(s.tag_time, '%Y-%m-%d %H:%i:%s')  &lt; #{dto.endTime} </if>
         </where>
         order by s.create_time desc
     </select>

+ 2 - 1
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/IInterlockDetailHistoryService.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.history.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.jeecg.modules.detail.dto.InterlockDetailQueryDTO;
+import org.jeecg.modules.history.dto.InterlockHistoryQueryDTO;
 import org.jeecg.modules.history.entity.InterlockDetailHistory;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.history.vo.InterlockDetailHistoryQueryVO;
@@ -24,6 +25,6 @@ public interface IInterlockDetailHistoryService extends IService<InterlockDetail
     /**
      * 联锁历史数据——各种逻辑状态分页查询
      */
-    IPage<InterlockSummaryHistoryVO> getPage(Page<InterlockSummaryHistoryVO> page, InterlockSummaryHistoryVO vo);
+    IPage<InterlockSummaryHistoryVO> getPage(Page<InterlockSummaryHistoryVO> page, InterlockHistoryQueryDTO dto);
 
 }

+ 3 - 2
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockDetailHistoryServiceImpl.java

@@ -3,6 +3,7 @@ package org.jeecg.modules.history.service.impl;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import org.jeecg.modules.detail.dto.InterlockDetailQueryDTO;
+import org.jeecg.modules.history.dto.InterlockHistoryQueryDTO;
 import org.jeecg.modules.history.entity.InterlockDetailHistory;
 import org.jeecg.modules.history.mapper.InterlockDetailHistoryMapper;
 import org.jeecg.modules.history.mapper.InterlockSummaryHistoryMapper;
@@ -37,8 +38,8 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
     /**
      * 联锁历史数据——各种逻辑状态分页查询
      */
-    public IPage<InterlockSummaryHistoryVO> getPage(Page<InterlockSummaryHistoryVO> page, InterlockSummaryHistoryVO vo){
-        return interlockDetailHistoryMapper.getPage(page, vo);
+    public IPage<InterlockSummaryHistoryVO> getPage(Page<InterlockSummaryHistoryVO> page, InterlockHistoryQueryDTO dto){
+        return interlockDetailHistoryMapper.getPage(page, dto);
     }
 
 }

+ 58 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/vo/InterlockExportVO.java

@@ -0,0 +1,58 @@
+package org.jeecg.modules.history.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.List;
+
+/**
+ * 功能描述
+ *
+ * @author: nn
+ * @date: 2024年06月06日 9:04
+ */
+@Data
+public class InterlockExportVO {
+
+
+    /**装置id*/
+    @Excel(name = "装置id", width = 15)
+    @ApiModelProperty(value = "装置id")
+    private java.lang.String interlockApparatusId;
+    /**系统id*/
+    @Excel(name = "系统id", width = 15)
+    @ApiModelProperty(value = "系统id")
+    private java.lang.String interlockSystemId;
+    /**装置名称*/
+    @Excel(name = "装置名称", width = 15)
+    @ApiModelProperty(value = "装置名称")
+    private java.lang.String interlockApparatusName;
+    /**系统名称*/
+    @Excel(name = "系统名称", width = 15)
+    @ApiModelProperty(value = "系统名称")
+    private java.lang.String interlockSystemName;
+    /**开始时间*/
+    @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 beginTime;
+    /**结束时间*/
+    @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 endTime;
+    /**投用率*/
+    @Excel(name = "投用率", width = 15)
+    @ApiModelProperty(value = "投用率")
+    private java.lang.String tyl;
+
+
+    List<InterlockSummaryHistoryVO> summaryHistoryVOS;
+
+}

+ 3 - 0
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/vo/InterlockSummaryHistoryVO.java

@@ -59,5 +59,8 @@ public class InterlockSummaryHistoryVO {
     @Dict(dicCode = "bypass")
     @ApiModelProperty(value = "旁路状态")
     private java.lang.String bypass;
+    /**采集时间*/
+    @ApiModelProperty(value = "采集时间")
+    private java.lang.String tagTime;
 
 }

+ 62 - 2
jeecg-module-interlock/src/main/java/org/jeecg/modules/summary/service/impl/InterlockSummaryServiceImpl.java

@@ -1,7 +1,9 @@
 package org.jeecg.modules.summary.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.base.mapper.InterlockBaseMapper;
 import org.jeecg.modules.base.service.IInterlockBaseService;
 import org.jeecg.modules.detail.convert.InterlockDetailConvert;
@@ -9,6 +11,8 @@ import org.jeecg.modules.detail.dto.InterlockDetailAddDTO;
 import org.jeecg.modules.detail.entity.InterlockDetail;
 import org.jeecg.modules.detail.mapper.InterlockDetailMapper;
 import org.jeecg.modules.detail.vo.InterlockDetailEditQueryVO;
+import org.jeecg.modules.iotedgeCollectData.entity.IotedgeCollectData;
+import org.jeecg.modules.iotedgeCollectData.service.IIotedgeCollectDataService;
 import org.jeecg.modules.summary.constants.InterlockConstants;
 import org.jeecg.modules.summary.convert.InterlockSummaryConvert;
 import org.jeecg.modules.summary.dto.InterlockAddDTO;
@@ -27,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.time.Duration;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
@@ -63,6 +68,9 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
     @Autowired
     @SuppressWarnings("all")
     private IInterlockTagService interlockTagService;
+    @Autowired
+    @SuppressWarnings("all")
+    private IIotedgeCollectDataService iotedgeCollectDataService;
 
     /**
      *  根据联锁总表id批量删除联锁及详细信息、点位
@@ -196,7 +204,33 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
                     if(ysmnlValue.compareTo(lowerLimit) == 1 && ysmnlValue.compareTo(upperLimit) == 1) dto.setInstrumentStatus("0");
                     else dto.setInstrumentStatus("1");
                 } else if("2".equals(dto.getInstrumentStatusJuge())){ //2突变超限判断
-                    //TODO
+                    //TODO  通过判断原始模拟量位号突变(与iotedge_collect_data表的数据进行比较???)超过某阈值得出值
+                    // 如果 采集的频率 大于 规定的时间
+                    // 例如 采集是一分钟采集一次 规定的时间的2s之内
+                    // 如果 采集的频率 小于等于 规定的时间
+                    // 例如 2S之内  去采集数据表中根据 设备id+模块名称+点位名称 查询2s之前的数据,但是表中的数据量大 时间?
+//                    BigDecimal yz = new BigDecimal(dto.getThresholdValue()); //阈值
+                    String yz = dto.getThresholdValue();  // 阈值
+                    String time = dto.getThresholdTime();  // 规定的时间
+                    String dw = dto.getThresholdTimeUnit();   // 时间单位
+                    if ("s".equals(dw)){
+                        BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue()); // 本次原始模拟量值
+                        // 查询上一次原始模拟量值
+                        String endDate = DateUtils.getDate("yyyy-MM-dd HH:mm:ss");  // 当前时间 规定时间的结束时间
+                        LocalDateTime endDateTime = LocalDateTime.parse(endDate, formatter);
+                        LocalDateTime beginDateTime = endDateTime.minus(Duration.ofSeconds(2));
+                        String beginDate = beginDateTime.format(formatter);  // 开始时间 规定时间的开始时间
+
+                        IotedgeCollectData iotedgeData = iotedgeCollectDataService.getOneInfo(dto.getYsmnlDeviceId(),dto.getYsmnlModuleName(),dto.getYsmnlTag(),beginDate);
+                        BigDecimal beginValue = BigDecimal.valueOf(Integer.parseInt(iotedgeData.getValue()));
+                        BigDecimal num = BigDecimal.valueOf(Integer.parseInt(dto.getYsmnlValue())).subtract(beginValue);
+
+                        if ((num.divide(beginValue).compareTo(BigDecimal.valueOf(Integer.parseInt(yz)))) > 0){
+                            dto.setInstrumentStatus("1"); //仪表状态(0正常1故障)
+                        }
+                    }
+
+
                 }
                 if(dto.getInstrumentStatus().equals("1")) instrumentStatus = "1";
             }
@@ -287,7 +321,33 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
                     if(ysmnlValue.compareTo(lowerLimit) == 1 && ysmnlValue.compareTo(upperLimit) == 1) dto.setInstrumentStatus("0");
                     else dto.setInstrumentStatus("1");
                 } else if("2".equals(dto.getInstrumentStatusJuge())){ //2突变超限判断
-                    //TODO
+                    //TODO  通过判断原始模拟量位号突变(与iotedge_collect_data表的数据进行比较???)超过某阈值得出值
+                    // 如果 采集的频率 大于 规定的时间
+                    // 例如 采集是一分钟采集一次 规定的时间的2s之内
+                    // 如果 采集的频率 小于等于 规定的时间
+                    // 例如 2S之内  去采集数据表中根据 设备id+模块名称+点位名称 查询2s之前的数据,但是表中的数据量大 时间?
+//                    BigDecimal yz = new BigDecimal(dto.getThresholdValue()); //阈值
+                    String yz = dto.getThresholdValue();  // 阈值
+                    String time = dto.getThresholdTime();  // 规定的时间
+                    String dw = dto.getThresholdTimeUnit();   // 时间单位
+                    if ("s".equals(dw)){
+                        BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue()); // 本次原始模拟量值
+                        // 查询上一次原始模拟量值
+                        String endDate = DateUtils.getDate("yyyy-MM-dd HH:mm:ss");  // 当前时间 规定时间的结束时间
+                        LocalDateTime endDateTime = LocalDateTime.parse(endDate, formatter);
+                        LocalDateTime beginDateTime = endDateTime.minus(Duration.ofSeconds(2));
+                        String beginDate = beginDateTime.format(formatter);  // 开始时间 规定时间的开始时间
+
+                        IotedgeCollectData iotedgeData = iotedgeCollectDataService.getOneInfo(dto.getYsmnlDeviceId(),dto.getYsmnlModuleName(),dto.getYsmnlTag(),beginDate);
+                        BigDecimal beginValue = BigDecimal.valueOf(Integer.parseInt(iotedgeData.getValue()));
+                        BigDecimal num = BigDecimal.valueOf(Integer.parseInt(dto.getYsmnlValue())).subtract(beginValue);
+
+                        if ((num.divide(beginValue).compareTo(BigDecimal.valueOf(Integer.parseInt(yz)))) > 0){
+                            dto.setInstrumentStatus("1"); //仪表状态(0正常1故障)
+                        }
+                    }
+
+
                 }
                 if(dto.getInstrumentStatus().equals("1")) instrumentStatus = "1";
             }