From de9702be46355443acf6522bcd7c6adc01547091 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期一, 24 三月 2025 15:43:15 +0800
Subject: [PATCH] #优化输送线循环逻辑

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   37 +++++++++++++++++++++++++++++--------
 src/main/resources/application.yml                          |    2 +-
 2 files changed, 30 insertions(+), 9 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 b03a68a..980186a 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -39,6 +39,7 @@
 import com.zy.core.thread.SiemensDevpThread;
 import com.zy.system.entity.Config;
 import com.zy.system.service.ConfigService;
+import lombok.Synchronized;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -113,7 +114,8 @@
     @Autowired
     private SiteController siteController;
     //鍑哄簱绔欑偣鑷�112寰幆绔欑偣
-    public synchronized void shiftTargetToCyclePoint() throws IOException, InterruptedException{
+    @Synchronized
+    public void shiftTargetToCyclePoint() throws IOException, InterruptedException{
         try{
             for (DevpSlave devp : slaveProperties.getDevp()) {
                 for (DevpSlave.Sta outSta : devp.getOutSta()) {
@@ -123,6 +125,7 @@
                     StaProtocol staProtocol2 = devpThread.getStation().get(1002);
                     StaProtocol staProtocol3 = devpThread.getStation().get(1003);
                     StaProtocol staProtocol4 = devpThread.getStation().get(1004);
+                    StaProtocol staProtocol6 = devpThread.getStation().get(111);
                     if (staProtocol == null) {
                         continue;
                     } else {
@@ -148,9 +151,14 @@
                     } else {
                         staProtocol4 = staProtocol4.clone();
                     }
+                    if (staProtocol6 == null) {
+                        continue;
+                    } else {
+                        staProtocol6 = staProtocol6.clone();
+                    }
                     boolean result = false;
                     switch(outSta.getStaNo()){
-                        case 105: if (staProtocol1.isLoading()){
+                        case 105: if (staProtocol1.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 105){
                             result = true;
                         }
                         case 107: if (staProtocol2.isLoading()){
@@ -159,15 +167,28 @@
                         case 109: if (staProtocol3.isLoading()){
                             result = true;
                         }
-                        case 110: if (staProtocol4.isLoading()){
+                        case 110: if ((staProtocol4.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 110) || ((staProtocol6.isLoading() && staProtocol.isLoading() && staProtocol.getStaNo() == 111))){
                             result = true;
                         }
                         default: break;
 
                     }
                     if(result){
-                        staProtocol.setStaNo((short) 112);
-                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+                        if(staProtocol.getSiteId() == 107 || staProtocol.getSiteId() == 109){
+                            StaProtocol staProtocol5 = devpThread.getStation().get(staProtocol.getSiteId() - 1);
+                            if (staProtocol5== null) {
+                                continue;
+                            } else {
+                                staProtocol5 = staProtocol5.clone();
+                            }
+                            if((staProtocol5.isLoading() && staProtocol5.getStaNo() == 107) || ((staProtocol5.isLoading() && staProtocol5.getStaNo() == 109))){
+                                staProtocol5.setStaNo((short) 112);
+                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol5));
+                            }
+                        }else{
+                            staProtocol.setStaNo((short) 112);
+                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+                        }
                     }
                 }
             }
@@ -188,9 +209,9 @@
                 } else {
                     staProtocol = staProtocol.clone();
                 }
-                WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
-                if(wrkMast != null &&  wrkMast.getWrkNo() < 9000 && wrkMast.getWrkNo() > 7000){
-                    staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
+                TaskWrk taskWrk = taskWrkMapper.selectById(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));
                 }
             }
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 38c4a6a..b3b8512 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -45,7 +45,7 @@
 
 wms:
   #鍫嗗灈鏈轰换鍔℃殏瀛樻暟
-  count: 4
+  count: 5
   # 鏄惁寮�鍚笂鎶�
   start: true
   # WMS绯荤粺ip

--
Gitblit v1.9.1