package com.tofly.watermeter.custom.controller.meterBusiness;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.watermeter.custom.entity.meterBusiness.dto.WareHousingDto;
import com.tofly.watermeter.custom.entity.meterBusiness.dto.WareHousingEntity;
import com.tofly.watermeter.custom.service.meterBusiness.WareHousingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author 泡泡
 */
@RestController
@AllArgsConstructor
@Api(tags = "表务管理-水表入库改动接口")
@RequestMapping("/wareHousing")
public class WareHousingController {

    private final WareHousingService wareHousingService;


    @ApiOperation("第一层：统计各个厂家入库、库存总数")
    @GetMapping("/count")
    @ApiImplicitParam(name = "export", value = "0:不导出 1：导出", required = true, dataType = "long")
    public ResultRespone count(HttpServletResponse response, Page page, WareHousingDto dto) {
        return ResultRespone.success(wareHousingService.count(response, page, dto));
    }

    @GetMapping("/countByVendor")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "state", value = "0：入库 1：库存", required = true, dataType = "long"),
            @ApiImplicitParam(name = "vendor", value = "水表厂家", dataType = "long"),
            @ApiImplicitParam(name = "export", value = "0:不导出 1：导出", required = true, dataType = "long")
    })
    @ApiOperation("第二层：查询厂家下各个口径水表信息")
    public ResultRespone countByVendor(HttpServletResponse response, Page page, WareHousingDto dto) {
        return ResultRespone.success(wareHousingService.countByVendor(response, page, dto));
    }

    @PostMapping("/wareHousing")
    @ApiOperation("水表入库")
    @ApiImplicitParam(name = "dto", required = true, dataType = "string")
    public ResultRespone wareHousing(@RequestBody WareHousingEntity dto) {
        return ResultRespone.success(wareHousingService.wareHousing(dto));
    }

    @GetMapping("/countByCaliber")
    @ApiOperation("第三层：查看厂家下某个口径某个类型的水表详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "state", value = "0：入库 1：库存", required = true, dataType = "long"),
            @ApiImplicitParam(name = "vendor", value = "水表厂家", required = true, dataType = "long"),
            @ApiImplicitParam(name = "type", value = "水表类型", required = true, dataType = "long"),
            @ApiImplicitParam(name = "caliber", value = "水表口径", required = true, dataType = "long"),
            @ApiImplicitParam(name = "export", value = "0:不导出 1：导出", required = true, dataType = "long")
    })
    public ResultRespone countByCaliber(HttpServletResponse response, Page page, WareHousingDto dto) {
        return ResultRespone.success(wareHousingService.countByCaliber(response, page, dto));
    }

    @DeleteMapping("/deleteTable")
    @ApiImplicitParam(name = "ids", value = "id 多个‘,’分割", required = true, dataType = "string")
    @ApiOperation("入库水表删除")
    public ResultRespone deleteTable(String ids) {
        return ResultRespone.success(wareHousingService.deleteTable(ids));
    }

    @GetMapping("/getAllInfo")
    @ApiOperation("全部库存信息查询")
    public ResultRespone getAllInfo(Page page, WareHousingDto dto) {
        return ResultRespone.success(wareHousingService.getAllInfo(page, dto));
    }

    @GetMapping("/countBatchNo")
    @ApiOperation("批次统计")
    public ResultRespone countBatchNo(HttpServletResponse response,Page page, WareHousingDto dto) {
        return ResultRespone.success(wareHousingService.countBatchNo(response,page, dto));
    }

    @GetMapping("/batchNoInfo")
    @ApiOperation("批次详情")
    public ResultRespone batchNoInfo(HttpServletResponse response, Page page, WareHousingDto dto) {
        return ResultRespone.success(wareHousingService.batchNoInfo(response, page, dto));
    }

}
