From 9540c4904147cb4baf037892447d6f85dc004646 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期四, 27 三月 2025 13:31:20 +0800
Subject: [PATCH] #输送线循环BUG修复

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   65 +++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index 3303ad3..ba7e4f9 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -158,10 +158,30 @@
                         if (staProtocol.getSiteId() == 107 || staProtocol.getSiteId() == 109) {
                             StaProtocol staProtocol5 = getClonedStation(devpThread, staProtocol.getSiteId() - 1);
                             if (staProtocol5 != null && (staProtocol5.isLoading() && (staProtocol5.getStaNo() == 107 || staProtocol5.getStaNo() == 109))) {
+                                short workNo = staProtocol5.getWorkNo();
+
+                                // **鍏堟竻闆讹紝绛夊緟 100ms**
+                                staProtocol5.setWorkNo((short) 0);
+                                staProtocol5.setStaNo((short) 0);
+                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol5));
+                                Thread.sleep(100);
+
+                                // **鍐嶅啓鍏ョ洰鏍囧��**
+                                staProtocol5.setWorkNo(workNo);
                                 staProtocol5.setStaNo((short) 112);
                                 MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol5));
                             }
                         } else {
+                            short workNo = staProtocol.getWorkNo();
+
+                            // **鍏堟竻闆讹紝绛夊緟 100ms**
+                            staProtocol.setWorkNo((short) 0);
+                            staProtocol.setStaNo((short) 0);
+                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+                            Thread.sleep(100);
+
+                            // **鍐嶅啓鍏ョ洰鏍囧��**
+                            staProtocol.setWorkNo(workNo);
                             staProtocol.setStaNo((short) 112);
                             MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                         }
@@ -181,35 +201,50 @@
         return (staProtocol != null) ? staProtocol.clone() : null;
     }
 
-    //112寰幆绔欑偣鑷冲嚭搴撶珯
-    public synchronized void shiftCyclePointToTarget() throws IOException, InterruptedException{
-        try{
+    // 112寰幆绔欑偣鑷冲嚭搴撶珯
+    public synchronized void shiftCyclePointToTarget() throws IOException, InterruptedException {
+        try {
             for (DevpSlave devp : slaveProperties.getDevp()) {
                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+                if (devpThread == null) {
+                    continue;
+                }
+
                 StaProtocol staProtocol = devpThread.getStation().get(112);
-                if (staProtocol == null) {
-                    continue;
-                } else {
-                    staProtocol = staProtocol.clone();
-                }
-                if(staProtocol.getWorkNo() == 0){
+                if (staProtocol == null || staProtocol.getWorkNo() == 0) {
                     continue;
                 }
+
+                // 鏌ヨ浠诲姟淇℃伅
                 TaskWrk taskWrk = taskWrkMapper.selectStaWorking(Integer.valueOf(staProtocol.getWorkNo()));
-                if(taskWrk != null &&  taskWrk.getWrkNo() < 9001 && taskWrk.getWrkNo() > 6000){
-                    staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint()));
-                    MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+                if (taskWrk == null || taskWrk.getWrkNo() < 6001 || taskWrk.getWrkNo() > 9000) {
+                    continue;
                 }
+
+                // 鍏堟竻闆�
+                short workNo = staProtocol.getWorkNo();
+                short oldStaNo = staProtocol.getStaNo();
+                staProtocol.setWorkNo((short) 0);
+                staProtocol.setStaNo((short) 0);
+                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+                Thread.sleep(100); // 璁� PLC 璇嗗埆鍙樺寲
+
+                // 鍐嶅啓鍏ョ洰鏍囩珯鐐�
+                staProtocol.setWorkNo(workNo);
+                staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint()));
+                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+
+                log.info("Shifted from cycle station 112 to target {}, workNo: {}", taskWrk.getTargetPoint(), workNo);
             }
-        }catch (Exception e) {
-            log.error("generateStoreWrkFile e", e);
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+        } catch (Exception e) {
+            log.error("shiftCyclePointToTarget error", e);
         }
     }
 
 
 
 
+
     public synchronized void generateStoreWrkFile1() throws IOException, InterruptedException {
         try {
             // 鏍规嵁杈撻�佺嚎plc閬嶅巻

--
Gitblit v1.9.1