瀏覽代碼

2023-3-22 配合前端,显示操作风扇最后时间的消息,修改定时器在0时间出现的bug,添加一个12月1号需要进行日历更新通知。

chaiyunlong 2 年之前
父節點
當前提交
a5cc5cb83e
共有 13 個文件被更改,包括 126 次插入10 次删除
  1. 11 0
      zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/vo/HardwareCVO.java
  2. 51 4
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabTimedExhaustController.java
  3. 11 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabHardware.java
  4. 3 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabExhaustJoinSubVo.java
  5. 11 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabTimedExhaustJoinsubVo.java
  6. 9 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabTimedExhaustJoinsubMapper.java
  7. 10 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabTimedExhaustJoinsubService.java
  8. 1 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectManagerService.java
  9. 6 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabTimedExhaustJoinsubServiceImpl.java
  10. 3 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabTimedExhaustServiceImpl.java
  11. 3 1
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHardwareMapper.xml
  12. 6 0
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabTimedExhaustJoinsubMapper.xml
  13. 1 1
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabTimedExhaustMapper.xml

+ 11 - 0
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/vo/HardwareCVO.java

@@ -40,6 +40,9 @@ public class HardwareCVO extends BaseHardware {
 
     @ApiModelProperty(value = "是否灭火主机")
     private Integer isPcfire;
+
+    @ApiModelProperty(value = "控制记录的id,参考字典表")
+    private Integer triggerModes;
     /**
      * 设备类型
      *
@@ -98,4 +101,12 @@ public class HardwareCVO extends BaseHardware {
     public void setIsPcfire(Integer isPcfire) {
         this.isPcfire = isPcfire;
     }
+
+    public Integer getTriggerModes() {
+        return triggerModes;
+    }
+
+    public void setTriggerModes(Integer triggerModes) {
+        this.triggerModes = triggerModes;
+    }
 }

+ 51 - 4
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabTimedExhaustController.java

@@ -6,11 +6,16 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.zd.common.core.annotation.Log;
 import com.zd.common.core.log.BusinessType;
+import com.zd.common.core.utils.StringUtils;
 import com.zd.common.core.web.controller.BaseController;
+import com.zd.laboratory.api.entity.LabMessageContent;
 import com.zd.laboratory.domain.LabTimedExhaust;
 import com.zd.laboratory.domain.vo.LabExhaustJoinSubVo;
 import com.zd.laboratory.domain.vo.LabSubjectVO;
+import com.zd.laboratory.domain.vo.LabTimedExhaustJoinsubVo;
 import com.zd.laboratory.domain.vo.LabTimedExhaustVo;
+import com.zd.laboratory.mapper.LabTimedExhaustJoinsubMapper;
+import com.zd.laboratory.service.ILabMessageContentService;
 import com.zd.laboratory.service.ILabTimedExhaustService;
 import com.zd.model.domain.ResultData;
 import com.zd.model.page.TableDataInfo;
@@ -18,10 +23,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 定时排风表Controller
@@ -36,6 +38,12 @@ public class LabTimedExhaustController  extends BaseController {
     @Autowired
     private ILabTimedExhaustService labTimedExhaustService;
 
+    @Autowired
+    private LabTimedExhaustJoinsubMapper labTimedExhaustJoinsubMapper;
+
+    @Autowired
+    private ILabMessageContentService labMessageContentService;
+
     @ApiOperation(value = "定时排风列表")
     @GetMapping("/list")
     public TableDataInfo list(LabTimedExhaust labTimedExhaust) {
@@ -142,6 +150,45 @@ public class LabTimedExhaustController  extends BaseController {
      */
     @RequestMapping(value = "/automaticExhaust")
     public ResultData automaticExhaust(){
+        //这里公用一个定时器,如果日期是12月1日,需要下发实验室管理员和实验室责任人提示消息
+        Calendar calendar = Calendar.getInstance();
+        int monthInt = calendar.get(Calendar.MONTH)+1;
+        int dateInt = calendar.get(Calendar.DATE);
+        if(monthInt==12 && dateInt==1){
+            //这里需要查询定时排风下的所有实验室和关联的责任人
+            new Thread(()->sendMassage()).start();
+        }
         return ResultData.success(labTimedExhaustService.automaticExhaust());
     }
+
+    /**
+     * 异步调用消息通知
+     */
+    public void sendMassage(){
+        List <LabTimedExhaustJoinsubVo> timedExhaustJoinsubList = labTimedExhaustJoinsubMapper.selectJoinsubList();
+        StringBuffer stringBuffer = new StringBuffer();
+        Optional.ofNullable(timedExhaustJoinsubList).orElseGet(Collections::emptyList)
+                .stream()
+                .forEach(a->{
+                    if(StringUtils.isNotNull(a.getAdminId())){
+                        stringBuffer.append(",");
+                        stringBuffer.append(a.getAdminId());
+                    }
+                    if(StringUtils.isNotNull(a.getSafeUserIds())){
+                        stringBuffer.append(",");
+                        stringBuffer.append(a.getSafeUserIds());
+                    }
+                });
+        if(StringUtils.isNotNull(stringBuffer)){
+            LabMessageContent labMessageContent = new LabMessageContent();
+            labMessageContent.setMessClass(1);
+            labMessageContent.setSendRange(3);
+            labMessageContent.setContent("你好,请及时更新定时排风任务排风日期");
+            labMessageContent.setUserIds(stringBuffer.substring(1));
+            labMessageContent.setCreateTime(new Date());
+            labMessageContent.setCreateBy("系统");
+            labMessageContent.setUserId(-2L);
+            labMessageContentService.insertLabMessageContent(labMessageContent);
+        }
+    }
 }

