From 664d9030efca22edd8e43b4db4b2c0700fff44af Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 14 一月 2026 09:18:33 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/utils/WmsOperateUtils.java |  114 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 87 insertions(+), 27 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..423b10d 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,28 +47,44 @@
     private CommonService commonService;
     @Autowired
     private BasCrnpService basCrnpService;
+    @Autowired
+    private BasDualCrnpService basDualCrnpService;
+    @Autowired
+    private BasStationService basStationService;
+    @Autowired
+    private StationOperateProcessUtils stationOperateProcessUtils;
+    @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();
+        String wmsSystemInUrl = systemConfigMap.get("wmsSystemInUrl");
+        if(wmsSystemInUrl == null){
+            News.error("鏈厤缃甒MS鍏ュ簱鎺ュ彛鍦板潃锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemInUrl");
+            return null;
         }
 
-        if(wmsSystemInUrlConfig == null){
-            News.error("鏈厤缃甒MS鍏ュ簱鎺ュ彛鍦板潃锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemInUrl");
+        int conveyorStationTaskLimit = 30;
+        String conveyorStationTaskLimitStr = systemConfigMap.get("conveyorStationTaskLimit");
+        if(conveyorStationTaskLimitStr != null){
+            conveyorStationTaskLimit = Integer.parseInt(conveyorStationTaskLimitStr);
+        }
+        int currentStationTaskCount = stationOperateProcessUtils.getCurrentStationTaskCount();
+        if (currentStationTaskCount > conveyorStationTaskLimit) {
+            News.error("杈撻�佺珯鐐逛换鍔″凡杈惧埌涓婇檺锛屼笂闄愬�硷細{}锛岀珯鐐逛换鍔℃暟锛歿}", conveyorStationTaskLimit, currentStationTaskCount);
             return null;
         }
 
@@ -66,10 +92,21 @@
         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)
@@ -104,7 +141,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 +159,7 @@
             wmsSystemReassignInTaskUrl = wmsSystemReassignInTaskUrlConfig.getValue();
         }
 
-        if(wmsSystemReassignInTaskUrl == null){
+        if (wmsSystemReassignInTaskUrl == null) {
             News.error("鏈厤缃甒MS浠诲姟閲嶆柊鍒嗛厤鍏ュ簱搴撲綅鎺ュ彛鍦板潃锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemReassignInTaskUrl");
             return null;
         }
@@ -137,8 +174,17 @@
         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)
@@ -152,10 +198,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 +242,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<>();

--
Gitblit v1.9.1