package com.wms_main.controller.wms;

import com.wms_main.model.bo.wms.BoxSummary;
import com.wms_main.model.bo.wms.KanbanLackDetail;
import com.wms_main.model.dto.query.*;
import com.wms_main.model.dto.request.wms.*;
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.*;
import com.wms_main.service.controller.IKateWorkControllerService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 卡特相关控制类
 */
@RestController
@ResponseBody
@CrossOrigin
@RequiredArgsConstructor
@RequestMapping("/wms/kate")
public class KateWorkController {
    private final IKateWorkControllerService kateWorkControllerService;

    /**
     * 处理查询请求
     * @param kateWorksQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/queryKateWorks")
    public WmsApiResponse<KateWorkOptionsVo> queryKateWorks(@RequestBody KateWorksQuery kateWorksQuery) {
        return kateWorkControllerService.queryKateWorks(kateWorksQuery);
    }

    /**
     * 请求创建工作
     * @param initKateWorkRequest 请求参数
     * @return 查询结果
     */
    @PostMapping("/initWorks")
    public BaseWmsApiResponse initWorks(@RequestBody InitKateWorkRequest initKateWorkRequest) {
        return kateWorkControllerService.initWorks(initKateWorkRequest);
    }

    /**
     * 获取工作信息
     * @param kateWorksQuery 请求参数
     * @return 查询结果
     */
    @PostMapping("/getCurrentWorks")
    public WmsApiResponse<WorkConfirmVo> getCurrentWorks(@RequestBody KateWorksQuery kateWorksQuery) {
        return kateWorkControllerService.getCurrentWorks(kateWorksQuery);
    }

    /**
     * 确认工作
     * @param confirmWorkRequest 请求参数
     * @return 查询结果
     */
    @PostMapping("/confirmCurrentWork")
    public BaseWmsApiResponse confirmCurrentWork(@RequestBody ConfirmWorkRequest confirmWorkRequest) {
        return kateWorkControllerService.confirmCurrentWork(confirmWorkRequest);
    }

    /**
     * 查询图纸
     * @param request 请求参数
     * @return 查询结果
     */
    @PostMapping("/getImageOfWork")
    public WmsApiResponse<ImageVo> getImageOfWork(@RequestBody BaseWmsRequest request) {
        return kateWorkControllerService.getImageOfWork(request);
    }

    /**
     * 配料界面获取料盒显示信息
     * @param request 请求
     * @return 查询结果
     */
    @PostMapping("/getBoxesAndLacks")
    WmsApiResponse<BoxDetailVo> getBoxesAndLacks(@RequestBody BaseWmsRequest request) {
        return kateWorkControllerService.getBoxesAndLacks(request);
    }

    /**
     * 分页查看看板
     * @param kanbanQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/queryKanbanByPage")
    WmsApiResponse<PageVo<KanbanVo>> queryKanbanByPage(@RequestBody KanbanQuery kanbanQuery) {
        return kateWorkControllerService.queryKanbanByPage(kanbanQuery);
    }

    /**
     * 生成看板需求
     * @param genRequest 生成需求
     * @return 处理结果
     */
    @PostMapping("/genClcKanbanRequirement")
    WmsApiResponse<List<KanbanLackDetail>> genClcKanbanRequirement(@RequestBody GenKanbanRequirementRequest genRequest) {
        return kateWorkControllerService.genClcKanbanRequirement(genRequest);
    }

    /**
     * 获取物料需求
     * @param goodsRequireRequest 请求参数
     * @return 处理结果
     */
    @PostMapping("/getGoodsRequirement")
    WmsApiResponse<List<GoodsRequireVo>> getGoodsRequirement(@RequestBody GoodsRequireRequest goodsRequireRequest) {
        return kateWorkControllerService.getGoodsRequirement(goodsRequireRequest);
    }

