zhoufan il y a 1 an
Parent
commit
bdddba2d82

+ 13 - 15
midware-service/src/main/java/midware/service/eslclient/EslEventListener.java

158
             Channel chan = EslCommon.getChanByNumber(chanNames[2]);
158
             Channel chan = EslCommon.getChanByNumber(chanNames[2]);
159
             Agent agent = EslCommon.getAgentByExten(chanNames[2]);
159
             Agent agent = EslCommon.getAgentByExten(chanNames[2]);
160
             Session session = EslCommon.getSessionById(callId);
160
             Session session = EslCommon.getSessionById(callId);
161
+            int callType = EslCommon.existExten(callerNum) ? 2 : 1;
161
 
162
 
162
             LambdaUpdateWrapper<Record> uw;
163
             LambdaUpdateWrapper<Record> uw;
163
 
164
 
169
                         chan.setVideo(isVideo);
170
                         chan.setVideo(isVideo);
170
                     }
171
                     }
171
                     if (session == null) {
172
                     if (session == null) {
172
-                        int callType = EslCommon.existExten(callerNum) ? 2 : 1;
173
                         session = new Session();
173
                         session = new Session();
174
                         session.setSessionId(callId);
174
                         session.setSessionId(callId);
175
                         session.setType(callType);
175
                         session.setType(callType);
188
 
188
 
189
                     //更新坐席状态
189
                     //更新坐席状态
190
                     if (agent != null) {
190
                     if (agent != null) {
191
-                        if (session.getType() == 2) {
191
+                        if (callType==2) {
192
                             eslClientService.setWork(agent.getAgent(), false);
192
                             eslClientService.setWork(agent.getAgent(), false);
193
                         }
193
                         }
194
                         agent.setAgentState(EslAgentNum.requested.ordinal());
194
                         agent.setAgentState(EslAgentNum.requested.ordinal());
195
                         if (agent.getOpType() == 4) return;
195
                         if (agent.getOpType() == 4) return;
196
                     }
196
                     }
197
 
197
 
198
-                    //呼出主叫通道/转移被叫通道 新增记录
199
-                    if (session.getType() == 2) {
198
+                    if (callType==2) {
200
                         Agent callerAgent = EslCommon.getAgentByExten(callerNum);
199
                         Agent callerAgent = EslCommon.getAgentByExten(callerNum);
201
                         if (callerAgent != null) callerAgent.setCallType(0);
200
                         if (callerAgent != null) callerAgent.setCallType(0);
202
                         Agent calleeAgent = EslCommon.getAgentByExten(calleeNum);
201
                         Agent calleeAgent = EslCommon.getAgentByExten(calleeNum);
237
                         }
236
                         }
238
                     }
237
                     }
239
                     //呼入时查找记录更新被叫工号分机号坐席组
238
                     //呼入时查找记录更新被叫工号分机号坐席组
240
-                    if (session.getType() == 1 && calleeNum.equals(chanNames[2])) {
239
+                    if (callType==1) {
241
                         LambdaQueryWrapper<Record> qw = new LambdaQueryWrapper<>();
240
                         LambdaQueryWrapper<Record> qw = new LambdaQueryWrapper<>();
242
                         qw.eq(Record::getUuid, callId);
241
                         qw.eq(Record::getUuid, callId);
243
                         qw.select(Record::getId).last("limit 1");
242
                         qw.select(Record::getId).last("limit 1");
283
                     }
282
                     }
284
                     break;
283
                     break;
285
                 case CHANNEL_ANSWER:
284
                 case CHANNEL_ANSWER:
286
-                    if (callerNum.equals(chanNames[2])) {
287
-                    }
288
                     if (chan != null && !chan.isAnswer()) {
285
                     if (chan != null && !chan.isAnswer()) {
289
                         chan.setAnswer(true);
286
                         chan.setAnswer(true);
287
+
290
                         //呼出号码应答通知坐席
288
                         //呼出号码应答通知坐席
291
-                        if (session != null && session.getType() == 2) {
289
+                        if (callType==2) {
292
                             if (!EslCommon.sessionOpera.containsKey(chanNames[2])) {
290
                             if (!EslCommon.sessionOpera.containsKey(chanNames[2])) {
293
                                 try {
291
                                 try {
294
                                     Thread.sleep(300);
292
                                     Thread.sleep(300);
315
                                 agent.setAgentState(EslAgentNum.talking.ordinal());
313
                                 agent.setAgentState(EslAgentNum.talking.ordinal());
316
                                 if (agent.getOpType() == 4) return;
314
                                 if (agent.getOpType() == 4) return;
317
                             }
315
                             }
318
-                            //呼出
319
-                            if (session.getType() == 2 && !session.isAnswer()) {
316
+                            //分机打分机时更新主叫坐席状态
317
+                            if (callType==2 && !session.isAnswer()) {
320
                                 Agent callerAgent = EslCommon.getAgentByExten(callerNum);
318
                                 Agent callerAgent = EslCommon.getAgentByExten(callerNum);
321
                                 if (callerAgent != null) callerAgent.setAgentState(EslAgentNum.talking.ordinal());
319
                                 if (callerAgent != null) callerAgent.setAgentState(EslAgentNum.talking.ordinal());
322
                             }
320
                             }
323
 
321
 
324
                             String ext = callerNum;
322
                             String ext = callerNum;
325
-                            if (session.getType() == 1) ext = calleeNum;
323
+                            if (callType==1) ext = calleeNum;
326
 
324
 
327
                             String sid = session.getSessionId(), cid = chan.getChanId();
325
                             String sid = session.getSessionId(), cid = chan.getChanId();
328
                             if (session.isVideo()) {
326
                             if (session.isVideo()) {
362
                     break;
360
                     break;
363
                 case CHANNEL_BRIDGE:
361
                 case CHANNEL_BRIDGE:
364
                     //呼入播报工号
362
                     //呼入播报工号
365
-                    if (session != null && session.getType() == 1) {
363
+                    if (callType==1) {
366
                         Agent agent1 = EslCommon.getAgentByExten(calleeNum);
364
                         Agent agent1 = EslCommon.getAgentByExten(calleeNum);
367
                         if (agent1 != null) eslClientService.playAgent(agent1.getAgent(), chan.getChanId());
365
                         if (agent1 != null) eslClientService.playAgent(agent1.getAgent(), chan.getChanId());
368
                     }
366
                     }
377
                     if (session == null) session = EslCommon.getSessionById(sid);
375
                     if (session == null) session = EslCommon.getSessionById(sid);
378
 
376
 
379
                     //呼出号码未接通挂断通知坐席
377
                     //呼出号码未接通挂断通知坐席
380
-                    if (session != null && session.getType() == 2 && !chan.isAnswer()) {
378
+                    if (callType==2 && !chan.isAnswer()) {
381
                         if (!EslCommon.sessionOpera.containsKey(calleeNum)) {
379
                         if (!EslCommon.sessionOpera.containsKey(calleeNum)) {
382
                             try {
380
                             try {
383
                                 Thread.sleep(300);
381
                                 Thread.sleep(300);
397
                     if (chan.getType() == 1) {
395
                     if (chan.getType() == 1) {
398
                         if (agent != null) {
396
                         if (agent != null) {
399
                             String agentNo = agent.getAgent();
397
                             String agentNo = agent.getAgent();
400
-                            if (session.getType() == 1 && chan.isAnswer()) {//呼入接通后挂断-话后处理
398
+                            if (callType==1 && chan.isAnswer()) {//呼入接通后挂断-话后处理
401
                                 agent.setAgentState(EslAgentNum.aftertalk.ordinal());
399
                                 agent.setAgentState(EslAgentNum.aftertalk.ordinal());
402
                                 new ScheduledThreadPoolExecutor(1).schedule(() -> {
400
                                 new ScheduledThreadPoolExecutor(1).schedule(() -> {
403
                                     Agent agent2 = EslCommon.getAgent(agentNo);
401
                                     Agent agent2 = EslCommon.getAgent(agentNo);
409
                                 chan.setSessionId("");
407
                                 chan.setSessionId("");
410
                                 agent.setAgentState(EslAgentNum.free.ordinal());
408
                                 agent.setAgentState(EslAgentNum.free.ordinal());
411
                             }
409
                             }
412
-                            if (session.getType() == 2) {
410
+                            if (callType==2) {
413
                                 eslClientService.setWork(agentNo, true);
411
                                 eslClientService.setWork(agentNo, true);
414
                             }
412
                             }
415
                             agent.setCallType(0);
413
                             agent.setCallType(0);

+ 11 - 2
midware-service/src/main/java/midware/service/init/EslClientService.java

138
                             chan = new Channel();
138
                             chan = new Channel();
139
                             chan.setType(1);
139
                             chan.setType(1);
140
                             chan.setNumber(exten);
140
                             chan.setNumber(exten);
141
+                            EslCommon.channels.add(chan);
142
+                        }else {
143
+                            chan.setAnswer(false);
144
+                            chan.setChanId("");
145
+                            chan.setRecordPath("");
146
+                            chan.setCallType(0);
147
+                            chan.setSessionId("");
148
+                            chan.setRecordId(0);
149
+                            chan.setRingTime(null);
150
+                            chan.setSessionSort(0);
141
                         }
151
                         }
142
-                        EslCommon.channels.add(chan);
143
                     }
152
                     }
144
                 }
153
                 }
145
             }
154
             }
322
             String arg = chanId + " playback::" + path;
331
             String arg = chanId + " playback::" + path;
323
             result = client.sendAsyncApiCommand(command, arg);
332
             result = client.sendAsyncApiCommand(command, arg);
324
         } catch (Exception e) {
333
         } catch (Exception e) {
325
-            log.error(num + "|" + chanId + " 播放坐席工号失败", e);
334
+            log.error(num + "|" + chanId + " 播放排队位置失败", e);
326
         }
335
         }
327
         return result;
336
         return result;
328
     }
337
     }