+ 11 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabHardware.java

@@ -212,6 +212,9 @@ public class LabHardware extends BaseEntity {
     @ApiModelProperty(value = "实验室id集合")
     private Long[] subIds;
 
+    @ApiModelProperty(value = "控制记录的id,参考字典表")
+    private Integer triggerModes;
+
     public Integer getManufacturerType() {
         return manufacturerType;
     }
@@ -510,4 +513,12 @@ public class LabHardware extends BaseEntity {
     public Long[] getSubIds() {        return subIds;    }
 
     public void setSubIds(Long[] subIds) {        this.subIds = subIds;    }
+
+    public Integer getTriggerModes() {
+        return triggerModes;
+    }
+
+    public void setTriggerModes(Integer triggerModes) {
+        this.triggerModes = triggerModes;
+    }
 }

+ 3 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabExhaustJoinSubVo.java

@@ -32,4 +32,7 @@ public class LabExhaustJoinSubVo {
 
     @ApiModelProperty(name = "学院")
     private Long deptId;
+
+    @ApiModelProperty(name = "定时排风主键id")
+    private Long timedExhaustId;
 }

+ 11 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabTimedExhaustJoinsubVo.java

@@ -27,4 +27,15 @@ public class LabTimedExhaustJoinsubVo {
     @ApiModelProperty("勾选后删除的实验室")
     private List<Long> delSubIds = new ArrayList <>();
 
+    /**
+     * 实验室管理员
+     */
+    @ApiModelProperty("实验室管理员")
+    private Long adminId;
+
+    /**
+     * 实验室安全责任人
+     */
+    @ApiModelProperty("实验室安全责任人")
+    private String safeUserIds;
 }

+ 9 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabTimedExhaustJoinsubMapper.java

@@ -1,6 +1,7 @@
 package com.zd.laboratory.mapper;
 
 import com.zd.laboratory.domain.LabTimedExhaustJoinsub;
+import com.zd.laboratory.domain.vo.LabTimedExhaustJoinsubVo;
 
 import java.util.List;
 
@@ -44,4 +45,12 @@ public interface LabTimedExhaustJoinsubMapper {
      */
     public int deleteLabTimedExhaustJoinsubByExhaustId(Long timedExhaustId);
 
+
+    /**
+     * 查询定时排风关联实验室
+     *
+     * @return 定时排风关联实验室
+     */
+    public List <LabTimedExhaustJoinsubVo> selectJoinsubList();
+
 }

+ 10 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabTimedExhaustJoinsubService.java

@@ -1,8 +1,9 @@
 package com.zd.laboratory.service;
 
-import com.zd.laboratory.domain.LabTimedExhaustJoinsub;
 import com.zd.laboratory.domain.vo.LabTimedExhaustJoinsubVo;
 
+import java.util.List;
+
 /**
  * 定时排风关联实验室Service
  *
@@ -18,4 +19,12 @@ public interface ILabTimedExhaustJoinsubService {
      * @return 结果
      */
     public int insertLabTimedExhaustJoinsub(LabTimedExhaustJoinsubVo labTimedExhaustJoinsubVo);
+
+
+    /**
+     * 查询定时排风列表
+     *
+     * @return 定时排风集合
+     */
+    public List <LabTimedExhaustJoinsubVo> selectJoinsubList();
 }

+ 1 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectManagerService.java

