From 98d120bd0633e4e0717d584cae5514132a18516b Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 18 十二月 2025 13:36:09 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/network/fake/ZyRgvFakeConnect.java        |   20 +++
 src/main/webapp/components/MapCanvas.js                             |    2 
 src/main/java/com/zy/core/utils/StationOperateProcessUtils.java     |  126 ++++++++++++++++++++
 src/main/java/com/zy/common/utils/HttpHandler.java                  |   10 +
 pom.xml                                                             |    4 
 src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java    |   89 +++++++++++---
 src/main/java/com/zy/asrs/controller/ConsoleController.java         |    3 
 src/main/java/com/zy/asrs/domain/vo/StationLatestDataVo.java        |    3 
 src/main/java/com/zy/core/model/protocol/StationProtocol.java       |    3 
 src/main/java/com/zy/core/network/entity/ZyStationStatusEntity.java |    3 
 src/main/java/com/zy/asrs/utils/Utils.java                          |    8 +
 src/main/java/com/zy/core/thread/impl/ZyStationThread.java          |    1 
 src/main/webapp/components/DevpCard.js                              |    1 
 src/main/java/com/zy/core/enums/RedisKeyType.java                   |    1 
 src/main/java/com/zy/core/network/fake/ZyCrnFakeConnect.java        |   21 +++
 src/main/resources/application.yml                                  |    4 
 src/main/java/com/zy/asrs/domain/enums/StationStatusType.java       |    5 
 src/main/java/com/zy/core/plugin/FakeProcess.java                   |    2 
 18 files changed, 277 insertions(+), 29 deletions(-)

diff --git a/pom.xml b/pom.xml
index 38b5e6a..80b8f0e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -131,6 +131,10 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-webflux</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/src/main/java/com/zy/asrs/controller/ConsoleController.java b/src/main/java/com/zy/asrs/controller/ConsoleController.java
index a775f51..6278bcb 100644
--- a/src/main/java/com/zy/asrs/controller/ConsoleController.java
+++ b/src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -117,11 +117,12 @@
                 vo.setOutEnable(stationProtocol.isOutEnable()); // 鏄惁鍙嚭
                 vo.setEmptyMk(stationProtocol.isEmptyMk()); // 鏄惁绌烘澘
                 vo.setFullPlt(stationProtocol.isFullPlt()); // 鏄惁婊℃澘
+                vo.setRunBlock(stationProtocol.isRunBlock());// 杩愯鍫靛
                 vo.setPalletHeight(stationProtocol.getPalletHeight()); // 鎵樼洏楂樺害
                 vo.setError(stationProtocol.getError()); // 閿欒鐮�
                 vo.setBarcode(stationProtocol.getBarcode()); // 鏉$爜
                 String stationStatus = StationStatusType.process(stationProtocol).toString().toLowerCase().replaceAll("_", "-");
