package com.shkj.wms.controller.business;


import com.shkj.common.annotation.Log;
import com.shkj.common.annotation.RepeatSubmit;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.enums.BusinessType;
import com.shkj.wms.bo.*;
import com.shkj.wms.service.IBusinDataTaskService;
import com.shkj.wms.vo.BusinDataTaskGoodsVo;
import com.shkj.wms.vo.BusinDataTaskManageVo;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RequiredArgsConstructor(onConstructor_ =@Autowired)
@RestController
@RequestMapping("/wms/datatask")
public class BusinDataTaskController extends BaseController {


    @Autowired
    IBusinDataTaskService businDataTaskService;

    /**
     * 任务管理页面接口-查询
     */
    @GetMapping("/selectTaskManagement")
    @RepeatSubmit
   public TableDataInfo<BusinDataTaskManageVo> selectTaskManagement(BusinTaskManageQueryBo bo) {
        startPage();
        return getDataTable(businDataTaskService.selectTaskManagement(bo));
    }


    /**
     * 任务管理--取消任务
     * @param bo
     * @return
     */
    @PostMapping("/cancelTask")
    @RepeatSubmit
    public Result<Boolean> cancelTask(BusinTaskManageDistributeBo bo){
        return businDataTaskService.cancelTask(bo);
    }

    /**
     * 任务管理--重新下发
     * @param bo
     * @return
     */
    @PostMapping("/reissueTask")
    @RepeatSubmit
    public Result<Boolean> reissueTask(BusinTaskManageDistributeBo bo){
        return businDataTaskService.reissueTask(bo);
    }

    /**
     * 任务管理--立即下发
     * @param bo
     * @return
     */
    @PostMapping("/instantlyTask")
    @RepeatSubmit
    public Result<Boolean> instantlyTask(BusinTaskManageDistributeBo bo){
        return businDataTaskService.instantlyTask(bo);
    }

    /**
     * 任务管理--优先
     * @param bo
     * @return
     */
    @PostMapping("/elevatePriorityTask")
    @RepeatSubmit
    public Result<Boolean> elevatePriorityTask(BusinTaskManageDistributeBo bo){
        return businDataTaskService.elevatePriorityTask(bo);
    }

    /**
     * 任务管理--暂停
     * @param bo
     * @return
     */
    @PostMapping("/pauseTask")
    @RepeatSubmit
    public Result<Boolean> pauseTask(BusinTaskManageDistributeBo bo){
        return businDataTaskService.pauseTask(bo);
    }

    /**
     * 任务管理--启用
     * @param bo
     * @return
     */
    @PostMapping("/activeTask")
    @RepeatSubmit
    public Result<Boolean> activeTask(BusinTaskManageDistributeBo bo){
        return businDataTaskService.pauseTask(bo);
    }



    /**
     * 紧急出库到达接驳点时，物料明细
     * @return
     */
    @GetMapping("/getEmergencyOutboundDtl")
    @RepeatSubmit
    public Result<List<BusinDataTaskGoodsVo>> getEmergencyOutboundDtl(){
        return Result.ok().data(businDataTaskService.getEmergencyOutboundDtl());
    }

    /**
     * 紧急出库到达接驳点后，确认按钮
     * @return
     */
    @PostMapping("/confirmEmergencyOutboundDtl")
    @RepeatSubmit
    public Result<Boolean> confirmEmergencyOutboundDtl(@Valid @RequestBody EmergencyOutboundAddBo bo){
        return Result.ok().data(businDataTaskService.confirmEmergencyOutboundDtl(bo));
    }

    /**
     * 创建移库任务
     * @param bo
     * @return
     */
    @Log(title = "创建移库任务", businessType = BusinessType.INSERT)
    @PostMapping("/addMoveTask")
    public Result<Boolean> addMoveTask(@Valid @RequestBody BusinStockMoveDAddBo bo) {
        return businDataTaskService.addMoveTask(bo);
    }


}
