From f5e49b2c04137fdc88c453cbe5d190cf7daab079 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期二, 30 十二月 2025 15:39:53 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/utils/WmsOperateUtils.java |  114 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 91 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/WmsOperateUtils.java b/src/main/java/com/zy/core/utils/WmsOperateUtils.java
index a2c975a..56453bb 100644
--- a/src/main/java/com/zy/core/utils/WmsOperateUtils.java
+++ b/src/main/java/com/zy/core/utils/WmsOperateUtils.java
@@ -1,20 +1,24 @@
 package com.zy.core.utils;
 
 import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
+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.HttpRequestLog;
 import com.zy.asrs.entity.WrkMast;
 import com.zy.asrs.service.BasCrnpService;
+import com.zy.asrs.service.BasDualCrnpService;
 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.core.News;
+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;
@@ -24,6 +28,7 @@
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 @Component
 public class WmsOperateUtils {
@@ -38,6 +43,8 @@
     private CommonService commonService;
     @Autowired
     private BasCrnpService basCrnpService;
+    @Autowired
+    private BasDualCrnpService basDualCrnpService;
 
     //鐢宠鍏ュ簱浠诲姟
     public synchronized String applyInTask(String barcode, Integer sourceStaNo, Integer locType1) {
@@ -65,34 +72,47 @@
 
         HashMap<String, Object> requestParam = new HashMap<>();
         String response = null;
+        int result = 0;
         try {
             requestParam.put("barcode", barcode);
             requestParam.put("sourceStaNo", sourceStaNo);
             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)
                     .build()
                     .doPost();
-            News.info("璇锋眰WMS鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response);
+            if (response != null) {
+                JSONObject jsonObject = JSON.parseObject(response);
+                if (jsonObject.getInteger("code") == 200) {
+                    result = 1;
+                    News.info("璇锋眰WMS鍏ュ簱鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response);
+                }else {
+                    News.info("璇锋眰WMS鍏ュ簱鎺ュ彛澶辫触锛屾帴鍙h繑鍥濩ode寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response);
+                }
+            }else {
+                News.info("璇锋眰WMS鍏ュ簱鎺ュ彛澶辫触锛屾帴鍙f湭鍝嶅簲锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response);
+            }
         } catch (Exception e) {
-            News.error("璇锋眰WMS鎺ュ彛寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response, e);
+            News.error("璇锋眰WMS鍏ュ簱鎺ュ彛寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemInUrl, JSON.toJSONString(requestParam), response, e);
         } finally {
             HttpRequestLog httpRequestLog = new HttpRequestLog();
             httpRequestLog.setName(wmsUrl + wmsSystemInUrl);
             httpRequestLog.setRequest(JSON.toJSONString(requestParam));
             httpRequestLog.setResponse(response);
             httpRequestLog.setCreateTime(new Date());
+            httpRequestLog.setResult(result);
             httpRequestLogService.insert(httpRequestLog);
         }
         return response;
     }
 
     //鐢宠浠诲姟閲嶆柊鍒嗛厤搴撲綅
-    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) {
@@ -110,7 +130,7 @@
             wmsSystemReassignInTaskUrl = wmsSystemReassignInTaskUrlConfig.getValue();
         }
 
-        if(wmsSystemReassignInTaskUrl == null){
+        if (wmsSystemReassignInTaskUrl == null) {
             News.error("鏈厤缃甒MS浠诲姟閲嶆柊鍒嗛厤鍏ュ簱搴撲綅鎺ュ彛鍦板潃锛岄厤缃枃浠禖ode缂栫爜锛歸msSystemReassignInTaskUrl");
             return null;
         }
@@ -123,25 +143,47 @@
 
         HashMap<String, Object> requestParam = new HashMap<>();
         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())));
+            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)
                     .build()
                     .doPost();
-            News.info("璇锋眰WMS鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
+            if (response != null) {
+                JSONObject jsonObject = JSON.parseObject(response);
+                if (jsonObject.getInteger("code") == 200) {
+                    result = 1;
+                    News.info("璇锋眰鐢宠浠诲姟閲嶆柊鍒嗛厤鍏ュ簱鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
+                } else {
+                    News.info("璇锋眰鐢宠浠诲姟閲嶆柊鍒嗛厤鍏ュ簱鎺ュ彛澶辫触锛屾帴鍙h繑鍥濩ode寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response);
+                }
+            } else {
+                News.info("璇锋眰鐢宠浠诲姟閲嶆柊鍒嗛厤鍏ュ簱鎺ュ彛澶辫触锛屾帴鍙f湭鍝嶅簲锛侊紒锛乽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);
+            News.error("璇锋眰鐢宠浠诲姟閲嶆柊鍒嗛厤鍏ュ簱鎺ュ彛寮傚父锛侊紒锛乽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());
+            httpRequestLog.setResult(result);
             httpRequestLogService.insert(httpRequestLog);
         }
         return response;
@@ -171,23 +213,38 @@
             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<>();
         String response = null;
+        int result = 0;
         try {
             requestParam.put("locNo", locNo);
             requestParam.put("row", crnRows);
@@ -196,22 +253,33 @@
                     .setUri(wmsUrl)
                     .setPath(wmsSystemChangeLocNoUrl)
                     .setJson(JSON.toJSONString(requestParam))
+                    .setTimeout(360, TimeUnit.SECONDS)
                     .build()
                     .doPost();
-            News.info("璇锋眰WMS鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemChangeLocNoUrl, JSON.toJSONString(requestParam), response);
 
-            return response;
+            if (response != null) {
+                JSONObject jsonObject = JSON.parseObject(response);
+                if (jsonObject.getInteger("code") == 200) {
+                    result = 1;
+                    News.info("璇锋眰WMS鐢宠鏇存崲搴撲綅鎺ュ彛鎴愬姛锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemChangeLocNoUrl, JSON.toJSONString(requestParam), response);
+                }else {
+                    News.info("璇锋眰WMS鐢宠鏇存崲搴撲綅鎺ュ彛澶辫触锛屾帴鍙h繑鍥濩ode寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemChangeLocNoUrl, JSON.toJSONString(requestParam), response);
+                }
+            }else {
+                News.info("璇锋眰WMS鐢宠鏇存崲搴撲綅鎺ュ彛澶辫触锛屾帴鍙f湭鍝嶅簲锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemChangeLocNoUrl, JSON.toJSONString(requestParam), response);
+            }
         } catch (Exception e) {
-            News.error("璇锋眰WMS鎺ュ彛寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemChangeLocNoUrl, JSON.toJSONString(requestParam), response, e);
+            News.error("璇锋眰WMS鐢宠鏇存崲搴撲綅鎺ュ彛寮傚父锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + wmsSystemChangeLocNoUrl, JSON.toJSONString(requestParam), response, e);
         } finally {
             HttpRequestLog httpRequestLog = new HttpRequestLog();
             httpRequestLog.setName(wmsUrl + wmsSystemChangeLocNoUrl);
             httpRequestLog.setRequest(JSON.toJSONString(requestParam));
             httpRequestLog.setResponse(response);
             httpRequestLog.setCreateTime(new Date());
+            httpRequestLog.setResult(result);
             httpRequestLogService.insert(httpRequestLog);
         }
-        return null;
+        return response;
     }
 
 }

--
Gitblit v1.9.1