package cn.ksource.web.controller.wechat.uwyw.stats; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import cn.ksource.beans.SC_PARTNER_CUSTOMER_INFO; import cn.ksource.core.util.ConvertUtil; import cn.ksource.core.util.DateUtil; import cn.ksource.core.util.JsonUtil; import cn.ksource.core.util.StringUtil; import cn.ksource.core.web.WebUtil; import cn.ksource.web.facade.tj.LocalStatisFacade; @Controller @RequestMapping("/uwyw/stats/uLocalStats") public class ULocalStatsController { @Resource private LocalStatisFacade localStatisFacade; /** * 驻场统计首页 * @author chenlong * @param request * @return */ @RequestMapping("/localStatsIndex.html") public String localStatsIndex(HttpServletRequest request){ return "/business/wechat/uwyw/stats/uLocalStats/localStatsIndex"; } /** * 查询条件 * @author chenlong * @param request * @return */ @RequestMapping("/localSearchIndex.html") public String localSearchIndex(Model model,HttpServletRequest request){ return "/business/wechat/uwyw/stats/uLocalStats/localSearchIndex"; } /** * 获取快速查询日期 * @author chenlong * @param request * @param response */ @RequestMapping("/getFastSearchDate.html") public void getFastSearchDate(HttpServletRequest request,HttpServletResponse response){ SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); Calendar cal = Calendar.getInstance(); Map dateMap = new HashMap(); String searchType = request.getParameter("searchType"); if(searchType.equals("one_week")){ dateMap = DateUtil.getRecentDate(df.format(cal.getTime()), -6, "DAY", 8); }else if(searchType.equals("one_month")){ dateMap = DateUtil.getRecentDate(df.format(cal.getTime()), -1, "MONTH", 8); }else if(searchType.equals("three_month")){ dateMap = DateUtil.getRecentDate(df.format(cal.getTime()), -2, "MONTH", 8); }else if(searchType.equals("six_month")){ dateMap = DateUtil.getRecentDate(df.format(cal.getTime()), -5, "MONTH", 8); }else if(searchType.equals("one_year")){ dateMap = DateUtil.getRecentDate(df.format(cal.getTime()), -1, "YEAR", 8); } WebUtil.write(response, JsonUtil.map2Json(dateMap)); } @RequestMapping("/localStatsJump.html") public String localStatsJump(HttpServletRequest request){ String statsType = request.getParameter("statsType"); if(statsType.equals("type")){ return "forward:/uwyw/stats/uLocalStats/localTypePie.html"; }else if(statsType.equals("source")){ return "forward:/uwyw/stats/uLocalStats/localSourcePie.html"; }else if(statsType.equals("close")){ return "forward:/uwyw/stats/uLocalStats/localCloseCol.html"; }else if(statsType.equals("priority")){ return "forward:/uwyw/stats/uLocalStats/localPriPie.html"; }else if(statsType.equals("influence")){ return "forward:/uwyw/stats/uLocalStats/localInfluenceCol.html"; }else if(statsType.equals("level")){ return "forward:/uwyw/stats/uLocalStats/localLvPie.html"; }else if(statsType.equals("response")){ return "forward:/uwyw/stats/uLocalStats/localResponsePie.html"; }else if(statsType.equals("deal")){ return "forward:/uwyw/stats/uLocalStats/localDealPie.html"; }else if(statsType.equals("happen")){ return "forward:/uwyw/stats/uLocalStats/localHappendTimeLine.html"; } return "forward:/uwyw/stats/uLocalStats/localStatsIndex.html"; } /** * 驻场类型饼状图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/localTypePie.html") public String localTypePie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } String cusId = WebUtil.getUserWywCusId(request); Map chartMap = localStatisFacade.localTypePie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/uwyw/stats/uLocalStats/localTypePie"; } /** * 驻场来源饼状图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/localSourcePie.html") public String localSourcePie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } String cusId = WebUtil.getUserWywCusId(request); Map chartMap = localStatisFacade.localSourcePie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/uwyw/stats/uLocalStats/localSourcePie"; } /** * 驻场关闭方式柱状图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/localCloseCol.html") public String localCloseCol(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } String cusId = WebUtil.getUserWywCusId(request); Map chartMap = localStatisFacade.localCloseCol("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/uwyw/stats/uLocalStats/localCloseCol"; } /** * 驻场优先级饼图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/localPriPie.html") public String localPriPie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } String cusId = WebUtil.getUserWywCusId(request); Map chartMap = localStatisFacade.localPriPie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/uwyw/stats/uLocalStats/localPriPie"; } /** * 驻场影响度柱状图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/localInfluenceCol.html") public String localInfluenceCol(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } String cusId = WebUtil.getUserWywCusId(request); Map chartMap = localStatisFacade.localInfluenceCol("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/uwyw/stats/uLocalStats/localInfluenceCol"; } /** * 驻场服务级别饼图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/localLvPie.html") public String localLvPie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } String cusId = WebUtil.getUserWywCusId(request); Map chartMap = localStatisFacade.localLvPie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/uwyw/stats/uLocalStats/localLvPie"; } /** * 驻场响应饼图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/localResponsePie.html") public String localResponsePie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } String cusId = WebUtil.getUserWywCusId(request); Map chartMap = localStatisFacade.localResponsePie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/uwyw/stats/uLocalStats/localResponsePie"; } /** * 驻场处理饼图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/localDealPie.html") public String localDealPie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } String cusId = WebUtil.getUserWywCusId(request); Map chartMap = localStatisFacade.localDealPie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/uwyw/stats/uLocalStats/localDealPie"; } /** * 驻场发生时间线形图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/localHappendTimeLine.html") public String localHappendTimeLine(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } String cusId = WebUtil.getUserWywCusId(request); Map chartMap = localStatisFacade.localHappendTimeLine("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/uwyw/stats/uLocalStats/localHappendTimeLine"; } public Map getInitDateMap(){ Calendar cal = Calendar.getInstance(); SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); Map dateMap = new HashMap(); dateMap = DateUtil.getRecentDate(df.format(cal.getTime()), -6, "DAY", 8); return dateMap; } @RequestMapping("/localStatsReportJump.html") public String localStatsReportJump(HttpServletRequest request){ String statsType = request.getParameter("statsType"); if(statsType.equals("pro")){ return "forward:/uwyw/stats/uLocalStats/ulocalTotalChart.html"; }else if(statsType.equals("all")){ return "forward:/uwyw/stats/uLocalStats/ulocalStatis.html"; } return "forward:/uwyw/stats/uLocalStats/localStatsIndex.html"; } /** * 查询条件 * @author sxj * @param request * @return */ @RequestMapping("/localSearchReport.html") public String localSearchReport(Model model,HttpServletRequest request){ return "/business/wechat/uwyw/stats/uLocalStats/localSearchReport"; } @RequestMapping("ulocalTotalChart.html") public ModelAndView ulocalTotalChart(HttpServletRequest request,HttpServletResponse response) { ModelAndView modelAndView = new ModelAndView("/business/wechat/uwyw/stats/uLocalStats/ulocalTotalChart"); //获取当前session中的客户信息 String cusId = WebUtil.getUserWywCusId(request); String beginTime = request.getParameter("beginDay"); String endTime = request.getParameter("endDay"); if(!StringUtil.isEmpty(cusId)){ Map resMap = localStatisFacade.localTotalChart(cusId,"",beginTime,endTime); List typeList = (List)resMap.get("typeList"); List sourceList = (List)resMap.get("sourceList"); List closeList = (List)resMap.get("closeList"); List priList = (List)resMap.get("priList"); List effectList = (List)resMap.get("effectList"); List levelList = (List)resMap.get("levelList"); List timeoutList = (List)resMap.get("timeoutList"); List resolveList = (List)resMap.get("resolveList"); List stateList = (List)resMap.get("stateList"); List resList = (List)resMap.get("resList"); modelAndView.addObject("typeList",typeList); modelAndView.addObject("sourceList",sourceList); modelAndView.addObject("closeList",closeList); modelAndView.addObject("priList",priList); modelAndView.addObject("effectList",effectList); modelAndView.addObject("levelList",levelList); modelAndView.addObject("timeoutList",timeoutList); modelAndView.addObject("resolveList",resolveList); modelAndView.addObject("stateList",stateList); modelAndView.addObject("resList",resList); SC_PARTNER_CUSTOMER_INFO cus = new SC_PARTNER_CUSTOMER_INFO(cusId).getInstanceById(); modelAndView.addObject("cusName",cus.getShort_name()); modelAndView.addObject("beginTime",DateUtil.format("yyyy/MM/dd", beginTime)); modelAndView.addObject("endTime",DateUtil.format("yyyy/MM/dd", endTime)); } return modelAndView; } /** * 办公网络保修统计 * @param request * @return */ @RequestMapping("ulocalStatis.html") public ModelAndView ulocalStatis(HttpServletRequest request){ ModelAndView modelAndView=new ModelAndView("/business/wechat/uwyw/stats/uLocalStats/ulocalStatis"); String cusId = WebUtil.getUserWywCusId(request); String beginTime = request.getParameter("beginDay"); String endTime = request.getParameter("endDay"); String subCustomerId=request.getParameter("sub_customer_id"); String wfstate=""; if(!StringUtil.isEmpty(cusId)){ List incidentList=localStatisFacade.queryLocalIncidentStatis(cusId,subCustomerId,beginTime,endTime,wfstate,""); modelAndView.addObject("incidentList",incidentList); modelAndView.addObject("beginTime",DateUtil.format("yyyy/MM/dd",beginTime)); modelAndView.addObject("endTime",DateUtil.format("yyyy/MM/dd",endTime)); SC_PARTNER_CUSTOMER_INFO cus = new SC_PARTNER_CUSTOMER_INFO(cusId).getInstanceById(); modelAndView.addObject("cusName",cus.getShort_name()); } return modelAndView; } }