From f8c14df2d6ceb57d1e8a389b62d6996d90a073fd Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期四, 30 十一月 2023 19:35:37 +0800
Subject: [PATCH] #盘点逻辑修改

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |  479 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 305 insertions(+), 174 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 a43118d..5589a68 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -205,12 +205,12 @@
 //                        devpThread.setPakMk(staProtocol.getSiteId(), false);
 //                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
 
-                        // led 寮傚父鏄剧ず
-                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
-                        if (ledThread != null) {
-                            String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
-                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
-                        }
+//                        // led 寮傚父鏄剧ず
+//                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
+//                        if (ledThread != null) {
+//                            String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
+//                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
+//                        }
                         continue;
                     }
 
@@ -416,68 +416,46 @@
                 }
                 if (staProtocol.isAutoing()
                         && staProtocol.isLoading()
-//                        && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999)
-//                        && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue())
+                        && staProtocol.isInEnable()
+                        && (staProtocol.getWorkNo() > 0)
                         && staProtocol.isPakMk()){
 
-                    // 鑾峰彇鏉$爜鎵弿浠俊鎭�
-                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
-                    if (barcodeThread == null) {
+                    WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue());
+                    if (wrkMast == null) {//鎵句笉鍒板伐浣滄。
                         continue;
                     }
-                    String barcode = barcodeThread.getBarcode();
-
-                    WrkMast wrkMast = null;
-                    wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode);
-                    if (wrkMast == null) {
-                        continue;
-                    }
-//                    if (staProtocol.getWorkNo() == 9996) {
-//                        String barcode = barcodeThread.getBarcode();
-//                        if(!Cools.isEmpty(barcode)) {
-//                            News.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode);
-//                            if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
-//                                staProtocol.setWorkNo((short) 32002);
-//                                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 (ledThread != null) {
-//                                    String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
-//                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
-//                                }
-//                                continue;
-//                            }
-//                        } else {
-//                            staProtocol.setWorkNo((short) 32002);
-//                            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 (ledThread != null) {
-//                                String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
-//                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
-//                            }
-//                            continue;
-//                        }
-//                        wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode);
-//                        if (null == wrkMast) {
-//                            News.error("{}鏉$爜閿欒锛屾殏鏃犳嫞鏂欎换鍔★紒", barcode);
-//                        }
-//                    }
 
                     if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
-                        || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) {
+                            || 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) {
-                        throw new CoolException(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�");
+                        News.info(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�");
+                        continue;
                     }
 
                     String sourceLocNo = wrkMast.getSourceLocNo().trim();
@@ -489,7 +467,7 @@
                     // 鏇存柊宸ヤ綔妗f暟鎹姸鎬�
                     wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57
                     wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋
-                    wrkMast.setSourceStaNo(pickSta.getStaNo()); // 婧愮珯
+                    wrkMast.setSourceStaNo(pickSta.getBackSta()); // 婧愮珯
 //                            wrkMast.setStaNo(dto.getStaNo()); // 鐩爣绔�
 //                            wrkMast.setCrnNo(dto.getCrnNo());
                     wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔�
@@ -498,10 +476,12 @@
                     wrkMast.setLiftNo(null);// 鎻愬崌鏈烘竻绌�
                     wrkMast.setModiTime(new Date());
                     if (wrkMastMapper.updateById(wrkMast) == 0) {
-                        throw new CoolException(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+                        News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+                        continue;
                     }
                     if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
-                        throw new CoolException(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+                        News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+                        continue;
                     }
 
                     // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴�
@@ -509,127 +489,252 @@
                     locMast.setLocSts("Q");
                     locMast.setModiTime(new Date());
                     if (!locMastService.updateById(locMast)) {
-                        throw new CoolException("淇敼搴撲綅鐘舵�佸け璐�");
+                        News.info("淇敼搴撲綅鐘舵�佸け璐�");
+                        continue;
                     }
-                    barcodeThread.setBarcode("");//娓呯悊鏉$爜
 
-//                    try {
-//                        // 璁块棶 WMS 鑾峰彇鍏ュ簱搴撲綅
-//                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
-//                        SearchLocParam param = new SearchLocParam();
-//                        param.setWrkNo(wrkMast.getWrkNo());
-//                        param.setIoType(wrkMast.getIoType());
-//                        param.setSourceStaNo(pickSta.getStaNo());
-////                        param.setLocType1(locTypeDto.getLocType1());
-//                        String response = new HttpHandler.Builder()
-//                                .setUri(wmsUrl)
-//                                .setPath("/rpc/pakin/loc/v1")
-//                                .setJson(JSON.toJSONString(param))
-//                                .build()
-//                                .doPost();
-//                        JSONObject jsonObject = JSON.parseObject(response);
-//                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
-//                        Integer code = jsonObject.getInteger("code");
-//                        if (code.equals(200)) {
-//                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
-//
-////                            // 鑾峰彇鐩爣绔�
-////                            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
-////                                    .eq("type_no", wrkMast.getIoType() - 50)
-////                                    .eq("stn_no", pickSta.getStaNo()) // 浣滀笟绔欑偣 = 鎷f枡鍑哄簱鐨勭洰鏍囩珯
-////                                    .eq("crn_no", dto.getCrnNo()); // 鍫嗗灈鏈哄彿
-////                            StaDesc staDesc = staDescService.selectOne(wrapper);
-////                            if (Cools.isEmpty(staDesc)) {
-////                                News.error("鍏ュ簱璺緞涓嶅瓨鍦紒type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
-////                                continue;
-////                            }
-////                            // 鍫嗗灈鏈虹珯鐐�(鐩爣绔�)
-////                            Integer staNo = staDesc.getCrnStn();
-//
-//                            // 淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。
-////                        if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
-////                            throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触");
-////                        }
-//                            // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
-//                            if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
-//                                throw new CoolException(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�");
-//                            }
-//
-//                            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.getStaNo()); // 婧愮珯
-////                            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) {
-//                                throw new CoolException(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
-//                            }
-//                            if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
-//                                throw new CoolException(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
-//                            }
-//
-//                            // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴�
-//                            LocMast locMast = locMastService.selectById(sourceLocNo);
-//                            locMast.setLocSts("Q");
-//                            locMast.setModiTime(new Date());
-//                            if (!locMastService.updateById(locMast)) {
-//                                throw new CoolException("淇敼搴撲綅鐘舵�佸け璐�");
-//                            }
-//
-////                            // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
-////                            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) {
-////                                News.error("鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
-////                            }
-//
-//                            barcodeThread.setBarcode("");//娓呯悊鏉$爜
-//
-//                        } else if (code == 500){
-//                            if (ledThread != null) {
-//                                String errorMsg = jsonObject.getString("msg");
-//                                if (!Cools.isEmpty(errorMsg)) {
-//                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
-//                                }
-//                            }
-//                            News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
-//                        } else {
-////                            staProtocol.setWorkNo((short) 32002);
-////                            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 = jsonObject.getString("msg");
-////                                String errorMsg = barcode + "鎵樼洏璇嗗埆寮傚父锛岃鍏堣繘琛岀粍鎵橈紒";
-//                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
-//                            }
-//                        }
-//
-//                    } catch (Exception e) {
-//                        e.printStackTrace();
-//                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-//                    }
-
+                    staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());//鍐欏叆宸ヤ綔鍙�
+                    staProtocol.setStaNo(pickSta.getBackSta().shortValue());//鍐欏叆鐩爣绔�
+                    MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                 }
             }
 
         }
     }
