From bbf283177eee80b573b583f2e29e62531eaf7f0a Mon Sep 17 00:00:00 2001
From: pang.jiabao <pang_jiabao@163.com>
Date: 星期六, 26 十月 2024 16:43:15 +0800
Subject: [PATCH] 入库过滤盘点再入库

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   83 +++++++++++++++++++++++++++++------------
 1 files changed, 59 insertions(+), 24 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 3bc9660..bade34f 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -96,7 +96,7 @@
      * 缁勬墭
      * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2
      */
-    public synchronized void generateStoreWrkFile(Integer mark) {
+    public synchronized void generateStoreWrkFile(Integer mark) throws InterruptedException {
         // 鏍规嵁杈撻�佺嚎plc閬嶅巻
         for (DevpSlave devp : slaveProperties.getDevp()) { //閬嶅巻杈撻�佺嚎
             // 閬嶅巻鍏ュ簱鍙�
@@ -125,10 +125,7 @@
                   鏄�2鍙疯緭閫佺嚎9995鎷f枡浠诲姟
                  */
                 String barcode = barcodeThread.getBarcode();
-                if (Cools.isEmpty(barcode) || !staProtocol.isInEnable() || staProtocol.isEmptyMk()
-                || !staProtocol.isFullPlt() || (staProtocol.getWorkNo() == 9995 && devp.getId() == 2)) {
-                    continue;
-                }
+
 
                 // 灏哄妫�娴嬪紓甯�
                 boolean back = false;
@@ -192,6 +189,12 @@
                     devpThread.setPakMk(staProtocol.getSiteId(), false);
                     MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                     MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errMsg));
+                    Thread.sleep(500);
+                }
+
+                if (Cools.isEmpty(barcode) || !staProtocol.isInEnable() || staProtocol.isEmptyMk()
+                        || !staProtocol.isFullPlt() || (staProtocol.getWorkNo() <= 9000 && devp.getId() == 2)) {
+                    continue;
                 }
 
                 if (staProtocol.isAutoing() && staProtocol.isInEnable()
@@ -202,15 +205,17 @@
                     //杩囨护鍒ゆ柇锛岄槻姝㈡嫞鏂欏啀鍏ュ簱璐х墿锛岀粡杩囧叆搴撶珯鍐嶅叆搴撴椂锛岃閫�鍥炲埌閫�搴撶珯
                     WrkMast wrkMast1 = wrkMastMapper.selectPakInStepBarcode(barcode);
                     if (wrkMast1 !=null){
-                        if (wrkMast1.getIoType()==103 || wrkMast1.getIoType()==107 || wrkMast1.getIoType()==104){
+                        if (wrkMast1.getIoType()==103 || wrkMast1.getIoType() == 53 || wrkMast1.getIoType()==107 || wrkMast1.getIoType()== 57 || wrkMast1.getIoType()==104){
                             continue;
                         }
                     }
                     if (wrkMast != null) {
-                        News.warn(""+mark+" - 4"+" - 宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
+                        News.warn(""+mark+" - 4"+" - 婊℃墭鐩樺叆搴撳伐浣滄。涓凡瀛樺湪璇ョ珯鐘舵�佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
                         if (devp.getId() == 2) {
-                            staProtocol.setWorkNo((short)9999);
-                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
+//                            staProtocol.setWorkNo((short)9999);
+//                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
+                            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
+                            staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                             devpThread.setPakMk(staProtocol.getSiteId(), false);
                             boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                             if (!result) {
@@ -221,7 +226,7 @@
                         // led 寮傚父鏄剧ず
                         if (ledThread != null) {
                             String errorMsg = "宸ヤ綔妗e凡瀛樺湪璇ユ潯鐮佸彿===>>" + barcode;
-                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
+//                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
                         }
                         continue;
                     }
@@ -264,17 +269,26 @@
                                 ledCommand.setTitle("鍏ㄦ澘鍏ュ簱");
                                 ledCommand.setLocNo(dto.getLocNo());
                                 ledCommand.setStaNo(dto.getStaNo());
+                                ArrayList<MatDto> matDtos = new ArrayList<>();
+                                MatDto matDto = new MatDto();
+                                matDto.setLocNo(dto.getLocNo());
+                                matDtos.add(matDto);
+                                ledCommand.setMatDtos(matDtos);
                                 ledCommand.setBarcode(barcode);
                                 commands.add(ledCommand);
                                 if (devp.getId() == 1) {
-                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(1, commands));
+//                                     if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(1, commands))){
+//                                         ledThread.setLedMk(false);
+//                                     }
                                 } else {
-                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands));
+                                    if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands))){
+                                        ledThread.setLedMk(false);
+                                    }
                                 }
 //                                ledThread.errorReset();
                             }
                         } 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);
                             if(devp.getId() == 2) {
                                 staProtocol.setWorkNo((short)9999);
                                 staProtocol.setStaNo(inSta.getBackSta().shortValue());
@@ -451,6 +465,8 @@
                             .eq("stn_no", stnNo) // 浣滀笟绔欑偣 = 鎷f枡鍑哄簱鐨勭洰鏍囩珯
                             .eq("crn_no", wrkMast.getCrnNo()); // 鍫嗗灈鏈哄彿
                     StaDesc staDesc = staDescService.selectOne(wrapper);
+                    //LED
+                    LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
                     if (Cools.isEmpty(staDesc)) {
                         News.error(""+mark+" - 2"+" - 鍏ュ簱璺緞涓嶅瓨鍦紒type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
                         if (devp.getId() == 2) {
@@ -459,8 +475,7 @@
                             devpThread.setPakMk(staProtocol.getSiteId(), false);
                             MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                         }
-                        //LED
-                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
+
                         // led 寮傚父鏄剧ず
                         if (ledThread != null) {
                             String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�"+pickSta.getBackSta().shortValue()+"绔欑偣";
@@ -516,11 +531,20 @@
                     ledCommand.setLocNo(wrkMast.getLocNo());
                     ledCommand.setStaNo(wrkMast.getStaNo());
                     ledCommand.setBarcode(barcode);
+                    ArrayList<MatDto> matDtos = new ArrayList<>();
+                    MatDto matDto = new MatDto();
+                    matDto.setLocNo(wrkMast.getLocNo());
+                    matDtos.add(matDto);
+                    ledCommand.setMatDtos(matDtos);
                     commands.add(ledCommand);
                     if (devp.getId() == 1) {
-                        MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(1, commands));
+//                        if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(1, commands))) {
+//                            ledThread.setLedMk(false);
+//                        }
                     } else {
-                        MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, commands));
+                        if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, commands))){
+                            ledThread.setLedMk(false);
+                        }
                     }
 
                     // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
