Просмотр исходного кода

Merge branch 'master' of http://192.168.1.43:3000/git/sass-lab-distributed-java

zhuchangxue лет назад: 3
Родитель
Сommit
3bc54b101d
18 измененных файлов с 679 добавлено и 169 удалено
  1. 10 0
      zd-api/zd-api-system/src/main/java/com/zd/system/api/chemical/RemoteChemicalService.java
  2. 17 2
      zd-api/zd-api-system/src/main/java/com/zd/system/api/factory/RemoteChemicalFallbackFactory.java
  3. 2 0
      zd-modules/zd-camera/src/main/java/com/zd/iot/vmp/onvif/IONVIFServer.java
  4. 13 0
      zd-modules/zd-camera/src/main/java/com/zd/iot/vmp/onvif/impl/ONVIFServerIMpl.java
  5. 6 4
      zd-modules/zd-camera/src/main/java/com/zd/iot/vmp/vmanager/onvif/ONVIFController.java
  6. 23 4
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/controller/HxpChemicalController.java
  7. 12 0
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/domain/HxpChemical.java
  8. 3 0
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/mapper/HxpChemicalMapper.java
  9. 5 0
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/IHxpChemicalService.java
  10. 46 2
      zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/impl/HxpChemicalServiceImpl.java
  11. 208 101
      zd-modules/zd-chemical/src/main/resources/mapper/chemical/HxpChemicalMapper.xml
  12. 5 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/device/DeviceRemoteController.java
  13. 35 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabSubjectVO.java
  14. 24 4
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectManagerService.java
  15. 6 1
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSubjectMapper.xml
  16. 2 1
      zd-modules/zd-netty/src/main/java/com/zd/netty/enums/ManufacturerTypeEnum.java
  17. 220 0
      zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDListenerService.java
  18. 42 46
      zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDService.java

+ 10 - 0
zd-api/zd-api-system/src/main/java/com/zd/system/api/chemical/RemoteChemicalService.java

@@ -5,9 +5,15 @@ import com.zd.common.core.domain.R;
 import com.zd.system.api.factory.RemoteExamFallbackFactory;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
 /**
  * 化学品管理Feign调用接口
  */
@@ -20,4 +26,8 @@ public interface RemoteChemicalService {
     @ApiOperation(value = "修改 化学品设备管理状态")
     @PutMapping("/hxpSmartTerminal/update/status")
     R<Boolean> updateStatus(@RequestParam("ipAddress") String ipAddress,@RequestParam("terminalStatus")Integer terminalStatus);
+
+    @ApiOperation(value = "查询实验室化学品临界量风险指标")
+    @PostMapping("/hxpChemical/queryCriticaliBySubId")
+    R<Map<Long, BigDecimal>> queryCriticaliBySubId(@RequestBody List<Long> subIds);
 }

+ 17 - 2
zd-api/zd-api-system/src/main/java/com/zd/system/api/factory/RemoteChemicalFallbackFactory.java

@@ -1,4 +1,4 @@
-package com.zd.system.api.factory;
+package com.zd.system.api.chemical.factory;
 
 import com.zd.common.core.domain.R;
 import com.zd.system.api.chemical.RemoteChemicalService;
@@ -7,6 +7,10 @@ import org.slf4j.LoggerFactory;
 import org.springframework.cloud.openfeign.FallbackFactory;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
 /**
  * 考试服务降级处理
  *
@@ -19,6 +23,17 @@ public class RemoteChemicalFallbackFactory implements FallbackFactory<RemoteChem
     @Override
     public RemoteChemicalService create(Throwable throwable) {
         log.error("化学品管理调用失败:{}", throwable.getMessage());
-        return (ipAddress, terminalStatus) -> R.fail("化学品管理调用失败:" + throwable.getMessage());
+        return new RemoteChemicalService() {
+            @Override
+            public R<Boolean> updateStatus(String ipAddress, Integer terminalStatus) {
+                return R.fail("化学品管理调用失败:" + throwable.getMessage());
+            }
+
+            @Override
+            public R<Map<Long, BigDecimal>> queryCriticaliBySubId(List<Long> subIds) {
+
+                return R.fail("查询实验室化学品临界量风险指标失败:" + throwable.getMessage());
+            }
+        };
     }
 }

+ 2 - 0
zd-modules/zd-camera/src/main/java/com/zd/iot/vmp/onvif/IONVIFServer.java

@@ -20,4 +20,6 @@ public interface IONVIFServer {
     Boolean isRecording(MediaServerItem mediaServerItem, Map<String, Object> param) ;
 
     String stopRecord(MediaServerItem mediaServerItem, Map<String, Object> param) ;
+
+    Boolean closeStream(MediaServerItem mediaServerItem, Map<String, Object> param) ;
 }

+ 13 - 0
zd-modules/zd-camera/src/main/java/com/zd/iot/vmp/onvif/impl/ONVIFServerIMpl.java

@@ -206,6 +206,19 @@ public class ONVIFServerIMpl implements IONVIFServer {
         return null;
     }
 
+    @Override
+    public Boolean closeStream(MediaServerItem mediaServerItem, Map<String, Object> param) {
+        param.put("schema","rtsp");
+        param.put("api","close_streams");
+        param.put("force",1);
+        JSONObject jsonObject=getCommonRecord(mediaServerItem,param);
+        Integer code=jsonObject.getInteger("code");
+        if(code==0){
+            return true;
+        }
+        return false;
+    }
+
 
     private JSONObject getCommonRecord(MediaServerItem mediaServerItem,Map<String, Object> param) {
         OkHttpClient client = new OkHttpClient();

+ 6 - 4
zd-modules/zd-camera/src/main/java/com/zd/iot/vmp/vmanager/onvif/ONVIFController.java

@@ -87,8 +87,8 @@ public class ONVIFController {
     @GetMapping(value = "/rtsp")
     public DeferredResult<ResponseEntity<WVPResult>> getRTSPUrl(@RequestParam(value = "timeout", required = false, defaultValue = "3000") Integer timeout,
                                                                 @RequestParam(required = true) String hostname,
-                                                                @RequestParam(required = false) String username,
-                                                                @RequestParam(required = false) String password){
+                                                                @RequestParam(required = false,defaultValue = "admin") String username,
+                                                                @RequestParam(required = false,defaultValue = "hk123456") String password){
         DeferredResult<ResponseEntity<WVPResult>> result = new DeferredResult<>(timeout + 10000L);
         UUID uuid = UUID.randomUUID();
         result.onTimeout(() -> {
@@ -130,7 +130,7 @@ public class ONVIFController {
     public DeferredResult <ResponseEntity<WVPResult>> startRecord(@RequestParam(value = "timeout", required = false, defaultValue = "3000") Integer timeout,
                                   @RequestParam(required = true) String hostname,
                                   @RequestParam(required = false,defaultValue = "admin") String username,
-                                  @RequestParam(required = false,defaultValue = "admin123456") String password)  {
+                                  @RequestParam(required = false,defaultValue = "hk123456") String password)  {
         DeferredResult<ResponseEntity<WVPResult>> result = new DeferredResult<>(timeout + 10000L);
         UUID uuid = UUID.randomUUID();
         result.onTimeout(() -> {
@@ -216,8 +216,10 @@ public class ONVIFController {
             return result;
         }
         String urlPath=onvifServer.stopRecord(mediaServerItem,map);
+        urlPath=urlPath.replace("/.","/");
+        boolean isCloseTrue=onvifServer.closeStream(mediaServerItem,map);
         WVPResult<String> resultData = new WVPResult();
-        if(StringUtils.isNotBlank(urlPath)){
+        if(StringUtils.isNotBlank(urlPath) && isCloseTrue){
             resultData.setCode(HttpStatus.SUCCESS);
             resultData.setData(urlPath);
             resultData.setMsg("success");

+ 23 - 4
zd-modules/zd-chemical/src/main/java/com/zd/chemical/controller/HxpChemicalController.java

@@ -1,16 +1,16 @@
 package com.zd.chemical.controller;
 
+import java.math.BigDecimal;
 import java.time.LocalDate;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
 import java.io.IOException;
-import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import javax.servlet.http.HttpServletResponse;
 
+import cn.hutool.core.map.MapUtil;
 import com.zd.chemical.domain.vo.*;
 import com.zd.chemical.service.IHxpChemicalJoinCabinetService;
+import com.zd.common.core.domain.R;
 import com.zd.common.core.domain.per.PerFun;
 import com.zd.common.core.domain.per.PerPrefix;
 import com.zd.common.core.exception.ServiceException;
@@ -247,4 +247,23 @@ public class HxpChemicalController extends BaseController {
         List<HxpChemicalVo> list = hxpChemicalService.selectHxpChemicalList(hxpChemicalSearch);
         return getDataTable(list);
     }
+
+    @ApiOperation(value = "查询实验室化学品临界量风险指标")
+    @PostMapping("/queryCriticaliBySubId")
+    public R<Map<Long, BigDecimal>> queryCriticaliBySubId(@RequestBody List<Long> subIds) {
+        if(subIds.isEmpty()){
+            return R.ok(MapUtil.empty());
+        }
+        return R.ok(hxpChemicalService.queryCriticaliBySubId(subIds));
+    }
+
+
+    @ApiOperation(value = "定时监测实验室化学品存放风险指标")
+    @Log(title = "定时监测实验室化学品存放风险指标", businessType = BusinessType.OTHER)
+    @PostMapping("/indicatorMonitoring")
+    public void indicatorMonitoring() {
+        hxpChemicalService.indicatorMonitoring();
+    }
+
+
 }

+ 12 - 0
zd-modules/zd-chemical/src/main/java/com/zd/chemical/domain/HxpChemical.java

@@ -8,6 +8,8 @@ import io.swagger.annotations.ApiModelProperty;
 import com.zd.common.core.web.domain.BaseEntity;
 import org.hibernate.validator.constraints.Length;
 
+import java.math.BigDecimal;
+
 /**
  * 化学品信息对象 hxp_chemical
  *
@@ -140,6 +142,8 @@ public class HxpChemical extends BaseEntity {
     @ApiModelProperty(value = "关联危险源的id")
     private String anotherNameChar;
 
+    @ApiModelProperty(value = "临界量")
+    private BigDecimal criticality;
 
     public void setId(Long id) {
         this.id = id;
@@ -308,4 +312,12 @@ public class HxpChemical extends BaseEntity {
     public void setAnotherNameChar(String anotherNameChar) {
         this.anotherNameChar = anotherNameChar;
     }
+
+    public BigDecimal getCriticality() {
+        return criticality;
+    }
+
+    public void setCriticality(BigDecimal criticality) {
+        this.criticality = criticality;
+    }
 }

+ 3 - 0
zd-modules/zd-chemical/src/main/java/com/zd/chemical/mapper/HxpChemicalMapper.java

@@ -1,5 +1,6 @@
 package com.zd.chemical.mapper;
 
+import java.math.BigDecimal;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -130,4 +131,6 @@ public interface HxpChemicalMapper
      * @return 化学品信息集合
      */
     public List<LinkedHashMap <String,String>> joinOutCount(HxpStock hxpStock);
