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.OutBoundDto;
import com.tofly.watermeter.custom.entity.meterBusiness.dto.OutBoundInfo;
import com.tofly.watermeter.custom.service.meterBusiness.OutBoundService;
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;

@RestController
@Api(tags = "表务管理-水表出库改动接口")
@AllArgsConstructor
@RequestMapping("/outBound")
public class OutBoundController {

    private final OutBoundService outBoundService;

    @GetMapping("/count")
    @ApiOperation("出库工单统计")
    public ResultRespone count(HttpServletResponse response, Page page, OutBoundDto dto) {
        return ResultRespone.success(outBoundService.count(response, page, dto));
    }

    @PostMapping("/tableOutBound")
    @ApiOperation("水表出库")
    public ResultRespone tableOutBound(@RequestBody OutBoundInfo dto) {
        return ResultRespone.success(outBoundService.tableOutBound(dto));
    }

    @GetMapping("/countByWorkOrder")
    @ApiOperation("工单-水表信息统计")
    public ResultRespone countByWorkOrder(HttpServletResponse response, Page page, OutBoundDto dto) {
        return ResultRespone.success(outBoundService.countByWorkOrder(response, page, dto));
    }

    @GetMapping("/queryTableInfo")
    @ApiOperation("工单出库水表详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "export", value = "0不导出 1导出", required = true, dataType = "long"),
            @ApiImplicitParam(name = "code", value = "工单编号", dataType = "string"),
    })
    public ResultRespone queryTableInfo(HttpServletResponse response, Page page, OutBoundDto dto) {
        return ResultRespone.success(outBoundService.queryTableInfo(response, page, dto));
    }

    @GetMapping("/getWareHousinginfo")
    @ApiOperation("查看已入库水表")
    public ResultRespone getWareHousinginfo(Page page, OutBoundDto dto) {
        return ResultRespone.success(outBoundService.getWareHousinginfo(page, dto));
    }

    @GetMapping("/getCkCount")
    @ApiOperation("出库工单汇总统计")
    public ResultRespone getCkCount(String code) {
        return ResultRespone.success(outBoundService.getCkCount(code));
    }

    @PostMapping("/abnormalTables")
    @ApiOperation("查询异常水表")
    public ResultRespone abnormalTables(String code){
        return ResultRespone.success(outBoundService.abnormalTables(code));
    }

    @GetMapping("/getContractInfo")
    @ApiOperation("出库合同及编号信息")
    public ResultRespone getContractInfo(){
        return ResultRespone.success(outBoundService.getContractInfo());
    }

}
