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


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

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

import java.util.List;

/**
 * <p>
 * 记录出入库信息 前端控制器
 * </p>
 *
 * @author Gongdc
 * @since 2021-05-21
 */
@RestController
@RequestMapping("/warehouseInOutInfo")
public class WarehouseInOutInfoController {
    @Autowired
    private IWarehouseInOutInfoService warehouseInOutInfoService;

    /**
     * 待完成页面分页列表查询
     * @param warehouseInOutInfo
     * @return
     */
    @GetMapping("/selectWarehouseInOutInfo")
    public Page<WarehouseInOutInfo> selectWarehouseInOutInfo(WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.selectWarehouseInOutInfo(warehouseInOutInfo);
    }

    /**
     * 待完成页面分页列表查询(临时仓库)
     * @param warehouseInOutInfo
     * @return
     */
    @GetMapping("/selectWarehouseInOutInfoTemporary")
    public Page<WarehouseInOutInfo> selectWarehouseInOutInfoTemporary(WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.selectWarehouseInOutInfoTemporary(warehouseInOutInfo);
    }

    /**
     * 删除记录
     * @param example
     */
    @PostMapping("/api/deleteWarehouse")
    public void deleteWarehouse(@RequestBody WarehouseInOutInfo example) {
        warehouseInOutInfoService.deleteWarehouse(example.getId());
    }

    /**
     * 出入库
     * @param warehouseInOutInfo
     * @return
     */
    @PostMapping("/InOutWarehouse")
    public String InOutWarehouse(@RequestBody WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.InOutWarehouse(warehouseInOutInfo);
    }

    /**
     * 退回
     * @param warehouseInOutInfo
     * @return
     */
    @PostMapping("/returnWarehouse")
    public String returnWarehouse(@RequestBody WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.returnWarehouse(warehouseInOutInfo);
    }

    /**
     * 流转记录查询
     * @param warehouseInOutInfo
     * @return
     */
    @GetMapping("/selectInfo")
    public Page<WarehouseInOutInfo> selectInfo(WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.selectInfo(warehouseInOutInfo);
    }

    /**
     * 关键字查询
     * @param warehouseInOutInfo
     * @return
     */
    @GetMapping("/selectInfoByKeyWord")
    public List<WarehouseInOutInfo> selectInfoByKeyWord(WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.selectInfoByKeyWord(warehouseInOutInfo);
    }

    /**
     * 流转记录查询(临时仓库)
     * @param warehouseInOutInfo
     * @return
     */
    @GetMapping("/selectInfoTemporary")
    public Page<WarehouseInOutInfo> selectInfoTemporary(WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.selectInfoTemporary(warehouseInOutInfo);
    }

    /**
     * 临时仓库货名下拉列表
     * @param baseId
     * @return
     */
    @GetMapping("/selectTemporaryGoodsNameList")
    public List<WarehouseInOutInfo> selectTemporaryGoodsNameList(String baseId) {
        return warehouseInOutInfoService.selectTemporaryGoodsNameList(baseId);
    }


    /**
     * 出入库任务新增 编辑
     * @param warehouseInOutInfo
     * @return
     */
    @PostMapping("/insertOrUpdateInOutTask")
    public String insertOrUpdateInOutTask(@RequestBody WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.insertOrUpdateInOutTask(warehouseInOutInfo);
    }

    /**
     * 调整
     * @param warehouseInOutInfo
     * @return
     */
    @PostMapping("/adjustment")
    public String adjustment(@RequestBody WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.adjustment(warehouseInOutInfo);
    }

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

    /**
     * 查看入库详情
     */
    @GetMapping("/getInfo")
    public WarehouseInOutInfo getInfo(@RequestParam String id) {
        return warehouseInOutInfoService.getInfo(id);
    }

    /**
     *查看已派车辆
     */
    @GetMapping("/selectDistributeCar")
    public List<WarehouseInOutInfo> selectDistributeCar(String contractNo){
        return warehouseInOutInfoService.selectDistributeCar(contractNo);
    }

    /**
     *查循公司id
     */
    @GetMapping("/selectCompId")
    public String selectCompId(String contractNo){
        return warehouseInOutInfoService.selectCompId(contractNo);
    }

    /**
     * 查看当天出/入数量
     * @param positionId,type
     * @return
     */
    @GetMapping("/count")
    public Integer count(@RequestParam String positionId,String inOutFlag) {
        return warehouseInOutInfoService.count(positionId,inOutFlag);
    }

    /**
     * 修改入库量
     * @param warehouseInOutInfo
     * @return
     */
    @PostMapping("/updateStockQuantity")
    public String updateStockQuantity(@RequestBody WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.updateStockQuantity(warehouseInOutInfo);
    }

    /**
     * 新出入库
     * @param warehouseInOutInfo
     * @return
     */
    @PostMapping("/api/newInOutWarehouse")
    public String newInOutWarehouse(@RequestBody WarehouseInOutInfo warehouseInOutInfo) {
        return warehouseInOutInfoService.newInOutWarehouse(warehouseInOutInfo);
    }
}

