package com.yh.saas.plugin.yiliangyiyun.controller;



import com.yh.saas.plugin.yiliangyiyun.entity.InOutWarehouseTask;
import com.yh.saas.plugin.yiliangyiyun.service.IInOutWarehouseTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * <p>
 * 出入库任务 前端控制器
 * </p>
 *
 * @author Gongdc
 * @since 2021-06-22
 */
@RestController
@RequestMapping("/inOutWarehouseTask")
public class InOutWarehouseTaskController {
    @Autowired
    private IInOutWarehouseTaskService inOutWarehouseTaskService;
    /**
     * 出入库任务新增 编辑
     *
     * @param inOutWarehouseTask
     * @return
     */
    @PostMapping("/api/insertOrUpdateInOutTask")
    public String insertOrUpdateInOutTask(@RequestBody InOutWarehouseTask inOutWarehouseTask) {
        return inOutWarehouseTaskService.insertOrUpdateInOutTask(inOutWarehouseTask);
    }

    /**
     * 判断移库编号
     *
     * @param moveTaskNo
     * @return
     */
    @GetMapping("/selectTaskNo")
    public boolean selectTaskNo(String moveTaskNo) {
        return inOutWarehouseTaskService.selectTaskNo(moveTaskNo);
    }

    /**
     * 出入库任务列表
     * @param inOutWarehouseTask
     * @return
     */
    @GetMapping("/selectInOutWarehouseTask")
    public Page<InOutWarehouseTask> selectInOutWarehouseTask(InOutWarehouseTask inOutWarehouseTask) {
        return inOutWarehouseTaskService.selectInOutWarehouseTask(inOutWarehouseTask);
    }

    /**
     * 查看出入库任务
     * @param relevanceId
     * @return
     */
    @GetMapping("/getInOutWarehouseTask")
    public List<InOutWarehouseTask> getInOutWarehouseTask(String relevanceId){
        return inOutWarehouseTaskService.getInOutWarehouseTask(relevanceId);
    }

    /**
     * 删除出入库任务
     * @param inOutWarehouseTask
     */
    @PostMapping("/api/deleteInOutWarehouseTask")
    public void deleteInOutWarehouseTask(@RequestBody InOutWarehouseTask inOutWarehouseTask){
        inOutWarehouseTaskService.deleteInOutWarehouseTask(inOutWarehouseTask.getId(),inOutWarehouseTask.getRelevanceId());
    }

    /**
     * 更改状态
     * @param inOutWarehouseTask
     * @return
     */
    @PostMapping("/api/editStatus")
    public String editStatus(@RequestBody InOutWarehouseTask inOutWarehouseTask){
        return inOutWarehouseTaskService.editStatus(inOutWarehouseTask.getId());
    }

    /**
     * 移库任务列表
     * @param inOutWarehouseTask
     * @return
     */
    @GetMapping("/selectInOutWarehouseTaskRelocation")
    public Page<InOutWarehouseTask> selectInOutWarehouseTaskRelocation(InOutWarehouseTask inOutWarehouseTask) {
        return inOutWarehouseTaskService.selectInOutWarehouseTaskRelocation(inOutWarehouseTask);
    }

    /**
     * 查看移库任务详情
     * @param moveTaskNo
     * @return
     */
    @GetMapping("/getInOutWarehouseTaskRelocation")
    public List<InOutWarehouseTask> getInOutWarehouseTaskRelocation(String moveTaskNo){
        return inOutWarehouseTaskService.getInOutWarehouseTaskRelocation(moveTaskNo);
    }

    /**
     * 出入库任务审核 编辑
     *
     * @param inOutWarehouseTask
     * @return
     */
    @PostMapping("/api/checkOrUpdateInOutTask")
    public String checkOrUpdateInOutTask(@RequestBody InOutWarehouseTask inOutWarehouseTask) {
        return inOutWarehouseTaskService.checkOrUpdateInOutTask(inOutWarehouseTask);
    }
    /**
     * 查看
     */
    @GetMapping("/getTask")
    public InOutWarehouseTask getTask(@RequestParam String id) {
        return inOutWarehouseTaskService.getTask(id);
    }
    /**
     * 任务列表
     * @param inOutWarehouseTask
     * @return
     */
    @GetMapping("/selectWarehouseTask")
    public Page<InOutWarehouseTask> selectWarehouseTask(InOutWarehouseTask inOutWarehouseTask) {
        return inOutWarehouseTaskService.selectWarehouseTask(inOutWarehouseTask);
    }
    /**
     * 出入库任务列表
     * @param inOutWarehouseTask
     * @return
     */
    @GetMapping("/selectInOutWarehouseNo")
    public List<InOutWarehouseTask> selectInOutWarehouseNo(InOutWarehouseTask inOutWarehouseTask) {
        return inOutWarehouseTaskService.selectInOutWarehouseNo(inOutWarehouseTask);
    }

    /**
     *
     * @param compId,warehouseName
     * @return
     */
    @GetMapping("/getContractNo")
    public InOutWarehouseTask getContractNo(String compId, String warehouseName) {
        return inOutWarehouseTaskService.getContractNo(compId,warehouseName);
    }

}

