From da79100553bf142a261934e23da0bea907c33cb0 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期二, 17 三月 2026 16:25:35 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/plugin/NormalProcess.java |   64 ++++++++++++++++++++++++++++++--
 1 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/core/plugin/NormalProcess.java b/src/main/java/com/zy/core/plugin/NormalProcess.java
index ebc4bdf..5973403 100644
--- a/src/main/java/com/zy/core/plugin/NormalProcess.java
+++ b/src/main/java/com/zy/core/plugin/NormalProcess.java
@@ -34,10 +34,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Slf4j
 @Component
@@ -85,6 +82,8 @@
 
         //涓婃姤鍫嗗灈鏈篋B110鐘舵�佹暟鎹�
         reportDb110();
+        //璺ㄥ尯鍏ュ簱浠诲姟涓嬪彂锛屼慨鏀圭珯鐐逛换鍔″彿涓哄叆搴撲换鍔″彿
+        taskToNewAreaInTaskStationSend();
     }
 
     /**
@@ -317,4 +316,61 @@
         }
     }
 
+    //璺ㄥ尯鍏ュ簱浠诲姟涓嬪彂锛屼慨鏀圭珯鐐逛换鍔″彿涓哄叆搴撲换鍔″彿
+    public synchronized void taskToNewAreaInTaskStationSend() {
+        Set<String> list = redisUtil.searchKeys(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK.key);
+        for (String key : list) {
+            Object dataStr = redisUtil.get(key);
+            if (dataStr == null) {
+                continue;
+            }
+
+            JSONObject data = JSON.parseObject(dataStr.toString());
+            Integer oldTaskNo = data.getInteger("oldTaskNo");
+            Integer newTaskNo = data.getInteger("newTaskNo");
+            StationCommand command = data.getObject("command", StationCommand.class);
+            Integer stationId = data.getInteger("stationId");
+            Integer deviceNo = data.getInteger("deviceNo");
+
+            Object lock = redisUtil.get(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK_SEND_LIMIT.key + stationId);
+            if(lock != null){
+                continue;
+            }
+
+            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, deviceNo);
+            if(stationThread == null){
+                continue;
+            }
+
+            Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
+            StationProtocol stationProtocol = statusMap.get(stationId);
+            if(stationProtocol == null){
+                continue;
+            }
+
+            if (!stationProtocol.isAutoing()) {
+                continue;
+            }
+
+            if (!stationProtocol.isLoading()) {
+                continue;
+            }
+
+            if (stationProtocol.getTaskNo() == 0) {
+                continue;
+            }
+
+            if (!stationProtocol.getTaskNo().equals(oldTaskNo)) {
+                //鍜岀紦瀛樺懡浠や笉鐩稿悓鍒犻櫎
+                redisUtil.del(key);
+                continue;
+            }
+
+            //缂撳瓨鍛戒护鐩稿悓锛屼笅鍙戝懡浠ゆ敼鍙樺叆搴撲换鍔″彿淇℃伅
+            MessageQueue.offer(SlaveType.Devp, deviceNo, new Task(2, command));
+            redisUtil.set(RedisKeyType.RECEIVE_IN_TASK_CHANGE_STATION_TASK_SEND_LIMIT.key + stationId, "lock", 5);
+        }
+
+    }
+
 }

--
Gitblit v1.9.1