From d297de1055d785752ad04d32d70c3a1e4e8af2c3 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 01 十二月 2023 16:23:51 +0800
Subject: [PATCH] #盘点逻辑

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  143 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 142 insertions(+), 1 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 071aa78..7fefcb4 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -405,6 +405,126 @@
         for (DevpSlave devp : slaveProperties.getDevp()) {
             // 閬嶅巻鎷f枡鍏ュ簱鍙�
             for (DevpSlave.Sta pickSta : devp.getPickInSta()) {
+                if (pickSta.getStaNo() == 325 || pickSta.getStaNo() == 331 || pickSta.getStaNo() == 333 || pickSta.getStaNo() == 339) {
+                    continue;
+                }
+
+                // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭�
+                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+                StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
+                if (staProtocol == null) {
+                    continue;
+                } else {
+                    staProtocol = staProtocol.clone();
+                }
+                if (staProtocol.isAutoing()
+                        && staProtocol.isLoading()
+                        && staProtocol.isInEnable()
+//                        && (staProtocol.getWorkNo() > 0)
+                        && staProtocol.isPakMk()){
+
+                    // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
+                    if (barcodeThread == null) {
+                        continue;
+                    }
+                    String barcode = barcodeThread.getBarcode();
+                    if(Cools.isEmpty(barcode)) {
+                        continue;
+                    }
+                    if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
+                        continue;
+                    }
+
+                    WrkMast wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode);
+                    if (wrkMast == null) {//鎵句笉鍒板伐浣滄。
+                        continue;
+                    }
+
+                    if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
+                            || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) {
+                        continue;
+                    }
+
+                    //*********************鍚屽簱浣嶇粍鏍¢獙*********************
+                    boolean flag = false;
+                    String th = "";
+                    List<String> innerLoc = Utils.getGroupInnerLoc(wrkMast.getSourceLocNo());
+                    for (String loc : innerLoc) {
+                        LocMast locMast = locMastService.selectById(loc);
+                        if (locMast == null) {
+                            continue;
+                        }
+
+                        if (!locMast.getLocSts().equals("F")) {
+                            flag = true;
+                            th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�";
+                            break;
+                        }
+                    }
+                    if (flag) {
+                        News.info(th);
+                        continue;
+                    }
+                    //*********************鍚屽簱浣嶇粍鏍¢獙*********************
+
+                    // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
+                    if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
+                        News.info(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�");
+                        continue;
+                    }
+
+                    String sourceLocNo = wrkMast.getSourceLocNo().trim();
+                    LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯
+                    if (liftStaProtocol == null) {
+                        continue;
+                    }
+
+                    // 鏇存柊宸ヤ綔妗f暟鎹姸鎬�
+                    wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57
+                    wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋
+                    wrkMast.setSourceStaNo(pickSta.getBackSta()); // 婧愮珯
+//                            wrkMast.setStaNo(dto.getStaNo()); // 鐩爣绔�
+//                            wrkMast.setCrnNo(dto.getCrnNo());
+                    wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔�
+                    wrkMast.setLocNo(sourceLocNo); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣�
+                    wrkMast.setShuttleNo(null); // 绌挎杞︽竻绌�
+                    wrkMast.setLiftNo(null);// 鎻愬崌鏈烘竻绌�
+                    wrkMast.setModiTime(new Date());
+                    if (wrkMastMapper.updateById(wrkMast) == 0) {
+                        News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+                        continue;
+                    }
+                    if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
+                        News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+                        continue;
+                    }
+
+                    // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴�
+                    LocMast locMast = locMastService.selectById(sourceLocNo);
+                    locMast.setLocSts("Q");
+                    locMast.setModiTime(new Date());
+                    if (!locMastService.updateById(locMast)) {
+                        News.info("淇敼搴撲綅鐘舵�佸け璐�");
+                        continue;
+                    }
+                }
+            }
+
+        }
+    }
+
+    /**
+     * 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱(325銆�331銆�333銆�339)
+     */
+    @Transactional
+    public synchronized void stnToCrnStnPick2(){
+        for (DevpSlave devp : slaveProperties.getDevp()) {
+            // 閬嶅巻鎷f枡鍏ュ簱鍙�
+            for (DevpSlave.Sta pickSta : devp.getPickInSta()) {
+                if (!(pickSta.getStaNo() == 325 || pickSta.getStaNo() == 331 || pickSta.getStaNo() == 333 || pickSta.getStaNo() == 339)) {
+                    continue;
+                }
 
                 // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭�
                 DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
@@ -493,7 +613,6 @@
                         continue;
                     }
 
-                    staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());//鍐欏叆宸ヤ綔鍙�
                     staProtocol.setStaNo(pickSta.getBackSta().shortValue());//鍐欏叆鐩爣绔�
                     MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                 }
@@ -1287,6 +1406,28 @@
                 return false;//绔欑偣涓嶅彲鍏�
             }
 
+            Integer barcodeId = Utils.getBarcodeIdByStaNo(wrkMast.getSourceStaNo());
+            if (barcodeId == null) {
+                News.info("{}浠诲姟锛寋}婧愮珯锛屾壘涓嶅埌鍙敤鏉$爜鍣↖D", wrkMast.getWrkNo(), sourceBasDevp.getDevNo());
+                return false;//绔欑偣涓嶅彲鍏�
+            }
+
+            BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId);
+            if (barcodeThread == null) {
+                News.info("{}浠诲姟锛寋}婧愮珯锛屾潯鐮佸櫒{}绾跨▼涓虹┖", wrkMast.getWrkNo(), sourceBasDevp.getDevNo(), barcodeId);
+                return false;//绔欑偣涓嶅彲鍏�
+            }
+            String barcode = barcodeThread.getBarcode();
+            if(!Cools.isEmpty(barcode)) {
+                if(!("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode))) {
+                    //瀛樺湪鏉$爜鍊硷紝鍒ゆ柇鏄惁鍜屽綋鍓嶅伐浣滄。涓�鑷�
+                    if (!barcode.equals(wrkMast.getBarcode())) {
+                        News.info("{}浠诲姟锛屾潯鐮佸櫒{}鍊納}涓庡伐浣滄。鏉$爜鍊间笉涓�鑷达紝绯荤粺璺宠繃鎵ц", wrkMast.getWrkNo(), sourceBasDevp.getDevNo(), barcodeId, barcode);
+                        return false;//绔欑偣涓嶅彲鍏�
+                    }
+                }
+            }
+
             //鍒ゆ柇鎻愬崌鏈烘暣涓笁妤兼槸鍚﹂兘澶勪簬鍏ュ簱妯″紡
             Integer outInModel1 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 1);
             Integer outInModel2 = Utils.getOutInModelByLift(sourceBasDevp.getLiftNo(), 5);

--
Gitblit v1.9.1