Browse Source

严重异味处理

hanzhiwei 2 years ago
parent
commit
f66fa08744

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

@@ -44,6 +44,8 @@ import java.util.concurrent.TimeUnit;
 @ApiSupport(author = Knife4jConfiguration.Author.CYL)
 @RequestMapping("/lineVertex")
 public class LabExitLineVertexController extends BaseController {
+
+    private static final String EXIT_LINE_BY = "exitLineBy";
     @Autowired
     private ILabExitLineVertexService labExitLineVertexService;
 
@@ -104,7 +106,7 @@ public class LabExitLineVertexController extends BaseController {
     public ResultData executeEvacuation(@RequestBody LabExitLineEvacuationVo labExitLineEvacuationVo) {
         Map <String, Object> joinPointVOS = labExitLineVertexService.executeEvacuation(labExitLineEvacuationVo);
         // redis把计算的逃生线路相关信息存储起来
-        redisService.setCacheObject("exitLineBy"+labExitLineEvacuationVo.getBuildId()+""+labExitLineEvacuationVo.getFloorId(), JSON.toJSONString(joinPointVOS), 3L, TimeUnit.HOURS);
+        redisService.setCacheObject(EXIT_LINE_BY + labExitLineEvacuationVo.getBuildId()+""+labExitLineEvacuationVo.getFloorId(), JSON.toJSONString(joinPointVOS), 3L, TimeUnit.HOURS);
         // 下发前端页面通知
         messageSendService.exitLineToFloor(labExitLineEvacuationVo.getFloorId());
         return ResultData.success(joinPointVOS);
@@ -119,7 +121,7 @@ public class LabExitLineVertexController extends BaseController {
     public ResultData endEvacuation(@RequestBody LabExitLineEvacuationVo labExitLineEvacuationVo) {
         new Thread(()->labExitLineVertexService.endEvacuation(labExitLineEvacuationVo)).start();
         // 结束疏散清空redis,以及下发通知
-        redisService.deleteObject("exitLineBy"+labExitLineEvacuationVo.getBuildId()+""+labExitLineEvacuationVo.getFloorId());
+        redisService.deleteObject(EXIT_LINE_BY + labExitLineEvacuationVo.getBuildId()+""+labExitLineEvacuationVo.getFloorId());
         // 下发前端页面通知
         messageSendService.overExitLineToFloor(labExitLineEvacuationVo.getFloorId());
         return ResultData.success();
@@ -131,7 +133,7 @@ public class LabExitLineVertexController extends BaseController {
     @PostMapping("/getRedisEvacuation")
     @ApiOperation(value = "获取redis的疏散数据")
     public ResultData getRedisEvacuation(@RequestBody LabExitLineEvacuationVo labExitLineEvacuationVo) {
-        String joinPointVOSStr = redisService.getCacheObject("exitLineBy"+labExitLineEvacuationVo.getBuildId()+""+labExitLineEvacuationVo.getFloorId());
+        String joinPointVOSStr = redisService.getCacheObject(EXIT_LINE_BY + labExitLineEvacuationVo.getBuildId()+""+labExitLineEvacuationVo.getFloorId());
         if(StringUtils.isNotNull(joinPointVOSStr)){
             Map <String, Object> joinPointVOS = (Map <String, Object>) JSON.parseObject(joinPointVOSStr, Object.class, Feature.OrderedField);
             return ResultData.success(joinPointVOS);

+ 27 - 31
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabHazardController.java

@@ -1,7 +1,5 @@
 package com.zd.laboratory.controller;
 
-import com.alibaba.fastjson.JSON;
-import com.zd.algorithm.api.fire.entity.vo.HardwareFireDeviceVO;
 import com.zd.common.core.annotation.Log;
 import com.zd.common.core.annotation.PreAuthorize;
 import com.zd.common.core.log.BusinessType;
@@ -22,7 +20,6 @@ import com.zd.laboratory.service.ILabHazardService;
 import com.zd.laboratory.service.ILabHazardSubjectRelationService;
 import com.zd.laboratory.service.ILabQpSubjectRelationService;
 import com.zd.model.constant.BaseConstants;
-import com.zd.model.constant.CacheConstants;
 import com.zd.model.domain.ResultData;
 import com.zd.model.domain.per.PerFun;
 import com.zd.model.domain.per.PerPrefix;
@@ -88,13 +85,13 @@ public class LabHazardController extends BaseController {
     @GetMapping(value = "/getQpHazard")
     @ApiOperation(value = "获取实验室气瓶存储数量")
     public ResultData<LabQpSubjectRelation> getQpHazard(Long subId) {
-        LabQpSubjectRelation LabQpSubjectRelation = new LabQpSubjectRelation();
-        LabQpSubjectRelation.setSubjectId(subId);
-        List<LabQpSubjectRelation> list = labQpSubjectRelationService.selectLabQpSubjectRelationList(LabQpSubjectRelation);
-        if(list.size()>0){
-            LabQpSubjectRelation = list.get(0);
+        LabQpSubjectRelation labQpSubjectRelation = new LabQpSubjectRelation();
+        labQpSubjectRelation.setSubjectId(subId);
+        List<LabQpSubjectRelation> list = labQpSubjectRelationService.selectLabQpSubjectRelationList(labQpSubjectRelation);
+        if (!list.isEmpty()) {
+            labQpSubjectRelation = list.get(0);
         }
-        return ResultData.success(LabQpSubjectRelation);
+        return ResultData.success(labQpSubjectRelation);
     }
 
     /**
@@ -139,7 +136,7 @@ public class LabHazardController extends BaseController {
     public ResultData<LabHazardNewVo> getInfo(@PathVariable("id") Long id) {
         LabHazard labHazard = labHazardService.selectLabHazardById(id);
         LabHazardNewVo labHazardNewVo = new LabHazardNewVo();
-        if(labHazard != null){
+        if (labHazard != null) {
             BeanUtils.copyProperties(labHazard, labHazardNewVo);
         }
         return ResultData.success(labHazardNewVo);
@@ -154,7 +151,7 @@ public class LabHazardController extends BaseController {
     public ResultData<LabHazardNewVo> lookUp(@PathVariable("id") Long id) {
         LabHazardNewVo labHazardNewVo = new LabHazardNewVo();
         LabHazard labHazard = labHazardService.selectLabHazardById(id);
-        if(labHazard != null){
+        if (labHazard != null) {
             labHazard.setScanCount(labHazard.getScanCount() + 1);
             labHazardService.updateLabHazardLook(labHazard);
             BeanUtils.copyProperties(labHazard, labHazardNewVo);
@@ -181,7 +178,7 @@ public class LabHazardController extends BaseController {
     @PostMapping("/edit")
     @ApiOperation(value = "修改危险源")
     public ResultData edit(@RequestBody @Validated(ValidGroup.Crud.Update.class) LabHazard labHazard) {
-        if(labHazard.getId() == null){
+        if (labHazard.getId() == null) {
             return ResultData.fail("ID不能为空!");
         }
         return ResultData.success(labHazardService.updateLabHazard(labHazard));
@@ -248,7 +245,6 @@ public class LabHazardController extends BaseController {
     }
 
 
-
     /**
      * 危险源统计列表(大屏用)
      */
@@ -256,11 +252,11 @@ public class LabHazardController extends BaseController {
     @ApiOperation(value = "危险源统计列表(大屏用)")
     public ResultData queryBigViewHazardList(LabHazardVO labHazardVO) {
         List<LabHazardBigViewVO> list = labHazardService.queryBigViewHazardList(labHazardVO);
-        if(list!=null && list.size()>0){
+        if (list != null && list.size() > 0) {
             //占比计算
-            Integer count= list.stream().mapToInt(a->a.getTotalNum()).sum();
-            for (LabHazardBigViewVO vo:list) {
-                vo.setRatio(myPercent(vo.getTotalNum(),count,"##.0%"));
+            Integer count = list.stream().mapToInt(a -> a.getTotalNum()).sum();
+            for (LabHazardBigViewVO vo : list) {
+                vo.setRatio(myPercent(vo.getTotalNum(), count, "##.0%"));
             }
         }
         return ResultData.success(list);
@@ -275,38 +271,38 @@ public class LabHazardController extends BaseController {
         //获取数据源
         List<LabHazardSubjectRelation> list = labHazardSubjectRelationService.relationBigViewCount(relation);
         //获取危险源列表
-        List<SysDictData> dictDataList =  redisService.getCacheObject(BaseConstants.SYS_DICT_KEY+"lab_hazard_type");
+        List<SysDictData> dictDataList = redisService.getCacheObject(BaseConstants.SYS_DICT_KEY + "lab_hazard_type");
         //按学院分组
         Map<String, List<LabHazardSubjectRelation>> bottleConfigMap = list.stream().collect(Collectors.groupingBy(LabHazardSubjectRelation::getDeptName));
 
-        Map<String,Object> allMap = new HashMap <>();
-        List<Map<String,Object>> backtList = new ArrayList<>();
-        LinkedHashSet <String> deptNames = new LinkedHashSet<>();
+        Map<String, Object> allMap = new HashMap<>();
+        List<Map<String, Object>> backtList = new ArrayList<>();
+        LinkedHashSet<String> deptNames = new LinkedHashSet<>();
 
-        if(!bottleConfigMap.isEmpty()){
-            for (SysDictData dicData:dictDataList) {
-                Map<String,Object> hazardMap = new HashMap <>();
-                hazardMap.put("name",dicData.getDictLabel());
+        if (!bottleConfigMap.isEmpty()) {
+            for (SysDictData dicData : dictDataList) {
+                Map<String, Object> hazardMap = new HashMap<>();
+                hazardMap.put("name", dicData.getDictLabel());
                 List<Integer> hazardtList = new ArrayList<>();
                 for (Map.Entry entry : bottleConfigMap.entrySet()) {
                     Object Key = entry.getKey();
-                    deptNames.add(Key+"");
+                    deptNames.add(Key + "");
                     Integer deptCount = 0;
                     // 循环数据源
-                    for (LabHazardSubjectRelation lsr:list) {
-                        if(Key.toString().equals(lsr.getDeptName()) && dicData.getDictLabel().equals(lsr.getHazardTypeModeName())){
+                    for (LabHazardSubjectRelation lsr : list) {
+                        if (Key.toString().equals(lsr.getDeptName()) && dicData.getDictLabel().equals(lsr.getHazardTypeModeName())) {
                             deptCount = lsr.getTotalNum();
                         }
                     }
                     hazardtList.add(deptCount);
                 }
-                hazardMap.put("data",hazardtList);
+                hazardMap.put("data", hazardtList);
                 backtList.add(hazardMap);
             }
         }
 
-        allMap.put("list",backtList);
-        allMap.put("deptNames",deptNames);
+        allMap.put("list", backtList);
+        allMap.put("deptNames", deptNames);
         return ResultData.success(allMap);
     }