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

import com.lightinit.hsdatashow.entity.StWaterLake;
import com.lightinit.hsdatashow.model.ResultState;
import com.lightinit.hsdatashow.model.admin.WaterqualityNameAndValueModel;
import com.lightinit.hsdatashow.model.topic.water.HeliuGaikuangReturnModel;
import com.lightinit.hsdatashow.model.topic.water.ListNameAndListValueModel;
import com.lightinit.hsdatashow.model.topic.water.ModelNameAndNameOrValue;
import com.lightinit.hsdatashow.model.topic.water.YueyongshuiReturnModel;
import com.lightinit.hsdatashow.service.topic.water.IHomeShowServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.math.BigDecimal;
import java.util.List;

@Controller
@RequestMapping("/topic/water/home")
public class HomeShowController {

    @Autowired
    private IHomeShowServer homeShowServer ;

    @RequestMapping(value = "/index.htm")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("topic/water/home/index") ;
//        ModelAndView modelAndView = new ModelAndView("/admin/waterThing/index") ;
        //河湖数量
        int riverCount = homeShowServer.getRiverCount() ;
        modelAndView.addObject("riverCount",riverCount) ;
        //上月降雨总量
        BigDecimal shangyuejiangyu = homeShowServer.getShangyueJiangyu() ;
        modelAndView.addObject("shangyuejiangyu",shangyuejiangyu) ;
        //上月用水总量
        BigDecimal shangyueyonghusi = homeShowServer.getShangyueYongshui() ;
        modelAndView.addObject("shangyueyonghusi",shangyueyonghusi) ;
        //可用水总量
        BigDecimal yongshui = homeShowServer.getYongshui() ;
        modelAndView.addObject("yongshui",yongshui) ;
        //河流概况(河流总长)
        BigDecimal riverLength = homeShowServer.getRiverLength() ;
        modelAndView.addObject("riverLength",riverLength) ;
        //衡水湖信息
        StWaterLake stWaterLake = homeShowServer.getHengshuiHu() ;
        modelAndView.addObject("hshxs",stWaterLake.getLakeImpoundage()) ;
        modelAndView.addObject("hshmj",stWaterLake.getLakeArea()) ;
        //河流总蓄水量
        BigDecimal hlxs = homeShowServer.getHlXs() ;
        modelAndView.addObject("hlxs",hlxs) ;
        return modelAndView ;
    }

    /**
     * 汛期预警
     * @return
     */
    @RequestMapping(value = "/getxunqiyujing.action")
    @ResponseBody
    public ResultState getxunqiyujing(){
        return homeShowServer.getxunqiyujing() ;
    }

    /**
     * 今日暴雨
     * @return
     */
    @RequestMapping(value = "getjinribaoyu.action")
    @ResponseBody
    public ResultState getjinribaoyu(){
        return homeShowServer.getjinribaoyu();
    }

    /**
     * 今日降雨变化
     * @return
     */
    @RequestMapping(value = "getjinrijiangyubianhua.action")
    @ResponseBody
    public ResultState getjinrijiangyubianhua(){
        return homeShowServer.getjinrijiangyubianhua();
    }

    /**
     * 衡水市主要河流概况
     * @return
     */
    @RequestMapping(value = "/getHeliuGaikuang.action")
    @ResponseBody
    public HeliuGaikuangReturnModel getHeliuGaikuang(){
        return homeShowServer.getHeliuGaikuang() ;
    }

    /**
     * 上月各区县降雨详情
     */
    @RequestMapping(value = "getGequJiangshui.action")
    @ResponseBody
    public List<WaterqualityNameAndValueModel> getGequJiangshui(){
        return homeShowServer.getGequJiangshui() ;
    }

    /**
     * 上月各区县用水详情
     */
    @RequestMapping(value = "getGequYongshui.action")
    @ResponseBody
    public List<WaterqualityNameAndValueModel> getGequYongshui(){
        return homeShowServer.getGequYongshui() ;
    }

    /**
     * 当前各水库可用水
     */
    @RequestMapping(value = "getGeshuikuYongshui.action")
    @ResponseBody
    public ModelNameAndNameOrValue getGeshuikuYongshui(){
        return homeShowServer.getGeshuikuYongshui() ;
    }

    /**
     * 各水库今年各月用水量
     */
    @RequestMapping(value = "getYueyongshui.action")
    @ResponseBody
    public YueyongshuiReturnModel getYueyongshui(){
        return homeShowServer.getYueyongshui() ;
    }

    /**
     * 农村工程
     *
     */
    @RequestMapping(value = "getNongcunGongcheng.action")
    @ResponseBody
    public ListNameAndListValueModel getNongcunGongcheng(){
        return homeShowServer.getNongcunGongcheng() ;
    }
}
