zhoufan 1 gadu atpakaļ
vecāks
revīzija
835c09cf78

+ 0 - 9
midware-service/src/main/java/midware/service/eslclient/EslCommon.java

@@ -87,15 +87,6 @@ public class EslCommon {
87 87
         return chan;
88 88
     }
89 89
 
90
-    //根据分机删除通道
91
-    public static boolean delChanByExten(String exten){
92
-        List<Channel> cs=channels.stream().filter(p -> p.getType() == 1 && p.getNumber().equals(exten)).collect(Collectors.toList());
93
-        if(cs.size()>0){
94
-            return channels.removeAll(cs);
95
-        }
96
-        return true;
97
-    }
98
-
99 90
     //根据id获取会话
100 91
     public static Session getSessionById(String id){
101 92
         List<Session> cs=sessions.stream().filter(p -> p.getSessionId().equals(id)).collect(Collectors.toList());

+ 41 - 16
midware-service/src/main/java/midware/service/eslclient/EslEventListener.java

@@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
31 31
 public class EslEventListener implements IEslEventListener {
32 32
     @Override
33 33
     public void eventReceived(EslEvent event) {
34
-        System.out.println(1 + "|" + JSON.toJSONString(event));
34
+        //System.out.println(1 + "|" + JSON.toJSONString(event));
35 35
 
36 36
         IRecordService iRecordService = SpringHelper.getBean(IRecordService.class);
37 37
         EslClientService eslClientService = SpringHelper.getBean(EslClientService.class);
@@ -51,7 +51,18 @@ public class EslEventListener implements IEslEventListener {
51 51
                     }
52 52
                     break;
53 53
                 case sofia_unregister:
54
-                    EslCommon.delChanByExten(exten);
54
+                    Channel chan1 = EslCommon.getChanByExten(exten);
55
+                    if(chan1!=null) {
56
+                        EslCommon.channels.remove(chan1);
57
+                        Agent at = EslCommon.getAgentByExten(exten);
58
+                        if (at != null){
59
+                            if (at.getAgentState() != EslAgentNum.logout.ordinal()) {
60
+                                at.setAgentState(EslAgentNum.logout.ordinal());
61
+                            }
62
+                            eslClientService.logout(at.getAgent(), at.getGroup());
63
+                            EslCommon.agents.remove(at);
64
+                        }
65
+                    }
55 66
                     break;
56 67
                 case callcenter_info:
57 68
                     String caller = header.get("Caller-Username");
@@ -179,24 +190,23 @@ public class EslEventListener implements IEslEventListener {
179 190
                     //呼出主叫通道/转移被叫通道 新增记录
180 191
                     if (session.getType() == 2) {
181 192
                         Agent callerAgent = EslCommon.getAgentByExten(callerNum);
182
-                        callerAgent.setCallType(0);
183
-                        if (!(calleeNum.equals(chanNames[2]) && callerAgent.getOpType() == 0)) {
184
-                            if (callerAgent.getOpType() > 0) {
193
+                        if (callerAgent != null) callerAgent.setCallType(0);
194
+                        Agent calleeAgent = EslCommon.getAgentByExten(calleeNum);
195
+                        if (calleeAgent != null) calleeAgent.setCallType(0);
196
+                        if (!(calleeNum.equals(chanNames[2]) && (callerAgent == null || callerAgent.getOpType() == 0))) {
197
+                            if (callerAgent != null && callerAgent.getOpType() > 0) {
185 198
                                 session.setActionId(session.getActionId() + 1);
186 199
                             }
187 200
 
188 201
                             Record record = new Record();
189 202
                             record.setCaller(callerNum);
190
-                            record.setCallerAgent(callerAgent.getAgent());
191
-                            record.setGroupNo(callerAgent.getGroup());
192
-                            record.setOpType(callerAgent.getOpType());
193
-
194
-                            record.setCallee(calleeNum);
195
-                            Agent calleeAgent = EslCommon.getAgentByExten(calleeNum);
196
-                            if (calleeAgent != null) {
197
-                                calleeAgent.setCallType(session.getType());
198
-                                record.setCalleeAgent(calleeAgent.getAgent());
203
+                            if (callerAgent != null) {
204
+                                record.setCallerAgent(callerAgent.getAgent());
205
+                                record.setGroupNo(callerAgent.getGroup());
206
+                                record.setOpType(callerAgent.getOpType());
199 207
                             }
208
+                            record.setCallee(calleeNum);
209
+                            if (calleeAgent != null) record.setCalleeAgent(calleeAgent.getAgent());
200 210
                             record.setCallType(2);
201 211
                             record.setUuid(callId);
202 212
                             record.setActionId(session.getActionId());
@@ -206,6 +216,14 @@ public class EslEventListener implements IEslEventListener {
206 216
                             chan.setRecordId(record.getId());
207 217
                         } else {
208 218
                             chan.setRecordId(EslCommon.getChanByNumber(callerNum).getRecordId());
219
+                            if (calleeAgent != null) {
220
+                                Map<String, Object> result = new HashMap<>();
221
+                                result.put("Type", "Incoming");
222
+                                result.put("Result", true);
223
+                                result.put("CallID", chan.getRecordId());
224
+                                result.put("Number", callerNum);
225
+                                SpringHelper.getBean(WebSocketService.class).sendMessage(calleeAgent.getAgent(), JSON.toJSONString(result));
226
+                            }
209 227
                         }
210 228
                     }
211 229
                     //呼入时查找记录更新被叫工号分机号坐席组
@@ -229,7 +247,7 @@ public class EslEventListener implements IEslEventListener {
229 247
                             Map<String, Object> result = new HashMap<>();
230 248
                             result.put("Type", "Incoming");
231 249
                             result.put("Result", true);
232
-                            result.put("CallID", callId);
250
+                            result.put("CallID", chan.getRecordId());
233 251
                             result.put("Number", callerNum);
234 252
                             SpringHelper.getBean(WebSocketService.class).sendMessage(calleeAgent.getAgent(), JSON.toJSONString(result));
235 253
                         }
@@ -427,7 +445,7 @@ public class EslEventListener implements IEslEventListener {
427 445
 
428 446
     @Override
429 447
     public void backgroundJobResultReceived(EslEvent event) {
430
-        System.out.println(2 + "|" + JSON.toJSONString(event));
448
+        //System.out.println(2 + "|" + JSON.toJSONString(event));
431 449
 
432 450
         String bodys = event.getEventBodyLines().size() > 0 ? event.getEventBodyLines().get(0) : "";
433 451
         String uuid = event.getEventHeaders().get("Job-UUID");
@@ -511,6 +529,13 @@ public class EslEventListener implements IEslEventListener {
511 529
                     case "Break"://强拆
512 530
                         break;
513 531
                 }
532
+            }else{
533
+                if(type.equals("Login")){
534
+                    if(agent!=null) {
535
+                        SpringHelper.getBean(EslClientService.class).logout(agentId, agent.getGroup());
536
+                        EslCommon.agents.remove(agent);
537
+                    }
538
+                }
514 539
             }
515 540
             EslCommon.sessionOpera.remove(uuid);
516 541
             if (isEnd) {

+ 66 - 58
midware-service/src/main/java/midware/service/init/WebSocketService.java

@@ -12,7 +12,6 @@ import midware.util.helper.StringHelper;
12 12
 import org.springframework.stereotype.Component;
13 13
 
14 14
 import javax.websocket.*;
15
-import javax.websocket.server.PathParam;
16 15
 import javax.websocket.server.ServerEndpoint;
17 16
 import java.io.IOException;
18 17
 import java.util.*;
@@ -56,7 +55,7 @@ public class WebSocketService {
56 55
                 EslCommon.agents.remove(a);
57 56
                 sessionPool.remove(agentId);
58 57
             }
59
-            if(subScribeSessionPool.contains(session))subScribeSessionPool.remove(session);
58
+            subScribeSessionPool.remove(session);
60 59
         } catch (Exception e) {
61 60
             log.error("close错误", e);
62 61
         }
@@ -70,15 +69,24 @@ public class WebSocketService {
70 69
     @OnMessage
71 70
     public void onMessage(String message) {
72 71
         try {
73
-            Map<String, Object> result = new HashMap<>();
74 72
             Map map = JSON.parseObject(message, Map.class);
75 73
             String type = map.get("Type").toString();
76
-            Agent agent = EslCommon.getAgent(agentId);
77
-            Channel chan = null;
78
-            if (agent != null) chan = EslCommon.getChanByExten(agent.getExten());
79
-            EslAgentNum state = agent == null ? null : EslAgentNum.values()[agent.getAgentState()];
74
+
75
+            Map<String, Object> result = new HashMap<>();
80 76
             result.put("Type", type);
81 77
             result.put("Result", "操作失败");
78
+            Agent agent = EslCommon.getAgent(agentId);
79
+            Channel chan = null;EslAgentNum state =null;
80
+            if (agent != null) {
81
+                chan = EslCommon.getChanByExten(agent.getExten());
82
+                state = EslAgentNum.values()[agent.getAgentState()];
83
+                if (chan == null) {
84
+                    result.put("Result", "分机未注册");
85
+                    state = null;
86
+                }
87
+            }
88
+
89
+
82 90
             String param = "";
83 91
             boolean isSend = true;
84 92
             switch (type) {
@@ -92,40 +100,37 @@ public class WebSocketService {
92 100
                     param = AgentExten + "|" + AgentGroup;
93 101
                     //String AgentType = map.get("AgentType").toString();
94 102
 
95
-                    if (StringHelper.isNotEmpty(agentId)) {
96
-                        result.put("Result", "重复签入");
97
-                    } else {
98
-                        if (StringHelper.isNotEmpty(AgentId) && StringHelper.isNotEmpty(AgentExten) && StringHelper.isNotEmpty(AgentGroup)) {
99
-                            if (EslCommon.existAgent(AgentId)) {
100
-                                result.put("Result", "坐席已存在");
101
-                            } else if (!EslCommon.existExten(AgentExten)) {
102
-                                result.put("Result", "分机未注册");
103
-                            } else if (EslCommon.getAgentByExten(AgentExten) != null) {
104
-                                result.put("Result", "分机已存在");
105
-                            } else {
106
-                                this.agentId = AgentId;
107
-                                sessionPool.put(AgentId,session);
103
+                    if (StringHelper.isNotEmpty(AgentId) && StringHelper.isNotEmpty(AgentExten) && StringHelper.isNotEmpty(AgentGroup)) {
104
+                        if (EslCommon.existAgent(AgentId)) {
105
+                            result.put("Result", "坐席已存在");
106
+                        } else if (!EslCommon.existExten(AgentExten)) {
107
+                            result.put("Result", "分机未注册");
108
+                        } else if (EslCommon.getAgentByExten(AgentExten) != null) {
109
+                            result.put("Result", "分机已存在");
110
+                        } else {
111
+                            this.agentId = AgentId;
112
+                            sessionPool.put(AgentId, session);
108 113
 
109
-                                agent = new Agent();
110
-                                agent.setAgent(AgentId);
111
-                                agent.setExten(AgentExten);
112
-                                agent.setGroup(AgentGroup);
113
-                                //agent.setAgentState(EslAgentNum.loging.ordinal());
114
+                            agent = new Agent();
115
+                            agent.setAgent(AgentId);
116
+                            agent.setExten(AgentExten);
117
+                            agent.setGroup(AgentGroup);
118
+                            agent.setAgentState(EslAgentNum.loging.ordinal());
114 119
 
115
-                                chan = EslCommon.getChanByExten(AgentExten);
116
-                                String rt = eslClientService.login(AgentId, AgentExten, AgentGroup);
117
-                                if (StringHelper.isNotEmpty(rt)) {
118
-                                    EslCommon.agents.add(agent);
119
-                                    EslCommon.sessionOpera.put(rt, type + "|" + AgentId);
120
-                                    isSend = false;
121
-                                }
120
+                            chan = EslCommon.getChanByExten(AgentExten);
121
+                            String rt = eslClientService.login(AgentId, AgentExten, AgentGroup);
122
+                            if (StringHelper.isNotEmpty(rt)) {
123
+                                EslCommon.agents.add(agent);
124
+                                EslCommon.sessionOpera.put(rt, type + "|" + AgentId);
125
+                                isSend = false;
122 126
                             }
123 127
                         }
124 128
                     }
129
+
125 130
                     break;
126 131
                 case "Logout"://签出
127 132
                     //空闲/置忙/话后处理  可以签出
128
-                    if (StringHelper.isNotEmpty(agentId) && Arrays.asList(EslAgentNum.free, EslAgentNum.busy, EslAgentNum.aftertalk).contains(state)) {
133
+                    if (Arrays.asList(EslAgentNum.free, EslAgentNum.busy, EslAgentNum.aftertalk).contains(state)) {
129 134
                         String rt = eslClientService.logout(agentId, agent.getGroup());
130 135
                         if (StringHelper.isNotEmpty(rt)) {
131 136
                             EslCommon.sessionOpera.put(rt, type + "|" + agentId);
@@ -137,7 +142,7 @@ public class WebSocketService {
137 142
                     break;
138 143
                 case "WorkOn"://置闲
139 144
                     //置忙/话后处理  可以置闲
140
-                    if (StringHelper.isNotEmpty(agentId) && Arrays.asList(EslAgentNum.busy, EslAgentNum.aftertalk).contains(state)) {
145
+                    if (Arrays.asList(EslAgentNum.busy, EslAgentNum.aftertalk).contains(state)) {
141 146
                         String rt = eslClientService.setWork(agentId, true);
142 147
                         if (StringHelper.isNotEmpty(rt)) {
143 148
                             EslCommon.sessionOpera.put(rt, type + "|" + agentId);
@@ -147,7 +152,7 @@ public class WebSocketService {
147 152
                     break;
148 153
                 case "WorkOff"://置忙
149 154
                     //空闲/话后处理  可以置忙
150
-                    if (StringHelper.isNotEmpty(agentId) && Arrays.asList(EslAgentNum.free, EslAgentNum.aftertalk).contains(state)) {
155
+                    if (Arrays.asList(EslAgentNum.free, EslAgentNum.aftertalk).contains(state)) {
151 156
                         String rt = eslClientService.setWork(agentId, false);
152 157
                         if (StringHelper.isNotEmpty(rt)) {
153 158
                             EslCommon.sessionOpera.put(rt, type + "|" + agentId);
@@ -157,7 +162,7 @@ public class WebSocketService {
157 162
                     break;
158 163
                 case "MakeCall"://外呼
159 164
                     //空闲/置忙/话后处理  可以外呼
160
-                    if (StringHelper.isNotEmpty(agentId) && Arrays.asList(EslAgentNum.free, EslAgentNum.busy, EslAgentNum.aftertalk).contains(state)) {
165
+                    if (map.get("DestinationNumber") != null && Arrays.asList(EslAgentNum.free, EslAgentNum.busy, EslAgentNum.aftertalk).contains(state)) {
161 166
                         String DestinationNumber = map.get("DestinationNumber").toString();
162 167
                         param = DestinationNumber;
163 168
                         if (StringHelper.isNotEmpty(DestinationNumber)) {
@@ -176,7 +181,7 @@ public class WebSocketService {
176 181
                     break;
177 182
                 case "HoldOn"://开启保持
178 183
                     //通话中  可以开启保持
179
-                    if (StringHelper.isNotEmpty(agentId) && Objects.equals(state, EslAgentNum.talking)) {
184
+                    if (Objects.equals(state, EslAgentNum.talking)) {
180 185
                         String rt = eslClientService.setHold(chan.getSessionId(), true);
181 186
                         if (StringHelper.isNotEmpty(rt)) {
182 187
                             EslCommon.sessionOpera.put(rt, type + "|" + agentId);
@@ -186,7 +191,7 @@ public class WebSocketService {
186 191
                     break;
187 192
                 case "HoldOff"://关闭保持
188 193
                     //通话中  可以关闭保持
189
-                    if (StringHelper.isNotEmpty(agentId) && Objects.equals(state, EslAgentNum.talking)) {
194
+                    if (Objects.equals(state, EslAgentNum.talking)) {
190 195
                         String rt = eslClientService.setHold(chan.getSessionId(), false);
191 196
                         if (StringHelper.isNotEmpty(rt)) {
192 197
                             EslCommon.sessionOpera.put(rt, type + "|" + agentId);
@@ -196,7 +201,7 @@ public class WebSocketService {
196 201
                     break;
197 202
                 case "MuteOn"://开启静音
198 203
                     //通话中  可以开启静音
199
-                    if (StringHelper.isNotEmpty(agentId) && Objects.equals(state, EslAgentNum.talking)) {
204
+                    if (Objects.equals(state, EslAgentNum.talking)) {
200 205
                         String rt = eslClientService.setMute(chan.getChanId(), true);
201 206
                         if (StringHelper.isNotEmpty(rt)) {
202 207
                             EslCommon.sessionOpera.put(rt, type + "|" + agentId);
@@ -206,7 +211,7 @@ public class WebSocketService {
206 211
                     break;
207 212
                 case "MuteOff"://关闭静音
208 213
                     //通话中  可以关闭静音
209
-                    if (StringHelper.isNotEmpty(agentId) && Objects.equals(state, EslAgentNum.talking)) {
214
+                    if (Objects.equals(state, EslAgentNum.talking)) {
210 215
                         String rt = eslClientService.setMute(chan.getChanId(), false);
211 216
                         if (StringHelper.isNotEmpty(rt)) {
212 217
                             EslCommon.sessionOpera.put(rt, type + "|" + agentId);
@@ -216,7 +221,7 @@ public class WebSocketService {
216 221
                     break;
217 222
                 case "Transfer"://转移
218 223
                     //通话中  可以转移
219
-                    if (StringHelper.isNotEmpty(agentId) && Objects.equals(state, EslAgentNum.talking)) {
224
+                    if (map.get("DestinationNumber") != null && Objects.equals(state, EslAgentNum.talking)) {
220 225
                         String DestinationNumber = map.get("DestinationNumber").toString();
221 226
                         param = DestinationNumber;
222 227
                         if (StringHelper.isNotEmpty(DestinationNumber)) {
@@ -244,7 +249,7 @@ public class WebSocketService {
244 249
                     break;
245 250
                 case "ConsultOn"://开启协商
246 251
                     //通话中  可以协商
247
-                    if (StringHelper.isNotEmpty(agentId) && Objects.equals(state, EslAgentNum.talking)) {
252
+                    if (map.get("DestinationNumber") != null && Objects.equals(state, EslAgentNum.talking)) {
248 253
                         String DestinationNumber = map.get("DestinationNumber").toString();
249 254
                         param = DestinationNumber;
250 255
                         if (StringHelper.isNotEmpty(DestinationNumber)) {
@@ -272,7 +277,7 @@ public class WebSocketService {
272 277
                     break;
273 278
                 case "ConsultOff"://关闭协商
274 279
                     //通话中  可以协商取消
275
-                    if (StringHelper.isNotEmpty(agentId) && Objects.equals(state, EslAgentNum.talking)) {
280
+                    if (Objects.equals(state, EslAgentNum.talking)) {
276 281
                         String sid = chan.getSessionId();
277 282
                         Channel channel = EslCommon.channels.stream().filter(p -> p.getSessionId().equals(sid)
278 283
                                 && p.getSessionSort() == 3).findFirst().get();
@@ -285,7 +290,7 @@ public class WebSocketService {
285 290
                     break;
286 291
                 case "Meeting"://会议
287 292
                     //通话中  可以会议
288
-                    if (StringHelper.isNotEmpty(agentId) && Objects.equals(state, EslAgentNum.talking)) {
293
+                    if (map.get("DestinationNumber") != null && Objects.equals(state, EslAgentNum.talking)) {
289 294
                         String DestinationNumber = map.get("DestinationNumber").toString();
290 295
                         param = DestinationNumber;
291 296
                         if (StringHelper.isNotEmpty(DestinationNumber)) {
@@ -311,7 +316,7 @@ public class WebSocketService {
311 316
                     break;
312 317
                 case "TurnMyd"://转满意度
313 318
                     //通话中  可以转满意度
314
-                    if (StringHelper.isNotEmpty(agentId) && Objects.equals(state, EslAgentNum.talking)) {
319
+                    if (Objects.equals(state, EslAgentNum.talking)) {
315 320
                         String rt = eslClientService.turnMyd(chan.getSessionId());
316 321
                         if (StringHelper.isNotEmpty(rt)) {
317 322
                             EslCommon.sessionOpera.put(rt, type + "|" + agentId);
@@ -321,7 +326,7 @@ public class WebSocketService {
321 326
                     break;
322 327
                 case "DropCall"://挂机
323 328
                     //通话中/请求中  可以挂机
324
-                    if (StringHelper.isNotEmpty(agentId) && Arrays.asList(EslAgentNum.talking, EslAgentNum.requested).contains(state)) {
329
+                    if (Arrays.asList(EslAgentNum.talking, EslAgentNum.requested).contains(state)) {
325 330
                         String rt = eslClientService.kill(chan.getChanId());
326 331
                         if (StringHelper.isNotEmpty(rt)) {
327 332
                             EslCommon.sessionOpera.put(rt, type + "|" + agentId);
@@ -330,18 +335,18 @@ public class WebSocketService {
330 335
                     }
331 336
                     break;
332 337
                 case "SubScribeOn":
333
-                    agent.setIsMonitor(1);
338
+                    if (agent != null) agent.setIsMonitor(1);
334 339
                     subScribeSessionPool.add(this.session);
335 340
                     result.put("Result", true);
336 341
                     break;
337 342
                 case "SubScribeOff":
338
-                    agent.setIsMonitor(0);
343
+                    if (agent != null) agent.setIsMonitor(0);
339 344
                     subScribeSessionPool.remove(this.session);
340 345
                     result.put("Result", true);
341 346
                     break;
342 347
                 case "Listen"://监听
343 348
                     //空闲/置忙  可以监听
344
-                    if (StringHelper.isNotEmpty(agentId) && Arrays.asList(EslAgentNum.free, EslAgentNum.busy).contains(state)) {
349
+                    if (map.get("TargetAgentID") != null && Arrays.asList(EslAgentNum.free, EslAgentNum.busy).contains(state)) {
345 350
                         String TargetAgentID = map.get("TargetAgentID").toString();
346 351
                         param = TargetAgentID;
347 352
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
@@ -369,7 +374,7 @@ public class WebSocketService {
369 374
                     break;
370 375
                 case "Insert"://强插
371 376
                     //空闲/置忙  可以强插
372
-                    if (StringHelper.isNotEmpty(agentId) && Arrays.asList(EslAgentNum.free, EslAgentNum.busy).contains(state)) {
377
+                    if (map.get("TargetAgentID") != null && Arrays.asList(EslAgentNum.free, EslAgentNum.busy).contains(state)) {
373 378
                         String TargetAgentID = map.get("TargetAgentID").toString();
374 379
                         param = TargetAgentID;
375 380
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
@@ -398,7 +403,7 @@ public class WebSocketService {
398 403
                     break;
399 404
                 case "Intercept"://强截
400 405
                     //空闲/置忙  可以强截
401
-                    if (StringHelper.isNotEmpty(agentId) && Arrays.asList(EslAgentNum.free, EslAgentNum.busy).contains(state)) {
406
+                    if (map.get("TargetAgentID") != null && Arrays.asList(EslAgentNum.free, EslAgentNum.busy).contains(state)) {
402 407
                         String TargetAgentID = map.get("TargetAgentID").toString();
403 408
                         param = TargetAgentID;
404 409
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
@@ -428,7 +433,7 @@ public class WebSocketService {
428 433
                     }
429 434
                     break;
430 435
                 case "Break"://强拆
431
-                    if (state.ordinal() > 0) {
436
+                    if (map.get("TargetAgentID") != null) {
432 437
                         String TargetAgentID = map.get("TargetAgentID").toString();
433 438
                         param = TargetAgentID;
434 439
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
@@ -455,7 +460,7 @@ public class WebSocketService {
455 460
                     break;
456 461
                 case "Instead"://代接
457 462
                     //空闲/置忙  可以代接
458
-                    if (StringHelper.isNotEmpty(agentId) && Arrays.asList(EslAgentNum.free, EslAgentNum.busy).contains(state)) {
463
+                    if (map.get("TargetAgentID") != null && Arrays.asList(EslAgentNum.free, EslAgentNum.busy).contains(state)) {
459 464
                         String TargetAgentID = map.get("TargetAgentID").toString();
460 465
                         param = TargetAgentID;
461 466
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
@@ -491,7 +496,7 @@ public class WebSocketService {
491 496
                     break;
492 497
                 case "ForceWorkOn"://强制置闲
493 498
                 case "ForceWorkOff"://强制置忙
494
-                    if (state.ordinal() > 0) {
499
+                    if (map.get("TargetAgentID") != null) {
495 500
                         String TargetAgentID = map.get("TargetAgentID").toString();
496 501
                         param = TargetAgentID;
497 502
                         if (StringHelper.isNotEmpty(TargetAgentID)) {
@@ -511,11 +516,14 @@ public class WebSocketService {
511 516
                     }
512 517
                     break;
513 518
             }
519
+
514 520
             AgentAction aa = new AgentAction();
515 521
             aa.setAction(type);
516
-            aa.setGroupNo(agent.getGroup());
517
-            aa.setAgent(agent.getAgent());
518
-            aa.setExten(agent.getExten());
522
+            if(agent!=null) {
523
+                aa.setGroupNo(agent.getGroup());
524
+                aa.setAgent(agent.getAgent());
525
+                aa.setExten(agent.getExten());
526
+            }
519 527
             aa.setParam(param);
520 528
             if (chan != null) aa.setUuid(chan.getSessionId());
521 529
             aa.setIsSuccess(0);
@@ -574,7 +582,7 @@ public class WebSocketService {
574 582
             EslCommon.agents.remove(a);
575 583
             sessionPool.remove(agentId);
576 584
         }
577
-        if(subScribeSessionPool.contains(session))subScribeSessionPool.remove(session);
585
+        subScribeSessionPool.remove(session);
578 586
         error.printStackTrace();
579 587
     }
580 588