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.ReturnTableDto;
import com.tofly.watermeter.custom.service.meterBusiness.ReturnTableService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "表务管理-退表管理")
@AllArgsConstructor
@RequestMapping("/returnTable")
public class ReturnTableController {

    private final ReturnTableService returnTableService;

    @GetMapping("/countReturnTable")
    @ApiOperation("退表统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dept", value = "部门id", dataType = "List"),
            @ApiImplicitParam(name = "export", value = "0 不导出 1 导出", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "start",value = "开始月份 yyyy-MM-dd",required = true,dataType = "string"),
            @ApiImplicitParam(name = "end",value = "结束月份 yyyy-MM-dd",required = true,dataType = "string")
    })
    public ResultRespone countReturnTable(HttpServletResponse response,ReturnTableDto dto){
        return ResultRespone.success(returnTableService.countReturnTable(response, dto));
    }

    @GetMapping("/countByVendor")
    @ApiOperation("退表汇总")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "vendor", value = "厂家", dataType = "List<Long>"),
            @ApiImplicitParam(name = "export", value = "0 不导出 1 导出", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "start",value = "开始月份 yyyy-MM-dd",required = true,dataType = "string"),
            @ApiImplicitParam(name = "end",value = "结束月份 yyyy-MM-dd",required = true,dataType = "string")
    })
    public ResultRespone countByVendor(HttpServletResponse response, ReturnTableDto dto) {
        return ResultRespone.success(returnTableService.countByVendor(response, dto));
    }

    @GetMapping("/queryInfoReturnTable")
    @ApiOperation("退表详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "vendor", value = "厂家", dataType = "List<Long>"),
            @ApiImplicitParam(name = "export", value = "0 不导出 1 导出", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "start",value = "开始月份 yyyy-MM-dd",required = true,dataType = "string"),
            @ApiImplicitParam(name = "end",value = "结束月份 yyyy-MM-dd",required = true,dataType = "string"),
            @ApiImplicitParam(name = "cal",value = "口径",dataType = "List<Long>")
    })
    public ResultRespone queryInfoReturnTable(HttpServletResponse response, Page page, ReturnTableDto dto){
        return ResultRespone.success(returnTableService.queryInfoReturnTable(response, page, dto));
    }

}
