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 |  284 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 162 insertions(+), 122 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 b55123d..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()) { //閬嶅巻杈撻�佺嚎
             // 閬嶅巻鍏ュ簱鍙�
@@ -117,14 +117,15 @@
                     staProtocol = staProtocol.clone();
                 }
 
+                /*
+                  鏃犳潯鐮�
+                  娌℃湁鍙叆淇″彿
+                  鏈夌┖鏉夸俊鍙�
+                  涓嶆槸婊℃墭鐩�
+                  鏄�2鍙疯緭閫佺嚎9995鎷f枡浠诲姟
+                 */
                 String barcode = barcodeThread.getBarcode();
-                if (Cools.isEmpty(barcode)) {
-                    continue;
-                }
 
-                if(!staProtocol.isInEnable()) {
-                    continue;
-                }
 
                 // 灏哄妫�娴嬪紓甯�
                 boolean back = false;
@@ -158,24 +159,19 @@
                     back = true;
                 }
 
-                if (!back && devp.getId() == 2) {
-                    if(staProtocol.getWorkNo() == 9907 && '5' != barcode.charAt(0)){
-                        errMsg = "鏉$爜5鍙兘鍏�7鎺�";
-                        back = true;
-                    }
-                    if(staProtocol.getWorkNo() == 9906 && '5' == barcode.charAt(0)){
-                        errMsg = "鏉$爜5涓嶈兘鍏�6鎺�";
-                        back = true;
-                    }
-                }
-
-                //鎷f枡銆佺洏鐐逛换鍔★紝涓嶈繘鍏ユ柊鏉垮叆搴撴柟娉曪紝鐩存帴璺冲嚭
-                if(staProtocol.getWorkNo() == 9995){
-                    continue;
-                }
+//                if (!back && devp.getId() == 2) {
+//                    if(staProtocol.getWorkNo() == 9907 && '5' != barcode.charAt(0)){
+//                        errMsg = "鏉$爜5鍙兘鍏�7鎺�";
+//                        back = true;
+//                    }
+//                    if(staProtocol.getWorkNo() == 9906 && '5' == barcode.charAt(0)){
+//                        errMsg = "鏉$爜5涓嶈兘鍏�6鎺�";
+//                        back = true;
+//                    }
+//                }
 
                 // 閫�鍥�
-                if (back) {
+                if (back && devp.getId() == 2) {
 //                    News.warn("鎵爜鍏ュ簱澶辫触锛寋}鍏ュ簱绔欏洜{}寮傚父锛屾墭鐩樺凡琚��鍥�", inSta.getStaNo(), errMsg);
 //                    if(!staProtocol.isOutEnable()){
 //                        continue;
@@ -193,84 +189,44 @@
                     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);
                 }
 
-//                String barcode11 = barcodeThread.getBarcode();
-//                if (Cools.isEmpty(barcode)){
-//                    if (staProtocol.isAutoing()&& !staProtocol.isEmptyMk() && staProtocol.isPakMk() && staProtocol.getStamp()>=2){
-//                        staProtocol.setStamp(0);
-//                        News.info(""+mark+" - 7"+" - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode11, inSta.getStaNo());
-//                        staProtocol.setWorkNo((short) 9989);
-//                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
-//                        devpThread.setPakMk(staProtocol.getSiteId(), false);
-//                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-//                        // led 寮傚父鏄剧ず
-//                        if (ledThread != null) {
-//                            String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
-//                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
-//                        }
-//                        continue;
-//                    }
-//                }
+                if (Cools.isEmpty(barcode) || !staProtocol.isInEnable() || staProtocol.isEmptyMk()
+                        || !staProtocol.isFullPlt() || (staProtocol.getWorkNo() <= 9000 && devp.getId() == 2)) {
+                    continue;
+                }
+
                 if (staProtocol.isAutoing() && staProtocol.isInEnable()
                         && !staProtocol.isEmptyMk() && staProtocol.getWorkNo() > 9000
-                        && staProtocol.isPakMk() && !back) { //&& staProtocol.getStamp()>=2) {// && !Cools.isEmpty(barcode)) {
-                    News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛�");
-//                    if(!Cools.isEmpty(barcode) ) {
-////                        News.info(""+mark+" - 1"+" - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode);
-//
-//                        if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
-//                            staProtocol.setWorkNo((short) 9999);
-//                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
-//                            devpThread.setPakMk(staProtocol.getSiteId(), false);
-//                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-//
-//                            News.info(""+mark+" - 2"+" - 鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo());
-//                            // led 寮傚父鏄剧ず
-//                            if (ledThread != null) {
-//                                String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
-//                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
-//                            }
-//                            continue;
-//                        }
-//                    } else {
-//                        staProtocol.setWorkNo((short) 9999);
-//                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
-//                        devpThread.setPakMk(staProtocol.getSiteId(), false);
-//                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-//
-//                        News.info(""+mark+" - 3"+" - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo());
-//                        // led 寮傚父鏄剧ず
-//                        if (ledThread != null) {
-//                            String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
-//                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
-//                        }
-//                        continue;
-//                    }
-
+                        && staProtocol.isPakMk() &&!Cools.isEmpty(barcode) && !back) {
                     // 鍒ゆ柇閲嶅宸ヤ綔妗�
                     WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
                     //杩囨护鍒ゆ柇锛岄槻姝㈡嫞鏂欏啀鍏ュ簱璐х墿锛岀粡杩囧叆搴撶珯鍐嶅叆搴撴椂锛岃閫�鍥炲埌閫�搴撶珯
                     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());
