package com.wms_main.controller.wms;

import com.wms_main.model.bo.wcs.WcsStackerTask;
import com.wms_main.model.dto.request.wcs.WcsBoxArriveRequest;
import com.wms_main.model.dto.request.wcs.WcsTaskResultRequest;
import com.wms_main.model.dto.request.wcs.WcsVehicleInRequest;
import com.wms_main.model.dto.request.wms.*;
import com.wms_main.model.dto.response.wcs.BaseWcsApiResponse;
import com.wms_main.model.dto.response.wcs.WcsApiResponse;
import com.wms_main.model.dto.response.wms.BaseWmsApiResponse;
import com.wms_main.model.dto.response.wms.WmsApiResponse;
import com.wms_main.model.vo.wms.InventoryConfirmVo;
import com.wms_main.model.vo.wms.TaskConfirmVo;
import com.wms_main.service.controller.ITaskControllerService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 任务控制类
 */
@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);
    }

    /**
     * 入库用出库
     * @param voiRequest 请求信息
     * @return 处理结果
     */
    @PostMapping("/requireVehiclesForIn")
    public BaseWmsApiResponse requireVehiclesForIn(@RequestBody VehicleOutForInRequest voiRequest) {
        return taskControllerService.requireVehiclesForIn(voiRequest);
    }

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

    /**
     * wcs请求载具入库
     * @param wcsVehicleInRequest 载具请求
     * @return 处理结果
     */
    @PostMapping("/wcsRequestVehicleIn")
    public WcsApiResponse<WcsStackerTask> wcsRequestVehicleIn(@RequestBody WcsVehicleInRequest wcsVehicleInRequest) {
        return taskControllerService.wcsRequestVehicleIn(wcsVehicleInRequest);
    }

    /**
     * Wcs上报载具到达站台
     * @param boxArriveRequest 请求信息
     * @return 处理结果
     */
    @PostMapping("/boxArrive")
    public BaseWcsApiResponse boxArrive(@RequestBody WcsBoxArriveRequest boxArriveRequest) {
        return taskControllerService.boxArrive(boxArriveRequest);
    }

    /**
     * 取消拣选任务
     * @param pickTaskRequest 请求信息
     * @return 处理结果
     */
    @PostMapping("/cancelPickTasks")
    public BaseWmsApiResponse cancelPickTasks(@RequestBody PickTaskRequest pickTaskRequest) {
        return taskControllerService.cancelPickTasks(pickTaskRequest);
    }

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

    /**
     * 确认当前站台拣货任务---拣配工作之外
     * @param confirmTaskRequest 请求信息
     * @return 处理结果
     */
    @PostMapping("/confirmCurrentTask")
    public BaseWmsApiResponse confirmCurrentTask(@RequestBody ConfirmTaskRequest confirmTaskRequest) {
        return taskControllerService.confirmCurrentTask(confirmTaskRequest);
    }

    /**
     * 下发盘点请求
     * @param inventoryRequest 盘点请求
     * @return 请求结果
     */
    @PostMapping("/requestInventory")
    public BaseWmsApiResponse requestInventory(@RequestBody InventoryRequest inventoryRequest) {
        return taskControllerService.requestInventory(inventoryRequest);
    }

    /**
     * 查询盘点任务确认信息
     * @param inventoryConfirmRequest 请求
     * @return 请求结果
     */
    @PostMapping("/getInventoryConfirm")
    WmsApiResponse<InventoryConfirmVo> getInventoryConfirm(@RequestBody InventoryConfirmRequest inventoryConfirmRequest) {
        return taskControllerService.getInventoryConfirm(inventoryConfirmRequest);
    }

    /**
     * 确认盘点信息
     * @param inventoryConfirmRequest 确认请求
     * @return 处理结果
     */
    @PostMapping("/confirmInventory")
    BaseWmsApiResponse confirmInventory(@RequestBody InventoryConfirmRequest inventoryConfirmRequest) {
        return taskControllerService.confirmInventory(inventoryConfirmRequest);
    }
}
