package com.zcxk.charge.web.controller;

import com.zcxk.charge.api.dto.CompanySceneInfoDto;
import com.zcxk.charge.api.dto.generalview.WaterSupplyChart;
import com.zcxk.charge.api.dto.homepage.WaterQualityRate;
import com.zcxk.charge.api.dto.homepage.WaterQualityRateForScene;
import com.zcxk.charge.web.service.AppReportMonitorService;
import com.zcxk.charge.web.service.HomePageReportService;
import com.zcxk.core.common.pojo.AjaxMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description
 * @author  wangli
 * @data 2021/2/24 9:09
 */
@RestController
@RequestMapping("/AppReportMonitorController")
@Api(tags = "App报表展示")
public class AppReportMonitorController {

    @Autowired
    private HomePageReportService homePageReportService;
    @Autowired
    private AppReportMonitorService appReportMonitorService;

    @RequestMapping(value = "getSceneByCompany",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——公司场景查询（点击公司查询水厂）")
    public AjaxMessage getSceneByCompany(
            @ApiParam(value = "场景类型名称：水源、水厂、泵站") @RequestParam(required = false)  String sceneTypeName,
            @ApiParam(value = "公司id") @RequestParam Integer companyOrgId){
        return AjaxMessage.success(appReportMonitorService.getSceneByCompany(sceneTypeName,companyOrgId));
    }


    @RequestMapping(value = "getSceneCompanyBySearch",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——公司场景查询（条件查询）")
    public AjaxMessage<CompanySceneInfoDto> getSceneCompanyBySearch(
            @ApiParam(value = "场景类型名称：水源、水厂、泵站") @RequestParam(required = false)  String sceneTypeName,
            @ApiParam(value = "查询条件") @RequestParam(required = false) String condition){
        return AjaxMessage.success(appReportMonitorService.getSceneByCompanyBySearch(sceneTypeName,condition));
    }


    @RequestMapping(value = "getDeviceCompanyBySearchForPipeNetwork",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——公司管网设备查询（条件查询）")
    public AjaxMessage<CompanySceneInfoDto> getDeviceCompanyBySearchForPipeNetwork(
            @ApiParam(value = "场景类型名称：压力、流量、水质") @RequestParam(required = false)  String typeName,
            @ApiParam(value = "查询条件") @RequestParam(required = false) String condition){
        return AjaxMessage.success(appReportMonitorService.getDeviceByCompanyBySearch(typeName,condition));
    }

    @RequestMapping(value = "getDeviceByCompanyForPipeNetwork",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——公司管网设备查询（点击公司查询水厂）")
    public AjaxMessage getDeviceByCompanyForPipeNetwork(
            @ApiParam(value = "场景类型名称：压力、流量、水质") @RequestParam(required = false)  String typeName,
            @ApiParam(value = "公司id") @RequestParam Integer companyOrgId){
        return AjaxMessage.success(appReportMonitorService.getDeviceByCompany(typeName,companyOrgId));
    }

    @RequestMapping(value = "getWaterQualification",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——综合水质情况")
    public AjaxMessage<WaterQualityRate> getWaterQualification(){
        return AjaxMessage.success(homePageReportService.getWaterQualification(null));
    }

    @RequestMapping(value = "getWaterQualityRateForWaterSource",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——水库本月水质合格率")
    public AjaxMessage<WaterQualityRateForScene> waterQualityRateForWaterSource(
            @ApiParam(value = "水库id",required = true) @RequestParam Integer sceneId){
        return AjaxMessage.success(homePageReportService.waterQualityRateForWaterSource(sceneId));
    }

    @RequestMapping(value = "waterQualityRateForWaterFactory",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——水厂本月水质合格率")
    public AjaxMessage<WaterQualityRateForScene> waterQualityRateForWaterFactory(
            @ApiParam(value = "水厂id",required = true) @RequestParam Integer sceneId){
        return AjaxMessage.success(homePageReportService.waterQualityRateForWaterFactory(sceneId));
    }

    @RequestMapping(value = "waterQualityRateForPumpingStation",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——泵站本月水质合格率")
    public AjaxMessage<WaterQualityRateForScene> waterQualityRateForPumpingStation(
            @ApiParam(value = "泵站id",required = true) @RequestParam Integer sceneId){
        return AjaxMessage.success(homePageReportService.waterQualityRateForPumpingStation(sceneId));
    }


    @RequestMapping(value = "waterEnergyConsumption",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——水源本月取水情况")
    public AjaxMessage<List<WaterSupplyChart>> waterEnergyConsumption(
            @ApiParam(value = "泵站id",required = true) @RequestParam Integer sceneId){
        return AjaxMessage.success(appReportMonitorService.waterEnergyConsumption(sceneId));
    }

    @RequestMapping(value = "getWaterLevelForWaterSource",method = RequestMethod.GET)
    @ApiOperation(value = "App报表展示——水源本月水位变化")
    public AjaxMessage<List<WaterSupplyChart>> getWaterLevelForWaterSource(
            @ApiParam(value = "泵站id",required = true) @RequestParam Integer sceneId){
        return AjaxMessage.success(appReportMonitorService.getWaterLevelForWaterSource(sceneId));
    }

}