-                        staProtocol.setWorkNo((short)9999);
-                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
-                        devpThread.setPakMk(staProtocol.getSiteId(), false);
-                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-                        if (!result) {
-                            throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                        News.warn(""+mark+" - 4"+" - 婊℃墭鐩樺叆搴撳伐浣滄。涓凡瀛樺湪璇ョ珯鐘舵�佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo());
+                        if (devp.getId() == 2) {
+//                            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) {
+                                throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                            }
                         }
 
                         // 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;
                     }
@@ -313,18 +269,34 @@
                                 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);
-                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands));
+                                if (devp.getId() == 1) {
+//                                     if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(1, commands))){
+//                                         ledThread.setLedMk(false);
+//                                     }
+                                } else {
+                                    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);
-                            staProtocol.setWorkNo((short)9999);
-                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
-                            devpThread.setPakMk(staProtocol.getSiteId(), false);
-                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
-                            if (!result) {
-                                throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                            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());
+                                devpThread.setPakMk(staProtocol.getSiteId(), false);
+                                boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+                                if (!result) {
+                                    throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
+                                }
                             }
 
                             // led 寮傚父鏄剧ず
@@ -493,14 +465,17 @@
                             .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());
-                        staProtocol.setWorkNo((short) 9989);
-                        staProtocol.setStaNo(pickSta.getBackSta().shortValue());
-                        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());
+                        if (devp.getId() == 2) {
+                            staProtocol.setWorkNo((short) 9999);
+                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
+                            devpThread.setPakMk(staProtocol.getSiteId(), false);
+                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
+                        }
+
                         // led 寮傚父鏄剧ず
                         if (ledThread != null) {
                             String errorMsg = "姝や负鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱.璇锋斁鍦�"+pickSta.getBackSta().shortValue()+"绔欑偣";
@@ -547,6 +522,29 @@
                         e.printStackTrace();
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         continue;
+                    }
+                    List<LedCommand> commands = new ArrayList<>();
+                    LedCommand ledCommand = new LedCommand();
+                    ledCommand.setWorkNo(wrkMast.getWrkNo());
+                    ledCommand.setIoType(wrkMast.getIoType());
+                    ledCommand.setTitle(wrkMast.getIoType() == 53 ? "鎷f枡鍐嶅叆搴�" : "鐩樼偣鍐嶅叆搴�");
+                    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) {
+//                        if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(1, commands))) {
+//                            ledThread.setLedMk(false);
+//                        }
+                    } else {
+                        if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, commands))){
+                            ledThread.setLedMk(false);
+                        }
                     }
 
                     // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
@@ -874,8 +872,17 @@
                     News.error(""+mark+" - 1"+" - 2"+" - 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", crnStn.getStaNo());
                     continue;
                 }
+                // 鑾峰彇宸ヤ綔鐘舵�佷负2锛堣澶囦笂璧帮級鐨勫叆搴撳伐浣滄。
+                WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo());
+                if (null == wrkMast) {
+                    News.infoNoLog(""+mark+" - 1"+" - 4"+" - 鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo());
+//                log.error("鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo());
+                    continue;
+                }
 
-                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
+                if (staProtocol.isAutoing() && staProtocol.isLoading() &&
+                        (staProtocol.getWorkNo() <= 9000 || (slave.getId() == 1 && (wrkMast.getIoType() == 53 || wrkMast.getIoType() == 57)))
+                        && staProtocol.isInEnable()
                         && staDetl.getCanining() != null && staDetl.getCanining().equals("Y")) {
                     flag = true;
                 }
@@ -886,13 +893,7 @@
                             +"鑳藉叆淇″彿锛坵ms璁剧疆锛�.equals(\"Y\")"+staDetl.getCanining());
                     continue;
                 }
