From 69a3c374ca3afb770e3b9ffcbdda07ce362cbf58 Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期五, 09 一月 2026 19:59:29 +0800
Subject: [PATCH] #

---
 rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java |  284 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 284 insertions(+), 0 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
new file mode 100644
index 0000000..b1c826e
--- /dev/null
+++ b/rsf-open-api/src/main/java/com/vincent/rsf/openApi/controller/phyz/ERPController.java
@@ -0,0 +1,284 @@
+package com.vincent.rsf.openApi.controller.phyz;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.vincent.rsf.framework.exception.CoolException;
+import com.vincent.rsf.openApi.entity.dto.CommonResponse;
+import com.vincent.rsf.openApi.entity.phyz.*;
+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.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 java.util.List;
+import java.util.Objects;
+
+import static com.vincent.rsf.openApi.controller.AuthController.SIMULATED_DATA_ENABLE;
+
+@RestController
+@RequestMapping("/erp")
+@Api("閾跺骇鏂板伐鍘傦紙浜旀湡锛塃RP鎺ュ彛")
+@Slf4j
+public class ERPController {
+
+    @ApiOperation("浠撳簱淇℃伅鍚屾")
+    @PostMapping("/wareHouse/sync")
+    public CommonResponse syncWareHouse(@RequestBody Object objParams) {
+        if (Objects.isNull(objParams)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        // 杩斿洖妯℃嫙鏁版嵁
+        if (SIMULATED_DATA_ENABLE.equals("1")) {
+            return CommonResponse.ok();
+        }
+
+        JSONArray params = paramsFormat(objParams);
+        List<Warehouse> warehouseList = JSON.parseArray(params.toJSONString(), Warehouse.class);
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
+        return CommonResponse.ok();
+    }
+
+    @ApiOperation("鐗╂枡淇℃伅鍚屾")
+    @PostMapping("/mat/sync")
+    public CommonResponse syncMaterial(@RequestBody Object objParams) {
+        if (Objects.isNull(objParams)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        // 杩斿洖妯℃嫙鏁版嵁
+        if (SIMULATED_DATA_ENABLE.equals("1")) {
+            return CommonResponse.ok();
+        }
+
+        JSONArray params = paramsFormat(objParams);
+        List<Material> materialList = JSON.parseArray(params.toJSONString(), Material.class);
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
+        return CommonResponse.ok();
+    }
+
+    @ApiOperation("瀹㈡埛淇℃伅鍚屾")
+    @PostMapping("/customer/sync")
+    public CommonResponse syncCustomer(@RequestBody Object objParams) {
+        if (Objects.isNull(objParams)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        // 杩斿洖妯℃嫙鏁版嵁
+        if (SIMULATED_DATA_ENABLE.equals("1")) {
+            return CommonResponse.ok();
+        }
+
+        JSONArray params = paramsFormat(objParams);
+        List<Customer> customerList = JSON.parseArray(params.toJSONString(), Customer.class);
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
+        return CommonResponse.ok();
+    }
+
+    @ApiOperation("渚涘簲鍟嗕俊鎭悓姝�")
+    @PostMapping("/supplier/sync")
+    public CommonResponse syncSupplier(@RequestBody Object objParams) {
+        if (Objects.isNull(objParams)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        // 杩斿洖妯℃嫙鏁版嵁
+        if (SIMULATED_DATA_ENABLE.equals("1")) {
+            return CommonResponse.ok();
+        }
+
+        JSONArray params = paramsFormat(objParams);
+        List<Supplier> supplierList = JSON.parseArray(params.toJSONString(), Supplier.class);
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
+        return CommonResponse.ok();
+    }
+
+    @ApiOperation("鍏�/鍑哄簱浠诲姟閫氱煡鍗�")
+    @PostMapping("/order/add")
+    public CommonResponse addOrder(@RequestBody Object objParams) {
+        if (Objects.isNull(objParams)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        // 杩斿洖妯℃嫙鏁版嵁
+        if (SIMULATED_DATA_ENABLE.equals("1")) {
+            return CommonResponse.ok();
+        }
+
+        JSONArray params = paramsFormat(objParams);
+        List<Order> orderList = JSON.parseArray(params.toJSONString(), Order.class);
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
+        return CommonResponse.ok();
+    }
+
+    @ApiOperation("鍏�/鍑哄簱浠诲姟閫氱煡鍗曞彇娑�")
+    @PostMapping("/order/cancel")
+    public CommonResponse cancelOrder(@RequestBody Object objParams) {
+        if (Objects.isNull(objParams)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        // 杩斿洖妯℃嫙鏁版嵁
+        if (SIMULATED_DATA_ENABLE.equals("1")) {
+            return CommonResponse.ok();
+        }
+
+        JSONArray params = paramsFormat(objParams);
+        List<Order> orderList = JSON.parseArray(params.toJSONString(), Order.class);
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
+        return CommonResponse.ok();
+    }
+
+    @ApiOperation("搴撳瓨鏌ヨ鏄庣粏")
+    @PostMapping("/inventory/details")
+    public CommonResponse queryInventoryDetails(@RequestBody JSONObject params) {
+        if (SIMULATED_DATA_ENABLE.equals("1")) {
+            String x = "[\n" +
+                    "  {\n" +
+                    "    \"locId\": \"LOC-A-01-01\",\n" +
+                    "    \"wareHouseId\": \"WH001\",\n" +
+                    "    \"wareHouseName\": \"鍘熸枡浠撳簱\",\n" +
+                    "    \"palletId\": \"PALLET001\",\n" +
+                    "    \"matNr\": \"MAT10001\",\n" +
+                    "    \"makTx\": \"閽㈡潗Q235\",\n" +
+                    "    \"spec\": \"鍥芥爣GB/T700-2006\",\n" +
+                    "    \"anfme\": 10.5,\n" +
+                    "    \"unit\": \"鍚╘",\n" +
+                    "    \"status\": \"鍙敤\",\n" +
+                    "    \"orderType\": 1,\n" +
+                    "    \"orderNo\": \"Order202698921\",\n" +
+                    "    \"prepareType\": 1,\n" +
+                    "    \"planNo\": \"PLAN202601060001\",\n" +
+                    "    \"batch\": \"BATCH20260106001\",\n" +
+                    "    \"stockOrgId\": \"ORG001\"\n" +
+                    "  },\n" +
+                    "  {\n" +
+                    "    \"locId\": \"LOC-B-02-03\",\n" +
+                    "    \"wareHouseId\": \"WH002\",\n" +
+                    "    \"wareHouseName\": \"鎴愬搧浠撳簱\",\n" +
+                    "    \"palletId\": \"PALLET002\",\n" +
+                    "    \"matNr\": \"MAT20001\",\n" +
+                    "    \"makTx\": \"鐢垫満缁勪欢\",\n" +
+                    "    \"spec\": \"380V 50Hz\",\n" +
+                    "    \"anfme\": 50,\n" +
+                    "    \"unit\": \"鍙癨",\n" +
+                    "    \"status\": \"鍙敤\",\n" +
+                    "    \"orderType\": \"1\",\n" +
+                    "    \"orderNo\": \"SO202601060001\",\n" +
+                    "    \"prepareType\": 1,\n" +
+                    "    \"planNo\": \"PLAN202601060002\",\n" +
+                    "    \"batch\": \"BATCH20260106002\",\n" +
+                    "    \"stockOrgId\": \"ORG001\"\n" +
+                    "  }\n" +
+                    "]";
+            return CommonResponse.ok(JSONArray.parseArray(x, InventoryDetails.class));
+        }
+
+        InventoryQueryCondition condition = JSON.parseObject(params.toJSONString(), InventoryQueryCondition.class);
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
+        List<InventoryDetails> inventoryDetails = Lists.newArrayList();
+        return new CommonResponse().setCode(200).setData(inventoryDetails);
+    }
+
+    @ApiOperation("搴撳瓨鏌ヨ姹囨��")
+    @PostMapping("/inventory/summary")
+    public CommonResponse queryInventorySummary(@RequestBody JSONObject params) {
+        if (SIMULATED_DATA_ENABLE.equals("1")) {
+            String s = "{\n" +
+                    "  \"code\": 200,\n" +
+                    "  \"msg\": \"鎿嶄綔鎴愬姛\",\n" +
+                    "  \"data\": [\n" +
+                    "    {\n" +
+                    "      \"wareHouseId\": \"WH001\",\n" +
+                    "      \"wareHouseName\": \"鍘熸枡浠撳簱\",\n" +
+                    "      \"matNr\": \"MAT10001\",\n" +
+                    "      \"makTx\": \"閽㈡潗Q235\",\n" +
+                    "      \"spec\": \"鍥芥爣GB/T700-2006\",\n" +
+                    "      \"anfme\": 10.5,\n" +
+                    "      \"unit\": \"鍚╘",\n" +
+                    "      \"stockOrgId\": \"ORG001\",\n" +
+                    "      \"batch\": \"BATCH20260106001\",\n" +
+                    "      \"planNo\": \"Plan20260106006\"\n" +
+                    "    },\n" +
+                    "    {\n" +
+                    "      \"wareHouseId\": \"WH001\",\n" +
+                    "      \"wareHouseName\": \"鍘熸枡浠撳簱\",\n" +
+                    "      \"matNr\": \"MAT10002\",\n" +
+                    "      \"makTx\": \"閾濆瀷鏉�6061\",\n" +
+                    "      \"spec\": \"鍥芥爣GB/T3190-2008\",\n" +
+                    "      \"anfme\": 20.3,\n" +
+                    "      \"unit\": \"鍚╘",\n" +
+                    "      \"stockOrgId\": \"ORG001\",\n" +
+                    "      \"batch\": \"BATCH20260106002\",\n" +
+                    "      \"planNo\": \"Plan20260106005\"\n" +
+                    "    },\n" +
+                    "    {\n" +
+                    "      \"wareHouseId\": \"WH002\",\n" +
+                    "      \"wareHouseName\": \"鎴愬搧浠撳簱\",\n" +
+                    "      \"matNr\": \"MAT30001\",\n" +
+                    "      \"makTx\": \"鐢垫満鎴愬搧\",\n" +
+                    "      \"spec\": \"380V 50Hz 15KW\",\n" +
+                    "      \"anfme\": 100,\n" +
+                    "      \"unit\": \"鍙癨",\n" +
+                    "      \"stockOrgId\": \"ORG001\",\n" +
+                    "      \"batch\": \"BATCH20260106003\",\n" +
+                    "      \"planNo\": \"Plan20260106004\"\n" +
+                    "    }\n" +
+                    "  ]\n" +
+                    "}";
+            return JSONObject.parseObject(s, CommonResponse.class);
+        }
+
+        InventoryQueryCondition condition = JSON.parseObject(params.toJSONString(), InventoryQueryCondition.class);
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
+        List<InventorySummary> inventorySummaries = Lists.newArrayList();
+        return new CommonResponse().setCode(200).setData(inventorySummaries);
+
+    }
+
+    @ApiOperation("鐩樼偣缁撴灉纭")
+    @PostMapping("/check/confirm")
+    public CommonResponse checkConfirm(@RequestBody Object objParams) {
+        if (Objects.isNull(objParams)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        // 杩斿洖妯℃嫙鏁版嵁
+        if (SIMULATED_DATA_ENABLE.equals("1")) {
+            return CommonResponse.ok();
+        }
+
+        JSONArray params = paramsFormat(objParams);
+        CheckOrder checkResult = JSON.parseObject(params.toJSONString(), CheckOrder.class);
+        // 鏁版嵁澶勭悊锛岃浆鍙憇erver
+        return CommonResponse.ok();
+    }
+
+    /**
+     * 鍏煎JSONObject鍜孞SONArray鏍煎紡鏁版嵁
+     *
+     * @param data json鏍煎紡鍙傛暟
+     * @return JSONArray鏍煎紡鏁版嵁
+     */
+    public static JSONArray paramsFormat(Object data) {
+        if (Objects.isNull(data)) {
+            return new JSONArray();
+        }
+
+        try {
+            String jsonStr = JSON.toJSONString(data);
+            if (jsonStr.startsWith("[")) {
+                return JSON.parseArray(jsonStr);
+            } else if (jsonStr.startsWith("{")) {
+                JSONArray params = new JSONArray();
+                params.add(JSON.parseObject(jsonStr));
+                return params;
+            }
+        } catch (Exception e) {
+            // 瑙f瀽澶辫触锛岃繑鍥炵┖鏁扮粍
+            log.error("杞崲鍙傛暟涓簀son鏍煎紡閿欒", e);
+        }
+
+        // 榛樿杩斿洖绌烘暟缁�
+        return new JSONArray();
+    }
+
+}

--
Gitblit v1.9.1