From 707f8db2227a6031f230e35895ea1c5f7ff03bd6 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 18 十二月 2025 14:43:52 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/utils/StationOperateProcessUtils.java |  165 ++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 108 insertions(+), 57 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
index fc0878c..5c31a55 100644
--- a/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
+++ b/src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -5,14 +5,8 @@
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
 import com.zy.asrs.domain.param.CreateInTaskParam;
-import com.zy.asrs.entity.BasCrnp;
-import com.zy.asrs.entity.BasDevp;
-import com.zy.asrs.entity.HttpRequestLog;
-import com.zy.asrs.entity.WrkMast;
-import com.zy.asrs.service.BasCrnpService;
-import com.zy.asrs.service.BasDevpService;
-import com.zy.asrs.service.HttpRequestLogService;
-import com.zy.asrs.service.WrkMastService;
+import com.zy.asrs.entity.*;
+import com.zy.asrs.service.*;
 import com.zy.asrs.utils.Utils;
 import com.zy.common.model.StartupDto;
 import com.zy.common.service.CommonService;
@@ -53,6 +47,8 @@
     private ConfigService configService;
     @Autowired
     private HttpRequestLogService httpRequestLogService;
+    @Autowired
+    private LocMastService locMastService;
 
     //鎵ц杈撻�佺珯鐐瑰叆搴撲换鍔�
     public synchronized void stationInExecute() {
@@ -253,6 +249,11 @@
                 continue;
             }
 