+
+//    /**
+//     * 鎷f枡銆佸苟鏉裤�佺洏鐐瑰啀鍏ュ簱
+//     */
+//    @Transactional
+//    public synchronized void stnToCrnStnPick(){
+//        for (DevpSlave devp : slaveProperties.getDevp()) {
+//            // 閬嶅巻鎷f枡鍏ュ簱鍙�
+//            for (DevpSlave.Sta pickSta : devp.getPickInSta()) {
+//
+//                // 鑾峰彇鎷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.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999)
+////                        && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue())
+//                        && staProtocol.isPakMk()){
+//
+//                    // 鑾峰彇鏉$爜鎵弿浠俊鎭�
+//                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
+//                    if (barcodeThread == null) {
+//                        continue;
+//                    }
+//                    String barcode = barcodeThread.getBarcode();
+//
+//                    WrkMast wrkMast = null;
+//                    wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode);
+//                    if (wrkMast == null) {
+//                        continue;
+//                    }
+////                    if (staProtocol.getWorkNo() == 9996) {
+////                        String barcode = barcodeThread.getBarcode();
+////                        if(!Cools.isEmpty(barcode)) {
+////                            News.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode);
+////                            if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
+////                                staProtocol.setWorkNo((short) 32002);
+////                                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 (ledThread != null) {
+////                                    String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
+////                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
+////                                }
+////                                continue;
+////                            }
+////                        } else {
+////                            staProtocol.setWorkNo((short) 32002);
+////                            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 (ledThread != null) {
+////                                String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯";
+////                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
+////                            }
+////                            continue;
+////                        }
+////                        wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode);
+////                        if (null == wrkMast) {
+////                            News.error("{}鏉$爜閿欒锛屾殏鏃犳嫞鏂欎换鍔★紒", barcode);
+////                        }
+////                    }
+//
+//                    if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
+//                        || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) {
+//                        continue;
+//                    }
+//
+//                    // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
+//                    if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
+//                        throw new CoolException(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�");
+//                    }
+//
+//                    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.getStaNo()); // 婧愮珯
+////                            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) {
+//                        throw new CoolException(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+//                    }
+//                    if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
+//                        throw new CoolException(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+//                    }
+//
+//                    // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴�
+//                    LocMast locMast = locMastService.selectById(sourceLocNo);
+//                    locMast.setLocSts("Q");
+//                    locMast.setModiTime(new Date());
+//                    if (!locMastService.updateById(locMast)) {
+//                        throw new CoolException("淇敼搴撲綅鐘舵�佸け璐�");
+//                    }
+//                    barcodeThread.setBarcode("");//娓呯悊鏉$爜
+//
+////                    try {
+////                        // 璁块棶 WMS 鑾峰彇鍏ュ簱搴撲綅
+////                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
+////                        SearchLocParam param = new SearchLocParam();
+////                        param.setWrkNo(wrkMast.getWrkNo());
+////                        param.setIoType(wrkMast.getIoType());
+////                        param.setSourceStaNo(pickSta.getStaNo());
+//////                        param.setLocType1(locTypeDto.getLocType1());
+////                        String response = new HttpHandler.Builder()
+////                                .setUri(wmsUrl)
+////                                .setPath("/rpc/pakin/loc/v1")
+////                                .setJson(JSON.toJSONString(param))
+////                                .build()
+////                                .doPost();
+////                        JSONObject jsonObject = JSON.parseObject(response);
+////                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
+////                        Integer code = jsonObject.getInteger("code");
+////                        if (code.equals(200)) {
+////                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+////
+//////                            // 鑾峰彇鐩爣绔�
+//////                            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
+//////                                    .eq("type_no", wrkMast.getIoType() - 50)
+//////                                    .eq("stn_no", pickSta.getStaNo()) // 浣滀笟绔欑偣 = 鎷f枡鍑哄簱鐨勭洰鏍囩珯
+//////                                    .eq("crn_no", dto.getCrnNo()); // 鍫嗗灈鏈哄彿
+//////                            StaDesc staDesc = staDescService.selectOne(wrapper);
+//////                            if (Cools.isEmpty(staDesc)) {
+//////                                News.error("鍏ュ簱璺緞涓嶅瓨鍦紒type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
+//////                                continue;
+//////                            }
+//////                            // 鍫嗗灈鏈虹珯鐐�(鐩爣绔�)
+//////                            Integer staNo = staDesc.getCrnStn();
+////
+////                            // 淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。
+//////                        if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
+//////                            throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触");
+//////                        }
+////                            // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗�
+////                            if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
+////                                throw new CoolException(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�");
+////                            }
+////
+////                            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.getStaNo()); // 婧愮珯
+//////                            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) {
+////                                throw new CoolException(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+////                            }
+////                            if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
+////                                throw new CoolException(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�");
+////                            }
+////
+////                            // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴�
+////                            LocMast locMast = locMastService.selectById(sourceLocNo);
+////                            locMast.setLocSts("Q");
+////                            locMast.setModiTime(new Date());
+////                            if (!locMastService.updateById(locMast)) {
+////                                throw new CoolException("淇敼搴撲綅鐘舵�佸け璐�");
+////                            }
+////
+//////                            // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
+//////                            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) {
+//////                                News.error("鍙戝竷鍛戒护鑷宠緭閫佺嚎闃熷垪澶辫触锛侊紒锛� [plc缂栧彿锛歿}]", devp.getId());
+//////                            }
+////
+////                            barcodeThread.setBarcode("");//娓呯悊鏉$爜
+////
+////                        } else if (code == 500){
+////                            if (ledThread != null) {
+////                                String errorMsg = jsonObject.getString("msg");
+////                                if (!Cools.isEmpty(errorMsg)) {
+////                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
+////                                }
+////                            }
+////                            News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
+////                        } else {
+//////                            staProtocol.setWorkNo((short) 32002);
+//////                            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 = jsonObject.getString("msg");
+//////                                String errorMsg = barcode + "鎵樼洏璇嗗埆寮傚父锛岃鍏堣繘琛岀粍鎵橈紒";
+////                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
+////                            }
+////                        }
+////
+////                    } catch (Exception e) {
+////                        e.printStackTrace();
+////                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+////                    }
+//
+//                }
+//            }
+//
+//        }
+//    }
 
     /**
      * 鍒濆鍖栧疄鏃跺湴鍥�
@@ -1180,6 +1285,28 @@
             if (!sourceBasDevp.getInEnable().equals("Y")) {
                 News.info("{}浠诲姟锛寋}婧愮珯锛屾病鏈夊彲鍏ヤ俊鍙�", wrkMast.getWrkNo(), sourceBasDevp.getDevNo());
                 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;//绔欑偣涓嶅彲鍏�
+                    }
+                }
             }
 
             //鍒ゆ柇鎻愬崌鏈烘暣涓笁妤兼槸鍚﹂兘澶勪簬鍏ュ簱妯″紡
@@ -2771,6 +2898,10 @@
                     continue;
                 }
 
+                if (shuttleProtocol.getVoltage() < 5630) {
+                    continue;//鐢靛帇涓嶅缁х画鍏呯數
+                }
+
                 //灏忚溅婊$數锛岀粨鏉熷厖鐢典换鍔�
                 NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), false);
                 ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>();

--
Gitblit v1.9.1