package cn.ksource.web.controller.business.pages.customerconfig.incident; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; 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.RequestMethod; import org.springframework.web.servlet.ModelAndView; import cn.ksource.core.util.ConvertUtil; import cn.ksource.core.util.JsonUtil; import cn.ksource.core.util.ParamsMapUtil; import cn.ksource.core.util.StringUtil; import cn.ksource.core.web.SysInfo; import cn.ksource.core.web.WebUtil; import cn.ksource.web.Constants; import cn.ksource.web.facade.customerconfig.incident.IncidentflowFacade; /** * 查询事件管理流转策略控制器 * @author liusen * */ @SuppressWarnings("unchecked") @Controller @RequestMapping("/business/pages/customerconfig/incidentflow") public class IncidentflowController { @Autowired private IncidentflowFacade incidentflowFacade; /** * 事件管理流转策略模板配置 */ @RequestMapping(value="incidentNodeDeal.html",method=RequestMethod.GET) public ModelAndView incidentNodeDealConfig(HttpServletRequest request,HttpServletResponse response) { ModelAndView modelAndView = new ModelAndView("/business/pages/customerconfig/incident/incidentNodeDeal"); Map param = ParamsMapUtil.getParameterMap(request); String customerId = param.get("customerId"); String edit = param.get("edit"); Map config = incidentflowFacade.queryIncidentNodeDealConfig(customerId); Map kfry = new HashMap(); Map ycjszc = new HashMap(); Map yxgcs = new HashMap(); Map exgcs = new HashMap(); Map sxgcs = new HashMap(); if(null!=config && config.size()>0) { String kf = ConvertUtil.obj2StrBlank(config.get("KFRY")); if(StringUtil.notEmpty(kf)) { List kfs = JsonUtil.json2List(kf); for(Map map : kfs) { kfry.put(map.get("nodeId"), map); } } String yc = ConvertUtil.obj2StrBlank(config.get("YCJSZC")); if(StringUtil.notEmpty(yc)) { List ycs = JsonUtil.json2List(yc); for(Map map : ycs) { ycjszc.put(map.get("nodeId"), map); } } String yx = ConvertUtil.obj2StrBlank(config.get("YXGCS")); if(StringUtil.notEmpty(yx)) { List yxs = JsonUtil.json2List(yx); for(Map map : yxs) { yxgcs.put(map.get("nodeId"), map); } } String ex = ConvertUtil.obj2StrBlank(config.get("EXGCS")); if(StringUtil.notEmpty(ex)) { List exs = JsonUtil.json2List(ex); for(Map map : exs) { exgcs.put(map.get("nodeId"), map); } } String sx = ConvertUtil.obj2StrBlank(config.get("SXGCS")); if(StringUtil.notEmpty(sx)) { List sxs = JsonUtil.json2List(sx); for(Map map : sxs) { sxgcs.put(map.get("nodeId"), map); } } if(StringUtil.isEmpty(edit)){ if(ConvertUtil.obj2Integer(config.get("isSelf")) == 1){ modelAndView = new ModelAndView("/business/pages/customerconfig/incident/incidentNodeDeal"); }else{ modelAndView = new ModelAndView("/business/pages/customerconfig/incident/incidentNodeDealDetail"); } }else{ modelAndView = new ModelAndView("/business/pages/customerconfig/incident/incidentNodeDeal"); } }else{ modelAndView.addObject("noresult", 1); } List kfryNode = new ArrayList(); List ycjszcNode = new ArrayList(); List yxgcsNode = new ArrayList(); List exgcsNode = new ArrayList(); List sxgcsNode = new ArrayList(); //查询所有节点 Map nodeMap = Constants.incidentNode; List nodes = new ArrayList(); for (Map.Entry entry : nodeMap.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); Map map1 = new HashMap(); Map map2 = new HashMap(); Map map3 = new HashMap(); Map map4 = new HashMap(); Map map5 = new HashMap(); Map map = new HashMap(); map.put("nodeId", key); map.put("nodeName", value); if(kfry.containsKey(key)) { map1.put("type", 1); } if(ycjszc.containsKey(key)) { map2.put("type", 1); } if(yxgcs.containsKey(key)) { map3.put("type", 1); } if(exgcs.containsKey(key)) { map4.put("type", 1); } if(sxgcs.containsKey(key)) { map5.put("type", 1); } map1.putAll(map); map2.putAll(map); map3.putAll(map); map4.putAll(map); map5.putAll(map); kfryNode.add(map1); ycjszcNode.add(map2); yxgcsNode.add(map3); exgcsNode.add(map4); sxgcsNode.add(map5); } modelAndView.addObject("kfryNode", kfryNode); modelAndView.addObject("ycjszcNode", ycjszcNode); modelAndView.addObject("yxgcsNode", yxgcsNode); modelAndView.addObject("exgcsNode", exgcsNode); modelAndView.addObject("sxgcsNode", sxgcsNode); modelAndView.addObject("config", config); return modelAndView; } /** * 事件管理流转策略模板配置 */ @RequestMapping(value="incidentNodeDeal.html",method=RequestMethod.POST) public ModelAndView saveIncidentNodeDealConfig(HttpServletRequest request,HttpServletResponse response) { Map param = ParamsMapUtil.getParameterMap(request); String[] kfry = request.getParameterValues("kfry"); if(null!=kfry && kfry.length>0) { param.put("kfry",arrayToString(kfry)); }else{ param.put("kfry",""); } String[] ycjszc = request.getParameterValues("ycjszc"); if(null!=ycjszc && ycjszc.length>0) { param.put("ycjszc",arrayToString(ycjszc)); }else{ param.put("ycjszc",""); } String[] yxgcs = request.getParameterValues("yxgcs"); if(null!=yxgcs && yxgcs.length>0) { param.put("yxgcs",arrayToString(yxgcs)); }else{ param.put("yxgcs",""); } String[] exgcs = request.getParameterValues("exgcs"); if(null!=exgcs && exgcs.length>0) { param.put("exgcs",arrayToString(exgcs)); }else{ param.put("exgcs",""); } String[] sxgcs = request.getParameterValues("sxgcs"); if(null!=sxgcs && sxgcs.length>0) { param.put("sxgcs",arrayToString(sxgcs)); }else{ param.put("sxgcs",""); } incidentflowFacade.saveIncidentNodeDealConfig(param); //客户编号 String customerId = param.get("customerId"); return WebUtil.sysInfoPage(request, "操作成功!", "", SysInfo.Success,"/business/pages/customerconfig/incidentflow/incidentNodeDeal.html?customerId="+customerId,null); } private String arrayToString(String[] kfry) { String result = new String(); for (String string : kfry) { result += string+","; } result = result.substring(0, result.length()-1); return result; } @RequestMapping(value="initlc.html",method=RequestMethod.POST) public void initlc(HttpServletRequest request,HttpServletResponse response){ Map params = ParamsMapUtil.getParameterMap(request); incidentflowFacade.updatelc(params); WebUtil.write(response, "1"); } }