zhoufan 8 maanden geleden
bovenliggende
commit
8e9fd2b901

+ 37 - 0
midware-api/src/main/java/midware/controller/HomeController.java

7
 import midware.entity.input.CodeInput;
7
 import midware.entity.input.CodeInput;
8
 import midware.model.AjaxResult;
8
 import midware.model.AjaxResult;
9
 import midware.service.eslclient.EslCommon;
9
 import midware.service.eslclient.EslCommon;
10
+import midware.service.eslclient.entity.Agent;
10
 import midware.service.eslclient.entity.Channel;
11
 import midware.service.eslclient.entity.Channel;
11
 import midware.service.eslclient.entity.Session;
12
 import midware.service.eslclient.entity.Session;
12
 import midware.service.init.EslClientService;
13
 import midware.service.init.EslClientService;
82
         return Success("",map );
83
         return Success("",map );
83
     }
84
     }
84
 
85
 
86
+    @GetMapping("/esl/del/{type}/{id}")
87
+    public AjaxResult delEsl(@PathVariable int type,@PathVariable String id) {
88
+        Object obj=null;
89
+        switch (type) {
90
+            case 1:
91
+                Agent a = EslCommon.getAgent(id);
92
+                if (a != null) EslCommon.agents.remove(a);
93
+                obj=EslCommon.agents;
94
+                break;
95
+            case 2:
96
+                Channel c=EslCommon.getChanByNumber(id);
97
+                if (c != null) EslCommon.channels.remove(c);
98
+                obj=EslCommon.channels;
99
+                break;
100
+            case 3:
101
+                Session s=EslCommon.getSessionById(id);
102
+                if (s != null) EslCommon.sessions.remove(s);
103
+                obj=EslCommon.sessions;
104
+                break;
105
+            case 4:
106
+                for (List<String> values : EslCommon.groupWaitList.values()) {
107
+                    values.remove(id);
108
+                }
109
+                obj=EslCommon.groupWaitList;
110
+                break;
111
+        }
112
+        return Success("",obj);
113
+    }
114
+
85
     @GetMapping("/midware/{type}")
115
     @GetMapping("/midware/{type}")
86
     public AjaxResult Midware(@PathVariable int type) {
116
     public AjaxResult Midware(@PathVariable int type) {
87
         List<Map<String,Object>> maps=new ArrayList<>();
117
         List<Map<String,Object>> maps=new ArrayList<>();
155
         return result;
185
         return result;
156
     }
186
     }
157
 
187
 
188
+    @GetMapping("/ivr/del/{type}")
189
+    public boolean delIvrXml(@PathVariable Integer type) {
190
+        String key = "ivr:context";
191
+        if (type == 2) key = "ivr:menu";
192
+        return redisHelper.deleteCache(key);
193
+    }
194
+
158
     @GetMapping("/getcode")
195
     @GetMapping("/getcode")