+
+    Map<Long, BigDecimal> queryCriticaliBySubId(List<Long> subIds);
 }

+ 5 - 0
zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/IHxpChemicalService.java

@@ -1,5 +1,6 @@
 package com.zd.chemical.service;
 
+import java.math.BigDecimal;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -130,4 +131,8 @@ public interface IHxpChemicalService
      * @return 化学品信息集合
      */
     public List<LinkedHashMap <String,String>> joinOutCount(HxpStock hxpStock);
+
+    Map<Long, BigDecimal> queryCriticaliBySubId(List<Long> subIds);
+
+    void indicatorMonitoring();
 }

+ 46 - 2
zd-modules/zd-chemical/src/main/java/com/zd/chemical/service/impl/HxpChemicalServiceImpl.java

@@ -1,11 +1,14 @@
 package com.zd.chemical.service.impl;
 
+import com.zd.chemical.domain.HxpAlarmRecord;
 import com.zd.chemical.domain.HxpChemical;
 import com.zd.chemical.domain.HxpChemicalClassify;
 import com.zd.chemical.domain.HxpStock;
 import com.zd.chemical.domain.vo.*;
+import com.zd.chemical.mapper.HxpAlarmRecordMapper;
 import com.zd.chemical.mapper.HxpChemicalClassifyMapper;
 import com.zd.chemical.mapper.HxpChemicalMapper;
+import com.zd.chemical.mapper.HxpUserecordMapper;
 import com.zd.chemical.service.IHxpChemicalService;
 import com.zd.common.core.domain.per.PerPrefix;
 import com.zd.common.core.exception.ServiceException;
@@ -28,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.ServletException;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.atomic.DoubleAdder;
 import java.util.concurrent.atomic.LongAdder;
