|
|
@@ -31,8 +31,6 @@ public class WebSocket {
|
|
31
|
31
|
@Autowired
|
|
32
|
32
|
private IMessageService messageService;
|
|
33
|
33
|
@Autowired
|
|
34
|
|
- private ICustomerService customerService;
|
|
35
|
|
- @Autowired
|
|
36
|
34
|
private WxMpService wxMpService;
|
|
37
|
35
|
|
|
38
|
36
|
private Session session;
|
|
|
@@ -91,7 +89,9 @@ public class WebSocket {
|
|
91
|
89
|
kfsessionPool.remove(userCode);
|
|
92
|
90
|
servicerQueue.remove(userCode);
|
|
93
|
91
|
servicers.remove(userCode);
|
|
94
|
|
- khkfs.values().removeIf(p->p.equals(userCode));
|
|
|
92
|
+ if(khkfs.values().contains(userCode)) {
|
|
|
93
|
+ khkfs.values().removeIf(p -> p.equals(userCode));
|
|
|
94
|
+ }
|
|
95
|
95
|
} else {
|
|
96
|
96
|
customers.remove(userCode);
|
|
97
|
97
|
String kf = khkfs.get(userCode);
|
|
|
@@ -145,7 +145,7 @@ public class WebSocket {
|
|
145
|
145
|
MessageView mv1 = new MessageView();
|
|
146
|
146
|
mv1.setUser(userCode);
|
|
147
|
147
|
|
|
148
|
|
- String en = khExist(kh, userCode);
|
|
|
148
|
+ String en = khExist( userCode,kh);
|
|
149
|
149
|
if (StringHelper.isEmpty(en)) {
|
|
150
|
150
|
exist = true;
|
|
151
|
151
|
msg.setKhUser(kh);
|
|
|
@@ -184,8 +184,10 @@ public class WebSocket {
|
|
184
|
184
|
String kf = khkfs.get(userCode);
|
|
185
|
185
|
if (StringHelper.isEmpty(kf)) {
|
|
186
|
186
|
kf = servicerQueue.poll();
|
|
187
|
|
- servicerQueue.add(kf);
|
|
188
|
|
- khkfs.put(userCode, kf);
|
|
|
187
|
+ if(!StringHelper.isEmpty(kf)) {
|
|
|
188
|
+ servicerQueue.add(kf);
|
|
|
189
|
+ khkfs.put(userCode, kf);
|
|
|
190
|
+ }
|
|
189
|
191
|
}
|
|
190
|
192
|
if (!StringHelper.isEmpty(kf)) {
|
|
191
|
193
|
Session session1 = kfsessionPool.get(kf);
|
|
|
@@ -221,7 +223,9 @@ public class WebSocket {
|
|
221
|
223
|
kfsessionPool.remove(userCode);
|
|
222
|
224
|
servicerQueue.remove(userCode);
|
|
223
|
225
|
servicers.remove(userCode);
|
|
224
|
|
- khkfs.values().removeIf(p->p.equals(userCode));
|
|
|
226
|
+ if(khkfs.values().contains(userCode)) {
|
|
|
227
|
+ khkfs.values().removeIf(p -> p.equals(userCode));
|
|
|
228
|
+ }
|
|
225
|
229
|
} else {
|
|
226
|
230
|
customers.remove(userCode);
|
|
227
|
231
|
String kf = khkfs.get(userCode);
|
|
|
@@ -241,25 +245,16 @@ public class WebSocket {
|
|
241
|
245
|
error.printStackTrace();
|
|
242
|
246
|
}
|
|
243
|
247
|
|
|
244
|
|
- //客服连接留言客户
|
|
245
|
|
- public String kfconnectKh(String kf,String kh){
|
|
246
|
|
- if(khkfs.containsKey(kh)){
|
|
247
|
|
- return "其他客服已接入";
|
|
248
|
|
- }
|
|
249
|
|
- if(!customers.containsKey(kh)){
|
|
250
|
|
- return "客户不在线";
|
|
251
|
|
- }
|
|
252
|
|
- khkfs.put(kh,kf);
|
|
253
|
|
- return "";
|
|
254
|
|
- }
|
|
255
|
|
-
|
|
256
|
248
|
//客户是否存在
|
|
257
|
249
|
public String khExist(String kf,String kh) {
|
|
258
|
250
|
String msg = "客户已下线";
|
|
259
|
|
- if (!StringHelper.isEmpty(kh)) {
|
|
|
251
|
+ if(!(servicers.containsKey(kf)&&kfsessionPool.containsKey(kf))){
|
|
|
252
|
+ msg = "未签入";
|
|
|
253
|
+ }
|
|
|
254
|
+ else if (!StringHelper.isEmpty(kh)) {
|
|
260
|
255
|
if (customers.containsKey(kh)) {
|
|
261
|
256
|
if (khkfs.containsKey(kh)) {
|
|
262
|
|
- if (khkfs.get(kh) == userCode) {
|
|
|
257
|
+ if (khkfs.get(kh).equals(kf) ) {
|
|
263
|
258
|
if (customers.get(kh) == 2) {
|
|
264
|
259
|
msg = "";
|
|
265
|
260
|
} else {
|
|
|
@@ -271,24 +266,29 @@ public class WebSocket {
|
|
271
|
266
|
msg = "其他客服已接入";
|
|
272
|
267
|
}
|
|
273
|
268
|
} else {
|
|
274
|
|
- if (khsessionPool.containsKey(kh)) {
|
|
|
269
|
+ if (customers.get(kh) == 2||khsessionPool.containsKey(kh)) {
|
|
275
|
270
|
khkfs.put(kh, kf);
|
|
276
|
271
|
msg = "";
|
|
277
|
272
|
}
|
|
278
|
273
|
}
|
|
279
|
274
|
} else {
|
|
280
|
275
|
LambdaQueryWrapper<Customer> qw = new LambdaQueryWrapper();
|
|
281
|
|
- qw.eq(Customer::getCustomerNo, kh);
|
|
282
|
|
- Customer cus = customerService.getEntity(qw);
|
|
283
|
|
- if (cus != null && cus.getType() == 2) {
|
|
284
|
|
- customers.put(kh, 2);
|
|
285
|
|
- msg = "";
|
|
|
276
|
+ qw.eq(Customer::getCustomerNo, kh).eq(Customer::getType,2);
|
|
|
277
|
+ if (SpringHelper.getBean(ICustomerService.class).exists(qw)) {
|
|
|
278
|
+ Date dt=new Date();
|
|
|
279
|
+ Date sj=new Date(dt.getTime()-(1000*60*60*48));
|
|
|
280
|
+ LambdaQueryWrapper<Message> qw1 = new LambdaQueryWrapper();
|
|
|
281
|
+ qw1.eq(Message::getKhUser,kh).eq(Message::getSend,2).gt(Message::getCreateTime,sj);
|
|
|
282
|
+ if(SpringHelper.getBean(IMessageService.class).exists(qw1)) {
|
|
|
283
|
+ customers.put(kh, 2);
|
|
|
284
|
+ khkfs.put(kh, kf);
|
|
|
285
|
+ msg = "";
|
|
|
286
|
+ }
|
|
286
|
287
|
}
|
|
287
|
288
|
}
|
|
288
|
289
|
} else {
|
|
289
|
290
|
msg = "客户不能为空";
|
|
290
|
291
|
}
|
|
291
|
|
-
|
|
292
|
292
|
return msg;
|
|
293
|
293
|
}
|
|
294
|
294
|
|
|
|
@@ -400,8 +400,10 @@ public class WebSocket {
|
|
400
|
400
|
String kf = khkfs.get(sendUser);
|
|
401
|
401
|
if (StringHelper.isEmpty(kf)) {
|
|
402
|
402
|
kf = servicerQueue.poll();
|
|
403
|
|
- servicerQueue.add(kf);
|
|
404
|
|
- khkfs.put(sendUser, kf);
|
|
|
403
|
+ if(!StringHelper.isEmpty(kf)) {
|
|
|
404
|
+ servicerQueue.add(kf);
|
|
|
405
|
+ khkfs.put(sendUser, kf);
|
|
|
406
|
+ }
|
|
405
|
407
|
}
|
|
406
|
408
|
if (!StringHelper.isEmpty(kf)) {
|
|
407
|
409
|
message.setKfUser(kf);
|
|
|
@@ -419,15 +421,17 @@ public class WebSocket {
|
|
419
|
421
|
messageService.insert(message);
|
|
420
|
422
|
}
|
|
421
|
423
|
|
|
422
|
|
- public void addCustomer(String userCode,Integer source){
|
|
|
424
|
+ public void addCustomer(String userCode,Integer source) {
|
|
|
425
|
+ ICustomerService cusService = SpringHelper.getBean(ICustomerService.class);
|
|
423
|
426
|
LambdaQueryWrapper<Customer> qw = new LambdaQueryWrapper();
|
|
424
|
|
- qw.eq(Customer::getCustomerNo,userCode);
|
|
425
|
|
- if(!customerService.exists(qw)){
|
|
426
|
|
- Customer customer=new Customer();
|
|
|
427
|
+ qw.eq(Customer::getCustomerNo, userCode);
|
|
|
428
|
+ if (!cusService.exists(qw)) {
|
|
|
429
|
+ Customer customer = new Customer();
|
|
427
|
430
|
customer.setCustomerNo(userCode);
|
|
428
|
431
|
customer.setType(Long.valueOf(source));
|
|
429
|
432
|
customer.setFCreatetime(new Date());
|
|
430
|
|
- customerService.insert(customer);
|
|
|
433
|
+ customer.setFIsdelete(0L);
|
|
|
434
|
+ cusService.insert(customer);
|
|
431
|
435
|
}
|
|
432
|
436
|
}
|
|
433
|
437
|
|