-                if (stationProtocol.isAutoing() && stationProtocol.isLoading() && stationProtocol.getTaskNo() > 0) {
+                if (stationProtocol.isAutoing() && stationProtocol.isLoading() && stationProtocol.getTaskNo() > 0 && !stationProtocol.isRunBlock()) {
                     String taskClass = getStationTaskClass(stationProtocol.getTaskNo(), inTaskRange, outTaskRange);
                     if (taskClass != null) {
                         stationStatus = taskClass;
diff --git a/src/main/java/com/zy/asrs/domain/enums/StationStatusType.java b/src/main/java/com/zy/asrs/domain/enums/StationStatusType.java
index a647119..61925bc 100644
--- a/src/main/java/com/zy/asrs/domain/enums/StationStatusType.java
+++ b/src/main/java/com/zy/asrs/domain/enums/StationStatusType.java
@@ -20,12 +20,17 @@
     SITE_AUTO_ID,
     // 鏁呴殰
     SITE_ERROR,
+    // 杩愯闃诲
+    SITE_RUN_BLOCK,
     ;
 
     public static StationStatusType process(StationProtocol stationProtocol){
         if (stationProtocol == null) {
             return null;
         }
+        if(stationProtocol.isAutoing() && stationProtocol.isLoading() && stationProtocol.getTaskNo() > 0 && stationProtocol.isRunBlock()){
+            return SITE_RUN_BLOCK;
+        }
         if (stationProtocol.isAutoing() && stationProtocol.isLoading() && stationProtocol.getTaskNo() > 0) {
             return SITE_AUTO_RUN_ID;
         }
diff --git a/src/main/java/com/zy/asrs/domain/vo/StationLatestDataVo.java b/src/main/java/com/zy/asrs/domain/vo/StationLatestDataVo.java
index c97c234..3d4807b 100644
--- a/src/main/java/com/zy/asrs/domain/vo/StationLatestDataVo.java
+++ b/src/main/java/com/zy/asrs/domain/vo/StationLatestDataVo.java
@@ -32,6 +32,9 @@
     // 婊℃墭鐩�
     private boolean fullPlt;
 
+    // 杩愯闃诲
+    private boolean runBlock;
+
     // 鎵樼洏楂樺害
     private Integer palletHeight;
 
diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index 2a27fa0..fd191c6 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -140,6 +140,11 @@
 
     //鑾峰彇鍏ュ簱浠诲姟鍙敤鎺�
     public static List<Integer> getInTaskEnableRow() {
+        return getInTaskEnableRow(new ArrayList<>());
+    }
+
+    //鑾峰彇鍏ュ簱浠诲姟鍙敤鎺�
+    public static List<Integer> getInTaskEnableRow(List<Integer> excludeCrnList) {
         List<Integer> list = new ArrayList<>();
         try {
             RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
@@ -201,6 +206,9 @@
                     News.info("鍫嗗灈鏈�:{} 宸茶揪鏈�澶у叆搴撲换鍔℃暟锛屽綋鍓嶄换鍔℃暟:{}", basCrnp.getCrnNo(), inWrkMasts.size());
                     continue;
                 }
+                if (excludeCrnList.contains(basCrnp.getCrnNo())) {
+                    continue;
+                }
                 enabledCrnps.add(basCrnp);
             }
 
diff --git a/src/main/java/com/zy/common/utils/HttpHandler.java b/src/main/java/com/zy/common/utils/HttpHandler.java
index 809a1cd..e90584e 100644
--- a/src/main/java/com/zy/common/utils/HttpHandler.java
+++ b/src/main/java/com/zy/common/utils/HttpHandler.java
@@ -51,9 +51,12 @@
             }
         }
         Request request = headerBuilder.url(url).build();
-        Response response = getClient(timeout, timeUnit).newCall(request).execute();
+        OkHttpClient client = getClient(timeout, timeUnit);
+        Response response = client.newCall(request).execute();
         String result = response.isSuccessful() ? response.body().string() : null;
         response.close();
+        try { client.dispatcher().executorService().shutdown(); } catch (Exception ignore) {}
+        try { client.connectionPool().evictAll(); } catch (Exception ignore) {}
         return result;
     }
 
@@ -86,10 +89,13 @@
             request = builder.post(body).build();
 
         }
-        Call call = getClient(timeout, timeUnit).newCall(request);
+        OkHttpClient client = getClient(timeout, timeUnit);
+        Call call = client.newCall(request);
         Response response = call.execute();
         String result = response.body().string();
         response.close();
+        try { client.dispatcher().executorService().shutdown(); } catch (Exception ignore) {}
+        try { client.connectionPool().evictAll(); } catch (Exception ignore) {}
         return result;
     }
 
diff --git a/src/main/java/com/zy/core/enums/RedisKeyType.java b/src/main/java/com/zy/core/enums/RedisKeyType.java
index 7fad3cf..1a85593 100644
--- a/src/main/java/com/zy/core/enums/RedisKeyType.java
+++ b/src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -33,6 +33,7 @@
     CRN_IO_EXECUTE_FINISH_LIMIT("crn_io_execute_finish_limit_"),
     STATION_IN_EXECUTE_LIMIT("station_in_execute_limit_"),
     STATION_OUT_EXECUTE_LIMIT("station_out_execute_limit_"),
