From 45acd20e06a15d0096776ffe3adae4dc94d22762 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 05 十月 2023 09:39:52 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java |   68 +++++++++++++++++++++++++---------
 1 files changed, 50 insertions(+), 18 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 4ecd592..1e3077e 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -3,6 +3,7 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.core.common.Cools;
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.*;
@@ -224,7 +225,7 @@
                         param.setBarcode(barcode);
                         param.setIoType(1);
                         param.setSourceStaNo(inSta.getStaNo());
-//                        param.setLocType1(locTypeDto.getLocType1());
+                        param.setLocType1(locTypeDto.getLocType1());
                         String response = new HttpHandler.Builder()
                                 .setUri(wmsUrl)
                                 .setPath("/rpc/pakin/loc/v1")
@@ -405,8 +406,8 @@
                 }
                 if (staProtocol.isAutoing()
                         && staProtocol.isLoading()
-                        && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999)
-                        && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue())
+//                        && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9999)
+//                        && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue())
                         && staProtocol.isPakMk()){
 
                     // 鑾峰彇鏉$爜鎵弿浠俊鎭�
@@ -507,12 +508,18 @@
                             }
 
                             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(dto.getStaNo()); // 鐩爣绔�
+//                            wrkMast.setCrnNo(dto.getCrnNo());
+                            wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔�
                             wrkMast.setLocNo(sourceLocNo); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣�
                             wrkMast.setShuttleNo(null); // 绌挎杞︽竻绌�
                             wrkMast.setModiTime(new Date());
@@ -531,14 +538,16 @@
                                 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());
-                            }
+//                            // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂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) {
@@ -549,10 +558,10 @@
                             }
                             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));
+//                            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) {
@@ -1167,6 +1176,12 @@
 
             //鑾峰彇鎻愬崌鏈哄懡浠�
             NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_TRAY.id, startSta, targetSta, wrkMast.getWrkNo());
+            if (wrkMast.getIoType() == 53) {
+                //鎷f枡鍐嶅洖搴擄紝閲嶆柊鍒嗛厤璁惧宸ヤ綔鍙�
+                Random random = new Random();
+                int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//鑾峰彇璁惧宸ヤ綔鍙�
+                liftCommand.setTaskNo((short) deviceWrk);
+            }
             ArrayList<NyLiftCommand> commands = new ArrayList<>();
             commands.add(liftCommand);
 
@@ -1916,6 +1931,13 @@
                         }
                     }
 
+                    if (!Cools.isEmpty(barcode)) {
+                        WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode);//鏉$爜瀛樺湪宸ヤ綔妗�
+                        if (wrkMast != null) {
+                            continue;
+                        }
+                    }
+
                     LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed());
 
                     try {
@@ -2610,7 +2632,8 @@
                 NyLiftCommand liftCommand = NyLiftUtils.getLiftCommand(liftProtocol.getLiftNo().intValue(), NyLiftTaskModelType.MOVE_CAR.id, sourceLiftSta.getStaNo(), sourceLiftSta.getStaNo(), wrkMast.getWrkNo());
 
                 Random random = new Random();
-                liftCommand.setTaskNo((short) Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999))));//鏇存崲闅忔満浠诲姟鍙�
+                int deviceWrk = Math.abs((liftCommand.getTaskNo().intValue() + random.nextInt(9999)));//鑾峰彇璁惧宸ヤ綔鍙�
+                liftCommand.setTaskNo((short) deviceWrk);//鏇存崲闅忔満浠诲姟鍙�
 
                 ArrayList<NyLiftCommand> commands = new ArrayList<>();
                 commands.add(liftCommand);
@@ -2932,6 +2955,15 @@
 //            NavigateNode liftNode = new NavigateNode(basLift.getPoint$().getX(), basLift.getPoint$().getY());
 //            liftNode.setZ(basLift.getPoint$().getZ());
 
+            //灏忚溅宸茬粡鍦ㄧ洰鏍囧簱浣嶏紝鐩存帴璁ゅ畾灏忚溅绉诲姩浠诲姟瀹屾垚
+            if (shuttleProtocol.getCurrentLocNo().equals(wrkMast.getLocNo())) {
+                wrkMast.setWrkSts(111L);//111.灏忚溅绉诲姩瀹屾垚
+                wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈�
+                wrkMast.setModiTime(now);
+                wrkMastMapper.updateById(wrkMast);
+                return false;
+            }
+
             //鑾峰彇灏忚溅鍒扮洰鏍囧簱浣嶅懡浠�
             NyShuttleOperaResult result = NyShuttleOperaUtils.getStartToTargetCommands(shuttleThread.getSlave().getId(), wrkMast.getWrkNo(), shuttleProtocol.getCurrentLocNo(), wrkMast.getLocNo(), NavigationMapType.NORMAL.id);
             if (result == null) {

--
Gitblit v1.9.1