159
     public void GetCode(HttpServletResponse response, CodeInput input) {
196
     public void GetCode(HttpServletResponse response, CodeInput input) {
160
         Map<String, Object> table = SqlRunner.db().selectOne("select table_name,table_comment from information_schema.tables"
197
         Map<String, Object> table = SqlRunner.db().selectOne("select table_name,table_comment from information_schema.tables"

+ 103 - 108
midware-service/src/main/java/midware/service/init/WebSocketService.java

172
                         String DestinationNumber = map.get("DestinationNumber").toString();
172
                         String DestinationNumber = map.get("DestinationNumber").toString();
173
                         String Fix = map.get("Fix") != null ? map.get("Fix").toString() : "";
173
                         String Fix = map.get("Fix") != null ? map.get("Fix").toString() : "";
174
                         param = DestinationNumber + (Fix.equals("") ? "" : "|" + Fix);
174
                         param = DestinationNumber + (Fix.equals("") ? "" : "|" + Fix);
175
-                        if (StringHelper.isNotEmpty(DestinationNumber)) {
176
-                            Agent tAgent = EslCommon.getAgentByExten(DestinationNumber);
177
-                            if (tAgent != null && tAgent.getAgentState() != EslAgentEnum.free.ordinal()) {
178
-                                result.put("Result", "目标坐席忙碌中");
179
-                            } else {
180
-                                agent.setOpType(type);
181
-                                isExec = eslClientService.extenCall(agent.getExten(), DestinationNumber, type + "|" + agentId + "|" + DestinationNumber + "|" + Fix);
182
-                            }
175
+
176
+                        String check = checkTargetNumber(agent.getExten() ,DestinationNumber);
177
+                        if (StringHelper.isEmpty(check)) {
178
+                            agent.setOpType(type);
179
+                            isExec = eslClientService.extenCall(agent.getExten(), DestinationNumber, type + "|" + agentId + "|" + DestinationNumber + "|" + Fix);
180
+                        } else {
181
+                            result.put("Result", check);
183
                         }
182
                         }
184
                     }
183
                     }
185
                     break;
184
                     break;
213
                         String DestinationNumber = map.get("DestinationNumber").toString();
212
                         String DestinationNumber = map.get("DestinationNumber").toString();
214
                         String Fix = map.get("Fix") != null ? map.get("Fix").toString() : "";
213
                         String Fix = map.get("Fix") != null ? map.get("Fix").toString() : "";
215
                         param = DestinationNumber + (Fix.equals("") ? "" : "|" + Fix);
214
                         param = DestinationNumber + (Fix.equals("") ? "" : "|" + Fix);
216
-                        if (StringHelper.isNotEmpty(DestinationNumber)) {
217
-                            if (DestinationNumber.equals(agent.getExten())) {
218
-                                result.put("Result", "目标不能是自己");
215
+
216
+                        String check = checkTargetNumber(agent.getExten(),DestinationNumber);
217
+                        if (StringHelper.isEmpty(check)) {
218
+                            if (chan.getSessionSort() == 1) {//呼出方不可以转移
219
+                                result.put("Result", "主叫不能此操作");
219
                             } else {
220
                             } else {
220
-                                Agent tAgent = EslCommon.getAgentByExten(DestinationNumber);
221
-                                if (tAgent != null && tAgent.getAgentState() != EslAgentEnum.free.ordinal()) {
222
-                                    result.put("Result", "目标坐席忙碌中");
223
-                                } else if (EslCommon.isInSession(DestinationNumber)) {
224
-                                    result.put("Result", "目标号码忙碌中");
225
-                                } else if (chan.getSessionSort() == 1) {//呼出方不可以转移
226
-                                    result.put("Result", "主叫不能此操作");
227
-                                } else {
228
-                                    agent.setOpType(type);
229
-                                    isExec = eslClientService.transfer(chan.getSessionId(), agent.getExten(), DestinationNumber, type + "|" + agentId + "|" + DestinationNumber+ "|" + Fix);
230
-                                }
221
+                                agent.setOpType(type);
222
+                                isExec = eslClientService.transfer(chan.getSessionId(), agent.getExten(), DestinationNumber, type + "|" + agentId + "|" + DestinationNumber + "|" + Fix);
231
                             }
223
                             }
224
+                        } else {
225
+                            result.put("Result", check);
232
                         }
226
                         }
233
                     }
227
                     }
234
                     break;
228
                     break;
238
                         String DestinationNumber = map.get("DestinationNumber").toString();
232
                         String DestinationNumber = map.get("DestinationNumber").toString();
239
                         String Fix = map.get("Fix") != null ? map.get("Fix").toString() : "";
233
                         String Fix = map.get("Fix") != null ? map.get("Fix").toString() : "";
240
                         param = DestinationNumber + (Fix.equals("") ? "" : "|" + Fix);
234
                         param = DestinationNumber + (Fix.equals("") ? "" : "|" + Fix);
