From ae1b1eefcfcaae12753466e6b8a77944cc96a688 Mon Sep 17 00:00:00 2001
From: cl <1442464845@qq.com>
Date: 星期五, 20 三月 2026 11:29:06 +0800
Subject: [PATCH] 有组托阻止出库

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  155 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 100 insertions(+), 55 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 8e0f034..783bca5 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -8,6 +8,7 @@
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
 import com.zy.asrs.mapper.BasCrnErrorMapper;
+import com.zy.asrs.mapper.WaitPakinMapper;
 import com.zy.asrs.mapper.WrkMastMapper;
 import com.zy.asrs.service.*;
 import com.zy.asrs.utils.Utils;
@@ -85,6 +86,8 @@
     @Autowired
     private WrkMastService wrkMastService;
     @Autowired
+    private WaitPakinMapper waitPakinMapper;
+    @Autowired
     private ConfigService configService;
     @Autowired
     private RedisUtil redisUtil;
@@ -96,7 +99,7 @@
      * 缁勬墭
      * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2
      */
-    public synchronized void generateStoreWrkFile(Integer mark) {
+    public synchronized void generateStoreWrkFile(Integer mark) throws InterruptedException {
         // 鏍规嵁杈撻�佺嚎plc閬嶅巻
         for (DevpSlave devp : slaveProperties.getDevp()) {
             // 閬嶅巻鍏ュ簱鍙�
@@ -167,51 +170,52 @@
                             continue;
                         }
                     }
-                    if (wrkMast != null) {
-                        News.error("" + mark + " - 4" + " - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 3.寮�濮嬫墽琛屽叆搴撲换鍔� 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
+//                    if (wrkMast != null) {
+//                        News.error("" + mark + " - 4" + " - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 3.寮�濮嬫墽琛屽叆搴撲换鍔� 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
 
                         // led 寮傚父鏄剧ず
 //                        if (ledThread != null) {
 //                            String errorMsg = "宸ヤ綔妗e凡瀛樺湪璇ユ潯鐮佸彿===>>" + barcode;
 //                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
 //                        }
-                        LiftProtocol liftProtocol = devpThread.getLiftStatus();
-
-                        if (liftProtocol == null) {
-                            continue;
-                        }
-                        if (liftProtocol.getMode() != 1) {
-                            continue;
-                        }
-                        if (liftProtocol.getDeviceStatus() != 0) {
-                            continue;
-                        }
-                        if (liftProtocol.getWorkNo() > 0) {
-                            continue;
-                        }
-
-                        Integer staNo = Utils.getStaNoByLocNo(wrkMast.getLocNo());
-
-                        LiftCommand command = new LiftCommand();
-                        command.setWorkNo(wrkMast.getWrkNo());
-                        command.setSourceStaNo(inSta.getStaNo());
-                        command.setTargetStaNo(staNo);
-
-                        barcodeThread.setBarcode("");
-
-                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, command));
-                        if (result) {
-                            News.info("WCS--->PLC涓嬪彂浠诲姟鎴愬姛:{}",command.toString());
-                        }
-                        if (!result) {
-                            throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
-                        }
-
-                        wrkMast.setWrkSts(3L);// 3.璁惧鎵ц涓�
-                        wrkMast.setCrnStrTime(new Date());
-                        wrkMastService.updateById(wrkMast);
-                        break;
-                    }
+//                        LiftProtocol liftProtocol = devpThread.getLiftStatus();
+//
+//                        if (liftProtocol == null) {
+//                            continue;
+//                        }
+//                        if (liftProtocol.getMode() != 1) {
+//                            continue;
+//                        }
+//                        if (liftProtocol.getDeviceStatus() != 0) {
+//                            continue;
+//                        }
+//                        if (liftProtocol.getWorkNo() > 0) {
+//                            continue;
+//                        }
+//
+//                        Integer staNo = Utils.getStaNoByLocNo(wrkMast.getLocNo());
+//
+//                        LiftCommand command = new LiftCommand();
+//                        command.setWorkNo(wrkMast.getWrkNo());
+//                        command.setSourceStaNo(inSta.getStaNo());
+//                        command.setTargetStaNo(staNo);
+//
+//                        barcodeThread.setBarcode("");
+//
+//                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, command));
+//                        if (result) {
+//                            News.info("WCS--->PLC涓嬪彂浠诲姟鎴愬姛:{}",command.toString());
+//                        }
+//                        if (!result) {
+//                            throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+//                        }
+//
+//                        wrkMast.setWrkSts(3L);// 3.璁惧鎵ц涓�
+//                        wrkMast.setCrnStrTime(new Date());
+//                        wrkMastService.updateById(wrkMast);
+//                        Thread.sleep(300);// 寤舵椂3S
+//                        continue;
+//                    }
 
                     LiftProtocol liftProtocol = devpThread.getLiftStatus();
                     if(liftProtocol == null) {
@@ -274,25 +278,55 @@
                             wrkMastService.updateById(currentWrkMast);
                             Thread.sleep(3000); // 寤舵椂3S
                         } else {
-                            News.error("" + mark + " - 5" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+//                            News.error("" + mark + " - 5" + " - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
 
                             // led 寮傚父鏄剧ず
-                            if (ledThread != null) {
-                                String errorMsg = jsonObject.getString("msg");
-                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
-                            }
-
+//                            if (ledThread != null) {
+//                                String errorMsg = jsonObject.getString("msg");
+//                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+//                            }
                             //鎵樼洏閫�鍥�
 //                            LiftCommand command = new LiftCommand();
 //                            command.setWorkNo(9998);
 //                            command.setSourceStaNo(inSta.getStaNo());
 //                            command.setTargetStaNo(inSta.getBackSta());
-                            Integer back = 999;
+                            if (wrkMast != null){
+                                Integer staNo = Utils.getStaNoByLocNo(wrkMast.getLocNo());
 
-                            barcodeThread.setBarcode("");
-                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, back));
-                            if (!result) {
-                                throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                                LiftCommand commandEmpty = new LiftCommand();
+                                commandEmpty.setWorkNo(wrkMast.getWrkNo());
+                                commandEmpty.setSourceStaNo(inSta.getStaNo());
+                                commandEmpty.setTargetStaNo(staNo);
+
+                                barcodeThread.setBarcode("");
+
+                                boolean resultEmpty = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, commandEmpty));
+                                if (resultEmpty) {
+                                    News.info("WCS--->PLC涓嬪彂浠诲姟鎴愬姛:{}",commandEmpty.toString());
+                                }
+                                if (!resultEmpty) {
+                                    throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                                }
+
+                                wrkMast.setWrkSts(3L);// 3.璁惧鎵ц涓�
+                                wrkMast.setCrnStrTime(new Date());
+                                wrkMastService.updateById(wrkMast);
+                                Thread.sleep(3000); // 寤舵椂3S
+                            }else {
+                                // 鏈粍鎵樻墭鐩橀��鍥� 鐢佃鏈烘樉绀鸿鍏堢粍鎵�
+                                Integer back = 999;
+                                if (ledThread != null) {
+                                    String errorMsg = jsonObject.getString("msg");
+                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+                                }
+                                barcodeThread.setBarcode("");
+                                boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, back));
+                                if (result) {
+                                    log.error("鎵樼洏閫�鍥炰换鍔′笅鍙戞垚鍔�");
+                                }
+                                if (!result) {
+                                    throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                                }
                             }
                         }
 