+    CHECK_STATION_RUN_BLOCK_LIMIT_("check_station_run_block_limit_"),
 
     CURRENT_CIRCLE_TASK_CRN_NO("current_circle_task_crn_no_"),
     AI_CHAT_HISTORY("ai_chat_history_"),
diff --git a/src/main/java/com/zy/core/model/protocol/StationProtocol.java b/src/main/java/com/zy/core/model/protocol/StationProtocol.java
index 65754ba..b74c810 100644
--- a/src/main/java/com/zy/core/model/protocol/StationProtocol.java
+++ b/src/main/java/com/zy/core/model/protocol/StationProtocol.java
@@ -35,6 +35,9 @@
     // 婊℃墭鐩�
     private boolean fullPlt;
 
+    // 杩愯闃诲
+    private boolean runBlock;
+
     // 鎵樼洏楂樺害
     private Integer palletHeight;
 
diff --git a/src/main/java/com/zy/core/network/entity/ZyStationStatusEntity.java b/src/main/java/com/zy/core/network/entity/ZyStationStatusEntity.java
index bbdf9cf..cc99b27 100644
--- a/src/main/java/com/zy/core/network/entity/ZyStationStatusEntity.java
+++ b/src/main/java/com/zy/core/network/entity/ZyStationStatusEntity.java
@@ -44,6 +44,9 @@
     //鏉$爜
     private String barcode;
 
+    //杩愯鍫靛
+    private boolean runBlock = false;
+
     @Override
     public ZyStationStatusEntity clone() {
         try {
diff --git a/src/main/java/com/zy/core/network/fake/ZyCrnFakeConnect.java b/src/main/java/com/zy/core/network/fake/ZyCrnFakeConnect.java
index a91560b..570b9aa 100644
--- a/src/main/java/com/zy/core/network/fake/ZyCrnFakeConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyCrnFakeConnect.java
@@ -29,6 +29,7 @@
 
     @Override
     public boolean disconnect() {
+        try { executor.shutdownNow(); } catch (Exception ignore) {}
         return true;
     }
 
@@ -90,6 +91,9 @@
         moveZ(this.crnStatus.getLevel(), sourcePosZ);
         this.crnStatus.setStatus(CrnStatusType.FETCHING.id);
         sleep(2000);
+        if (Thread.currentThread().isInterrupted()) {
+            return;
+        }
 
         this.crnStatus.setLoaded(1);
         this.crnStatus.setStatus(CrnStatusType.PUT_MOVING.id);
@@ -97,6 +101,9 @@
         moveZ(this.crnStatus.getLevel(), destinationPosZ);
         this.crnStatus.setStatus(CrnStatusType.PUTTING.id);
         sleep(2000);
+        if (Thread.currentThread().isInterrupted()) {
+            return;
+        }
         this.crnStatus.setLoaded(0);
         this.crnStatus.setStatus(CrnStatusType.WAITING.id);
     }
@@ -109,6 +116,9 @@
                 initSourcePosZ++;
                 this.crnStatus.setLevel(initSourcePosZ);
                 sleep(1000);
+                if (Thread.currentThread().isInterrupted()) {
+                    return;
+                }
             }
         }else {
             int moveLength = sourcePosZ - destinationPosZ;
@@ -117,6 +127,9 @@
                 initSourcePosZ--;
                 this.crnStatus.setLevel(initSourcePosZ);
                 sleep(1000);
+                if (Thread.currentThread().isInterrupted()) {
+                    return;
+                }
             }
         }
     }
@@ -129,6 +142,9 @@
                 initSourcePosY++;
                 this.crnStatus.setBay(initSourcePosY);
                 sleep(1000);
+                if (Thread.currentThread().isInterrupted()) {
+                    return;
+                }
             }
         }else {
             int moveLength = sourcePosY - destinationPosY;
@@ -137,6 +153,9 @@
                 initSourcePosY--;
                 this.crnStatus.setBay(initSourcePosY);
                 sleep(1000);
+                if (Thread.currentThread().isInterrupted()) {
+                    return;
+                }
             }
         }
     }