@@ -43,12 +47,14 @@ import java.util.stream.Collectors;
 public class HxpChemicalServiceImpl implements IHxpChemicalService {
     @Autowired
     private HxpChemicalMapper hxpChemicalMapper;
-
     @Autowired
     private HxpChemicalClassifyMapper hxpChemicalClassifyMapper;
-
     @Autowired
     private IHxpChemicalService hxpChemicalService;
+    @Autowired
+    private HxpUserecordMapper hxpUserecordMapper;
+    @Autowired
+    private HxpAlarmRecordMapper hxpAlarmRecordMapper;
 
     /**
      * 查询化学品信息
@@ -485,4 +491,42 @@ public class HxpChemicalServiceImpl implements IHxpChemicalService {
         List<LinkedHashMap <String,String>> stockCountList = hxpChemicalMapper.joinOutCount(hxpStock);
         return stockCountList;
     }
+
+    @Override
+    public Map<Long, BigDecimal> queryCriticaliBySubId(List<Long> subIds) {
+        return hxpChemicalMapper.queryCriticaliBySubId(subIds);
+    }
+
+    @Override
+    public void indicatorMonitoring() {
+        Map<Long, BigDecimal> map = hxpChemicalMapper.queryCriticaliBySubId(new ArrayList<>());
+        if(!map.isEmpty()){
+
+            map.entrySet().forEach(a -> {
+                if(BigDecimal.valueOf(1L).compareTo(a.getValue()) >= 0){
+
+                    Map<String,Object> subInfo = hxpUserecordMapper.selectSubInfoById(a.getKey());
+                    String safeUserId = "";
+                    if(subInfo != null){
+                        safeUserId = subInfo.get("safeUserId")==null?"":String.valueOf(subInfo.get("safeUserId"));
+                    }
+
+                    HxpAlarmRecord hxpAlarmRecord = new HxpAlarmRecord();
+                    hxpAlarmRecord.setAlarmContent("房间内危化品已定为重大危险源,请确认安全存放量!");
+                    hxpAlarmRecord.setAlarmType(2);
+                    hxpAlarmRecord.setHasValid(1);
+                    hxpAlarmRecord.setAlarmMode(3);
+                    hxpAlarmRecord.setAlarmTime(DateUtils.getNowDate());
+                    hxpAlarmRecord.setSubId(a.getKey());
+                    hxpAlarmRecord.setHandlingStatus(1);
+                    hxpAlarmRecord.setLiableUserIds(safeUserId);
+
+                    hxpAlarmRecordMapper.insertHxpAlarmRecord(hxpAlarmRecord);
+
+                    // TODO 此处需要发送短信通知
+                }
+            });
+
+        }
+    }
 }

+ 208 - 101
zd-modules/zd-chemical/src/main/resources/mapper/chemical/HxpChemicalMapper.xml

@@ -1,65 +1,120 @@
 <?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">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zd.chemical.mapper.HxpChemicalMapper">
 
     <resultMap type="com.zd.chemical.domain.HxpChemical" id="HxpChemicalResult">
-        <result property="id"    column="id"    />
-        <result property="chemicalNum"    column="chemical_num"    />
-        <result property="chemicalName"    column="chemical_name"    />
-        <result property="chemicalClassify"    column="chemical_classify"    />
-        <result property="classifyAttribute"    column="classify_attribute"    />
-        <result property="chemicalShape"    column="chemical_shape"    />
-        <result property="labelType"    column="label_type"    />
-        <result property="measuringMethod"    column="measuring_method"    />
-        <result property="chemicalUnit"    column="chemical_unit"    />
-        <result property="verification"    column="verification"    />
-        <result property="anotherName"    column="another_name"    />
-        <result property="casNum"    column="cas_num"    />
-        <result property="factory"    column="factory"    />
-        <result property="purity"    column="purity"    />
-        <result property="collectHour"    column="collect_hour"    />
-        <result property="collectMinute"    column="collect_minute"    />
-        <result property="joinHazardId"    column="join_hazard_id"    />
-        <result property="userId"    column="user_id"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="remark"    column="remark"    />
+        <result property="id" column="id"/>
+        <result property="chemicalNum" column="chemical_num"/>
+        <result property="chemicalName" column="chemical_name"/>
+        <result property="chemicalClassify" column="chemical_classify"/>
+        <result property="classifyAttribute" column="classify_attribute"/>
+        <result property="chemicalShape" column="chemical_shape"/>
+        <result property="labelType" column="label_type"/>
+        <result property="measuringMethod" column="measuring_method"/>
+        <result property="chemicalUnit" column="chemical_unit"/>
+        <result property="verification" column="verification"/>
+        <result property="anotherName" column="another_name"/>
+        <result property="casNum" column="cas_num"/>
+        <result property="factory" column="factory"/>
+        <result property="purity" column="purity"/>
+        <result property="collectHour" column="collect_hour"/>
+        <result property="collectMinute" column="collect_minute"/>
+        <result property="joinHazardId" column="join_hazard_id"/>
+        <result property="userId" column="user_id"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+
+        <result property="criticality" column="criticality"/>
     </resultMap>
 
     <sql id="selectHxpChemicalVo">
-        select id, chemical_num, chemical_name, chemical_classify, classify_attribute, chemical_shape, label_type, measuring_method, chemical_unit, verification, another_name, cas_num, factory, purity, collect_hour, collect_minute, user_id, create_by, create_time, update_by, update_time, remark from hxp_chemical
+        select id,
+               chemical_num,
+               chemical_name,
+               chemical_classify,
+               classify_attribute,
+               chemical_shape,
+               label_type,
+               measuring_method,
+               chemical_unit,
+               verification,
+               another_name,
+               cas_num,
+               factory,
+               purity,
+               collect_hour,
+               collect_minute,
+               user_id,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark,
+               criticality
+        from hxp_chemical
     </sql>
     <sql id="selectHxpChemicalListVo">
-        select t.id, t.chemical_num, t.chemical_name, t.chemical_classify, classify_attribute, t.chemical_shape, t.label_type, t.measuring_method, t.chemical_unit, t.verification, t.another_name, t.cas_num, t.factory, t.purity, t.collect_hour, t.collect_minute, t.user_id, t.create_by, t.create_time, t.update_by, t.update_time, t.remark from hxp_chemical as t
+        select t.id,
+               t.chemical_num,
+               t.chemical_name,
+               t.chemical_classify,
+               classify_attribute,
+               t.chemical_shape,
+               t.label_type,
+               t.measuring_method,
+               t.chemical_unit,
+               t.verification,
+               t.another_name,
+               t.cas_num,
+               t.factory,
+               t.purity,
+               t.collect_hour,
+               t.collect_minute,
+               t.user_id,
+               t.create_by,
+               t.create_time,
+               t.update_by,
+               t.update_time,
+               t.remark,
+               t.criticality
+        from hxp_chemical as t
     </sql>
-    <select id="selectHxpChemicalList" parameterType="com.zd.chemical.domain.vo.HxpChemicalSearch" resultType="com.zd.chemical.domain.vo.HxpChemicalVo">
+    <select id="selectHxpChemicalList" parameterType="com.zd.chemical.domain.vo.HxpChemicalSearch"
+            resultType="com.zd.chemical.domain.vo.HxpChemicalVo">
         select hc.id, hc.chemical_num, hc.chemical_name, hc.chemical_classify,
         (select ccf.classify_name from hxp_chemical_classify ccf where ccf.id = hc.chemical_classify) classifyName,
-        (SELECT GROUP_CONCAT(dda.dict_label) FROM sys_dict_data dda WHERE dda.dict_type = 'hxp_classifyattribute' AND FIND_IN_SET(dda.dict_value, hc.classify_attribute)) classifyAttribute,
-        (SELECT GROUP_CONCAT(CONCAT(dda.dict_label,'(',hc.chemical_unit,')')) FROM sys_dict_data dda WHERE dda.dict_type = 'chemical_shape' AND dda.dict_value = hc.chemical_shape) chemicalShapeInfo,
-        (SELECT GROUP_CONCAT(dda.dict_label) FROM sys_dict_data dda WHERE dda.dict_type = 'chemical_shape' AND dda.dict_value = hc.chemical_shape) chemicalShapeInfo2,
+        (SELECT GROUP_CONCAT(dda.dict_label) FROM sys_dict_data dda WHERE dda.dict_type = 'hxp_classifyattribute' AND
+        FIND_IN_SET(dda.dict_value, hc.classify_attribute)) classifyAttribute,
+        (SELECT GROUP_CONCAT(CONCAT(dda.dict_label,'(',hc.chemical_unit,')')) FROM sys_dict_data dda WHERE dda.dict_type
+        = 'chemical_shape' AND dda.dict_value = hc.chemical_shape) chemicalShapeInfo,
+        (SELECT GROUP_CONCAT(dda.dict_label) FROM sys_dict_data dda WHERE dda.dict_type = 'chemical_shape' AND
+        dda.dict_value = hc.chemical_shape) chemicalShapeInfo2,
         case when hc.label_type=1 then 'RFID' else '二维码' end labelContent, hc.measuring_method, hc.chemical_unit,
-        case when hc.verification=1 then '单人验证' else '双人双卡' end verificationContent, hc.another_name, hc.cas_num, hc.factory, hc.purity, hc.collect_hour, hc.collect_minute, hc.user_id,
+        case when hc.verification=1 then '单人验证' else '双人双卡' end verificationContent, hc.another_name, hc.cas_num,
+        hc.factory, hc.purity, hc.collect_hour, hc.collect_minute, hc.user_id,
         (SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = hc.user_id) create_by, hc.create_time,
         hc.update_by, hc.update_time, hc.remark,
-        CASE WHEN hc.measuring_method = 1 THEN '重量' ELSE CASE WHEN hc.measuring_method = 2 THEN '体积' ELSE '个数' END END measuringMethodContent
+        CASE WHEN hc.measuring_method = 1 THEN '重量' ELSE CASE WHEN hc.measuring_method = 2 THEN '体积' ELSE '个数' END END
+        measuringMethodContent
         from hxp_chemical hc LEFT JOIN sys_user su ON hc.user_id = su.user_id
         <where>
             <if test="searchValue != null  and searchValue != ''">
-             and (hc.chemical_name like concat('%',#{searchValue},'%') or hc.another_name like concat('%',#{searchValue},'%') or hc.cas_num like concat('%',#{searchValue},'%'))
+                and (hc.chemical_name like concat('%',#{searchValue},'%') or hc.another_name like
+                concat('%',#{searchValue},'%') or hc.cas_num like concat('%',#{searchValue},'%'))
             </if>
-            <if test="chemicalClassify != null "> and hc.chemical_classify = #{chemicalClassify}</if>
-            <if test="classifyAttribute != null "> AND FIND_IN_SET(#{classifyAttribute}, hc.classify_attribute)</if>
-            <if test="labelType != null "> and hc.label_type = #{labelType}</if>
+            <if test="chemicalClassify != null ">and hc.chemical_classify = #{chemicalClassify}</if>
+            <if test="classifyAttribute != null ">AND FIND_IN_SET(#{classifyAttribute}, hc.classify_attribute)</if>
+            <if test="labelType != null ">and hc.label_type = #{labelType}</if>
             <if test="ids!=null and ids.size > 0">
                 AND hc.id IN
                 <foreach item="item" collection="ids" separator="," open="(" close=")" index="">'${item}'</foreach>
             </if>
-            <if test="casNum != null "> and hc.cas_num = #{casNum}</if>
+            <if test="casNum != null ">and hc.cas_num = #{casNum}</if>
             <!-- 数据范围过滤 -->
             ${params.dataScope}
         </where>
@@ -79,50 +134,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
 
-    <insert id="insertHxpChemical" parameterType="com.zd.chemical.domain.HxpChemical" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertHxpChemical" parameterType="com.zd.chemical.domain.HxpChemical" useGeneratedKeys="true"
+            keyProperty="id">
         insert into hxp_chemical
         <trim prefix="(" suffix=")" suffixOverrides=",">
-    <if test="chemicalNum != null">chemical_num,</if>
+            <if test="chemicalNum != null">chemical_num,</if>
 
-    <if test="chemicalName != null">chemical_name,</if>
+            <if test="chemicalName != null">chemical_name,</if>
 
-    <if test="chemicalClassify != null">chemical_classify,</if>
+            <if test="chemicalClassify != null">chemical_classify,</if>
 
-    <if test="classifyAttribute != null">classify_attribute,</if>
+            <if test="classifyAttribute != null">classify_attribute,</if>
 
-    <if test="chemicalShape != null">chemical_shape,</if>
+            <if test="chemicalShape != null">chemical_shape,</if>
 
-    <if test="labelType != null">label_type,</if>
+            <if test="labelType != null">label_type,</if>
 
-    <if test="measuringMethod != null">measuring_method,</if>
+            <if test="measuringMethod != null">measuring_method,</if>
 
-    <if test="chemicalUnit != null">chemical_unit,</if>
+            <if test="chemicalUnit != null">chemical_unit,</if>
 
-    <if test="verification != null">verification,</if>
+            <if test="verification != null">verification,</if>
 
-    <if test="anotherName != null">another_name,</if>
+            <if test="anotherName != null">another_name,</if>
 
-    <if test="casNum != null">cas_num,</if>
+            <if test="casNum != null">cas_num,</if>
 
-    <if test="factory != null">factory,</if>
+            <if test="factory != null">factory,</if>
 
-    <if test="purity != null">purity,</if>
+            <if test="purity != null">purity,</if>
 
-    <if test="collectHour != null">collect_hour,</if>
+            <if test="collectHour != null">collect_hour,</if>
 
-    <if test="collectMinute != null">collect_minute,</if>
+            <if test="collectMinute != null">collect_minute,</if>
 
-    <if test="userId != null">user_id,</if>
+            <if test="userId != null">user_id,</if>
 
-    <if test="createBy != null">create_by,</if>
+            <if test="createBy != null">create_by,</if>
 
-    <if test="createTime != null">create_time,</if>
+            <if test="createTime != null">create_time,</if>
 
-    <if test="updateBy != null">update_by,</if>
+            <if test="updateBy != null">update_by,</if>
 
-    <if test="updateTime != null">update_time,</if>
+            <if test="updateTime != null">update_time,</if>
 
-    <if test="remark != null">remark,</if>
+            <if test="remark != null">remark,</if>
 
             <if test="chemicalNamePinyin != null">chemical_name_pinyin,</if>
 
@@ -132,29 +188,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
             <if test="anotherNameChar != null">another_name_char,</if>
 
-         </trim>
+            <if test="criticality != null">criticality,</if>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-    <if test="chemicalNum != null">#{chemicalNum},</if>
-    <if test="chemicalName != null">#{chemicalName},</if>
-    <if test="chemicalClassify != null">#{chemicalClassify},</if>
-    <if test="classifyAttribute != null">#{classifyAttribute},</if>
-    <if test="chemicalShape != null">#{chemicalShape},</if>
-    <if test="labelType != null">#{labelType},</if>
-    <if test="measuringMethod != null">#{measuringMethod},</if>
-    <if test="chemicalUnit != null">#{chemicalUnit},</if>
-    <if test="verification != null">#{verification},</if>
-    <if test="anotherName != null">#{anotherName},</if>
-    <if test="casNum != null">#{casNum},</if>
-    <if test="factory != null">#{factory},</if>
-    <if test="purity != null">#{purity},</if>
-    <if test="collectHour != null">#{collectHour},</if>
-    <if test="collectMinute != null">#{collectMinute},</if>
-    <if test="userId != null">#{userId},</if>
-    <if test="createBy != null">#{createBy},</if>
-    <if test="createTime != null">#{createTime},</if>
-    <if test="updateBy != null">#{updateBy},</if>
-    <if test="updateTime != null">#{updateTime},</if>
-    <if test="remark != null">#{remark},</if>
+            <if test="chemicalNum != null">#{chemicalNum},</if>
+            <if test="chemicalName != null">#{chemicalName},</if>
+            <if test="chemicalClassify != null">#{chemicalClassify},</if>
+            <if test="classifyAttribute != null">#{classifyAttribute},</if>
+            <if test="chemicalShape != null">#{chemicalShape},</if>
+            <if test="labelType != null">#{labelType},</if>
+            <if test="measuringMethod != null">#{measuringMethod},</if>
+            <if test="chemicalUnit != null">#{chemicalUnit},</if>
+            <if test="verification != null">#{verification},</if>
+            <if test="anotherName != null">#{anotherName},</if>
+            <if test="casNum != null">#{casNum},</if>
+            <if test="factory != null">#{factory},</if>
+            <if test="purity != null">#{purity},</if>
+            <if test="collectHour != null">#{collectHour},</if>
+            <if test="collectMinute != null">#{collectMinute},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
             <if test="chemicalNamePinyin != null">#{chemicalNamePinyin},</if>
 
             <if test="chemicalNameChar != null">#{chemicalNameChar},</if>
@@ -162,7 +219,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="anotherNamePinyin != null">#{anotherNamePinyin},</if>
 
             <if test="anotherNameChar != null">#{anotherNameChar},</if>
-         </trim>
+
+            <if test="criticality != null">#{criticality},</if>
+        </trim>
     </insert>
 
     <update id="updateHxpChemical" parameterType="com.zd.chemical.domain.HxpChemical">
@@ -196,18 +255,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="anotherNamePinyin != null">another_name_pinyin = #{anotherNamePinyin},</if>
             <if test="anotherNameChar != null">another_name_char = #{anotherNameChar},</if>
 
+            <if test="criticality != null">criticality = #{criticality},</if>
+
         </trim>
         where id = #{id}
     </update>
 
     <update id="clearHxpChemicalByJoinHazard" parameterType="com.zd.chemical.domain.HxpChemical">
-        update hxp_chemical set
-        join_hazard_id = NULL
+        update hxp_chemical
+        set join_hazard_id = NULL
         where id = #{id}
     </update>
 
     <delete id="deleteHxpChemicalById" parameterType="Long">
-        delete from hxp_chemical where id = #{id}
+        delete
+        from hxp_chemical
+        where id = #{id}
     </delete>
 
     <delete id="deleteHxpChemicalByIds" parameterType="String">
@@ -218,7 +281,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
 
-    <select id="chemicalUsageCount" parameterType="com.zd.chemical.domain.HxpChemical" resultType="com.zd.chemical.domain.vo.HxpHomeChemicalVo">
+    <select id="chemicalUsageCount" parameterType="com.zd.chemical.domain.HxpChemical"
+            resultType="com.zd.chemical.domain.vo.HxpHomeChemicalVo">
         SELECT
         (SELECT IFNULL(COUNT(1),0) FROM hxp_stock sk
         LEFT JOIN sys_user ur ON sk.user_id = ur.user_id WHERE sk.status=1
@@ -241,7 +305,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ${params.dataScope}
         ) chemicalCancelNum,
         (SELECT IFNULL(COUNT(1),0) FROM hxp_stock sk INNER JOIN hxp_chemical_join_cabinet cjc ON sk.join_id = cjc.id
-        LEFT JOIN sys_user ur ON sk.user_id = ur.user_id WHERE  DATE_SUB(cjc.expire_time, INTERVAL 3 DAY)&lt;=NOW()
+        LEFT JOIN sys_user ur ON sk.user_id = ur.user_id WHERE DATE_SUB(cjc.expire_time, INTERVAL 3 DAY)&lt;=NOW()
         AND cjc.expire_time>NOW()
         <!-- 数据范围过滤 -->
         ${params.dataScope}
@@ -249,7 +313,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         FROM DUAL
     </select>
 
-    <select id="chemicalUnusualCount" parameterType="com.zd.chemical.domain.HxpChemical" resultType="com.zd.chemical.domain.vo.HxpHomeChemicalUnusualVo">
+    <select id="chemicalUnusualCount" parameterType="com.zd.chemical.domain.HxpChemical"
+            resultType="com.zd.chemical.domain.vo.HxpHomeChemicalUnusualVo">
         SELECT
         (SELECT IFNULL(COUNT(1),0) FROM hxp_userecord rd
         LEFT JOIN sys_user ur ON rd.user_id = ur.user_id WHERE rd.use_status = 1
@@ -262,31 +327,37 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ${params.dataScope}
         ) overtimeReturn,
         (SELECT IFNULL(COUNT(1),0) FROM hxp_userecord rd
-        LEFT JOIN sys_user ur ON rd.user_id = ur.user_id WHERE DATE_FORMAT(rd.collect_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')
+        LEFT JOIN sys_user ur ON rd.user_id = ur.user_id WHERE DATE_FORMAT(rd.collect_time,'%Y-%m-%d') =
+        DATE_FORMAT(NOW(),'%Y-%m-%d')
         <!-- 数据范围过滤 -->
         ${params.dataScope}
         ) todayCollect,
         (SELECT IFNULL(COUNT(1),0) FROM hxp_userecord rd
-        LEFT JOIN sys_user ur ON rd.user_id = ur.user_id WHERE rd.use_status = 0 AND DATE_FORMAT(rd.collect_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')
+        LEFT JOIN sys_user ur ON rd.user_id = ur.user_id WHERE rd.use_status = 0 AND
+        DATE_FORMAT(rd.collect_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')
         <!-- 数据范围过滤 -->
         ${params.dataScope}
         ) todayReturn,
         (SELECT IFNULL(COUNT(1),0) FROM hxp_stock sk
-        LEFT JOIN sys_user ur ON sk.user_id = ur.user_id WHERE sk.status=2 AND DATE_FORMAT(sk.out_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')
+        LEFT JOIN sys_user ur ON sk.user_id = ur.user_id WHERE sk.status=2 AND DATE_FORMAT(sk.out_time,'%Y-%m-%d') =
+        DATE_FORMAT(NOW(),'%Y-%m-%d')
         <!-- 数据范围过滤 -->
         ${params.dataScope}
         ) todayOutNum,
         (SELECT IFNULL(COUNT(1),0) FROM hxp_stock sk
-        LEFT JOIN sys_user ur ON sk.user_id = ur.user_id WHERE sk.status=3 AND DATE_FORMAT(sk.out_time,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d')
+        LEFT JOIN sys_user ur ON sk.user_id = ur.user_id WHERE sk.status=3 AND DATE_FORMAT(sk.out_time,'%Y-%m-%d') =
+        DATE_FORMAT(NOW(),'%Y-%m-%d')
         <!-- 数据范围过滤 -->
         ${params.dataScope}
         ) todayCancelNum
         FROM DUAL
     </select>
 
-    <select id="chemicalUsagesCount" parameterType="com.zd.chemical.domain.HxpChemical" resultType="com.zd.chemical.domain.vo.HxpHomeChemicalUsagesVo">
-        SELECT CONCAT(cl.`chemical_name`,'使用重量',CONCAT(SUM(sk.usages-sk.out_usages),cl.chemical_unit)) chemicalUsages, SUM(sk.usages-sk.out_usages)usages,
-        (SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = cl.user_id)  adminUser,
+    <select id="chemicalUsagesCount" parameterType="com.zd.chemical.domain.HxpChemical"
+            resultType="com.zd.chemical.domain.vo.HxpHomeChemicalUsagesVo">
+        SELECT CONCAT(cl.`chemical_name`,'使用重量',CONCAT(SUM(sk.usages-sk.out_usages),cl.chemical_unit)) chemicalUsages,
+        SUM(sk.usages-sk.out_usages)usages,
+        (SELECT ur.nick_name FROM sys_user ur WHERE ur.user_id = cl.user_id) adminUser,
         (SELECT cc.classify_name FROM hxp_chemical_classify cc WHERE cc.id = cl.chemical_classify) classifyName,
         (SELECT cc.hazard_level FROM hxp_chemical_classify cc WHERE cc.id = cl.chemical_classify) classifyLevel
         FROM hxp_stock sk
@@ -300,8 +371,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         GROUP BY cl.`id` ORDER BY usages DESC LIMIT 6
     </select>
 
-    <select id="chemicalClassifyMix" parameterType="com.zd.chemical.domain.HxpChemical" resultType="java.util.LinkedHashMap">
-        SELECT x1.dict_label classifyAttribute,CONCAT(CASE WHEN x2.chemical_name IS NULL THEN 0 ELSE COUNT(0) END,'') chemicalMix FROM (
+    <select id="chemicalClassifyMix" parameterType="com.zd.chemical.domain.HxpChemical"
+            resultType="java.util.LinkedHashMap">
+        SELECT x1.dict_label classifyAttribute,CONCAT(CASE WHEN x2.chemical_name IS NULL THEN 0 ELSE COUNT(0) END,'')
+        chemicalMix FROM (
         select xx1.* from(SELECT dda.`dict_label`,dda.dict_value
         FROM sys_dict_data dda
         WHERE dda.dict_type = 'hxp_classifyattribute'
@@ -312,7 +385,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         )x1
         LEFT JOIN
         (
-        select xx.chemical_name,case when xx.classify_attribute='' or xx.classify_attribute is null then 99 else xx.classify_attribute end classify_attribute from (
+        select xx.chemical_name,case when xx.classify_attribute='' or xx.classify_attribute is null then 99 else
+        xx.classify_attribute end classify_attribute from (
         SELECT cl.chemical_name,cl.classify_attribute
         FROM hxp_stock sk
         INNER JOIN hxp_chemical_join_cabinet cjc ON sk.join_id= cjc.id
@@ -355,14 +429,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT DATE_FORMAT(NOW(),'%Y-%m-%d') FROM DUAL
         )x1 LEFT JOIN hxp_stock sk
         <if test="status == 1">
-            ON DATE_FORMAT(x1.nowData,'%Y-%m-%d') = DATE_FORMAT(sk.join_time,'%Y-%m-%d') AND (sk.status=#{status} or sk.status=4)
+            ON DATE_FORMAT(x1.nowData,'%Y-%m-%d') = DATE_FORMAT(sk.join_time,'%Y-%m-%d') AND (sk.status=#{status} or
+            sk.status=4)
         </if>
         <if test="status == 2">
-            ON DATE_FORMAT(x1.nowData,'%Y-%m-%d') = DATE_FORMAT(sk.out_time,'%Y-%m-%d') AND (sk.status=#{status}  or sk.status=3)
+            ON DATE_FORMAT(x1.nowData,'%Y-%m-%d') = DATE_FORMAT(sk.out_time,'%Y-%m-%d') AND (sk.status=#{status} or
+            sk.status=3)
         </if>
         LEFT JOIN sys_user ur ON sk.user_id = ur.user_id
         <!-- 数据范围过滤 -->
         ${params.dataScope}
         GROUP BY x1.nowData
     </select>
+
+    <select id="queryCriticaliBySubId" resultType="java.util.Map">
+        select
+            t.subId,
+            cast((sum(t.critica)) as decimal(5,2)) as criticali
+        from (
+            select
+                s.subId,
+                ifnull((sum(s.suttle)/1000/1000/s.criticality), 0) as critica
+            from (
+                select
+                jo.sub_id as subId,
+                jo.chemical_id as chemicalId,
+                ifnull(che.criticality, 0) as criticality,
+                (s.usages - s.tare) as suttle
+                from hxp_stock s left join hxp_chemical_join_cabinet jo on s.join_id = jo.id
+                left join hxp_chemical che on jo.chemical_id = che.id
+                <where>
+                    s.status != 2 and s.status != 3
+                    <if test="subIds != null and subIds.size > 0">
+                        and jo.sub_id in
+                        <foreach item="id" collection="list" open="(" separator="," close=")">
+                            #{id}
+                        </foreach>
+                    </if>
+                </where>
+            ) s
+            group by s.subId
+        ) t
+
+    </select>
 </mapper>

+ 5 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/device/DeviceRemoteController.java

@@ -57,14 +57,16 @@ public class DeviceRemoteController {
 
             Thread.sleep(100);
             Integer status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
-            if(status != null && status == 1){
+            /*if(status != null && status == 1){
                 return R.ok();
-            }
+            }*/
+            // TODO 因样件锁 发送开锁指令后锁未主动弹开,先不关注锁的状态
+            return R.ok();
         } catch (Exception e) {
             e.printStackTrace();
             return R.fail("柜锁连接失败!");
         }
