cl
6 小时以前 52e09a6b7b7054fc51b9d4bf5f1fbec0a57e60f1
rsf-server/src/main/java/com/vincent/rsf/server/api/controller/CloudWmsMockController.java
@@ -1,31 +1,44 @@
package com.vincent.rsf.server.api.controller;
import com.vincent.rsf.server.api.controller.erp.params.InOutResultReportParam;
import com.vincent.rsf.server.api.controller.erp.params.InventoryAdjustReportParam;
import com.vincent.rsf.server.api.controller.erp.params.DapIlcwmsCompletionRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
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.HashMap;
import java.util.Map;
/**
 * 云仓WMS 模拟接口(对接协议 9.1、9.2、物料同步)。
 * 云仓未提供真实 URL 时,可将 platform.erp.base-url 指向本机该服务(如 http://127.0.0.1:8086/rsf-server),
 * 立库上报请求会打到本接口并返回模拟成功。
 * 云仓模拟接口。platform.erp.base-url 指向本服务时,Feign 会请求下列 DAP 风格路径。
 */
@Slf4j
@RestController
@RequestMapping("/api")
@Api(value = "云仓模拟接口", tags = "云仓模拟(无真实云仓URL时使用)")
public class CloudWmsMockController {
    private static Map<String, Object> successResponse() {
    private static Map<String, Object> dapOkEnvelope() {
        Map<String, Object> profile = new HashMap<>();
        profile.put("tenantSid", 1);
        profile.put("userSid", "SYS");
        Map<String, Object> response = new HashMap<>();
        response.put("code", -1);
        response.put("success", false);
        response.put("message", "");
        Map<String, Object> map = new HashMap<>();
        map.put("duration", 58);
        map.put("statusDescription", "OK");
        map.put("response", response);
        map.put("profile", profile);
        map.put("uuid", "");
        map.put("status", 200);
        return map;
    }
    private static Map<String, Object> successResponseLegacy() {
        Map<String, Object> data = new HashMap<>();
        data.put("result", "SUCCESS");
        Map<String, Object> map = new HashMap<>();
@@ -35,33 +48,39 @@
        return map;
    }
    /** 9.1 入/出库结果上报 - 模拟 */
    @ApiOperation("入/出库结果上报(模拟)")
    @PostMapping(value = "/report/inOutResult", consumes = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> mockInOutResult(@RequestBody InOutResultReportParam body) {
        log.info("云仓模拟-入/出库结果上报,orderNo={},locId={},matNr={}",
                body != null ? body.getOrderNo() : null,
                body != null ? body.getLocId() : null,
                body != null ? body.getMatNr() : null);
        return successResponse();
    @ApiOperation("鼎捷-入库完成反馈(模拟)")
    @PostMapping(value = "/dapilc/restful/service/ilcwmsplus/IKWebService/cusInventoryCompletionReport", consumes = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> mockInventoryCompletion(@RequestBody DapIlcwmsCompletionRequest body) {
        log.info("云仓模拟-入库完成反馈,行数={}", body != null && body.getData() != null ? body.getData().size() : 0);
        return dapOkEnvelope();
    }
    /** 9.2 库存调整主动上报 - 模拟 */
    @ApiOperation("库存调整主动上报(模拟)")
    @PostMapping(value = "/report/inventoryAdjust", consumes = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> mockInventoryAdjust(@RequestBody InventoryAdjustReportParam body) {
        log.info("云仓模拟-库存调整上报,changeType={},wareHouseId={},matNr={}",
                body != null ? body.getChangeType() : null,
                body != null ? body.getWareHouseId() : null,
                body != null ? body.getMatNr() : null);
        return successResponse();
    @ApiOperation("鼎捷-出库完成反馈(模拟)")
    @PostMapping(value = "/dapilc/restful/service/ilcwmsplus/IKWebService/cusOutboundCompletionReport", consumes = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> mockOutboundCompletion(@RequestBody DapIlcwmsCompletionRequest body) {
        log.info("云仓模拟-出库完成反馈,行数={}", body != null && body.getData() != null ? body.getData().size() : 0);
        return dapOkEnvelope();
    }
    /** 9.2 库存调整主动上报 - 模拟(路径不变,body 为 {data:[]}) */
    @ApiOperation("库存调整上报(模拟)")
    @PostMapping(value = "/api/report/inventoryAdjust", consumes = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> mockInventoryAdjust(@RequestBody DapIlcwmsCompletionRequest body) {
        log.info("云仓模拟-库存调整上报,行数={}", body != null && body.getData() != null ? body.getData().size() : 0);
        return successResponseLegacy();
    }
    /** 物料基础信息同步 - 模拟 */
    @ApiOperation("物料同步(模拟)")
    @PostMapping(value = "/mat/sync", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/api/mat/sync", consumes = MediaType.APPLICATION_JSON_VALUE)
    public Map<String, Object> mockMatSync(@RequestBody Object body) {
        log.info("云仓模拟-物料同步,body={}", body != null ? body.toString() : null);
        return successResponse();
        return successResponseLegacy();
    }
//    /** 9.1 入/出库结果上报 - 模拟(旧路径,已改 DAP) */
//    @PostMapping(value = "/api/report/inOutResult", consumes = MediaType.APPLICATION_JSON_VALUE)
//    public Map<String, Object> mockInOutResult(@RequestBody InOutResultReportParam body) {
//        return successResponseLegacy();
//    }
}