@@ -145,7 +164,7 @@
         try {
             Thread.sleep(ms);
         } catch (InterruptedException e) {
-            e.printStackTrace();
+            Thread.currentThread().interrupt();
         }
     }
 }
diff --git a/src/main/java/com/zy/core/network/fake/ZyRgvFakeConnect.java b/src/main/java/com/zy/core/network/fake/ZyRgvFakeConnect.java
index 5f959b0..ac8cb73 100644
--- a/src/main/java/com/zy/core/network/fake/ZyRgvFakeConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyRgvFakeConnect.java
@@ -37,6 +37,7 @@
 
     @Override
     public boolean disconnect() {
+        try { executor.shutdownNow(); } catch (Exception ignore) {}
         return true;
     }
 
@@ -120,11 +121,17 @@
 
             status.setRgvPos(currentTrackSiteNo);
             sleep(1000);
+            if (Thread.currentThread().isInterrupted()) {
+                return;
+            }
         }
 
         status.setStatus(RgvStatusType.PUTTING.id);
         status.setLoaded(1);
         sleep(1000);
+        if (Thread.currentThread().isInterrupted()) {
+            return;
+        }
 
         for (int i = 0; i < targetNavigateNodes.size(); i++) {
             NavigateNode navigateNode = targetNavigateNodes.get(i);
@@ -133,9 +140,15 @@
 
             status.setRgvPos(currentTrackSiteNo);
             sleep(1000);
+            if (Thread.currentThread().isInterrupted()) {
+                return;
+            }
         }
 
         sleep(1000);
+        if (Thread.currentThread().isInterrupted()) {
+            return;
+        }
         status.setStatus(RgvStatusType.WAITING.id);
     }
 
@@ -181,6 +194,9 @@
 
             status.setRgvPos(currentTrackSiteNo);
             sleep(1000);
+            if (Thread.currentThread().isInterrupted()) {
+                return;
+            }
         }
         status.setStatus(RgvStatusType.WAITING.id);
     }
@@ -194,7 +210,7 @@
         try {
             Thread.sleep(ms);
         } catch (InterruptedException e) {
-            e.printStackTrace();
+            Thread.currentThread().interrupt();
         }
     }
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java b/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
index 3df812f..0aea24a 100644
--- a/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyStationFakeConnect.java
@@ -63,6 +63,7 @@
                     status.setOutEnable(true);// 妯℃嫙鍙嚭
                     status.setEmptyMk(false);// 妯℃嫙绌烘澘淇″彿
                     status.setFullPlt(false);// 妯℃嫙婊℃墭鐩�
+                    status.setRunBlock(false);// 杩愯鏃犲牭濉�
                     status.setPalletHeight(0);// 妯℃嫙鎵樼洏楂樺害涓�0
                     status.setError(0);// 妯℃嫙鏃犳姤璀�
                     status.setBarcode("");// 妯℃嫙鏃犳潯鐮�
@@ -263,15 +264,21 @@
             return;
         }
 
-        stationMove(navigateNodes, taskNo, stationId, true, generateBarcode);
-        stationMove(targetNavigateNodes, taskNo, targetStationId, false, generateBarcode);
+        boolean result = stationMove(navigateNodes, taskNo, stationId, true, generateBarcode);
+        if(result) {
+            stationMove(targetNavigateNodes, taskNo, targetStationId, false, generateBarcode);
+        }
     }
 
