Przeglądaj źródła

一键灭火修改

xuxiaofei 3 lat temu
rodzic
commit
0963103ae6

+ 1 - 1
zd-model/src/main/java/com/zd/model/domain/per/PerPrefix.java

@@ -763,5 +763,5 @@ public class PerPrefix {
     /**
      * 实验室项目:灭火设备
      */
-    public static final String LABORATORY_FIREDEVICE = "laboratory:firedevice:";
+    public static final String ALGORITHM_FIREDEVICE = "algorithm:firedevice:";
 }

+ 2 - 1
zd-model/src/main/java/com/zd/model/enums/HardwareTypeEnum.java

@@ -20,7 +20,8 @@ public enum HardwareTypeEnum implements BaseEnum<Integer>, HardwareType {
     AI_DOORLOCK(6, "智能门锁", ""),
     RFID_RECOGNIZER(7, "RFID识别器", ""),
     AI_ALARM(8, "智能报警器", ""),
-    AI_CABINETLOCK(9, "智能柜锁", "");
+    AI_CABINETLOCK(9, "智能柜锁", ""),
+    AI_OUTFIRE(10, "一键灭火", "");
 
 
 

+ 44 - 15
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/labFireDeviceController.java

@@ -1,10 +1,12 @@
 package com.zd.laboratory.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.zd.common.core.annotation.Log;
 import com.zd.common.core.annotation.PreAuthorize;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.log.BusinessType;
+import com.zd.common.core.redis.RedisService;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.laboratory.domain.LabFireDevice;
 import com.zd.laboratory.domain.LabMold;
@@ -12,6 +14,7 @@ import com.zd.laboratory.domain.vo.LabFireDeviceVO;
 import com.zd.laboratory.service.ILabExitLineService;
 import com.zd.laboratory.service.ILabFireDeviceService;
 import com.zd.laboratory.utils.FireLaborUtil;
+import com.zd.model.constant.MqttConstants;
 import com.zd.model.domain.AjaxResult;
 import com.zd.model.domain.ResultData;
 import com.zd.model.domain.per.PerFun;
@@ -22,7 +25,9 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 灭火装置
@@ -38,27 +43,51 @@ public class labFireDeviceController extends BaseController {
     @Autowired
     private ILabFireDeviceService labFireDeviceService;
 
+    @Autowired
+    private RedisService redisService;
+
     /**
      * 获取主机状态
      *
      * @return
      */
-    @GetMapping(value = "/status")
-    public AjaxResult getStatus() {
-        //根据主机地址-位获取主机状态指令
-        String activeCode = FireLaborUtil.getFireActiveOrder(2);
-        //根据状态指令获取主机状态
-        JSONObject jsonObject = FireLaborUtil.getFireStatus("0");
-        System.out.println(jsonObject.toJSONString());
+    @GetMapping(value = "/getStatus")
+    public ResultData getStatus(String deviceCode,Integer subjectId) {
+        Map<String,Object> map = new HashMap<>();
+        //烟雾
+        boolean smoke=false;
+        //温度
+        boolean temperature=false;
+        //火焰
+        boolean fire=false;
+
+        //根据编码从redis获取该设备状态
+        JSON strStatus=  redisService.getCacheObject(MqttConstants.TOPIC_FIRE_DEVICE_RECEIVE+deviceCode);
+        if(strStatus==null){
+            strStatus=new JSONObject();
+        }
+        map.put("smoke",smoke);
+        map.put("temperature",temperature);
+        map.put("fire",fire);
+        return ResultData.success(map);
+    }
+
+    /***
+     * 发送灭火请求
+     * @return
+     */
+    @GetMapping(value = "/sendRequest")
+    public AjaxResult sendRequest() {
+        //待对接
         return AjaxResult.success();
     }
 
     /**
      * 查询实验室灭火设备列表
      */
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_FIREDEVICE + PerFun.LIST)
+    @PreAuthorize(hasPermi = PerPrefix.ALGORITHM_FIREDEVICE + PerFun.LIST)
     @GetMapping("/list")
-    @ApiOperation(value = "查询实验室灭火设备列表", notes = "权限字符:" + PerPrefix.LABORATORY_FIREDEVICE + PerFun.LIST)
+    @ApiOperation(value = "查询实验室灭火设备列表", notes = "权限字符:" + PerPrefix.ALGORITHM_FIREDEVICE + PerFun.LIST)
     public TableDataInfo<LabFireDeviceVO> list(LabFireDeviceVO labFireDeviceVO) {
         startPage();
         List<LabFireDeviceVO> list = labFireDeviceService.selectLabFireDeviceList(labFireDeviceVO);
@@ -69,8 +98,8 @@ public class labFireDeviceController extends BaseController {
     /**
      * 获取实验室灭火设备详细信息
      */
-    @ApiOperation(value = "获取实验室灭火设备详细信息", notes = "权限字符:" + PerPrefix.LABORATORY_FIREDEVICE + PerFun.QUERY)
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_FIREDEVICE + PerFun.QUERY)
+    @ApiOperation(value = "获取实验室灭火设备详细信息", notes = "权限字符:" + PerPrefix.ALGORITHM_FIREDEVICE + PerFun.QUERY)
+    @PreAuthorize(hasPermi = PerPrefix.ALGORITHM_FIREDEVICE + PerFun.QUERY)
     @GetMapping(value = "/{id}")
     public ResultData<LabFireDeviceVO> getInfo(@PathVariable("id") Long id) {
         return ResultData.success(labFireDeviceService.selectLabFireDeviceById(id));
@@ -79,8 +108,8 @@ public class labFireDeviceController extends BaseController {
     /**
      * 新增实验室灭火设备
      */
-    @ApiOperation(value = "新增实验室灭火设备", notes = "权限字符:" + PerPrefix.LABORATORY_FIREDEVICE + PerFun.ADD)
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_FIREDEVICE + PerFun.ADD)
+    @ApiOperation(value = "新增实验室灭火设备", notes = "权限字符:" + PerPrefix.ALGORITHM_FIREDEVICE + PerFun.ADD)
+    @PreAuthorize(hasPermi = PerPrefix.ALGORITHM_FIREDEVICE + PerFun.ADD)
     @Log(title = "灭火设备", businessType = BusinessType.INSERT)
     @PostMapping
     public ResultData add(@RequestBody LabFireDevice labFireDevice) {
@@ -90,8 +119,8 @@ public class labFireDeviceController extends BaseController {
     /**
      * 修改实验室灭火设备
      */
-    @ApiOperation(value = "修改实验室灭火设备", notes = "权限字符:" + PerPrefix.LABORATORY_FIREDEVICE + PerFun.EDIT)
-    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_FIREDEVICE + PerFun.EDIT)
+    @ApiOperation(value = "修改实验室灭火设备", notes = "权限字符:" + PerPrefix.ALGORITHM_FIREDEVICE + PerFun.EDIT)
+    @PreAuthorize(hasPermi = PerPrefix.ALGORITHM_FIREDEVICE + PerFun.EDIT)
     @Log(title = "灭火设备", businessType = BusinessType.UPDATE)
     @PutMapping
     public ResultData edit(@RequestBody LabFireDevice labFireDevice) {

+ 3 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabFireDevice.java

@@ -48,7 +48,7 @@ public class LabFireDevice extends BaseEntity {
      */
     @ApiModelProperty("设备地址")
     @Excel(name = "设备地址")
-    private String deviceUrl;
+    private Integer deviceUrl;
 
     /**
      * 倒计时时间
@@ -110,11 +110,11 @@ public class LabFireDevice extends BaseEntity {
         this.deviceCode = deviceCode;
     }
 
-    public String getDeviceUrl() {
+    public Integer getDeviceUrl() {
         return deviceUrl;
     }
 
-    public void setDeviceUrl(String deviceUrl) {
+    public void setDeviceUrl(Integer deviceUrl) {
         this.deviceUrl = deviceUrl;
     }
 

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

@@ -60,6 +60,7 @@ public class LabFireDeviceServiceImpl implements ILabFireDeviceService {
     public int insertLabFireDevice(LabFireDevice labFireDevice) {
         LabFireDeviceVO vo = new LabFireDeviceVO();
         vo.setDeviceCode(labFireDevice.getDeviceCode());
+        vo.setSubjectId(labFireDevice.getSubjectId());
         //BeanUtils.copyProperties(labFireDevice, vo);
         List<LabFireDeviceVO> list = labFireDeviceMapper.selectLabFireDeviceList(vo);
         if (list.size() > 0) {

+ 6 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/utils/FireDeviceStatusTask.java

@@ -10,6 +10,7 @@ import com.zd.model.constant.MqttConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -34,16 +35,18 @@ public class FireDeviceStatusTask {
      *
      * 定时更新灭火装置状态
      */
+    //@Scheduled(cron = "0/20 * * * * ?")
     public void getFireDeviceStatus(){
         LabFireDeviceVO fdvo = new LabFireDeviceVO();
         List<LabFireDeviceVO> list = labFireDeviceService.selectLabFireDeviceList(fdvo);
         for (LabFireDeviceVO vo: list) {
             //根据主机地址-位获取主机状态指令
-            String activeCode = FireLaborUtil.getFireActiveOrder(2);
+            String activeCode = FireLaborUtil.getFireActiveOrder(vo.getDeviceUrl());
             //根据状态指令获取主机状态
-            JSONObject jsonObject = FireLaborUtil.getFireStatus("0");
+            //JSONObject jsonObject = FireLaborUtil.getFireStatus("0");
             //向mqtt发送状态信息
-            commonSend.send(MqttConstants.TOPIC_FIRE_DEVICE+vo.getSubjectId(),jsonObject.toJSONString());
+            commonSend.send(MqttConstants.TOPIC_FIRE_DEVICE+vo.getDeviceCode(),activeCode);
+            logger.info("==============mqtt消息推送, 灭火装置状态请求,实验室id:"+vo.getSubjectId()+",设备编号:"+vo.getDeviceCode());
         }
     }
 }

+ 2 - 2
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabFireDeviceLogMapper.xml

@@ -30,7 +30,7 @@
         from lab_fire_device_log
     </sql>
 
-    <select id="selectLabFireDeviceLogList" parameterType="com.zd.laboratory.domain.vo.LabFireDeviceVO"
+    <select id="selectLabFireDeviceLogList" parameterType="com.zd.laboratory.domain.LabFireDeviceLog"
             resultMap="LabFireDeviceLogResult">
         <include refid="selectFireDeviceLog"/>
         <where>
@@ -77,7 +77,7 @@
         </trim>
     </insert>
 
-    <update id="updateLabFireDeviceLog" parameterType="com.zd.laboratory.domain.LabMold">
+    <update id="updateLabFireDeviceLog" parameterType="com.zd.laboratory.domain.LabFireDeviceLog">
         update lab_fire_device_log
         <trim prefix="SET" suffixOverrides=",">
             <if test="deptName != null">dept_name = #{deptName},</if>