package com.unis.crk.common.controller;

import com.unis.crk.common.service.IBillnonewService;
import com.unis.crk.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 单据序号生成表前端控制器
 * </p>
 *
 * @author TangSong
 * @since 2021-10-27
 */
@Api(value = "单据序号生成表",tags = {"单据序号生成表"})
@RestController
@RequestMapping("billnonew")
@CrossOrigin
public class BillnonewController {

    private final static Logger LOGGER = LoggerFactory.getLogger(BillnonewController.class);


    @Autowired
    private IBillnonewService billnonewService;


    /**
     * 得到生产批号
     * @param unitId 单位id
     * @param spbh 商品编号
     * @param scrq 商品生产日期
     * @return
     */
    @ApiOperation(value="查询", notes="得到生产批号")
    @GetMapping("getScpc/{unitId}/{spbh}/{scrq}")
    public ResultUtil getScpc(@PathVariable("unitId") String unitId,@PathVariable("spbh") String spbh,@PathVariable("scrq") String scrq){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getScpc(unitId,spbh,scrq));
        return data;
    }


    /**
     *
     * @param unitId  单位id
     * @param spbh   商品编号
     * @param scrq   生产日期
     * @param scpc  生产批次
     * @return
     */
    @ApiOperation(value="根据已有商品得到生产批号", notes="得到生产批号")
    @GetMapping("getScpcbySp/{unitId}/{spbh}/{scpc}/{scrq}")
    public ResultUtil getScpcbySp(@PathVariable("unitId") String unitId,@PathVariable("spbh") String spbh,@RequestParam(value="scrq",required = false) String scrq,@PathVariable("scpc") String scpc){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getScpcbySp(unitId,spbh,scrq,scpc));
        return data;
    }
    /**
     * 得到生产批号
     * @param unitId 单位id
     * @param spbh 商品编号
     * @param scrq 商品生产日期
     * @param scrq 供应商Id
     * @return
     */
    @ApiOperation(value="查询", notes="得到生产批号")
    @GetMapping("getScpc/{unitId}/{spbh}/{scrq}/{gysId}")
    public ResultUtil getScpc(@PathVariable("unitId") String unitId,@PathVariable("spbh") String spbh,@PathVariable("scrq") String scrq,@PathVariable("gysId") String gysId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getScpc(unitId,spbh,scrq,gysId));
        return data;
    }
    /**
     * 得到分拣单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到得到分拣单号")
    @GetMapping("getFjDh/{unitId}")
    public ResultUtil getFjDh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getFjDh(unitId));
        return data;
    }
    /**
     * 得到库存变动单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到库存变动单号")
    @GetMapping("getKcbdDh/{unitId}")
    public ResultUtil getKcbdDh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getKcbdDh(unitId));
        return data;
    }
    /**
     * 得到标签单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到标签单号")
    @GetMapping("getBqDh/{unitId}")
    public ResultUtil getBqDh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getBqDh(unitId));
        return data;
    }
    /**
     * 得到领用单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到领用单号")
    @GetMapping("getLyDh/{unitId}")
    public ResultUtil getLyDh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getLyDh(unitId));
        return data;
    }
    /**
     * 得到期初库存单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到期初库存单号")
    @GetMapping("getCplQckcDh/{unitId}")
    public ResultUtil getCplQckcDh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getCplQckcDh(unitId));
        return data;
    }
    /**
     * 得到汽车入库入门单据号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到汽车入门单据号")
    @GetMapping("getQcrkBizNo/{unitId}")
    public ResultUtil getQcrkBizNo(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getQcrkBizNo(unitId));
        return data;
    }
    /**
     * 得到汽车入库扦样单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到汽车入库扦样单号")
    @GetMapping("getQcrkQydh/{unitId}")
    public ResultUtil getQcrkQydh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getQcrkQydh(unitId));
        return data;
    }
    /**
     * 得到汽车入库检斤单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到汽车入库检斤单号")
    @GetMapping("getQcrkJjdh/{unitId}")
    public ResultUtil getQcrkJjdh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getQcrkJjdh(unitId));
        return data;
    }
    /**
     * 得到汽车入库检验单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到汽车入库检验单号")
    @GetMapping("getQcrkJydh/{unitId}")
    public ResultUtil getQcrkJydh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getQcrkJydh(unitId));
        return data;
    }
    /**
     * 得到成品粮检验单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到成品粮检验单号")
    @GetMapping("getCplJydh/{unitId}")
    public ResultUtil getCplJydh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getCplJydh(unitId));
        return data;
    }
    /**
     * 得到汽车入库结算单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到汽车入库结算单号")
    @GetMapping("getQcrkJsdh/{unitId}")
    public ResultUtil getQcrkJsdh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getQcrkJsdh(unitId));
        return data;
    }


    /**
     * 得到汽车出库入门单据号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到汽车出库入门单据号")
    @GetMapping("getQcckBizNo/{unitId}")
    public ResultUtil getQcckBizNo(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getQcckBizNo(unitId));
        return data;
    }
    /**
     * 得到汽车出库检斤单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到汽车出库检斤单号")
    @GetMapping("getQcckJjdh/{unitId}")
    public ResultUtil getQcckJjdh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getQcckJjdh(unitId));
        return data;
    }
    /**
     * 得到成品粮入库单据号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到成品粮入库单据号")
    @GetMapping("getCplrkBizNo/{unitId}")
    public ResultUtil getCplrkBizNo(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getCplrkBizNo(unitId));
        return data;
    }
    /**
     * 得到成品粮入库单据号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="根据unitId得到成品粮出库单据号")
    @GetMapping("getCplckBizNo/{unitId}")
    public ResultUtil getCplckBizNo(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getCplckBizNo(unitId));
        return data;
    }
    @ApiOperation(value="根据unitId得到成品粮结算单据号", notes="根据unitId得到成品粮结算单据号")
    @GetMapping("getCpljsBizNo/{unitId}")
    public ResultUtil getCpljsBizNo(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getCpljsBizNo(unitId));
        return data;
    }
    /**
     * 得到原粮通知单编号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="得到原粮通知单编号")
    @GetMapping("getTzdh/{unitId}/{zylx}")
    public ResultUtil getTzdh(@PathVariable("unitId") String unitId,@PathVariable("zylx") Integer zylx){
        LOGGER.info("入参为:{}",unitId,zylx);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId) ){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getTzdh(unitId,zylx));
        return data;
    }
    /**
     * 得到成品粮通知单编号
     * @param unitId
     * @return
     */
    @ApiOperation(value="查询", notes="得到成品粮通知单编号")
    @GetMapping("getCplTzdh/{unitId}/{zylx}")
    public ResultUtil getCplTzdh(@PathVariable("unitId") String unitId,@PathVariable("zylx") Integer zylx){
        LOGGER.info("入参为:{}",unitId,zylx);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId) ){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getCplTzdh(unitId,zylx));
        return data;
    }

    /**
     * 得到商品拆分单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="商品拆分单号", notes="根据unitId得到商品拆分单号")
    @GetMapping("getCfdh/{unitId}")
    public ResultUtil getCfdh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getCfdh(unitId));
        return data;
    }

    /**
     * 得到商品拆分单号
     * @param unitId
     * @return
     */
    @ApiOperation(value="库存调整", notes="根据unitId得库存调整")
    @GetMapping("getcplkctzdh/{unitId}")
    public ResultUtil getcplkctzdh(@PathVariable("unitId") String unitId){
        LOGGER.info("入参为:{}",unitId);
        ResultUtil data = new ResultUtil();
        if (StringUtils.isEmpty(unitId)){
            data.failed("传入的单位id为空");
            return data;
        }
        data.success(this.billnonewService.getcplkctzdh(unitId));
        return data;
    }
}

