package org.cs.mgr.order.ctl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.cs.constants.Constants;
import org.cs.core.ctl.BaseCtl;
import org.cs.core.model.Dic;
import org.cs.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.cs.mgr.order.service.IMgmOrderBreakService;
import org.cs.mgr.order.service.IMgmOrderScheduleService;
import org.cs.mgr.order.service.IMgmOrderService;
import org.cs.mgr.user.model.MgmCustomer;
import org.cs.mgr.user.model.MgmUser;
import org.cs.mgr.user.service.IMgmCustomerService;
import org.cs.mgr.user.service.IMgmUserService;
import org.cs.util.Pager;
import org.cs.mgr.admin.model.Admin;
import org.cs.mgr.order.model.MgmOrder;
import org.cs.mgr.order.model.MgmOrderBreak;
import org.cs.mgr.order.model.MgmOrderTransfer;
import org.cs.util.StringUtil;
import com.alibaba.fastjson.JSONObject;


/**
 * 
 * @ClassName: MgmOrder 
 * @Description:  
 * @author: sunny_shi
 * @date: 2018-06-09 13:29:02
 */
@Controller
@RequestMapping("/statistics")
public class StatisticsCtl extends BaseCtl {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	private IMgmOrderService mgmOrderService;
	///客户信息服务
	@Autowired
	private IMgmCustomerService mgmCustomerService;
	//推荐人信息服务
	@Autowired
	private IMgmUserService mgmUserService;
	
	
	
	//进度跟踪
	@Autowired
	private IMgmOrderScheduleService mgmOrderScheduleService;
		
	//终止申请
	@Autowired
	private IMgmOrderBreakService mgmOrderBreakService;

	
	@RequestMapping("list")
	public String list(ModelMap mm, @RequestParam(required=false)String menuCode){
		mm.put(MENU_CODE, menuCode);
		this.set(MENU_CODE, menuCode);
		return "mgr/statistics/list";	
	}
	
	
	@RequestMapping(value="list2", method = RequestMethod.GET, produces="application/json;charset=UTF-8")
	@ResponseBody
	public String list2(int page, int pageSize,String  search){
		Map<String, String> map = getMapFromJson(search);			
		Pager pager = this.mgmOrderService.getMgmOrderStatistics(new Pager(page, pageSize));
		JSONObject json = new JSONObject();
		json.put("rows", pager.getResults());
		json.put("total", pager.getTotal());
		return JSONObject.toJSONString(json, features);	
	}
	
	@RequestMapping(value="export")
	public void export(HttpServletResponse response){
		Map<String, String> map1 = new HashMap<>();
		this.mgmOrderService.downExecl(map1, response);
	}
}

