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

import com.lightinit.hsdatashow.model.topic.water.ListNameAndListValueModel;
import com.lightinit.hsdatashow.model.topic.water.NameAndValue;
import com.lightinit.hsdatashow.model.topic.water.ShouyiRenkouFenleiReturnModel;
import com.lightinit.hsdatashow.service.topic.water.IWaterWorksService;
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/works")
public class WaterWorksController {

    @Autowired
    private IWaterWorksService waterWorksService ;

    @RequestMapping(value = "/index.htm")
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("/topic/water/works/index") ;
        //农村供水总人口
        BigDecimal gongshuiRenkou = waterWorksService.getGongshuiRenkou() ;
        modelAndView.addObject("gongshuiRenkou",gongshuiRenkou) ;
        //农村集中供水工程总量
        Integer gongchengZongliang = waterWorksService.getGongchengZongliang() ;
        modelAndView.addObject("gongchengZongliang",gongchengZongliang) ;
        //集中供水受益人口总数
        BigDecimal shouyiRenkou  = waterWorksService.getShouyiRenkou() ;
        modelAndView.addObject("shouyiRenkou",shouyiRenkou) ;
        //今年投资总额
        BigDecimal touzizongshu = waterWorksService.getTouziZongshu() ;
        modelAndView.addObject("touzizongshu",touzizongshu) ;
        return modelAndView ;
    }

    /**
     * 各区县人口 和 各区县贫困人口
     * @return
     */
    @RequestMapping(value = "/getGequxianRenkou.action")
    @ResponseBody
    public ListNameAndListValueModel getGequxianRenkou(String type){
        return waterWorksService.getGequxianRenkou(type) ;
    }

    /**
     * 工程分布
     * @return
     */
    @RequestMapping(value = "/getGongchengFenbu.action")
    @ResponseBody
    public List<NameAndValue> getGongchengFenbu(){
        return waterWorksService.getGongchengFenbu() ;
    }

    /**
     * 各区县构成
     * @return
     */
    @RequestMapping(value = "/getGongchengGexian.action")
    @ResponseBody
    public List<NameAndValue> getGongchengGexian(String type){
        return waterWorksService.getGongchengGexian(type) ;
    }

    /**
     * 投资构成
     * @return
     */
    @RequestMapping(value = "/getTouziGoucheng.action")
    @ResponseBody
    public List<NameAndValue> getTouziGoucheng(){
        return waterWorksService.getTouziGoucheng() ;
    }

    /**
     * 投资各区县构成
     * @return
     */
    @RequestMapping(value = "/getTouziQuxian.action")
    @ResponseBody
    public List<NameAndValue> getTouziQuxian(String type){
        return waterWorksService.getTouziQuxian(type) ;
    }

    /**
     * 收益人口分类
     * @return
     */
    @RequestMapping(value = "/getShouyiRenkouFenlei.action")
    @ResponseBody
    public ShouyiRenkouFenleiReturnModel getShouyiRenkouFenlei(){
        return waterWorksService.getShouyiRenkouFenlei() ;
    }

    /**
     * 收益人口分布
     * @return
     */
    @RequestMapping(value = "/getShouyiRenkouFenbu.action")
    @ResponseBody
    public  List<NameAndValue> getShouyiRenkouFenbu(String type){
        return waterWorksService.getShouyiRenkouFenbu(type) ;
    }
}
