From 62ba3824387832e3ef1d43e91d0d079b6f8b11d9 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期四, 06 六月 2024 16:21:31 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   95 +++++++++++++++++++++++++++++++++++++----------
 1 files changed, 74 insertions(+), 21 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 13036b1..e77aeab 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -10,6 +10,7 @@
 import com.zy.asrs.entity.*;
 import com.zy.asrs.mapper.*;
 import com.zy.asrs.service.*;
+import com.zy.asrs.utils.CodeDetectionUtil;
 import com.zy.asrs.utils.RouteUtils;
 import com.zy.asrs.utils.Utils;
 import com.zy.asrs.utils.VersionUtils;
@@ -103,6 +104,8 @@
     private RgvOneSignMapper rgvOneSignMapper;
     @Autowired
     private WrkMastCrnMapper wrkMastCrnMapper;
+    @Autowired
+    private WrkMastSplitTwinMapper wrkMastSplitTwinMapper;
 
     @Value("${wms.url}")
     private String wmsUrl;
@@ -125,7 +128,7 @@
 
                 if (!Cools.isEmpty(barcode)) {
 //                    log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
-                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                         continue;
                     }
                 } else {
@@ -294,7 +297,7 @@
 
                 if (!Cools.isEmpty(barcode)) {
 //                    log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
-                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                         continue;
                     }
                 } else {
@@ -366,7 +369,7 @@
                         && staProtocol.getWorkNo() == 0
                         && staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) {
 
-                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                         log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
 //                        //鏉$爜涓虹┖鎴栬�呬笉绗﹀悎锛岄��搴撳埌172绔欑偣
 //                        staProtocol.setWorkNo((short)32222);
@@ -463,7 +466,7 @@
 
                 if (!Cools.isEmpty(barcode)) {
 //                    log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
-                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                         continue;
                     }
                 } else {
@@ -535,7 +538,7 @@
                         && staProtocol.getWorkNo() == 0
                         && staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) {
 
-                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
+                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                         log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
 //                        //鏉$爜涓虹┖鎴栬�呬笉绗﹀悎锛岄��搴撳埌172绔欑偣
 //                        staProtocol.setWorkNo((short)32222);
@@ -1926,8 +1929,8 @@
                 log.error("鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
                 continue;
             }
-            if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
-                    && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) {
+            if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo().equals(wrkMast.getWrkNo())
+                    && staProtocol.isInEnable() && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) {
                 flag = true;
             }
             if (!flag) {
@@ -1968,6 +1971,12 @@
             // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
             if (wrkMastMapper.selectWorking(slave.getId()) != null) {
                 continue;
+            }
+
+            // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
+            if (wrkMastSplitTwinMapper.selectCount(new EntityWrapper<WrkMastSplitTwin>().eq("wrk_no", wrkMast.getWrkNo().longValue())) != 0) {
+                break;
+//                        return;
             }
 
             // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞�
@@ -2017,9 +2026,9 @@
             crnCommand.setSourcePosX(crnStn.getRow().shortValue());     // 婧愬簱浣嶆帓
             crnCommand.setSourcePosY(crnStn.getBay().shortValue());     // 婧愬簱浣嶅垪
             crnCommand.setSourcePosZ(crnStn.getLev().shortValue());     // 婧愬簱浣嶅眰
-            crnCommand.setDestinationPosX(locMast.getRow1().shortValue());     // 鐩爣搴撲綅鎺�
-            crnCommand.setDestinationPosY(locMast.getBay1().shortValue());     // 鐩爣搴撲綅鍒�
-            crnCommand.setDestinationPosZ(locMast.getLev1().shortValue());     // 鐩爣搴撲綅灞�
+            crnCommand.setDestinationPosX((short)0);     // 鐩爣搴撲綅鎺�
+            crnCommand.setDestinationPosY((short)0);     // 鐩爣搴撲綅鍒�
+            crnCommand.setDestinationPosZ((short)0);     // 鐩爣搴撲綅灞�
             if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(crnStation==1? 2:5, crnCommand))) {
                 log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
             } else {
@@ -2028,9 +2037,27 @@
                 wrkMast.setWrkSts(3L);
                 wrkMast.setCrnStrTime(now);
                 wrkMast.setModiTime(now);
+                WrkMastSplitTwin wrkMastSplitTwin = new WrkMastSplitTwin(wrkMast,crnStation,now);
+                wrkMastSplitTwin.setWrkSts(1);
+                wrkMastSplitTwin.setWrkStart(wrkMast.getStaNo().toString());
+                wrkMastSplitTwin.setWrkEnd(wrkMast.getLocNo());
+                wrkMastSplitTwin.setStartRow(crnStn.getRow());
+                wrkMastSplitTwin.setStartBay(crnStn.getBay());
+                wrkMastSplitTwin.setStartLev(crnStn.getLev());
+                wrkMastSplitTwin.setEndRow(locMast.getRow1());
+                wrkMastSplitTwin.setEndBay(locMast.getBay1());
+                wrkMastSplitTwin.setEndLev(locMast.getLev1());
+                wrkMastSplitTwin.setWrkType(1);
+                wrkMastSplitTwin.setIoType(1);
+
                 if (wrkMastMapper.updateById(wrkMast) == 0) {
                     log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
                 }
+
+                if (wrkMastSplitTwinMapper.insert(wrkMastSplitTwin)==0){
+                    log.error("鍒涘缓 鍫嗗灈鏈烘墽琛屼换鍔� 澶辫触锛侊紒锛屽伐浣滃彿={}锛屽爢鍨涙満鍙�={}", wrkMast.getWrkNo(),wrkMast.getCrnNo());
+                }
+                break;
             }
         }
     }
