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

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.watermeter.custom.service.statisticanalysis.IReportManagementService;
import com.tofly.watermeter.custom.service.statisticanalysis.IWaterStatisticsService;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 报表管理
 */
@RestController
@AllArgsConstructor
@RequestMapping("/report")
@Api(value = "报表管理",tags = "报表管理")
public class ReportManagementController {

    private final IReportManagementService service;

    /**
     * 经济/社会效益
     * @param startDate 开始日期 ‘年-月’
     * @param endDate 截止日期 ‘年-月’
     * @return
     */
    @GetMapping("/economic" )
    @ApiOperation(value = "经济/社会效益")
    public ResultRespone getEconomicBenefit(@RequestParam("startDate") String startDate,
                                            @RequestParam("endDate") String endDate) {
        return ResultRespone.success(service.getEconomicBenefit(startDate,endDate));
    }

    /**
     * 经济/社会效益查看明细
     * @param startDate 开始日期 ‘年-月’
     * @param endDate 截止日期 ‘年-月’
     * @return
     */
    @GetMapping("/economic-detail" )
    @ApiOperation(value = "经济/社会效益-查看明细")
    public ResultRespone getEconomicBenefitDetail(Page page,
                                                  @RequestParam("startDate") String startDate,
                                                  @RequestParam("endDate") String endDate,
                                                  @RequestParam("rectifyType") String rectifyType) {
        return ResultRespone.success(service.getEconomicBenefitDetail(page,startDate,endDate,rectifyType));
    }

    /**
     * 根据整改编号获取整改工单
     */
    @GetMapping("/getRectify")
    @ApiOperation(value = "根据整改编号获取整改工单")
    public ResultRespone getRectifyByNumber(String rectifyNumber){
        return ResultRespone.success(service.getRectifyByNumber(rectifyNumber));
    }

    /**
     * 管理效益
     */
    @GetMapping("/management" )
    @ApiOperation(value = "管理效益")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "queryType",value = "查询类型，不合格量-bhgl，合格率-hgl" ),
            @ApiImplicitParam(name = "startDate",value = "开始日期  年-月"),
            @ApiImplicitParam(name = "endDate",value = "开始日期  年-月"),
            @ApiImplicitParam(name = "cbpq",value = "抄表片区，多个','分隔 ")
    })
    public ResultRespone getmMnagementBenefit(@RequestParam("queryType") String queryType,
                                              @RequestParam("startDate") String startDate,
                                              @RequestParam("endDate") String endDate,
                                              @RequestParam("cbpq") String cbpq) {
        return ResultRespone.success(service.getManagementBenefit(queryType,startDate,endDate,cbpq));
    }

    /**
     * 管理效益-不合格量点击详情
     */
    @GetMapping("/unqualifiedQuantity" )
    @ApiOperation(value = "管理效益-不合格量点击详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "queryDate",value = "点击详情月份  年-月"),
            @ApiImplicitParam(name = "cbpq",value = "点击详情抄表片区")
    })
    public ResultRespone getUnqualifiedQuantityDetail(Page page,
                                                      @RequestParam("queryDate") String queryDate,
                                                      @RequestParam("cbpq") String cbpq) {
        return ResultRespone.success(service.getUnqualifiedQuantityDetail(page,queryDate,cbpq));
    }

    /**
     * 管理效益-合格率点击详情
     */
    @GetMapping("/passRate" )
    @ApiOperation(value = "管理效益-合格率点击详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "startDate",value = "开始日期  年-月"),
            @ApiImplicitParam(name = "endDate",value = "开始日期  年-月"),
            @ApiImplicitParam(name = "cbpq",value = "抄表片区")
    })
    public ResultRespone getPassRateDetail( @RequestParam("startDate") String startDate,
                                            @RequestParam("endDate") String endDate,
                                            @RequestParam("cbpq") String cbpq) {
        return ResultRespone.success(service.getPassRateDetail(startDate,endDate,cbpq));
    }

    /**
     * 质检统计 QualityStatistics
     * @param startDate 开始时间
     * @param endDate 结束时间
     * @param queryType 查询类型 多个','分隔
     * @return
     */
    @GetMapping("/quality" )
    @ApiOperation(value = "质检统计")
    public ResultRespone getQualityStatistics(@RequestParam("startDate") String startDate,
                                              @RequestParam("endDate") String endDate,
                                              @RequestParam(value = "queryType",required = false) String queryType) {
        return ResultRespone.success(service.getQualityStatistics(startDate,endDate,queryType));
    }

    /**
     * 质检统计-点击详情
     * @param yearMonth 查询年月
     * @param zglx 整改类型
     * @return
     */
    @GetMapping("/quality-detail" )
    @ApiOperation(value = "质检统计-点击详情")
    public ResultRespone getQualityStatisticsDetail(Page page,
                                                    @RequestParam("yearMonth") String yearMonth,
                                                    @RequestParam("zglx") String zglx) {
        return ResultRespone.success(service.getQualityStatisticsDetail(page,yearMonth,zglx));
    }

}
