package com.muchinfo.mtp3century.controller;

import com.muchinfo.mtp3century.service.IWarehouseService;
import com.muchinfo.mtp3century.utils.AjaxResult;
import com.muchinfo.mtp3common.vo.PageResult;
import com.muchinfo.mtp3pojos.entity.Dgfactoryitemtype;
import com.muchinfo.mtp3pojos.vo.LineTreeNode;
import com.muchinfo.mtp3pojos.vo.warehouse.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/warehouse")
@Api(value = "仓储仓单api", description = "仓储仓单管理")
public class WarehouseController {

    @Resource
    private IWarehouseService iWarehouseService;

    @RequestMapping(method = RequestMethod.GET, value = "/query")
    @ApiOperation("仓储仓单管理--> 仓单注册注销查询 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<WarehouseQueryResult> query(WarehouseQueryParam param, HttpServletRequest request) {
        return iWarehouseService.query(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryDetail")
    @ApiOperation("仓储仓单管理--> 仓单注册注销查询 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<WarehouseDetailResult> queryDetail(String applyid, HttpServletRequest request) {
        return iWarehouseService.queryDetail(applyid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/warehouseTree")
    @ApiOperation("仓储仓单管理--> 仓单注册申请、现货品种设置 --> 初始化商品信息")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<LineTreeNode> warehouseTree(Long categoryid, HttpServletRequest request) {
        return iWarehouseService.warehouseTree(categoryid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/querydgfactory")
    @ApiOperation("仓储仓单管理--> 仓单注册申请 --> 根据商品获取信息")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<Dgfactoryitemtype> querydgfactory(Long wrstandardid, HttpServletRequest request) {
        return iWarehouseService.querydgfactory(wrstandardid, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/wrInApply")
    @ApiOperation("仓储仓单管理--> 仓单注册申请 --> 新增")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult wrInApply(@RequestBody WarehouseInAddParam param, HttpServletRequest request) {
        return iWarehouseService.wrInApply(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryUserList")
    @ApiOperation("仓储仓单管理--> 仓单注销申请 --> 获取申请人列表")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult queryUserList(HttpServletRequest request) {
        return iWarehouseService.queryUserList(request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/querywslist")
    @ApiOperation("仓储仓单管理--> 仓单注销申请 --> 获取商品名称")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult querywslist(Long userid, HttpServletRequest request) {
        return iWarehouseService.querywslist(userid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/querywhlist")
    @ApiOperation("仓储仓单管理--> 仓单注销申请 --> 获取仓库地址")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult querywhlist(Long userid, Long wrstandardid, HttpServletRequest request) {
        return iWarehouseService.querywhlist(userid, wrstandardid, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/queryWRHoldLB")
    @ApiOperation("仓储仓单管理--> 仓单注销申请 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<WrHoldLBResult> queryWRHoldLB(WrHoldLBParam param, HttpServletRequest request) {
        return iWarehouseService.queryWRHoldLB(param, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/wrOutApply")
    @ApiOperation("仓储仓单管理--> 仓单注销申请 --> 新增")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult wrOutApply(@RequestBody WarehouseOutAddParam param, HttpServletRequest request) {
        return iWarehouseService.wrOutApply(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/receiptquery")
    @ApiOperation("仓储仓单管理--> 交收仓库管理 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<WarehouseReceiptResult> receiptquery(WarehouseReceiptParam param, HttpServletRequest request) {
        return iWarehouseService.receiptquery(param, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/receiptadd")
    @ApiOperation("仓储仓单管理--> 交收仓库管理 --> 新增、修改")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public AjaxResult receiptadd(@RequestBody WarehouseReceiptAddParam param, HttpServletRequest request) {
        return iWarehouseService.dealreceipt(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/receiptDetail")
    @ApiOperation("仓储仓单管理--> 交收仓库管理 --> 详情")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult<WarehouseReceiptDetailResult> receiptDetail(Long warehouseid,Integer isaudit, HttpServletRequest request) {
        return iWarehouseService.receiptDetail(warehouseid,isaudit, request);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/receiptaudit")
    @ApiOperation("仓储仓单管理--> 交收仓库管理 --> 审核")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult receiptaudit(@RequestBody WarehouseReceiptAuditParam param, HttpServletRequest request) {
        return iWarehouseService.receiptaudit(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/receiptlogff")
    @ApiOperation("仓储仓单管理--> 交收仓库管理 --> 注销")
    @ApiResponse(code = 200, message = "成功", response = AjaxResult.class)
    public AjaxResult receiptlogff(Long autoid, HttpServletRequest request) {
        return iWarehouseService.receiptlogff(autoid, request);
    }
    @RequestMapping(method = RequestMethod.GET, value = "/varietquery")
    @ApiOperation("仓储仓单管理--> 现货品种设置 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public PageResult<WarehouseVarietyResult> varietquery(WarehouseVarietyParam param, HttpServletRequest request) {
        return iWarehouseService.varietquery(param, request);
    }

    @RequestMapping(method = RequestMethod.GET, value = "/varietdetail")
    @ApiOperation("仓储仓单管理--> 现货品种设置 --> 获取列表")
    @ApiResponse(code = 200, message = "成功", response = PageResult.class)
    public AjaxResult<WarehouseVarietyDetailResult> varietdetail(Long wrstandardid, HttpServletRequest request) {
        return iWarehouseService.varietdetail(wrstandardid, request);
    }

}
