package com.wms_main.controller.wms;

import com.wms_main.model.dto.request.wcs.WcsTaskResultRequest;
import com.wms_main.model.dto.request.wms.*;
import com.wms_main.model.dto.response.wcs.BaseWcsApiResponse;
import com.wms_main.model.dto.response.wms.BaseWmsApiResponse;
import com.wms_main.model.dto.response.wms.WmsApiResponse;
import com.wms_main.model.po.TAppWcsTaskBak;
import com.wms_main.model.vo.wms.TaskConfirmVo;
import com.wms_main.service.controller.ITaskControllerService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 任务控制类
 */
@RestController
@ResponseBody
@CrossOrigin
@RequiredArgsConstructor
@RequestMapping("/wms/task")
public class TaskController {
    private final ITaskControllerService taskControllerService;

    /**
     * 请求入库
     * @param stockInRequest 请求信息
     * @return 处理结果
     */
    @PostMapping("/requireStockIn")
    public BaseWmsApiResponse requireStockIn(@RequestBody StockInRequest stockInRequest) {
        return taskControllerService.requireStockIn(stockInRequest);
    }

    /**
     * 请求出库
     * @param stockOutRequest 请求信息
     * @return 处理结果
     */
    @PostMapping("/requireStockOut")
    public BaseWmsApiResponse requireStockOut(@RequestBody StockOutRequest stockOutRequest) {
        return taskControllerService.requireStockOut(stockOutRequest);
    }

    /**
     * 接收wcs反馈任务状态
     * @param wcsTaskResultRequest 请求信息
     * @return 处理结果
     */
    @PostMapping("/sendTaskResult")
    public BaseWcsApiResponse sendTaskResult(@RequestBody WcsTaskResultRequest wcsTaskResultRequest) {
        return taskControllerService.sendTaskResult(wcsTaskResultRequest);
    }

    /**
     * 查询站台拣货任务---拣配工作之外
     * @param wmsRequest 请求信息
     * @return 处理结果
     */
    @PostMapping("/getCurrentTask")
    public WmsApiResponse<TaskConfirmVo> getCurrentTask(@RequestBody BaseWmsRequest wmsRequest) {
        return taskControllerService.getCurrentTask(wmsRequest);
    }

    @PostMapping("/getTaskBaks")
    public WmsApiResponse<List<TAppWcsTaskBak>> getTaskBaks(@RequestBody WcsTaskBakRequest request) {
        return taskControllerService.getWcsTaskBak(request);
    }
}
