From a56420ff2042a3f6b1e824341a717a28c692cad4 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期五, 30 一月 2026 16:39:15 +0800
Subject: [PATCH] 查询库存明细

---
 rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java |  133 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 126 insertions(+), 7 deletions(-)

diff --git a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java
index b1c826e..90edbd6 100644
--- a/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java
@@ -3,19 +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.service.phyz.ErpReportService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.utils.Lists;
+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;
@@ -25,6 +32,15 @@
 @Api("閾跺骇鏂板伐鍘傦紙浜旀湡锛塃RP鎺ュ彛")
 @Slf4j
 public class ERPController {
+
+    public static JSONArray map = new JSONArray();
+
+    @Resource
+    private ErpReportService erpReportService;
+
+    @Autowired(required = false)
+    private WmsServerFeignClient wmsServerFeignClient;
+
 
     @ApiOperation("浠撳簱淇℃伅鍚屾")
     @PostMapping("/wareHouse/sync")
@@ -108,7 +124,16 @@
         JSONArray params = paramsFormat(objParams);
         List<Order> orderList = JSON.parseArray(params.toJSONString(), Order.class);
         // 鏁版嵁澶勭悊锛岃浆鍙憇erver
-        return CommonResponse.ok();
+        StringBuffer errorMsg = new StringBuffer();
+        for (Order order : orderList) {
+            String i = erpReportService.addOrderToServer(order);
+            if (i.equals("200")){
+                errorMsg.append(order.getOrderNo()+"涓嬪彂鎴愬姛;");
+            } else {
+                errorMsg.append(order.getOrderNo()+"涓嬪彂澶辫触,鍘熷洜锛�"+i+";");
+            }
+        }
+        return CommonResponse.ok(errorMsg.toString());
     }
 
     @ApiOperation("鍏�/鍑哄簱浠诲姟閫氱煡鍗曞彇娑�")
@@ -130,7 +155,7 @@
 
     @ApiOperation("搴撳瓨鏌ヨ鏄庣粏")
     @PostMapping("/inventory/details")