+            List<Integer> runBlockReassignLocStationList = new ArrayList<>();
+            for (StationObjModel stationObjModel : basDevp.getRunBlockReassignLocStationList$()) {
+                runBlockReassignLocStationList.add(stationObjModel.getStationId());
+            }
+
             List<StationProtocol> list = stationThread.getStatus();
             for (StationProtocol stationProtocol : list) {
                 if(stationProtocol.isAutoing()
@@ -260,7 +261,6 @@
                     && stationProtocol.getTaskNo() > 0
                     && stationProtocol.isRunBlock()
                 ) {
-                    //杩愯鍫靛锛岄噸鏂扮敵璇蜂换鍔�
                     WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
                     if (wrkMast == null) {
                         News.info("杈撻�佺珯鐐瑰彿={} 杩愯闃诲锛屼絾鏃犳硶鎵惧埌瀵瑰簲浠诲姟锛屽伐浣滃彿={}", stationProtocol.getStationId(), stationProtocol.getTaskNo());
@@ -271,61 +271,112 @@
                     if (lock != null) {
                         continue;
                     }
-
                     redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15);
 
-                    HashMap<String, Object> requestParam = new HashMap<>();
-                    String response = null;
-                    try {
-                        requestParam.put("taskNo", wrkMast.getWmsWrkNo());
-                        requestParam.put("row", Utils.getInTaskEnableRow(new ArrayList<>(basDevp.getDevpNo())));
+                    if (runBlockReassignLocStationList.contains(stationProtocol.getStationId())) {
+                        //绔欑偣澶勪簬閲嶆柊鍒嗛厤搴撲綅鍖哄煙
+                        //杩愯鍫靛锛岄噸鏂扮敵璇蜂换鍔�
 
-                        response = new HttpHandler.Builder()
-                                .setUri(wmsUrl)
-                                .setPath(wmsSystemReassignInTaskUrl)
-                                .setJson(JSON.toJSONString(requestParam))
-                                .build()
-                                .doPost();
-                        JSONObject jsonObject = JSON.parseObject(response);
-                        if (jsonObject.getInteger("code").equals(200)) {
-                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
+                        HashMap<String, Object> requestParam = new HashMap<>();
+                        String response = null;
+                        try {
+                            requestParam.put("taskNo", wrkMast.getWmsWrkNo());
+                            requestParam.put("row", Utils.getInTaskEnableRow(new ArrayList<>(basDevp.getDevpNo())));
 
-                            String locNo = dto.getLocNo();
-                            //鏇存柊鏁版嵁
-                            wrkMast.setLocNo(locNo);
-                            wrkMastService.updateById(wrkMast);
+                            response = new HttpHandler.Builder()
+                                    .setUri(wmsUrl)
+                                    .setPath(wmsSystemReassignInTaskUrl)
+                                    .setJson(JSON.toJSONString(requestParam))
+                                    .build()
+                                    .doPost();
+                            JSONObject jsonObject = JSON.parseObject(response);
+                            if (jsonObject.getInteger("code").equals(200)) {
+                                StartupDto dto = jsonObject.getObject("data", StartupDto.class);
 
-                            Integer crnNo = commonService.findCrnNoByLocNo(locNo);
-                            if (crnNo == null) {
-                                News.taskInfo(wrkMast.getWrkNo(), "鏈尮閰嶅埌鍫嗗灈鏈�");
-                                continue;
+                                String sourceLocNo = wrkMast.getLocNo();
+                                String locNo = dto.getLocNo();
+
+                                LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo);
+                                if (sourceLocMast == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 婧愬簱浣嶄俊鎭笉瀛樺湪", sourceLocNo);
+                                    continue;
+                                }
+
+                                if (!sourceLocMast.getLocSts().equals("S")) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 婧愬簱浣嶇姸鎬佷笉澶勪簬鍏ュ簱棰勭害", sourceLocNo);
+                                    continue;
+                                }
+
+                                LocMast locMast = locMastService.queryByLoc(locNo);
+                                if (locMast == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 鐩爣搴撲綅淇℃伅涓嶅瓨鍦�", locNo);
+                                    continue;
+                                }
+
+                                if (!locMast.getLocSts().equals("O")) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "搴撲綅鍙�:{} 鐩爣搴撲綅鐘舵�佷笉澶勪簬绌哄簱浣�", locNo);
+                                    continue;
+                                }
+
+                                Integer crnNo = commonService.findCrnNoByLocNo(locNo);
+                                if (crnNo == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "鏈尮閰嶅埌鍫嗗灈鏈�");
+                                    continue;
+                                }
+
+                                Integer targetStationId = commonService.findInStationId(crnNo, stationProtocol.getStationId());
+                                if (targetStationId == null) {
+                                    News.taskInfo(wrkMast.getWrkNo(), "鎼滅储鍏ュ簱绔欑偣澶辫触");
+                                    continue;
+                                }
+
+                                StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
+                                if(command == null){
+                                    News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                                    continue;
+                                }
+
+                                //鏇存柊婧愬簱浣�
+                                sourceLocMast.setLocSts("O");
+                                sourceLocMast.setModiTime(new Date());
+                                locMastService.updateById(sourceLocMast);
+
+                                //鏇存柊鐩爣搴撲綅
+                                locMast.setLocSts("S");
+                                locMast.setModiTime(new Date());
+                                locMastService.updateById(locMast);
+
+                                //鏇存柊宸ヤ綔妗f暟鎹�
+                                wrkMast.setLocNo(locNo);
+                                wrkMast.setCrnNo(crnNo);
+                                wrkMast.setStaNo(targetStationId);
+                                if (wrkMastService.updateById(wrkMast)) {
+                                    MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
+                                }
+                                News.info("璇锋眰WMS鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
+                            } else {
+                                News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
                             }
-
-                            Integer targetStationId = commonService.findInStationId(crnNo, stationProtocol.getStationId());
-                            if (targetStationId == null) {
-                                News.taskInfo(wrkMast.getWrkNo(), "鎼滅储鍏ュ簱绔欑偣澶辫触");
-                                continue;
-                            }
-
-                            StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
-                            if(command == null){
-                                News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
-                                continue;
-                            }
-                            MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
-                            News.info("璇锋眰WMS鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
-                        } else {
-                            News.error("璇锋眰WMS鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
+                        } catch (Exception e) {
+                            News.error("璇锋眰WMS鎺ュ彛寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛� response锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response, e);
+                        } finally {
+                            HttpRequestLog httpRequestLog = new HttpRequestLog();
+                            httpRequestLog.setName(wmsUrl + wmsSystemReassignInTaskUrl);
+                            httpRequestLog.setRequest(JSON.toJSONString(requestParam));
+                            httpRequestLog.setResponse(response);
+                            httpRequestLog.setCreateTime(new Date());
+                            httpRequestLogService.insert(httpRequestLog);
                         }
-                    } catch (Exception e) {
-                        News.error("璇锋眰WMS鎺ュ彛寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛� response锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response, e);
-                    } finally {
-                        HttpRequestLog httpRequestLog = new HttpRequestLog();
-                        httpRequestLog.setName(wmsUrl + wmsSystemReassignInTaskUrl);
-                        httpRequestLog.setRequest(JSON.toJSONString(requestParam));
-                        httpRequestLog.setResponse(response);
-                        httpRequestLog.setCreateTime(new Date());
-                        httpRequestLogService.insert(httpRequestLog);
+                    }else {
+                        //杩愯鍫靛锛岄噸鏂拌绠楄矾绾�
+                        StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
+                        if(command == null){
+                            News.taskInfo(wrkMast.getWrkNo(), "鑾峰彇杈撻�佺嚎鍛戒护澶辫触");
+                            continue;
+                        }
+
+                        MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
+                        News.info("杈撻�佺珯鐐瑰牭濉炲悗閲嶆柊璁$畻璺緞鍛戒护涓嬪彂鎴愬姛锛岀珯鐐瑰彿={}锛屽伐浣滃彿={}锛屽懡浠ゆ暟鎹�={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                     }
                 }
             }

--
Gitblit v1.9.1