From a502dc5a81d42a70e2ba2ad9e4cce97fea2b7669 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 14 一月 2026 15:42:02 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/utils/WmsOperateUtils.java |  109 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 78 insertions(+), 31 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/WmsOperateUtils.java b/src/main/java/com/zy/core/utils/WmsOperateUtils.java
index 0f855a4..79e7e1e 100644
--- a/src/main/java/com/zy/core/utils/WmsOperateUtils.java
+++ b/src/main/java/com/zy/core/utils/WmsOperateUtils.java
@@ -3,16 +3,26 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.common.Cools;
+import com.core.exception.CoolException;
 import com.zy.asrs.entity.BasCrnp;
+import com.zy.asrs.entity.BasDualCrnp;
+import com.zy.asrs.entity.BasStation;
 import com.zy.asrs.entity.HttpRequestLog;
 import com.zy.asrs.entity.WrkMast;
 import com.zy.asrs.service.BasCrnpService;
+import com.zy.asrs.service.BasDualCrnpService;
+import com.zy.asrs.service.BasStationService;
 import com.zy.asrs.service.HttpRequestLogService;
 import com.zy.asrs.service.WrkMastService;
 import com.zy.asrs.utils.Utils;
+import com.zy.common.entity.FindCrnNoResult;
 import com.zy.common.service.CommonService;
 import com.zy.common.utils.HttpHandler;
+import com.zy.common.utils.RedisUtil;
 import com.zy.core.News;
+import com.zy.core.enums.RedisKeyType;
+import com.zy.core.enums.SlaveType;
 import com.zy.system.entity.Config;
 import com.zy.system.service.ConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,27 +47,30 @@
     private CommonService commonService;
     @Autowired
     private BasCrnpService basCrnpService;
