package com.tofly.xrtygis.custom.controller.dma;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.xrtygis.custom.service.dma.AreaSubTableService;
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;

/**
 * @author 20126
 */
@RestController
@AllArgsConstructor
@RequestMapping("/AreaSubTable")
@Api(tags = "分区计量--区域分表")
public class AreaSubTableController {

    private final AreaSubTableService areaSubTableService;

    @GetMapping("/getArea")
    @ApiOperation("获取抄表片区")
    public ResultRespone getArea() {
        return ResultRespone.success(areaSubTableService.getArea());
    }

    @GetMapping("/getCopybook")
    @ApiOperation("获取抄表本")
    @ApiImplicitParam(name = "cbpq", value = "抄表片区编码", required = true, dataType = "string")
    public ResultRespone getCopybook(String cbpq) {
        return ResultRespone.success(areaSubTableService.getCopybook(cbpq));
    }

    @GetMapping("/getSubTable")
    @ApiOperation("查询用户水表档案")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cbb", value = "抄表本编码", dataType = "string"),
            @ApiImplicitParam(name = "dto", value = "模糊查询条件", dataType = "string")
    })
    public ResultRespone getSubTable(Page page, String cbb, String dto) {
        return ResultRespone.success(areaSubTableService.getSubTable(page, cbb, dto));
    }

    @GetMapping("/exportSubTable")
    @ApiOperation("用户水表档案导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cbb", value = "抄表本编码", dataType = "string"),
            @ApiImplicitParam(name = "dto", value = "模糊查询条件", dataType = "string")
    })
    public void exportSubTable(HttpServletResponse response, String cbb, String dto) {
        areaSubTableService.exportSubTable(response, cbb, dto);
    }

    @GetMapping("/getUseWater")
    @ApiOperation("获取用户用水量")
    public ResultRespone getUseWater(Page page, String khbh, String start, String end) {
        return ResultRespone.success(areaSubTableService.getUseWater(page, khbh, start, end));
    }

}