-        return R.fail();
+//        return R.fail();
     }
 
     /**

+ 35 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabSubjectVO.java

@@ -7,6 +7,7 @@ import com.zd.laboratory.interfaces.SysProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -19,12 +20,18 @@ import java.util.List;
 @ApiModel("实验室管理类")
 public class LabSubjectVO extends LabSubject {
 
-    @ApiModelProperty("楼名称")
+    @ApiModelProperty("楼名称")
     private String buildName;
 
     @ApiModelProperty("楼栋名称")
     private String building;
 
+    @ApiModelProperty(value = "楼层名称")
+    private String floorName;
+
+    @ApiModelProperty(value = "房间名称")
+    private String roomName;
+
     @ApiModelProperty("实验室学科")
     private String subDept;
 
@@ -91,6 +98,9 @@ public class LabSubjectVO extends LabSubject {
 
     private String adminNameAndPhone;
 
+    @ApiModelProperty(value = "化学品临界值危险指标")
+    private BigDecimal riskIndicator;
+
     public LabSubjectVO() {
     }
 
@@ -300,4 +310,28 @@ public class LabSubjectVO extends LabSubject {
     public void setSafeUserNameAdminPhone(String safeUserNameAdminPhone) {
         this.safeUserNameAdminPhone = safeUserNameAdminPhone;
     }
+
+    public BigDecimal getRiskIndicator() {
+        return riskIndicator;
+    }
+
+    public void setRiskIndicator(BigDecimal riskIndicator) {
+        this.riskIndicator = riskIndicator;
+    }
+
+    public String getFloorName() {
+        return floorName;
+    }
+
+    public void setFloorName(String floorName) {
+        this.floorName = floorName;
+    }
+
+    public String getRoomName() {
+        return roomName;
+    }
+
+    public void setRoomName(String roomName) {
+        this.roomName = roomName;
+    }
 }

+ 24 - 4
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectManagerService.java

@@ -4,10 +4,7 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
-import com.zd.common.core.constant.CacheConstants;
-import com.zd.common.core.constant.CacheDevice;
-import com.zd.common.core.constant.Constants;
-import com.zd.common.core.constant.SecurityConstants;
+import com.zd.common.core.constant.*;
 import com.zd.common.core.domain.R;
 import com.zd.common.core.enums.HardwareOperate;
 import com.zd.common.core.enums.HardwareTypeEnum;
@@ -36,6 +33,7 @@ import com.zd.laboratory.socket.vo.TransmissionVo;
 import com.zd.laboratory.utils.FunctionMapperUtil;
 import com.zd.system.api.RemoteUserService;
 import com.zd.system.api.chemical.RemoteChemicalAlarmService;
+import com.zd.system.api.chemical.RemoteChemicalService;
 import com.zd.system.api.domain.SubQueryConfig;
 import com.zd.system.api.domain.SysDictData;
 import com.zd.system.api.domain.SysUser;
@@ -53,6 +51,7 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
@@ -103,6 +102,8 @@ public class LabSubjectManagerService {
 
     @Autowired
     RemoteChemicalAlarmService remoteChemicalAlarmService;
+    @Autowired
+    private RemoteChemicalService remoteChemicalService;
 
     private Map<Control.CommTypeEnums, ControlService> controlServiceMap = new HashMap<>();
 
@@ -493,6 +494,7 @@ public class LabSubjectManagerService {
         //1.获取权限的分页数据
         PageHelperUtil.startPage();
         List<LabSubjectVO> labSubjects = subjectService.selectLabSubjectListAUTH(subject);
+        List<Long> subIds = new ArrayList<>();
         labSubjects.forEach( a -> {
             // 危险源
             List<LabHazardSubVO> hazards = labHazardSubjectRelationService.queryHazardSubListVO(a.getId());
@@ -505,7 +507,25 @@ public class LabSubjectManagerService {
                 hazardList.add(hazardSubVO);
             });
             a.setLabHazardList(hazardList);
+
+            a.setSafeUserName(labSubjectMapper.queryUserNameBySafeUserId(a.getSafeUserId()));
+
+            subIds.add(a.getId());
+
+
         });
+        // 实验室化学品临界量计算
+        R r = remoteChemicalService.queryCriticaliBySubId(subIds);
+        if(r.getCode() == HttpStatus.SUCCESS){
+            Map<Long, BigDecimal> map = (Map<Long, BigDecimal>) r.getData();
+            map.entrySet().forEach(a -> {
+                labSubjects.forEach(s -> {
+                    if(Objects.equals(s.getId(), a.getKey())){
+                        s.setRiskIndicator(a.getValue());
+                    }
+                });
+            });
+        }
 
 
         // 2.5 页面改变,接口加分页,并拆成两部分

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

@@ -162,7 +162,12 @@
                t.check_count,
                t.sign_time,
                t.mold_id,
-               CONCAT(su.nick_name,'@',su.phonenumber) AS adminNameAndPhone
+               CONCAT(su.nick_name,'@',su.phonenumber) AS adminNameAndPhone,
+
+               (select d.dept_name from sys_dept d where t.build_id = d.dept_id) buildName,
+               (select b.name from lab_building b where b.id = t.floor_id) floorName,
+               (SELECT l.room FROM lab_subject_layout l WHERE l.id = t.layout_id ) roomName
+
         from lab_subject t
         left  join  sys_user su on su.user_id = t.admin_id  AND su.`del_flag`=0
         left  join  sys_dept sd on sd.dept_id = t.dept_id

+ 2 - 1
zd-modules/zd-netty/src/main/java/com/zd/netty/enums/ManufacturerTypeEnum.java

@@ -1,5 +1,6 @@
 package com.zd.netty.enums;
 
+import com.zd.netty.sdk.DeJuRFIDListenerService;
 import com.zd.netty.sdk.DeJuRFIDService;
 import com.zd.netty.sdk.WuYuanRFIDService;
 import com.zd.netty.service.IService;
@@ -11,7 +12,7 @@ import lombok.Getter;
 public enum ManufacturerTypeEnum {
 
     WU_WEI(1,"无源", WuYuanRFIDService.class),
-    DE_JU(2,"惠州德聚",DeJuRFIDService .class);
+    DE_JU(2,"惠州德聚", DeJuRFIDListenerService.class);
 
     private final Integer code;
     private final String name;

+ 220 - 0
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDListenerService.java

@@ -0,0 +1,220 @@
+package com.zd.netty.sdk;
+
+import com.gg.reader.api.dal.GClient;
+import com.gg.reader.api.dal.GServer;
+import com.gg.reader.api.protocol.gx.*;
+import com.zd.common.core.utils.SpringUtils;
+import com.zd.netty.service.ISendService;
+import com.zd.netty.service.IService;
+import com.zd.system.api.domain.InventoryTag;
+import com.zd.system.api.laboratory.domain.RemoteLabHardware;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Objects;
+import java.util.TimerTask;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+
+@Slf4j
+@Service
+public class DeJuRFIDListenerService implements IService {
+
+    @Resource
+    private ISendService sendService;
+
+    private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
+
+    AtomicBoolean isAlarm = new AtomicBoolean();
+
+    GClient client;
+
+    private final ScheduledExecutorService scheduledExecutorService = SpringUtils.getBean("scheduledExecutorService");
+
+    @Override
+    public void start(RemoteLabHardware hardware) {
+        String ipAddress = hardware.getIpAddress();
+        if (clientMap.containsKey(ipAddress)){
+            return;
+        }
+        GServer server = new GServer();
+        if (server.open(9190)) {
+            subscribeServerHandler(server);
+            if (client!=null){
+                clientMap.put(ipAddress,client);
+                setPower(hardware);
+                setInventory(hardware);
+                subscribeHandler(client);
+            }
+            log.info("开始监听");
+        } else {
+            log.info("监听失败");
+        }
+    }
+
+    @Override
+    public void disconnect(RemoteLabHardware hardware) {
+        stop();
+        clientMap.remove(hardware.getIpAddress());
+    }
+
+    //订阅监听上报
+    private void subscribeServerHandler(GServer server) {
+        server.onGClientConnected = (gClient, serialNumber) -> {
+            log.info(gClient.getName() + "---监听成功");
+            client = gClient;//切换连接对象
+            client.setSendHeartBeat(true);//开启心跳检测Tcp连接状态
+            client.setPrint(true);
+            subscribeTcpHandler();//订阅Tcp断连上报
+            stop();//测试监听成功的连接是否通信正常
+        };
+    }
+
+    //订阅TCP断开连接上报
+    private void subscribeTcpHandler() {
+        client.onDisconnected = s -> {
+            log.info("连接" + s + "已断开");
+            client.close();//释放当前连接资源
+        };
+    }
+
+    private void stop() {
+        MsgBaseStop msg = new MsgBaseStop();
+        client.sendSynMsg(msg);
+        if (0x00 == msg.getRtCode()) {
+            log.info("Stop success");
+        } else {
+            log.info(msg.getRtMsg());
+        }
+    }
+
+    /**
+     * 订阅6c标签信息上报
+     *
+     * @param client 客户端
+     */
+    private void subscribeHandler(GClient client) {
+        client.onTagEpcLog = (s, logBaseEpcInfo) -> {
+            if (logBaseEpcInfo.getResult() == 0) {
+                log.info("===========》{}", logBaseEpcInfo.getbEpc());
+                //灯带设置
+                if (!isAlarm.get()) {
+                    scheduledExecutorService.execute(() -> {
+                        isAlarm.set(true);
+                        changeGpo(1, client, 10);
+                    });
+                }
+                InventoryTag tag = new InventoryTag();
+                BeanUtils.copyProperties(logBaseEpcInfo, tag);
+                sendService.send(tag);
+            }
+        };
+        client.onTagEpcOver = (s, logBaseEpcOver) -> log.info("HandlerTagEpcOver");
+    }
+
+    private void changeGpo(int state, GClient client, int delayTime) {
+        MsgAppSetGpo msgAppSetGpo = new MsgAppSetGpo();
+        msgAppSetGpo.setGpo1(state);
+        msgAppSetGpo.setGpo2(state);
+
+        client.sendSynMsg(msgAppSetGpo);
+        String status = state == 1 ? "start" : "stop";
+        if (0 == msgAppSetGpo.getRtCode()) {
+            if (state == 1) {
+                stopGpo(client, delayTime);
+            } else {
+                isAlarm.set(false);
+            }
+        } else {
+            log.error("Gpo epc {} error.", status);
+            if (state == 1) {
+                stopGpo(client, delayTime);
+            }
+        }
+    }
+
+    public void stopGpo(GClient client, int delayTime) {
+        scheduledExecutorService.schedule(new TimerTask() {
+            @Override
+            public void run() {
+                changeGpo(0, client, 0);
+            }
+        }, delayTime, TimeUnit.SECONDS);
+    }
+
+    private void setPower(RemoteLabHardware hardware){
+        // 功率配置, 将4个天线功率都设置为30dBm.
+        Integer uniformPower = hardware.getUniformPower();
+        MsgBaseGetPower msgBaseGetPower = new MsgBaseGetPower();
+        client.sendSynMsg(msgBaseGetPower);
+        if (0 == msgBaseGetPower.getRtCode()) {
+            Hashtable<Integer, Integer> dicPower = msgBaseGetPower.getDicPower();
+            Integer integer = dicPower.get(0);
+            if (!Objects.equals(integer, uniformPower)) {
+                MsgBaseSetPower msgBaseSetPower = new MsgBaseSetPower();
+                Hashtable<Integer, Integer> hashtable = new Hashtable<>();
+
+                Integer channels = hardware.getChannels();
+                for (int i = 1; i <= channels; i++) {
+                    hashtable.put(i, uniformPower);
+                }
+                msgBaseSetPower.setDicPower(hashtable);
+                client.sendSynMsg(msgBaseSetPower);
+                if (0 != msgBaseSetPower.getRtCode()) {
+                    log.error("Power configuration error.");
+                    reset(client);
+                    disconnect(hardware);
+                    start(hardware);
+                }
+            }
+        } else {
+            log.error("Power configuration error.");
+            reset(client);
+            disconnect(hardware);
+            start(hardware);
+        }
+    }
+
+    private void setInventory(RemoteLabHardware hardware){
+        //天线读卡, 读取EPC数据区以及TID数据区
+        MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc();
+        switch (hardware.getChannels()) {
+            case 4:
+                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4);
+                break;
+            case 8:
+                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4 | EnumG.AntennaNo_5 | EnumG.AntennaNo_6 | EnumG.AntennaNo_7 | EnumG.AntennaNo_8);
+                break;
+            case 16:
+                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1 | EnumG.AntennaNo_2 | EnumG.AntennaNo_3 | EnumG.AntennaNo_4 | EnumG.AntennaNo_5 | EnumG.AntennaNo_6 | EnumG.AntennaNo_7 | EnumG.AntennaNo_8 | EnumG.AntennaNo_9 | EnumG.AntennaNo_10 | EnumG.AntennaNo_11 | EnumG.AntennaNo_12 | EnumG.AntennaNo_13 | EnumG.AntennaNo_14 | EnumG.AntennaNo_15 | EnumG.AntennaNo_16);
+                break;
+            case 1:
+            default:
+                msgBaseInventoryEpc.setAntennaEnable(EnumG.AntennaNo_1);
+        }
+        msgBaseInventoryEpc.setInventoryMode(EnumG.InventoryMode_Inventory);
+
+        client.sendSynMsg(msgBaseInventoryEpc);
+        if (0 != msgBaseInventoryEpc.getRtCode()) {
+            log.error("Inventory epc error.");
+            reset(client);
+            disconnect(hardware);
+            start(hardware);
+        }
+    }
+
+    public void reset(GClient client) {
+        MsgAppReset msgAppReset = new MsgAppReset();
+        client.sendSynMsg(msgAppReset);
+        if (0 != msgAppReset.getRtCode()) {
+            log.error("Reset epc error.");
+        }
+    }
+}

