package com.zcxk.charge.web.controller;

import com.zcxk.charge.api.dto.AmountDayThirtyDto;
import com.zcxk.charge.api.dto.AmountTotalDto;
import com.zcxk.charge.api.dto.WaterPieDto;
import com.zcxk.charge.api.dto.generalview.SceneWaterPressure;
import com.zcxk.charge.api.dto.generalview.WaterSupplyChart;
import com.zcxk.charge.core.entity.SceneEntity;
import com.zcxk.charge.web.service.MonitorDataReportService;
import com.zcxk.charge.web.service.SecSupplyService;
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.*;

import java.util.List;

/**
* @author Andy
**/
@RestController
@RequestMapping("/secsupply")
@Api(tags = "二供在线监测概览")
public class SecSupplyController extends BaseController{

    @Autowired
    private SecSupplyService secSupplyService;

    @Autowired
    private MonitorDataReportService monitorDataReportService;


    @ApiOperation(value = "二供概览首页——近15天供水量",notes = "sceneType 1为水源2水厂3泵站")
    @RequestMapping(value = "/selectAmountByTypeName", method = RequestMethod.GET)
    @ResponseBody
    public AjaxMessage findAmountDayThirty(@ApiParam(value = "一级场景类型", required = true) @RequestParam Integer sceneType) {
        SceneEntity sceneEntity = new SceneEntity();
        if (sceneType.equals(1)) {
            sceneEntity.setSceneTypeName(WATER_SOURCE.getMessage());
        } else if (sceneType.equals(2)) {
            sceneEntity.setSceneTypeName(WATER_WORKS.getMessage());
        } else {
            sceneEntity.setSceneTypeName(PUMPING_STATION.getMessage());
        }
        List<AmountDayThirtyDto> list = secSupplyService.getAmountDayThirty(sceneEntity);
        return AjaxMessage.success( list);
    }


    @ApiOperation(value = "二供概览首页——查询供水量汇总信息",notes = "sceneType 1为水源 2水厂 3泵站")
    @RequestMapping(value = "/selectAmountTotalByTypeName", method = RequestMethod.GET)
    @ResponseBody
    public AjaxMessage findAmountTotalByTypeName(@ApiParam(value = "一级场景类型", required = true) @RequestParam Integer sceneType) {
        AmountTotalDto amountTotalDto ;
        SceneEntity sceneEntity = new SceneEntity();
        if (sceneType.equals(1)) {
            sceneEntity.setSceneTypeName(WATER_SOURCE.getMessage());
        } else if (sceneType.equals(2)) {
            sceneEntity.setSceneTypeName(WATER_WORKS.getMessage());
        } else {
            sceneEntity.setSceneTypeName(PUMPING_STATION.getMessage());
        }
        amountTotalDto = secSupplyService.findAmountTotalByTypeName(sceneEntity);
        return AjaxMessage.success( amountTotalDto);
    }

    @ApiOperation(value = "二供概览首页——查询管网水质情况",notes = "sceneType 1为水源 2水厂 3泵站")
    @RequestMapping(value = "/selectWaterQualityByTypeName", method = RequestMethod.GET)
    @ResponseBody
    public  AjaxMessage<WaterPieDto> selectWaterQualityByTypeName(@ApiParam(value = "一级场景类型", required = true) @RequestParam Integer sceneType) {
        SceneEntity sceneEntity = new SceneEntity();
        if (sceneType.equals(1)) {
            sceneEntity.setSceneTypeName(WATER_SOURCE.getMessage());
        } else if (sceneType.equals(2)) {
            sceneEntity.setSceneTypeName(WATER_WORKS.getMessage());
        } else {
            sceneEntity.setSceneTypeName(PUMPING_STATION.getMessage());
        }
        WaterPieDto waterPieDto = secSupplyService.selectWaterQualityByTypeName(sceneEntity);
        return AjaxMessage.success(waterPieDto);
    }

    @RequestMapping(value = "sceneWaterPressure",method = RequestMethod.GET)
    @ApiOperation(value = "二供概览首页——压力分布区间")
    public AjaxMessage<SceneWaterPressure> sceneWaterPressure(){
        return AjaxMessage.success(monitorDataReportService.sceneWaterPressure("泵站"));
    }

    @RequestMapping(value = "waterSupplyCharts",method = RequestMethod.GET)
    @ApiOperation(value = "二供概览首页——供水电耗药耗对比曲线图")
    public AjaxMessage<List<WaterSupplyChart>> waterSupplyCharts(){
        return AjaxMessage.success(monitorDataReportService.waterSupplyCharts("泵站"));
    }
}
