linfutong пре 2 година
родитељ
комит
f0e456da3b
72 измењених фајлова са 1254 додато и 709 уклоњено
  1. 11 0
      zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/entity/LabMessageContent.java
  2. 12 0
      zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/RemoteLaboratoryService.java
  3. 10 0
      zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/fallback/RemoteLaboratoryFallbackFactory.java
  4. 3 0
      zd-modules/zd-modules-laboratory/pom.xml
  5. 2 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/ZdLaboratoryApplication.java
  6. 17 8
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/config/ExecutorConfig.java
  7. 0 29
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/config/MyBatisPlusConfig.java
  8. 1 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/AlgorithmController.java
  9. 11 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabBuildFloorLayoutController.java
  10. 11 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabHardwareController.java
  11. 5 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabMessageContentController.java
  12. 0 5
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabRiskPlanController.java
  13. 4 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabRiskPlanLevelController.java
  14. 14 4
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSecurityApplyController.java
  15. 21 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSparseHardwareController.java
  16. 3 2
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSubMangerController.java
  17. 22 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/bigview/BigViewController.java
  18. 43 49
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/device/DeviceRemoteController.java
  19. 46 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/LabHardware.java
  20. 1 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabExitLineJoinPointVO.java
  21. 6 6
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabSubjectVO.java
  22. 12 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabWarnPushMessageListVO.java
  23. 11 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabWarnPushMessageVO.java
  24. 6 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisExpiredAndAddListener.java
  25. 0 48
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisKeyExpirationListener.java
  26. 0 33
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisUpdateAndAddListener.java
  27. 7 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabBuildFloorLayoutMapper.java
  28. 10 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabHardwareMapper.java
  29. 1 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabSecurityApplyMapper.java
  30. 14 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabSparseHardwareMapper.java
  31. 15 8
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabWarnPushMessageMapper.java
  32. 19 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/config/MqttConfig.java
  33. 0 4
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/controller/MqttController.java
  34. 9 13
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/service/impl/SubMessageSendManager.java
  35. 0 36
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/test/MqttTest.java
  36. 17 11
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/controller/OneMachineController.java
  37. 4 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/service/OneMachineService.java
  38. 6 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabBuildFloorLayoutService.java
  39. 2 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabMessageContentService.java
  40. 14 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabSparseHardwareService.java
  41. 9 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabWarnPushMessageService.java
  42. 18 5
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabBuildFloorLayoutServiceImpl.java
  43. 4 5
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabCheckRecordServiceImpl.java
  44. 9 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabExitLineServiceImpl.java
  45. 49 10
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabExitLineVertexServiceImpl.java
  46. 8 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabMessageContentServiceImpl.java
  47. 44 41
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabMessageUserServiceImpl.java
  48. 13 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabRiskPlanAbnormalLogServiceImpl.java
  49. 3 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabRiskPlanLevelServiceImpl.java
  50. 185 152
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabRiskPlanServiceImpl.java
  51. 0 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSecurityApplyServiceImpl.java
  52. 2 5
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSensorServiceImpl.java
  53. 11 3
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSparseHardwareServiceImpl.java
  54. 35 11
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectManagerService.java
  55. 1 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabViolationServiceImpl.java
  56. 7 0
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabWarnPushMessageServiceImpl.java
  57. 1 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/SubQueryManager.java
  58. 1 1
      zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/socket/service/SocketService.java
  59. 13 0
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabBuildFloorLayoutMapper.xml
  60. 1 1
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabBuildFloorMapper.xml
  61. 4 4
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabCheckRecordMapper.xml
  62. 2 2
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabCheckRecordReleaseMapper.xml
  63. 44 7
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHardwareMapper.xml
  64. 2 0
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHazardMapper.xml
  65. 3 0
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabMessageContentMapper.xml
  66. 3 2
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabMessageUserMapper.xml
  67. 3 3
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabRiskPlanAbnormalGroupMapper.xml
  68. 3 2
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabRiskPlanAbnormalLogMapper.xml
  69. 14 0
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSparseHardwareMapper.xml
  70. 329 169
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSubjectMapper.xml
  71. 17 4
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabViolationMapper.xml
  72. 26 2
      zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabWarnPushMessageMapper.xml

+ 11 - 0
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/entity/LabMessageContent.java

@@ -98,6 +98,9 @@ public class LabMessageContent extends BaseEntity {
     @ApiModelProperty("过期日期(实验室消息专用)")
     private Date expirationDate;
 
+    @ApiModelProperty("是否已读")
+    private boolean ifRead = false;
+
     public Integer getMessClass() {
         return messClass;
     }
@@ -224,4 +227,12 @@ public class LabMessageContent extends BaseEntity {
     public void setSubName(String subName) {
         this.subName = subName;
     }
+
+    public boolean isIfRead() {
+        return ifRead;
+    }
+
+    public void setIfRead(boolean ifRead) {
+        this.ifRead = ifRead;
+    }
 }

+ 12 - 0
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/RemoteLaboratoryService.java

@@ -372,6 +372,14 @@ public interface RemoteLaboratoryService {
     public R<Object> getSpeakerBySub(@PathVariable("floorId") Long floorId, @PathVariable("subId") Long subId);
 
     /**
+     * 获取喇叭总数
+     * @Return com.zd.model.domain.R<java.lang.Object>
+     **/
+    @ApiOperation(value = "获取喇叭总数")
+    @GetMapping("/sparseHardware/selectSpeakerCount")
+    R<Object> selectSpeakerCount();
+
+    /**
      * 定时任务分级管控工作过期记录 - 并排列下次工作计划
      */
     @ApiOperation(value = "定时任务分级管控工作过期记录 - 并排列下次工作计划")
@@ -472,4 +480,8 @@ public interface RemoteLaboratoryService {
     @ApiOperation(value = "一件灭火接受火焰预警")
     @PostMapping("/plan/oneClickFire")
     ResultData oneClickFire(@RequestBody OneClickFireDTO oneClickFireDTO);
+
+    @ApiOperation(value = "根据实验室id查询实验室位置信息")
+    @PostMapping("/buildFloorLayout/getPositionBySubId")
+    ResultData getPositionBySubId(@RequestParam("subIds") String subIds);
 }

+ 10 - 0
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/fallback/RemoteLaboratoryFallbackFactory.java

@@ -346,6 +346,11 @@ public class RemoteLaboratoryFallbackFactory implements FallbackFactory<RemoteLa
             }
 
             @Override
+            public R<Object> selectSpeakerCount() {
+                throw new RuntimeException("获取喇叭总数失败!" + cause.getMessage());
+            }
+
+            @Override
             public void workArrange() {
                 throw new RuntimeException("定时任务分级管控工作过期记录 - 并排列下次工作计划失败:" + cause.getMessage());
             }
@@ -432,6 +437,11 @@ public class RemoteLaboratoryFallbackFactory implements FallbackFactory<RemoteLa
             public ResultData oneClickFire(OneClickFireDTO oneClickFireDTO) {
                 return ResultData.fail("一键灭火触发预案失败!"+ cause.getMessage());
             }
+
+            @Override
+            public ResultData getPositionBySubId(String subIds) {
+                return ResultData.fail("查询实验室位置信息失败!"+ cause.getMessage());
+            }
         };
     }
 }

+ 3 - 0
zd-modules/zd-modules-laboratory/pom.xml

@@ -107,6 +107,9 @@
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
                 <version>${spring-boot.version}</version>
+                <configuration>
+                    <includeSystemScope>true</includeSystemScope>
+                </configuration>
                 <executions>
                     <execution>
                         <goals>

+ 2 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/ZdLaboratoryApplication.java

@@ -8,6 +8,7 @@ import com.zd.model.constant.BaseConstants;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.context.annotation.ComponentScan;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.annotation.EnableScheduling;
 
 /**
@@ -21,6 +22,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @EnableScheduling
 @ComponentScan(basePackages = BaseConstants.BASE_PACKAGE)
 @MapperScan(value = {"com.zd.**.mapper"})
+@EnableAsync
 public class ZdLaboratoryApplication {
     public static void main(String[] args) {
         ZdStartApplication.run(ApplicationConstants.LABORATORY_SERVICE, ZdLaboratoryApplication.class, args);

+ 17 - 8
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/config/ExecutorConfig.java

@@ -4,6 +4,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableAsync;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 
 import java.util.concurrent.Executor;
@@ -14,10 +15,9 @@ import java.util.concurrent.ThreadPoolExecutor;
  * @Date: 2021/11/17/14:39
  * @Description:
  */
+@EnableAsync
 @Configuration
 public class ExecutorConfig {
-
-
     private static final Logger logger = LoggerFactory.getLogger(ExecutorConfig.class);
 
     @Bean(name = "labExecutor")
@@ -25,14 +25,23 @@ public class ExecutorConfig {
         logger.info("start asyncServiceExecutor");
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         //配置核心线程数
-        executor.setCorePoolSize(5);
-        //配置最大线程数
-        executor.setMaxPoolSize(8);
-        //配置队列大小
-        executor.setQueueCapacity(99999);
+        executor.setCorePoolSize(10);
+        //线程池维护线程的最大数量,只有在缓冲队列满了之后才会申请超过核心线程数的线程
+        executor.setMaxPoolSize(50);
+        //缓存队列
+        executor.setQueueCapacity(50);
+        //许的空闲时间,当超过了核心线程出之外的线程在空闲时间到达之后会被销毁
+        executor.setKeepAliveSeconds(200);
         //配置线程池中的线程的名称前缀
         executor.setThreadNamePrefix("async-service-");
-
+        /**
+         * 当线程池的任务缓存队列已满并且线程池中的线程数目达到maximumPoolSize,如果还有任务到来就会采取任务拒绝策略
+         * 通常有以下四种策略:
+         * ThreadPoolExecutor.AbortPolicy:丢弃任务并抛出RejectedExecutionException异常。
+         * ThreadPoolExecutor.DiscardPolicy:也是丢弃任务,但是不抛出异常。
+         * ThreadPoolExecutor.DiscardOldestPolicy:丢弃队列最前面的任务,然后重新尝试执行任务(重复此过程)
+         * ThreadPoolExecutor.CallerRunsPolicy:重试添加当前的任务,自动重复调用 execute() 方法,直到成功
+         */
         // rejection-policy:当pool已经达到max size的时候,如何处理新任务
         // CALLER_RUNS:不在新线程中执行任务,而是有调用者所在的线程来执行
         executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());

+ 0 - 29
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/config/MyBatisPlusConfig.java

@@ -1,29 +0,0 @@
-package com.zd.laboratory.config;
-
-import com.baomidou.mybatisplus.annotation.DbType;
-import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-@MapperScan("com.cn.springbootmybatisplus06.mapper")
-@EnableTransactionManagement//自动管理事务
-@Configuration // 配置类
-public class MyBatisPlusConfig {
-
-    /**
-     * 新版
-     */
-    @Bean
-    public MybatisPlusInterceptor mybatisPlusInterceptor() {
-        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
-        //配置乐观锁
-        mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
-        //配置分页插件
-        mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
-        return mybatisPlusInterceptor;
-    }
-}

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

@@ -51,7 +51,7 @@ public class AlgorithmController extends BaseController {
     }
 
     @PostMapping("/saveAlgorithm")
-    public ResultData saveAlgorithmData(Algorithm algorithm) {
+    public ResultData saveAlgorithmData(@RequestBody Algorithm algorithm) {
         logger.info("===================记录添加========================");
         return  ResultData.success(algorithmService.saveData(algorithm));
     }

+ 11 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabBuildFloorLayoutController.java

@@ -7,7 +7,6 @@ import com.zd.common.core.log.BusinessType;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.common.swagger.config.Knife4jConfiguration;
 import com.zd.laboratory.domain.LabBuildFloorLayout;
-import com.zd.laboratory.domain.LabExitLineVertex;
 import com.zd.laboratory.domain.vo.LabBuildFloorLayoutVo;
 import com.zd.laboratory.service.ILabBuildFloorLayoutService;
 import com.zd.model.domain.ResultData;
@@ -20,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * Controller
@@ -109,4 +109,14 @@ public class LabBuildFloorLayoutController extends BaseController<LabBuildFloorL
         List <LabBuildFloorLayoutVo> list = labBuildFloorLayoutService.selectLabBuildFloorLayoutList(labBuildFloorLayout);
         return getDataTable(list);
     }
+
+    /**
+     * 根据实验室id查询实验室位置信息(楼栋-楼层-实验室名称)
+     */
+    @PostMapping("/getPositionBySubId")
+    @ApiOperation(value = "根据实验室id查询实验室位置信息")
+    public ResultData getPositionBySubId(@RequestParam("subIds") String subIds) {
+        Map<Long, Map<String,Object>> map = labBuildFloorLayoutService.getPositionBySubId(subIds);
+        return ResultData.success(map);
+    }
 }

+ 11 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabHardwareController.java

@@ -223,6 +223,17 @@ public class LabHardwareController extends BaseController {
 
     }
 
+    @ApiOperation(value = "根据硬件类型查询该实验室下的硬件")
+    @GetMapping("/queryHardByType")
+    public ResultData<List<LabHardwareVO>> listBySubjectId(Long subjectId, HardwareTypeEnum type){
+
+        LabHardware labHardware = new LabHardware();
+        labHardware.setSubjectId(subjectId);
+        labHardware.setType(type);
+
+        return ResultData.success(labHardwareService.selectLabHardwareList(labHardware));
+    }
+
     /***
      * 根据实验室id查询该实验室下的硬件信息
      * @return
@@ -260,7 +271,6 @@ public class LabHardwareController extends BaseController {
         List<Long> ids = new ArrayList<>();
         ids.add(1L);//电源开关
         ids.add(2L);//智能通风
-        ids.add(10L);//一键灭火
         ytjVo.setIds(ids);
         List<LabHardware> listkzsb=labHardwareService.selectNewLabHardwareByTypes(ytjVo);
 

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

@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.constraints.NotNull;
 import java.util.List;
 
 /**
@@ -202,4 +203,8 @@ public class LabMessageContentController extends BaseController {
         messageUserService.readByLoginUser(labMessageUser);
     }
 
+    @GetMapping("/readMsgContent")
+    public void readMsgContent(@RequestParam @NotNull Long id) {
+        labMessageContentService.readMsgContent(id);
+    }
 }

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

@@ -1,7 +1,5 @@
 package com.zd.laboratory.controller;
 
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.date.TimeInterval;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.zd.algorithm.api.fire.RemoteFireDeviceService;
@@ -353,7 +351,6 @@ public class LabRiskPlanController extends BaseController {
     @PostMapping("/closeRiskPlan")
     public ResultData closeRiskPlan(@RequestBody LabRiskPlanAbnormalGroup labRiskPlanAbnormalGroup) {
         try {
-            TimeInterval timer = DateUtil.timer();
             logger.info("开始进入手动关闭预案");
             LabRiskPlanAbnormalLog labRiskPlanAbnormalLog = new LabRiskPlanAbnormalLog();
             labRiskPlanAbnormalLog.setGroupId(labRiskPlanAbnormalGroup.getId());
@@ -366,8 +363,6 @@ public class LabRiskPlanController extends BaseController {
                 //关闭预案
                 labRiskPlanService.closeRiskPlan(subFunction);
             });
-            long interval = timer.interval();
-            logger.info("开始执行花费时间={}",interval);
             return ResultData.success(1);
         }catch (Exception e){
             logger.error("手动关闭风险预案controller异常!{}",e);

+ 4 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabRiskPlanLevelController.java

@@ -51,7 +51,10 @@ public class LabRiskPlanLevelController extends BaseController {
     @PreAuthorize(hasPermi = PerPrefix.LABORATORY_PLAN + PerFun.REMOVE)
     @DeleteMapping("/delete")
     public ResultData delete(@RequestBody LabRiskPlanLevel labRiskPlanLevel) {
-        return ResultData.result(labRiskPlanLevelService.deleteById(labRiskPlanLevel));
+        if (labRiskPlanLevelService.deleteById(labRiskPlanLevel)>0) {
+            return ResultData.success(null,"删除预案规则成功");
+        }
+        return ResultData.fail("删除预案规则失败");
     }
 
     /**

+ 14 - 4
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSecurityApplyController.java

@@ -5,6 +5,7 @@ import java.util.*;
 import java.io.IOException;
 import javax.servlet.http.HttpServletResponse;
 
+import com.zd.common.core.utils.*;
 import com.zd.laboratory.domain.LabWhitelist;
 import com.zd.laboratory.service.*;
 import com.zd.model.constant.UserConstants;
@@ -14,10 +15,6 @@ import com.zd.model.domain.per.PerPrefix;
 import com.zd.model.constant.SecurityConstants;
 import com.zd.model.domain.ResultData;
 import com.zd.common.core.exception.ServiceException;
-import com.zd.common.core.utils.FileConfigUtils;
-import com.zd.common.core.utils.StringUtils;
-import com.zd.common.core.utils.UrlFormatUtils;
-import com.zd.common.core.utils.ExcelUtil;
 import com.zd.common.core.web.controller.BaseController;
 import com.zd.model.page.TableDataInfo;
 import com.zd.common.core.annotation.Log;
@@ -103,6 +100,10 @@ public class LabSecurityApplyController extends BaseController
             LabSubject labSubject = new LabSubject();
             labSubject.setAdminId(sysUser.getUserId());
             List<LabSubject> list = labSubjectService.selectLabSubjectListByadminidNotnull(labSubject);
+            if(list.size()==0){
+                //该人员没有负责相关的实验室 直接返回
+                return getDataTable(new ArrayList());
+            }
             for (LabSubject sub:list) {
                 ids.add(sub.getId());
             }
@@ -409,6 +410,11 @@ public class LabSecurityApplyController extends BaseController
         //根据id查询用户信息
         R<SysUser> rDate =remoteUserService.getUserInfoByUserId(tokensysUser.getUserId(), SecurityConstants.INNER);
         SysUser  sysUser = rDate.getData();
+        //卡号解密
+        if(StringUtils.isNotEmpty(sysUser.getCardNumSimple())){
+            sysUser.setCardNum(DESUtils.decrypt(sysUser.getCardNumSimple()));
+        }
+
 
         //PC端根据条件校验,小程序端不做校验(操作流程不同)
         if(StringUtils.isNotBlank(remark)) {
@@ -581,6 +587,10 @@ public class LabSecurityApplyController extends BaseController
             LabSubject labSubject = new LabSubject();
             labSubject.setAdminId(sysUser.getUserId());
             List<LabSubject> list = labSubjectService.selectLabSubjectListByadminidNotnull(labSubject);
+            if(list.size()==0){
+                //该人员没有负责相关的实验室 直接返回
+                return getDataTable(new ArrayList());
+            }
             for (LabSubject sub:list) {
                 ids.add(sub.getId());
             }

+ 21 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabSparseHardwareController.java

@@ -95,10 +95,21 @@ public class LabSparseHardwareController extends BaseController {
     @RequestMapping(value = "/getSpeaker/{floorId}/{subId}")
     public ResultData<List<Map<String,Object>>> getSpeakerBySub(
             @PathVariable("floorId") Long floorId, @PathVariable("subId") Long subId) {
-
+        if (floorId == -99L && subId != null) {
+            return ResultData.success(labSparseHardwareService.selectSpeakerBySubId(subId));
+        }
         return ResultData.success(labSparseHardwareService.selectSpeakerByFloorId(floorId, subId));
     }
 
+    /**
+     * 根据实验室id获取喇叭列表
+     */
+    @ApiOperation(value = "根据实验室id获取喇叭列表")
+    @RequestMapping(value = "/getSpeakerBySubId/{subId}")
+    public ResultData<List<Map<String,Object>>> getSpeakerBySubId(@PathVariable("subId") Long subId) {
+        return ResultData.success(labSparseHardwareService.selectSpeakerBySubId(subId));
+    }
+
 
     /**
      * 新增疏散硬件
@@ -132,4 +143,13 @@ public class LabSparseHardwareController extends BaseController {
     public ResultData remove(@PathVariable Long[] ids) {
         return ResultData.result(labSparseHardwareService.deleteLabSparseHardwareByIds(ids));
     }
+    /**
+     * 查询疏散硬件列表
+     */
+    @PreAuthorize(hasPermi = PerPrefix.LABORATORY_SPARSEHARDWARE + PerFun.LIST)
+    @GetMapping("/selectSpeakerCount")
+    @ApiOperation(value = "查询喇叭总数")
+    public ResultData selectSpeakerCount() {
+        return ResultData.success(labSparseHardwareService.selectSpeakerCount());
+    }
 }

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