-    private void stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId, boolean clearData, boolean generateBarcode) {
+    private boolean stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId, boolean clearData, boolean generateBarcode) {
         Integer lastStationId = null;
 
+        long executeTime = System.currentTimeMillis();
         int i = 0;
         while (i < navigateNodes.size()) {
+            if (Thread.currentThread().isInterrupted()) {
+                return false;
+            }
             NavigateNode navigateNode = navigateNodes.get(i);
             JSONObject valueObject = JSON.parseObject(navigateNode.getNodeValue());
             Integer currentStationId = valueObject.getInteger("stationId");
@@ -285,8 +292,15 @@
 
             }
 
-            if (nextStationId != null) {
-
+            if (!checkTaskNoInArea(taskNo)) {
+                if (System.currentTimeMillis() - executeTime > 1000 * 10) {
+                    //璁ゅ畾鍫靛
+                    boolean result = runBlockStation(taskNo, currentStationId, taskNo, currentStationId);
+                    if(!result) {
+                        continue;
+                    }
+                    return false;
+                }
             }
 
             if (i == 0) {
@@ -295,6 +309,9 @@
                     continue;
                 }
                 sleep(1000);
+                if (Thread.currentThread().isInterrupted()) {
+                    return false;
+                }
             }
 
             if(nextStationId != null) {
@@ -306,12 +323,19 @@
             }
 
             i++;
+            executeTime = System.currentTimeMillis();
             sleep(1000);
+            if (Thread.currentThread().isInterrupted()) {
+                return false;
+            }
         }
 
         if (generateBarcode) {
             if (lastStationId != null) {
                 while (true) {
+                    if (Thread.currentThread().isInterrupted()) {
+                        break;
+                    }
                     boolean result = generateStationBarcode(taskNo, targetStationId);
                     sleep(1000);
                     if (!result) {
@@ -324,8 +348,14 @@
 
         if (clearData) {
             sleep(10000);
+            if (Thread.currentThread().isInterrupted()) {
+                return true;
+            }
             if (lastStationId != null) {
                 while (true) {
+                    if (Thread.currentThread().isInterrupted()) {
+                        break;
+                    }
                     boolean result = clearStation(taskNo, targetStationId);
                     sleep(1000);
                     if (!result) {
@@ -335,13 +365,15 @@
                 }
             }
         }
+
+        return true;
     }
 
     private void sleep(long ms) {
         try {
             Thread.sleep(ms);
         } catch (InterruptedException e) {
-            e.printStackTrace();
+            Thread.currentThread().interrupt();
         }
     }
 
@@ -366,7 +398,7 @@
         return true;
     }
 
-    public synchronized boolean updateStationData(Integer lockTaskNo, Integer stationId, Integer taskNo, Integer targetStaNo, Boolean isLoading, String barcode) {
+    public synchronized boolean updateStationData(Integer lockTaskNo, Integer stationId, Integer taskNo, Integer targetStaNo, Boolean isLoading, String barcode, Boolean runBlock) {
         if (LOCK_STATION != lockTaskNo) {
             return false;
         }
@@ -393,6 +425,10 @@
         if (barcode != null) {
             currentStatus.setBarcode(barcode);
         }
+
+        if(runBlock != null) {
+            currentStatus.setRunBlock(runBlock);
+        }
         return true;
     }
 
@@ -405,15 +441,13 @@
                 return false;
             }
 
-            if(currentStatus.getTaskNo().equals(taskNo)) {
-                return true;
+            if (currentStatus.getTaskNo() > 0) {
+                if (!currentStatus.getTaskNo().equals(taskNo) && currentStatus.isLoading()) {
+                    return false;
+                }
             }
 
-            if (currentStatus.getTaskNo() > 0 || currentStatus.isLoading()) {
-                return false;
-            }
-
-            boolean result = updateStationData(taskNo, currentStationId, taskNo, targetStationId, isLoading, barcode);
+            boolean result = updateStationData(taskNo, currentStationId, taskNo, targetStationId, isLoading, barcode, false);
             if (!result) {
                 return false;
             }
@@ -439,12 +473,12 @@
                 return false;
             }
 
-            boolean result = updateStationData(lockTaskNo, nextStationId, taskNo, targetStaNo, true, null);
+            boolean result = updateStationData(lockTaskNo, nextStationId, taskNo, targetStaNo, true, null, false);
             if (!result) {
                 return false;
             }
 
-            boolean result2 = updateStationData(lockTaskNo, currentStationId, 0, 0, false, null);
+            boolean result2 = updateStationData(lockTaskNo, currentStationId, 0, 0, false, null, false);
             if (!result2) {
                 return false;
             }
@@ -466,7 +500,7 @@
             String barcodeTime = String.valueOf(System.currentTimeMillis());
             String barcode = barcodeTime.substring(5);
 
-            boolean result = updateStationData(lockTaskNo, currentStationId, null, null, null, barcode);
+            boolean result = updateStationData(lockTaskNo, currentStationId, null, null, null, barcode, null);
             if (!result) {
                 return false;
             }
@@ -485,7 +519,26 @@
                 return false;
             }
 
-            boolean result = updateStationData(lockTaskNo, currentStationId, 0, 0, false, "");
+            boolean result = updateStationData(lockTaskNo, currentStationId, 0, 0, false, "", false);
+            if (!result) {
+                return false;
+            }
+            return true;
+        });
+
+        return executeResult;
+    }
+
+    public synchronized boolean runBlockStation(Integer lockTaskNo, Integer currentStationId, Integer taskNo, Integer blockStationId) {
+        boolean executeResult = lockExecute(lockTaskNo, () -> {
+            ZyStationStatusEntity currentStatus = statusList.stream()
+                    .filter(item -> item.getStationId().equals(currentStationId)).findFirst().orElse(null);
+
+            if (currentStatus == null) {
+                return false;
+            }
+
+            boolean result = updateStationData(lockTaskNo, currentStationId, taskNo, blockStationId, true, "", true);
             if (!result) {
                 return false;
             }
diff --git a/src/main/java/com/zy/core/plugin/FakeProcess.java b/src/main/java/com/zy/core/plugin/FakeProcess.java
index da22a9a..703ec18 100644
--- a/src/main/java/com/zy/core/plugin/FakeProcess.java
+++ b/src/main/java/com/zy/core/plugin/FakeProcess.java
@@ -113,6 +113,8 @@
         stationOperateProcessUtils.stationOutExecute();
         //妫�娴嬭緭閫佺珯鐐瑰嚭搴撲换鍔℃墽琛屽畬鎴�
         stationOperateProcessUtils.stationOutExecuteFinish();
+        //妫�娴嬭緭閫佺珯鐐规槸鍚﹁繍琛屽牭濉�
+        stationOperateProcessUtils.checkStationRunBlock();
     }
 
     //妫�娴嬪叆搴撶珯鏄惁鏈変换鍔$敓鎴愶紝骞朵豢鐪熺敓鎴愭ā鎷熷叆搴撶珯鐐规暟鎹�
diff --git a/src/main/java/com/zy/core/thread/impl/ZyStationThread.java b/src/main/java/com/zy/core/thread/impl/ZyStationThread.java
index 9298523..9f7db71 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyStationThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyStationThread.java
@@ -158,6 +158,7 @@
                     stationProtocol.setPalletHeight(statusEntity.getPalletHeight());
                     stationProtocol.setError(statusEntity.getError());
                     stationProtocol.setBarcode(statusEntity.getBarcode());
+                    stationProtocol.setRunBlock(statusEntity.isRunBlock());
                 }
             }
         }
diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index d4cff0e..fc0878c 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -4,13 +4,19 @@
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
+import com.zy.asrs.domain.param.CreateInTaskParam;
 import com.zy.asrs.entity.BasCrnp;
 import com.zy.asrs.entity.BasDevp;
+import com.zy.asrs.entity.HttpRequestLog;
 import com.zy.asrs.entity.WrkMast;
 import com.zy.asrs.service.BasCrnpService;
 import com.zy.asrs.service.BasDevpService;
+import com.zy.asrs.service.HttpRequestLogService;
 import com.zy.asrs.service.WrkMastService;
+import com.zy.asrs.utils.Utils;
+import com.zy.common.model.StartupDto;
 import com.zy.common.service.CommonService;
+import com.zy.common.utils.HttpHandler;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.News;
 import com.zy.core.cache.MessageQueue;
@@ -23,12 +29,12 @@
 import com.zy.core.model.command.StationCommand;
 import com.zy.core.model.protocol.StationProtocol;
 import com.zy.core.thread.StationThread;
+import com.zy.system.entity.Config;
+import com.zy.system.service.ConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Component
 public class StationOperateProcessUtils {
@@ -43,6 +49,10 @@
     private BasCrnpService basCrnpService;
     @Autowired
     private RedisUtil redisUtil;
+    @Autowired
+    private ConfigService configService;
+    @Autowired
+    private HttpRequestLogService httpRequestLogService;
 
     //鎵ц杈撻�佺珯鐐瑰叆搴撲换鍔�
     public synchronized void stationInExecute() {
@@ -212,5 +222,115 @@
         }
     }
 