241
-                        if (StringHelper.isNotEmpty(DestinationNumber)) {
242
-                            if (DestinationNumber.equals(agent.getExten())) {
243
-                                result.put("Result", "目标不能是自己");
235
+
236
+                        String check = checkTargetNumber(agent.getExten(), DestinationNumber);
237
+                        if (StringHelper.isEmpty(check)) {
238
+                            if (chan.getSessionSort() == 1) {//呼出方不可以转移
239
+                                result.put("Result", "主叫不能此操作");
244
                             } else {
240
                             } else {
245
-                                Agent tAgent = EslCommon.getAgentByExten(DestinationNumber);
246
-                                if (tAgent != null && tAgent.getAgentState() != EslAgentEnum.free.ordinal()) {
247
-                                    result.put("Result", "目标坐席忙碌中");
248
-                                } else if (EslCommon.isInSession(DestinationNumber)) {
249
-                                    result.put("Result", "目标号码忙碌中");
250
-                                } else if (chan.getSessionSort() == 1) {//呼出方不可以协商
251
-                                    result.put("Result", "主叫不能此操作");
252
-                                } else {
253
-                                    agent.setOpType(type);
254
-                                    isExec = eslClientService.consult(chan.getSessionId(), agent.getExten(), DestinationNumber, type + "|" + agentId + "|" + DestinationNumber+ "|" + Fix);
255
-                                }
241
+                                agent.setOpType(type);
242
+                                isExec = eslClientService.consult(chan.getSessionId(), agent.getExten(), DestinationNumber, type + "|" + agentId + "|" + DestinationNumber + "|" + Fix);
256
                             }
243
                             }
244
+                        } else {
245
+                            result.put("Result", check);
257
                         }
246
                         }
258
                     }
247
                     }
259
                     break;
248
                     break;
272
                         String DestinationNumber = map.get("DestinationNumber").toString();
261
                         String DestinationNumber = map.get("DestinationNumber").toString();
273
                         String Fix = map.get("Fix") != null ? map.get("Fix").toString() : "";
262
                         String Fix = map.get("Fix") != null ? map.get("Fix").toString() : "";
274
                         param = DestinationNumber + (Fix.equals("") ? "" : "|" + Fix);
263
                         param = DestinationNumber + (Fix.equals("") ? "" : "|" + Fix);
275
-                        if (StringHelper.isNotEmpty(DestinationNumber)) {
276
-                            if (DestinationNumber.equals(agent.getExten())) {
277
-                                result.put("Result", "目标不能是自己");
278
-                            } else {
279
-                                Agent tAgent = EslCommon.getAgentByExten(DestinationNumber);
280
-                                if (tAgent != null && tAgent.getAgentState() != EslAgentEnum.free.ordinal()) {
281
-                                    result.put("Result", "目标坐席忙碌中");
282
-                                } else if (EslCommon.isInSession(DestinationNumber)) {
283
-                                    result.put("Result", "目标号码忙碌中");
284
-                                } else {
285
-                                    agent.setOpType(type);
286
-                                    String mute = map.get("Mute") != null ? map.get("Mute").toString() : "";
287
-                                    EslCommon.getSessionById(chan.getSessionId()).setMeetingMute(mute.equals("true"));
288
-                                    isExec = eslClientService.callJoinMeeting(agent.getExten(), DestinationNumber, chan.getSessionId(), type + "|" + agentId + "|" + DestinationNumber+ "|" + Fix);
289
-                                }
290
-                            }
264
+
265
+                        String check = checkTargetNumber(agent.getExten(), DestinationNumber);
266
+                        if (StringHelper.isEmpty(check)) {
267
+                            agent.setOpType(type);
268
+                            String mute = map.get("Mute") != null ? map.get("Mute").toString() : "";
269
+                            EslCommon.getSessionById(chan.getSessionId()).setMeetingMute(mute.equals("true"));
270
+                            isExec = eslClientService.callJoinMeeting(agent.getExten(), DestinationNumber, chan.getSessionId(), type + "|" + agentId + "|" + DestinationNumber+ "|" + Fix);
271
+                        } else {
272
+                            result.put("Result", check);
291
                         }
273
                         }
292
                     }
274
                     }
293
                     break;
275
                     break;
348
                         String TargetAgentID = map.get("TargetAgentID").toString();
330
                         String TargetAgentID = map.get("TargetAgentID").toString();
349
                         param = TargetAgentID;
331
                         param = TargetAgentID;
