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



import com.baomidou.mybatisplus.plugins.Page;
import com.yh.saas.plugin.yiliangyiyun.entity.ContractManagementInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseBaseInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseInOutInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.view.WarehouseNumView;
import com.yh.saas.plugin.yiliangyiyun.entity.view.WarehouseView;
import com.yh.saas.plugin.yiliangyiyun.service.IWarehouseBaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 记录仓库信息 前端控制器
 * </p>
 *
 * @author Gongdc
 * @since 2021-05-21
 */
@RestController
@RequestMapping("/warehouseBaseInfo")
public class WarehouseBaseInfoController {

    @Autowired
    private IWarehouseBaseInfoService warehouseBaseInfoService;
    /**
     * 添加仓库
     */
    @PostMapping("/api/addWarehouse")
    public String addWarehouse(@RequestBody WarehouseBaseInfo warehouseBaseInfo) {
        return warehouseBaseInfoService.addWarehouse(warehouseBaseInfo);
    }

    /**
     * 添加临时仓库
     * @param warehouseBaseInfo
     * @return
     */
    @PostMapping("/api/addTemporaryWarehouse")
    public String addTemporaryWarehouse(@RequestBody WarehouseBaseInfo warehouseBaseInfo){
        return warehouseBaseInfoService.addTemporaryWarehouse(warehouseBaseInfo);
    }
    /**
     * 编辑仓库
     */
    @PostMapping("/api/editWarehouse")
    public String editWarehouse(@RequestBody WarehouseBaseInfo warehouseBaseInfo) {
        return warehouseBaseInfoService.editWarehouse(warehouseBaseInfo);
    }
    /**
     * 查看库房下拉列表
     */
    @GetMapping("/selectWarehouse")
    public List<WarehouseBaseInfo> selectWarehouse(@RequestParam String compId,String warehouseType){
        return warehouseBaseInfoService.selectWarehouse(compId,warehouseType);
    }
    /**
     * 查看自己负责的常用仓库
     * 公司ID,手机号
     */
    @GetMapping("/selectWarehouseSelf")
    public List<WarehouseBaseInfo> selectWarehouseSelf(@RequestParam String compId,String personCharge){
        return warehouseBaseInfoService.selectWarehouseSelf(compId,personCharge);
    }
    /**
     * 查看自己负责的常用仓库
     * 公司ID,手机号
     */
    @GetMapping("/selectWarehouseSelfApp")
    public List<WarehouseBaseInfo> selectWarehouseSelfApp(@RequestParam String compId,String personCharge){
        return warehouseBaseInfoService.selectWarehouseSelfApp(compId,personCharge);
    }
    /**
     * 查看库房
     */
    @GetMapping("/getWarehouse")
    public WarehouseBaseInfo getWarehouse(String id){
        return warehouseBaseInfoService.getWarehouse(id);
    }

    /**
     * @description 仓库管理页面列表
     *
     * @param compId
     * @return
     */
    @GetMapping("/selectWarehouseViewinfo")
    public WarehouseBaseInfo selectWarehouseViewinfo(String compId,String warehouseName,String warehouseType){
        return warehouseBaseInfoService.selectWarehouseViewinfo(compId,warehouseName,warehouseType);
    }

    /**
     * 今日储量明细
     *
     * @param compId
     * @return
     */
    @GetMapping("/reservesDetails")
    public List<WarehouseNumView> reservesDetails(String compId){
        return warehouseBaseInfoService.reservesDetails(compId);
    }

    /**
     * 全部仓库
     *
     * @param compId
     * @return
     */
    @GetMapping("/allWarehouse")
    public List<WarehouseView> allWarehouse(String compId,String warehouseName,String goodsName){
        return warehouseBaseInfoService.allWarehouse(compId,warehouseName,goodsName);
    }

    /**
     * 更改显示状态
     */
    @PostMapping("/api/editShow")
    public String editShow(@RequestBody WarehouseBaseInfo warehouseBaseInfo){
        return warehouseBaseInfoService.editShow(warehouseBaseInfo.getId());
    }