@@ -521,10 +555,21 @@
 //        if (!staProtocol.isOutEnable()) {
 //            return;
 //        }
-
-        //妫�鏌ユ槸鍚︽湁姝e湪鎵ц鐨勪换鍔�
-        List<WrkMast> workingWrkMast = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", 3, 12));
-        if (!workingWrkMast.isEmpty()) {
+        // 缁勬墭妗e瓨鍦ㄥ凡缁勬墭鏈叆搴撳垯绛夊緟锛屼笉涓嬪彂鍑哄簱
+        int waitPakinNotIn = waitPakinMapper.selectCount(new EntityWrapper<WaitPakin>()
+                .eq("status", "Y"));
+        if (waitPakinNotIn > 0) {
+            return;
+        }
+        // 瀛樺湪杩涜涓�/鍦ㄩ�斾换鍔�(2,3,12,13,14)鍒欎笉涓嬪彂鍑哄簱锛岄伩鍏嶅啿绐�
+        // 2 寰呮墽琛岋紙鍏ュ簱锛�
+        //3 璁惧鎵ц涓紙鍏ュ簱锛�
+        //12 璁惧鎵ц涓紙鍑哄簱锛�
+        //13 鍑哄簱鍒扮珯鐐逛笂
+        //14 鍑哄簱绛夊緟纭
+        int activeCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>()
+                .in("wrk_sts", 2, 3, 12, 13, 14));
+        if (activeCount > 0) {
             return;
         }
 

--
Gitblit v1.9.1