package com.shlanbao.tzsc.pms.equ.trouble.controller; import java.util.List; import java.util.UUID; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; 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.ResponseBody; import com.shlanbao.tzsc.base.model.DataGrid; import com.shlanbao.tzsc.base.model.Json; import com.shlanbao.tzsc.base.model.PageParams; import com.shlanbao.tzsc.pms.equ.trouble.beans.EqmTroubleBean; import com.shlanbao.tzsc.pms.equ.trouble.beans.EqmTroubleInfoBean; import com.shlanbao.tzsc.pms.equ.trouble.beans.TroubleBean; import com.shlanbao.tzsc.pms.equ.trouble.service.TroubleServiceI; import com.shlanbao.tzsc.utils.tools.StringUtil; @Controller @RequestMapping("/pms/trouble") public class TroubleController { protected Logger log = Logger.getLogger(this.getClass()); @Autowired private TroubleServiceI troubleService; @ResponseBody @RequestMapping("/queryTrouble") public DataGrid queryTrouble(TroubleBean troubleBean,PageParams pageParams){ try { DataGrid gd = troubleService.queryTrouble(troubleBean, pageParams); return gd; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } /**设备维修记录反馈*/ @ResponseBody @RequestMapping("/dasSendTrouble") public Json dasSendTrouble(String ids,HttpSession session){ Json json = new Json(); try { troubleService.dasSendTrouble(ids); json.setSuccess(true); json.setMsg("反馈成功!"); } catch (Exception e) { e.printStackTrace(); json.setMsg("反馈失败!"); } return json; } @ResponseBody @RequestMapping("/queryList") public DataGrid queryList(EqmTroubleBean eqmtroubleBean,PageParams pageParams){ try { DataGrid gd = troubleService.queryTrouble(eqmtroubleBean, pageParams); return gd; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } /** * 张璐 * 用于WCT故障信息树状结构查询 * @param troubleBean * @return */ @ResponseBody @RequestMapping("/queryTroubleInfo") public String queryTroubleInfo(EqmTroubleInfoBean troubleBean){ List list = troubleService.queryTroubleInfo(troubleBean); StringBuffer htmlBuffer=new StringBuffer(); if(list.size()>0){ for(int i1=0;i1"+description1+" "); htmlBuffer.append(""); } } } return htmlBuffer.toString(); /*Map> map1=new HashMap>();//一级标题键,值为二级标题的键,以下以此类推 Map> map2=new HashMap>(); Map> map3=new HashMap>(); Map> map4=new HashMap>(); List list = troubleService.queryTroubleInfo(troubleBean); for(EqmTroubleInfoBean bean:list){ String eqpDes=bean.getEqp_DES();//1 String trouble2=bean.getTrouble_part_description(); String trouble3=bean.getPart_code_description(); String trouble4=bean.getTrouble_phenomenon_description(); String trouble5=bean.getTrouble_reason_description(); String code=bean.getTrouble_code()+"-"+bean.getTrouble_phenomenon()+"-"+bean.getTrouble_reason(); String fourCode=bean.getTrouble_code()+"~"+bean.getTrouble_phenomenon(); if(map1.get(eqpDes)!=null){ List tempList=map1.get(eqpDes); if(!tempList.contains(trouble2)){ tempList.add(trouble2); map1.put(eqpDes, tempList); } }else{ List tempList=new ArrayList(); tempList.add(trouble2); map1.put(eqpDes, tempList); } if(map2.get(trouble2)!=null){ List tempList=map2.get(trouble2); if(!tempList.contains(trouble3)){ tempList.add(trouble3); map2.put(trouble2, tempList); } }else{ List tempList=new ArrayList(); tempList.add(trouble3); map2.put(trouble2, tempList); } if(map3.get(trouble3)!=null){ List tempList=map3.get(trouble3); if(!tempList.contains(trouble4)){ tempList.add(trouble4); map3.put(trouble3, tempList); } }else{ List tempList=new ArrayList(); tempList.add(trouble4); map3.put(trouble3,tempList); } if(map4.get(trouble4)!=null){ List tempList=map4.get(trouble4); if(!tempList.contains(trouble5)){ tempList.add(code+":1"+trouble5); map4.put(trouble4, tempList); } }else{ List tempList=new ArrayList(); tempList.add(code+":1"+trouble5); map4.put(trouble4, tempList); } } int j=1; StringBuffer htmlBuffer=new StringBuffer(); for (Entry> entry : map1.entrySet()) { String trouble1=entry.getKey(); List trouble2=entry.getValue(); htmlBuffer.append(" "); htmlBuffer.append("
  • "); for(String temp2:trouble2){//循环第二层Key htmlBuffer.append(""); if(map2.get(temp2)!=null){ List trouble3=map2.get(temp2); htmlBuffer.append("
    • "); for(String temp3:trouble3){//第三次Key htmlBuffer.append(""); if(map3.get(temp3)!=null){ List trouble4=map3.get(temp3); htmlBuffer.append("
      • "); for(String temp4:trouble4){ htmlBuffer.append(""); if(map4.get(temp4)!=null){ List touble5=map4.get(temp4); htmlBuffer.append("
        • "); for(String temp5:touble5){ String[] t=new String[2]; t=temp5.split(":1"); htmlBuffer.append(""); }htmlBuffer.append("
        ");//4 } }htmlBuffer.append("
      ");//4 } j++; }htmlBuffer.append("
    ");//3 } }htmlBuffer.append("
");//2 //j++; }*/ } /**张璐2015-10-30 * 用于添加新的故障信息 */ @ResponseBody @RequestMapping("/addNewTrouble") public String[] addNewTrouble(EqmTroubleInfoBean troubleBean){ String des = troubleBean.getDescription(); String pid=troubleBean.getParent_id(); String[] codeId=new String[50]; if(StringUtil.notNull(pid)&&StringUtil.notNull(des)){ List list = troubleService.queryTroubleInfo(troubleBean); if(list.size()>0){ int fcode=list.size()+1; String fiveCode=""+fcode; String id=UUID.randomUUID().toString(); troubleService.addNewTrouble(des, fiveCode, pid,id); codeId[0]=fiveCode; codeId[1]=id; return codeId; } } return null; } @ResponseBody @RequestMapping("/deleteNewTrouble") public void deleteNewTrouble(String id){ String ids[]=id.split(","); for(int i=0;i