From a439542ebcd5466ebc544741bca13d82955580ce Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期二, 22 二月 2022 16:18:24 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   54 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 49 insertions(+), 5 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 e753cd9..d32e861 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -7,7 +7,6 @@
 import com.core.common.Cools;
 import com.core.common.DateUtils;
 import com.core.exception.CoolException;
-import com.zy.asrs.domain.enums.WorkNoType;
 import com.zy.asrs.entity.*;
 import com.zy.asrs.mapper.BasCrnErrorMapper;
 import com.zy.asrs.mapper.WaitPakinMapper;
@@ -17,11 +16,11 @@
 import com.zy.asrs.utils.VersionUtils;
 import com.zy.common.model.LocTypeDto;
 import com.zy.common.model.MatDto;
+import com.zy.common.model.SearchLocParam;
 import com.zy.common.model.StartupDto;
 import com.zy.common.service.CommonService;
 import com.zy.common.utils.CollectionUtils;
 import com.zy.common.utils.HttpHandler;
-import com.zy.common.model.SearchLocParam;
 import com.zy.core.CrnThread;
 import com.zy.core.DevpThread;
 import com.zy.core.cache.MessageQueue;
@@ -304,6 +303,21 @@
         for (DevpSlave devp : slaveProperties.getDevp()) {
             // 閬嶅巻鎷f枡鍏ュ簱鍙�
             for (DevpSlave.Sta pickSta : devp.getPickSta()) {
+                // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
+                if (barcodeThread == null) {
+                    continue;
+                }
+                String barcode = barcodeThread.getBarcode();
+                if(!Cools.isEmpty(barcode)) {
+                    log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode);
+                    if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+                        continue;
+                    }
+                } else {
+                    continue;
+                }
+
                 // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭�
                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                 StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
@@ -1116,6 +1130,8 @@
                 if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
                     log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
                     continue;
+                } else {
+                    ledThread.setLedMk(false);
                 }
             }
 
@@ -1145,6 +1161,33 @@
      */
     @Async
     public void ledReset() {
+//        for (LedSlave led : slaveProperties.getLed()) {
+//            // 鑾峰彇杈撻�佺嚎plc绾跨▼
+//            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
+//            // 鍛戒护闆嗗悎
+//            boolean reset = true;
+//            for (Integer staNo : led.getStaArr()) {
+//                // 鑾峰彇鍙夎溅绔欑偣
+//                StaProtocol staProtocol = devpThread.getStation().get(staNo);
+//                if (staProtocol == null) {
+//                    continue;
+//                } else {
+//                    staProtocol = staProtocol.clone();
+//                }
+//                if (staProtocol.getWorkNo() != 0) {
+//                    reset = false;
+//                    break;
+//                }
+//            }
+//            // 鑾峰彇led绾跨▼
+//            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId());
+//            // led鏄剧ず榛樿鍐呭
+//            if (reset) {
+//                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
+//                    log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+//                }
+//            }
+//        }
         for (LedSlave led : slaveProperties.getLed()) {
             // 鑾峰彇杈撻�佺嚎plc绾跨▼
             DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
@@ -1155,8 +1198,6 @@
                 StaProtocol staProtocol = devpThread.getStation().get(staNo);
                 if (staProtocol == null) {
                     continue;
-                } else {
-                    staProtocol = staProtocol.clone();
                 }
                 if (staProtocol.getWorkNo() != 0) {
                     reset = false;
@@ -1166,9 +1207,12 @@
             // 鑾峰彇led绾跨▼
             LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId());
             // led鏄剧ず榛樿鍐呭
-            if (reset) {
+            if (reset && !ledThread.isLedMk()) {
+                ledThread.setLedMk(true);
                 if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
                     log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+                } else {
+
                 }
             }
         }

--
Gitblit v1.9.1