linfutong 3 anni fa
parent
commit
ca712b0699
17 ha cambiato i file con 371 aggiunte e 388 eliminazioni
  1. 80 0
      zd-model/src/main/java/com/zd/model/constant/MqttConstants.java
  2. 5 5
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabRotationChartController.java
  3. 3 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubjectController.java
  4. 0 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubjectDengerRelationController.java
  5. 2 2
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/SensorLabMessageEvent.java
  6. 36 35
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/config/MqttConfig.java
  7. 0 86
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/constants/MqttConstants.java
  8. 2 2
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/service/hxp/HxpLockService.java
  9. 19 20
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/service/impl/SubMessageSendManager.java
  10. 0 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/test/MqttTest.java
  11. 67 67
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabCheckMachineMsgServiceImpl.java
  12. 2 2
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabCheckRecordReleaseServiceImpl.java
  13. 2 2
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabCheckRecordServiceImpl.java
  14. 2 2
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabContentMachineMsgServiceImpl.java
  15. 103 104
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabGradeManageRecordServiceImpl.java
  16. 46 53
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabMessageContentServiceImpl.java
  17. 2 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabNotifyplanServiceImpl.java

+ 80 - 0
zd-model/src/main/java/com/zd/model/constant/MqttConstants.java

@@ -0,0 +1,80 @@
+package com.zd.model.constant;
+
+/**
+ * <p>MQTT配置常量</p>
+ *
+ * @author linft
+ * @version 1.0
+ * @date 10/26/2022
+ */
+public interface MqttConstants {
+
+    String TOPIC_ALERT = "alarm/";
+
+    String TOPIC_LAB = "lab/new";
+
+    //实验室项目配置
+
+    //实验室信息变更通知 topic
+    String TOPIC_LAB_SUB_INFO = "lab/subInfo";
+    //数据大屏数据改变通知 topic
+    String TOPIC_LAB_BIG_VIEW = "lab/bigview";
+    //预警改变通知 topic
+    String TOPIC_LAB_WRAN = "lab/wran";
+    //测点数据topic
+    String TOPIC_LAB_FUNCTION_DATA = "lab/function/data";
+    //一体机消息推送 topic
+    String TOPIC_LAB_ONEPC_SUB_NEWS = "lab/news";
+    //一体机消息推送apk版本升级 topic
+    String TOPIC_LAB_ONEPC_SUB_APKUP = "lab/apkup";
+    //一体机消息推送配置变动 topic
+    String TOPIC_LAB_ONEPC_SUB_UPCONFIG = "lab/upconfig";
+    //硬件状态变化 LAB_HARDWARE_DATA_SUB和LAB_VIDEO的合集
+    String TOPIC_LAB_VIDEO_DATA = "lab/hardware/data";
+
+    //硬件状态变化,实验室为主体 (继电器)
+    String TOPIC_LAB_HARDWARE_DATA_SUB = "lab/hardware/data/sub";
+    //视频、一体机上下线
+    String TOPIC_LAB_VIDEO = "lab/video";
+
+    //硬件统计 好像不需要
+    String TOPIC_LAB_HARDWARE_TOTAL = "lab/hardware/total";
+
+    //传感器
+    String TOPIC_LAB_SENSOR = "lab/sensor";
+
+    // 一体机检查通知
+    String TOPIC_LAB_CHECK = "lab/check";
+
+    // 一体机消息通知
+    String TOPIC_LAB_CONTENT = "lab/content";
+
+    // 一体机轮播图变更通知
+    String TOPIC_LAB_ROTATION = "lab/rotation";
+
+    //逃生指引线路通知
+    String TOPIC_LAB_EXIT_LINE = "lab/exit/line";
+
+    //管控工作通知
+    String TOPIC_LAB_MANAGE_WORK = "manage/work";
+
+    //大屏通知计划更新通知
+    String TOPIC_LAB_BIG_VIEW_PLAN = "lab/bigview/plan";
+
+    //大屏安全检查更新通知
+    String TOPIC_LAB_BIG_VIEW_CHECKAPPLY = "lab/bigview/checkApply";
+
+    //logo同步通知 topic
+    String TOPIC_SYS_LOGO_CONFIG = "sys/logo";
+
+    // 化学品终端心跳 + {设备编号}
+    String TOPIC_SYS_CHEMICAL_ON = "lab/chemical/";
+
+    // 化学品终端离线遗嘱 + {设备编号}
+    String TOPIC_SYS_CHEMICAL_OFF = "lab/off-chemical/";
+    //坨机接收topic
+    String TOPIC_HEAP_RECIVER = "lab/heap/";
+
+    // 柜锁操作成功topic  lab/cabinetLock/{subId}/{lockId}
+    String TOPIC_CABINET_LOCK = "lab/cabinetLock/";
+}

+ 5 - 5
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabRotationChartController.java

@@ -5,10 +5,10 @@ import java.io.IOException;
 import javax.servlet.http.HttpServletResponse;
 
 import com.github.xiaoymin.knife4j.annotations.ApiSupport;
+import com.zd.model.constant.MqttConstants;
 import com.zd.model.domain.per.PerFun;
 import com.zd.model.domain.per.PerPrefix;
 import com.zd.model.domain.ResultData;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -98,7 +98,7 @@ public class LabRotationChartController extends BaseController
     {
         int num = labRotationChartService.insertLabRotationChart(labRotationChart);
 
-        commonSend.send(MqttConstants.LAB_ROTATION, "新增了一个轮播图");
+        commonSend.send(MqttConstants.TOPIC_LAB_ROTATION, "新增了一个轮播图");
         return ResultData.result(num);
     }
 
@@ -112,7 +112,7 @@ public class LabRotationChartController extends BaseController
     public ResultData edit(@RequestBody LabRotationChart labRotationChart)
     {
         int count = labRotationChartService.updateLabRotationChart(labRotationChart);
-        commonSend.send(MqttConstants.LAB_ROTATION, "修改了一个轮播图");
+        commonSend.send(MqttConstants.TOPIC_LAB_ROTATION, "修改了一个轮播图");
         return  ResultData.result(count);
     }
 
@@ -126,7 +126,7 @@ public class LabRotationChartController extends BaseController
     public ResultData remove(@PathVariable Long[] ids)
     {
         int count = labRotationChartService.deleteLabRotationChartByIds(ids);
-        commonSend.send(MqttConstants.LAB_ROTATION, "删除了一个轮播图");
+        commonSend.send(MqttConstants.TOPIC_LAB_ROTATION, "删除了一个轮播图");
         return ResultData.result(count);
     }
 
@@ -146,7 +146,7 @@ public class LabRotationChartController extends BaseController
             labRotationChart.setImgType(1);
         }
         labRotationChartService.updateLabRotationChart(labRotationChart);
-        commonSend.send(MqttConstants.LAB_ROTATION, "打开或关闭轮播图");
+        commonSend.send(MqttConstants.TOPIC_LAB_ROTATION, "打开或关闭轮播图");
         return  ResultData.success(labRotationChart.getImgType());
     }
 

+ 3 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubjectController.java

@@ -14,11 +14,11 @@ import com.zd.laboratory.domain.LabSubject;
 import com.zd.laboratory.domain.vo.LabHazardSubjectRelationVO;
 import com.zd.laboratory.domain.vo.LabSubjectVO;
 import com.zd.laboratory.mapper.LabSubjectMapper;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import com.zd.laboratory.service.ILabHazardSubjectRelationService;
 import com.zd.laboratory.service.ILabQpSubjectRelationService;
 import com.zd.laboratory.service.ILabSubjectService;
+import com.zd.model.constant.MqttConstants;
 import com.zd.model.domain.R;
 import com.zd.model.domain.ResultData;
 import com.zd.model.domain.per.PerFun;