-    public CommonResponse queryInventoryDetails(@RequestBody JSONObject params) {
+    public CommonResponse queryInventoryDetails(@RequestBody InventoryQueryCondition condition) {
         if (SIMULATED_DATA_ENABLE.equals("1")) {
             String x = "[\n" +
                     "  {\n" +
@@ -170,13 +195,83 @@
                     "    \"stockOrgId\": \"ORG001\"\n" +
                     "  }\n" +
                     "]";
-            return CommonResponse.ok(JSONArray.parseArray(x, InventoryDetails.class));
+            if (map == null || map.isEmpty()) {
+                map = JSON.parseArray(x);
+            }
+            return CommonResponse.ok(JSONArray.parseArray(map.toJSONString(), InventoryDetails.class));
         }
 
-        InventoryQueryCondition condition = JSON.parseObject(params.toJSONString(), InventoryQueryCondition.class);
-        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
-        List<InventoryDetails> inventoryDetails = Lists.newArrayList();
-        return new CommonResponse().setCode(200).setData(inventoryDetails);
+        try {
+            if (wmsServerFeignClient == null) {
+                log.warn("WmsServerFeignClient鏈敞鍏ワ紝鏃犳硶杩涜璋冪敤");
+                return CommonResponse.error("鏈嶅姟鏈垵濮嬪寲");
+            }
+            
+            // 鍙傛暟楠岃瘉
+            if (condition == null) {
+                return CommonResponse.error("鏌ヨ鏉′欢涓嶈兘涓虹┖");
+            }
+            
+            log.info("搴撳瓨鏌ヨ鏄庣粏璇锋眰鍙傛暟锛� {}", JSON.toJSONString(condition));
+            
+            // 鐩存帴浼犻�掑疄浣撶被锛孎eign浼氳嚜鍔ㄥ簭鍒楀寲涓篔SON
+            R result = wmsServerFeignClient.queryInventoryDetails(condition);
+            
+            log.info("搴撳瓨鏌ヨ鏄庣粏杩斿洖缁撴灉锛� {}", JSON.toJSONString(result));
+            
+            if (result != null) {
+                // R绫荤户鎵胯嚜HashMap锛屼娇鐢╣et鏂规硶鑾峰彇鍊�
+                Integer code = (Integer) result.get("code");
+                String msg = (String) result.get("msg");
+                Object data = result.get("data");
+                
+                if (code != null && code == 200) {
+                    // 灏哅ap鍒楄〃杞崲涓篒nventoryDetails鍒楄〃
+                    if (data != null) {
+                        @SuppressWarnings("unchecked")
+                        List<Map<String, Object>> dataList = (List<Map<String, Object>>) data;
+                        List<InventoryDetails> inventoryDetails = new ArrayList<>();
+                        for (Map<String, Object> item : dataList) {
+                            InventoryDetails details = JSON.parseObject(JSON.toJSONString(item), InventoryDetails.class);
+                            inventoryDetails.add(details);
+                        }
+                        return CommonResponse.ok(inventoryDetails);
+                    } else {
+                        return CommonResponse.ok(new ArrayList<>());
+                    }
+                } else {
+                    return CommonResponse.error(msg != null ? msg : "鏌ヨ澶辫触");
+                }
+            } else {
+                return CommonResponse.error("鏌ヨ澶辫触锛氳繑鍥炵粨鏋滀负绌�");
+            }
+        } catch (Exception e) {
+            log.error("搴撳瓨鏌ヨ鏄庣粏澶辫触", e);
+            // 杩囨护閿欒娑堟伅涓殑URL锛屽彧淇濈暀閿欒绫诲瀷
+            String errorMessage = e.getMessage();
+            if (errorMessage != null) {
+                // 濡傛灉鍖呭惈"executing"锛岃鏄庢槸HTTP璇锋眰閿欒锛屽幓鎺塙RL閮ㄥ垎
+                if (errorMessage.contains("executing")) {
+                    int executingIndex = errorMessage.indexOf("executing");
+                    if (executingIndex > 0) {
+                        // 鎻愬彇"executing"涔嬪墠鐨勯儴鍒嗭紙濡�"Read timed out"锛�
+                        errorMessage = errorMessage.substring(0, executingIndex).trim();
+                    } else {
+                        // 濡傛灉"executing"鍦ㄥ紑澶达紝浣跨敤榛樿閿欒娑堟伅
+                        errorMessage = "璇锋眰瓒呮椂";
+                    }
+                }
+                // 濡傛灉鍖呭惈"http://"鎴�"https://"锛屼篃灏濊瘯鍘绘帀URL閮ㄥ垎
+                else if (errorMessage.contains("http://") || errorMessage.contains("https://")) {
+                    // 浣跨敤姝e垯琛ㄨ揪寮忓幓鎺塙RL
+                    errorMessage = errorMessage.replaceAll("https?://[^\\s]+", "").trim();
+                    if (errorMessage.isEmpty()) {
+                        errorMessage = "璇锋眰澶辫触";
+                    }
+                }
+            }
+            return CommonResponse.error("鏌ヨ澶辫触锛�" + (errorMessage != null && !errorMessage.isEmpty() ? errorMessage : "鏈煡閿欒"));
+        }
     }
 
     @ApiOperation("搴撳瓨鏌ヨ姹囨��")
@@ -281,4 +376,28 @@
         return new JSONArray();
     }
 
+    // region 娴嬭瘯鎺ㄩ�佸姛鑳�
+    @ApiOperation("鐧诲綍")
+    @PostMapping("/loginBySign")
+    public CommonResponse loginBySign() {
+        try {
+            return CommonResponse.ok(erpReportService.loginBySign());
+        } catch (Exception e) {
+            log.error("erp, loginBySign", e);
+        }
+        return CommonResponse.ok();
+    }
+
+    @ApiOperation("鍏�/鍑哄簱浠诲姟鍥炶皟")
+    @PostMapping("/reportInOrOutBound")
+    public CommonResponse reportInOrOutBound(@RequestBody Object objParams) {
+        try {
+            return erpReportService.reportInOrOutBound(objParams);
+        } catch (Exception e) {
+            log.error("erp, reportInOrOutBound", e);
+        }
+        return CommonResponse.ok();
+    }
+    // endregion
+
 }

--
Gitblit v1.9.1