package com.lightinit.hsdatashow.controller.topic.water;

import com.lightinit.hsdatashow.dictionary.DicToPicType;
import com.lightinit.hsdatashow.entity.Region;
import com.lightinit.hsdatashow.entity.StWaterConsumer;
import com.lightinit.hsdatashow.model.topic.water.NameAndValueModel;
import com.lightinit.hsdatashow.model.topic.water.ThreeYearsModel;
import com.lightinit.hsdatashow.model.topic.water.WaterSupplyModel;
import com.lightinit.hsdatashow.model.topic.water.YearMonthDayModel;
import com.lightinit.hsdatashow.service.topic.water.IWholeCityWaterService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Calendar;
import java.util.List;

@Controller
@RequestMapping("/topic/water/WholeCityWater")
public class WholeCityWaterController {
    @Autowired
    private IWholeCityWaterService wholeCityWaterService;

    @RequestMapping(value = "/index.htm")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("topic/water/wholeCityWater/index") ;
        List<Region> list = wholeCityWaterService.getRegion();
        modelAndView.addObject("list",list);
        return modelAndView ;
    }
    @RequestMapping(value = "/areaIndex.htm")
    public ModelAndView areaIndex(String regionName){
        ModelAndView modelAndView = new ModelAndView("topic/water/wholeCityWater/areaIndex") ;
        modelAndView.addObject("regionName",regionName);
        return modelAndView ;
    }


    /**
     * 取水用户总数
     */

    @RequestMapping(value = "/getConsume.action")
    @ResponseBody
    public List<NameAndValueModel> getWaterConsumer(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        List<NameAndValueModel>  list = wholeCityWaterService.getWaterConsumer(regionName);
        return list;
    }


    /**
     * 昨日用水总量
     */
    @RequestMapping(value = "/getYesterday.action")
    @ResponseBody
    public YearMonthDayModel getYesterday(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getYesterday(regionName);
    }

    /**
     * 上月用水总量
     */
    @RequestMapping(value = "/getLastMonth.action")
    @ResponseBody
    public YearMonthDayModel getLastMonth(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getLastMonth(regionName);
    }

    /**
     * 本月用水总量
     */
    @RequestMapping(value = "/getMonth.action")
    @ResponseBody
    public YearMonthDayModel getMonth(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getMonth(regionName);
    }

    /**
     * 今年用水总量
     */
    @RequestMapping(value = "/getYear.action")
    @ResponseBody
    public YearMonthDayModel getYear(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getYear(regionName);
    }


    /**
     * 今年用水总量
     */
    @RequestMapping(value = "/getJianCeZhanCount.action")
    @ResponseBody
    public Long getJianCeZhanCount(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getJianCeZhanCount(regionName);
    }

    /**
     * 本市本月每日用水
     */
    @RequestMapping(value = "/getTotalDay.action")
    @ResponseBody
    public YearMonthDayModel getTotalDay(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getTotalDay("",regionName);
    }
    /**
     * 本市本月每日用水
     */
    @RequestMapping(value = "/getFeiNongDay.action")
    @ResponseBody
    public YearMonthDayModel getFeiNongDay(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getTotalDay(DicToPicType.FEINONG,regionName);
    }


    /**
     * 本市今年用水变化趋势
     */
    @RequestMapping(value = "/getTotalMonth.action")
    @ResponseBody
    public YearMonthDayModel getTotalMonth(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getTotalMonth("",regionName);
    }


    /**
     * 本市今年非农用水变化趋势
     */
    @RequestMapping(value = "/getFeiNongMonth.action")
    @ResponseBody
    public YearMonthDayModel getFeiNongMonth(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getTotalMonth(DicToPicType.FEINONG,regionName);
    }
    /**
     * 历年用水变化趋势
     */
    @RequestMapping(value = "/getTotleYear.action")
    @ResponseBody
    public YearMonthDayModel getTotleYear(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getTotalYear("",regionName);
    }
    /**
     * 历年非农用水变化趋势
     */
    @RequestMapping(value = "/getFeiNongYear.action")
    @ResponseBody
    public YearMonthDayModel getFeiNongYear(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getTotalYear(DicToPicType.FEINONG,regionName);
    }

    /**
     * 历年供水变化趋势
     */
    @RequestMapping(value = "/getLiNianGongShui.action")
    @ResponseBody
    public WaterSupplyModel getLiNianGongShui(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getLiNianGongShui(regionName);
    }

    /**
     * 地下水深埋各月平均水位
     */
    @RequestMapping(value = "/getDiXiaShuiShenAVG.action")
    @ResponseBody
    public ThreeYearsModel getDiXiaShuiShenAVG(@RequestParam(defaultValue = "",value = "regionName") String regionName) {
        return wholeCityWaterService.getDiXiaShuiShenAVG(regionName);
    }




}