+ 42 - 46
zd-modules/zd-netty/src/main/java/com/zd/netty/sdk/DeJuRFIDService.java

@@ -22,6 +22,7 @@ import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 @Slf4j
 @Service
@@ -32,7 +33,9 @@ public class DeJuRFIDService implements IService {
 
     private final Map<String, GClient> clientMap = new ConcurrentHashMap<>();
 
-    private final ScheduledExecutorService scheduledExecutorService= SpringUtils.getBean("scheduledExecutorService");
+    AtomicBoolean isAlarm = new AtomicBoolean();
+
+    private final ScheduledExecutorService scheduledExecutorService = SpringUtils.getBean("scheduledExecutorService");
 
     @Override
     public void start(RemoteLabHardware hardware) {
@@ -64,32 +67,20 @@ public class DeJuRFIDService implements IService {
                     }
                     msgBaseSetPower.setDicPower(hashtable);
                     client.sendSynMsg(msgBaseSetPower);
-                    if (0 == msgBaseSetPower.getRtCode()) {
-                        log.info("Power configuration successful.");
-                    } else {
-                        log.info("Power configuration error.");
+                    if (0 != msgBaseSetPower.getRtCode()) {
+                        log.error("Power configuration error.");
+                        reset(client);
                         disconnect(hardware);
                         start(hardware);
                     }
                 }
             } else {
-                log.info("Power configuration error.");
+                log.error("Power configuration error.");
+                reset(client);
                 disconnect(hardware);
                 start(hardware);
             }
 
-            //蜂鸣器设置
-//            MsgAppSetBeep msgAppSetBeep = new MsgAppSetBeep();
-//            msgAppSetBeep.setBeepMode(hardware.getSessionIndex() > 1 ? 1 : 0);
-//            msgAppSetBeep.setBeepStatus(1);
-//            client.sendSynMsg(msgAppSetBeep);
-//
-//            if (0 == msgAppSetBeep.getRtCode()) {
-//                log.info("Beep epc successful.");
-//            } else {
-//                log.info("Beep epc error.");
-//            }
-
             //天线读卡, 读取EPC数据区以及TID数据区
             MsgBaseInventoryEpc msgBaseInventoryEpc = new MsgBaseInventoryEpc();
             switch (hardware.getChannels()) {
@@ -109,10 +100,9 @@ public class DeJuRFIDService implements IService {
             msgBaseInventoryEpc.setInventoryMode(EnumG.InventoryMode_Inventory);
 
             client.sendSynMsg(msgBaseInventoryEpc);
-            if (0 == msgBaseInventoryEpc.getRtCode()) {
-                log.info("Inventory epc successful.");
-            } else {
-                log.info("Inventory epc error.");
+            if (0 != msgBaseInventoryEpc.getRtCode()) {
+                log.error("Inventory epc error.");
+                reset(client);
                 disconnect(hardware);
                 start(hardware);
             }
@@ -121,53 +111,56 @@ public class DeJuRFIDService implements IService {
         }
     }
 
+    public void reset(GClient client) {
+        MsgAppReset msgAppReset = new MsgAppReset();
+        client.sendSynMsg(msgAppReset);
+        if (0 != msgAppReset.getRtCode()) {
+            log.error("Reset epc error.");
+        }
+    }
+
     @Override
     public void disconnect(RemoteLabHardware hardware) {
         String ipAddress = hardware.getIpAddress();
         if (clientMap.containsKey(ipAddress)) {
             GClient client = clientMap.get(ipAddress);
-            changeGpo(0, client);
+            changeGpo(0, client, 0);
             MsgBaseStop msg = new MsgBaseStop();
             // 停止读卡,空闲态
             client.sendSynMsg(msg);
-            if (0 == msg.getRtCode()) {
-                log.info("Stop successful.");
-            } else {
-                log.info("Stop error.");
-            }
-            log.info("Close the connection");
             client.close();
             clientMap.remove(ipAddress);
         }
     }
 
-    private void changeGpo(int state, GClient client) {
-        MsgAppSetGpo msgAppSetGpo=new MsgAppSetGpo();
+    private void changeGpo(int state, GClient client, int delayTime) {
+        MsgAppSetGpo msgAppSetGpo = new MsgAppSetGpo();
         msgAppSetGpo.setGpo1(state);
         msgAppSetGpo.setGpo2(state);
-        msgAppSetGpo.setGpo3(state);
-        msgAppSetGpo.setGpo4(state);
-        msgAppSetGpo.setGpo5(state);
-        msgAppSetGpo.setGpo6(state);
-        msgAppSetGpo.setGpo7(state);
-        msgAppSetGpo.setGpo8(state);
 
         client.sendSynMsg(msgAppSetGpo);
         String status = state == 1 ? "start" : "stop";
         if (0 == msgAppSetGpo.getRtCode()) {
-            log.info("Gpo epc {} successful.",status);
+            if (state == 1) {
+                stopGpo(client, delayTime);
+            } else {
+                isAlarm.set(false);
+            }
         } else {
-            log.error("Gpo epc {} error.",status);
+            log.error("Gpo epc {} error.", status);
+            if (state == 1) {
+                stopGpo(client, delayTime);
+            }
         }
     }
 
-    public void stopGpo(GClient client){
+    public void stopGpo(GClient client, int delayTime) {
         scheduledExecutorService.schedule(new TimerTask() {
             @Override
             public void run() {
-                changeGpo(0, client);
+                changeGpo(0, client, 0);
             }
-        },10, TimeUnit.SECONDS);
+        }, delayTime, TimeUnit.SECONDS);
     }
 
     /**
@@ -178,16 +171,19 @@ public class DeJuRFIDService implements IService {
     private void subscribeHandler(GClient client) {
         client.onTagEpcLog = (s, logBaseEpcInfo) -> {
             if (logBaseEpcInfo.getResult() == 0) {
-                log.info("===========》{}",logBaseEpcInfo.getbEpc());
+                log.info("===========》{}", logBaseEpcInfo.getbEpc());
                 //灯带设置
-                changeGpo(1, client);
-                stopGpo(client);
+                if (!isAlarm.get()) {
+                    scheduledExecutorService.execute(() -> {
+                        isAlarm.set(true);
+                        changeGpo(1, client, 10);
+                    });
+                }
                 InventoryTag tag = new InventoryTag();
                 BeanUtils.copyProperties(logBaseEpcInfo, tag);
                 sendService.send(tag);
             }
         };
-
         client.onTagEpcOver = (s, logBaseEpcOver) -> log.info("HandlerTagEpcOver");
     }
 }