package com.zcxk.controller;

import com.zcxk.dto.AmountDayThirtyDto;
import com.zcxk.dto.AmountTotalDto;
import com.zcxk.dto.WaterPieDto;
import com.zcxk.dto.generalView.SceneWaterPressure;
import com.zcxk.dto.generalView.WaterSupplyChart;
import com.zcxk.entity.SceneEntity;
import com.zcxk.model.AjaxMessage;
import com.zcxk.model.ResultStatus;
import com.zcxk.service.MonitorDataReportService;
import com.zcxk.service.SecSupplyService;
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.*;

@RestController
@RequestMapping("/secsupply")
@Api(tags = "二供在线监测概览")
public class SecSupplyController {
    @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<List<AmountDayThirtyDto>> findAmountDayThirty(@ApiParam(value = "一级场景类型", required = true) @RequestParam Integer sceneType) {
        SceneEntity sceneEntity = new SceneEntity();
        if (sceneType.equals(1)) {
            sceneEntity.setSceneTypeName("水源");
        } else if (sceneType.equals(2)) {
            sceneEntity.setSceneTypeName("水厂");
        } else {
            sceneEntity.setSceneTypeName("泵站");
        }
        List<AmountDayThirtyDto> list = secSupplyService.getAmountDayThirty(sceneEntity);
        return new AjaxMessage<>(ResultStatus.OK, list);
    }
    @ApiOperation(value = "二供概览首页——查询供水量汇总信息",notes = "sceneType 1为水源 2水厂 3泵站")
    @RequestMapping(value = "/selectAmountTotalByTypeName", method = RequestMethod.GET)
    @ResponseBody
    public AjaxMessage<AmountTotalDto> findAmountTotalByTypeName(@ApiParam(value = "一级场景类型", required = true) @RequestParam Integer sceneType) {
        AmountTotalDto amountTotalDto = new AmountTotalDto();
        SceneEntity sceneEntity = new SceneEntity();
        if (sceneType.equals(1)) {
            sceneEntity.setSceneTypeName("水源");
        } else if (sceneType.equals(2)) {
            sceneEntity.setSceneTypeName("水厂");
        } else {
            sceneEntity.setSceneTypeName("泵站");
        }
        amountTotalDto = secSupplyService.findAmountTotalByTypeName(sceneEntity);
        return new AjaxMessage<>(ResultStatus.OK, 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("水源");
        } else if (sceneType.equals(2)) {
            sceneEntity.setSceneTypeName("水厂");
        } else {
            sceneEntity.setSceneTypeName("泵站");
        }
        WaterPieDto waterPieDto = secSupplyService.selectWaterQualityByTypeName(sceneEntity);
        return new AjaxMessage<>(ResultStatus.OK, waterPieDto);
    }

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

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