@@ -2079,9 +2106,13 @@
                 log.error("鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
                 continue;
             }
-            if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
-                    && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) {
+            if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo().equals(wrkMast.getWrkNo())
+                    && staProtocol.isInEnable() && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) {
                 flag = true;
+            }
+
+            if (staProtocol.getWorkNo().equals(staProtocolOther.getWorkNo())){
+                continue;
             }
 
             // 鏌ヨ绔欑偣璇︾粏淇℃伅
@@ -2206,8 +2237,8 @@
                 log.error("鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
                 continue;
             }
-            if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
-                    && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) {
+            if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo().equals(wrkMast.getWrkNo())
+                    && staProtocol.isInEnable() && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) {
                 flag = true;
             }
             if (!flag) {
@@ -2332,7 +2363,7 @@
                 // 鑾峰彇婧愬簱浣嶄俊鎭�
                 LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
                 if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) {
-                    log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts());
+                    log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getSourceLocNo(), sourceSta.getLocSts());
                     continue;
                 }
                 // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅
@@ -2486,7 +2517,7 @@
             // 鑾峰彇婧愬簱浣嶄俊鎭�
             LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
             if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) {
-                log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts());
+                log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getSourceLocNo(), sourceSta.getLocSts());
                 continue;
             }
             // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅
@@ -2646,7 +2677,7 @@
             // 鑾峰彇婧愬簱浣嶄俊鎭�
             LocMast sourceSta = locMastService.selectById(wrkMastCrn.getSourceLocNo());
             if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) {
-                log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMastCrn.getLocNo(), sourceSta.getLocSts());
+                log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMastCrn.getSourceLocNo(), sourceSta.getLocSts());
                 continue;
             }
             // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅
@@ -2788,7 +2819,7 @@
             // 鑾峰彇婧愬簱浣嶄俊鎭�
             LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
             if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) {
-                log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getLocNo(), sourceSta.getLocSts());
+                log.error("鍑哄簱鎿嶄綔搴撲綅鐘舵�佷笉绗﹀悎--鐘舵��, 搴撲綅鍙�={}锛屽簱浣嶇姸鎬�={}", wrkMast.getSourceLocNo(), sourceSta.getLocSts());
                 continue;
             }
             // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅
@@ -2892,6 +2923,12 @@
 //                        return;
                 }
 
+                // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊�
+                if (wrkMastSplitTwinMapper.selectCount(new EntityWrapper<WrkMastSplitTwin>().eq("wrk_no", wrkMast.getWrkNo().longValue())) != 0) {
+                    break;
+//                        return;
+                }
+
                 // 1.鍫嗗灈鏈哄紑濮嬬Щ鍔�
                 CrnCommand crnCommand = new CrnCommand();
                 crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
@@ -2901,9 +2938,9 @@
                 crnCommand.setSourcePosX(sourceSta.getRow1().shortValue());     // 婧愬簱浣嶆帓
                 crnCommand.setSourcePosY(sourceSta.getBay1().shortValue());     // 婧愬簱浣嶅垪
                 crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue());     // 婧愬簱浣嶅眰
-                crnCommand.setDestinationPosX(crnStn.getRow().shortValue());     // 鐩爣搴撲綅鎺�
-                crnCommand.setDestinationPosY(crnStn.getBay().shortValue());     // 鐩爣搴撲綅鍒�
-                crnCommand.setDestinationPosZ(crnStn.getLev().shortValue());     // 鐩爣搴撲綅灞�
+                crnCommand.setDestinationPosX((short)0);     // 鐩爣搴撲綅鎺�
+                crnCommand.setDestinationPosY((short)0);     // 鐩爣搴撲綅鍒�
+                crnCommand.setDestinationPosZ((short)0);     // 鐩爣搴撲綅灞�
                 if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(crnStation==1? 2:5, crnCommand))) {
                     log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
                 } else {
@@ -2912,9 +2949,25 @@
                     wrkMast.setWrkSts(12L);
                     wrkMast.setCrnStrTime(now);
                     wrkMast.setModiTime(now);
+                    WrkMastSplitTwin wrkMastSplitTwin = new WrkMastSplitTwin(wrkMast,crnStation,now);
+                    wrkMastSplitTwin.setWrkSts(1);
+                    wrkMastSplitTwin.setWrkStart(wrkMast.getSourceLocNo());
+                    wrkMastSplitTwin.setWrkEnd(wrkMast.getSourceStaNo().toString());
+                    wrkMastSplitTwin.setStartRow(sourceSta.getRow1());
+                    wrkMastSplitTwin.setStartBay(sourceSta.getBay1());
+                    wrkMastSplitTwin.setStartLev(sourceSta.getLev1());
+                    wrkMastSplitTwin.setEndRow(crnStn.getRow());
+                    wrkMastSplitTwin.setEndBay(crnStn.getBay());
+                    wrkMastSplitTwin.setEndLev(crnStn.getLev());
+                    wrkMastSplitTwin.setWrkType(1);
+                    wrkMastSplitTwin.setIoType(2);
                     if (wrkMastMapper.updateById(wrkMast) == 0) {
                         log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo());
                     }
+
+                    if (wrkMastSplitTwinMapper.insert(wrkMastSplitTwin)==0){
+                        log.error("鍒涘缓 鍫嗗灈鏈烘墽琛屼换鍔� 澶辫触锛侊紒锛屽伐浣滃彿={}锛屽爢鍨涙満鍙�={}", wrkMast.getWrkNo(),wrkMast.getCrnNo());
+                    }
                     break;
                 }
             }

--
Gitblit v1.9.1