package com.wms_main.controller.ycwms;


import com.wms_main.model.dto.request.ycwms.OrderInReq;
import com.wms_main.model.dto.request.ycwms.OrderOutReq;
import com.wms_main.model.dto.request.ycwms.StockReq;
import com.wms_main.model.dto.request.ycwms.StockResp;
import com.wms_main.model.dto.response.ycwms.YcwmsResponse;
import com.wms_main.service.controller.IYcwmsControllerService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 和亚驰仓库对接的接口
 */
@RestController
@ResponseBody
@CrossOrigin
@RequiredArgsConstructor
@RequestMapping("/ycwms")
public class YcwmsController {


    private final IYcwmsControllerService ycwmsControllerService;

    /**
     * 接收亚驰 WMS 发来的 入库单
     * @param request 请求数据
     * @return 返回
     */
    @PostMapping("/orderIn")
    public YcwmsResponse<Object> orderIn(@RequestBody OrderInReq request) {
        return ycwmsControllerService.orderIn(request);
    }

    @PostMapping("/orderOut")
    public YcwmsResponse<Object> orderOut(@RequestBody OrderOutReq request) {
        return ycwmsControllerService.orderOut(request);
    }

    @PostMapping("/stock")
    public YcwmsResponse<List<StockResp>> stock(@RequestBody StockReq request) {
        return ycwmsControllerService.stock(request);
    }

    @GetMapping("/getAvailPercent")
    public YcwmsResponse<Object> getAvailPercent(@RequestParam(value = "equipmentId") String equipmentId) {
        return ycwmsControllerService.getAvailPercent(equipmentId);
    }
}
