package cn.com.countrygarden.bi.main.controller;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.model.bii.BiIncomeMonth;
import cn.com.countrygarden.bi.main.service.bii.BiIncomeMonthService;


/**  

* <p>Title: BiIncomeMonthController</p>  

* <p>Description: </p>  

* @author zhaolie 

* @date 2018年6月5日  

*/  
@RestController("biIncomeMonthController")
@RequestMapping("/api/service/datav/bii")
public class BiIncomeMonthController {
	 @Autowired
	 private BiIncomeMonthService biIncomeMonthService;
	 
	 //总体收入累计查询_本月
	 @ResponseBody
	 @RequestMapping(value = "/getToMonthIncome",method = {RequestMethod.POST,RequestMethod.GET})
	 public Object getToMonthIncome (){
	    List<BiIncomeMonth> biml = new ArrayList<BiIncomeMonth>();
	    BiIncomeMonth bim = new BiIncomeMonth();
	    Calendar cal = Calendar.getInstance();//得到当前时间
	    bim.setYear(String.valueOf(cal.get(Calendar.YEAR))); //取年
	    bim.setMonth(String.valueOf(cal.get(Calendar.MONTH) + 1));//取月
	   /* bim.setMonth(String.valueOf(cal.get(Calendar.DATE)));//取日
*/        bim.setCorpCostId("000000");     
        try {
			biml = this.biIncomeMonthService.getToMonthIncome(bim);
			List dataList = new ArrayList();
	        for(BiIncomeMonth incomeMonth : biml){
	            Map dataMap = new HashMap();
	            dataMap.put("value",incomeMonth.getPaidAmount());
	            dataList.add(dataMap);
	        }
	            return Response.response(dataList);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			 return Response.responseFail("");
		}
        
		 
	 }
	 
	      //房产经营收入查询_每月
		 @ResponseBody
		 @RequestMapping(value = "/getHouAllMonthIncome",method = {RequestMethod.POST,RequestMethod.GET})
		 public Object getHouAllMonthIncome (){
		    List<BiIncomeMonth> biml = new ArrayList<BiIncomeMonth>();
		    BiIncomeMonth bim = new BiIncomeMonth();
		    Calendar cal = Calendar.getInstance();//得到当前时间
		    bim.setYear(String.valueOf(cal.get(Calendar.YEAR))); //取年
            bim.setCorpCostId("100000583");     
	        try {
				biml = this.biIncomeMonthService.getHouAllMonthIncome(bim);
				List dataList = new ArrayList();
		        for(BiIncomeMonth incomeMonth : biml){
		            Map dataMap = new HashMap();
		            dataMap.put("value",incomeMonth.getPaidAmount());
		            dataList.add(dataMap);
		        }
		            return Response.response(dataList);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				 return Response.responseFail("");
			}
	        
			 
		 }
}
  