350
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
332
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
351
-                            if (TargetAgentID.equals(agentId)) {
352
-                                result.put("Result", "目标不能是自己");
353
-                            } else {
354
-                                Agent tAgent = EslCommon.getAgent(TargetAgentID);
355
-                                String check = checkTargetAgentTalk(tAgent);
356
-                                if (StringHelper.isEmpty(check)) {
357
-                                    Channel tchan = EslCommon.getChanByExten(tAgent.getExten());
358
-                                    if (tchan != null && StringHelper.isNotEmpty(tchan.getSessionId())) {
359
-                                        agent.setOpType(type);
360
-                                        isExec = eslClientService.listen(agent.getExten(),tchan.getNumber(), tchan.getSessionId(), type + "|" + agentId + "|" + agent.getExten());
361
-                                    }
362
-                                } else {
363
-                                    result.put("Result", check);
333
+                            Agent tAgent = EslCommon.getAgent(TargetAgentID);
334
+                            String check = checkTargetAgentTalk(tAgent);
335
+                            if (StringHelper.isEmpty(check)) {
336
+                                Channel tchan = EslCommon.getChanByExten(tAgent.getExten());
337
+                                if (tchan != null && StringHelper.isNotEmpty(tchan.getSessionId())) {
338
+                                    agent.setOpType(type);
339
+                                    isExec = eslClientService.listen(agent.getExten(),tchan.getNumber(), tchan.getSessionId(), type + "|" + agentId + "|" + agent.getExten());
364
                                 }
340
                                 }
341
+                            } else {
342
+                                result.put("Result", check);
365
                             }
343
                             }
366
                         }
344
                         }
367
                     }
345
                     }
372
                         String TargetAgentID = map.get("TargetAgentID").toString();
350
                         String TargetAgentID = map.get("TargetAgentID").toString();
373
                         param = TargetAgentID;
351
                         param = TargetAgentID;
374
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
352
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
375
-                            if (TargetAgentID.equals(agentId)) {
376
-                                result.put("Result", "目标不能是自己");
377
-                            } else {
378
-                                Agent tAgent = EslCommon.getAgent(TargetAgentID);
379
-                                String check = checkTargetAgentTalk(tAgent);
380
-                                if (StringHelper.isEmpty(check)) {
381
-                                    Channel tchan = EslCommon.getChanByExten(tAgent.getExten());
382
-                                    if (tchan != null && StringHelper.isNotEmpty(tchan.getSessionId())) {
383
-                                        agent.setOpType(type);
384
-                                        String sid = tchan.getSessionId();
385
-                                        isExec = eslClientService.insert(agent.getExten(), tchan.getNumber(), sid, type + "|" + agentId + "|" + agent.getExten());
386
-                                    }
387
-                                } else {
388
-                                    result.put("Result", check);
353
+                            Agent tAgent = EslCommon.getAgent(TargetAgentID);
354
+                            String check = checkTargetAgentTalk(tAgent);
355
+                            if (StringHelper.isEmpty(check)) {
356
+                                Channel tchan = EslCommon.getChanByExten(tAgent.getExten());
357
+                                if (tchan != null && StringHelper.isNotEmpty(tchan.getSessionId())) {
358
+                                    agent.setOpType(type);
359
+                                    String sid = tchan.getSessionId();
360
+                                    isExec = eslClientService.insert(agent.getExten(), tchan.getNumber(), sid, type + "|" + agentId + "|" + agent.getExten());
389
                                 }
361
                                 }
362
+                            } else {
363
+                                result.put("Result", check);
390
                             }
364
                             }
391
                         }
365
                         }
392
                     }
366
                     }
397
                         String TargetAgentID = map.get("TargetAgentID").toString();
371
                         String TargetAgentID = map.get("TargetAgentID").toString();
398
                         param = TargetAgentID;
372
                         param = TargetAgentID;
399
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
373
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
400
-                            if (TargetAgentID.equals(agentId)) {
401
-                                result.put("Result", "目标不能是自己");
402
-                            } else {
403
-                                Agent tAgent = EslCommon.getAgent(TargetAgentID);
404
-                                String check = checkTargetAgentTalk(tAgent);
405
-                                if (StringHelper.isEmpty(check)) {
406
-                                    Channel tchan = EslCommon.getChanByExten(tAgent.getExten());
407
-                                    if (tchan != null && StringHelper.isNotEmpty(tchan.getSessionId())) {
408
-                                        agent.setOpType(type);
409
-                                        String sid = tchan.getSessionId();
410
-                                        Channel channel = EslCommon.getFirstChanBySessionId(sid);
411
-                                        isExec = eslClientService.intercept(agent.getExten(), tAgent.getExten(), channel.getChanId(), sid, type + "|" + agentId + "|" + agent.getExten());
412
-                                    }
413
-                                } else {
414
-                                    result.put("Result", check);
374
+                            Agent tAgent = EslCommon.getAgent(TargetAgentID);
375
+                            String check = checkTargetAgentTalk(tAgent);
376
+                            if (StringHelper.isEmpty(check)) {
377
+                                Channel tchan = EslCommon.getChanByExten(tAgent.getExten());
378
+                                if (tchan != null && StringHelper.isNotEmpty(tchan.getSessionId())) {
379
+                                    agent.setOpType(type);
380
+                                    String sid = tchan.getSessionId();
381
+                                    Channel channel = EslCommon.getFirstChanBySessionId(sid);
382
+                                    isExec = eslClientService.intercept(agent.getExten(), tAgent.getExten(), channel.getChanId(), sid, type + "|" + agentId + "|" + agent.getExten());
415
                                 }
383
                                 }
384
+                            } else {
385
+                                result.put("Result", check);
416
                             }
386
                             }