+    @Autowired
+    private BasDualCrnpService basDualCrnpService;
+    @Autowired
+    private BasStationService basStationService;
+    @Autowired
+    private RedisUtil redisUtil;
 
     //鐢宠鍏ュ簱浠诲姟
     public synchronized String applyInTask(String barcode, Integer sourceStaNo, Integer locType1) {
-        String wmsUrl = null;
-        Config wmsSystemUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemUri"));
-        if (wmsSystemUriConfig != null) {
-            wmsUrl = wmsSystemUriConfig.getValue();
+        Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+        if (systemConfigMapObj == null) {
+            News.error("绯荤粺Config缂撳瓨澶辨晥");
+            return null;
         }
+        HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
 
+        String wmsUrl = systemConfigMap.get("wmsSystemUri");
         if (wmsUrl == null) {
             News.error("鏈厤缃甒MS绯荤粺URI锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemUri");
             return null;
         }
 
-        String wmsSystemInUrl = null;
-        Config wmsSystemInUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemInUrl"));
-        if (wmsSystemInUrlConfig != null) {
-            wmsSystemInUrl = wmsSystemInUrlConfig.getValue();
-        }
-
-        if(wmsSystemInUrlConfig == null){
+        String wmsSystemInUrl = systemConfigMap.get("wmsSystemInUrl");
+        if(wmsSystemInUrl == null){
             News.error("鏈厤缃甒MS鍏ュ簱鎺ュ彛鍦板潃锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemInUrl");
             return null;
         }
@@ -66,16 +79,27 @@
         String response = null;
         int result = 0;
         try {
+            BasStation basStation = basStationService.selectOne(new EntityWrapper<BasStation>().eq("station_id", sourceStaNo));
+            if(basStation == null){
+                News.error("绔欑偣{}涓嶅瓨鍦�", sourceStaNo);
+                return null;
+            }
+
+            String stationNo = String.valueOf(sourceStaNo);
+            if(!Cools.isEmpty(basStation.getStationAlias())){
+                stationNo = basStation.getStationAlias();
+            }
+
             requestParam.put("barcode", barcode);
-            requestParam.put("sourceStaNo", sourceStaNo);
+            requestParam.put("sourceStaNo", stationNo);
             requestParam.put("locType1", locType1);
-            requestParam.put("row", Utils.getInTaskEnableRow());
+            requestParam.put("row", Utils.getInTaskEnableRow(sourceStaNo));
 
             response = new HttpHandler.Builder()
                     .setUri(wmsUrl)
                     .setPath(wmsSystemInUrl)
                     .setJson(JSON.toJSONString(requestParam))
-                    .setTimeout(360, TimeUnit.SECONDS)
+                    .setTimeout(30, TimeUnit.SECONDS)
                     .build()
                     .doPost();
             if (response != null) {
@@ -104,7 +128,7 @@
     }
 
     //鐢宠浠诲姟閲嶆柊鍒嗛厤搴撲綅
-    public synchronized String applyReassignTaskLocNo(Integer taskNo) {
+    public synchronized String applyReassignTaskLocNo(Integer taskNo, Integer stationId) {
         String wmsUrl = null;
         Config wmsSystemUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemUri"));
         if (wmsSystemUriConfig != null) {
@@ -122,7 +146,7 @@
             wmsSystemReassignInTaskUrl = wmsSystemReassignInTaskUrlConfig.getValue();
         }
 
-        if(wmsSystemReassignInTaskUrl == null){
+        if (wmsSystemReassignInTaskUrl == null) {
             News.error("鏈厤缃甒MS浠诲姟閲嶆柊鍒嗛厤鍏ュ簱搴撲綅鎺ュ彛鍦板潃锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemReassignInTaskUrl");
             return null;
         }
@@ -137,14 +161,23 @@
         String response = null;
         int result = 0;
         try {
+            List<Integer> excludeCrnList = new ArrayList<>();
+            List<Integer> excludeDualCrnList = new ArrayList<>();
+            if (!Cools.isEmpty(wrkMast.getCrnNo())) {
+                excludeCrnList.add(wrkMast.getCrnNo());
+            }
+            if (!Cools.isEmpty(wrkMast.getDualCrnNo())) {
+                excludeDualCrnList.add(wrkMast.getDualCrnNo());
+            }
+
             requestParam.put("taskNo", wrkMast.getWmsWrkNo());
-            requestParam.put("row", Utils.getInTaskEnableRow(new ArrayList<>(wrkMast.getCrnNo()), false));
+            requestParam.put("row", Utils.getInTaskEnableRow(stationId, excludeCrnList, excludeDualCrnList, false));
 
             response = new HttpHandler.Builder()
                     .setUri(wmsUrl)
                     .setPath(wmsSystemReassignInTaskUrl)
                     .setJson(JSON.toJSONString(requestParam))
-                    .setTimeout(360, TimeUnit.SECONDS)
+                    .setTimeout(30, TimeUnit.SECONDS)
                     .build()
                     .doPost();
             if (response != null) {
@@ -152,10 +185,10 @@
                 if (jsonObject.getInteger("code") == 200) {
                     result = 1;
                     News.info("璇锋眰鐢宠浠诲姟閲嶆柊鍒嗛厤鍏ュ簱鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
-                }else {
+                } else {
                     News.info("璇锋眰鐢宠浠诲姟閲嶆柊鍒嗛厤鍏ュ簱鎺ュ彛澶辫触锛屾帴鍙h繑鍥濩ode寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
                 }
-            }else {
+            } else {
                 News.info("璇锋眰鐢宠浠诲姟閲嶆柊鍒嗛厤鍏ュ簱鎺ュ彛澶辫触锛屾帴鍙f湭鍝嶅簲锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
             }
         } catch (Exception e) {
@@ -196,19 +229,33 @@
             return null;
         }
 
-        Integer crnNo = commonService.findCrnNoByLocNo(locNo);
-        if (crnNo == null) {
+        FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
+        if (findCrnNoResult == null) {
             return null;
         }
-        BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", crnNo));
-        if (basCrnp == null) {
-            return null;
-        }
-
+        Integer crnNo = findCrnNoResult.getCrnNo();
         List<Integer> crnRows = new ArrayList<>();
-        List<List<Integer>> rowList = basCrnp.getControlRows$();
-        for (List<Integer> list : rowList) {
-            crnRows.addAll(list);
+
+        if (findCrnNoResult.getCrnType().equals(SlaveType.Crn)) {
+            BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", crnNo));
+            if (basCrnp == null) {
+                return null;
+            }
+            List<List<Integer>> rowList = basCrnp.getControlRows$();
+            for (List<Integer> list : rowList) {
+                crnRows.addAll(list);
+            }
+        } else if (findCrnNoResult.getCrnType().equals(SlaveType.DualCrn)) {
+            BasDualCrnp basDualCrnp = basDualCrnpService.selectOne(new EntityWrapper<BasDualCrnp>().eq("crn_no", crnNo));
+            if (basDualCrnp == null) {
+                return null;
+            }
+            List<List<Integer>> rowList = basDualCrnp.getControlRows$();
+            for (List<Integer> list : rowList) {
+                crnRows.addAll(list);
+            }
+        }else {
+            throw new CoolException("鏈煡璁惧绫诲瀷");
         }
 
         HashMap<String, Object> requestParam = new HashMap<>();
@@ -222,7 +269,7 @@
                     .setUri(wmsUrl)
                     .setPath(wmsSystemChangeLocNoUrl)
                     .setJson(JSON.toJSONString(requestParam))
-                    .setTimeout(360, TimeUnit.SECONDS)
+                    .setTimeout(30, TimeUnit.SECONDS)
                     .build()
                     .doPost();
 

--
Gitblit v1.9.1