@@ -197,7 +197,7 @@ public class LabSubjectController extends BaseController {
     @PutMapping
     public ResultData edit(@RequestBody LabSubject labSubject) {
         labSubjectService.updateLabSubject(labSubject);
-        commonSend.send(MqttConstants.LAB_SUB_INFO + labSubject.getId(), labSubject.getId() + "实验室信息变更通知!");
+        commonSend.send(MqttConstants.TOPIC_LAB_SUB_INFO + labSubject.getId(), labSubject.getId() + "实验室信息变更通知!");
         return ResultData.success();
     }
 
@@ -210,7 +210,7 @@ public class LabSubjectController extends BaseController {
     @PutMapping("/editJoinHazard")
     public ResultData editJoinHazard(@RequestBody LabSubject labSubject) {
         labSubjectService.editJoinHazard(labSubject);
-        commonSend.send(MqttConstants.LAB_SUB_INFO + labSubject.getId(), labSubject.getId() + "实验室信息变更通知!");
+        commonSend.send(MqttConstants.TOPIC_LAB_SUB_INFO + labSubject.getId(), labSubject.getId() + "实验室信息变更通知!");
         return ResultData.success();
     }
 

+ 0 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubjectDengerRelationController.java

@@ -9,7 +9,6 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-
 import java.util.List;
 import java.util.Map;
 

+ 2 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/SensorLabMessageEvent.java

@@ -2,7 +2,7 @@ package com.zd.laboratory.event;
 
 import com.zd.laboratory.api.entity.SensorFunctionStatus;
 import com.zd.laboratory.api.vo.SubFunction;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
+import com.zd.model.constant.MqttConstants;
 import org.springframework.stereotype.Component;
 
 /**
@@ -31,6 +31,6 @@ public class SensorLabMessageEvent extends LabMessageEvent<SubFunction<SensorFun
 
     @Override
     public  String topic() {
-        return MqttConstants.LAB_FUNCTION_DATA;
+        return MqttConstants.TOPIC_LAB_FUNCTION_DATA;
     }
 }

+ 36 - 35
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/config/MqttConfig.java

@@ -5,9 +5,9 @@ import com.alibaba.fastjson.JSONObject;
 import com.zd.common.core.utils.SpringUtils;
 import com.zd.laboratory.event.LabMessageEvent;
 import com.zd.laboratory.event.SensorNewStatusEvent;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.service.TerminalRouter;
 import com.zd.laboratory.utils.HexUtils;
+import com.zd.model.constant.MqttConstants;
 import org.apache.commons.lang3.StringUtils;
 import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
 import org.slf4j.Logger;
@@ -31,6 +31,7 @@ import java.util.stream.Collectors;
 
 /**
  * mqtt配置
+ *
  * @author dgs
  */
 @Configuration
@@ -59,8 +60,8 @@ public class MqttConfig {
     @Value("${mqtt.url}")
     private String url;
 
-    @Value("${mqtt.defaultTopic}")
-    private String defaultTopic;
+    /*@Value("${mqtt.defaultTopic}")
+    private String defaultTopic;*/
 
     @Value("${mqtt.producer.clientId}")
     private String producerClientId;
@@ -79,14 +80,13 @@ public class MqttConfig {
 
     private MqttPahoMessageDrivenChannelAdapter adapter;
 
-    final Map<String, List<LabMessageEvent>> labMessMap = new HashMap <>();
+    final Map<String, List<LabMessageEvent>> labMessMap = new HashMap<>();
 
     public Map<String, List<LabMessageEvent>> getLabMessMap() {
         return labMessMap;
     }
 
-    public  MqttConfig(List<LabMessageEvent> messageEvents)
-    {
+    public MqttConfig(List<LabMessageEvent> messageEvents) {
         Map<String, List<LabMessageEvent>> collect = Optional.ofNullable(messageEvents)
                 .filter(a -> a.size() > 0)
                 .orElseGet(Collections::emptyList)
@@ -94,6 +94,7 @@ public class MqttConfig {
                 .collect(Collectors.groupingBy(LabMessageEvent::topic));
         labMessMap.putAll(collect);
     }
+
     /**
      * 连接mqtt配置
      *
@@ -184,7 +185,8 @@ public class MqttConfig {
 
     /**
      * 消费者消息处理
-     *设备心跳
+     * 设备心跳
+     *
      * @return
      */
     @Bean
@@ -198,54 +200,54 @@ public class MqttConfig {
                 String receivedTopic = (String) messageHeaders.get(MqttHeaders.RECEIVED_TOPIC);
 //                logger.info("[通道] - [{}]",receivedTopic);
 //                logger.info("[消息] - [{}]",message.getPayload());
-                String messageStr=message.getPayload().toString();
-                if(receivedTopic.startsWith(devicePrefix)){
-                    if(receivedTopic.contains("788D4C6C6187ABC")){
-                        logger.info("[原始消息] - [{}]",message.getPayload());
+                String messageStr = message.getPayload().toString();
+                if (receivedTopic.startsWith(devicePrefix)) {
+                    if (receivedTopic.contains("788D4C6C6187ABC")) {
+                        logger.info("[原始消息] - [{}]", message.getPayload());
                     }
-                    String topicEnd=receivedTopic.substring(receivedTopic.lastIndexOf("/")+1);
-                    JSONObject jsonObject=JSONObject.parseObject(messageStr);
-                    jsonObject.put("deviceNo",topicEnd);
-                    SensorNewStatusEvent newStatusEvent=new SensorNewStatusEvent(jsonObject);
+                    String topicEnd = receivedTopic.substring(receivedTopic.lastIndexOf("/") + 1);
+                    JSONObject jsonObject = JSONObject.parseObject(messageStr);
+                    jsonObject.put("deviceNo", topicEnd);
+                    SensorNewStatusEvent newStatusEvent = new SensorNewStatusEvent(jsonObject);
                     SpringUtils.getApplicationContext().publishEvent(newStatusEvent);
-                }else if(receivedTopic.startsWith(MqttConstants.SYS_CHEMICAL_ON)){
+                } else if (receivedTopic.startsWith(MqttConstants.TOPIC_SYS_CHEMICAL_ON)) {
                     // 化学品终端设备 心跳消息
-                    String codeNum = receivedTopic.replaceAll(MqttConstants.SYS_CHEMICAL_ON, "");
+                    String codeNum = receivedTopic.replaceAll(MqttConstants.TOPIC_SYS_CHEMICAL_ON, "");
                     logger.info("化学品终端设备心跳编号:" + codeNum);
                     TerminalRouter.routerMap.get("HxpTerminalService").onLine(codeNum);
-                }else if(receivedTopic.startsWith(MqttConstants.SYS_CHEMICAL_OFF)){
+                } else if (receivedTopic.startsWith(MqttConstants.TOPIC_SYS_CHEMICAL_OFF)) {
                     logger.warn(messageHeaders.get(MqttHeaders.ID) + "意外中断!");
-                    String codeNum = receivedTopic.replaceAll(MqttConstants.SYS_CHEMICAL_OFF, "");
+                    String codeNum = receivedTopic.replaceAll(MqttConstants.TOPIC_SYS_CHEMICAL_OFF, "");
                     logger.warn(" 中断设备编码: " + codeNum);
                     TerminalRouter.routerMap.get("HxpTerminalService").offLine(codeNum);
-                }else if(receivedTopic.startsWith(steerPublishPrefix)){
+                } else if (receivedTopic.startsWith(steerPublishPrefix)) {
 //                    messageStr = byte2Hex(message.getPayload().toString().getBytes(StandardCharsets.UTF_8));
                     char[] str = message.getPayload().toString().toCharArray();
                     logger.info("柜锁mqtt消费:" + messageStr);
-                    String replaceMess=messageStr.replace(" ","");
+                    String replaceMess = messageStr.replace(" ", "");
                     //坨机写指令返回数据
-                    if(replaceMess.length()==12){
-                        String command=replaceMess.substring(8,10);
+                    if (replaceMess.length() == 12) {
+                        String command = replaceMess.substring(8, 10);
                         //表示坨机成功
-                        if(HexUtils.hexToInteger(command)==0){
+                        if (HexUtils.hexToInteger(command) == 0) {
                             //TODO 成功逻辑、、
-                            Long lockId = Long.parseLong(HexUtils.hexToInteger(replaceMess.substring(4,6))+ "");
+                            Long lockId = Long.parseLong(HexUtils.hexToInteger(replaceMess.substring(4, 6)) + "");
                             String[] prefix = steerPublishPrefix.split("/");
-                            if(prefix != null && prefix.length > 0){
+                            if (prefix != null && prefix.length > 0) {
                                 // 采集器编号
-                                String relayCode = prefix[prefix.length-1];
+                                String relayCode = prefix[prefix.length - 1];
                                 TerminalRouter.routerMap.get("HxpLockService").onLine(relayCode + "/" + lockId);
                             }
                         }
-                    //坨机读指令返回数据,用于在线监测
-                    }else if(replaceMess.length()==16){
+                        //坨机读指令返回数据,用于在线监测
+                    } else if (replaceMess.length() == 16) {
 //                        String command=replaceMess.substring(4,6);
 //                        Long lockId = Long.parseLong(HexUtils.hexToInteger(command) + "");
 //                        System.out.println("坨机编号");
                         String[] prefix = steerPublishPrefix.split("/");
-                        if(prefix != null && prefix.length > 0){
+                        if (prefix != null && prefix.length > 0) {
                             // 采集器编号
-                            String relayCode = prefix[prefix.length-1];
+                            String relayCode = prefix[prefix.length - 1];
                             TerminalRouter.routerMap.get("HxpLockService").offLine(relayCode);
                         }
 
@@ -254,17 +256,16 @@ public class MqttConfig {
 
                 // TODO
 //                MessageBody messageBody = JSONObject.parseObject(messageStr, MessageBody.class);
-
 //                mqttResHandler.deal(JSONUtil.toBean(msg,com.ffy.mqtt.model.Message.class));
                 List<LabMessageEvent> labMessageEvents = labMessMap.get(receivedTopic);
-                if(CollUtil.isEmpty(labMessageEvents)){
-                    return ;
+                if (CollUtil.isEmpty(labMessageEvents)) {
+                    return;
                 }
             }
         };
     }
 
-    public static String byte2Hex(byte[] bytes){
+    public static String byte2Hex(byte[] bytes) {
         StringBuilder builder = new StringBuilder();
         String temp;
         for (byte aByte : bytes) {

+ 0 - 86
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/constants/MqttConstants.java

@@ -1,86 +0,0 @@
-package com.zd.laboratory.mqtt.constants;
-
-/**
- * mqtt常量类
- */
-public class MqttConstants {
-
-    public static final String MSG="支付成功,货道缺货,已做退款操作!";
-//    //支付成功topic
-//    public static final String PAY_SUCESS_SEND="renming/pay/";
-//    //apk版本发生改变
-//    public static final String APK_VERSION="renming/updateApk/";
-//    //广告发生改变
-//    public static final String ADVICE_="renming/advice/";
-//    //登录
-//    public static final String LOGIN_SCAN="renming/login/";
-//    //设备初始化
-//    public static final String INIT="renming/init/";
-
-
-    //实验室项目配置
-
-    //实验室信息变更通知 topic
-    public static final String LAB_SUB_INFO = "lab/subInfo";
-    //数据大屏数据改变通知 topic
-    public static final String LAB_BIG_VIEW = "lab/bigview";
-    //预警改变通知 topic
-    public static final String LAB_WRAN = "lab/wran";
-    //测点数据topic
-    public static final String LAB_FUNCTION_DATA = "lab/function/data";
-    //一体机消息推送 topic
-    public static final String LAB_ONEPC_SUB_NEWS = "lab/news";
-    //一体机消息推送apk版本升级 topic
-    public static final String LAB_ONEPC_SUB_APKUP = "lab/apkup";
-    //一体机消息推送配置变动 topic
-    public static final String LAB_ONEPC_SUB_UPCONFIG = "lab/upconfig";
-    //硬件状态变化 LAB_HARDWARE_DATA_SUB和LAB_VIDEO的合集
-    public static final String LAB_VIDEO_DATA = "lab/hardware/data";
-
-    //硬件状态变化,实验室为主体 (继电器)
-    public static final String LAB_HARDWARE_DATA_SUB = "lab/hardware/data/sub";
-    //视频、一体机上下线
-    public static final String LAB_VIDEO = "lab/video";
-
-    //硬件统计 好像不需要
-    public static final String LAB_HARDWARE_TOTAL = "lab/hardware/total";
-
-    //传感器
-    public static final String LAB_SENSOR = "lab/sensor";
-
-    // 一体机检查通知
-    public static final String LAB_CHECK = "lab/check";
-
-    // 一体机消息通知
-    public static final String LAB_CONTENT = "lab/content";
-
-    // 一体机轮播图变更通知
-    public static final String LAB_ROTATION = "lab/rotation";
-
-    //逃生指引线路通知
-    public static final String LAB_EXIT_LINE = "lab/exit/line";
-
-    //管控工作通知
-    public static final String LAB_MANAGE_WORK = "manage/work";
-
-    //大屏通知计划更新通知
-    public static final String LAB_BIG_VIEW_PLAN = "lab/bigview/plan";
-
-    //大屏安全检查更新通知
-    public static final String LAB_BIG_VIEW_CHECKAPPLY = "lab/bigview/checkApply";
-
-    //logo同步通知 topic
-    public static final String SYS_LOGO_CONFIG = "sys/logo";
-
-    // 化学品终端心跳 + {设备编号}
-    public static final String SYS_CHEMICAL_ON = "lab/chemical/";
-
-    // 化学品终端离线遗嘱 + {设备编号}
-    public static final String SYS_CHEMICAL_OFF = "lab/off-chemical/";
-    //坨机接收topic
-    public static final String HEAP_RECIVER = "lab/heap/";
-
-    // 柜锁操作成功topic  lab/cabinetLock/{subId}/{lockId}
-    public static final String CABINET_LOCK = "lab/cabinetLock/";
-
-}

+ 2 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/service/hxp/HxpLockService.java

@@ -2,11 +2,11 @@ package com.zd.laboratory.mqtt.service.hxp;
 
 import com.zd.laboratory.mapper.HxpTerminalMapper;
 import com.zd.laboratory.mapper.LabHardwareMapper;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.entiy.MessageBody;
 import com.zd.laboratory.mqtt.enums.SendMode;
 import com.zd.laboratory.mqtt.service.TerminalRouter;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
+import com.zd.model.constant.MqttConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -36,7 +36,7 @@ public class HxpLockService implements TerminalRouter {
                 MessageBody messageBody = new MessageBody();
                 messageBody.setData("柜锁操作成功");
                 logger.info("发送柜锁操作mqtt");
-                commonSend.send(MqttConstants.SYS_LOGO_CONFIG + subId + "/" + lockId, messageBody, SendMode.ONCE);
+                commonSend.send(MqttConstants.TOPIC_SYS_LOGO_CONFIG + subId + "/" + lockId, messageBody, SendMode.ONCE);
             }
         }
     }

+ 19 - 20
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/service/impl/SubMessageSendManager.java

@@ -10,18 +10,17 @@ import com.zd.laboratory.api.vo.SubFunction;
 import com.zd.laboratory.domain.LabHardware;
 import com.zd.laboratory.event.LabMessageEvent;
 import com.zd.laboratory.mqtt.config.MqttConfig;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.entiy.EquipmentStatus;
 import com.zd.laboratory.mqtt.entiy.MessageBody;
 import com.zd.laboratory.mqtt.entiy.SensorStatus;
 import com.zd.laboratory.mqtt.entiy.SubHardwareStatus;
 import com.zd.laboratory.mqtt.enums.BigViewDataType;
 import com.zd.laboratory.mqtt.enums.SendMode;
+import com.zd.model.constant.MqttConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -59,7 +58,7 @@ public class SubMessageSendManager {
         MessageBody messageBody = new MessageBody();
         messageBody.setData(exitLineNotic);
         //仅发送一次
-        commonSend.send(MqttConstants.LAB_EXIT_LINE, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_EXIT_LINE, messageBody, SendMode.ONCE);
     }
 
     /**
@@ -73,7 +72,7 @@ public class SubMessageSendManager {
         MessageBody messageBody = new MessageBody();
         messageBody.setData(bigViewDataType);
         //仅发送一次
-        commonSend.send(MqttConstants.LAB_BIG_VIEW, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_BIG_VIEW, messageBody, SendMode.ONCE);
     }
 
     /**
@@ -89,7 +88,7 @@ public class SubMessageSendManager {
         }
 
         //仅发送一次
-        commonSend.send(MqttConstants.LAB_BIG_VIEW, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_BIG_VIEW, messageBody, SendMode.ONCE);
     }
 
     /**
@@ -121,18 +120,18 @@ public class SubMessageSendManager {
             SubHardwareStatus subHardwareStatus = new SubHardwareStatus();
             subHardwareStatus.setSubId(hardware.getSubjectId());
             subHardwareStatus.setEquipmentStatus(equipmentStatus);
-            String topic = MqttConstants.LAB_VIDEO_DATA + hardware.getSubjectId();
+            String topic = MqttConstants.TOPIC_LAB_VIDEO_DATA + hardware.getSubjectId();
             //发送实验室主题
             commonSend.send(topic, messageBody, SendMode.ONCE);
             //发送以实验室为主体数据
             if (type == 1) {
-                commonSend.send(MqttConstants.LAB_HARDWARE_DATA_SUB, getMessageBody(subHardwareStatus), SendMode.ONCE);
+                commonSend.send(MqttConstants.TOPIC_LAB_HARDWARE_DATA_SUB, getMessageBody(subHardwareStatus), SendMode.ONCE);
             } else {
-                commonSend.send(MqttConstants.LAB_VIDEO, getMessageBody(subHardwareStatus), SendMode.ONCE);
+                commonSend.send(MqttConstants.TOPIC_LAB_VIDEO, getMessageBody(subHardwareStatus), SendMode.ONCE);
             }
         }
         //仅发送一次
-        commonSend.send(MqttConstants.LAB_VIDEO_DATA, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_VIDEO_DATA, messageBody, SendMode.ONCE);
     }
 
 
@@ -143,7 +142,7 @@ public class SubMessageSendManager {
     public void sendNewHardwareUpdate(List<EquipmentStatus> equipmentStatus) {
         MessageBody messageBody = getMessageBody(equipmentStatus);
         //仅发送一次
-        commonSend.send(MqttConstants.LAB_VIDEO_DATA, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_VIDEO_DATA, messageBody, SendMode.ONCE);
     }
 
     /**
@@ -154,7 +153,7 @@ public class SubMessageSendManager {
         if(null!=subjectId){
             MessageBody messageBody = getMessageBody(equipmentStatus);
             //仅发送一次
-            commonSend.send(MqttConstants.LAB_VIDEO_DATA+subjectId, messageBody, SendMode.ONCE);
+            commonSend.send(MqttConstants.TOPIC_LAB_VIDEO_DATA+subjectId, messageBody, SendMode.ONCE);
         }
     }
 
@@ -189,7 +188,7 @@ public class SubMessageSendManager {
         logger.error("@@@@@@@@" + json);
         //发送事件
         //本来使用mqtt接收,因为mqtt 每个客户端接受到都会处理,
-        List<LabMessageEvent> labMessageEvents = mqttConfig.getLabMessMap().get(MqttConstants.LAB_FUNCTION_DATA);
+        List<LabMessageEvent> labMessageEvents = mqttConfig.getLabMessMap().get(MqttConstants.TOPIC_LAB_FUNCTION_DATA);
         if (CollUtil.isNotEmpty(labMessageEvents)) {
             labMessageEvents.forEach(a -> {
                 SpringUtils.getApplicationContext().publishEvent(a.getNewLabMessageEvent(subFunction));
@@ -199,7 +198,7 @@ public class SubMessageSendManager {
         messageBody.setData(subFunction);
         //同时发送到对应实验室
         sendFunctionUpdate(subFunction);
-        commonSend.send(MqttConstants.LAB_FUNCTION_DATA, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_FUNCTION_DATA, messageBody, SendMode.ONCE);
     }
 
     /**
@@ -213,7 +212,7 @@ public class SubMessageSendManager {
         }
         MessageBody messageBody = new MessageBody();
         messageBody.setData(BigViewDataType.SUB_WRAN);
-        commonSend.send(MqttConstants.LAB_WRAN + id, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_WRAN + id, messageBody, SendMode.ONCE);
     }
 
     /**
@@ -223,7 +222,7 @@ public class SubMessageSendManager {
     public void noticeFunctionToOneMachine() {
         MessageBody messageBody = new MessageBody();
         messageBody.setData(BigViewDataType.NOTICE_ONEPC_LOGO);
-        commonSend.send(MqttConstants.SYS_LOGO_CONFIG, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_SYS_LOGO_CONFIG, messageBody, SendMode.ONCE);
     }
 
     /**
@@ -233,7 +232,7 @@ public class SubMessageSendManager {
      * @return
      */
     private String getFunctionSubTopic(Long subId) {
-        return Optional.ofNullable(subId).map(a -> MqttConstants.LAB_FUNCTION_DATA + subId).orElseThrow(() -> new ServiceException("实验室ID不能为空"));
+        return Optional.ofNullable(subId).map(a -> MqttConstants.TOPIC_LAB_FUNCTION_DATA + subId).orElseThrow(() -> new ServiceException("实验室ID不能为空"));
 
     }
 
@@ -257,7 +256,7 @@ public class SubMessageSendManager {
         MessageBody messageBody = new MessageBody();
         messageBody.setData(map);
         //仅发送一次
-        commonSend.send(MqttConstants.LAB_ONEPC_SUB_NEWS + subId, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_ONEPC_SUB_NEWS + subId, messageBody, SendMode.ONCE);
     }
 
     /**
@@ -270,7 +269,7 @@ public class SubMessageSendManager {
         MessageBody messageBody = new MessageBody();
         messageBody.setData(object);
         //仅发送一次
-        commonSend.send(MqttConstants.LAB_ONEPC_SUB_APKUP + object.get("onepcHardwareNum"), messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_ONEPC_SUB_APKUP + object.get("onepcHardwareNum"), messageBody, SendMode.ONCE);
     }
 
 
@@ -284,7 +283,7 @@ public class SubMessageSendManager {
         MessageBody messageBody = new MessageBody();
         messageBody.setData(object);
         //仅发送一次
-        commonSend.send(MqttConstants.LAB_ONEPC_SUB_UPCONFIG + object.get("onepcHardwareNum"), messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_ONEPC_SUB_UPCONFIG + object.get("onepcHardwareNum"), messageBody, SendMode.ONCE);
     }
 
     /**
@@ -296,6 +295,6 @@ public class SubMessageSendManager {
         MessageBody messageBody = new MessageBody();
         messageBody.setData(context);
         //仅发送一次
-        commonSend.send(MqttConstants.LAB_SENSOR, messageBody, SendMode.ONCE);
+        commonSend.send(MqttConstants.TOPIC_LAB_SENSOR, messageBody, SendMode.ONCE);
     }
 }

+ 0 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/test/MqttTest.java

@@ -1,7 +1,6 @@
 package com.zd.laboratory.mqtt.test;
 
 import com.zd.laboratory.config.HardwareFunctionStatusConfig;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
 import org.springframework.boot.context.event.ApplicationStartedEvent;
 import org.springframework.context.ApplicationListener;

+ 67 - 67
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabCheckMachineMsgServiceImpl.java

@@ -14,11 +14,11 @@ import com.zd.laboratory.domain.LabCheckRecord;
 import com.zd.laboratory.domain.LabCheckRecordDetails;
 import com.zd.laboratory.domain.vo.LabCheckMachineMsgVo;
 import com.zd.laboratory.mapper.LabCheckMachineMsgMapper;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.entiy.MessageBody;
 import com.zd.laboratory.mqtt.enums.SendMode;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import com.zd.laboratory.service.*;
+import com.zd.model.constant.MqttConstants;
 import com.zd.model.constant.SecurityConstants;
 import com.zd.model.domain.R;
 import com.zd.model.entity.SysUser;
@@ -28,7 +28,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
 import java.util.List;
 
 /**
@@ -92,7 +91,7 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
             checkMachineMsg.setDetails(labCheckRecordDetailsService.selectLabCheckRecordDetailsList(labCheckRecordDetails));
 
             labCheckRecord = labCheckRecordService.selectLabCheckRecordById(checkMachineMsg.getCheckRecordId());
-            if(labCheckRecord != null){
+            if (labCheckRecord != null) {
                 checkMachineMsg.setCheckRecord(labCheckRecord);
 
             }
@@ -100,7 +99,7 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
 
             String str = "  学院于check_date对你实验室实施了安全管理现场检查,共发现了count个整改项(见整改详情)。请逐一对照、分析原因、采取有效措施实施整改,并于check_date在系统里提交整改证明材料和整改报告。\n" +
                     "  请你实验室务必高度重视,积极采取有效措施,切实加强对实验室的安全管理。同时,要举一反三,对实验室定期开展安全自查与整改,不断提升实验室安全工作水平。";
-            str = str.replaceAll("check_date", checkDateStr).replaceAll("count", checkMachineMsg.getDetails().size()+"");
+            str = str.replaceAll("check_date", checkDateStr).replaceAll("count", checkMachineMsg.getDetails().size() + "");
 
             checkMachineMsg.setNotifyMsg(str);
             checkMachineMsg.setCheckDateStr(checkDateStr);
@@ -112,7 +111,8 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
 
     /**
      * 新增一体机安全检查通知消息
-     * @param type 通知类型 1 一般整改,2 重大整改
+     *
+     * @param type          通知类型 1 一般整改,2 重大整改
      * @param checkRecordId 安全检查ID
      * @return 结果
      */
@@ -122,11 +122,11 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
 
         // 查询配置信息
         LabCheckConfig checkConfigInfo = labCheckConfigService.getCheckConfigInfo();
-        if(checkConfigInfo != null){
+        if (checkConfigInfo != null) {
             boolean senMsg = false;
             LabCheckRecord checkRecord = labCheckRecordService.selectLabCheckRecordById(checkRecordId);
 
-            if(checkRecord == null){
+            if (checkRecord == null) {
                 logger.error("发送消息通知失败,ID无效");
             }
             // 查询实验室负责人
@@ -134,9 +134,9 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
 
             LabCheckMachineMsg labCheckMachineMsg = null;
             LabMessageContent labMessageContent = null;
-            if(type == 1){
+            if (type == 1) {
                 // 1.短信通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getCheckSmsMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getCheckSmsMsg())) {
                     // 查询负责人手机号
 //                    ResultData<SysUser> user = remoteUserService.getUserInfoByUserId(userId, SecurityConstants.INNER);
 //                    if (user.getCode() == 200 && user.getData() != null && StringUtils.isNotBlank(user.getData().getPhonenumber())) {
@@ -144,14 +144,14 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     // 修改为 提交输入的手机号
 
                     if (StringUtils.isNotBlank(checkRecord.getFzrLxfs())) {
-                        AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, new String[]{checkRecord.getFzrLxfs()}, SendTypes.SMS+"", checkConfigInfo.getCheckSmsMsg());
+                        AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, new String[]{checkRecord.getFzrLxfs()}, SendTypes.SMS + "", checkConfigInfo.getCheckSmsMsg());
                         MessageBody messageBody = new MessageBody();
                         messageBody.setData(alarmEntrty);
-                        commonSend.send("alarm/"+checkRecordId,messageBody, SendMode.DISTINCT);
+                        commonSend.send(MqttConstants.TOPIC_ALERT + checkRecordId, messageBody, SendMode.DISTINCT);
                     }
                 }
                 // 2.一体机通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getCheckAioMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getCheckAioMsg())) {
                     labCheckMachineMsg = new LabCheckMachineMsg();
                     labCheckMachineMsg.setCheckRecordId(checkRecordId);
                     labCheckMachineMsg.setType(type);
@@ -161,29 +161,29 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     senMsg = true;
                 }
                 // 3.小程序消息通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getCheckAppMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getCheckAppMsg())) {
                     labMessageContent = new LabMessageContent();
                     labMessageContent.setSendMode(2);
                     labMessageContent.setSendRange(3);
                     labMessageContent.setMessClass(1);
                     labMessageContent.setContent(checkConfigInfo.getCheckAppMsg());
-                    labMessageContent.setUserIds(userId+"");
+                    labMessageContent.setUserIds(userId + "");
 
                 }
-            }else if(type == 2){
+            } else if (type == 2) {
                 // 1.短信通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getRectifySmsMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getRectifySmsMsg())) {
                     // 查询负责人手机号
                     R<SysUser> user = remoteUserService.getUserInfoByUserId(userId, SecurityConstants.INNER);
                     if (user.getCode() == 200 && user.getData() != null && StringUtils.isNotBlank(user.getData().getPhonenumber())) {
-                        AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, new String[]{user.getData().getPhonenumber()}, SendTypes.SMS+"", checkConfigInfo.getRectifySmsMsg());
+                        AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, new String[]{user.getData().getPhonenumber()}, SendTypes.SMS + "", checkConfigInfo.getRectifySmsMsg());
                         MessageBody messageBody = new MessageBody();
                         messageBody.setData(alarmEntrty);
-                        commonSend.send("alarm/"+checkRecordId,messageBody, SendMode.DISTINCT);
+                        commonSend.send(MqttConstants.TOPIC_ALERT + checkRecordId, messageBody, SendMode.DISTINCT);
                     }
                 }
                 // 2.一体机通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getRectifyAioMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getRectifyAioMsg())) {
                     labCheckMachineMsg = new LabCheckMachineMsg();
                     labCheckMachineMsg.setCheckRecordId(checkRecordId);
                     labCheckMachineMsg.setType(type);
@@ -193,28 +193,28 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     senMsg = true;
                 }
                 // 3.小程序消息通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getRectifyAppMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getRectifyAppMsg())) {
                     labMessageContent = new LabMessageContent();
                     labMessageContent.setSendMode(2);
                     labMessageContent.setSendRange(3);
                     labMessageContent.setMessClass(1);
                     labMessageContent.setContent(checkConfigInfo.getCheckAppMsg());
-                    labMessageContent.setUserIds(userId+"");
+                    labMessageContent.setUserIds(userId + "");
                 }
             }
 
-            if(labCheckMachineMsg != null){
+            if (labCheckMachineMsg != null) {
                 labCheckMachineMsg.setStatus(1);
                 labCheckMachineMsgMapper.insertLabCheckMachineMsg(labCheckMachineMsg);
             }
-            if(labMessageContent != null){
+            if (labMessageContent != null) {
                 labMessageContentService.insertLabMessageContent(labMessageContent);
             }
-            if(senMsg){
+            if (senMsg) {
                 MessageBody messageBody = new MessageBody();
                 messageBody.setData(labCheckMachineMsg);
                 //仅发送一次
-                commonSend.send(MqttConstants.LAB_CHECK + checkRecord.getLaboratoryId(), messageBody, SendMode.ONCE);
+                commonSend.send(MqttConstants.TOPIC_LAB_CHECK + checkRecord.getLaboratoryId(), messageBody, SendMode.ONCE);
             }
         }
     }
@@ -228,13 +228,13 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
     public void insertLabCheckMachineJcz(int type, long checkRecordId) {
         // 查询配置信息
         LabCheckConfig checkConfigInfo = labCheckConfigService.getCheckConfigInfo();
-        if(checkConfigInfo != null){
+        if (checkConfigInfo != null) {
             boolean senMsg = false;
             //String count="您有新的整改报告需要审批,请注意查看";//发送的内容
 
             LabCheckRecord checkRecord = labCheckRecordService.selectLabCheckRecordById(checkRecordId);
 
-            if(checkRecord == null){
+            if (checkRecord == null) {
                 logger.error("发送消息通知失败,ID无效");
             }
             // 查询实验室负责人
@@ -242,9 +242,9 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
 
             LabCheckMachineMsg labCheckMachineMsg = null;
             LabMessageContent labMessageContent = null;
-            if(type == 1){
+            if (type == 1) {
                 // 1.短信通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getCheckSmsMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getCheckSmsMsg())) {
                     // 查询负责人手机号
 //                    ResultData<SysUser> user = remoteUserService.getUserInfoByUserId(userId, SecurityConstants.INNER);
 //                    if (user.getCode() == 200 && user.getData() != null && StringUtils.isNotBlank(user.getData().getPhonenumber())) {
@@ -259,7 +259,7 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     }*/
                 }
                 // 2.一体机通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getCheckAioMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getCheckAioMsg())) {
                     labCheckMachineMsg = new LabCheckMachineMsg();
                     labCheckMachineMsg.setCheckRecordId(checkRecordId);
                     labCheckMachineMsg.setType(type);
@@ -269,17 +269,17 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     senMsg = true;
                 }
                 // 3.小程序消息通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getCheckAppMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getCheckAppMsg())) {
                     labMessageContent = new LabMessageContent();
                     labMessageContent.setSendMode(2);
                     labMessageContent.setSendRange(3);
                     labMessageContent.setMessClass(1);
                     labMessageContent.setContent(checkConfigInfo.getCheckAppMsg());
                     //labMessageContent.setContent(count);
-                    labMessageContent.setUserIds(userId+"");
+                    labMessageContent.setUserIds(userId + "");
 
                 }
-            }else if(type == 2){
+            } else if (type == 2) {
                 // 1.短信通知
                 /*if(StringUtils.isNotBlank(checkConfigInfo.getRectifySmsMsg())){
                     // 查询负责人手机号
@@ -292,7 +292,7 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     }
                 }*/
                 // 2.一体机通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getRectifyAioMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getRectifyAioMsg())) {
                     labCheckMachineMsg = new LabCheckMachineMsg();
                     labCheckMachineMsg.setCheckRecordId(checkRecordId);
                     labCheckMachineMsg.setType(type);
@@ -302,36 +302,36 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     senMsg = true;
                 }
                 // 3.小程序消息通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getRectifyAppMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getRectifyAppMsg())) {
                     labMessageContent = new LabMessageContent();
                     labMessageContent.setSendMode(2);
                     labMessageContent.setSendRange(3);
                     labMessageContent.setMessClass(1);
                     labMessageContent.setContent(checkConfigInfo.getRectifyAppMsg());
-                    labMessageContent.setUserIds(userId+"");
+                    labMessageContent.setUserIds(userId + "");
                 }
             }
 
-            if(labCheckMachineMsg != null){
+            if (labCheckMachineMsg != null) {
                 //检查消息通知是否存在
-                LabCheckMachineMsg lmm= new LabCheckMachineMsg();
+                LabCheckMachineMsg lmm = new LabCheckMachineMsg();
                 lmm.setCheckRecordId(checkRecordId);
                 List<LabCheckMachineMsg> list = labCheckMachineMsgMapper.selectLabCheckMachineMsgList(lmm);
-                if(list.size()==0){
+                if (list.size() == 0) {
                     senMsg = true;
                     labCheckMachineMsg.setStatus(1);
                     labCheckMachineMsgMapper.insertLabCheckMachineMsg(labCheckMachineMsg);
                 }
 
             }
-            if(labMessageContent != null){
+            if (labMessageContent != null) {
                 labMessageContentService.insertLabMessageContent(labMessageContent);
             }
-            if(senMsg){
+            if (senMsg) {
                 MessageBody messageBody = new MessageBody();
                 messageBody.setData(labCheckMachineMsg);
                 //仅发送一次
-                commonSend.send(MqttConstants.LAB_CHECK + checkRecord.getLaboratoryId(), messageBody, SendMode.ONCE);
+                commonSend.send(MqttConstants.TOPIC_LAB_CHECK + checkRecord.getLaboratoryId(), messageBody, SendMode.ONCE);
             }
         }
     }
@@ -348,19 +348,19 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
     public void insertLabCheckMachineTjz(int type, long checkRecordId, int status) {
         // 查询配置信息
         LabCheckConfig checkConfigInfo = labCheckConfigService.getCheckConfigInfo();
-        if(checkConfigInfo != null){
+        if (checkConfigInfo != null) {
             boolean senMsg = false;
-            String count=null;//发送的内容
-            if(status==1){//提交时
+            String count = null;//发送的内容
+            if (status == 1) {//提交时
 
-            }else if(status==2){
-                count="您的整改报告未能通过审批,请注意查看";
-            }else if(status==4){
-                count="您的整改报告通过了审批,请注意查看";
+            } else if (status == 2) {
+                count = "您的整改报告未能通过审批,请注意查看";
+            } else if (status == 4) {
+                count = "您的整改报告通过了审批,请注意查看";
             }
             LabCheckRecord checkRecord = labCheckRecordService.selectLabCheckRecordById(checkRecordId);
 
-            if(checkRecord == null){
+            if (checkRecord == null) {
                 logger.error("发送消息通知失败,ID无效");
             }
             // 查询实验室负责人
@@ -368,9 +368,9 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
 
             LabCheckMachineMsg labCheckMachineMsg = null;
             LabMessageContent labMessageContent = null;
-            if(type == 1){
+            if (type == 1) {
                 // 1.短信通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getCheckSmsMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getCheckSmsMsg())) {
                     // 查询负责人手机号
 //                    ResultData<SysUser> user = remoteUserService.getUserInfoByUserId(userId, SecurityConstants.INNER);
 //                    if (user.getCode() == 200 && user.getData() != null && StringUtils.isNotBlank(user.getData().getPhonenumber())) {
@@ -385,7 +385,7 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     }*/
                 }
                 // 2.一体机通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getCheckAioMsg()) && status==1){
+                if (StringUtils.isNotBlank(checkConfigInfo.getCheckAioMsg()) && status == 1) {
                     labCheckMachineMsg = new LabCheckMachineMsg();
                     labCheckMachineMsg.setCheckRecordId(checkRecordId);
                     labCheckMachineMsg.setType(type);
@@ -396,17 +396,17 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     senMsg = true;
                 }
                 // 3.小程序消息通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getCheckAppMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getCheckAppMsg())) {
                     labMessageContent = new LabMessageContent();
                     labMessageContent.setSendMode(2);
                     labMessageContent.setSendRange(3);
                     labMessageContent.setMessClass(1);
                     //labMessageContent.setContent(checkConfigInfo.getCheckAppMsg());
-                    labMessageContent.setContent(count!=null?count:checkConfigInfo.getCheckAppMsg());
-                    labMessageContent.setUserIds(userId+"");
+                    labMessageContent.setContent(count != null ? count : checkConfigInfo.getCheckAppMsg());
+                    labMessageContent.setUserIds(userId + "");
 
                 }
-            }else if(type == 2){
+            } else if (type == 2) {
                 // 1.短信通知
                 /*if(StringUtils.isNotBlank(checkConfigInfo.getRectifySmsMsg())){
                     // 查询负责人手机号
@@ -419,7 +419,7 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     }
                 }*/
                 // 2.一体机通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getRectifyAioMsg()) && status==1){
+                if (StringUtils.isNotBlank(checkConfigInfo.getRectifyAioMsg()) && status == 1) {
                     labCheckMachineMsg = new LabCheckMachineMsg();
                     labCheckMachineMsg.setCheckRecordId(checkRecordId);
                     labCheckMachineMsg.setType(type);
@@ -430,36 +430,36 @@ public class LabCheckMachineMsgServiceImpl implements ILabCheckMachineMsgService
                     senMsg = true;
                 }
                 // 3.小程序消息通知
-                if(StringUtils.isNotBlank(checkConfigInfo.getRectifyAppMsg())){
+                if (StringUtils.isNotBlank(checkConfigInfo.getRectifyAppMsg())) {
                     labMessageContent = new LabMessageContent();
                     labMessageContent.setSendMode(2);
                     labMessageContent.setSendRange(3);
                     labMessageContent.setMessClass(1);
                     //labMessageContent.setContent(checkConfigInfo.getCheckAppMsg());
-                    labMessageContent.setContent(count!=null?count:checkConfigInfo.getRectifyAppMsg());
-                    labMessageContent.setUserIds(userId+"");
+                    labMessageContent.setContent(count != null ? count : checkConfigInfo.getRectifyAppMsg());
+                    labMessageContent.setUserIds(userId + "");
                 }
             }
 
-            if(labCheckMachineMsg != null && status==1){
+            if (labCheckMachineMsg != null && status == 1) {
                 //检查消息通知是否存在
-                LabCheckMachineMsg lmm= new LabCheckMachineMsg();
+                LabCheckMachineMsg lmm = new LabCheckMachineMsg();
                 lmm.setCheckRecordId(checkRecordId);
                 List<LabCheckMachineMsg> list = labCheckMachineMsgMapper.selectLabCheckMachineMsgList(lmm);
-                if(list.size()==0){
+                if (list.size() == 0) {
                     senMsg = true;
                     labCheckMachineMsg.setStatus(1);
                     labCheckMachineMsgMapper.insertLabCheckMachineMsg(labCheckMachineMsg);
                 }
             }
-            if(labMessageContent != null){
+            if (labMessageContent != null) {
                 labMessageContentService.insertLabMessageContent(labMessageContent);
             }
-            if(senMsg){
+            if (senMsg) {
                 MessageBody messageBody = new MessageBody();
                 messageBody.setData(labCheckMachineMsg);
                 //仅发送一次
-                commonSend.send(MqttConstants.LAB_CHECK + checkRecord.getLaboratoryId(), messageBody, SendMode.ONCE);
+                commonSend.send(MqttConstants.TOPIC_LAB_CHECK + checkRecord.getLaboratoryId(), messageBody, SendMode.ONCE);
             }
         }
     }

+ 2 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabCheckRecordReleaseServiceImpl.java

@@ -3,6 +3,7 @@ package com.zd.laboratory.service.impl;
 import java.util.Date;
 import java.util.List;
 
+import com.zd.model.constant.MqttConstants;
 import com.zd.model.domain.per.PerPrefix;
 import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.annotation.DataScope;
@@ -11,7 +12,6 @@ import com.zd.common.core.utils.SaveUtil;
 
 import com.zd.laboratory.domain.LabCheckRecord;
 import com.zd.laboratory.domain.vo.LabCheckRecordReleaseVO;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.entiy.MessageBody;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import com.zd.laboratory.service.ILabCheckMachineMsgService;
@@ -112,7 +112,7 @@ public class LabCheckRecordReleaseServiceImpl implements ILabCheckRecordReleaseS
 
         if(id>0){
             //3 有新的发布信息
-            commonSend.send(MqttConstants.LAB_BIG_VIEW_CHECKAPPLY, new MessageBody("有新的检查发布。", 3));
+            commonSend.send(MqttConstants.TOPIC_LAB_BIG_VIEW_CHECKAPPLY, new MessageBody("有新的检查发布。", 3));
         }
         return id;
     }

+ 2 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabCheckRecordServiceImpl.java

@@ -15,13 +15,13 @@ import com.zd.laboratory.domain.vo.LabCheckRecordVO;
 import com.zd.laboratory.domain.vo.LabSecurityApplyVO;
 import com.zd.laboratory.domain.vo.LabSubjectVO;
 import com.zd.laboratory.mapper.*;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.entiy.MessageBody;
 import com.zd.laboratory.mqtt.enums.SendMode;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import com.zd.laboratory.service.ILabCheckRecordReleaseService;
 import com.zd.laboratory.service.ILabCheckRecordService;
 import com.zd.laboratory.service.ILabMessageContentService;
+import com.zd.model.constant.MqttConstants;
 import com.zd.model.domain.per.PerPrefix;
 import com.zd.model.entity.SysUser;
 import org.slf4j.Logger;
@@ -319,7 +319,7 @@ public class LabCheckRecordServiceImpl implements ILabCheckRecordService
             // 不确定前端传值是否有实验室ID 故重新查询保证
             LabCheckRecord checkRecord = labCheckRecordMapper.selectLabCheckRecordById(labCheckRecordVo.getId());
             //仅发送一次
-            commonSend.send(MqttConstants.LAB_CHECK + checkRecord.getLaboratoryId(), messageBody, SendMode.ONCE);
+            commonSend.send(MqttConstants.TOPIC_LAB_CHECK + checkRecord.getLaboratoryId(), messageBody, SendMode.ONCE);
         }
 
         return id;

+ 2 - 2
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabContentMachineMsgServiceImpl.java

@@ -5,9 +5,9 @@ import com.zd.common.core.utils.SecurityUtils;
 import com.zd.laboratory.api.entity.LabMessageContent;
 import com.zd.laboratory.domain.LabContentMachineMsg;
 import com.zd.laboratory.mapper.LabContentMachineMsgMapper;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import com.zd.laboratory.service.ILabContentMachineMsgService;
+import com.zd.model.constant.MqttConstants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -119,7 +119,7 @@ public class LabContentMachineMsgServiceImpl implements ILabContentMachineMsgSer
             insertLabContentMachineMsg(labContentMachineMsg);
 
             // 生成一条通知一个,此处不应该有重复的实验室ID
-            commonSend.send(MqttConstants.LAB_CONTENT + subId, "收到一条新的消息通知!");
+            commonSend.send(MqttConstants.TOPIC_LAB_CONTENT + subId, "收到一条新的消息通知!");
             logger.info("发送实验室一体机消息通知:" + subId);
         }
 

+ 103 - 104
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabGradeManageRecordServiceImpl.java

@@ -17,12 +17,12 @@ import com.zd.laboratory.domain.LabGradeManageRuleUser;
 import com.zd.laboratory.domain.LabMessageDynamic;
 import com.zd.laboratory.domain.vo.LabManageWorkChartVo;
 import com.zd.laboratory.mapper.*;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.entiy.MessageBody;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import com.zd.laboratory.service.ILabGradeManageRecordService;
 import com.zd.laboratory.service.ILabSubjectService;
 import com.zd.laboratory.utils.word.WordUtils;
+import com.zd.model.constant.MqttConstants;
 import com.zd.model.domain.R;
 import com.zd.model.domain.per.PerPrefix;
 import com.zd.model.entity.SysDept;
@@ -34,7 +34,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-
 import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.*;
@@ -90,37 +89,36 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
 
         labGradeManageRecord.setDetail(labGradeManageRecordDetailMapper.selectLabGradeManageRecordDetailByRecordId(id));
         // 列出规则制定的所有人员- 沙士比鸭
-        if(labGradeManageRecord.getStatus() == 0){
+        if (labGradeManageRecord.getStatus() == 0) {
             LabGradeManageRuleUser ruleUser = labGradeManageRuleUserMapper.selectLabGradeManageRuleUserById(labGradeManageRecord.getRuleUserId());
-            if(StringUtils.isNull(ruleUser)){
-                throw new ServiceException("管控工作已失效或被删除!",504);
+            if (StringUtils.isNull(ruleUser)) {
+                throw new ServiceException("管控工作已失效或被删除!", 504);
             }
             List<Long> subIds = labGradeManageMapper.selectSubIdsByManageId(ruleUser.getGradeManageId());
 
             List<Long> users = new ArrayList<>();
-            if(ruleUser.getType() == 3){
-                users.addAll( Arrays.asList(ruleUser.getUserIds() .split(",")).stream().map(s -> (Long.parseLong(s.trim()))).collect(Collectors.toList()));
-            }else if(ruleUser.getType() == 1){
+            if (ruleUser.getType() == 3) {
+                users.addAll(Arrays.asList(ruleUser.getUserIds().split(",")).stream().map(s -> (Long.parseLong(s.trim()))).collect(Collectors.toList()));
+            } else if (ruleUser.getType() == 1) {
                 List<Map<String, Long>> datas = labSubjectMapper.selectLabAdminByIds(subIds);
                 datas.forEach(d -> {
                     users.add(d.get("adminId"));
                 });
-            }else if(ruleUser.getType() == 2){
+            } else if (ruleUser.getType() == 2) {
                 List<Map<String, Long>> datas = labSubjectAccessRecordMapper.selectJoinUsers(subIds, ruleUser.getUpdateTime());
                 datas.forEach(d -> {
                     users.add(d.get("userId"));
                 });
-            }else if(ruleUser.getType() == 4){
+            } else if (ruleUser.getType() == 4) {
                 List<Map<String, Long>> datas = labSecurityApplyMapper.selectApplyListBySubIds(subIds);
                 datas.forEach(d -> {
                     users.add(d.get("userId"));
                 });
             }
-            if(users.size() > 0){
+            if (users.size() > 0) {
                 labGradeManageRecord.setAllUserName(labGradeManageRuleUserMapper.selectUserNameByUserIds(users));
             }
         }
-
         return labGradeManageRecord;
     }
 
@@ -131,7 +129,7 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
      * @return 管控执行记录
      */
     @Override
-    @DataScope(deptAlias = "d" , userAlias = "u" , permi = PerPrefix.LABORATORY_GRADEMANAGERECORD)
+    @DataScope(deptAlias = "d", userAlias = "u", permi = PerPrefix.LABORATORY_GRADEMANAGERECORD)
     public List<LabGradeManageRecord> selectLabGradeManageRecordList(LabGradeManageRecord labGradeManageRecord) {
         return labGradeManageRecordMapper.selectLabGradeManageRecordList(labGradeManageRecord);
     }
@@ -174,11 +172,10 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
         LabGradeManageRecord record = new LabGradeManageRecord();
         record.setJoinUserId(SecurityUtils.getUserId());
         record.setStatus(0);
-        if(labGradeManageRecordMapper.selectLabGradeManageRecordList(record).size() == 0){
+        if (labGradeManageRecordMapper.selectLabGradeManageRecordList(record).size() == 0) {
             // 1 新工作通知, 2 已过期工作通知, 21 关闭已过期通知
-            commonSend.send(MqttConstants.LAB_MANAGE_WORK+SecurityUtils.getUserId(), new MessageBody("您已过期的管控工作已全部完成。", 21));
+            commonSend.send(MqttConstants.TOPIC_LAB_MANAGE_WORK + SecurityUtils.getUserId(), new MessageBody("您已过期的管控工作已全部完成。", 21));
         }
-
         return labGradeManageRecord;
     }
 
@@ -229,7 +226,7 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
 
         List<Long> ruleIds = manageRuleUserList.stream().map(LabGradeManageRuleUser::getGradeManageRuleId).collect(Collectors.toList());
 
-        if(CollectionUtils.isNotEmpty(ruleIds)){
+        if (CollectionUtils.isNotEmpty(ruleIds)) {
 
             List<LabGradeManageRecord> insertRecordList = new ArrayList<>();
 
@@ -245,15 +242,15 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                 // 2.7 获取实验室方式变动- 此处要修改
                 //LabGradeManage manage = labGradeManageMapper.selectLabGradeManageById(ruleUser.getGradeManageId());
                 List<Long> subIds = labGradeManageMapper.selectSubIdsByManageId(ruleUser.getGradeManageId());
-                if(subIds.size() == 0){
+                if (subIds.size() == 0) {
                     continue;
                 }
                 for (Long subId : subIds) {
-                    if(ruleUser.getIsAll() == 0){
+                    if (ruleUser.getIsAll() == 0) {
                         queryRecord.setSubId(subId);
                         // 单人执行,有一个人执行,则其他人都不生成过期数据
                         executedCount = labGradeManageRecordMapper.selectCountByUserRecord(queryRecord);
-                        if(executedCount > 0){
+                        if (executedCount > 0) {
                             continue;
                         }
                     }
@@ -262,8 +259,8 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                 //List<Long> users = new ArrayList<>();
 
 //                String userPosition = null;
-                if(ruleUser.getType() == 3){
-                    List<Long> users = Arrays.asList(ruleUser.getUserIds() .split(",")).stream().map(s -> (Long.parseLong(s.trim()))).collect(Collectors.toList());
+                if (ruleUser.getType() == 3) {
+                    List<Long> users = Arrays.asList(ruleUser.getUserIds().split(",")).stream().map(s -> (Long.parseLong(s.trim()))).collect(Collectors.toList());
 
                     // 多个实验室则需要生成多条工作 - 过期未执行记录
                     for (Long subId : subIds) {
@@ -296,14 +293,14 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
 //                            insertRecordList.add(labGradeManageRecord);
                         }
                     }
-                }else if(ruleUser.getType() == 1){
+                } else if (ruleUser.getType() == 1) {
                     // 查询实验室负责人
                     // users = labSubjectMapper.selectAdminIds(subIds);
                     List<Map<String, Long>> datas = labSubjectMapper.selectLabAdminByIds(subIds);
                     subIds.forEach(s -> {
                         datas.forEach(d -> {
                             // adminId, id as subId
-                            if(s.equals(d.get("subId")) && d.get("adminId") != null){
+                            if (s.equals(d.get("subId")) && d.get("adminId") != null) {
                                 putUserData(ruleUser, d.get("subId"), d.get("adminId"), insertRecordList, "实验室负责人");
 //                                LabGradeManageRecord labGradeManageRecord = new LabGradeManageRecord();
 //                                labGradeManageRecord.setCreateTime(DateUtils.getNowDate());
@@ -325,14 +322,14 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                             }
                         });
                     });
-                }else if(ruleUser.getType() == 2){
+                } else if (ruleUser.getType() == 2) {
                     // 当天进入实验室人员
                     List<Map<String, Long>> datas = labSubjectAccessRecordMapper.selectJoinUsers(subIds, ruleUser.getUpdateTime());
                     subIds.forEach(s -> {
                         datas.forEach(d -> {
                             //  userId, subject_id as subId
-                            if(s.equals(d.get("subId")) && d.get("userId") != null){
-                                putUserData(ruleUser,d.get("subId"), d.get("userId"), insertRecordList, "当天进入实验室人员");
+                            if (s.equals(d.get("subId")) && d.get("userId") != null) {
+                                putUserData(ruleUser, d.get("subId"), d.get("userId"), insertRecordList, "当天进入实验室人员");
 //                                LabGradeManageRecord labGradeManageRecord = new LabGradeManageRecord();
 //                                labGradeManageRecord.setCreateTime(DateUtils.getNowDate());
 //                                labGradeManageRecord.setUserId(-1L);
@@ -353,13 +350,13 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                             }
                         });
                     });
-                }else if(ruleUser.getType() == 4){
+                } else if (ruleUser.getType() == 4) {
                     // 实验室准入人员
                     List<Map<String, Long>> datas = labSecurityApplyMapper.selectApplyListBySubIds(subIds);
                     subIds.forEach(s -> {
                         datas.forEach(d -> {
                             //  userId, subject_id as subId
-                            if(s.equals(d.get("subId")) && d.get("userId") != null){
+                            if (s.equals(d.get("subId")) && d.get("userId") != null) {
                                 putUserData(ruleUser, d.get("subId"), d.get("userId"), insertRecordList, "实验室准入人员");
 //                                LabGradeManageRecord labGradeManageRecord = new LabGradeManageRecord();
 //                                labGradeManageRecord.setCreateTime(DateUtils.getNowDate());
@@ -381,7 +378,7 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                             }
                         });
                     });
-                }else {
+                } else {
                     logger.error("workArrange: 分级管控周期工作编排数据异常, {}", JSONUtil.toJsonStr(ruleUser));
                     continue;
                 }
@@ -397,7 +394,7 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                 }*/
             }
 
-            if(insertRecordList.size() > 0){
+            if (insertRecordList.size() > 0) {
                 // 批量存储
                 labGradeManageRecordMapper.insertBatch(insertRecordList);
             }
@@ -421,14 +418,14 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
     }
 
     private void putUserData(LabGradeManageRuleUser ruleUser, @NotNull Long subId, @NotNull Long userId,
-                             List<LabGradeManageRecord> insertRecordList, String userPosition){
+                             List<LabGradeManageRecord> insertRecordList, String userPosition) {
         LabGradeManageRecord queryRecord = new LabGradeManageRecord();
         queryRecord.setRuleId(ruleUser.getGradeManageRuleId());
         queryRecord.setRuleUserId(ruleUser.getId());
         queryRecord.setCycleCount(ruleUser.getCycleCount());
         queryRecord.setSubId(subId);
         queryRecord.setJoinUserId(userId);
-        if(labGradeManageRecordMapper.selectCountByUserRecord(queryRecord) > 0){
+        if (labGradeManageRecordMapper.selectCountByUserRecord(queryRecord) > 0) {
             return;
         }
         LabGradeManageRecord labGradeManageRecord = new LabGradeManageRecord();
@@ -492,9 +489,9 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
             messageUsers.add(labMessageUser);
         });
 
-        if(manageRecords.size() > 0){
+        if (manageRecords.size() > 0) {
             labMessageUserMapper.insertLabMessageUserBatch(messageUsers);
-        }else {
+        } else {
             throw new ServiceException("消息通知未匹配到关联人员,事务回滚");
         }
     }
@@ -530,13 +527,13 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
 
             // 查询哪些人需要通知
             List<Long> subIds = labGradeManageMapper.selectSubIdsByManageId(ruleUser.getGradeManageId());
-            if(ruleUser.getType() == 3){
-                List<Long> users = Arrays.asList(ruleUser.getUserIds() .split(",")).stream().map(s -> (Long.parseLong(s.trim()))).collect(Collectors.toList());
+            if (ruleUser.getType() == 3) {
+                List<Long> users = Arrays.asList(ruleUser.getUserIds().split(",")).stream().map(s -> (Long.parseLong(s.trim()))).collect(Collectors.toList());
 
                 subIds.forEach(s -> {
                     users.forEach(u -> {
                         int count = labGradeManageRecordMapper.selectExecutionsByUserId(u, 2, s, ruleUser.getId());
-                        if(count == 0){
+                        if (count == 0) {
                             LabMessageUser labMessageUser = new LabMessageUser();
                             labMessageUser.setJoinUserId(u);
                             labMessageUser.setCreateTime(DateUtils.getNowDate());
@@ -549,14 +546,14 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                         }
                     });
                 });
-            }else if(ruleUser.getType() == 1){
+            } else if (ruleUser.getType() == 1) {
                 // 查询实验室负责人
                 List<Map<String, Long>> datas = labSubjectMapper.selectLabAdminByIds(subIds);
                 subIds.forEach(s -> {
                     datas.forEach(d -> {
-                        if(s.equals(d.get("subId")) && d.get("adminId") != null){
+                        if (s.equals(d.get("subId")) && d.get("adminId") != null) {
                             int count = labGradeManageRecordMapper.selectExecutionsByUserId(d.get("adminId"), 2, d.get("subId"), ruleUser.getId());
-                            if(count == 0){
+                            if (count == 0) {
                                 LabMessageUser labMessageUser = new LabMessageUser();
                                 labMessageUser.setJoinUserId(d.get("adminId"));
                                 labMessageUser.setCreateTime(DateUtils.getNowDate());
@@ -569,14 +566,14 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                         }
                     });
                 });
-            }else if(ruleUser.getType() == 2){
+            } else if (ruleUser.getType() == 2) {
                 // 当天进入实验室人员
                 List<Map<String, Long>> datas = labSubjectAccessRecordMapper.selectJoinUsers(subIds, ruleUser.getUpdateTime());
                 subIds.forEach(s -> {
                     datas.forEach(d -> {
-                        if(s.equals(d.get("subId")) && d.get("userId") != null){
+                        if (s.equals(d.get("subId")) && d.get("userId") != null) {
                             int count = labGradeManageRecordMapper.selectExecutionsByUserId(d.get("userId"), 2, s, ruleUser.getId());
-                            if(count == 0){
+                            if (count == 0) {
                                 LabMessageUser labMessageUser = new LabMessageUser();
                                 labMessageUser.setJoinUserId(d.get("userId"));
                                 labMessageUser.setCreateTime(DateUtils.getNowDate());
@@ -589,14 +586,14 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                         }
                     });
                 });
-            }else if(ruleUser.getType() == 4){
+            } else if (ruleUser.getType() == 4) {
                 // 实验室准入人员
                 List<Map<String, Long>> datas = labSecurityApplyMapper.selectApplyListBySubIds(subIds);
                 subIds.forEach(s -> {
                     datas.forEach(d -> {
-                        if(s.equals(d.get("subId")) && d.get("userId") != null){
+                        if (s.equals(d.get("subId")) && d.get("userId") != null) {
                             int count = labGradeManageRecordMapper.selectExecutionsByUserId(d.get("userId"), 2, s, ruleUser.getId());
-                            if(count == 0){
+                            if (count == 0) {
                                 LabMessageUser labMessageUser = new LabMessageUser();
                                 labMessageUser.setJoinUserId(d.get("userId"));
                                 labMessageUser.setCreateTime(DateUtils.getNowDate());
@@ -612,48 +609,48 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
             }
         }
 
-        if(messageUsers.size() > 0){
+        if (messageUsers.size() > 0) {
             labMessageUserMapper.insertLabMessageUserBatch(messageUsers);
-        }else {
+        } else {
             throw new ServiceException("消息通知未匹配到关联人员,事务回滚");
         }
     }
 
     /**
-     *  分级管控通知类型(执行人-可跳转处理)
-     *  2.执行通知:周,每周五早8点
-     *  3.执行周期:月,提前三天早8点
-     *  4.执行周期:年,季度,半年,提前一周早8点,提前三天早8点 各一次
+     * 分级管控通知类型(执行人-可跳转处理)
+     * 2.执行通知:周,每周五早8点
+     * 3.执行周期:月,提前三天早8点
+     * 4.执行周期:年,季度,半年,提前一周早8点,提前三天早8点 各一次
      */
     @Override
     public void workExecute() {
 
-        if(DateUtil.dayOfWeek(DateUtil.date()) == 6){
+        if (DateUtil.dayOfWeek(DateUtil.date()) == 6) {
             workExecuteByDay("一周");
         }
 
-        if(DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 2){
+        if (DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 2) {
             workExecuteByDay("一月");
         }
 
-        if(DateUtil.month(DateUtil.endOfQuarter(DateUtil.date())) == DateUtil.month(DateUtil.date()) && (
+        if (DateUtil.month(DateUtil.endOfQuarter(DateUtil.date())) == DateUtil.month(DateUtil.date()) && (
                 DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 2 ||
-                DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 6
-        )){
+                        DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 6
+        )) {
             workExecuteByDay("季度");
         }
 
-        if((DateUtil.thisMonth() == 6 || DateUtil.thisMonth() == 12) && (
+        if ((DateUtil.thisMonth() == 6 || DateUtil.thisMonth() == 12) && (
                 DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 2 ||
-                DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 6
-        )){
+                        DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 6
+        )) {
             workExecuteByDay("半年");
         }
 
-        if(DateUtil.thisMonth() == 12 && (
+        if (DateUtil.thisMonth() == 12 && (
                 DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 2 ||
-                DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 6
-        )){
+                        DateUtil.dayOfMonth(DateUtil.endOfMonth(DateUtil.date())) - DateUtil.dayOfMonth(DateUtil.date()) == 6
+        )) {
             workExecuteByDay("一年");
         }
 
@@ -666,13 +663,13 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
     public void sendManageMsgBySiginUser(Long userId, Long subId) {
 
         try {
-            logger.info("进入实验室人员进行消息通知执行..." + subId + " : "+ userId);
+            logger.info("进入实验室人员进行消息通知执行..." + subId + " : " + userId);
             List<LabGradeManageRuleUser> manageRuleUserList = labGradeManageRuleUserMapper.selectType2ByAdminSubId(subId);
-            if(manageRuleUserList.size() > 0){
-                commonSend.send(MqttConstants.LAB_MANAGE_WORK+userId, new MessageBody("您当前有" + manageRuleUserList.size() + "条管控工作需完成,请点击查看详情。", 1));
+            if (manageRuleUserList.size() > 0) {
+                commonSend.send(MqttConstants.TOPIC_LAB_MANAGE_WORK + userId, new MessageBody("您当前有" + manageRuleUserList.size() + "条管控工作需完成,请点击查看详情。", 1));
                 logger.info("已执行发送...");
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             logger.error("进入实验室人员管控工作通知异常,{}", e.getMessage());
         }
     }
@@ -683,25 +680,25 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
     @Override
     public Map<String, Object> queryManageWorkInfo(LabManageWorkChartVo labManageWorkChartVo) {
         labManageWorkChartVo.setStartTime(DateUtil.beginOfWeek(DateUtils.getNowDate()));
-        labManageWorkChartVo.setEndTime( DateUtil.offsetDay(labManageWorkChartVo.getStartTime(), 4));
+        labManageWorkChartVo.setEndTime(DateUtil.offsetDay(labManageWorkChartVo.getStartTime(), 4));
 
         labManageWorkChartVo.setTitle(
                 DateUtil.format(labManageWorkChartVo.getStartTime(), dateFormat) + "至" + DateUtil.format(labManageWorkChartVo.getEndTime(), dateFormat) +
-                "分级管控工作");
+                        "分级管控工作");
         Map<String, Object> map = new HashMap<>();
         map.put("title", labManageWorkChartVo.getTitle());
 
         List<LabManageWorkChartVo> list;
 
-        if(labManageWorkChartVo.getType() == 1){
+        if (labManageWorkChartVo.getType() == 1) {
             list = new ArrayList<>();
             R r = remoteDeptService.getDeptList(new SysDept());
             List<SysDept> deptList = (List<SysDept>) r.getData();
 
-            LabManageWorkChartVo workChartVo ;
-            if(deptList.size() > 0){
+            LabManageWorkChartVo workChartVo;
+            if (deptList.size() > 0) {
                 for (SysDept dept : deptList) {
-                    if(labManageWorkChartVo.getDeptId() == null || (labManageWorkChartVo.getDeptId() != null && dept.getDeptId().equals(labManageWorkChartVo.getDeptId()))){
+                    if (labManageWorkChartVo.getDeptId() == null || (labManageWorkChartVo.getDeptId() != null && dept.getDeptId().equals(labManageWorkChartVo.getDeptId()))) {
                         workChartVo = new LabManageWorkChartVo();
 
                         workChartVo.setDeptId(dept.getDeptId());
@@ -719,7 +716,7 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                     }
                 }
             }
-        }else {
+        } else {
             list = labGradeManageRecordMapper.queryManageWorkChartDetailsType2(labManageWorkChartVo);
             for (LabManageWorkChartVo workChartVo : list) {
 
@@ -743,6 +740,7 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
 
     /**
      * 分级管控统计 柱状图2.4需求
+     *
      * @return
      */
     @Override
@@ -782,54 +780,54 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
 
             chart.setParams(labManageWorkChartVo.getParams());
 
-            chart.setCurrentDateStr( DateUtil.format(chart.getCurrentDate(), dateFormat));
-            chart.setOfWeek("星期" + WordUtils.CN_NUM[(DateUtil.dayOfWeek(chart.getCurrentDate()) -2)]);
+            chart.setCurrentDateStr(DateUtil.format(chart.getCurrentDate(), dateFormat));
+            chart.setOfWeek("星期" + WordUtils.CN_NUM[(DateUtil.dayOfWeek(chart.getCurrentDate()) - 2)]);
 
 
             int compare = DateUtil.compare(chart.getCurrentDate(), now);
             for (LabManageWorkChartVo date : dates) {
-                if(i == 0){
-                    if(date.getCurrentDate().equals(chart.getCurrentDate())){
-                        if("一天".equals(date.getCycle())){
+                if (i == 0) {
+                    if (date.getCurrentDate().equals(chart.getCurrentDate())) {
+                        if ("一天".equals(date.getCycle())) {
                             chart.setPlanNum(date.getPlanNum());
                         }
                         break;
                     }
 
-                }else if(i == 1){
-                    if(date.getCurrentDate().equals(chart.getCurrentDate())){
-                        if("一天".equals(date.getCycle())){
-                            chart.setPlanNum(date.getPlanNum() + list.get(i-1).getPlanNum());
+                } else if (i == 1) {
+                    if (date.getCurrentDate().equals(chart.getCurrentDate())) {
+                        if ("一天".equals(date.getCycle())) {
+                            chart.setPlanNum(date.getPlanNum() + list.get(i - 1).getPlanNum());
                         }
                         break;
                     }
-                }else if(i == 2){
-                    if(date.getCurrentDate().equals(chart.getCurrentDate())){
-                        if("一天".equals(date.getCycle())){
-                            chart.setPlanNum(date.getPlanNum() + list.get(i-1).getPlanNum());
+                } else if (i == 2) {
+                    if (date.getCurrentDate().equals(chart.getCurrentDate())) {
+                        if ("一天".equals(date.getCycle())) {
+                            chart.setPlanNum(date.getPlanNum() + list.get(i - 1).getPlanNum());
                         }
                         break;
                     }
-                }else if(i == 3){
-                    if("一天".equals(date.getCycle()) && date.getCurrentDate().equals(chart.getCurrentDate())){
-                        chart.setPlanNum(date.getPlanNum() + list.get(i-1).getPlanNum());
+                } else if (i == 3) {
+                    if ("一天".equals(date.getCycle()) && date.getCurrentDate().equals(chart.getCurrentDate())) {
+                        chart.setPlanNum(date.getPlanNum() + list.get(i - 1).getPlanNum());
                     }
                     break;
-                }else if(i == 4){
-                    if(date.getCurrentDate().equals(chart.getCurrentDate())){
-                        if("一天".equals(date.getCycle())){
-                            chart.setPlanNum(date.getPlanNum() + list.get(i-1).getPlanNum());
+                } else if (i == 4) {
+                    if (date.getCurrentDate().equals(chart.getCurrentDate())) {
+                        if ("一天".equals(date.getCycle())) {
+                            chart.setPlanNum(date.getPlanNum() + list.get(i - 1).getPlanNum());
                         }
                         break;
                     }
-                    if("一周".equals(date.getCycle())){
+                    if ("一周".equals(date.getCycle())) {
                         chart.setPlanNum(date.getPlanNum() + chart.getPlanNum());
                     }
                 }
             }
 
             // 如果今天大于这天, 查询的计划数量永远是0 需要查询记录中已执行和未执行的总和
-            if(compare < 0){
+            if (compare < 0) {
                 chart.setPlanNum(chart.getPlanNum() + labGradeManageRecordMapper.selectAllWorkCountByDate(chart));
             }
 
@@ -840,10 +838,10 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
         }
 
         List<List<Object>> datas = new ArrayList<>();
-        List<Object> data ;
+        List<Object> data;
         for (LabManageWorkChartVo workChartVo : list) {
             data = new ArrayList<>();
-            data.add(workChartVo.getOfWeek()+" - " + workChartVo.getCurrentDateStr());
+            data.add(workChartVo.getOfWeek() + " - " + workChartVo.getCurrentDateStr());
             data.add(workChartVo.getPlanNum());
             data.add(workChartVo.getFinishedNum());
 
@@ -854,20 +852,21 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
 
     /**
      * 分级管控统计 详情页列表2.4需求
+     *
      * @return
      */
     @Override
     public List<LabManageWorkChartVo> queryManageWorkChartDetails(LabManageWorkChartVo labManageWorkChartVo) {
 
         List<LabManageWorkChartVo> list = new ArrayList<>();
-        if(labManageWorkChartVo.getType() == 1){
+        if (labManageWorkChartVo.getType() == 1) {
             R r = remoteDeptService.getDeptList(new SysDept());
             List<SysDept> deptList = (List<SysDept>) r.getData();
 
-            LabManageWorkChartVo workChartVo ;
-            if(deptList.size() > 0){
+            LabManageWorkChartVo workChartVo;
+            if (deptList.size() > 0) {
                 for (SysDept dept : deptList) {
-                    if(labManageWorkChartVo.getDeptId() == null || (labManageWorkChartVo.getDeptId() != null && dept.getDeptId().equals(labManageWorkChartVo.getDeptId()))){
+                    if (labManageWorkChartVo.getDeptId() == null || (labManageWorkChartVo.getDeptId() != null && dept.getDeptId().equals(labManageWorkChartVo.getDeptId()))) {
                         workChartVo = new LabManageWorkChartVo();
 
                         workChartVo.setDeptId(dept.getDeptId());
@@ -885,7 +884,7 @@ public class LabGradeManageRecordServiceImpl implements ILabGradeManageRecordSer
                     }
                 }
             }
-        }else {
+        } else {
             list = labGradeManageRecordMapper.queryManageWorkChartDetailsType2(labManageWorkChartVo);
 
             for (LabManageWorkChartVo workChartVo : list) {

+ 46 - 53
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabMessageContentServiceImpl.java

@@ -23,11 +23,11 @@ import com.zd.laboratory.domain.vo.LabSubjectVO;
 import com.zd.laboratory.mapper.LabContentMachineMsgMapper;
 import com.zd.laboratory.mapper.LabMessageContentMapper;
 import com.zd.laboratory.mapper.LabSubjectMapper;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.entiy.MessageBody;
 import com.zd.laboratory.mqtt.enums.SendMode;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import com.zd.laboratory.service.*;
+import com.zd.model.constant.MqttConstants;
 import com.zd.model.domain.R;
 import com.zd.model.domain.per.PerPrefix;
 import com.zd.model.enums.WarnUserAttrEnum;
@@ -42,7 +42,6 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
@@ -89,7 +88,7 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
     public Integer phoneMode;
 
     @Value("${phoneMode:0}")
-    private void setPhoneMode(Integer phoneMode){
+    private void setPhoneMode(Integer phoneMode) {
         this.phoneMode = phoneMode;
     }
 
@@ -97,7 +96,8 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
     RemoteStockService remoteStockService;
 
 
-    private final String smsFormat="{}: {},发生风险预案,{}";
+    private final String smsFormat = "{}: {},发生风险预案,{}";
+
     /**
      * 查询消息发布
      *
@@ -129,7 +129,7 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
      * @return 消息发布
      */
     @Override
-    @DataScope(deptAlias = "s" , permi = PerPrefix.LABORATORY_CONTENT)
+    @DataScope(deptAlias = "s", permi = PerPrefix.LABORATORY_CONTENT)
     public List<LabMessageContentVO> selectLabMessageContentVOList(LabMessageContentListQuery labMessageContent) {
         return labMessageContentMapper.selectLabMessageContentVOList(labMessageContent);
     }
@@ -141,19 +141,20 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
      * ①全院,院系和个人不再给用户单独发送
      * 坏处:1,查询复杂,逻辑不统一,2.新建的用户能看到全校和所属院系历史所有数据(可以增加时间过滤来解决,暂时不解决) ,3 用户院系发生变化,时能看到之前该院系消息(该方式无解)
      * 好处:一次只产生一条消息,能极大的减少负载。
+     *
      * @param labMessageContent
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean sendMessage(LabMessageContent labMessageContent) {
         //消息表入库
-        if(labMessageContent.getMessClass() == null){
+        if (labMessageContent.getMessClass() == null) {
             labMessageContent.setMessClass(1);
         }
 
         insertLabMessageContent(labMessageContent);
 
-        if(labMessageContent.getMessClass() == 3 && StringUtils.isNotBlank(labMessageContent.getSubIds())){
+        if (labMessageContent.getMessClass() == 3 && StringUtils.isNotBlank(labMessageContent.getSubIds())) {
             // 一体机消息发送mqtt 通知,并生成相关数据
             labContentMachineMsgService.insert(labMessageContent);
         }
@@ -173,54 +174,49 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
      * 发送预警消息
      * 这里一定要重构,预警消息里内部又发送预案消息,以后需要重构为事件驱动
      *
-     *
-     * @param subId 实验室ID
+     * @param subId       实验室ID
      * @param newRiskPlan 预案
      */
     @Override
     @Async("labExecutor")
-    public void  sendWranMessage(Long subId, LabRiskPlan newRiskPlan,Long groupId)
-    {
+    public void sendWranMessage(Long subId, LabRiskPlan newRiskPlan, Long groupId) {
         logger.info("*******************sendWranMessage***********************");
         //获取实验室负责人信息
         LabSubject subject = new LabSubject();
         subject.setId(subId);
         List<LabSubjectVO> labSubjects = labSubjectMapper.selectLabSubjectVOList(subject);
-        logger.info("**************labSubjects.size()***********"+labSubjects.size());
+        logger.info("**************labSubjects.size()***********" + labSubjects.size());
         Optional.ofNullable(labSubjects)
                 .filter(a -> a.size() > 0)
                 .map(a -> a.get(0))
-                .map(a->{
-                    sendSubWran(a,newRiskPlan,groupId);
+                .map(a -> {
+                    sendSubWran(a, newRiskPlan, groupId);
                     return a;
                 })
                 .orElse(null);
     }
 
-    private void  sendSubWran(LabSubjectVO subject,LabRiskPlan newRiskPlan,Long groupId)
-    {
+    private void sendSubWran(LabSubjectVO subject, LabRiskPlan newRiskPlan, Long groupId) {
         logger.info("$$$$$$$$$$$$$进入sendSubWran$$$$$$$$$$$$$");
-        String safeUserId=subject.getSafeUserId();
-        if(StringUtils.isNotBlank(safeUserId)){
+        String safeUserId = subject.getSafeUserId();
+        if (StringUtils.isNotBlank(safeUserId)) {
             subject.setSafeUserPhone(labSubjectMapper.queryUserPhoneBySafeUserId(safeUserId));
         }
         String deptName = "";
         List<SubAddrr> subAddrrs = subjectLayoutService.selectAddrrByLayoutIds(subject.getLayoutId());
-        if(CollectionUtils.isNotEmpty(subAddrrs) && subAddrrs.size() > 0){
+        if (CollectionUtils.isNotEmpty(subAddrrs) && subAddrrs.size() > 0) {
             deptName = subAddrrs.get(0).getBuildName();
         }
 
         String format = StrUtil.format(smsFormat, deptName, subject.getName(), StrUtil.isBlank(newRiskPlan.getMessage()) ? newRiskPlan.getName() : newRiskPlan.getMessage());
-        String phone =null;
+        String phone = null;
         String userids = null;
         try {
             userids = getDoingUserId(subject);
-            if(StrUtil.isNotBlank(userids))
-            {
+            if (StrUtil.isNotBlank(userids)) {
 
                 R<List<String>> phoneByUserIDS = remoteUserService.getPhoneByUserIDS(userids);
-                if(phoneByUserIDS.getCode()==200&& CollUtil.isNotEmpty(phoneByUserIDS.getData()))
-                {
+                if (phoneByUserIDS.getCode() == 200 && CollUtil.isNotEmpty(phoneByUserIDS.getData())) {
                     phone = phoneByUserIDS.getData().stream()
                             .collect(Collectors.joining(","));
 
@@ -236,41 +232,38 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
                 .collect(Collectors.joining(","))
                 .split(",");
 
-        logger.info("%%%%%%%%%%%%%%%%%%%%strings:"+strings);
+        logger.info("%%%%%%%%%%%%%%%%%%%%strings:" + strings);
         //todo 发送最多支持200个电话号码 , 这里不会超过200人 所以没有验证, 切割
         //todo 这里判断电话类型,如果是0,发送短信,如果是1,是四医大内部短信接口。
-        if(phoneMode == 0){
-            if(strings!=null)
-            {
-                AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush,strings,format);
+        if (phoneMode == 0) {
+            if (strings != null) {
+                AlarmEntrty alarmEntrty = new AlarmEntrty(Routes.NoticePush, strings, format);
                 MessageBody messageBody = new MessageBody();
                 messageBody.setData(alarmEntrty);
-                commonSend.send("alarm/"+newRiskPlan.getId()+"/"+subject.getId(),messageBody, SendMode.DISTINCT);
-                logger.info("&&&&"+"alarm/"+newRiskPlan.getId()+"/"+subject.getId());
-                logger.info("&&&&"+JSON.toJSONString(messageBody));
+                //commonSend.send("alarm/"+newRiskPlan.getId()+"/"+subject.getId(),messageBody, SendMode.DISTINCT);
+                commonSend.send(MqttConstants.TOPIC_ALERT + newRiskPlan.getId() + "/" + subject.getId(), messageBody, SendMode.DISTINCT);
+                logger.info("&&&&" + MqttConstants.TOPIC_ALERT + newRiskPlan.getId() + "/" + subject.getId());
+                logger.info("&&&&" + JSON.toJSONString(messageBody));
 //           改用mqtt
 //           ResultData send = remoteAlarmService.send(alarmEntrty);
                 try {
-                    if(subject.getAdminId()!=null)
-                    {
+                    if (subject.getAdminId() != null) {
                         //发送预案消息(预案指挥中心) 没什么卵用 lab_warn_push_message
-                        labWarnPushMessageService.insertLabWarnPushMessage(subject.getId(),subject.getAdminId().toString(),groupId,newRiskPlan, WarnUserAttrEnum.ADMIN);
+                        labWarnPushMessageService.insertLabWarnPushMessage(subject.getId(), subject.getAdminId().toString(), groupId, newRiskPlan, WarnUserAttrEnum.ADMIN);
                     }
                     //发送预案消息(预案指挥中心) 没什么卵用 lab_warn_push_message 保持实验室内部人员发送记录  ?安全的要不要保存展示?
-                    labWarnPushMessageService.insertLabWarnPushMessage(subject.getId(),userids,groupId,newRiskPlan, WarnUserAttrEnum.NONE);
+                    labWarnPushMessageService.insertLabWarnPushMessage(subject.getId(), userids, groupId, newRiskPlan, WarnUserAttrEnum.NONE);
                 } catch (Exception e) {
                     logger.error("发送预案消息失败!");
                 }
             }
 
             //发送消息
-            if(StrUtil.isNotBlank(newRiskPlan.getInformation()))
-            {
-                String collect = Stream.of(new String[]{subject.getAdminId()==null?null:subject.getAdminId().toString(), subject.getSafeUserId()})
+            if (StrUtil.isNotBlank(newRiskPlan.getInformation())) {
+                String collect = Stream.of(new String[]{subject.getAdminId() == null ? null : subject.getAdminId().toString(), subject.getSafeUserId()})
                         .filter(a -> StrUtil.isNotBlank(a))
                         .collect(Collectors.joining(","));
-                if(StrUtil.isNotBlank(collect))
-                {
+                if (StrUtil.isNotBlank(collect)) {
                     LabMessageContentDTO labMessageContentDTO = new LabMessageContentDTO();
                     labMessageContentDTO.setUserIds(collect);
                     labMessageContentDTO.setSendMode(2);
@@ -281,9 +274,9 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
                 }
 
             }
-        }else if(phoneMode == 1){
+        } else if (phoneMode == 1) {
             //走四医大发送短信服务接口
-            remoteStockService.sendSydSms(newRiskPlan.getMessage(),5,null,strings);
+            remoteStockService.sendSydSms(newRiskPlan.getMessage(), 5, null, strings);
         }
 
     }
@@ -297,16 +290,15 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
         List<LabSubjectAccessRecordVo> labSubjectAccessRecordVos = subjectAccessRecordService.selectLabSubjectAccessRecordListNoAuth(labSubjectAccessRecordVo);
         //userids
         String userids = Optional.ofNullable(labSubjectAccessRecordVos)
-                        .filter(a->a.size()>0)
-                                .orElse(Collections.emptyList())
-                                .stream().map(a->a.getJoinUserId()).filter(a->a!=null)
-                .map(a->a.toString())
-                        .collect(Collectors.joining(","));
+                .filter(a -> a.size() > 0)
+                .orElse(Collections.emptyList())
+                .stream().map(a -> a.getJoinUserId()).filter(a -> a != null)
+                .map(a -> a.toString())
+                .collect(Collectors.joining(","));
         return userids;
     }
 
 
-
     /**
      * 新增消息发布
      *
@@ -319,8 +311,8 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
         logger.info("***************SaveUtil.setCommonAttr开始*****************");
         try {
             SaveUtil.setCommonAttr(labMessageContent);
-        }catch (Exception e){
-            logger.info("异常了:"+e.getMessage());
+        } catch (Exception e) {
+            logger.info("异常了:" + e.getMessage());
         }
         logger.info("***************SaveUtil.setCommonAttr结束*****************");
         return labMessageContentMapper.insertLabMessageContent(labMessageContent);
@@ -364,6 +356,7 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
 
     /**
      * 查询预案向一体机推送的消息,如果超过两小时,需要清理
+     *
      * @return 结果
      */
     @Override
@@ -375,11 +368,11 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
         labMessageContentListQuery.setMessClass(3);
         List<LabMessageContentVO> labMessageContentList = labMessageContentMapper.selectLabClearMessageList(labMessageContentListQuery);
         Optional.ofNullable(labMessageContentList).orElseGet(Collections::emptyList).stream()
-                .forEach(a->{
+                .forEach(a -> {
                     labContentMachineMsgMapper.deleteLabContentMachineMsgByContentId(a.getId());
                     labMessageContentMapper.deleteLabMessageContentById(a.getId());
                     // 生成一条通知一个,此处不应该有重复的实验室ID
-                    commonSend.send(MqttConstants.LAB_CONTENT + a.getSubIds(), "收到一条新的消息通知!");
+                    commonSend.send(MqttConstants.TOPIC_LAB_CONTENT + a.getSubIds(), "收到一条新的消息通知!");
                 });
         return flag;
     }

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

@@ -1,5 +1,6 @@
 package com.zd.laboratory.service.impl;
 
+import com.zd.model.constant.MqttConstants;
 import com.zd.model.domain.per.PerPrefix;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.utils.DateUtils;
@@ -12,7 +13,6 @@ import com.zd.laboratory.domain.LabNotifyplan;
 import com.zd.laboratory.domain.vo.LabNotifyplanExcelVO;
 import com.zd.laboratory.domain.vo.LabNotifyplanVO;
 import com.zd.laboratory.mapper.LabNotifyplanMapper;
-import com.zd.laboratory.mqtt.constants.MqttConstants;
 import com.zd.laboratory.mqtt.entiy.MessageBody;
 import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import com.zd.laboratory.service.ILabNotifyplanService;
@@ -20,7 +20,6 @@ import com.zd.model.entity.SysUser;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.io.InputStream;
@@ -339,7 +338,7 @@ public class LabNotifyplanServiceImpl implements ILabNotifyplanService
         int id = labNotifyplanMapper.insertLabNotifyplan(labNotifyplan);
         if(id>0){
             //1通知 2计划
-            commonSend.send(MqttConstants.LAB_BIG_VIEW_PLAN, new MessageBody("有新的通知发布。", labNotifyplan.getType()));
+            commonSend.send(MqttConstants.TOPIC_LAB_BIG_VIEW_PLAN, new MessageBody("有新的通知发布。", labNotifyplan.getType()));
         }
         return id;
     }