package com.prolog.cs.biz.outbound.controller;

import com.prolog.cs.biz.outbound.model.ContainerBindTaskVO;
import com.prolog.cs.biz.outbound.model.dto.WorkStageTransferDTO;
import com.prolog.cs.biz.outbound.model.vo.WorkStageVO;
import com.prolog.cs.biz.outbound.service.ContainerBindTaskService;
import com.prolog.cs.biz.outbound.service.WavesService;
import com.prolog.cs.biz.outbound.service.WorkStageService;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.exception.BizException;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.framework.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "托盘转运")
@RestController
@RequestMapping("/containerBindTask")
public class ContainerBindTaskController {

    @Autowired
    private ContainerBindTaskService containerBindTaskService;

    @UserLog
    @ApiOperation(value = "RF托盘绑定任务确认")
    @PostMapping("/taskConfirm")
    public RestMessage<Object> taskConfirm(@RequestBody ContainerBindTaskVO containerBindTaskVO) {
        if(StringUtils.isEmpty(containerBindTaskVO.getTargetFloor())||StringUtils.isEmpty(containerBindTaskVO.getContainerNo())||StringUtils.isEmpty(containerBindTaskVO.getSourceFloor())){
            throw new BizException("托盘号/楼层不能为空！");
        }
        if(StringUtils.isEmpty(containerBindTaskVO.getWarehouseId())){
            throw new BizException("仓库不能为空！");
        }
        return RestMessage.success("操作成功", containerBindTaskService.taskConfirm(containerBindTaskVO));
    }

    @UserLog
    @ApiOperation(value = "RF托盘绑定任务查询")
    @PostMapping("/queryList")
    public RestMessage<List<ContainerBindTaskVO>> queryList(@RequestBody ContainerBindTaskVO containerBindTaskVO) {
        return RestMessage.success("操作成功", containerBindTaskService.queryList(containerBindTaskVO));
    }

    @UserLog
    @ApiOperation(value = "根据任务ID更新任务状态")
    @PostMapping("/updateTaskStatus")
    public RestMessage<?> updateTaskStatus(@RequestBody List<String> taskIds) {
        return RestMessage.success("操作成功", containerBindTaskService.updateTaskStatus(taskIds));
    }

}
