package cn.ksource.web.controller.wechat.ewyw.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.customermanage.CustomerManageFacade; import cn.ksource.web.facade.tj.IncidentStatisFacade; @Controller @RequestMapping("/ewyw/stats/ewIncidentStats") public class EwIncidentStatsController { @Resource private IncidentStatisFacade incidentStatisFacade; @Resource private CustomerManageFacade customerFacade; /** * 事件统计首页 * @author chenlong * @param request * @return */ @RequestMapping("/incidentStatsIndex.html") public String incidentStatsIndex(HttpServletRequest request){ return "/business/wechat/ewyw/stats/ewIncidentStats/incidentStatsIndex"; } /** * 查询条件 * @author chenlong * @param request * @return */ @RequestMapping("/incidentSearchIndex.html") public String incidentSearchIndex(Model model,HttpServletRequest request){ List customers = customerFacade.getCusList(); model.addAttribute("customers",customers); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentSearchIndex"; } /** * 获取快速查询日期 * @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("/incidentStatsJump.html") public String incidentStatsJump(HttpServletRequest request){ String statsType = request.getParameter("statsType"); if(statsType.equals("type")){ return "forward:/ewyw/stats/ewIncidentStats/incidentTypePie.html"; }else if(statsType.equals("source")){ return "forward:/ewyw/stats/ewIncidentStats/incidentSourcePie.html"; }else if(statsType.equals("close")){ return "forward:/ewyw/stats/ewIncidentStats/incidentCloseCol.html"; }else if(statsType.equals("priority")){ return "forward:/ewyw/stats/ewIncidentStats/incidentPriPie.html"; }else if(statsType.equals("influence")){ return "forward:/ewyw/stats/ewIncidentStats/incidentInfluenceCol.html"; }else if(statsType.equals("level")){ return "forward:/ewyw/stats/ewIncidentStats/incidentLvPie.html"; }else if(statsType.equals("response")){ return "forward:/ewyw/stats/ewIncidentStats/incidentResponsePie.html"; }else if(statsType.equals("deal")){ return "forward:/ewyw/stats/ewIncidentStats/incidentDealPie.html"; }else if(statsType.equals("happen")){ return "forward:/ewyw/stats/ewIncidentStats/incidentHappendTimeLine.html"; } return "forward:/ewyw/stats/ewIncidentStats/incidentStatsIndex.html"; } /** * 事件类型饼状图 * @author chenlong * @param model * @param request * @return */ @SuppressWarnings("rawtypes") @RequestMapping("/incidentTypePie.html") public String incidentTypePie(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 = request.getParameter("cusId"); Map chartMap = incidentStatisFacade.incidentTypePie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentTypePie"; } /** * 事件来源饼状图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/incidentSourcePie.html") public String incidentSourcePie(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 = request.getParameter("cusId"); Map chartMap = incidentStatisFacade.incidentSourcePie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentSourcePie"; } /** * 事件关闭方式柱状图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/incidentCloseCol.html") public String incidentCloseCol(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); String cusId = request.getParameter("cusId"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } Map chartMap = incidentStatisFacade.incidentCloseCol("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentCloseCol"; } /** * 事件优先级饼图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/incidentPriPie.html") public String incidentPriPie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); String cusId = request.getParameter("cusId"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } Map chartMap = incidentStatisFacade.incidentPriPie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentPriPie"; } /** * 事件影响度柱状图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/incidentInfluenceCol.html") public String incidentInfluenceCol(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); String cusId = request.getParameter("cusId"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } Map chartMap = incidentStatisFacade.incidentInfluenceCol("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentInfluenceCol"; } /** * 事件服务级别饼图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/incidentLvPie.html") public String incidentLvPie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); String cusId = request.getParameter("cusId"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } Map chartMap = incidentStatisFacade.incidentLvPie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentLvPie"; } /** * 事件响应饼图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/incidentResponsePie.html") public String incidentResponsePie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); String cusId = request.getParameter("cusId"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } Map chartMap = incidentStatisFacade.incidentResponsePie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentResponsePie"; } /** * 事件处理饼图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/incidentDealPie.html") public String incidentDealPie(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); String cusId = request.getParameter("cusId"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } Map chartMap = incidentStatisFacade.incidentDealPie("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentDealPie"; } /** * 事件发生时间线形图 * @author chenlong * @param model * @param request * @return */ @RequestMapping("/incidentHappendTimeLine.html") public String incidentHappendTimeLine(Model model,HttpServletRequest request){ String startDate = request.getParameter("startDate"); String endDate = request.getParameter("endDate"); String cusId = request.getParameter("cusId"); if(StringUtil.isBlank(startDate)){ Map dateMap = getInitDateMap(); startDate =ConvertUtil.obj2Str(dateMap.get("startDate")).replace("-", ""); endDate = ConvertUtil.obj2Str(dateMap.get("endDate")).replace("-", ""); } Map chartMap = incidentStatisFacade.incidentHappendTimeLine("day",cusId,startDate,endDate); model.addAttribute("chartJsonStr",JsonUtil.map2Json(chartMap)); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentHappendTimeLine"; } 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("/incidentStatsReportJump.html") public String incidentStatsReportJump(HttpServletRequest request){ String statsType = request.getParameter("statsType"); if(statsType.equals("cus")){ return "forward:/ewyw/stats/ewIncidentStats/ewincidentTotalChart.html"; }else if(statsType.equals("detail")){ return "forward:/ewyw/stats/ewIncidentStats/ewincidentStatis.html"; }else if(statsType.equals("dcl")){ return "forward:/ewyw/stats/ewIncidentStats/ewincidentDclStatis.html"; }else if(statsType.equals("close")){ return "forward:/ewyw/stats/ewIncidentStats/ewincidentCloseStatis.html"; }else if(statsType.equals("type")){ return "forward:/ewyw/stats/ewIncidentStats/ewincidentTypeStatis.html"; }else if(statsType.equals("dealtime")){ return "forward:/ewyw/stats/ewIncidentStats/ewincidentDealTimeStatis.html"; }else if(statsType.equals("deal")){ return "forward:/ewyw/stats/ewIncidentStats/ewincidentDealStatis.html"; } return "forward:/ewyw/stats/ewIncidentStats/incidentStatsIndex.html"; } @RequestMapping("ewincidentTotalChart.html") public ModelAndView incidentTotalChart(HttpServletRequest request,HttpServletResponse response) { ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/stats/ewIncidentStats/ewincidentTotalChart"); //获取当前session中的客户信息 String cusId = request.getParameter("cusId"); String beginTime = request.getParameter("beginDay"); String endTime = request.getParameter("endDay"); if(!StringUtil.isEmpty(cusId)){ Map resMap = incidentStatisFacade.incidentTotalChart(cusId,"",beginTime,endTime); SC_PARTNER_CUSTOMER_INFO cus = new SC_PARTNER_CUSTOMER_INFO(cusId).getInstanceById(); 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); 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; } /** * 查询条件 * @author chenlong * @param request * @return */ @RequestMapping("/incidentSearchReport.html") public String incidentSearchReport(Model model,HttpServletRequest request){ List customers = customerFacade.getCusList(); model.addAttribute("customers",customers); return "/business/wechat/ewyw/stats/ewIncidentStats/incidentSearchReport"; } /** * 办公网络保修统计 * @param request * @return */ @RequestMapping("ewincidentStatis.html") public ModelAndView ewincidentStatis(HttpServletRequest request){ ModelAndView modelAndView=new ModelAndView("/business/wechat/ewyw/stats/ewIncidentStats/ewincidentStatis"); String cusId = request.getParameter("cusId"); String beginTime = request.getParameter("beginDay"); String endTime = request.getParameter("endDay"); String sub_customer_id = request.getParameter("sub_customer_id"); if(!StringUtil.isEmpty(cusId)){ List incidentList=incidentStatisFacade.queryIncidentStatis(cusId,sub_customer_id,beginTime,endTime,"","",""); modelAndView.addObject("incidentList",incidentList); SC_PARTNER_CUSTOMER_INFO cus = new SC_PARTNER_CUSTOMER_INFO(cusId).getInstanceById(); modelAndView.addObject("beginTime",DateUtil.format("yyyy/MM/dd", request.getParameter("beginDay"))); modelAndView.addObject("endTime",DateUtil.format("yyyy/MM/dd", request.getParameter("endDay"))); modelAndView.addObject("cusName",cus.getShort_name()); } return modelAndView; } /** * 跳转到事件达成率信息页面 */ @RequestMapping("ewincidentDclStatis.html") public ModelAndView ewincidentDclStatis(HttpServletRequest request) { ModelAndView modelAndView = new ModelAndView("/business/wechat/ewyw/stats/ewIncidentStats/ewincidentDclStatis"); String cusId = request.getParameter("cusId"); String beginTime = request.getParameter("beginTime"); String endTime = request.getParameter("endTime"); String subCustomerId = request.getParameter("sub_customer_id"); if(!StringUtil.isEmpty(cusId)){ List reports = incidentStatisFacade.queryIncidentDclStatis(cusId,subCustomerId,beginTime,endTime); SC_PARTNER_CUSTOMER_INFO cus = new SC_PARTNER_CUSTOMER_INFO(cusId).getInstanceById(); modelAndView.addObject("reports", reports); modelAndView.addObject("beginTime",DateUtil.format("yyyy/MM/dd", request.getParameter("beginTime"))); modelAndView.addObject("endTime",DateUtil.format("yyyy/MM/dd", request.getParameter("endTime"))); modelAndView.addObject("cusName",cus.getShort_name()); } return modelAndView; } @RequestMapping("ewincidentCloseStatis.html") public String ewincidentCloseStatis(Model model,HttpServletRequest request,HttpServletResponse response){ String cusId = request.getParameter("cusId"); String beginDay = request.getParameter("beginDay"); String endDay = request.getParameter("endDay"); if(!StringUtil.isEmpty(cusId)){ Map report = incidentStatisFacade.queryCloseReport(cusId,beginDay,endDay); model.addAttribute("report", report); SC_PARTNER_CUSTOMER_INFO cus = new SC_PARTNER_CUSTOMER_INFO(cusId).getInstanceById(); model.addAttribute("beginTime",DateUtil.format("yyyy/MM/dd", request.getParameter("beginDay"))); model.addAttribute("endTime",DateUtil.format("yyyy/MM/dd", request.getParameter("endDay"))); model.addAttribute("cusName",cus.getShort_name()); } return "/business/wechat/ewyw/stats/ewIncidentStats/ewincidentCloseStatis"; } @RequestMapping("ewincidentTypeStatis.html") public String ewincidentTypeStatis(Model model,HttpServletRequest request,HttpServletResponse response){ String cusId = request.getParameter("cusId"); String beginDay = request.getParameter("beginDay"); String endDay = request.getParameter("endDay"); if(!StringUtil.isEmpty(cusId)){ Map report = incidentStatisFacade.queryTypeReport(cusId,beginDay,endDay); List dataList = (List)report.get("dataList"); if(dataList.size() > 0){ for(List list:dataList){ int hj = 0; for(int i = 0 ;i < list.size();i++){ if(i != 0){ hj = hj + ConvertUtil.obj2Int(list.get(i)); } } list.add(ConvertUtil.obj2StrBlank(hj)); } } model.addAttribute("report", report); SC_PARTNER_CUSTOMER_INFO cus = new SC_PARTNER_CUSTOMER_INFO(cusId).getInstanceById(); model.addAttribute("beginTime",DateUtil.format("yyyy/MM/dd", request.getParameter("beginDay"))); model.addAttribute("endTime",DateUtil.format("yyyy/MM/dd", request.getParameter("endDay"))); model.addAttribute("cusName",cus.getShort_name()); } return "/business/wechat/ewyw/stats/ewIncidentStats/ewincidentTypeStatis"; } @RequestMapping("ewincidentDealTimeStatis.html") public String ewincidentDealTimeStatis(Model model,HttpServletRequest request,HttpServletResponse response){ String cusId = request.getParameter("cusId"); String beginDay = request.getParameter("beginDay"); String endDay = request.getParameter("endDay"); if(!StringUtil.isEmpty(cusId)){ Map report = incidentStatisFacade.queryDealTimeReport(cusId,beginDay,endDay); model.addAttribute("report", report); SC_PARTNER_CUSTOMER_INFO cus = new SC_PARTNER_CUSTOMER_INFO(cusId).getInstanceById(); model.addAttribute("beginTime",DateUtil.format("yyyy/MM/dd", request.getParameter("beginDay"))); model.addAttribute("endTime",DateUtil.format("yyyy/MM/dd", request.getParameter("endDay"))); model.addAttribute("cusName",cus.getShort_name()); } return "/business/wechat/ewyw/stats/ewIncidentStats/ewincidentDealTimeStatis"; } @RequestMapping("ewincidentDealStatis.html") public String ewincidentDealStatis(Model model,HttpServletRequest request,HttpServletResponse response){ String cusId = request.getParameter("cusId"); String beginDay = request.getParameter("beginDay"); String endDay = request.getParameter("endDay"); if(!StringUtil.isEmpty(cusId)){ Map report = incidentStatisFacade.queryDealSituationReport(cusId,beginDay,endDay); model.addAttribute("report", report); SC_PARTNER_CUSTOMER_INFO cus = new SC_PARTNER_CUSTOMER_INFO(cusId).getInstanceById(); model.addAttribute("beginTime",DateUtil.format("yyyy/MM/dd", request.getParameter("beginDay"))); model.addAttribute("endTime",DateUtil.format("yyyy/MM/dd", request.getParameter("endDay"))); model.addAttribute("cusName",cus.getShort_name()); } return "/business/wechat/ewyw/stats/ewIncidentStats/ewincidentDealStatis"; } }