+    //妫�娴嬭緭閫佺珯鐐规槸鍚﹁繍琛屽牭濉�
+    public synchronized void checkStationRunBlock() {
+        String wmsUrl = null;
+        Config wmsSystemUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemUri"));
+        if (wmsSystemUriConfig != null) {
+            wmsUrl = wmsSystemUriConfig.getValue();
+        }
+
+        if(wmsUrl == null){
+            News.error("鏈厤缃甒MS绯荤粺URI锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemUri");
+            return;
+        }
+
+        String wmsSystemReassignInTaskUrl = null;
+        Config wmsSystemReassignInTaskUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemReassignInTaskUrl"));
+        if (wmsSystemReassignInTaskUrlConfig != null) {
+            wmsSystemReassignInTaskUrl = wmsSystemReassignInTaskUrlConfig.getValue();
+        }
+
+        if(wmsSystemReassignInTaskUrl == null){
+            News.error("鏈厤缃甒MS浠诲姟閲嶆柊鍒嗛厤鍏ュ簱搴撲綅鎺ュ彛鍦板潃锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemReassignInTaskUrl");
+            return;
+        }
+
+        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
+        for (BasDevp basDevp : basDevps) {
+            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
+            if(stationThread == null){
+                continue;
+            }
+
+            List<StationProtocol> list = stationThread.getStatus();
+            for (StationProtocol stationProtocol : list) {
+                if(stationProtocol.isAutoing()
+                    && stationProtocol.isLoading()
+                    && stationProtocol.getTaskNo() > 0
+                    && stationProtocol.isRunBlock()
+                ) {
+                    //杩愯鍫靛锛岄噸鏂扮敵璇蜂换鍔�
+                    WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
+                    if (wrkMast == null) {
+                        News.info("杈撻�佺珯鐐瑰彿={} 杩愯闃诲锛屼絾鏃犳硶鎵惧埌瀵瑰簲浠诲姟锛屽伐浣滃彿={}", stationProtocol.getStationId(), stationProtocol.getTaskNo());
+                        continue;
+                    }
+
+                    Object lock = redisUtil.get(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo());
+                    if (lock != null) {
+                        continue;
+                    }
+
+                    redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15);
+
+                    HashMap<String, Object> requestParam = new HashMap<>();
+                    String response = null;
+                    try {
+                        requestParam.put("taskNo", wrkMast.getWmsWrkNo());
+                        requestParam.put("row", Utils.getInTaskEnableRow(new ArrayList<>(basDevp.getDevpNo())));
+
+                        response = new HttpHandler.Builder()
+                                .setUri(wmsUrl)
+                                .setPath(wmsSystemReassignInTaskUrl)
+                                .setJson(JSON.toJSONString(requestParam))
+                                .build()
+                                .doPost();
+                        JSONObject jsonObject = JSON.parseObject(response);
+                        if (jsonObject.getInteger("code").equals(200)) {
+                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+
+                            String locNo = dto.getLocNo();
+                            //鏇存柊鏁版嵁
+                            wrkMast.setLocNo(locNo);
+                            wrkMastService.updateById(wrkMast);
+
+                            Integer crnNo = commonService.findCrnNoByLocNo(locNo);
+                            if (crnNo == null) {
+                                News.taskInfo(wrkMast.getWrkNo(), "鏈尮閰嶅埌鍫嗗灈鏈�");
+                                continue;
+                            }
+
+                            Integer targetStationId = commonService.findInStationId(crnNo, stationProtocol.getStationId());
+                            if (targetStationId == null) {
+                                News.taskInfo(wrkMast.getWrkNo(), "鎼滅储鍏ュ簱绔欑偣澶辫触");
+                                continue;
+                            }
+
+                            StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
+                            if(command == null){
+                                News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                                continue;
+                            }
+                            MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
+                            News.info("璇锋眰WMS鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
+                        } else {
+                            News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
+                        }
+                    } catch (Exception e) {
+                        News.error("璇锋眰WMS鎺ュ彛寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛� response锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response, e);
+                    } finally {
+                        HttpRequestLog httpRequestLog = new HttpRequestLog();
+                        httpRequestLog.setName(wmsUrl + wmsSystemReassignInTaskUrl);
+                        httpRequestLog.setRequest(JSON.toJSONString(requestParam));
+                        httpRequestLog.setResponse(response);
+                        httpRequestLog.setCreateTime(new Date());
+                        httpRequestLogService.insert(httpRequestLog);
+                    }
+                }
+            }
+        }
+    }
+
 
 }
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 75485dd..7f8fe23 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -46,7 +46,7 @@
 
 logging:
   file:
-    path: ./stock/out/@pom.build.finalName@/logs
+    path: /stock/out/@pom.build.finalName@/logs
 
 super:
   pwd: xltys1995
@@ -73,7 +73,7 @@
   # 璁惧鏃ュ織瀛樺偍鏂瑰紡 mysql file
   type: file
   # file绫诲瀷瀛樺偍鍦板潃
-  loggingPath: ./stock/out/@pom.build.finalName@/deviceLogs
+  loggingPath: /stock/out/@pom.build.finalName@/deviceLogs
   # 鏃ュ織杩囨湡鏃堕棿 鍗曚綅澶�
   expireDays: 7
 
diff --git a/src/main/webapp/components/DevpCard.js b/src/main/webapp/components/DevpCard.js
index 497116a..5f91ad5 100644
--- a/src/main/webapp/components/DevpCard.js
+++ b/src/main/webapp/components/DevpCard.js
@@ -39,6 +39,7 @@
                 <el-descriptions-item label="鍙嚭">{{ item.outEnable ? 'Y' : 'N' }}</el-descriptions-item>
                 <el-descriptions-item label="绌烘澘淇″彿">{{ item.emptyMk ? 'Y' : 'N' }}</el-descriptions-item>
                 <el-descriptions-item label="婊℃澘淇″彿">{{ item.fullPlt ? 'Y' : 'N' }}</el-descriptions-item>
+                <el-descriptions-item label="杩愯闃诲">{{ item.runBlock ? 'Y' : 'N' }}</el-descriptions-item>
                 <el-descriptions-item label="鎵樼洏楂樺害">{{ item.palletHeight }}</el-descriptions-item>
                 <el-descriptions-item label="鏉$爜">{{ item.barcode }}</el-descriptions-item>
                 <el-descriptions-item label="鏁呴殰浠g爜">{{ item.error }}</el-descriptions-item>
diff --git a/src/main/webapp/components/MapCanvas.js b/src/main/webapp/components/MapCanvas.js
index 8a6a55e..0b3705a 100644
--- a/src/main/webapp/components/MapCanvas.js
+++ b/src/main/webapp/components/MapCanvas.js
@@ -479,6 +479,8 @@
           this.updateColor(sta, 0x30bffc);
         } else if (status === "machine-pakout") {
           this.updateColor(sta, 0x97b400);
+        } else if (status === "site-run-block") {
+          this.updateColor(sta, 0xe69138);
         } else {
           this.updateColor(sta, 0xb8b8b8);
         }

--
Gitblit v1.9.1