cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
package cn.ksource.web.controller.business.pages.customerconfig.question;
 
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.question.QuestionflowFacade;
import cn.ksource.web.facade.workflow.TemplateFacade;
/**
 * 问题流转策略控制器
 * @author liusen
 *
 */
@SuppressWarnings("unchecked")
@Controller
@RequestMapping("/business/pages/customerconfig/questionflow")
public class QuestionflowController {
    @Autowired
    private QuestionflowFacade questionflowFacade; 
    /**
     * 问题管理流转策略模板配置
     */
    @RequestMapping(value="questionNodeDeal.html",method=RequestMethod.GET)
    public ModelAndView questionNodeDealConfig(HttpServletRequest request,HttpServletResponse response) {
        ModelAndView modelAndView = new ModelAndView("/business/pages/customerconfig/question/questionNodeDeal");
        Map<String, String> param = ParamsMapUtil.getParameterMap(request);
        //客户编号      
        String customerId = param.get("customerId");
        String edit = param.get("edit");
        
        Map config = questionflowFacade.queryQuestionNodeDealConfig(customerId);
        
        
        
        Map closejd = new HashMap();
        Map backjd = new HashMap();
        Map wtfq = new HashMap();
        Map wtsl = new HashMap();
        Map wtsh = new HashMap();
        Map wtzd = new HashMap();
        Map fasp = new HashMap();
        Map fass = new HashMap();
        Map wthg = new HashMap();
        
        if(null!=config && config.size()>0) {
            String close = ConvertUtil.obj2StrBlank(config.get("CLOSEJD"));
            if(StringUtil.notEmpty(close)) {
                List<Map> closes = JsonUtil.json2List(close);
                for(Map map : closes) {
                    closejd.put(map.get("nodeId"), map);
                }
            }
            
            String back = ConvertUtil.obj2StrBlank(config.get("GOBACKJD"));
            if(StringUtil.notEmpty(back)) {
                List<Map> backs = JsonUtil.json2List(back);
                for(Map map : backs) {
                    backjd.put(map.get("nodeId"), map);
                }
            }
            
            String fq = ConvertUtil.obj2StrBlank(config.get("WTFQ"));
            if(StringUtil.notEmpty(fq)) {
                List<Map> fqs = JsonUtil.json2List(fq);
                for(Map map : fqs) {
                    wtfq.put(map.get("nodeId"), map);
                }
            }
            
            String sl = ConvertUtil.obj2StrBlank(config.get("WTSL"));
            if(StringUtil.notEmpty(sl)) {
                List<Map> sls = JsonUtil.json2List(sl);
                for(Map map : sls) {
                    wtsl.put(map.get("nodeId"), map);
                }
            }
            
            String sh = ConvertUtil.obj2StrBlank(config.get("WTSH"));
            if(StringUtil.notEmpty(sh)) {
                List<Map> shs = JsonUtil.json2List(sh);
                for(Map map : shs) {
                    wtsh.put(map.get("nodeId"), map);
                }
            }
            
            
            
            String zd = ConvertUtil.obj2StrBlank(config.get("WTZD"));
            if(StringUtil.notEmpty(zd)) {
                List<Map> zds = JsonUtil.json2List(zd);
                for(Map map : zds) {
                    wtzd.put(map.get("nodeId"), map);
                }
            }
            
            
            String sp = ConvertUtil.obj2StrBlank(config.get("FASP"));
            if(StringUtil.notEmpty(sp)) {
                List<Map> sps = JsonUtil.json2List(sp);
                for(Map map : sps) {
                    fasp.put(map.get("nodeId"), map);
                }
            }
            
            String fa = ConvertUtil.obj2StrBlank(config.get("FASS"));
            if(StringUtil.notEmpty(fa)) {
                List<Map> fas = JsonUtil.json2List(fa);
                for(Map map : fas) {
                    fass.put(map.get("nodeId"), map);
                }
            }
            
            String hg = ConvertUtil.obj2StrBlank(config.get("WTHG"));
            if(StringUtil.notEmpty(hg)) {
                List<Map> hgs = JsonUtil.json2List(hg);
                for(Map map : hgs) {
                    wthg.put(map.get("nodeId"), map);
                }
            }
            if(StringUtil.isEmpty(edit)){
                if(ConvertUtil.obj2Integer(config.get("isSelf")) == 1){
                    modelAndView = new ModelAndView("/business/pages/customerconfig/question/questionNodeDeal");
                }else{
                    modelAndView = new ModelAndView("/business/pages/customerconfig/question/questionNodeDealDetail");
                }
            }else{
                modelAndView = new ModelAndView("/business/pages/customerconfig/question/questionNodeDeal");
            }
            
        }else{
            modelAndView.addObject("noresult", 1);
        }
        
        List closejdNode = new ArrayList();
        List backjdNode = new ArrayList();
        List wtfqNode = new ArrayList();
        List wtslNode = new ArrayList();
        List wtshNode = new ArrayList();
        List wtzdNode = new ArrayList();
        List faspNode = new ArrayList();
        List fassNode = new ArrayList();
        List wthgNode = new ArrayList();
        
        
        
        //查询所有节点
        Map<String, String> nodeMap = Constants.questionNode;
        for (Map.Entry<String, String> 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 map6 = new HashMap();
            Map map7 = new HashMap();
            Map map8 = new HashMap();
            Map map9 = new HashMap();
            
            Map map = new HashMap();
            map.put("nodeId", key);
            map.put("nodeName", value);
            
            if(closejd.containsKey(key)) {
                map1.put("type", 1);
            }
            
            if(backjd.containsKey(key)) {
                map8.put("type", 1);
            }
            
            if(wtfq.containsKey(key)) {
                map9.put("type", 1);
            }
            
            if(wtsl.containsKey(key)) {
                map2.put("type", 1);
            }
            
            
            if(wtsh.containsKey(key)) {
                map3.put("type", 1);
            }
            
            if(wtzd.containsKey(key)) {
                map4.put("type", 1);
            }
            
            if(fasp.containsKey(key)) {
                map5.put("type", 1);
            }
            
            if(fass.containsKey(key)) {
                map6.put("type", 1);
            }
            
            if(wthg.containsKey(key)) {
                map7.put("type", 1);
            }
            
            map1.putAll(map);
            map2.putAll(map);
            map3.putAll(map);
            map4.putAll(map);
            map5.putAll(map);
            map6.putAll(map);
            map7.putAll(map);
            map8.putAll(map);
            map9.putAll(map);
            
            
            closejdNode.add(map1);
            wtslNode.add(map2);
            wtshNode.add(map3);
            wtzdNode.add(map4);
            faspNode.add(map5);
            fassNode.add(map6);
            wthgNode.add(map7);
            backjdNode.add(map8);
            wtfqNode.add(map9);
        }
        modelAndView.addObject("closejdNode", closejdNode);
        modelAndView.addObject("backjdNode", backjdNode);
        modelAndView.addObject("wtfqNode", wtfqNode);
        modelAndView.addObject("wtslNode", wtslNode);
        modelAndView.addObject("wtshNode", wtshNode);
        modelAndView.addObject("wtzdNode", wtzdNode);
        modelAndView.addObject("faspNode", faspNode);
        modelAndView.addObject("fassNode", fassNode);
        modelAndView.addObject("wthgNode", wthgNode);
        modelAndView.addObject("config", config);
        
        return modelAndView;
    }
    
    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="questionNodeDeal.html",method=RequestMethod.POST)
    public ModelAndView saveQuestionNodeDealConfig(HttpServletRequest request,HttpServletResponse response) {
        Map<String, String> param = ParamsMapUtil.getParameterMap(request);
        
        String[] wtfq = request.getParameterValues("wtfq");
        if(null!=wtfq && wtfq.length>0) {
            param.put("wtfq",arrayToString(wtfq));
        }else{
            param.put("wtfq","");
        }
        
        String[] wtsl = request.getParameterValues("wtsl");
        if(null!=wtsl && wtsl.length>0) {
            param.put("wtsl",arrayToString(wtsl));
        }else{
            param.put("wtsl","");
        }
        
        
        String[] wtsh = request.getParameterValues("wtsh");
        if(null!=wtsh && wtsh.length>0) {
            param.put("wtsh",arrayToString(wtsh));
        }else{
            param.put("wtsh","");
        }
        
        
        String[] wtzd = request.getParameterValues("wtzd");        
        if(null!=wtzd && wtzd.length>0) {
            param.put("wtzd",arrayToString(wtzd));
        }else{
            param.put("wtzd","");
        }
        
        String[] fasp = request.getParameterValues("fasp");
        if(null!=fasp && fasp.length>0) {
            param.put("fasp",arrayToString(fasp));
        }else{
            param.put("fasp","");
        }
        
        
        String[] fass = request.getParameterValues("fass");
        if(null!=fass && fass.length>0) {
            param.put("fass",arrayToString(fass));
        }else{
            param.put("fass","");
        }
        
         
        String[] wthg = request.getParameterValues("wthg");
        if(null!=wthg && wthg.length>0) {
            param.put("wthg",arrayToString(wthg));
        }else{
            param.put("wthg","");
        }
        
        
        String[] isclose = request.getParameterValues("isclose");
        if(null!=isclose && isclose.length>0) {
            param.put("isclose",arrayToString(isclose));
        }else{
            param.put("isclose","");
        }
        
        
        String[] isback = request.getParameterValues("isback");
        if(null!=isback && isback.length>0) {
            param.put("isback",arrayToString(isback));
        }else{
            param.put("isback","");
        }
        
        questionflowFacade.saveQuestionNodeDealConfig(param);
        //客户编号
        String customerId = param.get("customerId");
        return WebUtil.sysInfoPage(request, "操作成功!",
                "",
                SysInfo.Success,"/business/pages/customerconfig/questionflow/questionNodeDeal.html?customerId="+customerId,null);
    }
    
    @RequestMapping(value="initlc.html",method=RequestMethod.POST)
    public void initlc(HttpServletRequest request,HttpServletResponse response){
        Map<String,String> params = ParamsMapUtil.getParameterMap(request);
        questionflowFacade.updatelc(params);
        WebUtil.write(response, "1");
    }
}