-                // 鑾峰彇宸ヤ綔鐘舵�佷负2锛堣澶囦笂璧帮級鐨勫叆搴撳伐浣滄。
-                WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo().intValue(), crnStn.getStaNo());
-                if (null == wrkMast) {
-                    News.infoNoLog(""+mark+" - 1"+" - 4"+" - 鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo());
-//                log.error("鏌ヨ鏃犲緟鍏ュ簱鏁版嵁--wrk_sts=2, 宸ヤ綔鍙�={}", staProtocol.getWorkNo());
-                    continue;
-                }
+
                 // 鑾峰彇搴撲綅淇℃伅
                 LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
                 if (locMast == null) {
@@ -1337,6 +1338,7 @@
         crnCommand.setDestinationPosX(sta.getRow1().shortValue());     // 鐩爣搴撲綅鎺�
         crnCommand.setDestinationPosY(sta.getBay1().shortValue());     // 鐩爣搴撲綅鍒�
         crnCommand.setDestinationPosZ(sta.getLev1().shortValue());     // 鐩爣搴撲綅灞�
+        crnCommand.setCommand((short) 1);
         if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
             News.error(""+mark+" - 3"+" - 4"+" - 鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
         } else {
@@ -1373,7 +1375,6 @@
                     crnThread.setResetFlag(true);
                 } else {
                     // 鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。
-                    System.out.println("浠诲姟鍙�"+crnProtocol.getTaskNo());
                     WrkMast wrkMast = wrkMastMapper.selectPakInStep3(Integer.valueOf(crnProtocol.getTaskNo()));
                     if (wrkMast == null) {
                         News.error(""+mark+" - 1"+" - 鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getTaskNo());
@@ -1548,18 +1549,22 @@
                     ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed());
                 }
 
-                if (!staProtocol.isLoading()){
-                    continue;
-                }
                 // 绔欑偣鏉′欢鍒ゆ柇
                 if (staProtocol.isAutoing()
                         && staProtocol.isInEnable()
                         && staProtocol.isEmptyMk()
-                        && (staProtocol.getWorkNo() >= 9990 && staProtocol.getWorkNo() <= 9999)
+                        && staProtocol.getWorkNo() > 9000
                         && staProtocol.isPakMk()
+                        && 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);
 
@@ -1586,24 +1591,34 @@
                                 News.errorNoLog(""+mark+" - 1"+" - 鏇存柊plc绔欑偣淇℃伅澶辫触");
                                 throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
                             }
-
                             if (ledThread != null) {
                                 // 鍛戒护闆嗗悎
                                 List<LedCommand> commands = new ArrayList<>();
                                 // 缁勮鍛戒护
                                 LedCommand ledCommand = new LedCommand();
                                 ledCommand.setWorkNo(dto.getWorkNo());
-                                ledCommand.setIoType(1);
-                                ledCommand.setTitle("鍏ㄦ澘鍏ュ簱");
+                                ledCommand.setIoType(10);
+                                ledCommand.setTitle("绌烘澘鍏ュ簱");
                                 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);
-                                MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, commands));
+                                if (devp.getId() == 1) {
+//                                    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) {
@@ -1617,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();
@@ -1647,6 +1662,9 @@
             // 宸ヤ綔妗i泦鍚�
             List<WrkMast> wrkMasts = new ArrayList<>();
             for (Integer staNo : led.getStaArr()) {
+                if (staNo == 104 || staNo == 204 || staNo == 304) {
+                    continue;
+                }
                 // 鑾峰彇鍙夎溅绔欑偣
                 StaProtocol staProtocol = devpThread.getStation().get(staNo);
                 if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) {
@@ -1697,10 +1715,11 @@
                 ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
                 ledCommand.setLocNo(wrkMast.getLocNo());
                 ledCommand.setStaNo(wrkMast.getStaNo());
+                ledCommand.setBarcode(wrkMast.getBarcode());
 //                ledCommand.setSourceStaNo(wrkMast.getSourceStaNo());
                 if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) {
                     List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
-                    wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getSpecs())));
+                    wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(),wrkDetl.getSpecs(),wrkDetl.getBatch(),wrkDetl.getMemo())));
                 }
                 commands.add(ledCommand);
             }
@@ -1720,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;
@@ -1791,11 +1810,20 @@
             // led鏄剧ず榛樿鍐呭
             if (reset && !ledThread.isLedMk()) {
                 ledThread.setLedMk(true);
-                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) {
-                    News.error(""+mark+" - 1"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
-                } else {
+                if (led.getId() <=2 ) {
+                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
+                        News.error(""+mark+" - 1"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+                    } else {
 
+                    }
+                } else {
+                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) {
+                        News.error(""+mark+" - 1"+" - {}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort());
+                    } else {
+
+                    }
                 }
+
             }
         }
         News.infoNoLog(""+mark+" - 0"+" - 鎵ц瀹屾垚锛氬叾浠�  ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅");
@@ -2371,4 +2399,16 @@
         }
     }
 
+    public void resetOneLed() {
+        // 鏍规嵁杈撻�佺嚎plc閬嶅巻
+        for (DevpSlave devp : slaveProperties.getDevp()) { //閬嶅巻杈撻�佺嚎
+            if (devp.getId() == 1) {
+                // 閬嶅巻鍏ュ簱鍙�
+                for (DevpSlave.Sta inSta : devp.getInSta()) {  // 閬嶅巻鍏ュ簱鍙�
+                    SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
+                    StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
+                }
+            }
+        }
+    }
 }

--
Gitblit v1.9.1