    /**
     * 查询所有库房
     * @param compId,warehouseType
     * @return
     */
    @GetMapping("/selectAllWarehouse")
    public List<WarehouseBaseInfo> selectAllWarehouse(String compId,String warehouseType,String warehouseName){
        return warehouseBaseInfoService.selectAllWarehouse(compId,warehouseType,warehouseName);
    }

    /**
     * 删除库房
     * @param warehouseBaseInfo
     */
    @PostMapping("/api/deleteWarehouse")
    public void deleteWarehouse(@RequestBody WarehouseBaseInfo warehouseBaseInfo){
        warehouseBaseInfoService.deleteWarehouse(warehouseBaseInfo.getId());
    }

    /**
     * 清仓状态
     * @param warehouseBaseInfo
     * @return
     */
    @PostMapping("/api/editCleared")
    public String editCleared(@RequestBody WarehouseBaseInfo warehouseBaseInfo){
        return warehouseBaseInfoService.editCleared(warehouseBaseInfo.getId());
    }
    /**
     * 出入库合同编号下拉列表
     * @param compId
     * @return
     */
    @GetMapping("/selectContractNoList")
    public List<ContractManagementInfo> selectContractNoList(String compId,Integer flag) {
        return warehouseBaseInfoService.selectContractNoList(compId,flag);
    }
    /**
     * 获取检斤打印接口
     * @param id
     * @return
     */
    @GetMapping("/getPrintInfo")
    public WarehouseInOutInfo getPrintInfo(String id) {
        return warehouseBaseInfoService.getPrintInfo(id);
    }
    /**
     * 查出库时的成本
     * @param contractNo,carNo
     * @return
     */
    @GetMapping("/selectCost")
    public Float selectCost(String contractNo,String carNo) {
        return warehouseBaseInfoService.selectCost(contractNo,carNo);
    }
    /**
     * 查看自己负责的常用仓库
     * 公司ID,手机号
     */
    @GetMapping("/selectResponsible")
    public List<WarehouseBaseInfo> selectResponsible(@RequestParam String compId,String personCharge){
        return warehouseBaseInfoService.selectResponsible(compId,personCharge);
    }
    /**
     * 导出入库
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/export")
    public void export(@RequestBody WarehouseBaseInfo example, HttpServletResponse response) throws Exception {
        warehouseBaseInfoService.export(example,response);
    }
    /**
     * 导出出库
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/exportOut")
    public void exportOut(@RequestBody WarehouseBaseInfo example, HttpServletResponse response) throws Exception {
        warehouseBaseInfoService.exportOut(example,response);
    }


    /**
     * 导出入库
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/exportphone")
    public String exportphone(@RequestBody WarehouseBaseInfo example, HttpServletResponse response) throws Exception {
        return warehouseBaseInfoService.exportphone(example,response);
    }
    /**
     * 导出出库
     *
     * @return
     * @throws Exception
     */
    @PostMapping("/exportPhoneOut")
    public String exportPhoneOut(@RequestBody WarehouseBaseInfo example, HttpServletResponse response) throws Exception {
        return warehouseBaseInfoService.exportPhoneOut(example,response);
    }

    /**
     * 库点利润详情列表查询
     *
     * @param warehouseBaseInfo
     * @return
     */
    @GetMapping("/selectBaseInfo")
    public Page<WarehouseBaseInfo> selectBaseInfo(WarehouseBaseInfo warehouseBaseInfo) {
        return warehouseBaseInfoService.selectBaseInfo(warehouseBaseInfo);
    }
    /**
     * 库点利润图表
     */
    @GetMapping("/selectWarehouseChart")
    public WarehouseBaseInfo selectWarehouseChart(WarehouseBaseInfo warehouseBaseInfo) {
        return warehouseBaseInfoService.selectWarehouseChart(warehouseBaseInfo);
    }
}