@@ -104,13 +104,14 @@ public class LabSubMangerController extends BaseController {
      * 查询实验室详情
      * @param id 实验室ID
      * @param type 1 只查硬件数据, 0 查全部详情
+     * @param typeCollection   设备类型集合(非必须)
      * @return
      */
     @ApiOperation("查询实验室详情")
     @GetMapping("/query/{id}/{type}")
     @PreAuthorize(hasPermi = PerPrefix.LABORATORY_SUBJECT + PerFun.QUERY)
-    public ResultData<LabSubjectControllerVO> querySubById(@PathVariable("id") Long id, @PathVariable("type") Integer type) {
-        return ResultData.success(subjectManagerService.querySubById(id, type));
+    public ResultData<LabSubjectControllerVO> querySubById(@PathVariable("id") Long id, @PathVariable("type") Integer type,Long[] typeCollection) {
+        return ResultData.success(subjectManagerService.querySubById(id, type,typeCollection));
     }
 
     /**

+ 22 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/bigview/BigViewController.java

@@ -241,6 +241,28 @@ public class BigViewController extends BaseController {
 
 
     /**
+     * 查询风险分组内消息推送记录
+     *
+     * @return
+     */
+    @ApiOperation("查询风险分组内消息推送记录")
+    @GetMapping("/{group}/warn/getRiskLog")
+    public  List<LabWarnPushMessageListVO> getRiskLog(@PathVariable("group") Long groupId) {
+        List<LabWarnPushMessageVO> labWarnPushMessageVOS = warnPushMessageService.selectLabRiskLogList(groupId);
+
+        return Optional.ofNullable(labWarnPushMessageVOS)
+                .orElseGet(Collections::emptyList)
+                .stream()
+                .map(a->{
+                    LabWarnPushMessageListVO warnPushMessageVO = new LabWarnPushMessageListVO();
+                    BeanUtils.copyProperties(a,warnPushMessageVO);
+                    return warnPushMessageVO;
+                })
+                .collect(Collectors.toList());
+    }
+
+
+    /**
      * 安全隐患统计 柱状图2.4需求
      */
     @ApiOperation("安全隐患统计信息")

+ 43 - 49
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/device/DeviceRemoteController.java

@@ -4,6 +4,7 @@ import com.zd.common.core.redis.RedisService;
 import com.zd.common.core.utils.ReUtil;
 import com.zd.laboratory.api.entity.CabinetLock;
 import com.zd.laboratory.api.entity.CabinetV2Lock;
+import com.zd.laboratory.mqtt.service.impl.CommonSend;
 import com.zd.laboratory.socket.runner.TCPServer;
 import com.zd.laboratory.socket.service.SocketService;
 import com.zd.laboratory.utils.CRCCHECK;
@@ -11,6 +12,7 @@ import com.zd.model.domain.ResultData;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -31,6 +33,11 @@ public class DeviceRemoteController {
     private SocketService socketService;
     @Autowired
     private RedisService redisService;
+    @Autowired
+    private CommonSend commonSend;
+
+    @Value("${sys.lockTimer:30}")
+    private Integer lockTimer;
 
 
     @PostMapping("/cabinetLock")
@@ -54,44 +61,29 @@ public class DeviceRemoteController {
             ops.flush();
             logger.info("柜锁开锁指令:" + instruct);
 
-            Thread.sleep(500);
-            ops.write(ReUtil.hexStringToByteArray(instruct));
-            ops.flush();
-
-            Thread.sleep(300);
-            ops.write(ReUtil.hexStringToByteArray(instruct));
-            ops.flush();
-            Thread.sleep(500);
-            ops.write(ReUtil.hexStringToByteArray(instruct));
-            ops.flush();
-            Thread.sleep(300);
-            ops.write(ReUtil.hexStringToByteArray(instruct));
-            ops.flush();
-            Thread.sleep(500);
-            ops.write(ReUtil.hexStringToByteArray(instruct));
-            ops.flush();
-            Thread.sleep(300);
-            ops.write(ReUtil.hexStringToByteArray(instruct));
-            ops.flush();
-
+            Thread.sleep(1000);
             instruct = CRCCHECK.getReadLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
-            ops.write(ReUtil.hexStringToByteArray(instruct));
-            ops.flush();
-
-            Thread.sleep(500);
-            Integer status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
-            logger.info("柜锁开锁锁状态查询:" + instruct + ",开锁结果:" + status);
-            /*if(status != null && status == 1){
-                return ResultData.success("开锁成功");
-            }*/
-            // TODO 因样件锁 发送开锁指令后锁未主动弹开,先不关注锁的状态
-            return ResultData.success("开锁成功");
+            int timer = lockTimer;
+            Integer status;
+            while (timer > 1){
+
+                ops.write(ReUtil.hexStringToByteArray(instruct));
+                ops.flush();
+                timer-=2;
+
+                Thread.sleep(1900);
+                status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
+                logger.info("柜锁开锁锁状态查询:" + instruct + ",开锁结果:" + status);
+                if(status != null && status == 1){
+                    return ResultData.success("开锁成功");
+                }
+            }
         } catch (Exception e) {
             e.printStackTrace();
             logger.error("柜锁连接失败:" + e.getMessage());
             return ResultData.fail("柜锁连接失败!");
         }
-        //return ResultData.fail("开锁失败");
+        return ResultData.fail("开锁失败");
     }
 
     /**
@@ -99,29 +91,31 @@ public class DeviceRemoteController {
      */
     @PostMapping("/V2/closeLock")
     public ResultData cabinetV2CloseLock(@RequestBody CabinetV2Lock cabinetV2Lock){
-        String instruct = CRCCHECK.getCloseLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
+//        String instruct = CRCCHECK.getCloseLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
         String relayCode = cabinetV2Lock.getRelayCode();
         OutputStream ops = TCPServer.cacheMap.get(relayCode);
 
         try {
-            ops.write(ReUtil.hexStringToByteArray(instruct));
+            /*ops.write(ReUtil.hexStringToByteArray(instruct));
             ops.flush();
             logger.info("柜锁关锁指令:" + instruct);
-            Thread.sleep(1000);
-
-            instruct = CRCCHECK.getReadLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
-            ops.write(ReUtil.hexStringToByteArray(instruct));
-            ops.flush();
-
-            Thread.sleep(600);
-            ops.write(ReUtil.hexStringToByteArray(instruct));
-            ops.flush();
-
-            Thread.sleep(900);
-            Integer status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
-            logger.info("柜锁关锁状态查询:" + instruct + ",关锁结果" + status);
-            if(status != null && status == 0){
-                return ResultData.success("关锁成功");
+            Thread.sleep(1000);*/
+
+            String instruct = CRCCHECK.getReadLockOrder(Integer.parseInt(cabinetV2Lock.getLockId()));
+            int timer = lockTimer;
+            Integer status;
+            while (timer > 1){
+
+                ops.write(ReUtil.hexStringToByteArray(instruct));
+                ops.flush();
+                timer-=2;
+
+                Thread.sleep(1900);
+                status = redisService.getCacheObject(relayCode + ":" + cabinetV2Lock.getLockId());
+                logger.info("柜锁关锁状态查询:" + instruct + ",关锁结果" + status);
+                if(status != null && status == 0){
+                    return ResultData.success("关锁成功");
+                }
             }
 //            return ResultData.success("关锁成功");
         } catch (Exception e) {

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

@@ -11,6 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
 import org.hibernate.validator.constraints.Length;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * 硬件对象 lab_hardware
@@ -137,6 +138,13 @@ public class LabHardware extends BaseEntity {
     @ApiModelProperty(value = "柜锁id")
     private Integer lockId;
 
+    @ApiModelProperty(value = "设备用户")
+    private String harUser;
+    @ApiModelProperty(value = "设备密码")
+    private String harPsw;
+    @ApiModelProperty(value = "设备应用范围(1 安全准入,2 白名单)")
+    private String controlScope;
+
 
 
     public String getHardwareNum() {
@@ -198,6 +206,12 @@ public class LabHardware extends BaseEntity {
     @ApiModelProperty(value = "是否灭火主机")
     private Integer isPcfire;
 
+    @ApiModelProperty(value = "设备类型集合")
+    private Long[] typeCollection;
+
+    @ApiModelProperty(value = "实验室id集合")
+    private Long[] subIds;
+
     public Integer getManufacturerType() {
         return manufacturerType;
     }
@@ -464,4 +478,36 @@ public class LabHardware extends BaseEntity {
     public Integer getIsPcfire() {        return isPcfire;    }
 
     public void setIsPcfire(Integer isPcfire) {        this.isPcfire = isPcfire;    }
+
+    public String getHarUser() {
+        return harUser;
+    }
+
+    public void setHarUser(String harUser) {
+        this.harUser = harUser;
+    }
+
+    public String getHarPsw() {
+        return harPsw;
+    }
+
+    public void setHarPsw(String harPsw) {
+        this.harPsw = harPsw;
+    }
+
+    public String getControlScope() {
+        return controlScope;
+    }
+
+    public void setControlScope(String controlScope) {
+        this.controlScope = controlScope;
+    }
+
+    public Long[] getTypeCollection() {        return typeCollection;    }
+
+    public void setTypeCollection(Long[] typeCollection) {        this.typeCollection = typeCollection;    }
+
+    public Long[] getSubIds() {        return subIds;    }
+
+    public void setSubIds(Long[] subIds) {        this.subIds = subIds;    }
 }

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

@@ -33,7 +33,7 @@ public class LabExitLineJoinPointVO {
     @ApiModelProperty(value = "起点名称")
     private String startPointName;
 
-    @ApiModelProperty(value = "点属性")
+    @ApiModelProperty(value = "点属性1:逃生 2:灯 4:实验室 3:其他  5:交通点")
     private Integer pointAttribute;
 
     @ApiModelProperty(value = "房间或者灯的名称,通过房间或者灯的pointName寻找这个key")

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

@@ -80,9 +80,9 @@ public class LabSubjectVO extends LabSubject {
 
     private Integer pageSizeStr;
 
-    private Integer whiteUserId;
+    private Long whiteUserId;
 
-    private Integer subjectId;
+    private Long subjectId;
 
     @ApiModelProperty(value = "实验室类型名称")
     private String moldName;
@@ -307,19 +307,19 @@ public class LabSubjectVO extends LabSubject {
         this.pageSizeStr = pageSizeStr;
     }
 
-    public Integer getWhiteUserId() {
+    public Long getWhiteUserId() {
         return whiteUserId;
     }
 
-    public void setWhiteUserId(Integer whiteUserId) {
+    public void setWhiteUserId(Long whiteUserId) {
         this.whiteUserId = whiteUserId;
     }
 
-    public Integer getSubjectId() {
+    public Long getSubjectId() {
         return subjectId;
     }
 
-    public void setSubjectId(Integer subjectId) {
+    public void setSubjectId(Long subjectId) {
         this.subjectId = subjectId;
     }
 

+ 12 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabWarnPushMessageListVO.java

@@ -30,6 +30,9 @@ public class LabWarnPushMessageListVO
     @ApiModelProperty("实验室名称")
     private String subName;
 
+    @ApiModelProperty("创建时间格式化")
+    private String createTimeStr;
+
     @ApiModelProperty(value = "人员属性0:负责人1:内部人员")
     private WarnUserAttrEnum userAttributes;
 
@@ -40,7 +43,7 @@ public class LabWarnPushMessageListVO
         {
             return subName;
         }
-        if(WarnMessageTypeEnum.SMS.equals(pushType))
+        if(WarnMessageTypeEnum.SMS.equals(pushType)||WarnMessageTypeEnum.PHONE.equals(pushType))
         {
             return StrUtil.format("{}-{}",userAttributes.getName(), Optional.ofNullable(recipientName).orElseGet(()->StrUtil.EMPTY)) ;
         }
@@ -91,4 +94,12 @@ public class LabWarnPushMessageListVO
     public void setCreateTime(Date createTime) {
         this.createTime = createTime;
     }
+
+    public String getCreateTimeStr() {
+        return createTimeStr;
+    }
+
+    public void setCreateTimeStr(String createTimeStr) {
+        this.createTimeStr = createTimeStr;
+    }
 }

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

@@ -20,6 +20,9 @@ public class LabWarnPushMessageVO extends LabWarnPushMessage
     @ApiModelProperty("实验室名称")
     private String subName;
 
+    @ApiModelProperty("创建时间格式化")
+    private String createTimeStr;
+
     public String getRecipientName() {
         return recipientName;
     }
@@ -35,4 +38,12 @@ public class LabWarnPushMessageVO extends LabWarnPushMessage
     public void setSubName(String subName) {
         this.subName = subName;
     }
+
+    public String getCreateTimeStr() {
+        return createTimeStr;
+    }
+
+    public void setCreateTimeStr(String createTimeStr) {
+        this.createTimeStr = createTimeStr;
+    }
 }

+ 6 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisExpiredAndAddListener.java

@@ -2,9 +2,11 @@ package com.zd.laboratory.event;
 
 import cn.hutool.core.util.StrUtil;
 import com.zd.laboratory.event.handle.EventHandler;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.data.redis.connection.Message;
-import org.springframework.data.redis.connection.MessageListener;
+import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
 import org.springframework.data.redis.listener.PatternTopic;
+import org.springframework.data.redis.listener.RedisMessageListenerContainer;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -30,7 +32,7 @@ import java.util.stream.Collectors;
  * @Description:
  */
 @Component
-public class RedisExpiredAndAddListener implements MessageListener {
+public class RedisExpiredAndAddListener extends KeyExpirationEventMessageListener {
 
     //监听的主题  现在只监听0号数据库
     private  final PatternTopic topic = new PatternTopic("__keyevent@0__:expired");
@@ -39,8 +41,9 @@ public class RedisExpiredAndAddListener implements MessageListener {
 
     private Map<String,EventHandler> map ;
 
-    public RedisExpiredAndAddListener(List<EventHandler> eventHandlers)
+    public RedisExpiredAndAddListener(List<EventHandler> eventHandlers, RedisMessageListenerContainer listenerContainer)
     {
+        super(listenerContainer);
         map = eventHandlers.stream().collect(Collectors.toMap(a -> a.handleKey(), Function.identity()));
     }
 

+ 0 - 48
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisKeyExpirationListener.java

@@ -1,48 +0,0 @@
-package com.zd.laboratory.event;
-
-import cn.hutool.core.util.StrUtil;
-import com.zd.common.core.utils.SpringUtils;
-import com.zd.laboratory.mqtt.entiy.EquipmentStatus;
-import com.zd.model.constant.CacheDevice;
-import com.zd.model.enums.HardwareOperate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.data.redis.connection.Message;
-import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
-import org.springframework.data.redis.listener.RedisMessageListenerContainer;
-
-/**
- * 该方式会导致监听所有的库 所以没有使用
- * @Author: zhoupan
- * @Date: 2021/10/20/10:17
- */
-@Deprecated
-public class RedisKeyExpirationListener extends KeyExpirationEventMessageListener {
-
-    private final static Logger logger = LoggerFactory.getLogger(RedisKeyExpirationListener.class);
-
-    public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
-        super(listenerContainer);
-    }
-
-    @Override
-    public void onMessage(Message message, byte[] pattern) {
-        // 用户做自己的业务处理即可,注意message.toString()可以获取失效的key
-        String expiredKey = message.toString();
-        //继电器状态
-        if(expiredKey.startsWith(CacheDevice.RELAY_KEY.getRedisKey())){
-            //TODO 抛出事件
-            //得到 继电器编号
-
-            String s = StrUtil.subAfter(expiredKey, CacheDevice.RELAY_KEY.getRedisKey(), false);
-            logger.info("继电器离线:编号{}",s);
-            //创建离线对象
-            EquipmentStatus equipmentStatus = new EquipmentStatus();
-            equipmentStatus.setNum(s);
-            equipmentStatus.setHardwareOperate(HardwareOperate.OFFLINE);
-            //抛出继电器上下线切换事件
-            RelayHardwareStatusEvent relayHardwareStatusEvent = new RelayHardwareStatusEvent(equipmentStatus);
-            SpringUtils.getApplicationContext().publishEvent(relayHardwareStatusEvent);
-        }
-    }
-}

+ 0 - 33
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/event/RedisUpdateAndAddListener.java

@@ -1,33 +0,0 @@
-package com.zd.laboratory.event;
-
-import org.springframework.data.redis.connection.Message;
-import org.springframework.data.redis.connection.MessageListener;
-import org.springframework.data.redis.listener.PatternTopic;
-import org.springframework.stereotype.Component;
-
-/**
- * 暂时不使用
- * @Author: zhoupan
- * @Date: 2021/10/20/11:19
- * @Description:
- */
-//@Component
-public class RedisUpdateAndAddListener implements MessageListener {
-
-    //监听的主题  现在只监听0号数据库
-    private  final PatternTopic topic = new PatternTopic("__keyevent@0__:set");
-    //直接订阅key
-    private  final PatternTopic topic2 = new PatternTopic("__keyspace@0__:sss*");
-
-    @Override
-    public void onMessage(Message message, byte[] bytes) {
-        String topic = new String(bytes);
-        String msg = new String(message.getBody());
-        System.out.println("收到key更新或修改,消息主题是:"+ topic+",消息内容是:"+msg);
-    }
-
-
-    public PatternTopic getTopic() {
-        return topic;
-    }
-}

+ 7 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabBuildFloorLayoutMapper.java

@@ -80,4 +80,11 @@ public interface LabBuildFloorLayoutMapper {
      * @return 布局图集合
      */
     public List <Map <String,Object>> getLotStatis(LabBuildFloorLayout labBuildFloorLayout);
+
+    /**
+     * 根据实验室id查询实验室位置信息(楼栋-楼层-实验室名称)
+     * @Param [subId]
+     * @Return java.lang.String
+     **/
+    List<Map<String,Object>> getPositionBySubId(String subIds);
 }

+ 10 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabHardwareMapper.java

@@ -28,6 +28,12 @@ public interface LabHardwareMapper {
      */
     List<LabHardware> selectLabHardwareBySubIds(Long... ids);
 
+    /***
+     * 硬件查询
+     * @param hardware
+     * @return
+     */
+    List<LabHardware> selectLabHardwareByParameter(LabHardware hardware);
 
     /**
      * 查询硬件列表-根据实验室IDS(排除一键灭火类型)
@@ -158,4 +164,8 @@ public interface LabHardwareMapper {
      * @Return com.zd.laboratory.domain.LabHardware
      **/
     LabHardware selectLabHardwareCameraBySub(Long subId);
+
+    int selectCountByType(LabHardware labHardware);
+
+    String querySubNameById(Long hardId);
 }

+ 1 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabSecurityApplyMapper.java

@@ -124,7 +124,7 @@ public interface LabSecurityApplyMapper
      * @param labSecurityApply
      * @return
      */
-    public List<LabSecurityApplyVO> selectApplyListEffective(LabSecurityApply labSecurityApply);
+    public List<LabSecurityApplyVO> selectApplyListEffective(LabSecurityApplyVO labSecurityApply);
     /***
      * 校验申请时间是否有重叠
      * @param labSecurityApplyVO

+ 14 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabSparseHardwareMapper.java

@@ -83,9 +83,23 @@ public interface LabSparseHardwareMapper
     List<Map<String,Object>> selectListByFloorId(@Param("floorId") Long floorId, @Param("subId") Long subId, @Param("type") int type);
 
     /**
+     * 根据实验室id查询喇叭列表
+     * @param subId
+     * @return
+     */
+    List<Map<String,Object>> selectListBySubId(@Param("subId") Long subId);
+
+    /**
      * 根据楼层查询设备列表
      * @param floorId
      * @return
      */
     List<String> selectCameraByFloorId(Long floorId);
+
+    /**
+     * 查询喇叭总数
+     * @Param []
+     * @Return java.lang.Integer
+     **/
+    Integer selectSpeakerCount();
 }

+ 15 - 8
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabWarnPushMessageMapper.java

@@ -6,15 +6,15 @@ import com.zd.laboratory.domain.vo.LabWarnPushMessageVO;
 
 /**
  * 预警推送消息Mapper接口
- * 
+ *
  * @author zhoupan
  * @date 2021-10-06
  */
-public interface LabWarnPushMessageMapper 
+public interface LabWarnPushMessageMapper
 {
     /**
      * 查询预警推送消息
-     * 
+     *
      * @param id 预警推送消息主键
      * @return 预警推送消息
      */
@@ -22,7 +22,7 @@ public interface LabWarnPushMessageMapper
 
     /**
      * 查询预警推送消息列表
-     * 
+     *
      * @param labWarnPushMessage 预警推送消息
      * @return 预警推送消息集合
      */
@@ -36,8 +36,15 @@ public interface LabWarnPushMessageMapper
     public List<LabWarnPushMessageVO> selectLabWarnPushMessageVOList(Long riskGroup);
 
     /**
+     * 查询预警推送消息列表VO
+     *
+     * @return 预警推送消息集合
+     */
+    public List<LabWarnPushMessageVO> selectLabRiskLogVOList(Long riskGroup);
+
+    /**
      * 新增预警推送消息
-     * 
+     *
      * @param labWarnPushMessage 预警推送消息
      * @return 结果
      */
@@ -45,7 +52,7 @@ public interface LabWarnPushMessageMapper
 
     /**
      * 修改预警推送消息
-     * 
+     *
      * @param labWarnPushMessage 预警推送消息
      * @return 结果
      */
@@ -53,7 +60,7 @@ public interface LabWarnPushMessageMapper
 
     /**
      * 删除预警推送消息
-     * 
+     *
      * @param id 预警推送消息主键
      * @return 结果
      */
@@ -61,7 +68,7 @@ public interface LabWarnPushMessageMapper
 
     /**
      * 批量删除预警推送消息
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */

+ 19 - 3
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/config/MqttConfig.java

@@ -35,7 +35,8 @@ import org.springframework.integration.mqtt.support.MqttHeaders;
 import org.springframework.messaging.*;
 
 import javax.annotation.Resource;
-import java.nio.charset.StandardCharsets;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
@@ -202,8 +203,9 @@ public class MqttConfig {
     @Bean
     @ServiceActivator(inputChannel = MQTT_OUTBOUND_CHANNEL)
     public MessageHandler mqttOutbound() {
+        int num = new Random().nextInt(998)+1;
         MqttPahoMessageHandler messageHandler = new MqttPahoMessageHandler(
-                producerClientId,
+                producerClientId +"_"+ num,
                 mqttClientFactory());
         messageHandler.setAsync(true);
         messageHandler.setDefaultTopic(defaultTopic);
@@ -217,8 +219,9 @@ public class MqttConfig {
      */
     @Bean
     public MessageProducer inbound() {
+        int num = new Random().nextInt(98)+1;
         // 可同时消费(订阅)多个Topic
-        adapter = new MqttPahoMessageDrivenChannelAdapter(consumerClientId, mqttClientFactory(), StringUtils.split(defaultTopic, ","));
+        adapter = new MqttPahoMessageDrivenChannelAdapter(consumerClientId+num, mqttClientFactory(), StringUtils.split(defaultTopic, ","));
         adapter.setCompletionTimeout(5000);
         adapter.setConverter(new DefaultPahoMessageConverter());
         adapter.setQos(2);
@@ -286,6 +289,19 @@ public class MqttConfig {
                     if (receivedTopic.contains("788D4C6C6187ABC")) {
                         logger.info("[原始消息] - [{}]", message.getPayload());
                     }
+                    if ((message.getPayload() instanceof byte[])) {
+                        messageStr = "";
+                        try {
+                            ByteArrayInputStream bis  = new ByteArrayInputStream((byte[]) message.getPayload());
+                            byte[] buffer = new byte[1024];
+                            int len = -1;
+                            while((len = bis.read(buffer)) != -1){
+                                messageStr+= new String(buffer);
+                            }
+                        } catch (IOException e) {
+                           logger.error("传感器数据转换异常!");
+                        }
+                    }
                     String topicEnd = receivedTopic.substring(receivedTopic.lastIndexOf("/") + 1);
                     JSONObject jsonObject = JSONObject.parseObject(messageStr);
                     jsonObject.put("deviceNo", topicEnd);

+ 0 - 4
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/controller/MqttController.java

@@ -1,16 +1,12 @@
 package com.zd.laboratory.mqtt.controller;
 
-import com.alibaba.fastjson.JSONObject;
 import com.zd.model.enums.HardwareOperate;
 import com.zd.common.core.utils.SpringUtils;
 import com.zd.model.domain.ResultData;
-import com.zd.laboratory.domain.LabHardware;
-import com.zd.laboratory.event.RelayHardwareStatusEvent;
 import com.zd.laboratory.event.VideoHardwareStatusEvent;
 import com.zd.laboratory.mapper.LabHardwareMapper;
 import com.zd.laboratory.mqtt.MqttProducer;
 import com.zd.laboratory.mqtt.entiy.EquipmentStatus;
-import com.zd.laboratory.service.ILabHardwareService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 

+ 9 - 13
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mqtt/service/impl/SubMessageSendManager.java

@@ -7,7 +7,6 @@ import com.zd.algorithm.api.speaker.feign.RemoteSpeakService;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.utils.Assert;
 import com.zd.common.core.utils.SpringUtils;
-import com.zd.laboratory.api.entity.SensorFunctionStatus;
 import com.zd.laboratory.api.vo.SubFunction;
 import com.zd.laboratory.domain.LabHardware;
 import com.zd.laboratory.event.LabMessageEvent;
@@ -23,13 +22,12 @@ 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;
 import java.util.Optional;
 
-import java.util.*;
-
 /**
  * 实验室消息发送管理 -- 对外使用该类进行操作
  *
@@ -201,18 +199,16 @@ public class SubMessageSendManager {
             return;
         }
         //todo 这里是零时处理一下甲烷传感器没有上报describe 数据,这里先用funName代替describe,后期修复好了,在删除这块代码
-        List<SensorFunctionStatus> functionStatuses = subFunction.getFunctionStatuses();
-        List<SensorFunctionStatus> newFunctionStatuses = new ArrayList <>();
-        for(SensorFunctionStatus sensor:functionStatuses){
-            sensor.setDescribe(sensor.getFuncName());
-            newFunctionStatuses.add(sensor);
-        }
-        subFunction.setFunctionStatuses(newFunctionStatuses);
+//        List<SensorFunctionStatus> functionStatuses = subFunction.getFunctionStatuses();
+//        List<SensorFunctionStatus> newFunctionStatuses = new ArrayList <>();
+//        for(SensorFunctionStatus sensor:functionStatuses){
+//            sensor.setDescribe(sensor.getDescribe());
+//            newFunctionStatuses.add(sensor);
+//        }
+//        subFunction.setFunctionStatuses(newFunctionStatuses);
         //todo 到这里结束
-
-        //String json = JSONObject.toJSONString(subFunction);
-        //logger.error("@@@@@@@@" + json);
         //发送事件
+        logger.info("采集器数据接收={}",JSON.toJSONString(subFunction));
         //本来使用mqtt接收,因为mqtt 每个客户端接受到都会处理,
         List<LabMessageEvent> labMessageEvents = mqttConfig.getLabMessMap().get(MqttConstants.TOPIC_LAB_FUNCTION_DATA);
         if (CollUtil.isNotEmpty(labMessageEvents)) {

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

@@ -1,36 +0,0 @@
-package com.zd.laboratory.mqtt.test;
-
-import com.zd.laboratory.config.HardwareFunctionStatusConfig;
-import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
-import org.springframework.boot.context.event.ApplicationStartedEvent;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.annotation.Profile;
-import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter;
-import org.springframework.stereotype.Component;
-
-/**
- * @Author: zhoupan
- * @Date: 2021/10/08/13:09
- * @Description:
- */
-
-@Profile("dev")
-@Component
-public class MqttTest implements ApplicationListener<ApplicationStartedEvent> {
-
-
-
-    @Override
-    public void onApplicationEvent(ApplicationStartedEvent applicationStartedEvent) {
-//        MqttPahoMessageDrivenChannelAdapter messageProducer = (MqttPahoMessageDrivenChannelAdapter)applicationStartedEvent.getApplicationContext().getBeanFactory().getBean("inbound");
-//        //添加主题
-//        messageProducer.addTopic(MqttConstants.LAB_FUNCTION_DATA+-1L);
-//
-//        SubMessageSendManager bean = applicationStartedEvent.getApplicationContext().getBeanFactory().getBean(SubMessageSendManager.class);
-//        HardwareFunctionStatusConfig function = applicationStartedEvent.getApplicationContext().getBeanFactory().getBean(HardwareFunctionStatusConfig.class);
-//        //发送一个测试测点数据
-//        bean.sendFunctionUpdate(-1L,function.getSensorFunctionStatuses());
-
-
-    }
-}

+ 17 - 11
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/controller/OneMachineController.java

@@ -312,19 +312,23 @@ public class OneMachineController extends BaseController {
      * @return
      */
     private R<SysUser> getSysUserR(@PathVariable("username") String username) {
-        //查询卡号转换到16位后去数据库查询
-        if(StringUtils.isNumeric(username)) {
-            Long carNum10 = Long.parseLong(username);
-            String carNum16 = Long.toHexString(carNum10).toUpperCase();
-            username = carNum16;
-        }
+//        //查询卡号转换到16位后去数据库查询
+//        if(StringUtils.isNumeric(username)) {
+//            Long carNum10 = Long.parseLong(username);
+//            String carNum16 = Long.toHexString(carNum10).toUpperCase();
+//            username = carNum16;
+//        }
+        //通过des生成对称加密卡号
+        String desCardNum = DESUtils.encrypt(username);
+        username = desCardNum;
+
         // 查询用户信息
         R<SysUser> userResult = userService.getUserInfoByCardNum(username, SecurityConstants.INNER);
         if (HttpStatus.ERROR == userResult.getCode()) {
             throw new ServiceException(userResult.getMsg());
         }
         if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
-            throw new ServiceException("用户:" + username + " 不存在");
+            throw new ServiceException("用户卡号:" + username + " 不存在");
         }
         return userResult;
     }
@@ -353,10 +357,12 @@ public class OneMachineController extends BaseController {
                 url=fileConfigUtils.getRemoteUrl()+sysUser.getAvatar();
             }*/
             //通过配置动态加载域名
-            url = fileConfigUtils.getFileDomainApp() + sysUser.getAvatar();
-            url= UrlFormatUtils.getHttpsORHttpUrl(url);
-            logger.error("url:"+url);
-            sysUser.setAvatar(url);
+            if(sysUser.getAvatar()!=null && !"".equals(sysUser.getAvatar())){
+                url = fileConfigUtils.getFileDomainApp() + sysUser.getAvatar();
+                url= UrlFormatUtils.getHttpsORHttpUrl(url);
+                logger.error("url:"+url);
+                sysUser.setAvatar(url);
+            }
         }
         return getDataTable(sysList);
     }

+ 4 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/onemachine/service/OneMachineService.java

@@ -45,6 +45,7 @@ import javax.annotation.PostConstruct;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * 一体机服务
@@ -137,7 +138,7 @@ public class OneMachineService implements ValidationSignInPerInfo {
             //1、判断是否有安全准入资格,如没有准入资格进行提示(语音+浮层):验证失败,您需要通过小程序申请实验室准入资格后才能签到。
             if(UserConstants.USER_TYPE_STUDENT.equals(signInPerInfoVO.getSingInUser().getType())){
                 if (signInPerInfoVO.getSingInUser().getExpirationDate() != null) {
-                    if (!signInPerInfoVO.getSingInUser().getExpirationDate().after(DateUtils.getNowDate())) {
+                    if(signInPerInfoVO.getSingInUser().getExpirationDate().getTime() < DateUtils.dateTime(DateUtils.YYYY_MM_DD,DateUtils.getDate()).getTime()){
                         messages.add("您准入凭证已过期!您需要通过小程序重新申请实验室准入资格后才能签到。");
                     }
                 } else {
@@ -162,6 +163,7 @@ public class OneMachineService implements ValidationSignInPerInfo {
                     if (listapply.size()==0) {
                         messages.add("您未获取准入凭证!您需要通过小程序申请实验室准入资格后才能签到。");
                     }
+                     listapply.stream().filter(a->a.getAuditStatus()==2).collect(Collectors.toList());
                 }
             }else if("11".equals(signInPerInfoVO.getSingInUser().getType())){
 
@@ -352,6 +354,7 @@ public class OneMachineService implements ValidationSignInPerInfo {
                     //调用人脸验证
                     R r = faceCompare(user.getUserId(), face);
                     //验证失败刷新验证码时间
+                    logger.info("r.getCode():"+r.getCode());
                     if (r.getCode() != 200) {
                         return ResultData.fail(r.getMsg());
                     }

+ 6 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabBuildFloorLayoutService.java

@@ -1,7 +1,6 @@
 package com.zd.laboratory.service;
 
 import com.zd.laboratory.domain.LabBuildFloorLayout;
-import com.zd.laboratory.domain.LabExitLineVertex;
 import com.zd.laboratory.domain.vo.LabBuildFloorLayoutVo;
 
 import java.util.List;
@@ -65,4 +64,10 @@ public interface ILabBuildFloorLayoutService {
      */
     public Map <String,Object> getLotStatis(LabBuildFloorLayout labBuildFloorLayout);
 
+    /**
+     * 根据实验室id查询实验室位置信息(楼栋-楼层-实验室名称)
+     * @Param [subId 实验室id]
+     * @Return java.lang.String
+     **/
+    Map<Long,Map<String,Object>> getPositionBySubId(String subIds);
 }

+ 2 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabMessageContentService.java

@@ -89,4 +89,6 @@ public interface ILabMessageContentService {
      * @return 结果
      */
     public int outTimeClearMessage();
+
+    void readMsgContent(Long id);
 }

+ 14 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabSparseHardwareService.java

@@ -74,4 +74,18 @@ public interface ILabSparseHardwareService
      * @return
      */
     List<Map<String,Object>> selectSpeakerByFloorId(Long floorId, Long subId);
+
+    /**
+     * 根据实验室id查询喇叭列表
+     * @param subId
+     * @return
+     */
+    List<Map<String,Object>> selectSpeakerBySubId(Long subId);
+
+    /**
+     * 查询所有喇叭的数量
+     * @Param []
+     * @Return java.lang.Integer
+     **/
+    Integer selectSpeakerCount();
 }

+ 9 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/ILabWarnPushMessageService.java

@@ -25,6 +25,15 @@ public interface ILabWarnPushMessageService
      */
     public List<LabWarnPushMessageVO> selectLabWarnPushMessageList(Long riskGroup);
 
+
+    /**
+     * 查询预警推送消息列表
+     *
+     * @param riskGroup 风险分组ID
+     * @return 预警推送消息集合
+     */
+    public List<LabWarnPushMessageVO> selectLabRiskLogList(Long riskGroup);
+
     /**
      * 新增预警推送消息
      *

+ 18 - 5
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabBuildFloorLayoutServiceImpl.java

@@ -1,6 +1,5 @@
 package com.zd.laboratory.service.impl;
 
-import com.zd.common.core.utils.DictUtils;
 import com.zd.common.core.utils.StringUtils;
 import com.zd.laboratory.domain.LabBuildFloorLayout;
 import com.zd.laboratory.domain.LabExitLineVertex;
@@ -8,13 +7,13 @@ import com.zd.laboratory.domain.vo.LabBuildFloorLayoutVo;
 import com.zd.laboratory.mapper.LabBuildFloorLayoutMapper;
 import com.zd.laboratory.mapper.LabExitLineVertexMapper;
 import com.zd.laboratory.service.ILabBuildFloorLayoutService;
-import com.zd.system.api.entity.SysDictData;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Controller
@@ -88,4 +87,18 @@ public class LabBuildFloorLayoutServiceImpl implements ILabBuildFloorLayoutServi
         }
         return allMap;
     }
+
+    @Override
+    public Map<Long,Map<String,Object>> getPositionBySubId(String subIds) {
+        List<Map<String, Object>> positionBySubId = labBuildFloorLayoutMapper.getPositionBySubId(subIds);
+        if (positionBySubId.isEmpty()){
+            return new HashMap<>();
+        }
+        Map<Long,Map<String,Object>> map = new HashMap<>();
+        for (Map<String, Object> stringStringMap : positionBySubId) {
+            Long subId = (Long) stringStringMap.get("subId");
+            map.put(subId,stringStringMap);
+        }
+        return map;
+    }
 }

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

@@ -10,7 +10,6 @@ import com.zd.laboratory.api.feign.RemoteLaboratoryService;
 import com.zd.laboratory.domain.LabCheckRecord;
 import com.zd.laboratory.domain.LabCheckRecordDetails;
 import com.zd.laboratory.domain.LabCheckRecordRelease;
-import com.zd.laboratory.domain.LabSecurityApply;
 import com.zd.laboratory.domain.vo.LabCheckRecordVO;
 import com.zd.laboratory.domain.vo.LabSecurityApplyVO;
 import com.zd.laboratory.domain.vo.LabSubjectVO;
@@ -554,9 +553,9 @@ public class LabCheckRecordServiceImpl implements ILabCheckRecordService
             //循环发送消息-即将预期未整改的隐患项
             for (int i=0;i<list.size();i++){
                 //获取该实验室下准入资格未过期的学生申请集合
-                LabSecurityApply apply=new LabSecurityApply();
+                LabSecurityApplyVO apply=new LabSecurityApplyVO();
                 apply.setSubjectId(Long.valueOf(list.get(i).getLaboratoryId()) );
-                List<LabSecurityApplyVO> listapply=  LabSecurityApplyMapper.selectApplyListEffective(new LabSecurityApply());
+                List<LabSecurityApplyVO> listapply=  LabSecurityApplyMapper.selectApplyListEffective(apply);
                 String userIds="";//学生id集合
                 if(listapply.size()>0){
                     for (int k=0;k<listapply.size();k++){
@@ -591,9 +590,9 @@ public class LabCheckRecordServiceImpl implements ILabCheckRecordService
             //循环发送消息-即将预期未整改的隐患项
             for (int i=0;i<list3.size();i++){
                 //获取该实验室下准入资格未过期的学生申请集合
-                LabSecurityApply apply=new LabSecurityApply();
+                LabSecurityApplyVO apply=new LabSecurityApplyVO();
                 apply.setSubjectId(Long.valueOf(list3.get(i).getLaboratoryId()) );
-                List<LabSecurityApplyVO> listapply=  LabSecurityApplyMapper.selectApplyListEffective(new LabSecurityApply());
+                List<LabSecurityApplyVO> listapply=  LabSecurityApplyMapper.selectApplyListEffective(apply);
                 String userIds=""; //学生id集合
                 if(listapply.size()>0){
                     for (int k=0;k<listapply.size();k++){

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

@@ -18,6 +18,7 @@ import com.zd.laboratory.domain.vo.*;
 import com.zd.laboratory.mapper.*;
 import com.zd.laboratory.mqtt.service.impl.SubMessageSendManager;
 import com.zd.laboratory.service.ILabExitLineService;
+import com.zd.laboratory.service.ILabSparseHardwareService;
 import com.zd.laboratory.socket.command.Symbol;
 import com.zd.laboratory.socket.service.SocketService;
 import com.zd.model.constant.CacheConstants;
@@ -64,7 +65,8 @@ public class LabExitLineServiceImpl implements ILabExitLineService
     private LabAudioSynthesisMapper labAudioSynthesisMapper;
     @Autowired
     private RemoteSpeakService remoteSpeakService;
-
+    @Autowired
+    private ILabSparseHardwareService labSparseHardwareService;
     /**
      * 查询逃生线路主
      *
@@ -367,7 +369,9 @@ public class LabExitLineServiceImpl implements ILabExitLineService
             List<LabAudioSynthesis> audioSynList = labAudioSynthesisMapper.selectLabAudioSynthesisList(audioSyn);
             if(audioSynList.size()>0){
                 LabAudioSynthesis audioSyntheses = audioSynList.get(0);
-                R deviceList = remoteSpeakService.getDeviceList(1,100,5L);
+                Integer count = labSparseHardwareService.selectSpeakerCount();
+                logger.info("查询喇叭总数:{}",count);
+                R deviceList = remoteSpeakService.getDeviceList(1,count + 10,5L);
                 if(deviceList.getCode()==200){
                     List<Map<String,Object>> mapList = (List <Map <String, Object>>) deviceList.getData();
                     List<PlayVo> playVoList = new ArrayList<>();
@@ -521,7 +525,9 @@ public class LabExitLineServiceImpl implements ILabExitLineService
                 if(audioSynList.size()>0){
                     LabAudioSynthesis audioSyntheses = audioSynList.get(0);
                     //获取喇叭列表
-                    R deviceList = remoteSpeakService.getDeviceList(1,100, 5L);
+                    Integer count = labSparseHardwareService.selectSpeakerCount();
+                    logger.info("查询喇叭总数:{}",count);
+                    R deviceList = remoteSpeakService.getDeviceList(1,count + 10, 5L);
                     if(deviceList.getCode()==200){
                         List<Map<String,Object>> mapList = (List <Map <String, Object>>) deviceList.getData();
 

+ 49 - 10
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabExitLineVertexServiceImpl.java

@@ -3,14 +3,9 @@ package com.zd.laboratory.service.impl;
 import cn.hutool.core.date.StopWatch;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.TypeReference;
-import com.alibaba.fastjson.parser.Feature;
-import com.alibaba.nacos.shaded.org.checkerframework.checker.nullness.Opt;
 import com.zd.algorithm.api.speaker.entity.ParamVo;
 import com.zd.algorithm.api.speaker.entity.PlayVo;
 import com.zd.algorithm.api.speaker.feign.RemoteSpeakService;
-import com.zd.common.core.redis.RedisService;
 import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.utils.SaveUtil;
 import com.zd.common.core.utils.SecurityUtils;
@@ -20,6 +15,7 @@ import com.zd.laboratory.domain.*;
 import com.zd.laboratory.domain.vo.*;
 import com.zd.laboratory.mapper.*;
 import com.zd.laboratory.service.ILabExitLineVertexService;
+import com.zd.laboratory.service.ILabSparseHardwareService;
 import com.zd.laboratory.socket.command.Symbol;
 import com.zd.laboratory.socket.service.SocketService;
 import com.zd.model.domain.R;
@@ -78,6 +74,9 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
     @Autowired
     private LabHardwareStateMapper labHardwareStateMapper;
 
+    @Autowired
+    private ILabSparseHardwareService labSparseHardwareService;
+
 
     private static final Logger log = LoggerFactory.getLogger(LabExitLineVertexServiceImpl.class);
 
@@ -207,7 +206,7 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
         exitPointRelay.setBuildId(labExitLineEvacuationVo.getBuildId());
         exitPointRelay.setFloorId(labExitLineEvacuationVo.getFloorId());
         List <LabExitPointRelay> labExitPointRelays = labExitPointRelayMapper.selectLabExitPointRelayList(exitPointRelay);
-        //todo  开启继电器开关
+        //todo  关闭继电器开关
         for(LabExitPointRelay relay : labExitPointRelays) {
             try {
                 if (relay.getRelayType().intValue() == 1) {
@@ -223,6 +222,8 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
                 e.printStackTrace();
             }
         }
+        //todo 关闭喇叭
+        closeHorn(labExitLineEvacuationVo);
     }
 
     //todo 计算坏点(目前只有发生预案的实验室需要标记为坏点),需要把非坏点关联坏点点位全部改成无限大
@@ -238,7 +239,7 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
                 );
     }
 
-    //todo 计算坏点(目前只有发生预案的实验室需要标记为坏点),需要把非坏点关联坏点点位全部改成无限大
+    //todo 计算交通点,把所有关闭的逃生口,全部标记为通道
     public void crossPoints(List <LabExitLineJoinPointVO> newRelationalData, String badPointName) {
         //这里计算预案发生的实验室坏点
         Optional.ofNullable(newRelationalData).orElseGet(Collections::emptyList)
@@ -377,13 +378,15 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
             List<LabAudioSynthesis> audioSyntheses = labAudioSynthesisMapper.selectLabAudioSynthesisList(labAudioSynthesis);
             if(audioSyntheses.size()>0){
                 //预案调用喇叭
-                R deviceList = remoteSpeakService.getDeviceList(1,100,labExitLineEvacuationVo.getFloorId());
+                Integer count = labSparseHardwareService.selectSpeakerCount();
+                log.info("查询喇叭总数:{}",count);
+                R deviceList = remoteSpeakService.getDeviceList(1,count + 10,labExitLineEvacuationVo.getFloorId());
                 if(deviceList.getCode()==200){
+                    List<PlayVo> playVoList = new ArrayList<>();
                     List<Map<String,Object>> mapList = (List <Map <String, Object>>) deviceList.getData();
                     for(Map<String,Object> map:mapList){
                         log.info("喇叭日志============================="+map);
                         if(StringUtils.isNotNull(map.get("deviceSn")) && StringUtils.isNotNull(map.get("port"))){
-                            List<PlayVo> playVoList = new ArrayList<>();
                             PlayVo playVo = new PlayVo();
                             playVo.setSn(map.get("deviceSn")+"");
                             playVo.setDeviceIp(map.get("deviceIp")+"");
@@ -392,9 +395,9 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
                             paramVo.setVol(Integer.parseInt(map.get("deviceVol").toString()));
                             playVo.setParams(paramVo);
                             playVoList.add(playVo);
-                            remoteSpeakService.textParseUrlAppIps(audioSyntheses.get(0).getNewMusicUrl(),playVoList);
                         }
                     }
+                    remoteSpeakService.textMoreParseUrlAppIps(audioSyntheses.get(0).getNewMusicUrl(),playVoList,100);
                 }
             }
         }catch (Exception e){
@@ -403,6 +406,42 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
     }
 
 
+
+    /**
+     * 关闭喇叭播放音乐
+     *
+     * @param labExitLineEvacuationVo 楼栋和楼层的基础数据
+     */
+    public void closeHorn(LabExitLineEvacuationVo labExitLineEvacuationVo){
+        try{
+            //这里查询预案下的合成音乐
+            LabAudioSynthesis labAudioSynthesis = new LabAudioSynthesis();
+            labAudioSynthesis.setSceneType(2);
+            List<LabAudioSynthesis> audioSyntheses = labAudioSynthesisMapper.selectLabAudioSynthesisList(labAudioSynthesis);
+            if(audioSyntheses.size()>0){
+                //预案调用喇叭
+                Integer count = labSparseHardwareService.selectSpeakerCount();
+                log.info("查询喇叭总数:{}",count);
+                R deviceList = remoteSpeakService.getDeviceList(1,count + 10,labExitLineEvacuationVo.getFloorId());
+                if(deviceList.getCode()==200){
+                    List<Map<String,Object>> mapList = (List <Map <String, Object>>) deviceList.getData();
+                    for(Map<String,Object> map:mapList){
+                        if (StringUtils.isNotNull(map.get("deviceSn")) && StringUtils.isNotNull(map.get("port"))) {
+                            log.info("关闭喇叭-疏散调用喇叭播放音乐!url={},deviceSn={}", audioSyntheses.get(0).getNewMusicUrl(), map.get("deviceSn"));
+                            R r = remoteSpeakService.stopPlayMusic(map.get("deviceSn") + "", String.valueOf(map.get("deviceIp")));
+                            log.info("关闭喇叭-疏散调用喇叭播放音乐返回信息:{}", JSON.toJSONString(r));
+                        } else {
+                            log.info("关闭喇叭deviceSn/port为空!");
+                        }
+                    }
+                }
+            }
+        }catch (Exception e){
+            log.error("疏散关闭喇叭失败!!!!!:"+e);
+        }
+    }
+
+
     /**
      * 关联过滤线路
      *

+ 8 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabMessageContentServiceImpl.java

@@ -366,4 +366,12 @@ public class LabMessageContentServiceImpl implements ILabMessageContentService {
                 });
         return flag;
     }
+
+    @Override
+    public void readMsgContent(Long id) {
+        LabMessageContent labMessageContent = new LabMessageContent();
+        labMessageContent.setId(id);
+        labMessageContent.setIfRead(true);
+        labMessageContentMapper.updateLabMessageContent(labMessageContent);
+    }
 }

+ 44 - 41
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabMessageUserServiceImpl.java

@@ -3,6 +3,7 @@ package com.zd.laboratory.service.impl;
 
 import com.zd.common.core.security.TokenService;
 import com.zd.common.core.utils.DateUtils;
+import com.zd.common.core.utils.StringUtils;
 import com.zd.laboratory.api.entity.LabMessageUser;
 import com.zd.laboratory.api.vo.LabMessageUserListVO;
 import com.zd.laboratory.domain.LabMessageDynamic;
@@ -225,54 +226,56 @@ public class LabMessageUserServiceImpl implements ILabMessageUserService {
 //            map.put("listModel",listTemp);//模板
 //        }
 //        map.put("labSecurityApply",labSecurityApplyVO);//安全准入申请信息
-        map.put("applyId",labMessageDynamic.getDynamicId());//安全准入申请id
-        if(labMessageDynamic.getMessClass()==1){
-            //查询安全准入相关信息
-            LabSecurityApplyVO labSecurityApplyVO = labSecurityApplyMapper.selectLabSecurityApplyById(labMessageDynamic.getDynamicId());
-            R<SysUser> rDate =remoteUserService.getUserInfoByUserId(labSecurityApplyVO.getUserId(), SecurityConstants.INNER);
-            SysUser sysUser = rDate.getData();
-            labSecurityApplyVO.setSysUser(sysUser);
+        if(StringUtils.isNotNull(labMessageDynamic)){
+            map.put("applyId",labMessageDynamic.getDynamicId());//安全准入申请id
+            if(labMessageDynamic.getMessClass()==1){
+                //查询安全准入相关信息
+                LabSecurityApplyVO labSecurityApplyVO = labSecurityApplyMapper.selectLabSecurityApplyById(labMessageDynamic.getDynamicId());
+                R<SysUser> rDate =remoteUserService.getUserInfoByUserId(labSecurityApplyVO.getUserId(), SecurityConstants.INNER);
+                SysUser sysUser = rDate.getData();
+                labSecurityApplyVO.setSysUser(sysUser);
 
-            List<LabSecurityMaterialDataVO> listTemp=Collections.emptyList();//模板
-            //学生登录
-            if(UserConstants.USER_TYPE_STUDENT.equals(sysUser.getUserType())){
-                //模板查询
+                List<LabSecurityMaterialDataVO> listTemp=Collections.emptyList();//模板
+                //学生登录
+                if(UserConstants.USER_TYPE_STUDENT.equals(sysUser.getUserType())){
+                    //模板查询
 //            listModel =labSecurityMaterialDataMapper.selectLabSecurityMaterialDataStudent(labSecurityApplyVO.getSubjectId());
-                //模板查询
-                listTemp =labSecurityMaterialDataMapper.selectLabSecurityMaterialDataStudent(labSecurityApplyVO.getSubjectId());
-                for (int i=0;i<listTemp.size();i++){
-                    //如果是关联模板 查询出具体关联的内容
-                    if(1==listTemp.get(i).getMaterialType()){
-                        //上传材料查询
-                        LabSecurityMaterialrelation lmr = new LabSecurityMaterialrelation();
-                        lmr.setApplyId(labSecurityApplyVO.getId());
-                        lmr.setMaterialId(listTemp.get(i).getId());
-                        List<LabSecurityMaterialrelation>  list =labSecurityMaterialrelationMapper.selectLabSecurityMaterialrelationList(lmr);
-                        listTemp.get(i).setListMr(list);
+                    //模板查询
+                    listTemp =labSecurityMaterialDataMapper.selectLabSecurityMaterialDataStudent(labSecurityApplyVO.getSubjectId());
+                    for (int i=0;i<listTemp.size();i++){
+                        //如果是关联模板 查询出具体关联的内容
+                        if(1==listTemp.get(i).getMaterialType()){
+                            //上传材料查询
+                            LabSecurityMaterialrelation lmr = new LabSecurityMaterialrelation();
+                            lmr.setApplyId(labSecurityApplyVO.getId());
+                            lmr.setMaterialId(listTemp.get(i).getId());
+                            List<LabSecurityMaterialrelation>  list =labSecurityMaterialrelationMapper.selectLabSecurityMaterialrelationList(lmr);
+                            listTemp.get(i).setListMr(list);
+                        }
                     }
-                }
-                map.put("listModel",listTemp);//模板
-            }else if("11".equals(sysUser.getUserType())){
-                //教职工 模板查询
+                    map.put("listModel",listTemp);//模板
+                }else if("11".equals(sysUser.getUserType())){
+                    //教职工 模板查询
 //            listModel= labSecurityMaterialDataMapper.selectLabSecurityMaterialDataTeacher(labSecurityApplyVO.getSubjectId());
-                //教职工 模板查询
-                listTemp= labSecurityMaterialDataMapper.selectLabSecurityMaterialDataTeacher(labSecurityApplyVO.getSubjectId());
-                for (int i=0;i<listTemp.size();i++){
-                    //如果是关联模板 查询出具体关联的内容
-                    if(1==listTemp.get(i).getMaterialType()){
-                        //上传材料查询
-                        LabSecurityMaterialrelation lmr = new LabSecurityMaterialrelation();
-                        lmr.setApplyId(labSecurityApplyVO.getId());
-                        lmr.setMaterialId(listTemp.get(i).getId());
-                        List<LabSecurityMaterialrelation>  list =labSecurityMaterialrelationMapper.selectLabSecurityMaterialrelationList(lmr);
-                        listTemp.get(i).setListMr(list);
+                    //教职工 模板查询
+                    listTemp= labSecurityMaterialDataMapper.selectLabSecurityMaterialDataTeacher(labSecurityApplyVO.getSubjectId());
+                    for (int i=0;i<listTemp.size();i++){
+                        //如果是关联模板 查询出具体关联的内容
+                        if(1==listTemp.get(i).getMaterialType()){
+                            //上传材料查询
+                            LabSecurityMaterialrelation lmr = new LabSecurityMaterialrelation();
+                            lmr.setApplyId(labSecurityApplyVO.getId());
+                            lmr.setMaterialId(listTemp.get(i).getId());
+                            List<LabSecurityMaterialrelation>  list =labSecurityMaterialrelationMapper.selectLabSecurityMaterialrelationList(lmr);
+                            listTemp.get(i).setListMr(list);
+                        }
                     }
+                    map.put("listModel",listTemp);//模板
                 }
-                map.put("listModel",listTemp);//模板
+                map.put("labSecurityApply",labSecurityApplyVO);//安全准入申请信息
+            }else if(labMessageDynamic.getMessClass()==2){
+                map.put("dynamicId",labMessageDynamic.getDynamicId());//随手拍主键id
             }
-            map.put("labSecurityApply",labSecurityApplyVO);//安全准入申请信息
-        }else if(labMessageDynamic.getMessClass()==2){
-            map.put("dynamicId",labMessageDynamic.getDynamicId());//随手拍主键id
         }
         return map;
     }

+ 13 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabRiskPlanAbnormalLogServiceImpl.java

@@ -6,6 +6,7 @@ import com.zd.algorithm.api.alarm.entity.AlarmLog;
 import com.zd.common.core.annotation.DataScope;
 import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.utils.SecurityUtils;
+import com.zd.laboratory.api.entity.SensorFunctionStatus;
 import com.zd.laboratory.config.HardwareFunctionStatusConfig;
 import com.zd.laboratory.domain.*;
 import com.zd.laboratory.domain.vo.LabRiskPlanAbnormalLogVO;
@@ -74,7 +75,18 @@ public class LabRiskPlanAbnormalLogServiceImpl implements ILabRiskPlanAbnormalLo
     @Override
     @DataScope(deptAlias = "s", permi = PerPrefix.LABORATORY_PLANLOG)
     public List<LabRiskPlanAbnormalLog> selectLabRiskPlanAbnormalLogList(LabRiskPlanAbnormalLog labRiskPlanAbnormalLog) {
-        return labRiskPlanAbnormalLogMapper.selectLabRiskPlanAbnormalLogList(labRiskPlanAbnormalLog);
+        List<LabRiskPlanAbnormalLog> riskLogList = labRiskPlanAbnormalLogMapper.selectLabRiskPlanAbnormalLogList(labRiskPlanAbnormalLog);
+        for(LabRiskPlanAbnormalLog riskLog:riskLogList){
+            JSONArray json = JSONArray.parseArray(riskLog.getSensorJson());
+            if (json != null) {
+                for (int i = 0; i < json.size(); i++) {
+                    String describe = json.getJSONObject(i).get("describe")+"传感器:检测数值"+json.getJSONObject(i).get("value");
+                    riskLog.setRemark(describe);
+                }
+            }
+        }
+
+        return riskLogList;
     }
 
     /**

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

@@ -15,6 +15,7 @@ import com.zd.laboratory.service.LabRiskPlanLevelService;
 import com.zd.model.domain.ResultData;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -36,6 +37,7 @@ public class LabRiskPlanLevelServiceImpl extends ServiceImpl<LabRiskPlanLevelMap
     private ILabRiskPlanHardwareRelationService labRiskPlanHardwareRelationService;
 
     @Autowired
+    @Lazy
     private ILabRiskPlanService labRiskPlanService;
 
 
@@ -77,7 +79,7 @@ public class LabRiskPlanLevelServiceImpl extends ServiceImpl<LabRiskPlanLevelMap
             }
             labRiskPlanHardwareRelationService.saveBatch(riskPlanHardwareList);
         }
-        return ResultData.success(labRiskPlanLevel.getId());
+        return ResultData.success(labRiskPlanLevel.getId(),"预案规则新增成功");
     }
 
     @Override

+ 185 - 152
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabRiskPlanServiceImpl.java

@@ -47,6 +47,7 @@ import org.jetbrains.annotations.NotNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -114,6 +115,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
     private LabAudioSynthesisMapper labAudioSynthesisMapper;
 
     @Autowired
+    @Lazy
     private LabRiskPlanLevelService labRiskPlanLevelService;
 
     @Autowired
@@ -143,6 +145,9 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
     @Autowired
     private ILabBuildFloorLayoutService labBuildFloorLayoutService;
 
+    @Autowired
+    private ILabSparseHardwareService labSparseHardwareService;
+
     private static final Logger log = LoggerFactory.getLogger(LabRiskPlanServiceImpl.class);
 
 
@@ -654,19 +659,21 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 log.info("日志组id不为空时,预警消息记录,groupId = {}", groupId);
                 //记录通知
                 recordNotice(subFunction, labRiskPlanLevel, groupId);
-                //向前端发送mqtt预案触发提示
-                messageSendService.riskPlanTriggerNotice();
                 //打开喇叭
                 openLoudSpeaker(subFunction.getSubId(), labRiskPlanLevel.getFloorId(), labRiskPlanLevel.getRiskPlanId());
                 //远程调用开始录制视频接口
                 startVideo(subFunction.getSubId());
+                //向前端发送mqtt预案触发提示
+                messageSendService.riskPlanTriggerNotice();
+            }else {
+                log.info("已触发过预案跳过操作设备!");
             }
-
         } else {
             if (redisService.getCacheObject("subjectByYa" + subFunction.getSubId()) != null) {
+                log.info("预案缓存冗余时间,请等待...");
                 return flag;
             }
-            log.info("传感器触发关闭预案!实验室id={}",subFunction.getSubId());
+            log.info("传感器触发关闭预案!实验室id={}", subFunction.getSubId());
             for (LabRiskPlanAbnormalGroupVO groupVo : groupList) {
                 //更新结束预案日志
                 updateLogs(subFunction, groupVo);
@@ -765,7 +772,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 log.info("录制视频结束返回结果打印={}", JSON.toJSONString(r));
                 if (r.getCode() == HttpStatus.SUCCESS) {
                     com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(JSON.toJSONString(r.getData()));
-                    if(jsonObject.getInteger("code") == HttpStatus.SUCCESS){
+                    if (jsonObject.getInteger("code") == HttpStatus.SUCCESS) {
                         recordVideo = jsonObject.getString("data");
                     }
                 } else {
@@ -779,9 +786,9 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
         }
         //更新风险概要  recordVideo - 视频记录存放地址
         String handlePerson = "";
-        if(!Objects.isNull(tokenService.getLoginUser())){
+        if (!Objects.isNull(tokenService.getLoginUser())) {
             handlePerson = tokenService.getLoginUser().getNickName();
-        }else {
+        } else {
             handlePerson = "SYSTEM";
         }
         labRiskPlanAbnormalDescService.updateLabRiskPlanAbnormalDesc(groupId, handlePerson, recordVideo);
@@ -793,7 +800,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
      * @Param [subjectid 实验室id, floorId 楼层id, riskPlanId 预案id]
      * @Return void
      **/
-    private void closeLoudSpeaker(Long subjectid, Long floorId, Long riskPlanId) {
+    private void closeLoudSpeaker(Long subjectId, Long floorId, Long riskPlanId) {
         //预案关闭喇叭
         try {
             //这里查询预案下的合成音乐
@@ -802,15 +809,17 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
             List<LabAudioSynthesis> audioSyntheses = labAudioSynthesisMapper.selectLabAudioSynthesisList(labAudioSynthesis);
             log.info("关闭喇叭-查询的音乐列表信息 audioSyntheses= {}", JSON.toJSONString(audioSyntheses));
             if (audioSyntheses != null && audioSyntheses.size() > 0) {
-                log.info("关闭喇叭-远程调用查询喇叭列表,楼层id={},实验室id={}", floorId, subjectid);
-                R deviceList = remoteSpeakService.getDeviceList(1, 100, floorId, subjectid);
+                log.info("关闭喇叭-远程调用查询喇叭列表,楼层id={},实验室id={}", floorId, subjectId);
+                Integer count = labSparseHardwareService.selectSpeakerCount();
+                log.info("查询喇叭总数:{}",count);
+                R deviceList = remoteSpeakService.getDeviceList(1, count + 10, -99L, subjectId);
                 log.info("关闭喇叭-远程调用喇叭列表返回内容: deviceList={}", JSON.toJSONString(deviceList));
                 if (deviceList.getCode() == 200) {
                     List<Map<String, Object>> mapList = (List<Map<String, Object>>) deviceList.getData();
                     for (Map<String, Object> map : mapList) {
                         if (StringUtils.isNotNull(map.get("deviceSn")) && StringUtils.isNotNull(map.get("port"))) {
-                            log.info("关闭喇叭-远程调用喇叭播放音乐!url={},deviceSn={}", audioSyntheses.get(0).getNewMusicUrl(), map.get("deviceSn"));
-                            R r = remoteSpeakService.stopPlayMusic(map.get("deviceSn") + "", audioSyntheses.get(0).getNewMusicUrl());
+                            log.info("关闭喇叭-远程调用喇叭播放音乐!deviceSn={},deviceIp={}",map.get("deviceSn"), map.get("deviceIp"));
+                            R r = remoteSpeakService.stopPlayMusic(String.valueOf(map.get("deviceSn")), String.valueOf(map.get("deviceIp")));
                             log.info("关闭喇叭-远程调用喇叭播放音乐返回信息:{}", JSON.toJSONString(r));
                         } else {
                             log.info("关闭喇叭deviceSn/port为空!");
@@ -865,12 +874,16 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
      * @param labRiskPlanLevel
      */
     private void getFloorInfo(SubFunction<SensorFunctionStatus> subFunction, LabRiskPlanLevel labRiskPlanLevel) {
-        LabRiskPlan labRiskPlan = labRiskPlanMapper.selectLabRiskPlanByRiskPlanId(subFunction.getSubId());
-        LabBuildFloorLayout labBuildFloorLayout = new LabBuildFloorLayout();
-        labBuildFloorLayout.setSubId(subFunction.getSubId());
-        List<LabBuildFloorLayoutVo> list = labBuildFloorLayoutService.selectLabBuildFloorLayoutList(labBuildFloorLayout);
-        labRiskPlanLevel.setFloorId(list.get(0).getFloorId());
-        labRiskPlanLevel.setTopName(labRiskPlan.getTopName());
+        try {
+            LabRiskPlan labRiskPlan = labRiskPlanMapper.selectLabRiskPlanByRiskPlanId(subFunction.getSubId());
+            LabBuildFloorLayout labBuildFloorLayout = new LabBuildFloorLayout();
+            labBuildFloorLayout.setSubId(subFunction.getSubId());
+            List<LabBuildFloorLayoutVo> list = labBuildFloorLayoutService.selectLabBuildFloorLayoutList(labBuildFloorLayout);
+            labRiskPlanLevel.setFloorId(list.get(0).getFloorId());
+            labRiskPlanLevel.setTopName(labRiskPlan.getTopName());
+        } catch (Exception e) {
+            log.error("获取园区楼栋信息异常!{}", e);
+        }
     }
 
     /**
@@ -879,37 +892,45 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
      * @param labRiskPlanLevel
      */
     private void getConfigNoticeTemplate(LabRiskPlanLevel labRiskPlanLevel) {
-        //获取通知配置信息
-        List<LabNoticeconfig> noticeconfigList = labNoticeconfigMapper.selectLabNoticeconfigList(new LabNoticeconfig());
-        if (!noticeconfigList.isEmpty()) {
-            LabNoticeconfig labNoticeconfig = noticeconfigList.get(0);
-            StringBuffer radioStr = new StringBuffer();
-            radioStr.append(noticeconfigList.get(0).getRiskRadio());
-            labRiskPlanLevel.setMessage(labNoticeconfig.getRiskMessage());
-            labRiskPlanLevel.setVoicebroadcast(labNoticeconfig.getRiskVoice());
-            labRiskPlanLevel.setInformation(labNoticeconfig.getRiskPhone());
+        try {
+            //获取通知配置信息
+            List<LabNoticeconfig> noticeconfigList = labNoticeconfigMapper.selectLabNoticeconfigList(new LabNoticeconfig());
+            if (!noticeconfigList.isEmpty()) {
+                LabNoticeconfig labNoticeconfig = noticeconfigList.get(0);
+                StringBuffer radioStr = new StringBuffer();
+                radioStr.append(noticeconfigList.get(0).getRiskRadio());
+                labRiskPlanLevel.setMessage(labNoticeconfig.getRiskMessage());
+                labRiskPlanLevel.setVoicebroadcast(labNoticeconfig.getRiskVoice());
+                labRiskPlanLevel.setInformation(labNoticeconfig.getRiskPhone());
+            }
+        } catch (Exception e) {
+            log.error("获取通知配置信息异常!{}", e);
         }
     }
 
     @NotNull
     private JSONArray getSensorInfo(SubFunction<SensorFunctionStatus> subFunction, LabRiskPlanLevel labRiskPlanLevel) {
-        Map<SenseType, List<SensorFunctionStatus>> sensorFunctionStatusListMap = hardwareFunctionStatusConfig.getSensorFunctionStatusListMap();
-        //处理预案下的传感器翻译
         JSONArray riskPlanJson = new JSONArray();
-        StringBuffer sb = new StringBuffer();
-        for (LabRiskPlanSensorRelation rps : labRiskPlanLevel.getRiskPlanSensorList()) {
-            //硬件社保统一传入的传感器设备列表
-            for (SensorFunctionStatus sensorFunc : subFunction.getFunctionStatuses()) {
-                String funNum1 = sensorFunctionStatusListMap.get(SenseType.getByCode(rps.getSensorType())).get(0).getFunNum();
-                if (funNum1.equals(sensorFunc.getFunNum())) {
-                    getJsonStr(riskPlanJson, sensorFunc);
-                    labRiskPlanLevel.setTopName(labRiskPlanLevel.getTopName() + "-" + sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
-                    sb.append(sensorFunc.getDescribe()).append("、");
+        try {
+            Map<SenseType, List<SensorFunctionStatus>> sensorFunctionStatusListMap = hardwareFunctionStatusConfig.getSensorFunctionStatusListMap();
+            //处理预案下的传感器翻译
+            StringBuffer sb = new StringBuffer();
+            for (LabRiskPlanSensorRelation rps : labRiskPlanLevel.getRiskPlanSensorList()) {
+                //硬件社保统一传入的传感器设备列表
+                for (SensorFunctionStatus sensorFunc : subFunction.getFunctionStatuses()) {
+                    String funNum1 = sensorFunctionStatusListMap.get(SenseType.getByCode(rps.getSensorType())).get(0).getFunNum();
+                    if (funNum1.equals(sensorFunc.getFunNum())) {
+                        getJsonStr(riskPlanJson, sensorFunc);
+                        labRiskPlanLevel.setTopName(labRiskPlanLevel.getTopName() + "-" + sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
+                        sb.append(sensorFunc.getDescribe()).append("、");
+                    }
                 }
             }
-        }
-        if (StringUtils.isNotBlank(sb)) {
-            labRiskPlanLevel.setDescribe(sb.substring(0, sb.length() - 1) + "异常");
+            if (StringUtils.isNotBlank(sb)) {
+                labRiskPlanLevel.setDescribe(sb.substring(0, sb.length() - 1) + "异常");
+            }
+        } catch (Exception e) {
+            log.error("传感器数据翻译异常!{}", e);
         }
         return riskPlanJson;
     }
@@ -966,7 +987,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_EXIT);
             }
         } catch (Exception e) {
-            log.error("预案处理消息异常!{}",e);
+            log.error("预案处理消息异常!{}", e);
         }
     }
 
@@ -987,13 +1008,15 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
             if (audioSyntheses != null && audioSyntheses.size() > 0) {
                 //预案调用喇叭
                 log.info("打开喇叭-远程调用查询喇叭列表,楼层id={},实验室id={}", floorId, subjectId);
-                R deviceList = remoteSpeakService.getDeviceList(1, 100, floorId, subjectId);
+                Integer count = labSparseHardwareService.selectSpeakerCount();
+                log.info("查询喇叭总数:{}",count);
+                R deviceList = remoteSpeakService.getDeviceList(1, count + 10, -99L, subjectId);
                 log.info("打开喇叭-远程调用喇叭列表返回内容: deviceList={}", JSON.toJSONString(deviceList));
                 if (deviceList.getCode() == 200) {
+                    List<PlayVo> playVoList = new ArrayList<>();
                     List<Map<String, Object>> mapList = (List<Map<String, Object>>) deviceList.getData();
                     for (Map<String, Object> map : mapList) {
                         if (StringUtils.isNotNull(map.get("deviceSn")) && StringUtils.isNotNull(map.get("port"))) {
-                            List<PlayVo> playVoList = new ArrayList<>();
                             PlayVo playVo = new PlayVo();
                             playVo.setSn(map.get("deviceSn") + "");
                             playVo.setDeviceIp(map.get("deviceIp") + "");
@@ -1002,13 +1025,13 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                             paramVo.setVol(Integer.parseInt(map.get("deviceVol").toString()));
                             playVo.setParams(paramVo);
                             playVoList.add(playVo);
-                            log.info("打开喇叭-远程调用喇叭播放音乐!url={},playVoList={}", audioSyntheses.get(0).getNewMusicUrl(), JSON.toJSONString(playVoList));
-                            R r = remoteSpeakService.textParseUrlAppIps(audioSyntheses.get(0).getNewMusicUrl(), playVoList);
-                            log.info("打开喇叭-远程调用喇叭播放音乐返回信息:{}", JSON.toJSONString(r));
                         } else {
                             log.info("打开喇叭-喇叭deviceSn/port为空!");
                         }
                     }
+                    log.info("打开喇叭-远程调用喇叭播放音乐!url={},playVoList={}", audioSyntheses.get(0).getNewMusicUrl(), JSON.toJSONString(playVoList));
+                    R r = remoteSpeakService.textMoreParseUrlAppIps(audioSyntheses.get(0).getNewMusicUrl(), playVoList,100);
+                    log.info("打开喇叭-远程调用喇叭播放音乐返回信息:{}", JSON.toJSONString(r));
                 } else {
                     log.info("打开喇叭-远程查询喇叭信息错误!");
                 }
@@ -1016,7 +1039,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 log.info("打开喇叭-合成音乐列表为空,此预案不触发音乐!riskPlanId={}", riskPlanId);
             }
         } catch (Exception e) {
-            log.error("开启喇叭异常!{}",e);
+            log.error("开启喇叭异常!{}", e);
         }
     }
 
@@ -1029,7 +1052,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
     private void startVideo(Long subjectId) {
         try {
             LabHardware labHardware = labHardwareService.selectLabHardwareCameraBySub(subjectId);
-            if (labHardware != null || labHardware.getIpAddress() != null) {
+            if (labHardware != null && labHardware.getIpAddress() != null) {
                 //开始录制视频
                 log.info("远程调用开始录制视频ip地址={}", labHardware.getIpAddress());
                 remoteCameraService.stopRecord(labHardware.getIpAddress());
@@ -1037,14 +1060,14 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 log.info("开始录制视频返回结果打印={}", JSON.toJSONString(r));
                 if (r.getCode() == HttpStatus.SUCCESS) {
                     log.info("开始录制视频成功!");
-                }else {
+                } else {
                     log.info("开始录制视频失败!");
                 }
-            }else {
+            } else {
                 log.info("未查询到实验室关联摄像头信息!请检查ip是否为空!");
             }
         } catch (Exception e) {
-            log.error("远程调用开始录制视频接口失败!{}", e);
+            log.error("远程调用开始录制视频接口异常!{}", e);
         }
     }
 
@@ -1058,7 +1081,6 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 messageSendService.sendWranFunctionToSub(subFunction.getSubId());
                 //首页预案流程通知
                 messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_GROUP);
-                messageSendService.riskPlanTriggerNotice();
                 messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_LOG);
                 //首页预案是否同步疏散线路
                 messageSendService.SendBigViewUpdate(BigViewDataType.SUB_RISKPLAN_EXIT);
@@ -1070,14 +1092,16 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 updateLogs(subFunction, groupVo);
             }
         } catch (Exception e) {
-            log.error("手动关闭火焰预案发生异常!{}",e);
+            log.error("手动关闭火焰预案发生异常!{}", e);
         } finally {
             //删除火焰报警的redis验证,这样其他传感器上报预案就能执行了
-            redisService.deleteObject("subjectByHuoyan"+subFunction.getSubId());
+            redisService.deleteObject("subjectByHuoyan" + subFunction.getSubId());
             //删除预案升级火焰预案时,基本预案缓存
             if (redisService.getCacheObject("subjectByYa" + subFunction.getSubId()) != null) {
                 redisService.deleteObject("subjectByYa" + subFunction.getSubId());
             }
+            //向前端发送预案关闭
+            messageSendService.riskPlanTriggerNotice();
         }
         return 0;
     }
@@ -1114,90 +1138,108 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
 
 
     public Long insertPlanAbnormalLog(LabRiskPlanLevel labRiskPlanLevel, JSONArray riskPlanJson, List<LabRiskPlanAbnormalGroupVO> groupList, Long riskStatus, SubFunction<SensorFunctionStatus> subFunction, Integer riskAttribute) {
-        LabRiskPlanAbnormalGroup labRiskPlanAbnormalGroup;
-        Long groupId;
-        //将风险预案写入日志表
-        LabRiskPlanAbnormalLog labRiskPlanAbnormalLog = new LabRiskPlanAbnormalLog();
-        labRiskPlanAbnormalLog.setRiskPlanId(labRiskPlanLevel.getRiskPlanId());
-        labRiskPlanAbnormalLog.setRiskPlanName(labRiskPlanLevel.getRiskName());
-        labRiskPlanAbnormalLog.setCreateTime(new Date());
-        labRiskPlanAbnormalLog.setSensorJson(riskPlanJson.toString());
-        labRiskPlanAbnormalLog.setRiskStatus(riskStatus);
-        labRiskPlanAbnormalLog.setSubjectId(subFunction.getSubId());
-        labRiskPlanAbnormalLog.setRiskAttribute(labRiskPlanLevel.getRiskAttribute());
-        labRiskPlanAbnormalLog.setRiskPlanLevelId(labRiskPlanLevel.getId());
-        labRiskPlanAbnormalLog.setRiskPlanLevelName(RiskPlanLevelEnum.getValue(labRiskPlanLevel.getRiskPlanLevel()));
-        labRiskPlanAbnormalLog.setRiskPlanLevel(labRiskPlanLevel.getRiskPlanLevel());
-        if (groupList == null || groupList.size() == 0) {
-            labRiskPlanAbnormalGroup = insertPlanAbnormalGroup(labRiskPlanLevel, subFunction.getSubId(), riskAttribute, labRiskPlanLevel.getRiskPlanLevel());
-            groupId = labRiskPlanAbnormalGroup.getId();
-            //给风险日志表关联组
-            labRiskPlanAbnormalLog.setGroupId(labRiskPlanAbnormalGroup.getId());
-            //处理预案下的传感器翻译
-            for (LabRiskPlanSensorRelation rps : labRiskPlanLevel.getRiskPlanSensorList()) {
-                //硬件社保统一传入的传感器设备列表
-                for (SensorFunctionStatus sensorFunc : subFunction.getFunctionStatuses()) {
-                    if (rps.getFunNum().equals(sensorFunc.getFunNum())) {
-                        if (StringUtils.isNotNull(labRiskPlanAbnormalLog.getRemark())) {
-                            labRiskPlanAbnormalLog.setRemark(labRiskPlanAbnormalLog.getRemark() + " " + sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
-                        } else {
-                            labRiskPlanAbnormalLog.setRemark(sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
+        try {
+            LabRiskPlanAbnormalGroup labRiskPlanAbnormalGroup;
+            Long groupId;
+            //将风险预案写入日志表
+            LabRiskPlanAbnormalLog labRiskPlanAbnormalLog = new LabRiskPlanAbnormalLog();
+            labRiskPlanAbnormalLog.setRiskPlanId(labRiskPlanLevel.getRiskPlanId());
+            labRiskPlanAbnormalLog.setRiskPlanName(labRiskPlanLevel.getRiskName());
+            labRiskPlanAbnormalLog.setCreateTime(new Date());
+            labRiskPlanAbnormalLog.setSensorJson(riskPlanJson.toString());
+            labRiskPlanAbnormalLog.setRiskStatus(riskStatus);
+            labRiskPlanAbnormalLog.setSubjectId(subFunction.getSubId());
+            labRiskPlanAbnormalLog.setRiskAttribute(labRiskPlanLevel.getRiskAttribute());
+            labRiskPlanAbnormalLog.setRiskPlanLevelId(labRiskPlanLevel.getId());
+            labRiskPlanAbnormalLog.setRiskPlanLevelName(RiskPlanLevelEnum.getValue(labRiskPlanLevel.getRiskPlanLevel()));
+            labRiskPlanAbnormalLog.setRiskPlanLevel(labRiskPlanLevel.getRiskPlanLevel());
+            if (groupList == null || groupList.size() == 0) {
+                labRiskPlanAbnormalGroup = insertPlanAbnormalGroup(labRiskPlanLevel, subFunction.getSubId(), riskAttribute, labRiskPlanLevel.getRiskPlanLevel());
+                groupId = labRiskPlanAbnormalGroup.getId();
+                //给风险日志表关联组
+                labRiskPlanAbnormalLog.setGroupId(labRiskPlanAbnormalGroup.getId());
+                //处理预案下的传感器翻译
+                for (LabRiskPlanSensorRelation rps : labRiskPlanLevel.getRiskPlanSensorList()) {
+                    //硬件社保统一传入的传感器设备列表
+                    for (SensorFunctionStatus sensorFunc : subFunction.getFunctionStatuses()) {
+                        if (rps.getFunNum().equals(sensorFunc.getFunNum())) {
+                            if (StringUtils.isNotNull(labRiskPlanAbnormalLog.getRemark())) {
+                                labRiskPlanAbnormalLog.setRemark(labRiskPlanAbnormalLog.getRemark() + " " + sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
+                            } else {
+                                labRiskPlanAbnormalLog.setRemark(sensorFunc.getDescribe() + ":" + sensorFunc.getVal());
+                            }
                         }
                     }
                 }
-            }
-            //插入风险日志
-            labRiskPlanAbnormalLogMapper.insertLabRiskPlanAbnormalLog(labRiskPlanAbnormalLog);
-            // 后面放入老柴的事件中 或者订阅老柴的事件处理
-            //增加预警缓存
-            Optional.ofNullable(labRiskPlanLevel.getRiskPlanSensorList()).ifPresent(f -> {
-                Set<String> funSet = labRiskPlanLevel.getRiskPlanSensorList().stream().map(d -> d.getFunNum()).collect(Collectors.toSet());
-                redisService.setCacheSetV2(BaseConstants.WRAN_KEY + subFunction.getSubId(), funSet);
-            });
-            try {
-                //插入风险硬件日志
-                operateHardWareInfo(labRiskPlanLevel, labRiskPlanAbnormalGroup.getSubjectId(), labRiskPlanAbnormalLog.getGroupId(), riskPlanJson.toString());
-            } catch (Exception e) {
-                log.error("操作硬件设备异常::::" + e);
-            } finally {
-                return groupId;
-            }
-        } else {
-            labRiskPlanAbnormalGroup = groupList.get(0);
-            //如果查询到是当前组,那么就给日志表插入的时候,补上组id
-            labRiskPlanAbnormalLog.setGroupId(labRiskPlanAbnormalGroup.getId());
-            //查询风险日志,启动的预案是不是同一个,如果不是,执行插入日志
-            LabRiskPlanAbnormalLog labRiskPlanAbnormalLogByGroupId = new LabRiskPlanAbnormalLog();
-            labRiskPlanAbnormalLogByGroupId.setGroupId(groupList.get(0).getId());
-            List<LabRiskPlanAbnormalLog> newPlanAbnormalLogList = labRiskPlanAbnormalLogMapper.selectLabRiskPlanAbnormalLogOrderByList(labRiskPlanAbnormalLogByGroupId);
-            if (newPlanAbnormalLogList.size() > 0) {
-                LabRiskPlanAbnormalLog checkLog = newPlanAbnormalLogList.get(0);
-                //判断如果当前传感器匹配预案和日志表的预案相同,则不插入日志。过滤重复预案
-                if (!labRiskPlanLevel.getId().equals(checkLog.getRiskPlanLevelId())) {
-                    //这里调用旧预案结束动作的方法
-                    overRiskPlanAction(checkLog.getRiskPlanId(), checkLog.getSubjectId());
-                    groupId = labRiskPlanAbnormalGroup.getId();
-                    //插入风险日志
-                    labRiskPlanAbnormalLogMapper.insertLabRiskPlanAbnormalLog(labRiskPlanAbnormalLog);
-                    try {
-                        //插入风险硬件日志
-                        operateHardWareInfo(labRiskPlanLevel, labRiskPlanAbnormalGroup.getSubjectId(), groupList.get(0).getId(), riskPlanJson.toString());
-                        //todo 后面放入老柴的事件中 或者订阅老柴的事件处理
-                        //增加预警缓存
-                        Optional.ofNullable(labRiskPlanLevel.getRiskPlanSensorList()).ifPresent(f -> {
-                            Set<String> funSet = labRiskPlanLevel.getRiskPlanSensorList().stream().map(d -> d.getFunNum()).collect(Collectors.toSet());
-                            redisService.setCacheSetV2(BaseConstants.WRAN_KEY + subFunction.getSubId(), funSet);
-                        });
-                    } catch (Exception e) {
-                        log.error("操作硬件设备异常::::" + e);
-                    } finally {
-                        return groupId;
+                //插入风险日志
+                labRiskPlanAbnormalLog.setRiskPlanName("发生预案:" + labRiskPlanAbnormalLog.getRiskPlanName());
+                labRiskPlanAbnormalLogMapper.insertLabRiskPlanAbnormalLog(labRiskPlanAbnormalLog);
+                // 后面放入老柴的事件中 或者订阅老柴的事件处理
+                //增加预警缓存
+                Optional.ofNullable(labRiskPlanLevel.getRiskPlanSensorList()).ifPresent(f -> {
+                    Set<String> funSet = labRiskPlanLevel.getRiskPlanSensorList().stream().map(d -> d.getFunNum()).collect(Collectors.toSet());
+                    redisService.setCacheSetV2(BaseConstants.WRAN_KEY + subFunction.getSubId(), funSet);
+                });
+                try {
+                    //插入风险硬件日志
+                    operateHardWareInfo(labRiskPlanLevel, labRiskPlanAbnormalGroup.getSubjectId(), labRiskPlanAbnormalLog.getGroupId(), riskPlanJson.toString());
+                } catch (Exception e) {
+                    log.error("操作硬件设备异常::::" + e);
+                } finally {
+                    return groupId;
+                }
+            } else {
+                labRiskPlanAbnormalGroup = groupList.get(0);
+                //如果查询到是当前组,那么就给日志表插入的时候,补上组id
+                labRiskPlanAbnormalLog.setGroupId(labRiskPlanAbnormalGroup.getId());
+                //查询风险日志,启动的预案是不是同一个,如果不是,执行插入日志
+                LabRiskPlanAbnormalLog labRiskPlanAbnormalLogByGroupId = new LabRiskPlanAbnormalLog();
+                labRiskPlanAbnormalLogByGroupId.setGroupId(groupList.get(0).getId());
+                List<LabRiskPlanAbnormalLog> newPlanAbnormalLogList = labRiskPlanAbnormalLogMapper.selectLabRiskPlanAbnormalLogOrderByList(labRiskPlanAbnormalLogByGroupId);
+                if (newPlanAbnormalLogList.size() > 0) {
+                    LabRiskPlanAbnormalLog checkLog = newPlanAbnormalLogList.get(0);
+                    //判断如果当前传感器匹配预案和日志表的预案相同,则不插入日志。过滤重复预案
+                    if (!labRiskPlanLevel.getId().equals(checkLog.getRiskPlanLevelId())) {
+                        //这里调用旧预案结束动作的方法
+                        overRiskPlanAction(checkLog.getRiskPlanId(), checkLog.getSubjectId());
+                        groupId = labRiskPlanAbnormalGroup.getId();
+                        if (labRiskPlanLevel.getRiskPlanId().equals(checkLog.getRiskPlanId())) {
+                            if (labRiskPlanLevel.getRiskPlanLevel() > checkLog.getRiskPlanLevel()) {
+                                //升级
+                                labRiskPlanAbnormalLog.setRiskPlanName("预案升级:" + labRiskPlanAbnormalLog.getRiskPlanName());
+                            }
+                            if (labRiskPlanLevel.getRiskPlanLevel() < checkLog.getRiskPlanLevel()) {
+                                //降级
+                                labRiskPlanAbnormalLog.setRiskPlanName("预案降级:" + labRiskPlanAbnormalLog.getRiskPlanName());
+                            }
+                        } else {
+                            labRiskPlanAbnormalLog.setRiskPlanName("预案变更:" + labRiskPlanAbnormalLog.getRiskPlanName());
+                        }
+                        //插入风险日志
+                        labRiskPlanAbnormalLogMapper.insertLabRiskPlanAbnormalLog(labRiskPlanAbnormalLog);
+                        try {
+                            //插入风险硬件日志
+                            operateHardWareInfo(labRiskPlanLevel, labRiskPlanAbnormalGroup.getSubjectId(), groupList.get(0).getId(), riskPlanJson.toString());
+                            //todo 后面放入老柴的事件中 或者订阅老柴的事件处理
+                            //增加预警缓存
+                            Optional.ofNullable(labRiskPlanLevel.getRiskPlanSensorList()).ifPresent(f -> {
+                                Set<String> funSet = labRiskPlanLevel.getRiskPlanSensorList().stream().map(d -> d.getFunNum()).collect(Collectors.toSet());
+                                redisService.setCacheSetV2(BaseConstants.WRAN_KEY + subFunction.getSubId(), funSet);
+                            });
+                        } catch (Exception e) {
+                            log.error("操作硬件设备异常::::" + e);
+                        } finally {
+                            return groupId;
+                        }
                     }
                 }
+                //插入风险日志
+                return null;
             }
-            //插入风险日志
-            return null;
+        } catch (Exception e) {
+            log.error("插入风险日志异常!{}", e);
         }
+        return null;
     }
 
     public void insertPlanAbnormalLogByHard(LabRiskPlanLevel labRiskPlanLevel, LabRiskPlanHardwareRelation hardRelation, Long subjectId, Long groupId, String riskPlanJson) {
@@ -1273,10 +1315,10 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
     }
 
 
-    public void insertPlanAbnormalLogByOver(LabRiskPlanAbnormalGroup groupVo, JSONArray allRiskPlanJson, SubFunction<SensorFunctionStatus> subFunction) {
+    public void insertPlanAbnormalLogByOver(LabRiskPlanAbnormalGroupVO groupVo, JSONArray allRiskPlanJson, SubFunction<SensorFunctionStatus> subFunction) {
         //将风险预案写入日志表
         LabRiskPlanAbnormalLog labRiskPlanAbnormalLog = new LabRiskPlanAbnormalLog();
-        labRiskPlanAbnormalLog.setRiskPlanId(groupVo.getId());
+        labRiskPlanAbnormalLog.setRiskPlanId(groupVo.getRiskPlanId());
         labRiskPlanAbnormalLog.setRiskPlanName("风险解除");
         labRiskPlanAbnormalLog.setSubjectId(subFunction.getSubId());
         labRiskPlanAbnormalLog.setCreateTime(new Date());
@@ -1309,7 +1351,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                 }
             });
         } catch (Exception e) {
-            log.error("一键灭火插入日志异常!{}",e);
+            log.error("一键灭火插入日志异常!{}", e);
         }
     }
 
@@ -1333,15 +1375,8 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                     labHardware.setSubjectId(subjectId);
                     labHardware.setType(HardwareTypeEnum.getByCode(riskPlanHardwareList.get(i).getHardwareType()));
                     List<LabHardware> hardwareList = labHardwareMapper.selectLabHardwareListBySubject(labHardware);
-                    //循环执行实验室下的硬件功能
-                    for (LabHardware hard : hardwareList) {
-                        ResultData result = labSubjectManagerService.excutingComm(hard, status);
-                        try {
-                            Thread.sleep(300);
-                        } catch (InterruptedException e) {
-                            e.printStackTrace();
-                        }
-                    }
+                    //异步循环执行实验室下的硬件功能
+                    labSubjectManagerService.operationHardware(status, hardwareList);
                 }
             }
             log.error("打开硬件记录风险日志");
@@ -1369,15 +1404,12 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
                     labHardware.setSubjectId(subjectId);
                     labHardware.setType(HardwareTypeEnum.getByCode(riskPlanHardwareList.get(i).getHardwareType()));
                     List<LabHardware> hardwareList = labHardwareMapper.selectLabHardwareListBySubject(labHardware);
-                    //循环执行实验室下的硬件功能
-                    for (LabHardware hard : hardwareList) {
-                        labSubjectManagerService.excutingComm(hard, status);
-                        try {
-                            Thread.sleep(300);
-                        } catch (InterruptedException e) {
-                            e.printStackTrace();
-                        }
+                    if (hardwareList.isEmpty()) {
+                        log.info("查询实验室硬件信息为空,跳过此实验室!subjectId={}",subjectId);
+                        continue;
                     }
+                    //异步循环执行实验室下的硬件功能
+                    labSubjectManagerService.operationHardware(status,hardwareList);
                 }
             }
         }
@@ -1496,6 +1528,7 @@ public class LabRiskPlanServiceImpl extends ServiceImpl<LabRiskPlanMapper, LabRi
         List<LabRiskPlanDTO> list = labRiskPlanMapper.queryRiskPlanList(riskPlan);
         return list;
     }
+
     @Override
     public List<LabSubjectVO> getLabRiskPlanJoinSubInfo(LabRiskPlanSubVo labRiskPlanSubVo) {
         //通过传感器字符串和预案id查询相关实验室列表

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

@@ -243,7 +243,6 @@ public class LabSecurityApplyServiceImpl implements ILabSecurityApplyService
             ){
                 //更新用户信息
                 AjaxResult ajax=remoteUserService.editStudent(labSecurityApplyVO.getSysUser());
-                System.out.println(ajax);
                 String str = JSON.toJSONString(ajax);
                 JSONObject json = JSON.parseObject(str);
                 if(500==json.getInteger("code")){

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

@@ -147,7 +147,7 @@ public class LabSensorServiceImpl implements ILabSensorService {
         Object subjectStr=redisService.getCacheObject(getKey(GatewayNum));
         Long subId=null;
         if(null!=subjectStr && !"".equals(subjectStr) ){
-            logger.error("num:"+GatewayNum+"subjectStr:"+subjectStr);
+            //logger.error("num:"+GatewayNum+"subjectStr:"+subjectStr);
             subId=Long.parseLong(subjectStr.toString());
         }
 
@@ -204,7 +204,7 @@ public class LabSensorServiceImpl implements ILabSensorService {
             subId=aLong;
             redisService.setCacheObject(getKey(GatewayNum),aLong,5L, TimeUnit.MINUTES);
         }
-        logger.error("num:"+GatewayNum+"subId:"+subId);
+        //logger.error("num:"+GatewayNum+"subId:"+subId);
         return subId;
     }
 
@@ -218,9 +218,6 @@ public class LabSensorServiceImpl implements ILabSensorService {
     @Override
     public int updateLabSensor(LabSensor labSensor) {
         labSensor.setUpdateTime(DateUtils.getNowDate());
-
-
-
         LabSensor old = labSensorMapper.selectLabSensorById(labSensor.getId());
         int i = labSensorMapper.updateLabSensor(labSensor);
         if(i==1)

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

@@ -1,12 +1,10 @@
 package com.zd.laboratory.service.impl;
 
-import com.zd.model.domain.per.PerPrefix;
 import com.zd.common.core.exception.ServiceException;
 import com.zd.common.core.utils.DateUtils;
+import com.zd.common.core.utils.SaveUtil;
 import com.zd.common.core.utils.SecurityUtils;
 import com.zd.common.core.utils.StringUtils;
-import com.zd.common.core.annotation.DataScope;
-import com.zd.common.core.utils.SaveUtil;
 import com.zd.laboratory.domain.LabSparseHardware;
 import com.zd.laboratory.mapper.LabSparseHardwareMapper;
 import com.zd.laboratory.service.ILabSparseHardwareService;
@@ -117,4 +115,14 @@ public class LabSparseHardwareServiceImpl implements ILabSparseHardwareService {
     public List<Map<String,Object>> selectSpeakerByFloorId(Long floorId, Long subId) {
         return labSparseHardwareMapper.selectListByFloorId(floorId, subId,2);
     }
+
+    @Override
+    public List<Map<String,Object>> selectSpeakerBySubId(Long subId) {
+        return labSparseHardwareMapper.selectListBySubId(subId);
+    }
+
+    @Override
+    public Integer selectSpeakerCount() {
+        return labSparseHardwareMapper.selectSpeakerCount();
+    }
 }

+ 35 - 11
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectManagerService.java

@@ -18,6 +18,7 @@ import com.zd.laboratory.api.vo.HardwareCVO;
 import com.zd.laboratory.api.vo.LabSubClassVO;
 import com.zd.laboratory.api.vo.SenseValVO;
 import com.zd.laboratory.config.HardwareFunctionStatusConfig;
+import com.zd.laboratory.config.TimeWaitConfigUtils;
 import com.zd.laboratory.domain.*;
 import com.zd.laboratory.domain.dto.LabSubListQuery;
 import com.zd.laboratory.domain.vo.*;
@@ -115,13 +116,27 @@ public class LabSubjectManagerService {
     private SocketService socketService;
     @Autowired
     private ILabControlService labControlService;
-
+    @Autowired
+    private TimeWaitConfigUtils timeWaitConfigUtils;
 
     public LabSubjectManagerService(List<ControlService> controlServices) {
         controlServiceMap = controlServices.stream().collect(Collectors.toMap(a -> a.comTypeEnums(), Function.identity()));
 
     }
 
+//    @Async("labExecutor")
+    public void operationHardware(FunctionStatus status, List<LabHardware> hardwareList) {
+        try {
+            logger.info("异步线程处理硬件信息:id={},name={}",Thread.currentThread().getId(),Thread.currentThread().getName());
+            for (LabHardware hard : hardwareList) {
+                ResultData result = excutingComm(hard, status);
+                Thread.sleep(timeWaitConfigUtils.getWaitTime());
+            }
+        } catch (InterruptedException e) {
+            logger.error("异步处理硬件异常!",e);
+        }
+    }
+
     /**
      * 设备-执行命令
      *
@@ -164,7 +179,7 @@ public class LabSubjectManagerService {
             return ResultData.fail("继电器指令错误!!");
         }
 
-        logger.info("预案调用硬件,硬件id={},硬件指令={}",labHardware.getId(), JSON.toJSONString(command));
+        logger.info("预案调用硬件,硬件id={},硬件名称={},硬件指令={}",labHardware.getId(), JSON.toJSONString(labHardware.getName()),JSON.toJSONString(command));
         return ResultData.success(control(labHardware.getId(), command));
 
         //老继电器调用方法
@@ -349,11 +364,12 @@ public class LabSubjectManagerService {
         List<String> newDictDatas = new ArrayList<>();
         if(StringUtils.isNotBlank(subject.getCheckOut())){
             newDictDatas = Optional.ofNullable(subject.getCheckOut()).map(b -> b.split(",")).map(b -> Arrays.asList(b))
-                    .orElseGet(null).stream().map(b -> Optional.ofNullable(dictDatas).filter(a -> a.size() > 0)
+                    .orElse(new ArrayList <>()).stream().map(b -> Optional.ofNullable(dictDatas).filter(a -> a.size() > 0)
                             .orElseGet(Collections::emptyList).stream()
-                            .filter(a -> b.equals(a.getDictValue())).findFirst().orElseGet(null))
+                            .filter(a -> b.equals(a.getDictValue())).findFirst().orElse(new SysDictData()))
                     .map(SysDictData::getDictLabel).collect(Collectors.toList());
         }
+        newDictDatas.removeIf(x->StringUtils.isEmpty(x));
 
         //离开检查
         subSimpleVO.setOutCheck(newDictDatas);
@@ -553,12 +569,12 @@ public class LabSubjectManagerService {
 //         return createSubControllerVO(labSubjects, true, true, true, true, true);
     }
 
-    public LabSubjectControllerVO querySubById(Long id, Integer type) {
+    public LabSubjectControllerVO querySubById(Long id, Integer type,Long[] typeCollection) {
         LabSubject subject = new LabSubject();
         subject.setId(id);
         List<LabSubjectVO> labSubjects = subjectService.selectLabSubjectListAuthByPc(subject);
-        List<LabSubjectControllerVO> list = createSubControllerVO2(labSubjects, true, true, true, true, true);
-        if(list.size() > 0){
+        List<LabSubjectControllerVO> list = createSubControllerVO2(labSubjects,typeCollection, true, true, true, true, true);
+        if(list !=null && list.size() > 0){
             LabSubjectControllerVO subjectControllerVO = list.get(0);
             subjectControllerVO.setSafeUserNameAdminPhone(labSubjectMapper.queryUserNameBySafeUserInfo(subjectControllerVO.getSafeUserId()));
             subjectControllerVO.setSafeUserName(labSubjectMapper.queryUserNameBySafeUserId(subjectControllerVO.getSafeUserId()));
@@ -1210,7 +1226,7 @@ public class LabSubjectManagerService {
      * @return
      */
     @Deprecated
-    private List<LabSubjectControllerVO> createSubControllerVO2(List<? extends LabSubject> labSubjects, boolean flag, boolean iflabSubClassVOS, boolean iflabHardwares, boolean iflabSensors, boolean ifFunction) {
+    private List<LabSubjectControllerVO> createSubControllerVO2(List<? extends LabSubject> labSubjects,Long[] typeCollection, boolean flag, boolean iflabSubClassVOS, boolean iflabHardwares, boolean iflabSensors, boolean ifFunction) {
         List<LabSubjectControllerVO> list = null;
         if (CollUtil.isNotEmpty(labSubjects)) {
             Long[] longs = labSubjects.stream().map(a -> a.getId()).toArray(Long[]::new);
@@ -1222,7 +1238,11 @@ public class LabSubjectManagerService {
             List<LabHardware> labHardwares = null;
             if (iflabHardwares) {
                 //1.可控设备
-                labHardwares = hardwareMapper.selectLabHardwareBySubIds(longs);
+                //labHardwares = hardwareMapper.selectLabHardwareBySubIds(longs);
+                LabHardware hardware = new LabHardware();
+                hardware.setSubIds(longs);
+                hardware.setTypeCollection(typeCollection);
+                labHardwares = hardwareMapper.selectLabHardwareByParameter(hardware);
             }
             List<LabSensor> labSensors = null;
             boolean flagUpdate = false;
@@ -1346,9 +1366,13 @@ public class LabSubjectManagerService {
      * @return
      */
     @Async("labExecutor")
-    public CompletableFuture<Integer> queryHardwares(Map<Long, SubDiyVO> subDiyVOMap, Long... longs) {
+    public CompletableFuture<Integer> queryHardwares(Long[] typeCollection,Map<Long, SubDiyVO> subDiyVOMap, Long... longs) {
         int re = 0;
-        List<LabHardware> labHardwares = hardwareMapper.selectLabHardwareBySubIds(longs);
+        //List<LabHardware> labHardwares = hardwareMapper.selectLabHardwareBySubIds(longs);
+        LabHardware lhd = new LabHardware();
+        lhd.setSubIds(longs);
+        lhd.setTypeCollection(typeCollection);
+        List<LabHardware> labHardwares = hardwareMapper.selectLabHardwareByParameter(lhd);
         //传感器和可控设备都转为vo数据,并映射为map表
         Map<Long, List<HardwareCVO>> mapHardwareCVO = Optional.ofNullable(labHardwares).orElse(new ArrayList<>(0)).stream().map(a -> {
             HardwareCVO hardware = getHardwareCVO(a);

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

@@ -314,7 +314,7 @@ public class LabViolationServiceImpl implements ILabViolationService {
             Optional.ofNullable(value).orElseGet(Collections::emptyList).stream()
                     .forEach(a -> Optional.ofNullable(allList).orElseGet(Collections::emptyList).stream()
                             .filter(b -> b.getType().equals(a.getType())).forEach(b -> {
-                                b.setNum(a.getNum());
+                                b.setNum(a.getNum()+b.getNum());
                                 b.setCurrencyid(a.getCurrencyid());
                                 b.setCurrencyName(a.getCurrencyName());
                             }));

+ 7 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabWarnPushMessageServiceImpl.java

@@ -44,6 +44,13 @@ public class LabWarnPushMessageServiceImpl implements ILabWarnPushMessageService
         return labWarnPushMessageMapper.selectLabWarnPushMessageVOList(riskGroup);
     }
 
+    @Override
+    public List <LabWarnPushMessageVO> selectLabRiskLogList(Long riskGroup) {
+        LabWarnPushMessage labWarnPushMessage = new LabWarnPushMessage();
+        labWarnPushMessage.setRiskGroup(riskGroup);
+        return labWarnPushMessageMapper.selectLabRiskLogVOList(riskGroup);
+    }
+
     /**
      * 新增预警推送消息
      *

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

@@ -244,7 +244,7 @@ public class SubQueryManager {
         //===================硬件设备开始
         if(subQueryConfig.getHardware())
         {
-            CompletableFuture<Integer> integerCompletableFuture = subjectManagerService.queryHardwares(subDiyVOMap, longs);
+            CompletableFuture<Integer> integerCompletableFuture = subjectManagerService.queryHardwares(subQueryConfig.getTypeCollection(),subDiyVOMap, longs);
             completableFutures.add(integerCompletableFuture);
         }
         //===================硬件设备结束

+ 1 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/socket/service/SocketService.java

@@ -108,7 +108,7 @@ public class SocketService {
                 SpringUtils.getApplicationContext().publishEvent(sensorStatusEvent);
             }
             //缓存数据
-            redisService.setCacheObject(redisKey, transmissionVo.toString(), 5L, TimeUnit.MINUTES);
+            redisService.setCacheObject(redisKey, transmissionVo.toString(), CacheDevice.SENSOR_KEY.getRedisTime(), TimeUnit.SECONDS);
             redisService.setCacheObject( CacheDevice.SENSOR_LIFE.getRedisKey() + transmissionVo.getA3(), transmissionVo.getA3(),
                     CacheDevice.SENSOR_LIFE.getRedisTime() ,TimeUnit.SECONDS);
 

+ 13 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabBuildFloorLayoutMapper.xml

@@ -243,5 +243,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+    <select id="getPositionBySubId" resultType="java.util.Map">
+        SELECT
+        ls.id subId,
+        CONCAT( lbf.NAME,'-', ( SELECT lbf.NAME FROM lab_build_floor lbf WHERE lbf.id = lbfl.floor_id ),'-', ls.`name` ) position,
+        dept.dept_name deptName
+        FROM
+            lab_build_floor_layout lbfl
+            LEFT JOIN lab_build_floor lbf ON lbfl.build_id = lbf.id
+            LEFT JOIN lab_subject ls ON lbfl.`sub_id` = ls.`id`
+            LEFT JOIN sys_dept dept ON dept.dept_id = ls.dept_id
+        WHERE
+        FIND_IN_SET(lbfl.sub_id,#{subIds})
+    </select>
 
 </mapper>

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

@@ -113,7 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="parentId != null "> and t.parent_id = #{parentId}</if>
             <if test="type != null "> and t.`type` = #{type}</if>
         </where>
-        GROUP BY t.id
+        GROUP BY t.id ORDER BY t.`sort_no` ASC
     </select>
 
 

+ 4 - 4
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabCheckRecordMapper.xml

@@ -283,9 +283,9 @@
         (select nick_name from sys_user u where u.user_id=s.admin_id) safe_user_name,
         (select phonenumber from sys_user u where u.user_id=s.admin_id) safe_user_phone,
         s.admin_id userId,
-        l.room
-        from lab_subject_layout l INNER JOIN lab_subject s on l.id= s.layout_id
-        where  l.is_subject=1
+        l.room_num room
+        from lab_build_floor_layout l INNER JOIN lab_subject s on l.sub_id= s.id
+        where  1=1
         <if test="deptIds != null and deptIds.size()>0"> <!-- 部门集合id-->
             and s.dept_id in
             <foreach item="item" collection="deptIds" separator="," open="(" close=")" index="">'${item}'</foreach>
@@ -294,7 +294,7 @@
             and ( s.dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId} ,ancestors )) or s.dept_id = #{deptId} )
         </if>
         <if test="room != null "> <!-- 房间号-->
-            and l.room like concat('%', #{room}, '%')
+            and l.room_num like concat('%', #{room}, '%')
         </if>
         <if test="name != null "> <!-- 实验室名称-->
             and s.name like concat('%', #{name}, '%')

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

@@ -130,10 +130,10 @@
         LEFT JOIN   sys_dept d on   rr.dept_id=d.dept_id
         LEFT JOIN sys_user u on  rr.user_id=u.user_id where 1=1
         <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
-            and rr.create_time &gt;= str_to_date(#{beginTime},'%Y-%m-%d')
+            and DATE_FORMAT(rr.create_time,'%Y-%m-%d') &gt;= str_to_date(#{beginTime},'%Y-%m-%d')
         </if>
         <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
-            and rr.create_time &lt;= str_to_date(#{endTime},'%Y-%m-%d')
+            and DATE_FORMAT(rr.create_time,'%Y-%m-%d') &lt;= str_to_date(#{endTime},'%Y-%m-%d')
         </if>
         <if test="releaseDescribe != null  and releaseDescribe != ''">
          and rr.release_describe like concat('%', #{releaseDescribe}, '%')

+ 44 - 7
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabHardwareMapper.xml

@@ -100,11 +100,7 @@
                                        lab_subject st
                                   WHERE bg.id = st.floor_id
                                     AND st.id = he.subject_id),
-                            '-', (SELECT slt.room
-                                  FROM lab_subject_layout slt,
-                                       lab_subject st
-                                  WHERE slt.id = st.layout_id
-                                    AND st.id = he.subject_id))                    posi,
+                            IFNULL(CONCAT('-',(SELECT slt.room_num room FROM lab_build_floor_layout slt,lab_subject st WHERE slt.sub_id = st.id AND st.id = he.subject_id)),'')) posi,
                      stc.ring_time,
                      stc.deal_time,
                      he.operate_time,
@@ -112,7 +108,8 @@
                      he.join_cabinet_time                                          joinCabinetTime,
                      he.lock_id                                                    lockId,
                      he.device_status                                              deviceStatus,
-                     he.manufacturer_type                                          manufacturerType
+                     he.manufacturer_type                                          manufacturerType,
+                     he.har_user, he.har_psw, he.control_scope
               from lab_hardware he
                        LEFT JOIN hxp_smart_terminal_config stc ON he.id = stc.terminal_id) xx
                  left join lab_subject_hardware_position hp on hp.hard_id = xx.id
@@ -212,6 +209,26 @@
         </foreach>
     </select>
 
+    <!--   硬件设备查询 -->
+    <select id="selectLabHardwareByParameter" resultMap="LabHardwareResult">
+        <include refid="selectLabHardwareVo"/>
+        <where>
+            <if test="subIds != null and subIds.length > 0">
+                and xx.subject_id in
+                <foreach item="id" collection="subIds" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </if>
+
+            <if test="typeCollection != null and typeCollection.length > 0">
+                and xx.type in
+                <foreach item="item" collection="typeCollection" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
     <!--   通过实验室ids查询设备 -->
     <select id="selLabHardwareBySubIds" resultMap="LabHardwareResult">
         <include refid="selectLabHardwareVo"/>
@@ -273,7 +290,7 @@
         session_index,
         manufacturer_type,
         channels,
-        bit
+        bit, har_user, har_psw, control_scope
         from
         lab_hardware
         <where>
@@ -383,6 +400,10 @@
             <if test="channels != null">channels,</if>
             <if test="lockId != null">lock_id,</if>
             <if test="isPcfire != null">is_pcfire,</if>
+
+            <if test="harUser != null">har_user,</if>
+            <if test="harPsw != null">har_psw,</if>
+            <if test="controlScope != null">control_scope,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -416,6 +437,10 @@
             <if test="channels != null">#{channels},</if>
             <if test="lockId != null">#{lockId},</if>
             <if test="isPcfire != null">#{isPcfire},</if>
+
+            <if test="harUser != null">#{harUser},</if>
+            <if test="harPsw != null">#{harPsw},</if>
+            <if test="controlScope != null">#{controlScope},</if>
         </trim>
     </insert>
 
@@ -454,6 +479,10 @@
             <if test="deviceStatus != null">device_status=#{deviceStatus},</if>
             <if test="manufacturerType != null">manufacturer_type=#{manufacturerType},</if>
             <if test="isPcfire != null">is_pcfire=#{isPcfire},</if>
+
+            <if test="harUser != null">har_user=#{harUser},</if>
+            <if test="harPsw != null">har_psw=#{harPsw},</if>
+            <if test="controlScope != null">control_scope=#{controlScope},</if>
         </trim>
         where id = #{id}
     </update>
@@ -531,4 +560,12 @@
         ORDER BY lh.create_time DESC
         LIMIT 1
     </select>
+
+    <select id="selectCountByType" resultType="java.lang.Integer">
+        select count(1) from lab_hardware where subject_id = #{subjectId} and type = #{type}
+    </select>
+
+    <select id="querySubNameById" resultType="java.lang.String">
+        select name from lab_subject where id = (select subject_id from lab_hardware where id = #{hardId})
+    </select>
 </mapper>

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

@@ -494,12 +494,14 @@
         select h.`id`,count(hr.`hazard_id`) num,
         (select count(hr1.`hazard_id`) from lab_hazard_subject_relation hr1
         INNER JOIN lab_hazard h1 ON hr1.hazard_id = h1.id
+        INNER JOIN sys_dict_data sd ON sd.`dict_value` = h1.`hazard_type_mode` AND sd.`dict_type` = 'lab_hazard_type'
         inner join lab_subject s on hr1.`subject_id` = s.`id`
         inner join sys_dept t on s.`build_id` = t.`dept_id`
         ) totalNum,
         h.`ch_name` chName
         from lab_hazard_subject_relation hr
         inner JOIN lab_hazard h ON hr.hazard_id = h.id
+        INNER JOIN sys_dict_data sd ON sd.`dict_value` = h.`hazard_type_mode` and sd.`dict_type` = 'lab_hazard_type'
         inner join lab_subject s on hr.`subject_id` = s.`id`
         inner join sys_dept t on s.`build_id` = t.`dept_id`
         <where>

+ 3 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabMessageContentMapper.xml

@@ -160,6 +160,7 @@
             <if test="updateBy != null">update_by,</if>
             <if test="remark != null">remark,</if>
             <if test="messClass != null">mess_class,</if>
+            <if test="ifRead != null">if_read,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
@@ -180,6 +181,7 @@
             <if test="updateBy != null">#{updateBy},</if>
             <if test="remark != null">#{remark},</if>
             <if test="messClass != null">#{messClass},</if>
+            <if test="ifRead != null">#{ifRead},</if>
         </trim>
     </insert>
 
@@ -202,6 +204,7 @@
             <if test="deptIds != null">dept_ids = #{deptIds},</if>
             <if test="subIds != null">sub_ids = #{subIds},</if>
             <if test="remark != null">remark = #{remark},</if>
+            <if test="ifRead != null">if_read = #{ifRead},</if>
         </trim>
         where id = #{id}
     </update>

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

@@ -322,7 +322,7 @@
                 FROM
                     lab_message_content lc
                         left join sys_user s on s.user_id = #{userId}
-                where  lc.send_range =1
+                where  (lc.send_range =1
                    or (
                     lc.send_range =2 and FIND_IN_SET(#{deptId},lc.dept_ids)
                     )
@@ -332,7 +332,8 @@
 
                         (find_in_set(s.dept_id, lc.dept_ids) and find_in_set(s.position, lc.post_ids))
                         )
-                    )
+                    ))
+                   and (lc.if_read is null or if_read = 0)
                 GROUP BY lc.user_id
             ) a
                 LEFT JOIN sys_user su ON a.user_id = su.user_id

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

@@ -35,8 +35,7 @@
           (SELECT CONCAT(s.name,s.room) FROM lab_subject s WHERE s.id = subject_id) subject_name,
           (SELECT s.build_id FROM lab_subject s WHERE s.id = subject_id) build_id,
           (SELECT d.dept_name FROM lab_subject s,sys_dept d WHERE s.id = gp.subject_id AND s.build_id = d.dept_id) buildName,
-          (SELECT b.name FROM lab_building b,lab_subject s WHERE b.id = s.floor_id AND s.id = gp.subject_id) floorName,
-          (SELECT b.id FROM lab_building b,lab_subject s WHERE b.id = s.floor_id AND s.id = gp.subject_id) floorId,
+          (SELECT b.floor_id FROM lab_build_floor_layout b,lab_subject s WHERE b.sub_id = s.id AND s.id = gp.subject_id) floorId,
           (SELECT l.room FROM lab_subject_layout l,lab_subject s WHERE l.id = s.layout_id AND s.id = gp.subject_id) roomName,
           (select distinct max(al.risk_plan_id) from lab_risk_plan_abnormal_log al where gp.`id` = al.group_id and al.risk_status=1) riskPlanId
         FROM
@@ -163,12 +162,13 @@
         FROM lab_risk_plan_abnormal_group g
         LEFT JOIN lab_subject s ON s.id = g.subject_id
         <where>
+            g.STATUS = 0
             <if test="searchValue != null and searchValue!='' ">and (
                 g.group_name like concat('%', #{searchValue}, '%')
                 or s.name like concat('%', #{searchValue}, '%')
                 )
             </if>
-            <if test="riskAttribute != null ">and risk_attribute = #{riskAttribute}</if>
+            <if test="riskAttribute != null ">and g.risk_attribute = #{riskAttribute}</if>
         </where>
         ORDER  BY g.create_time DESC
     </select>

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

@@ -64,7 +64,8 @@
         pl.create_by, pl.update_time, pl.update_by,
         dt.dept_id,
         dt.dept_name,
-        s.name as subjectName
+        s.name as subjectName,
+        pl.sensor_json
         from lab_risk_plan_abnormal_log pl left join lab_subject s on pl.subject_id = s.id
         LEFT JOIN sys_dept dt ON s.`dept_id` = dt.`dept_id`
         <where>
@@ -190,7 +191,7 @@
         <where>
             <if test="groupId != null ">and pl.group_id = #{groupId}</if>
             <if test="riskPlanId != null ">and pl.risk_plan_id = #{riskPlanId}</if>
-            and pl.risk_status in(1,0,3)
+            and pl.risk_status in(1,0,3,2)
         </where>
         ORDER BY pl.`id` DESC,pl.create_time DESC
     </select>

+ 14 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSparseHardwareMapper.xml

@@ -114,6 +114,14 @@
             or (subject_id = #{subId} and device_type = 2)
         </if>
     </select>
+
+    <select id="selectListBySubId" resultType="java.util.Map">
+        SELECT t.hardware_num as hardwareNum,t.`name`,t.operate,t.port,t.device_vol as deviceVol FROM lab_sparse_hardware t LEFT JOIN lab_build_floor d ON t.floor_id = d.id
+        WHERE t.`type`= 2
+        AND device_type = 2
+        AND subject_id = #{subId}
+    </select>
+
     <select id="selectCameraByFloorId" resultType="java.lang.String">
        SELECT  t.hardware_num FROM  lab_sparse_hardware t LEFT JOIN lab_build_floor d ON t.floor_id = d.id
        WHERE t.floor_id=#{floorId} AND t.`type`=1
@@ -222,4 +230,10 @@
             #{id}
         </foreach>
     </delete>
+
+    <select id="selectSpeakerCount" resultType="java.lang.Integer">
+        select count(*)
+        from lab_sparse_hardware
+        where type = 2
+    </select>
 </mapper>

+ 329 - 169
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSubjectMapper.xml

@@ -117,18 +117,78 @@
     </resultMap>
 
     <sql id="selectLabSubjectVo">
-        select
-            id, name, floor_id,layout_id,build_id,sub_dept,level, check_out,check_in,room,dept_id,
-            (SELECT d.dept_name FROM sys_dept d WHERE s.dept_id = d.dept_id) dept_name,
-            admin_id, is_del, create_time, user_id,
-            create_by, update_time, update_by, remark, sub_dept,
-            check_out, check_in, safe_user_id, safe_signs, hazard_category, risk_measure,
-            outfire, qr_code,safe_user_id, skipped, check_count,sign_time,
-	        (SELECT GROUP_CONCAT(ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id, s.`safe_user_id`)) AS safeUserNames,
-            (select d.dept_name from sys_dept d where s.build_id = d.dept_id) build_name,
-            (select b.name from lab_building b where b.id = s.floor_id) floorName,
-            (SELECT l.room FROM lab_subject_layout l WHERE l.id = s.layout_id ) roomName,
-            (select GROUP_CONCAT(phonenumber) from sys_user where find_in_set(user_id, s.safe_user_id)) safeUserPhone
+        select id,
+               name,
+               floor_id,
+               layout_id,
+               build_id,
+               sub_dept,
+               level,
+               check_out,
+               check_in,
+               room,
+               dept_id,
+               (SELECT d.dept_name FROM sys_dept d WHERE s.dept_id = d.dept_id) dept_name,
+               admin_id,
+               is_del,
+               create_time,
+               user_id,
+               create_by,
+               update_time,
+               update_by,
+               remark,
+               sub_dept,
+               check_out,
+               check_in,
+               safe_user_id,
+               safe_signs,
+               hazard_category,
+               risk_measure,
+               outfire,
+               qr_code,
+               safe_user_id,
+               skipped,
+               check_count,
+               sign_time,
+               (SELECT GROUP_CONCAT(ur.nick_name)
+                FROM sys_user ur
+                WHERE ur.`user_id`
+                          IN (
+                          SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(s.safe_user_id, ',', b.help_topic_id + 1), ',',
+                                                 -1) result
+                          FROM mysql.help_topic b
+                          WHERE b.help_topic_id &lt;
+                                (LENGTH(s.safe_user_id) - LENGTH(REPLACE(s.safe_user_id, ',', '')) + 1)
+                      )
+               )                                                                safeUserNames,
+               (select f.`name`
+                from lab_build_floor f
+                where f.type = 2
+                  and f.id =
+                      (select bfl.build_id
+                       from lab_build_floor_layout bfl
+                       where bfl.sub_id = s.id))                                build_name,
+               (select f.`name`
+                from lab_build_floor f
+                where f.type = 3
+                  and f.id =
+                      (select bfl.floor_id
+                       from lab_build_floor_layout bfl
+                       where bfl.sub_id = s.id))                                floorName,
+               (select bfl.room_num
+                from lab_build_floor_layout bfl
+                where bfl.sub_id = s.id)                                        roomName,
+               (SELECT GROUP_CONCAT(phonenumber)
+                FROM sys_user ur
+                WHERE ur.`user_id`
+                          IN (
+                          SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(s.safe_user_id, ',', b.help_topic_id + 1), ',',
+                                                 -1) result
+                          FROM mysql.help_topic b
+                          WHERE b.help_topic_id &lt;
+                                (LENGTH(s.safe_user_id) - LENGTH(REPLACE(s.safe_user_id, ',', '')) + 1)
+                      )
+               )                                                                safeUserPhone
         from lab_subject s
     </sql>
     <sql id="selectLabSubjectListVo">
@@ -137,7 +197,7 @@
                bfl.floor_id,
                lb.room,
                t.dept_id,
-               IFNULL(su.user_id,-1) admin_id,
+               IFNULL(su.user_id, -1)                                                     admin_id,
                t.is_del,
                t.create_time,
                t.user_id,
@@ -145,38 +205,43 @@
                t.update_time,
                t.update_by,
                t.sub_dept,
-               bfl.id layout_id,
+               bfl.id                                                                     layout_id,
                t.build_id,
                t.remark,
                t.level,
                t.diy_order,
-               cf.classified_name levelName,
-               cf.classified_color fiedColor,
+               cf.classified_name                                                         levelName,
+               cf.classified_color                                                        fiedColor,
                t.type_id,
                (SELECT ct.type_name FROM lab_safe_classtype ct WHERE ct.id = t.`type_id`) typeName,
                t.mold_id,
-               (select lm.mold_name from lab_mold lm where t.mold_id = lm.id) as moldName,
-               t.check_out, t.check_in, t.safe_user_id, t.safe_signs, t.hazard_category, t.risk_measure,
-               t.outfire, t.qr_code,
-               su.nick_name as admin_name,
-               su.phonenumber as adminPhone,
-               sd.dept_name as dept_name,
+               (select lm.mold_name from lab_mold lm where t.mold_id = lm.id) as          moldName,
+               t.check_out,
+               t.check_in,
+               t.safe_user_id,
+               t.safe_signs,
+               t.hazard_category,
+               t.risk_measure,
+               t.outfire,
+               t.qr_code,
+               su.nick_name                                                   as          admin_name,
+               su.phonenumber                                                 as          adminPhone,
+               sd.dept_name                                                   as          dept_name,
                t.skipped,
                t.check_count,
                t.sign_time,
-               t.mold_id,
-               CONCAT(su.nick_name,'@',su.phonenumber) AS adminNameAndPhone,
+               CONCAT(su.nick_name, '@', su.phonenumber)                      AS          adminNameAndPhone,
 
-               (select d.dept_name from sys_dept d where t.build_id = d.dept_id) buildName,
-               (select b.name from lab_building b where b.id = t.floor_id) floorName,
-               (SELECT l.room FROM lab_subject_layout l WHERE l.id = t.layout_id ) roomName
+               (select d.dept_name from sys_dept d where t.build_id = d.dept_id)          buildName,
+               (select b.name from lab_building b where b.id = t.floor_id)                floorName,
+               (SELECT l.room_num FROM lab_build_floor_layout l WHERE l.sub_id = t.id)         roomName
 
         from lab_subject t
-        left  join  sys_user su on su.user_id = t.admin_id  AND su.`del_flag`=0
-        left  join  sys_dept sd on sd.dept_id = t.dept_id
-        left  join  lab_subject_layout lb on lb.id = t.layout_id
-        left join lab_safe_classified cf on cf.id = t.level
-        LEFT JOIN lab_build_floor_layout bfl ON t.`id` = bfl.`sub_id`
+                 left join sys_user su on su.user_id = t.admin_id AND su.`del_flag` = 0
+                 left join sys_dept sd on sd.dept_id = t.dept_id
+                 left join lab_subject_layout lb on lb.id = t.layout_id
+                 left join lab_safe_classified cf on cf.id = t.level
+                 LEFT JOIN lab_build_floor_layout bfl ON t.`id` = bfl.`sub_id`
     </sql>
     <sql id="selectLabSubjectListVoIFPhone">
         select t.id,
@@ -192,28 +257,34 @@
                t.update_time,
                t.update_by,
                t.sub_dept,
-               bfl.id layout_id,
+               bfl.id                                                                           layout_id,
                t.build_id,
                t.check_out,
                t.check_in,
                t.remark,
                t.sub_dept,
                t.level,
-                t.skipped,
-                t.check_count,
-              (SELECT cf.classified_name FROM lab_safe_classified cf WHERE cf.id = t.`level`) levelName,
-              (SELECT cf.classified_color FROM lab_safe_classified cf WHERE cf.id = t.`level`) fiedColor,
-              t.type_id,
-              (SELECT ct.type_name FROM lab_safe_classtype ct WHERE ct.id = t.`type_id`) typeName,
-               t.check_out, t.check_in, t.safe_user_id, t.safe_signs, t.hazard_category, t.risk_measure,
-               t.outfire, t.qr_code,
-               su.nick_name as admin_name,
-               su.phonenumber as adminPhone,
-               sd.dept_name as dept_name
+               t.skipped,
+               t.check_count,
+               (SELECT cf.classified_name FROM lab_safe_classified cf WHERE cf.id = t.`level`)  levelName,
+               (SELECT cf.classified_color FROM lab_safe_classified cf WHERE cf.id = t.`level`) fiedColor,
+               t.type_id,
+               (SELECT ct.type_name FROM lab_safe_classtype ct WHERE ct.id = t.`type_id`)       typeName,
+               t.check_out,
+               t.check_in,
+               t.safe_user_id,
+               t.safe_signs,
+               t.hazard_category,
+               t.risk_measure,
+               t.outfire,
+               t.qr_code,
+               su.nick_name   as                                                                admin_name,
+               su.phonenumber as                                                                adminPhone,
+               sd.dept_name   as                                                                dept_name
         from lab_subject t
-                 left  join  sys_user su on su.user_id = t.admin_id
-                 left  join  sys_dept sd on sd.dept_id = t.dept_id
-                 left  join  lab_subject_layout lb on lb.id = t.layout_id
+                 left join sys_user su on su.user_id = t.admin_id
+                 left join sys_dept sd on sd.dept_id = t.dept_id
+                 left join lab_subject_layout lb on lb.id = t.layout_id
                  LEFT JOIN lab_build_floor_layout bfl ON t.`id` = bfl.`sub_id`
     </sql>
     <select id="selectLabSubjectList" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResult">
@@ -233,77 +304,91 @@
         </where>
     </select>
 
-    <select id="selectLabSubjectListSecurity" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResult">
+    <select id="selectLabSubjectListSecurity" parameterType="com.zd.laboratory.domain.LabSubject"
+            resultMap="LabSubjectResult">
         <include refid="selectLabSubjectVo"/>
         <where>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="floorId != null "> and floor_id = #{floorId}</if>
-            <if test="room != null  and room != ''"> and room = #{room}</if>
-            <if test="deptId != null "> and dept_id = #{deptId}</if>
-            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
-            <if test="adminId != null "> and admin_id = #{adminId}</if>
-            <if test="isDel != null "> and is_del = #{isDel}</if>
-            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="floorId != null ">and floor_id = #{floorId}</if>
+            <if test="room != null  and room != ''">and room = #{room}</if>
+            <if test="deptId != null ">and dept_id = #{deptId}</if>
+            <if test="deptName != null  and deptName != ''">and dept_name like concat('%', #{deptName}, '%')</if>
+            <if test="adminId != null ">and admin_id = #{adminId}</if>
+            <if test="isDel != null ">and is_del = #{isDel}</if>
+            <if test="userId != null ">and user_id = #{userId}</if>
         </where>
     </select>
 
 
     <select id="queryUserNameBySafeUserByOnepc" parameterType="string" resultType="string">
-        SELECT GROUP_CONCAT(CONCAT(nick_name,' ',phonenumber) SEPARATOR '、') safeUserName FROM sys_user WHERE FIND_IN_SET(user_id, #{safeUserId})
+        SELECT GROUP_CONCAT(CONCAT(nick_name, ' ', phonenumber) SEPARATOR '、') safeUserName
+        FROM sys_user
+        WHERE FIND_IN_SET(user_id, #{safeUserId})
     </select>
 
     <select id="queryUserNameBySafeUserInfo" parameterType="string" resultType="string">
-        SELECT GROUP_CONCAT(CONCAT(nick_name,'@',phonenumber)) safeUserName FROM sys_user WHERE FIND_IN_SET(user_id, #{safeUserId})
+        SELECT GROUP_CONCAT(CONCAT(nick_name, '@', phonenumber)) safeUserName
+        FROM sys_user
+        WHERE FIND_IN_SET(user_id, #{safeUserId})
     </select>
 
     <select id="queryUserNameBySafeUserId" parameterType="string" resultType="string">
-        SELECT GROUP_CONCAT(nick_name) safeUserName FROM sys_user WHERE FIND_IN_SET(user_id, #{safeUserId})
+        SELECT GROUP_CONCAT(nick_name) safeUserName
+        FROM sys_user
+        WHERE FIND_IN_SET(user_id, #{safeUserId})
     </select>
 
     <select id="queryUserPhoneBySafeUserId" parameterType="string" resultType="string">
-        SELECT GROUP_CONCAT(phonenumber) safeUserPhone FROM sys_user WHERE FIND_IN_SET(user_id, #{safeUserId})
+        SELECT GROUP_CONCAT(phonenumber) safeUserPhone
+        FROM sys_user
+        WHERE FIND_IN_SET(user_id, #{safeUserId})
     </select>
 
-    <select id="selectLabSubjectListByadminidNotnull" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResult">
+    <select id="selectLabSubjectListByadminidNotnull" parameterType="com.zd.laboratory.domain.LabSubject"
+            resultMap="LabSubjectResult">
         <include refid="selectLabSubjectVo"/>
-            where admin_id != -1
+        where admin_id != -1
         <if test="deptIds != null and deptIds.size()>0"> <!-- 部门集合id-->
             and s.dept_id in
             <foreach item="item" collection="deptIds" separator="," open="(" close=")" index="">'${item}'</foreach>
         </if>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="floorId != null "> and floor_id = #{floorId}</if>
-            <if test="room != null  and room != ''"> and room = #{room}</if>
-            <if test="deptId != null "> and ( dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId} ,ancestors )) or dept_id = #{deptId} )</if>
-            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
-            <if test="adminId != null "> and admin_id = #{adminId}</if>
-            <if test="isDel != null "> and is_del = #{isDel}</if>
-            <if test="userId != null "> and user_id = #{userId}</if>
+        <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+        <if test="floorId != null ">and floor_id = #{floorId}</if>
+        <if test="room != null  and room != ''">and room = #{room}</if>
+        <if test="deptId != null ">and ( dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId}
+            ,ancestors )) or dept_id = #{deptId} )
+        </if>
+        <if test="deptName != null  and deptName != ''">and dept_name like concat('%', #{deptName}, '%')</if>
+        <if test="adminId != null ">and admin_id = #{adminId}</if>
+        <if test="isDel != null ">and is_del = #{isDel}</if>
+        <if test="userId != null ">and user_id = #{userId}</if>
 
     </select>
 
-    <select id="selectLabSubjectVOList" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResultVO">
+    <select id="selectLabSubjectVOList" parameterType="com.zd.laboratory.domain.LabSubject"
+            resultMap="LabSubjectResultVO">
         <include refid="selectLabSubjectListVo"/>
         <where>
-            <if test="name != null  and name != ''"> and t.name like concat('%', #{name}, '%')</if>
-            <if test="adminName != null  and adminName != ''"> and su.nick_name like concat('%', #{adminName}, '%')</if>
-
-            <if test="buildId != null "> and t.build_id = #{buildId}</if>
-            <if test="deptId != null "> and t.dept_id = #{deptId}</if>
-            <if test="id != null "> and t.id = #{id}</if>
-            <if test="subIds != null and subIds != ''"> and find_in_set(t.id, #{subIds})</if>
-
-            <if test="adminId != null "> and t.admin_id = #{adminId}</if>
-            <if test="level != null "> and t.level = #{level}</if>
-            <if test="typeId != null "> and t.type_id = #{typeId}</if>
-            <if test="subDept != null and subDept != ''"> and t.sub_dept = #{subDept}</if>
+            <if test="name != null  and name != ''">and t.name like concat('%', #{name}, '%')</if>
+            <if test="adminName != null  and adminName != ''">and su.nick_name like concat('%', #{adminName}, '%')</if>
+
+            <if test="buildId != null ">and t.build_id = #{buildId}</if>
+            <if test="deptId != null ">and t.dept_id = #{deptId}</if>
+            <if test="id != null ">and t.id = #{id}</if>
+            <if test="subIds != null and subIds != ''">and find_in_set(t.id, #{subIds})</if>
+
+            <if test="adminId != null ">and t.admin_id = #{adminId}</if>
+            <if test="level != null ">and t.level = #{level}</if>
+            <if test="typeId != null ">and t.type_id = #{typeId}</if>
+            <if test="subDept != null and subDept != ''">and t.sub_dept = #{subDept}</if>
             <!-- 数据范围过滤 -->
             ${params.dataScope}
         </where>
         order by t.diy_order desc , t.create_time desc
     </select>
 
-    <select id="selectLabSubjectVOListByPc" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResultVO">
+    <select id="selectLabSubjectVOListByPc" parameterType="com.zd.laboratory.domain.LabSubject"
+            resultMap="LabSubjectResultVO">
         select t.id,
         t.name,
         t.floor_id,
@@ -336,7 +421,6 @@
         t.skipped,
         t.check_count,
         t.sign_time,
-        t.mold_id,
         CONCAT(su.nick_name,'@',su.phonenumber) AS adminNameAndPhone,
 
         (select d.dept_name from sys_dept d where t.build_id = d.dept_id) buildName,
@@ -344,31 +428,31 @@
         (SELECT l.room FROM lab_subject_layout l WHERE l.id = t.layout_id ) roomName
 
         from lab_subject t
-        left  join  sys_user su on su.user_id = t.admin_id  AND su.`del_flag`=0
-        left  join  sys_dept sd on sd.dept_id = t.dept_id
-        left  join  lab_subject_layout lb on lb.id = t.layout_id
+        left join sys_user su on su.user_id = t.admin_id AND su.`del_flag`=0
+        left join sys_dept sd on sd.dept_id = t.dept_id
+        left join lab_subject_layout lb on lb.id = t.layout_id
         left join lab_safe_classified cf on cf.id = t.level
         <where>
-            <if test="name != null  and name != ''"> and t.name like concat('%', #{name}, '%')</if>
-            <if test="adminName != null  and adminName != ''"> and su.nick_name like concat('%', #{adminName}, '%')</if>
-
-            <if test="buildId != null "> and t.build_id = #{buildId}</if>
-            <if test="deptId != null "> and t.dept_id = #{deptId}</if>
-            <if test="id != null "> and t.id = #{id}</if>
-            <if test="subIds != null and subIds != ''"> and find_in_set(t.id, #{subIds})</if>
-
-            <if test="adminId != null "> and t.admin_id = #{adminId}</if>
-            <if test="level != null "> and t.level = #{level}</if>
-            <if test="typeId != null "> and t.type_id = #{typeId}</if>
-            <if test="subDept != null and subDept != ''"> and t.sub_dept = #{subDept}</if>
+            <if test="name != null  and name != ''">and t.name like concat('%', #{name}, '%')</if>
+            <if test="adminName != null  and adminName != ''">and su.nick_name like concat('%', #{adminName}, '%')</if>
+
+            <if test="buildId != null ">and t.build_id = #{buildId}</if>
+            <if test="deptId != null ">and t.dept_id = #{deptId}</if>
+            <if test="id != null ">and t.id = #{id}</if>
+            <if test="subIds != null and subIds != ''">and find_in_set(t.id, #{subIds})</if>
+
+            <if test="adminId != null ">and t.admin_id = #{adminId}</if>
+            <if test="level != null ">and t.level = #{level}</if>
+            <if test="typeId != null ">and t.type_id = #{typeId}</if>
+            <if test="subDept != null and subDept != ''">and t.sub_dept = #{subDept}</if>
             <!-- 数据范围过滤 -->
             ${params.dataScope}
         </where>
         order by t.diy_order desc , t.create_time desc
     </select>
-<!--  我管理的实验室数量 管理的意思是数据权限加业务权限  -->
+    <!--  我管理的实验室数量 管理的意思是数据权限加业务权限  -->
     <select id="myAdminSubCount" parameterType="com.zd.laboratory.domain.LabSubject" resultType="int">
-        select count(id)  from lab_subject t
+        select count(id) from lab_subject t
         <where>
             <if test="deptId != null">
                 and dept_id = #{deptId}
@@ -379,8 +463,8 @@
 
     </select>
 
-<!--  通过实验室IDS 查询 不需要数据权限  -->
-    <select id="selectLabSubjectVOListByIds"  resultMap="LabSubjectResultVO">
+    <!--  通过实验室IDS 查询 不需要数据权限  -->
+    <select id="selectLabSubjectVOListByIds" resultMap="LabSubjectResultVO">
         <include refid="selectLabSubjectListVoIFPhone"/>
         where t.id in
         <foreach item="id" collection="ids" open="(" separator="," close=")">
@@ -390,9 +474,9 @@
     </select>
 
     <!--  通过实验室IDS 查询 安全信息 不需要数据权限  -->
-    <select id="selectLabSubSafeInfoByIds"  resultMap="LabSubjectResultVO">
+    <select id="selectLabSubSafeInfoByIds" resultMap="LabSubjectResultVO">
         select t.id,
-               t.level,
+        t.level,
         t.safe_signs, t.hazard_category, t.risk_measure,
         t.outfire, t.qr_code,
         su.nick_name as admin_name,
@@ -401,11 +485,12 @@
         ,(select GROUP_CONCAT(nick_name) from sys_user where find_in_set(user_id, t.safe_user_id)) safeUserName
         ,(select GROUP_CONCAT(phonenumber) from sys_user where find_in_set(user_id, t.safe_user_id)) safeUserPhone,
         concat(su.nick_name,'@',su.phonenumber) adminNameAndPhone,
-        (select GROUP_CONCAT(concat(nick_name,'@',phonenumber)) from sys_user where find_in_set(user_id, t.safe_user_id)) safeUserNameAdminPhone
+        (select GROUP_CONCAT(concat(nick_name,'@',phonenumber)) from sys_user where find_in_set(user_id,
+        t.safe_user_id)) safeUserNameAdminPhone
         from lab_subject t
-        left  join  sys_user su on su.user_id = t.admin_id
-        left  join  sys_dept sd on sd.dept_id = t.dept_id
-        left  join  lab_subject_layout lb on lb.id = t.layout_id
+        left join sys_user su on su.user_id = t.admin_id
+        left join sys_dept sd on sd.dept_id = t.dept_id
+        left join lab_subject_layout lb on lb.id = t.layout_id
         where t.id in
         <foreach item="id" collection="ids" open="(" separator="," close=")">
             #{id}
@@ -543,27 +628,33 @@
 
 
     <delete id="deleteLabSubjectById" parameterType="Long">
-        delete from lab_subject where id = #{id}
+        delete
+        from lab_subject
+        where id = #{id}
     </delete>
 
     <delete id="deleteLabSubjectByIds" parameterType="String">
-        update  lab_subject  set is_del = 1  where id in
+        update lab_subject set is_del = 1 where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
     <!--    根据多层ID个 -->
-    <select id="selectLabSubjectListByIds" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResultVO">
-        select id, name, floor_id, room, dept_id, dept_name, admin_id, is_del, create_time, user_id, create_by, update_time, update_by, remark
-         from lab_subject
+    <select id="selectLabSubjectListByIds" parameterType="com.zd.laboratory.domain.LabSubject"
+            resultMap="LabSubjectResultVO">
+        select id, name, floor_id, room, dept_id, dept_name, admin_id, is_del, create_time, user_id, create_by,
+        update_time, update_by, remark
+        from lab_subject
         where floor_id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </select>
     <!--  根据负责人查询  -->
-    <select id="selectLabSubjectListByAdminIds" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResultVO">
-        select id, name, floor_id, room, dept_id, dept_name, admin_id, is_del, create_time, user_id, create_by, update_time, update_by, remark from lab_subject
+    <select id="selectLabSubjectListByAdminIds" parameterType="com.zd.laboratory.domain.LabSubject"
+            resultMap="LabSubjectResultVO">
+        select id, name, floor_id, room, dept_id, dept_name, admin_id, is_del, create_time, user_id, create_by,
+        update_time, update_by, remark from lab_subject
         where admin_id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
@@ -573,10 +664,11 @@
     <select id="getSubjectDict" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResult">
         select s.id, s.name `name`
         from
-            lab_subject s inner join lab_building b on s.`floor_id` = b.`id`
+        lab_subject s inner join lab_building b on s.`floor_id` = b.`id`
         <where>
             <if test="deptId != null ">
-                and (b.dept_id =#{deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET(#{deptId},
+                and (b.dept_id =#{deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE
+                FIND_IN_SET(#{deptId},
                 ancestors) ))
             </if>
             <if test="buildId != null">
@@ -587,13 +679,15 @@
         </where>
     </select>
 
-    <select id="getSubjectDictByViolation" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResult">
+    <select id="getSubjectDictByViolation" parameterType="com.zd.laboratory.domain.LabSubject"
+            resultMap="LabSubjectResult">
         select s.id, s.name `name`
         from
         lab_subject s inner join lab_building b on s.`floor_id` = b.`id`
         <where>
             <if test="deptId != null ">
-                and (b.dept_id =#{deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET(#{deptId},
+                and (b.dept_id =#{deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE
+                FIND_IN_SET(#{deptId},
                 ancestors) ))
             </if>
             <if test="buildId != null">
@@ -602,21 +696,23 @@
         </where>
     </select>
 
-    <select id="getFilterSubjectDict" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO" resultMap="LabSubjectResult">
+    <select id="getFilterSubjectDict" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO"
+            resultMap="LabSubjectResult">
         select s.id, s.name `name`
         from
         lab_subject s inner join lab_building b on s.`floor_id` = b.`id`
         <where>
             (NOT EXISTS(SELECT fg.`subject_id` FROM lab_subject_securityconfigure fg WHERE fg.`subject_id` = s.`id`)
             <if test="subjectIds != null ">
-            OR s.`id` IN
-            <foreach item="subId" collection="subjectIds" open="(" separator="," close=")">
-                #{subId}
-            </foreach>
+                OR s.`id` IN
+                <foreach item="subId" collection="subjectIds" open="(" separator="," close=")">
+                    #{subId}
+                </foreach>
             </if>
             )
             <if test="deptId != null ">
-                and (b.dept_id =#{deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET(#{deptId},
+                and (b.dept_id =#{deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE
+                FIND_IN_SET(#{deptId},
                 ancestors) ))
             </if>
             <if test="buildId != null">
@@ -625,7 +721,8 @@
         </where>
     </select>
 
-    <select id="getUserRoleBySub" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO" resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
+    <select id="getUserRoleBySub" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO"
+            resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
         SELECT s.id, s.name `name`,d.`dept_name` deptName,
         sc.classified_name AS levelName,
         st.type_name AS typeName,
@@ -643,10 +740,10 @@
             <if test="floorId != null ">
                 and s.floor_id = #{floorId}
             </if>
-<!--            <if test="searchValue != null ">-->
-<!--                and (s.name like concat('%', #{searchValue}, '%')-->
-<!--                or u.nick_name like concat('%', #{adminName}, '%'))-->
-<!--            </if>-->
+            <!--            <if test="searchValue != null ">-->
+            <!--                and (s.name like concat('%', #{searchValue}, '%')-->
+            <!--                or u.nick_name like concat('%', #{adminName}, '%'))-->
+            <!--            </if>-->
             <if test="buildId != null ">
                 and s.build_id = #{buildId}
             </if>
@@ -672,7 +769,8 @@
     </select>
 
 
-    <select id="getUserRoleBySubBindRisk" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO" resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
+    <select id="getUserRoleBySubBindRisk" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO"
+            resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
         SELECT s.id, s.name `name`,d.`dept_name` deptName,
         sc.classified_name AS levelName,
         st.type_name AS typeName,
@@ -721,7 +819,8 @@
         </where>
     </select>
 
-    <select id="getAllSubjectByParame" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO" resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
+    <select id="getAllSubjectByParame" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO"
+            resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
         SELECT s.id subjectId, s.name `name`,d.`dept_name` deptName,
         sc.classified_name AS levelName,
         st.type_name AS typeName,
@@ -755,7 +854,8 @@
                 and s.name like concat('%', #{name}, '%')
             </if>
             <if test="deptId != null">
-               and  ( s.dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId} ,ancestors )) or s.dept_id = #{deptId} )
+                and ( s.dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId} ,ancestors )) or
+                s.dept_id = #{deptId} )
             </if>
             <if test="level != null">
                 and s.level = #{level}
@@ -773,27 +873,41 @@
     </select>
 
     <select id="mySubjectList" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResultVO">
-        select s.`id`,s.name,s.`room`, b.`name` build_name,d.`dept_name`,s.`sub_dept`,u.nick_name as admin_name,
+        select s.`id`,s.name,s.`room`,
+        (select f.`name`
+        from lab_build_floor f
+        where f.type = 3
+        and f.id =bfl.floor_id) build_name,
+        (select f.`name`
+        from lab_build_floor f
+        where f.type = 2
+        and f.id =bfl.build_id) dept_name,
+        s.`sub_dept`,u.nick_name as admin_name,
         (SELECT ct.type_name FROM lab_safe_classtype ct WHERE ct.id=s.`type_id`) danger_name,
-        IFNULL((SELECT CASE a.record_content WHEN  0 THEN 0 WHEN 4 THEN 0 ELSE 1 END FROM lab_approval a
+        IFNULL((SELECT CASE a.record_content WHEN 0 THEN 0 WHEN 4 THEN 0 ELSE 1 END FROM lab_approval a
         WHERE a.join_user_id = #{userId} AND a.subject_id = s.`id` limit 1),0) is_apply,
         (SELECT a.record_content FROM lab_approval a
         WHERE a.join_user_id = 2 AND a.subject_id = s.`id` LIMIT 1) record_content,
         (SELECT a.id FROM lab_approval a
         WHERE a.join_user_id = 2 AND a.subject_id = s.`id` LIMIT 1) app_id
-         from lab_subject s inner join lab_building b on s.`floor_id` = b.`id` inner join sys_dept d on b.`dept_id` = d.`dept_id`
+        from lab_subject s inner join lab_building b on s.`floor_id` = b.`id` inner join sys_dept d on b.`dept_id` =
+        d.`dept_id`
         LEFT JOIN sys_user u ON u.user_id = s.admin_id
+        LEFT JOIN lab_build_floor_layout bfl ON bfl.sub_id=s.id
         <where>
             <if test="deptId != null ">
-                AND (b.dept_id = #{deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
+                AND (b.dept_id = #{deptId} OR b.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE
+                find_in_set(#{deptId},
                 ancestors) ))
             </if>
         </where>
     </select>
 
 
-    <select id="getTypeCount" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO" resultType="com.zd.laboratory.domain.vo.LabClasstypeVo">
-        SELECT sc.id,sc.type_name typeName,SUM(CASE WHEN st.id IS NULL THEN 0 ELSE 1 END) totalNum FROM lab_safe_classtype sc
+    <select id="getTypeCount" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO"
+            resultType="com.zd.laboratory.domain.vo.LabClasstypeVo">
+        SELECT sc.id,sc.type_name typeName,SUM(CASE WHEN st.id IS NULL THEN 0 ELSE 1 END) totalNum FROM
+        lab_safe_classtype sc
         LEFT JOIN lab_subject st ON sc.id = st.type_id
         <where>
             1=1
@@ -803,8 +917,10 @@
         GROUP BY sc.id,sc.type_name
     </select>
 
-    <select id="getFiedCount" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO" resultType="com.zd.laboratory.domain.vo.LabClassifiedVo">
-        SELECT sc.id,sc.classified_name classifiedName,SUM(CASE WHEN st.id IS NULL THEN 0 ELSE 1 END) totalNum FROM lab_safe_classified sc
+    <select id="getFiedCount" parameterType="com.zd.laboratory.domain.vo.LabSubjectVO"
+            resultType="com.zd.laboratory.domain.vo.LabClassifiedVo">
+        SELECT sc.id,sc.classified_name classifiedName,SUM(CASE WHEN st.id IS NULL THEN 0 ELSE 1 END) totalNum FROM
+        lab_safe_classified sc
         LEFT JOIN lab_subject st ON sc.id = st.level
         <where>
             1=1
@@ -828,7 +944,7 @@
         WHERE
         a.id IN
         <foreach item="id" collection="array" open="(" separator="," close=")">
-        #{id}
+            #{id}
         </foreach>
     </select>
 
@@ -851,21 +967,25 @@
     </select>
 
     <select id="selectLabSubjectCheckById" resultType="com.zd.laboratory.domain.LabSubject">
-        select s.check_in,s.skipped,s.check_count,
-         (SELECT sl.room FROM lab_subject_layout sl WHERE sl.id = s.`layout_id`) room,
-         (SELECT dt.dept_name FROM sys_dept dt WHERE dt.dept_id = s.`dept_id`) dept_name
-         from lab_subject s where s.id=#{id}
+        select s.check_in,
+               s.skipped,
+               s.check_count,
+               (SELECT sl.room FROM lab_subject_layout sl WHERE sl.id = s.`layout_id`) room,
+               (SELECT dt.dept_name FROM sys_dept dt WHERE dt.dept_id = s.`dept_id`)   dept_name
+        from lab_subject s
+        where s.id = #{id}
     </select>
 
     <select id="selectSubInfoByMyGradeManageWork"
             resultType="com.zd.laboratory.api.vo.LabGradeManageWorkVO">
 
-        select s.id as subId, s.name as subName,
+        select s.id                           as subId,
+               s.name                         as subName,
                s.level,
                ifnull(sc.classified_name, "") as levelName,
-               sc.classified_color as levelColor,
-               s.type_id as typeId,
-               ifnull(st.type_name, "") as typeName,
+               sc.classified_color            as levelColor,
+               s.type_id                      as typeId,
+               ifnull(st.type_name, "")       as typeName,
                s.dept_id,
                sd.dept_name
         from lab_subject as s
@@ -881,11 +1001,13 @@
         </foreach>
     </select>
     <select id="selectSubIdByAdminId" resultType="java.lang.Long">
-        select id from lab_subject where admin_id = #{adminId}
+        select id
+        from lab_subject
+        where admin_id = #{adminId}
     </select>
 
     <select id="selectLabAdminByIds" resultType="java.util.Map">
-        select admin_id as adminId, id as subId  from lab_subject where id in
+        select admin_id as adminId, id as subId from lab_subject where id in
         <foreach item="id" collection="list" open="(" separator="," close=")">
             #{id}
         </foreach>
@@ -919,10 +1041,12 @@
 
     </select>
     <select id="selectLabSubjectListPage" resultType="com.zd.laboratory.domain.vo.LabSubjectVO">
-        select * from lab_subject
+        select *
+        from lab_subject
 
     </select>
-    <select id="selectLabSubjectListByLayout" parameterType="com.zd.laboratory.domain.LabSubject" resultMap="LabSubjectResult">
+    <select id="selectLabSubjectListByLayout" parameterType="com.zd.laboratory.domain.LabSubject"
+            resultMap="LabSubjectResult">
         select
         id, name, floor_id,layout_id,build_id,sub_dept,level, check_out,check_in,room,dept_id,
         (SELECT d.dept_name FROM sys_dept d WHERE s.dept_id = d.dept_id) dept_name,
@@ -930,11 +1054,45 @@
         create_by, update_time, update_by, remark, sub_dept,
         check_out, check_in, safe_user_id, safe_signs, hazard_category, risk_measure,
         outfire, qr_code,safe_user_id, skipped, check_count,sign_time,
-        (SELECT GROUP_CONCAT(ur.nick_name) FROM sys_user ur WHERE FIND_IN_SET(ur.user_id, s.`safe_user_id`)) AS safeUserNames,
-        (select d.dept_name from sys_dept d where s.build_id = d.dept_id) build_name,
-        (select b.name from lab_building b where b.id = s.floor_id) floorName,
-        (SELECT l.room FROM lab_subject_layout l WHERE l.id = s.layout_id ) roomName,
-        (select GROUP_CONCAT(phonenumber) from sys_user where find_in_set(user_id, s.safe_user_id)) safeUserPhone
+        (SELECT GROUP_CONCAT(ur.nick_name) FROM sys_user ur
+        WHERE ur.`user_id`
+        IN (
+        SELECT
+        SUBSTRING_INDEX(SUBSTRING_INDEX(s.safe_user_id,',', b.help_topic_id + 1), ',', -1) result
+        FROM
+        mysql.help_topic b
+        WHERE
+        b.help_topic_id &lt; (LENGTH(s.safe_user_id) - LENGTH(REPLACE(s.safe_user_id, ',', '')) + 1)
+        )
+        ) AS safeUserNames,
+        (select f.`name`
+        from lab_build_floor f
+        where f.type = 2
+        and f.id =
+        (select bfl.build_id
+        from lab_build_floor_layout bfl
+        where bfl.sub_id = s.id)) build_name,
+        (select f.`name`
+        from lab_build_floor f
+        where f.type = 3
+        and f.id =
+        (select bfl.floor_id
+        from lab_build_floor_layout bfl
+        where bfl.sub_id = s.id)) floorName,
+        (select bfl.room_num
+        from lab_build_floor_layout bfl
+        where bfl.sub_id = s.id ) roomName,
+        (SELECT GROUP_CONCAT(phonenumber) FROM sys_user ur
+        WHERE ur.`user_id`
+        IN (
+        SELECT
+        SUBSTRING_INDEX(SUBSTRING_INDEX(s.safe_user_id,',', b.help_topic_id + 1), ',', -1) result
+        FROM
+        mysql.help_topic b
+        WHERE
+        b.help_topic_id &lt; (LENGTH(s.safe_user_id) - LENGTH(REPLACE(s.safe_user_id, ',', '')) + 1)
+        )
+        ) safeUserPhone
         from lab_subject s
         <where>
             s.`id` NOT IN(SELECT bfl.`sub_id` FROM lab_build_floor_layout bfl)
@@ -942,14 +1100,16 @@
                 and s.dept_id in
                 <foreach item="item" collection="deptIds" separator="," open="(" close=")" index="">'${item}'</foreach>
             </if>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="floorId != null "> and floor_id = #{floorId}</if>
-            <if test="room != null  and room != ''"> and room = #{room}</if>
-            <if test="deptId != null "> and ( dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId} ,ancestors )) or dept_id = #{deptId} )</if>
-            <if test="deptName != null  and deptName != ''"> and dept_name like concat('%', #{deptName}, '%')</if>
-            <if test="adminId != null "> and admin_id = #{adminId}</if>
-            <if test="isDel != null "> and is_del = #{isDel}</if>
-            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
+            <if test="floorId != null ">and floor_id = #{floorId}</if>
+            <if test="room != null  and room != ''">and room = #{room}</if>
+            <if test="deptId != null ">and ( dept_id in (SELECT dt.dept_id FROM sys_dept dt WHERE find_in_set(#{deptId}
+                ,ancestors )) or dept_id = #{deptId} )
+            </if>
+            <if test="deptName != null  and deptName != ''">and dept_name like concat('%', #{deptName}, '%')</if>
+            <if test="adminId != null ">and admin_id = #{adminId}</if>
+            <if test="isDel != null ">and is_del = #{isDel}</if>
+            <if test="userId != null ">and user_id = #{userId}</if>
         </where>
     </select>
 </mapper>

+ 17 - 4
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabViolationMapper.xml

@@ -299,6 +299,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             INNER JOIN lab_violation_score_site vs ON v.`reason` = vs.`violation_name`
             where DATE_FORMAT(v.`create_time`,'%Y-%m') = DATE_FORMAT(NOW(),'%Y-%m')
             UNION ALL
+            SELECT v.violation_content violation_type, v.`id` num,t.`build_id` dept_dept_id FROM lab_violation v INNER JOIN lab_subject t ON v.subject_id = t.`id`
+            WHERE DATE_FORMAT(v.`create_time`,'%Y-%m') = DATE_FORMAT(NOW(),'%Y-%m')
+            UNION ALL
             SELECT '其他' violation_type , v.`id` num,t.`build_id` dept_id
             FROM lab_negativelist_history v INNER JOIN lab_subject t ON v.`laboratory_id` = t.`id`
             WHERE v.reason NOT IN(
@@ -329,7 +332,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT '-99' id,'其他' violation_name FROM DUAL
         ) dd LEFT JOIN
         (
-        SELECT v.id,v.`violation_type`,s.build_id dept_id,t.parent_id,t.`ancestors`,
+        SELECT DISTINCT v.id,v.`violation_type`,s.build_id dept_id,t.parent_id,t.`ancestors`,
         (SELECT dt.`dept_id`
         FROM  sys_dept d JOIN sys_dept dt ON d.dept_id = dt.parent_id
         WHERE d.parent_id = 0 AND FIND_IN_SET(dt.dept_id,t.`ancestors`)) deptGroup
@@ -337,6 +340,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             SELECT v.reason violation_type, vs.`id`,v.`laboratory_id` subject_id,v.`create_time`
             FROM lab_negativelist_history v INNER JOIN lab_violation_score_site vs ON v.`reason` = vs.`violation_name`
             UNION ALL
+            SELECT v.violation_content violation_type, v.`id`,v.`subject_id`,v.`create_time` FROM lab_violation v
+            UNION ALL
             SELECT '其他' violation_type , '-99' id,v.`laboratory_id` subject_id,v.`create_time`
             FROM lab_negativelist_history v
             WHERE v.reason NOT IN(
@@ -372,6 +377,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             SELECT v.reason violation_type, vs.`id`,v.`laboratory_id` subject_id,v.`create_time`
             FROM lab_negativelist_history v INNER JOIN lab_violation_score_site vs ON v.`reason` = vs.`violation_name`
             UNION ALL
+            SELECT v.violation_content violation_type, v.`id`,v.`subject_id`,v.`create_time` FROM lab_violation v
+            UNION ALL
             SELECT '其他' violation_type , '-99' id,v.`laboratory_id` subject_id,v.`create_time`
             FROM lab_negativelist_history v
             WHERE v.reason NOT IN(
@@ -379,7 +386,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             FROM lab_violation_score_site vs
             )
             ) v ON s.`id` = v.`subject_id`
-            )x2 GROUP BY x2.subjectId ORDER BY num DESC LIMIT 10
+            )x2 GROUP BY x2.subjectId ORDER BY num DESC
         )xs1 LEFT JOIN (
         SELECT xx2.type,xx2.content,xx2.num,xx2.subjectId currencyId,xx2.subjectName currencyName FROM (SELECT x2.subjectId,IFNULL(COUNT(1),0) num FROM (
         SELECT v.id,v.`violation_type`,s.id subjectId,s.`name` subjectName
@@ -387,6 +394,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT v.reason violation_type, vs.`id`,v.`laboratory_id` subject_id,v.`create_time`
         FROM lab_negativelist_history v INNER JOIN lab_violation_score_site vs ON v.`reason` = vs.`violation_name`
         UNION ALL
+        SELECT v.violation_content violation_type, v.`id`,v.`subject_id`,v.`create_time` FROM lab_violation v
+        UNION ALL
         SELECT '其他' violation_type , '-99' id,v.`laboratory_id` subject_id,v.`create_time`
         FROM lab_negativelist_history v
         WHERE v.reason NOT IN(
@@ -399,7 +408,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <!-- 数据范围过滤 -->
             ${params.dataScope}
         </where>
-        )x2 GROUP BY x2.subjectId ORDER BY num DESC LIMIT 10)xx1
+        )x2 GROUP BY x2.subjectId ORDER BY num DESC)xx1
         INNER JOIN (
         SELECT dd.id AS TYPE, dd.violation_name AS content,IFNULL(COUNT(x1.id),0) num,x1.subjectId subjectId,x1.`subjectName` subjectName
         FROM (
@@ -414,6 +423,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         SELECT v.reason violation_type, vs.`id`,v.`laboratory_id` subject_id,v.`create_time`
         FROM lab_negativelist_history v INNER JOIN lab_violation_score_site vs ON v.`reason` = vs.`violation_name`
         UNION ALL
+        SELECT v.violation_content violation_type, v.`id`,v.`subject_id`,v.`create_time` FROM lab_violation v
+        UNION ALL
         SELECT '其他' violation_type , '-99' id,v.`laboratory_id` subject_id,v.`create_time`
         FROM lab_negativelist_history v
         WHERE v.reason NOT IN(
@@ -437,7 +448,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         )x1 ON dd.violation_name = x1.violation_type
         GROUP BY x1.subjectId,x1.violation_type
         )xx2 ON xx1.subjectId = xx2.subjectId
-        )xs2 ON xs1.currencyId = xs2.currencyId ORDER BY num DESC,xs1.currencyId DESC
+        )xs2 ON xs1.currencyId = xs2.currencyId ORDER BY num DESC,xs1.currencyId DESC LIMIT 10
     </select>
 
 
@@ -457,6 +468,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             SELECT v.reason violation_type, vs.`id` id,v.`laboratory_id` subject_id,v.`create_time`
             FROM lab_negativelist_history v INNER JOIN lab_violation_score_site vs ON v.`reason` = vs.`violation_name`
             UNION ALL
+            SELECT v.violation_content violation_type, v.`id`,v.`subject_id`,v.`create_time` FROM lab_violation v
+            UNION ALL
             SELECT '其他' violation_type , '-99' id,v.`laboratory_id` subject_id,v.`create_time`
             FROM lab_negativelist_history v
             WHERE v.reason NOT IN(

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

@@ -46,11 +46,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where   t.risk_group = #{id}
         order by t.create_time desc
     </select>
+
+    <select id="selectLabRiskLogVOList"  resultType="com.zd.laboratory.domain.vo.LabWarnPushMessageVO">
+        SELECT xx.* FROM (
+        SELECT l.id,l.`group_id` risk_group,ls.name sub_name,DATE_FORMAT(l.`create_time`,'%Y-%m-%d %H:%i') createTimeStr,0 push_type,NULL recipient_name,0 user_attributes FROM lab_risk_plan_abnormal_log l
+        LEFT JOIN lab_subject AS ls ON ls.id=l.`subject_id`
+        WHERE l.`risk_status`=5
+        UNION ALL
+        SELECT l.id,l.`group_id` risk_group,ls.name sub_name,DATE_FORMAT(l.`create_time`,'%Y-%m-%d %H:%i') createTimeStr,1 push_type,CONCAT(su.nick_name,'(实验室负责人)',',',(
+        SELECT GROUP_CONCAT(su.`nick_name`) FROM sys_user AS su WHERE FIND_IN_SET(su.user_id, ls.`safe_user_id`)
+        ),'(实验室安全责任人)') recipient_name,0 user_attributes FROM lab_risk_plan_abnormal_log l
+        LEFT JOIN lab_subject AS ls ON ls.id=l.`subject_id`
+        LEFT JOIN sys_user AS su ON su.user_id = ls.`admin_id`
+        WHERE l.`risk_status`=4 AND l.group_id = #{id}
+        UNION ALL
+        SELECT l.id,l.`group_id` risk_group,ls.name sub_name,DATE_FORMAT(l.`create_time`,'%Y-%m-%d %H:%i') createTimeStr,2 push_type,CONCAT(su.nick_name,'(实验室负责人)',',',(
+        SELECT GROUP_CONCAT(su.`nick_name`) FROM sys_user AS su WHERE FIND_IN_SET(su.user_id, ls.`safe_user_id`)
+        ),'(实验室安全责任人)') recipient_name,0 user_attributes
+        FROM lab_risk_plan_abnormal_log l
+        LEFT JOIN lab_subject AS ls ON ls.id=l.`subject_id`
+        LEFT JOIN sys_user AS su ON su.user_id = ls.`admin_id`
+        WHERE l.`risk_status`=5  AND l.group_id = #{id}
+        )xx
+        WHERE xx.risk_group = #{id}
+    </select>
     <select id="selectLabWarnPushMessageById"  resultMap="LabWarnPushMessageResult">
         <include refid="selectLabWarnPushMessageVo"/>
         where id = #{id}
     </select>
-        
+
     <insert id="insertLabWarnPushMessage" parameterType="com.zd.laboratory.domain.LabWarnPushMessage" useGeneratedKeys="true" keyProperty="id">
         insert into lab_warn_push_message
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -103,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <delete id="deleteLabWarnPushMessageByIds">
-        delete from lab_warn_push_message where id in 
+        delete from lab_warn_push_message where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>