From 076cd7a73eb60c86d43eda67c5625704576d44cc Mon Sep 17 00:00:00 2001
From: lbq <1065079612@qq.com>
Date: 星期二, 03 二月 2026 17:32:03 +0800
Subject: [PATCH] 实现mes空托和agv任务接口

---
 rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/MESController.java |  100 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/MESController.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/MESController.java
index b8d1c7b..325814a 100644
--- a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/MESController.java
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/MESController.java
@@ -3,20 +3,26 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.vincent.rsf.framework.common.R;
 import com.vincent.rsf.framework.exception.CoolException;
 import com.vincent.rsf.openApi.entity.dto.CommonResponse;
 import com.vincent.rsf.openApi.entity.phyz.*;
+import com.vincent.rsf.openApi.feign.wms.WmsServerFeignClient;
+import com.vincent.rsf.openApi.feign.wms.fallback.WmsServerFeignClientFallback;
 import com.vincent.rsf.openApi.service.phyz.MesReportService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 
 import static com.vincent.rsf.openApi.controller.AuthController.SIMULATED_DATA_ENABLE;
@@ -30,6 +36,8 @@
 
     @Resource
     private MesReportService mesReportService;
+    @Autowired(required = false)
+    private WmsServerFeignClient wmsServerFeignClient;
 
 
     @ApiOperation("澶囨枡閫氱煡")
@@ -92,8 +100,51 @@
 
         JSONArray params = paramsFormat(objParams);
         List<Task> tasks = JSON.parseArray(params.toJSONString(), Task.class);
-        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
-        return CommonResponse.ok();
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver          http://127.0.0.1:8085/rsf-server/pda/callForEmptyContainers   {"staNo":"103-1","type":"3"}
+        int success = 0;
+        StringBuilder errorMsg = new StringBuilder();
+        for (Task task : tasks) {
+            try {
+                if (wmsServerFeignClient == null) {
+                    log.warn("WmsServerFeignClient鏈敞鍏ワ紝鏃犳硶杩涜璋冪敤");
+                    return CommonResponse.error("鏈嶅姟鏈垵濮嬪寲");
+                }
+
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("type", task.getPalletType());
+                jsonObject.put("taskNo", task.getTaskNo());
+                jsonObject.put("staNo", task.getEndStationId());
+                jsonObject.put("taskOrigin", "mes");
+
+                log.info("mes绌烘墭鍑哄簱鍙傛暟锛� {}", JSON.toJSONString(jsonObject));
+
+                // 鐩存帴浼犻�掑疄浣撶被锛孎eign浼氳嚜鍔ㄥ簭鍒楀寲涓篔SON
+                R result = wmsServerFeignClient.callForEmptyContainers(jsonObject);
+
+                log.info("mes绌烘墭鍑哄簱杩斿洖缁撴灉锛� {}", JSON.toJSONString(result));
+
+                if (result != null) {
+                    Integer code = (Integer) result.get("code");
+                    if (code != null && code == 200) {
+                        success++;
+                    } else {
+                        errorMsg.append((String) result.get("msg"));
+                    }
+                } else {
+                    return CommonResponse.error("绌烘墭鍑哄簱鎵ц澶辫触锛氳繑鍥炵粨鏋滀负绌�");
+                }
+            } catch (Exception e) {
+                log.error("绌烘墭鍑哄簱鎵ц澶辫触", e);
+                String errorMessage = WmsServerFeignClientFallback.filterErrorMessage(e);
+                errorMsg.append(errorMessage);
+            }
+        }
+
+        if (success == tasks.size()) {
+            return CommonResponse.ok();
+        } else {
+            return CommonResponse.error(errorMsg.toString());
+        }
     }
 
     @ApiOperation("绌烘墭鍏ュ簱")
@@ -110,7 +161,50 @@
         JSONArray params = paramsFormat(objParams);
         List<Task> tasks = JSON.parseArray(params.toJSONString(), Task.class);
         // 鏁版嵁澶勭悊锛岃浆鍙憇erver
-        return CommonResponse.ok();
+        int success = 0;
+        StringBuilder errorMsg = new StringBuilder();
+        for (Task task : tasks) {
+            try {
+                if (wmsServerFeignClient == null) {
+                    log.warn("WmsServerFeignClient鏈敞鍏ワ紝鏃犳硶杩涜璋冪敤");
+                    return CommonResponse.error("鏈嶅姟鏈垵濮嬪寲");
+                }
+
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("containerNo", task.getPalletId());
+                jsonObject.put("taskNo", task.getTaskNo());
+                jsonObject.put("transferStationNo", task.getStartStationId());
+                jsonObject.put("taskOrigin", "mes");
+
+                log.info("mes绌烘墭鍏ュ簱鍙傛暟锛� {}", JSON.toJSONString(jsonObject));
+
+                // 鐩存帴浼犻�掑疄浣撶被锛孎eign浼氳嚜鍔ㄥ簭鍒楀寲涓篔SON
+                R result = wmsServerFeignClient.emptyContainerWarehousing(jsonObject);
+
+                log.info("mes绌烘墭鍏ュ簱杩斿洖缁撴灉锛� {}", JSON.toJSONString(result));
+
+                if (result != null) {
+                    Integer code = (Integer) result.get("code");
+                    if (code != null && code == 200) {
+                        success++;
+                    } else {
+                        errorMsg.append((String) result.get("msg"));
+                    }
+                } else {
+                    return CommonResponse.error("绌烘墭鍏ュ簱鎵ц澶辫触锛氳繑鍥炵粨鏋滀负绌�");
+                }
+            } catch (Exception e) {
+                log.error("绌烘墭鍏ュ簱鎵ц澶辫触", e);
+                String errorMessage = WmsServerFeignClientFallback.filterErrorMessage(e);
+                errorMsg.append(errorMessage);
+            }
+        }
+
+        if (success == tasks.size()) {
+            return CommonResponse.ok();
+        } else {
+            return CommonResponse.error(errorMsg.toString());
+        }
     }
 
     // region 娴嬭瘯鎺ㄩ�佸姛鑳�

--
Gitblit v1.9.1