CX 1 year ago
parent
commit
6436e5cd7e
1 changed files with 34 additions and 9 deletions
  1. 34 9
      src/main/java/com/dashitech/callcenter/socket/HandlerThread.java

+ 34 - 9
src/main/java/com/dashitech/callcenter/socket/HandlerThread.java

@@ -251,18 +251,16 @@ public class HandlerThread  {
251 251
                             if (jsonObject.containsKey("dtmfa") && jsonObject.get("dtmfa").toString() != null && !jsonObject.optString("dtmfa").toString().equals("")){
252 252
                                 rMap.put("phone", jsonObject.opt("dtmfa"));
253 253
                                 rMap.put("status", 201);
254
+                                rMap.put("callId",jsonObject.optString("uuid"));
254 255
 
255
-                                //TODO 先保存通话记录
256
-                                CallLogEntity callLogEntity = new CallLogEntity();
257
-                                callLogEntity.setdTMFA(jsonObject.optString("dtmfa"));
258
-                                callLogEntity.setdTMFB(jsonObject.optString("dtmfb"));
256
+//                                //TODO 先保存通话记录,打通了的走这里
257
+                                log.info("先保存通话记录2:"+jsonObject.toString());
258
+                                CallLogEntity callLogEntity = getCallLog(jsonObject);
259 259
                                 if(StringUtils.isNotEmpty(jsonObject.optString("rstime"))) {
260 260
                                     callLogEntity.setResponseTime(DateUtil2.parseDateTime(jsonObject.optString("rstime")));
261 261
                                 }
262 262
 
263 263
                                 saveItsmCallRecord(callLogEntity,jsonObject.optString("uuid"));
264
-                                rMap.put("callId",jsonObject.optString("uuid"));
265
-
266 264
                             }else {
267 265
                                 rMap.put("phone","");
268 266
                                 rMap.put("status", 201);
@@ -280,8 +278,6 @@ public class HandlerThread  {
280 278
                         if (jsonObject.containsKey("channel")&&jsonObject.get("channel").toString()!=null){
281 279
                             PhoneWebSocket.sendMessage(phoneMap.get(his+jsonObject.get("channel").toString()),json);
282 280
                         }
283
-                        CallLogEntity callLog = new CallLogEntity();
284
-                        callLog.setCallState(0);
285 281
                     }
286 282
                 }
287 283
 
@@ -307,6 +303,15 @@ public class HandlerThread  {
307 303
                 }
308 304
                 callLog.setHosId(Integer.parseInt(his));
309 305
                 callLogDAO.save(callLog);
306
+
307
+                log.info("先保存通话记录1:"+jsonObject.toString());
308
+                //TODO 先保存通话记录,打不通的走这里
309
+                if(StringUtils.isNotEmpty(jsonObject.optString("rstime"))) {
310
+                    callLog.setResponseTime(DateUtil2.parseDateTime(jsonObject.optString("rstime")));
311
+                }
312
+
313
+                saveItsmCallRecord(callLog,jsonObject.optString("uuid"));
314
+
310 315
             }
311 316
         }else if(jsonObject.get("phonestate").toString().equals("1")){
312 317
             phoneLog.put(his+jsonObject.get("channel").toString(),null);
@@ -356,6 +361,7 @@ public class HandlerThread  {
356 361
      * @param message
357 362
      */
358 363
     public void saveCallLog(String message,String his){
364
+        log.info(message);
359 365
         //TODO 修改通话记录数据;DTMFA DTMFB rstime
360 366
         if (JsonUtil.toJSONObject(message).containsKey("recordList")) {
361 367
             List list = JsonUtil.toJSONObject(message).optJSONArray("recordList");
@@ -399,7 +405,13 @@ public class HandlerThread  {
399 405
                     }else{//未知
400 406
                         callLog.setCallType(2);
401 407
                     }
408
+//                    callLog.setCallState(1);
409
+                }
410
+                //是否接电话,1接了,0未接
411
+                if (jsonObject.get("rstime") != null && StringUtils.isNotEmpty(jsonObject.get("rstime").toString())){
402 412
                     callLog.setCallState(1);
413
+                }else {
414
+                    callLog.setCallState(0);
403 415
                 }
404 416
                 callLog.setHosId(Integer.parseInt(his));
405 417
                 callLogDAO.save(callLog);
@@ -454,6 +466,16 @@ public class HandlerThread  {
454 466
                         recordEntity.setCallerIdNumber(callLog.getdTMFA());
455 467
                         recordEntity.setDestinationNumber(callLog.getdTMFB());
456 468
                         recordEntity.setCreatedTime(callLog.getResponseTime());
469
+                        recordEntity.setIsAnswered(callLog.getCallState());
470
+                        recordEntity.setCallTime("0");
471
+                        recordEntity.setOverTime(new Date());
472
+                        recordEntity.setBranch(callLog.getHosId() == null ? null : callLog.getHosId().longValue());
473
+                        if(callLog.getCallType() != null && "0".equals(callLog.getCallType().toString())) {
474
+                            recordEntity.setCallType("1");
475
+                        }else if(callLog.getCallType() != null && "1".equals(callLog.getCallType().toString())) {
476
+                            recordEntity.setCallType("2");
477
+                        }
478
+                        recordEntity.setGateWay(callLog.getPhyIDA());
457 479
                         callRecordDAO.save(recordEntity);
458 480
                         log.info("新增临时通话记录完成");
459 481
                     }else {
@@ -503,13 +525,16 @@ public class HandlerThread  {
503 525
                         }
504 526
                     }
505 527
                     //处理录音地址
506
-                    if(callLog.getPath() != null) {
528
+                    if(callLog.getPath() != null && StringUtils.isNotEmpty(callLog.getPath())) {
507 529
                         String newPath = callLog.getPath();
508 530
                         String[] arr = callLog.getPath().split(recordRegex);
509 531
                         if (arr.length > 1) {
510 532
                             newPath = recordNginxPath + arr[1];
511 533
                         }
512 534
                         recordEntity.setRecordingFileName(newPath);
535
+                    }else {
536
+                        log.info("callLog 保存没有路径path");
537
+                        return;
513 538
                     }
514 539
 
515 540
                     callRecordDAO.save(recordEntity);