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

import com.tofly.common.core.entity.ResultRespone;
import com.tofly.xrtygis.custom.entity.dma.CostomWaterDiff;

import com.tofly.xrtygis.service.DmamonthflowService;
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;
import java.util.List;
import java.util.Map;

/**
 * @author FlashWJL
 * @date 2021/5/24 17:53
 */
@RestController
@AllArgsConstructor
@RequestMapping("/produceDiff")
@Api(tags = "分区计量--产销差分析")
public class CostomPodDiffController {

    private final DmamonthflowService dmamonthflowService;

    @GetMapping("/waterDiff")
    @ApiOperation(value = "根据DMA分区ID，时间段获取水量差（汇总、详情）情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dmaId", value = "dma分区ID", readOnly = true, dataType = "long"),
            @ApiImplicitParam(name = "startTime", value = "起始月份；如：2021-05", readOnly = true, dataType = "string"),
            @ApiImplicitParam(name = "endTime", value = "结束月份；如：2021-06", readOnly = true, dataType = "string"),
            @ApiImplicitParam(name = "flag", value = "查询标识；1：查询汇总正常数/异常；2：查询产销差的详情", readOnly = true, dataType = "string"),
    })
    public ResultRespone getWaterDiffByDma(HttpServletResponse response, CostomWaterDiff diff) {
        Long dmaId = diff.getDmaId();
        String startTime = diff.getStartTime();
        String endTime = diff.getEndTime();
        String flag = diff.getFlag();
        String templateFlag = diff.getTemplateFlag();
        return ResultRespone.success(dmamonthflowService.getWaterDiffByDma(response, dmaId, startTime, endTime, flag, templateFlag));
    }

    @GetMapping("/clloctByDma")
    @ApiOperation(value = "根据DMA分区ID，时间段获取月份供水量、售水量、产销差量汇总情况")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dmaId", value = "dma分区ID", readOnly = true, dataType = "long"),
            @ApiImplicitParam(name = "startTime", value = "起始月份；如：2021-05", readOnly = true, dataType = "string"),
            @ApiImplicitParam(name = "endTime", value = "结束月份；如：2021-06", readOnly = true, dataType = "string"),
            @ApiImplicitParam(name = "templateFlag", value = "导出标识；1：导出", readOnly = true, dataType = "string"),
    })
    public ResultRespone getClloctByDma(HttpServletResponse response, CostomWaterDiff diff) {
        Long dmaId = diff.getDmaId();
        String startTime = diff.getStartTime();
        String endTime = diff.getEndTime();
        String templateFlag = diff.getTemplateFlag();
        return ResultRespone.success(dmamonthflowService.getClloctByDma(response, dmaId, startTime, endTime, templateFlag));
    }

}