@@ -1491,6 +1491,7 @@ public class LabSubjectManagerService {
         hardware.setState(a.getOperate() == null ? HardwareOperate.OFFLINE : a.getOperate());
         hardware.setHardwareNUM(a.getHardwareNum());
         hardware.setIsPcfire(a.getIsPcfire());
+        hardware.setTriggerModes(a.getTriggerModes());
         //默认不在线
         hardware.setSwitchEnums(ControlEntity.SwitchEnums.NO_ONLINE);
         //通风设备

+ 6 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabTimedExhaustJoinsubServiceImpl.java

@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 定时排风关联实验室Service
@@ -54,4 +55,9 @@ public class LabTimedExhaustJoinsubServiceImpl implements ILabTimedExhaustJoinsu
         }
         return 1;
     }
+
+    @Override
+    public List <LabTimedExhaustJoinsubVo> selectJoinsubList() {
+        return labTimedExhaustJoinsubMapper.selectJoinsubList();
+    }
 }

+ 3 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabTimedExhaustServiceImpl.java

@@ -261,14 +261,14 @@ public class LabTimedExhaustServiceImpl implements ILabTimedExhaustService {
                     long lDate1 = calendar.getTime().getTime();
                     Calendar newCalendar = Calendar.getInstance();
                     Long newBeginTime = calendarTime(lDate1,beginTimeStr,newCalendar);
-                    if(newBeginTime>=0){
+                    if(newBeginTime>0){
                         executionTimer(newBeginTime,subId,1);
                     }
                     //这里执行redis存储,如果是结束时间,那么就存实验室和开关“关”。
                     String[] endTimeStr = a.getEndTime().split(":");
                     Long newEndTime = calendarTime(lDate1,endTimeStr,newCalendar);
-                    if(newEndTime>=0){
-                        executionTimer(Long.parseLong(newEndTime+""),subId,0);
+                    if(newEndTime>0){
+                        executionTimer(newEndTime,subId,0);
                     }
                 });
     }

+ 3 - 1
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHardwareMapper.xml

@@ -39,6 +39,7 @@
         <result property="deviceStatus" column="device_status"/>
         <result property="manufacturerType" column="manufacturer_type"/>
         <result property="isPcfire" column="is_pcfire"/>
+        <result property="triggerModes" column="trigger_modes"/>
     </resultMap>
 
     <resultMap type="com.zd.laboratory.domain.vo.LabHardwareVO" id="LabHardwareVOResult">
@@ -109,7 +110,8 @@
                      he.lock_id                                                    lockId,
                      he.device_status                                              deviceStatus,
                      he.manufacturer_type                                          manufacturerType,
-                     he.har_user, he.har_psw, he.control_scope
+                     he.har_user, he.har_psw, he.control_scope,
+                     (select c.trigger_modes from lab_control c where c.hardware_id = he.`id` order by c.create_time desc limit 1) trigger_modes
               from lab_hardware he
                        LEFT JOIN hxp_smart_terminal_config stc ON he.id = stc.terminal_id) xx
                  left join lab_subject_hardware_position hp on hp.hard_id = xx.id

+ 6 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabTimedExhaustJoinsubMapper.xml

@@ -26,6 +26,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLabTimedExhaustJoinsubList" resultType="com.zd.laboratory.domain.LabTimedExhaust" resultMap="LabTimedExhaustJoinsubResult">
         <include refid="selectLabTimedExhaustJoinsubVo"/>
     </select>
+    <select id="selectJoinsubList" resultType="com.zd.laboratory.domain.vo.LabTimedExhaustJoinsubVo">
+
+        SELECT  st.`admin_id` adminId,st.`safe_user_id` safeUserIds
+        FROM lab_timed_exhaust_joinsub tej left join lab_subject st on tej.`sub_id` = st.`id`
+
+    </select>
 
     <insert id="insertLabTimedExhaustJoinsub" parameterType="com.zd.laboratory.domain.LabTimedExhaustJoinsub" useGeneratedKeys="true" keyProperty="id">
         insert into lab_timed_exhaust_joinsub

+ 1 - 1
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabTimedExhaustMapper.xml

@@ -108,7 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         LEFT JOIN lab_safe_classtype st ON ls.type_id = st.`id`
         <where>
             (ls.id IN(
-            SELECT tej.`sub_id` FROM lab_timed_exhaust_joinsub tej
+            SELECT tej.`sub_id` FROM lab_timed_exhaust_joinsub tej where tej.`timed_exhaust_id`= #{timedExhaustId}
             )
             <if test="subIds != null and subIds.length > 0">
                 and