chen.lin
1 天以前 b003a49794f49a329e2702918ecfc8d14b371d0d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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 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),
 * 立库上报请求会打到本接口并返回模拟成功。
 */
@Slf4j
@RestController
@RequestMapping("/api")
@Api(value = "云仓模拟接口", tags = "云仓模拟(无真实云仓URL时使用)")
public class CloudWmsMockController {
 
    private static Map<String, Object> successResponse() {
        Map<String, Object> data = new HashMap<>();
        data.put("result", "SUCCESS");
        Map<String, Object> map = new HashMap<>();
        map.put("code", 200);
        map.put("msg", "");
        map.put("data", data);
        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();
    }
 
    /** 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 = "/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();
    }
}