zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
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<EqmTroubleInfoBean> list =  troubleService.queryTroubleInfo(troubleBean);
            StringBuffer htmlBuffer=new StringBuffer();
            if(list.size()>0){
                for(int i1=0;i1<list.size();i1++){
                    String type1=list.get(i1).getType();
                    String description1=list.get(i1).getDescription();
                    String id1=list.get(i1).getId();
                    String code1=list.get(i1).getCode();
                    if(type1.equals("1")){
                        htmlBuffer.append("<div class='tree ce_ceng_close' style='margin-top:10px'><a href='javascript:void(0);'>"+description1+"</a></div> ");
                        htmlBuffer.append("<ul class='node' ><li>");
                    for(int i2=0;i2<list.size();i2++){
                        String type2=list.get(i2).getType();
                        String description2=list.get(i2).getDescription();
                        String parent_id2=list.get(i2).getParent_id();
                        String id2=list.get(i2).getId();
                        String code2=list.get(i2).getCode();
                        if(type2.equals("2")&&parent_id2.equals(id1)){
                            htmlBuffer.append("<div class='tree ce_ceng_close' style='margin-top:10px'><a href='javascript:void(0);'>"+description2+"</a></div>");
                            htmlBuffer.append("<ul class='node' ><li>");
                            for(int i3=0;i3<list.size();i3++){
                                String type3=list.get(i3).getType();
                                String description3=list.get(i3).getDescription();
                                String parent_id3=list.get(i3).getParent_id();
                                String id3=list.get(i3).getId();
                                String code3=list.get(i3).getCode();
                                if(type3.equals("3")&&parent_id3.equals(id2)){
                                    htmlBuffer.append("<div class='tree'  style='margin-top:10px'><a href='javascript:void(0);'>"+description3+"</a></div>");
                                    htmlBuffer.append("<ul class='node' ><li>");
                                    for(int i4=0;i4<list.size();i4++){
                                        String type4=list.get(i4).getType();
                                        String description4=list.get(i4).getDescription();
                                        String parent_id4=list.get(i4).getParent_id();
                                        String id4=list.get(i4).getId();
                                        String code4=list.get(i4).getCode();
                                        if(type4.equals("4")&&parent_id4.equals(id3)){
                                            htmlBuffer.append("<div class='tree'  style='margin-top:10px' onclick=addNewCode('"+code3+"','"+code4+"','"+id4+"');><a href='javascript:void(0);'>"+description4+"</a></div>");
                                            htmlBuffer.append("<ul class='node' ><li>");
                                            for(int i5=0;i5<list.size();i5++){
                                                String type5=list.get(i5).getType();
                                                String description5=list.get(i5).getDescription();
                                                String parent_id5=list.get(i5).getParent_id();
                                                String id5=list.get(i5).getId();
                                                String code5=list.get(i5).getCode();
                                                if(type5.equals("5")&&parent_id5.equals(id4)){
                                                    htmlBuffer.append("<div class='tree'  onclick=save('"+code3+'-'+code4+'-'+code5+"','"+description5+"'); style='margin-top:10px; width:210px;'><a href='javascript:void(0);'>"+description5+"</a></div>");
                                                }
                                            }htmlBuffer.append("</li></ul>");
                                        }
                                    }htmlBuffer.append("</li></ul>");
                                }
                            }htmlBuffer.append("</li></ul>");
                        }
                    }htmlBuffer.append("</li></ul>");
                    
                  }
                }
            }
            return htmlBuffer.toString();
        /*Map<String, List<String>> map1=new HashMap<String,List<String>>();//一级标题键,值为二级标题的键,以下以此类推
        Map<String, List<String>> map2=new HashMap<String,List<String>>();
        Map<String, List<String>> map3=new HashMap<String,List<String>>();
        Map<String, List<String>> map4=new HashMap<String,List<String>>();
        
        List<EqmTroubleInfoBean> 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<String> tempList=map1.get(eqpDes);
                if(!tempList.contains(trouble2)){
                    tempList.add(trouble2);
                    map1.put(eqpDes, tempList);
                }
            }else{
                List<String> tempList=new ArrayList<String>();
                tempList.add(trouble2);
                map1.put(eqpDes, tempList);
            }
            
             
            if(map2.get(trouble2)!=null){
                List<String> tempList=map2.get(trouble2);
                if(!tempList.contains(trouble3)){
                    tempList.add(trouble3);
                    map2.put(trouble2, tempList);
                }
            }else{
                List<String> tempList=new ArrayList<String>();
                tempList.add(trouble3);
                map2.put(trouble2, tempList);
            }
            
            if(map3.get(trouble3)!=null){
                List<String> tempList=map3.get(trouble3);
                if(!tempList.contains(trouble4)){
                    tempList.add(trouble4);
                    map3.put(trouble3, tempList);
                }
            }else{
                List<String> tempList=new ArrayList<String>();
                tempList.add(trouble4);
                map3.put(trouble3,tempList);
            }
            
            if(map4.get(trouble4)!=null){
                List<String> tempList=map4.get(trouble4);
                if(!tempList.contains(trouble5)){
                    tempList.add(code+":1"+trouble5);
                    map4.put(trouble4, tempList);
                }
            }else{
                List<String> tempList=new ArrayList<String>();
                tempList.add(code+":1"+trouble5);
                map4.put(trouble4, tempList);
            }
        }
        int j=1;
        StringBuffer htmlBuffer=new StringBuffer();
        
        for (Entry<String, List<String>> entry : map1.entrySet()) {
            String trouble1=entry.getKey();
            List<String> trouble2=entry.getValue();
            htmlBuffer.append("<div class='tree ce_ceng_close' style='margin-top:10px'><a href='javascript:void(0);'>"+trouble1+"</a></div> ");
            htmlBuffer.append("<ul class='node' ><li>");
            for(String temp2:trouble2){//循环第二层Key
                htmlBuffer.append("<div class='tree ce_ceng_close' style='margin-top:10px'><a href='javascript:void(0);'>"+temp2+"</a></div>");
                if(map2.get(temp2)!=null){
                    List<String> trouble3=map2.get(temp2);
                    htmlBuffer.append("<ul class='node' ><li>");
                    for(String temp3:trouble3){//第三次Key
                        htmlBuffer.append("<div class='tree' id='tem3"+j+"' style='margin-top:10px'><a href='javascript:void(0);'>"+temp3+"</a></div>");
                        if(map3.get(temp3)!=null){
                            List<String> trouble4=map3.get(temp3);
                            htmlBuffer.append("<ul class='node'> <li>");
                            for(String temp4:trouble4){
                                htmlBuffer.append("<div class='tree'  style='margin-top:10px' onclick=fourCode('"+j+"','"+temp4+"')><a href='javascript:void(0);'>"+temp4+"</a></div>");
                                if(map4.get(temp4)!=null){
                                    List<String> touble5=map4.get(temp4);
                                    htmlBuffer.append("<ul class='node'><li>");
                                    for(String temp5:touble5){
                                        String[] t=new String[2];
                                        t=temp5.split(":1");
                                        htmlBuffer.append("<div class='tree'  onclick=save('"+t[0]+"','"+t[1]+"'); style='margin-top:10px;'><a href='javascript:void(0);'>"+t[1]+"</a></div>");
                                    }htmlBuffer.append("</li></ul>");//4    
                                }
                                
                            }htmlBuffer.append("</li></ul>");//4
                        }
                        j++;
                    }htmlBuffer.append("</li></ul>");//3
                }
                
                
            }htmlBuffer.append("</li></ul>");//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<EqmTroubleInfoBean> 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<ids.length;i++){
            troubleService.deleteNewTrouble(ids[i]);
        }
        
    }
}