Sfoglia il codice sorgente

代码异味处理

hanzhiwei 2 anni fa
parent
commit
9e62eb6b23

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

@@ -272,11 +272,9 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
         logger.info("orign->dist" + " dist " + " path");
         for (int i = 0; i < V; i++) {
             for (int j = 0; j < V; j++) {
-                if (i != j) {//只是避免了vi->vi的输出
-                    if (linePointVOList.get(i).getPointAttribute() == 4 && linePointVOList.get(i).getPointVOList().get(j).getPointAttribute() == 1) {
-                        CompletableFuture <Map <String, Object>> setCompletableFuture = optimalRoute(linePointVOList, path, chain, i, j, oldList, oldRelationalData,labExitLineEvacuationVo);
-                        completableFutures.add(setCompletableFuture);
-                    }
+                if (i != j && linePointVOList.get(i).getPointAttribute() == 4 && linePointVOList.get(i).getPointVOList().get(j).getPointAttribute() == 1) {//只是避免了vi->vi的输出
+                    CompletableFuture <Map <String, Object>> setCompletableFuture = optimalRoute(linePointVOList, path, chain, i, j, oldList, oldRelationalData,labExitLineEvacuationVo);
+                    completableFutures.add(setCompletableFuture);
                 }
             }
         }
@@ -357,9 +355,7 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
                             Thread.sleep(timeWaitConfigUtils.getWaitTime());
                         }else if(a.getRelayType().intValue()==3){
                             try {
-                                String relayCode = a.getRelayCode();
-                                String commandStr = RelayConstants.AT_STACH + a.getRelayBit() + "=" + RelayConstants.AT_OPEN + RelayConstants.SPACE_WRAP;
-                                NettyPushMsgService.push(relayCode, commandStr.getBytes());
+                                extracted(a);
                             } catch (IOException e) {
                                 logger.error("异常信息:", e);
                             }
@@ -375,6 +371,12 @@ public class LabExitLineVertexServiceImpl implements ILabExitLineVertexService {
         openHorn(labExitLineEvacuationVo);
     }
 
+    private static void extracted(LabExitPointRelay a) throws IOException {
+        String relayCode = a.getRelayCode();
+        String commandStr = RelayConstants.AT_STACH + a.getRelayBit() + "=" + RelayConstants.AT_OPEN + RelayConstants.SPACE_WRAP;
+        NettyPushMsgService.push(relayCode, commandStr.getBytes());
+    }
+
     /**
      * 开启喇叭播放音乐
      *

+ 11 - 5
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabHardwareServiceImpl.java

@@ -234,11 +234,7 @@ public class LabHardwareServiceImpl implements ILabHardwareService {
             }
             int id;
             try{
-                id = labHardwareMapper.insertLabHardware(labHardware);
-                if(HardwareTypeEnum.HK_DOOR.equals(labHardware.getType())
-                        && labHardwareMapper.selectCountByType(labHardware) > 3){
-                    throw new ServiceException("添加失败:同一实验室最多添加3台门禁设备");
-                }
+                id = getId(labHardware);
 
             }catch (DuplicateKeyException e){
                 throw new ServiceException("继电器编号位置重复,请重新输入。");
@@ -259,6 +255,16 @@ public class LabHardwareServiceImpl implements ILabHardwareService {
 
     }
 
+    private int getId(LabHardware labHardware) {
+        int id;
+        id = labHardwareMapper.insertLabHardware(labHardware);
+        if(HardwareTypeEnum.HK_DOOR.equals(labHardware.getType())
+                && labHardwareMapper.selectCountByType(labHardware) > 3){
+            throw new ServiceException("添加失败:同一实验室最多添加3台门禁设备");
+        }
+        return id;
+    }
+
     /**
      * 修改硬件
      *