zhoufan 9 mēneši atpakaļ
vecāks
revīzija
c976e3b657

+ 1 - 1
midware-service/src/main/java/midware/service/eslclient/EslEventListenerEvent.java

@@ -365,7 +365,7 @@ public class EslEventListenerEvent implements IEslEventListener {
365 365
                             if (agent1 != null) agent1.setAgentState(EslAgentEnum.talking.ordinal());
366 366
                         }
367 367
                         break;
368
-                    case CHANNEL_HANGUP_COMPLETE:
368
+                    case CHANNEL_HANGUP:
369 369
                         if (chan != null) {
370 370
                             String sid = chan.getSessionId();
371 371
                             if (session == null) session = EslCommon.getSessionById(sid);

+ 69 - 68
midware-service/src/main/java/midware/service/init/EslClientService.java

@@ -56,10 +56,10 @@ public class EslClientService {
56 56
                 try {
57 57
                     if (EslCommon.agents.size() > 0) {
58 58
                         for (Agent a : EslCommon.agents) {
59
-                            logout(a.getAgent(), a.getGroup(),"");
59
+                            logout(a.getAgent(), a.getGroup(), "");
60 60
                             a.setAgentState(EslAgentEnum.logout.ordinal());
61 61
                         }
62
-                        EslCommon.agents=new ArrayList<>();
62
+                        EslCommon.agents = new ArrayList<>();
63 63
                     }
64 64
 
65 65
                     client.connect(config.getHost(), config.getPort(), config.getPassword(), config.getTimeout());
@@ -80,8 +80,8 @@ public class EslClientService {
80 80
                     //扫描已注册的分机
81 81
                     scanExten();
82 82
                     //设置中间件根目录
83
-                    String path=new File("").getAbsolutePath();
84
-                    client.sendAsyncApiCommand(EslCommandEnum.global_setvar.name(), "md_base_dir=" +path );
83
+                    String path = new File("").getAbsolutePath();
84
+                    client.sendAsyncApiCommand(EslCommandEnum.global_setvar.name(), "md_base_dir=" + path);
85 85
                 } catch (Exception e) {
86 86
                     log.error("fs reConnect Exception", e);
87 87
                 }
@@ -94,8 +94,8 @@ public class EslClientService {
94 94
             //扫描已注册的分机
95 95
             scanExten();
96 96
             //设置中间件根目录
97
-            String path=new File("").getAbsolutePath();
98
-            client.sendAsyncApiCommand(EslCommandEnum.global_setvar.name(), "md_base_dir=" +path );
97
+            String path = new File("").getAbsolutePath();
98
+            client.sendAsyncApiCommand(EslCommandEnum.global_setvar.name(), "md_base_dir=" + path);
99 99
         }
100 100
 
101 101
         EslCommon.checkAuth();
@@ -105,10 +105,10 @@ public class EslClientService {
105 105
     public void destroy() {
106 106
         if (EslCommon.agents.size() > 0) {
107 107
             for (Agent a : EslCommon.agents) {
108
-                logout(a.getAgent(), a.getGroup(),"");
108
+                logout(a.getAgent(), a.getGroup(), "");
109 109
                 a.setAgentState(EslAgentEnum.logout.ordinal());
110 110
             }
111
-            EslCommon.agents=new ArrayList<>();
111
+            EslCommon.agents = new ArrayList<>();
112 112
         }
113 113
     }
114 114
 
@@ -182,7 +182,7 @@ public class EslClientService {
182 182
     }
183 183
 
184 184
     //坐席签入
185
-    public boolean login(String agent, String ext, String group,String action) {
185
+    public boolean login(String agent, String ext, String group, String action) {
186 186
         String result = "";
187 187
         try {
188 188
             String command = EslCommandEnum.callcenter_config.name();
@@ -216,9 +216,9 @@ public class EslClientService {
216 216
             // 添加梯队到队列等价于坐席组
217 217
             group = StringHelper.isEmpty(group) ? "ZXZ" : group;
218 218
             arg = " tier add " + group + " " + agent + " 1 1"
219
-                    +"\r\nJob-UUID:" + action + "|"+ System.currentTimeMillis();
219
+                    + "\r\nJob-UUID:" + action + "|" + System.currentTimeMillis();
220 220
             client.sendAsyncApiCommand(command, arg);
221
-            
221
+
222 222
         } catch (Exception e) {
223 223
             log.error(agent + "|" + ext + "|" + group + " 签入失败", e);
224 224
         }
@@ -226,7 +226,7 @@ public class EslClientService {
226 226
     }
227 227
 
228 228
     //坐席签出
229
-    public boolean logout(String agent, String group,String action) {
229
+    public boolean logout(String agent, String group, String action) {
230 230
         String result = "";
231 231
         try {
232 232
             String command = EslCommandEnum.callcenter_config.name();
@@ -236,9 +236,9 @@ public class EslClientService {
236 236
             // 删除梯队
237 237
             group = StringHelper.isEmpty(group) ? "ZXZ" : group;
238 238
             arg = " tier del " + group + " " + agent
239
-                    +"\r\nJob-UUID:" + action + "|"+ System.currentTimeMillis();
239
+                    + "\r\nJob-UUID:" + action + "|" + System.currentTimeMillis();
240 240
             client.sendAsyncApiCommand(command, arg);
241
-            
241
+
242 242
         } catch (Exception e) {
243 243
             log.error(agent + "|" + group + " 签出失败", e);
244 244
         }
@@ -246,15 +246,15 @@ public class EslClientService {
246 246
     }
247 247
 
248 248
     //坐席置忙/置闲
249
-    public boolean setWork(String agent, boolean isWork,String action) {
249
+    public boolean setWork(String agent, boolean isWork, String action) {
250 250
         String result = "";
251 251
         try {
252 252
             String command = EslCommandEnum.callcenter_config.name();
253 253
             String state = isWork ? "'Available'" : "'On Break'";
254 254
             String arg = " agent set status " + agent + " " + state
255
-                    +"\r\nJob-UUID:" + action + "|"+ System.currentTimeMillis();
255
+                    + "\r\nJob-UUID:" + action + "|" + System.currentTimeMillis();
256 256
             result = client.sendAsyncApiCommand(command, arg);
257
-            
257
+
258 258
         } catch (Exception e) {
259 259
             String state = isWork ? "置闲" : "置忙";
260 260
             log.error(agent + "|" + isWork + " " + state + "失败", e);
@@ -263,12 +263,12 @@ public class EslClientService {
263 263
     }
264 264
 
265 265
     //删除
266
-    public boolean kill(String chanId,String action) {
266
+    public boolean kill(String chanId, String action) {
267 267
         String result = "";
268 268
         try {
269 269
             result = client.sendAsyncApiCommand(EslCommandEnum.uuid_kill.name(), chanId
270 270
                     + "\r\nJob-UUID: " + action + "|" + System.currentTimeMillis());
271
-            
271
+
272 272
         } catch (Exception e) {
273 273
             log.error(chanId + " 删除失败", e);
274 274
         }
@@ -280,16 +280,16 @@ public class EslClientService {
280 280
         String result = "";
281 281
         try {
282 282
             String command = EslCommandEnum.uuid_broadcast.name();
283
-            String arg = chanId + " hangup::NORMAL_CLEARING" ;
283
+            String arg = chanId + " hangup::NORMAL_CLEARING";
284 284
             result = client.sendAsyncApiCommand(command, arg);
285 285
         } catch (Exception e) {
286
-            log.error( chanId + " app挂断失败", e);
286
+            log.error(chanId + " app挂断失败", e);
287 287
         }
288 288
         return !result.equals("");
289 289
     }
290 290
 
291 291
     //分机呼叫
292
-    public boolean extenCall(String callerNum, String calleeNum,String action) {
292
+    public boolean extenCall(String callerNum, String calleeNum, String action) {
293 293
         String result = "";
294 294
         try {
295 295
             String fix = action.substring(action.lastIndexOf("|") + 1);
@@ -313,12 +313,12 @@ public class EslClientService {
313 313
     }
314 314
 
315 315
     //呼叫2个号码并桥接
316
-    public boolean bridgeNum(String callerNum, String calleeNum,String action) {
316
+    public boolean bridgeNum(String callerNum, String calleeNum, String action) {
317 317
         String result = "";
318 318
         try {
319 319
             String command = EslCommandEnum.originate.name();
320 320
             String arg = " {call_caller=" + callerNum + ",call_callee=" + calleeNum + ",call_type=2"
321
-                    + getOrigination(calleeNum) +"}"+ getCallString(callerNum)
321
+                    + getOrigination(calleeNum) + "}" + getCallString(callerNum)
322 322
                     + " &bridge({call_caller=" + callerNum + getOrigination(calleeNum)
323 323
                     + "}" + getCallString(calleeNum) + ")"
324 324
                     + "\r\nJob-UUID: " + action + "|" + System.currentTimeMillis();
@@ -331,16 +331,16 @@ public class EslClientService {
331 331
     }
332 332
 
333 333
     //协商呼叫
334
-    public boolean consult(String chanId, String callerNum,String calleeNum,String action) {
334
+    public boolean consult(String chanId, String callerNum, String calleeNum, String action) {
335 335
         String result = "";
336 336
         try {
337
-            String fix = action.substring(action.lastIndexOf("|")+1);
337
+            String fix = action.substring(action.lastIndexOf("|") + 1);
338 338
             String command = EslCommandEnum.uuid_broadcast.name();
339 339
             String arg = chanId + " att_xfer::{origination_caller_id_number=12356,record_concat_video=true"
340 340
                     + ",call_caller=" + callerNum + ",call_callee=" + calleeNum.substring(fix.length()) + "}" + getCallString(calleeNum)
341 341
                     + "\r\nJob-UUID: " + action + "|" + System.currentTimeMillis();
342 342
             result = client.sendAsyncApiCommand(command, arg);
343
-            
343
+
344 344
         } catch (Exception e) {
345 345
             log.error(chanId + "|" + calleeNum + " 协商呼叫失败", e);
346 346
         }
@@ -348,7 +348,7 @@ public class EslClientService {
348 348
     }
349 349
 
350 350
     //强插
351
-    public boolean insert(String callerNum,String calleeNum, String sessionId,String action) {
351
+    public boolean insert(String callerNum, String calleeNum, String sessionId, String action) {
352 352
         String result = "";
353 353
         try {
354 354
             String command = EslCommandEnum.originate.name();
@@ -363,7 +363,7 @@ public class EslClientService {
363 363
     }
364 364
 
365 365
     //强截
366
-    public boolean intercept(String callerNum,String calleeNum, String chanId,String sessionId,String action) {
366
+    public boolean intercept(String callerNum, String calleeNum, String chanId, String sessionId, String action) {
367 367
         String result = "";
368 368
         try {
369 369
             Session session = EslCommon.getSessionById(sessionId);
@@ -380,15 +380,15 @@ public class EslClientService {
380 380
     }
381 381
 
382 382
     //监听
383
-    public boolean listen(String callerNum,String calleeNum, String sessionId,String action) {
383
+    public boolean listen(String callerNum, String calleeNum, String sessionId, String action) {
384 384
         String result = "";
385 385
         try {
386 386
             String command = EslCommandEnum.originate.name();
387
-            String arg = " {origination_caller_id_number=" + callerNum+ ",cc_member_session_uuid=" + sessionId
388
-                    + ",absolute_codec_string='PCMA,PCMU',call_callee=" + calleeNum+ "}user/" + callerNum + " &eavesdrop(" + sessionId + ")"
387
+            String arg = " {origination_caller_id_number=" + callerNum + ",cc_member_session_uuid=" + sessionId
388
+                    + ",absolute_codec_string='PCMA,PCMU',call_callee=" + calleeNum + "}user/" + callerNum + " &eavesdrop(" + sessionId + ")"
389 389
                     + "\r\nJob-UUID: " + action + "|" + System.currentTimeMillis();
390 390
             result = client.sendAsyncApiCommand(command, arg);
391
-            
391
+
392 392
         } catch (Exception e) {
393 393
             log.error(callerNum + "|" + sessionId + " 监听失败", e);
394 394
         }
@@ -426,7 +426,8 @@ public class EslClientService {
426 426
             try {
427 427
                 Integer.parseInt(agent);
428 428
                 at = agent.replaceAll("(.)", " $1").substring(1);
429
-            } catch (Exception ex) { }
429
+            } catch (Exception ex) {
430
+            }
430 431
 
431 432
             String path = TtsHelper.TextToSpeechAgent("你好," + at + "号话务员为您服务", agent);
432 433
             String arg = chanId + " playback::" + path + " both";
@@ -482,7 +483,7 @@ public class EslClientService {
482 483
     }
483 484
 
484 485
     //放音收号
485
-    public boolean playAndGetDigits(String path,String var, String chanId) {
486
+    public boolean playAndGetDigits(String path, String var, String chanId) {
486 487
         String result = "";
487 488
         try {
488 489
             String command = EslCommandEnum.uuid_broadcast.name();
@@ -498,7 +499,7 @@ public class EslClientService {
498 499
     }
499 500
 
500 501
     //放音识别
501
-    public boolean playAndDetectSpeech(String path,String var,  String chanId) {
502
+    public boolean playAndDetectSpeech(String path, String var, String chanId) {
502 503
         String result = "";
503 504
         try {
504 505
             String command = EslCommandEnum.uuid_broadcast.name();
@@ -519,16 +520,16 @@ public class EslClientService {
519 520
         String result = "";
520 521
         try {
521 522
             String command = EslCommandEnum.uuid_break.name();
522
-            String arg = chanId ;
523
+            String arg = chanId;
523 524
             result = client.sendAsyncApiCommand(command, arg);
524 525
         } catch (Exception e) {
525
-            log.error( chanId + " 暂停播放语音失败", e);
526
+            log.error(chanId + " 暂停播放语音失败", e);
526 527
         }
527 528
         return !result.equals("");
528 529
     }
529 530
 
530 531
     //语音识别
531
-    public boolean funasr(String chanId,boolean isAsr) {
532
+    public boolean funasr(String chanId, boolean isAsr) {
532 533
         String result = "";
533 534
         try {
534 535
             String command = EslCommandEnum.uuid_audio_stream.name();
@@ -542,7 +543,7 @@ public class EslClientService {
542 543
             params.put("hotwords", null);
543 544
             String arg = "";
544 545
             if (isAsr) {
545
-                String url=SpringHelper.getRequiredProperty("common.funasr");
546
+                String url = SpringHelper.getRequiredProperty("common.funasr");
546 547
                 arg = chanId + " start " + url + " mono 16k " + JSON.toJSONString(params);
547 548
             } else {
548 549
                 arg = chanId + " stop " + JSON.toJSONString(params);
@@ -576,7 +577,7 @@ public class EslClientService {
576 577
     }
577 578
 
578 579
     //呼叫号码加入会议
579
-    public boolean callJoinMeeting(String callerNum, String calleeNum, String meetingId,String action) {
580
+    public boolean callJoinMeeting(String callerNum, String calleeNum, String meetingId, String action) {
580 581
         String result = "";
581 582
         try {
582 583
             String fix = action.substring(action.lastIndexOf("|") + 1);
@@ -593,7 +594,7 @@ public class EslClientService {
593 594
 
594 595
             String arg = " {cc_member_session_uuid=" + meetingId
595 596
                     + getOrigination(calleeNum)
596
-                    + ",call_callee=" + calleeNum.substring(fix.length())+",call_caller=" + callerNum
597
+                    + ",call_callee=" + calleeNum.substring(fix.length()) + ",call_caller=" + callerNum
597 598
                     + ",transfer_ringback=local_stream://moh,ringback=local_stream://moh"
598 599
                     + argstr + "}" + getCallString(calleeNum)
599 600
                     // + " " + meetingId + " xml ExtenMeeting";
@@ -608,12 +609,12 @@ public class EslClientService {
608 609
     }
609 610
 
610 611
     //开启/关闭静音
611
-    public boolean setMute(String chanId, boolean isMute,String action) {
612
+    public boolean setMute(String chanId, boolean isMute, String action) {
612 613
         String result = "";
613 614
         try {
614 615
             String command = EslCommandEnum.uuid_audio.name();
615 616
             String arg = chanId + (isMute ? " start" : " stop") + " write mute -4"
616
-                    +"\r\nJob-UUID: " + action + "|" + System.currentTimeMillis();
617
+                    + "\r\nJob-UUID: " + action + "|" + System.currentTimeMillis();
617 618
             result = client.sendAsyncApiCommand(command, arg);
618 619
 
619 620
         } catch (Exception e) {
@@ -624,7 +625,7 @@ public class EslClientService {
624 625
     }
625 626
 
626 627
     //开启/关闭保持
627
-    public boolean setHold(String chanId, boolean isHold,String action) {
628
+    public boolean setHold(String chanId, boolean isHold, String action) {
628 629
         String result = "";
629 630
         try {
630 631
             String command = EslCommandEnum.uuid_hold.name();
@@ -640,7 +641,7 @@ public class EslClientService {
640 641
     }
641 642
 
642 643
     //录音
643
-    public boolean record(String chanId, String filePath,boolean isRecord) {
644
+    public boolean record(String chanId, String filePath, boolean isRecord) {
644 645
         String result = "";
645 646
         try {
646 647
             String command = EslCommandEnum.uuid_record.name();
@@ -669,15 +670,15 @@ public class EslClientService {
669 670
     }
670 671
 
671 672
     //转满意度
672
-    public boolean transferMyd(String chanId,String action) {
673
+    public boolean transferMyd(String chanId, String action) {
673 674
         String result = "";
674 675
         try {
675 676
             String command = EslCommandEnum.uuid_transfer.name();
676 677
             //String arg = chanId + " turnmyd xml ForExten";
677 678
             String arg = chanId + " 'set:hangup_after_bridge=false,ivr:myd' inline"
678
-                    +"\r\nJob-UUID: " + action + "|" + System.currentTimeMillis();
679
+                    + "\r\nJob-UUID: " + action + "|" + System.currentTimeMillis();
679 680
             result = client.sendAsyncApiCommand(command, arg);
680
-            
681
+
681 682
         } catch (Exception e) {
682 683
             log.error(chanId + " 转满意度失败", e);
683 684
         }
@@ -685,7 +686,7 @@ public class EslClientService {
685 686
     }
686 687
 
687 688
     //转移号码
688
-    public boolean transfer(String chanId,String callerNum, String calleeNum,String action) {
689
+    public boolean transfer(String chanId, String callerNum, String calleeNum, String action) {
689 690
         String result = "";
690 691
         try {
691 692
             String fix = action.substring(action.lastIndexOf("|") + 1);
@@ -710,14 +711,14 @@ public class EslClientService {
710 711
     }
711 712
 
712 713
     //发送按键
713
-    public boolean sendDtmf(String chanId, String dtmf,String action) {
714
+    public boolean sendDtmf(String chanId, String dtmf, String action) {
714 715
         String result = "";
715 716
         try {
716 717
             String command = EslCommandEnum.uuid_send_dtmf.name();
717 718
             String arg = chanId + " " + dtmf
718
-                    +"\r\nJob-UUID: " + action + "|" + System.currentTimeMillis();
719
+                    + "\r\nJob-UUID: " + action + "|" + System.currentTimeMillis();
719 720
             result = client.sendAsyncApiCommand(command, arg);
720
-            
721
+
721 722
         } catch (Exception e) {
722 723
             log.error(chanId + "|" + dtmf + " 发送按键失败", e);
723 724
         }
@@ -748,7 +749,7 @@ public class EslClientService {
748 749
             String command = EslCommandEnum.conference.name();
749 750
             String arg = meetingId + " exit_sound " + (isplay ? "on" : "off");
750 751
             result = client.sendAsyncApiCommand(command, arg);
751
-            
752
+
752 753
         } catch (Exception e) {
753 754
             log.error(meetingId + "|" + isplay + " 设置会议离开失败", e);
754 755
         }
@@ -756,7 +757,7 @@ public class EslClientService {
756 757
     }
757 758
 
758 759
     //设置会议人员是否静音
759
-    public boolean setConferenceIsMute(String meetingId, String chanId, boolean isMute,String action) {
760
+    public boolean setConferenceIsMute(String meetingId, String chanId, boolean isMute, String action) {
760 761
         String result = "";
761 762
         try {
762 763
             String memberId = getConferenceMemberId(meetingId, chanId);
@@ -784,7 +785,7 @@ public class EslClientService {
784 785
     }
785 786
 
786 787
     //自动外呼
787
-    public boolean autoCall(String callerNum, String calleeNum,String taskId,String phoneId) {
788
+    public boolean autoCall(String callerNum, String calleeNum, String taskId, String phoneId) {
788 789
         String result = "";
789 790
         try {
790 791
             String command = EslCommandEnum.originate.name();
@@ -810,9 +811,9 @@ public class EslClientService {
810 811
         return !result.equals("");
811 812
     }
812 813
 
813
-    public boolean appCommand(String chanId,String command, String arg) {
814
+    public boolean appCommand(String chanId, String command, String arg) {
814 815
         try {
815
-            SendMsg sm=new SendMsg(chanId);
816
+            SendMsg sm = new SendMsg(chanId);
816 817
             sm.addCallCommand("execute");
817 818
             sm.addExecuteAppName(command);
818 819
             sm.addExecuteAppArg(arg);
@@ -826,7 +827,7 @@ public class EslClientService {
826 827
     //源号码
827 828
     private String getOrigination(String calleeNum) {
828 829
         String str = "";
829
-        String origination= SpringHelper.getRequiredProperty("common.gateway.origination");
830
+        String origination = SpringHelper.getRequiredProperty("common.gateway.origination");
830 831
         if (!EslCommon.existExten(calleeNum) && StringHelper.isNotEmpty(origination)) {
831 832
             str = ",origination_caller_id_number=" + origination;
832 833
         }
@@ -839,16 +840,16 @@ public class EslClientService {
839 840
         String callStr = "user/" + calleeNum;
840 841
         //呼叫外线号码
841 842
         if (!EslCommon.existExten(calleeNum)) {
842
-            String register= SpringHelper.getRequiredProperty("common.gateway.register");
843
+            String register = SpringHelper.getRequiredProperty("common.gateway.register");
843 844
             if (StringHelper.isNotEmpty(register)) {
844
-                callStr = "sofia/internal/" + calleeNum + "@" + register;
845
-
846
-//            //注册网关
847
-//            EslMessage message = client.sendSyncApiCommand("sofia_contact", "9400");
848
-//            if (message != null && message.getBodyLines().size() > 0) {
849
-//                String gwip = message.getBodyLines().get(0);
850
-//                callStr = "sofia/internal/" + calleeNum + gwip.substring(gwip.indexOf("@"));
851
-//            }
845
+                //callStr = "sofia/internal/" + calleeNum + "@" + register;
846
+
847
+                //注册网关
848
+                EslMessage message = client.sendSyncApiCommand("sofia_contact", register);
849
+                if (message != null && message.getBodyLines().size() > 0) {
850
+                    String gwip = message.getBodyLines().get(0);
851
+                    callStr = "sofia/internal/" + calleeNum + gwip.substring(gwip.indexOf("@"));
852
+                }
852 853
 
853 854
             } else {
854 855
                 callStr = "sofia/gateway/hykj/" + calleeNum;

+ 2 - 1
midware-util/src/main/java/midware/util/enums/EslEventEnum.java

@@ -6,7 +6,8 @@ public enum EslEventEnum {
6 6
     CHANNEL_PROGRESS_MEDIA("媒体进度"),
7 7
     CHANNEL_ANSWER("接听"),
8 8
     CHANNEL_BRIDGE("桥接"),
9
-    CHANNEL_HANGUP_COMPLETE("挂机完成"),
9
+    CHANNEL_HANGUP("挂机"),
10
+    //CHANNEL_HANGUP_COMPLETE("挂机完成"),
10 11
     //CHANNEL_HOLD("保持"),
11 12
     //CHANNEL_UNHOLD("接回"),
12 13
     //CHANNEL_EXECUTE_COMPLETE("执行完成"),