417
                         }
387
                         }
418
                     }
388
                     }
422
                         String TargetAgentID = map.get("TargetAgentID").toString();
392
                         String TargetAgentID = map.get("TargetAgentID").toString();
423
                         param = TargetAgentID;
393
                         param = TargetAgentID;
424
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
394
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
425
-                            if (TargetAgentID.equals(agentId)) {
426
-                                result.put("Result", "目标不能是自己");
427
-                            } else {
428
-                                Agent tAgent = EslCommon.getAgent(TargetAgentID);
429
-                                String check = checkTargetAgentTalk(tAgent);
430
-                                if (StringHelper.isEmpty(check)) {
431
-                                    Channel tchan = EslCommon.getChanByExten(tAgent.getExten());
432
-                                    if (tchan != null && StringHelper.isNotEmpty(tchan.getSessionId())) {
433
-                                        isExec = eslClientService.kill(tchan.getSessionId(),type + "|" + agentId);
434
-                                    }
435
-                                } else {
436
-                                    result.put("Result", check);
395
+                            Agent tAgent = EslCommon.getAgent(TargetAgentID);
396
+                            String check = checkTargetAgentTalk(tAgent);
397
+                            if (StringHelper.isEmpty(check)) {
398
+                                Channel tchan = EslCommon.getChanByExten(tAgent.getExten());
399
+                                if (tchan != null && StringHelper.isNotEmpty(tchan.getSessionId())) {
400
+                                    isExec = eslClientService.kill(tchan.getSessionId(),type + "|" + agentId);
437
                                 }
401
                                 }
402
+                            } else {
403
+                                result.put("Result", check);
438
                             }
404
                             }
439
                         }
405
                         }
440
                     }
406
                     }
542
         String result = "";
508
         String result = "";
543
         if (agent == null) {
509
         if (agent == null) {
544
             result = "目标坐席未签入";
510
             result = "目标坐席未签入";
545
-        } else if (agent.getAgentState() != EslAgentEnum.talking.ordinal()) {
546
-            result = "目标坐席未通话";
511
+        } else {
512
+            if (agent.getAgent().equals(agentId)) {
513
+                result = "目标不能是自己";
514
+            }else if (agent.getAgentState() != EslAgentEnum.talking.ordinal()) {
515
+                result = "目标坐席未通话";
516
+            }
517
+        }
518
+        return result;
519
+    }
520
+
521
+    //判断目标号码是否可以呼出
522
+    private String checkTargetNumber(String exten,String num) {
523
+        String result = "";
524
+        if (StringHelper.isEmpty(num)) {
525
+            result = "目标号码不能为空";
526
+        } else {
527
+            if (exten.equals(num)) {
528
+                result = "目标不能是自己";
529
+            } else {
530
+                Channel chan = EslCommon.getChanByNumber(num);
531
+                if (chan != null) {
532
+                    if (!chan.getSessionId().equals("")) {
533
+                        result = "目标号码忙碌中";
534
+                    } else if (chan.getType() == 1) {//坐席
535
+                        Agent tAgent = EslCommon.getAgentByExten(num);
536
+                        if (tAgent != null && tAgent.getAgentState() != EslAgentEnum.free.ordinal()) {
537
+                            result = "目标坐席忙碌中";
538
+                        }
539
+                    }
540
+                }
541
+            }
547
         }
542
         }
548
         return result;
543
         return result;
549
     }
544
     }