    /**
     * 查询图纸
     * @param imageQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/requestImageDetail")
    public WmsApiResponse<List<ImageVo>> requestImageDetail(@RequestBody ImageQuery imageQuery) {
        return kateWorkControllerService.requestImageDetail(imageQuery);
    }

    /**
     * 查询图纸---分页
     * @param imageQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/queryImagesByPage")
    public WmsApiResponse<PageVo<ImageVo>> queryImagesByPage(@RequestBody ImageQuery imageQuery) {
        return kateWorkControllerService.queryImagesByPage(imageQuery);
    }

    /**
     * 查询DBS数据--分页
     * @param dbsQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/queryDbsByPage")
    public WmsApiResponse<PageVo<DbsVo>> queryDbsByPage(@RequestBody DbsQuery dbsQuery) {
        return kateWorkControllerService.queryDbsByPage(dbsQuery);
    }

    /**
     * 查询配料单数据--分页
     * @param kittingBomQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/queryKittingBomByPage")
    public WmsApiResponse<PageVo<KittingBomVo>> queryKittingBomByPage(@RequestBody KittingBomQuery kittingBomQuery) {
        return kateWorkControllerService.queryKittingBomByPage(kittingBomQuery);
    }

    /**
     * 查询配对关系数据--分页
     * @param kittingBomRelationQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/queryRelationByPage")
    public WmsApiResponse<PageVo<KittingBomRelationVo>> queryKittingRelationByPage(@RequestBody KittingBomRelationQuery kittingBomRelationQuery) {
        return kateWorkControllerService.queryKittingRelationByPage(kittingBomRelationQuery);
    }

    /**
     * 查询工作分析数据--分页
     * @param workSummaryQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/queryWorkSummaryByPage")
    public WmsApiResponse<PageVo<KateWorkVo>> queryWorkSummaryByPage(@RequestBody WorkSummaryQuery workSummaryQuery) {
        return kateWorkControllerService.queryWorkSummaryByPage(workSummaryQuery);
    }

    /**
     * 查询当前站台待工作的物料列表
     * @param workSummaryQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/queryWorkingGoodsByPage")
    public WmsApiResponse<PageVo<KateWorkVo>> queryWorkingGoodsByPage(@RequestBody WorkSummaryQuery workSummaryQuery) {
        return kateWorkControllerService.queryWorkingGoodsByPage(workSummaryQuery);
    }

    /**
     * 查询当前站台待工作的物料列表
     * @param kateWorksQuery 查询参数
     * @return 查询结果
     */
    @PostMapping("/getLackGoods")
    public WmsApiResponse<List<KateWorkVo>> getLackGoods(@RequestBody KateWorksQuery kateWorksQuery) {
        return kateWorkControllerService.getLackGoods(kateWorksQuery);
    }

    /**
     * 更新工作
     * @param updateWorkRequest 更新请求
     * @return 响应结果
     */
    @PostMapping("/updateKateWorks")
    public BaseWmsApiResponse updateKateWorks(@RequestBody UpdateWorkRequest updateWorkRequest) {
        return kateWorkControllerService.updateKateWorks(updateWorkRequest);
    }

    /**
     * 关闭当前缺料工作
     * @param closeWorkRequest 关闭请求
     * @return 关闭结果
     */
    @PostMapping("/closeCurrentWorks")
    public BaseWmsApiResponse closeCurrentWorks(@RequestBody UpdateWorkRequest closeWorkRequest) {
        return kateWorkControllerService.closeCurrentWorks(closeWorkRequest);
    }

    /**
     * 请求打印料盒标签
     * @param kateWorksQuery 查询参数
     * @return 需要打印的料盒标签
     */
    @PostMapping("/requestPrintBoxTags")
    WmsApiResponse<BoxSummary> requestPrintBoxTags(@RequestBody KateWorksQuery kateWorksQuery) {
        return kateWorkControllerService.requestPrintBoxTags(kateWorksQuery);
    }

    /**
     * 删除当前dbs工单计划
     * @param dbsRequest 关闭请求
     * @return 删除结果
     */
    @PostMapping("/deleteDbsPlan")
    public BaseWmsApiResponse deleteDbsPlan(@RequestBody DbsRequest dbsRequest) {
        return kateWorkControllerService.deleteDbsPlan(dbsRequest);
    }

    /**
     * 删除配料单
     * @param kittingBomRequest 删除请求
     * @return 删除结果
     */
    @PostMapping("/deleteKittingBom")
    public BaseWmsApiResponse deleteKittingBom(@RequestBody KittingBomRequest kittingBomRequest) {
        return kateWorkControllerService.deleteKittingBom(kittingBomRequest);
    }

    /**
     * 获取目标工单列表
     * @param dbsQuery 查询参数
     * @return 目标工单列表
     */
    @PostMapping("/getTargetOrderList")
    public WmsApiResponse<List<String>> getTargetOrderList(@RequestBody DbsQuery dbsQuery) {
        return kateWorkControllerService.getTargetOrderList(dbsQuery);
    }
}