@@ -1534,7 +1558,13 @@
                         && staProtocol.isLoading()
                 ) {
                     News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛岋細绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐�");
-
+                    // 鍒ゆ柇涓婁竴涓┖鎵樺叆搴撳啓鍏ュ悗锛岀嚎绋嬭繕璇诲彇鍒帮紝閫犳垚閲嶅璇锋眰
+                    List<WrkMast> wrkMastList = wrkMastMapper.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts",2)
+                            .eq("io_type",10).eq("source_sta_no",emptyInSta.getStaNo()));
+                    if(!wrkMastList.isEmpty()) {
+                        log.warn("鏌ヨ鍒颁竴涓湪璁惧涓婅蛋浠诲姟锛歿}",wrkMastList.get(0).getWrkNo());
+                        continue;
+                    }
                     try {
                         LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
 
@@ -1561,7 +1591,6 @@
                                 News.errorNoLog(""+mark+" - 1"+" - 鏇存柊plc绔欑偣淇℃伅澶辫触");
                                 throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
                             }
-
                             if (ledThread != null) {
                                 // 鍛戒护闆嗗悎
                                 List<LedCommand> commands = new ArrayList<>();
@@ -1573,17 +1602,23 @@
                                 ledCommand.setLocNo(dto.getLocNo());
                                 ledCommand.setStaNo(dto.getStaNo());
                                 ledCommand.setBarcode("");
+                                ArrayList<MatDto> matDtos = new ArrayList<>();
+                                MatDto matDto = new MatDto();
+                                matDto.setLocNo(dto.getLocNo());
+                                matDtos.add(matDto);
+                                ledCommand.setMatDtos(matDtos);
                                 commands.add(ledCommand);
                                 if (devp.getId() == 1) {
-                                    MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(1, commands));
+//                                    MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(1, commands));
                                 } else {
                                     MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, commands));
                                 }
 //                                ledThread.errorReset();
                             }
+                            Thread.sleep(1000);
                         } else {
                             staProtocol.setWorkNo((short)9991);
-                            staProtocol.setStaNo((short)100);
+                            staProtocol.setStaNo(emptyInSta.getBackSta().shortValue());
                             devpThread.setPakMk(staProtocol.getSiteId(), false);
                             boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                             if (!result) {
@@ -1597,7 +1632,7 @@
                                     MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg));
                                 }
                             }
-                            News.error(""+mark+" - 3"+" - 璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+                            News.error(""+mark+" - 3"+" - 绌烘澘鍏ュ簱璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                         }
                     } catch (Exception e) {
                         e.printStackTrace();
@@ -1627,7 +1662,7 @@
             // 宸ヤ綔妗i泦鍚�
             List<WrkMast> wrkMasts = new ArrayList<>();
             for (Integer staNo : led.getStaArr()) {
-                if (staNo == 104 || staNo == 204) {
+                if (staNo == 104 || staNo == 204 || staNo == 304) {
                     continue;
                 }
                 // 鑾峰彇鍙夎溅绔欑偣
@@ -1704,7 +1739,7 @@
                     } else {
                         ledThread.setLedMk(false);
                     }
-                } else {
+                } else if(led.getId() == 1 || led.getId() == 2){
                     if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
                         News.error(""+mark+" - 3"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
                         continue;

--
Gitblit v1.9.1