Kaynağa Gözat

呼叫中心录音盒失败处理

seimin 4 ay önce
ebeveyn
işleme
ea7d3ec910

+ 3 - 3
src/app/services/websocket-incoming.service.ts

@@ -2,7 +2,7 @@
2 2
  * @Author: seimin
3 3
  * @Date: 2024-09-24 16:34:47
4 4
  * @LastEditors: seimin
5
- * @LastEditTime: 2024-09-29 15:41:54
5
+ * @LastEditTime: 2024-11-28 03:12:59
6 6
  * @Description: 来电弹屏websocket服务
7 7
  */
8 8
 import { Injectable } from "@angular/core";
@@ -24,8 +24,8 @@ export class WebsocketIncomingService {
24 24
 
25 25
   // 连接websocket { userCount }
26 26
   private user = JSON.parse(localStorage.getItem("user")); //用户信息
27
-  connectWs(): Observable<any> {
28
-    let userCount = this.user.user.account + "|" + this.getPhoneNumber();
27
+  connectWs(phoneNumber): Observable<any> {
28
+    let userCount = this.user.user.account + "|" + phoneNumber;
29 29
     if(this.getSign() === 'box'){
30 30
       return this.phoneService.connectWs(http.phoneWs, { userCount });
31 31
     }

+ 3 - 3
src/app/services/websocket-phone.service.ts

@@ -2,7 +2,7 @@
2 2
  * @Author: seimin
3 3
  * @Date: 2024-03-11 11:11:09
4 4
  * @LastEditors: seimin
5
- * @LastEditTime: 2024-09-24 16:38:23
5
+ * @LastEditTime: 2024-11-28 03:03:38
6 6
  * @Description: 录音盒websocket服务
7 7
  */
8 8
 import { Injectable } from "@angular/core";
@@ -60,7 +60,7 @@ export class WebsocketPhoneService {
60 60
       console.log("ws连接关闭" + new Date().toLocaleString(), this.isHandler);
61 61
       this.ws = null;
62 62
       console.log(response)
63
-      if (!this.isHandler && response.status === 408) {
63
+      if (!this.isHandler && response.status === 408 && sessionStorage.getItem('phoneNumber')) {
64 64
         this.reconnect(this.url, this.urlParams);
65 65
       }
66 66
     };
@@ -68,7 +68,7 @@ export class WebsocketPhoneService {
68 68
     request.onError = (response) => {
69 69
       console.log("ws连接错误", this.isHandler);
70 70
       this.ws = null;
71
-      if (response.status === 0) {
71
+      if (response.status === 0 && sessionStorage.getItem('phoneNumber')) {
72 72
         this.reconnect(this.url, this.urlParams);
73 73
       }
74 74
     };

+ 1 - 1
src/app/views/fuwutai/fuwutai.component.html

@@ -926,7 +926,7 @@
926 926
           </button>
927 927
         </div>
928 928
       </div>
929
-      <div class="fixedMenu" *ngIf="!websocketLoading && !incomingService.getPhoneNumber()">
929
+      <div class="fixedMenu" *ngIf="!incomingService.getPhoneNumber()">
930 930
         <div class="menuItems">
931 931
           <button nz-button nzType="link" class="item itemLink" (click)="showBindExtensionNumber()">
932 932
             绑定分机

+ 20 - 11
src/app/views/fuwutai/fuwutai.component.ts

@@ -804,6 +804,7 @@ export class FuwutaiComponent implements OnInit {
804 804
     TLWSA.onOpenreturn = (err) => {
805 805
       err = Number(err);
806 806
       if (!err) {
807
+        _this.incomingService.setPhoneNumber(TLWSA.phoneNumber);
807 808
         _this.websocketLoading = false;
808 809
         _this.cancelBindExtensionNumber();
809 810
         console.log('呼叫中心连接成功-----seimin');
@@ -888,12 +889,17 @@ export class FuwutaiComponent implements OnInit {
888 889
       clearTimeout(timer);
889 890
       if(location.hash === '#/dispatchingDesk'){
890 891
         console.log('与服务器网络连接中断-----seimin');
891
-        _this.msg.info('与服务器网络连接中断,2分钟后重连')
892
-        console.log('2分钟后自动重连-----seimin')
893
-        timer = setTimeout(function () {
894
-          //连接
895
-          tlwsa.tlaOpen(_this.incomingService.getSocketUrl());
896
-        }, 120000)
892
+        if(this.incomingService.getPhoneNumber()){
893
+          _this.msg.info('与服务器网络连接中断,2分钟后重连')
894
+          console.log('2分钟后自动重连-----seimin')
895
+          timer = setTimeout(function () {
896
+            //连接
897
+            TLWSA.phoneNumber = _this.incomingService.getPhoneNumber();
898
+            tlwsa.tlaOpen(_this.incomingService.getSocketUrl());
899
+          }, 120000)
900
+        }else{
901
+          _this.websocketLoading = false;
902
+        }
897 903
       }
898 904
     }
899 905
     //签入回调函数
@@ -1349,14 +1355,15 @@ export class FuwutaiComponent implements OnInit {
1349 1355
 
1350 1356
   showBindExtensionNumber() {
1351 1357
     this.showBindExtensionNumberModal = true;
1358
+    this.websocketLoading = false;
1352 1359
   }
1353 1360
 
1354 1361
   // 保存绑定分机-签入
1355 1362
   checkIn(phoneNumber){
1356 1363
     this.websocketLoading = true;
1357
-    this.incomingService.setPhoneNumber(phoneNumber);
1364
+    // this.incomingService.setPhoneNumber(phoneNumber);
1358 1365
     this.incomingService.closeWs(true);
1359
-    this.getWebsocketPhone();
1366
+    this.getWebsocketPhone(phoneNumber);
1360 1367
   }
1361 1368
 
1362 1369
   // 签出
@@ -1385,11 +1392,11 @@ export class FuwutaiComponent implements OnInit {
1385 1392
     // tel1: '',//目的号码对象
1386 1393
     // tel2: '',//转接坐席对象
1387 1394
   }
1388
-  getWebsocketPhone() {
1395
+  getWebsocketPhone(phoneNumber) {
1389 1396
     const sign = this.incomingService.getSign();
1390 1397
     if(sign === 'box'){
1391 1398
       // 录音盒
1392
-      this.incomingService.connectWs().subscribe((data) => {
1399
+      this.incomingService.connectWs(phoneNumber).subscribe((data) => {
1393 1400
         // data = { status: 201, phone: '013581394341' };//ceshi
1394 1401
         console.log(data);
1395 1402
         console.log(this.incidentModel);
@@ -1397,6 +1404,7 @@ export class FuwutaiComponent implements OnInit {
1397 1404
 
1398 1405
         // 200签入 201摘机 202来电
1399 1406
         if (data.status == 200 && data.phone) {
1407
+          this.incomingService.setPhoneNumber(phoneNumber);
1400 1408
           this.incidentModel = {};
1401 1409
           this.incidentMsg = {};
1402 1410
           this.incidentModel.callID = data.callId || undefined;
@@ -1426,6 +1434,7 @@ export class FuwutaiComponent implements OnInit {
1426 1434
       // 呼叫中心----start
1427 1435
       this.preState = '';
1428 1436
       //连接
1437
+      TLWSA.phoneNumber = phoneNumber;
1429 1438
       tlwsa.tlaOpen(this.incomingService.getSocketUrl());
1430 1439
     }else{
1431 1440
       this.websocketLoading = false;
@@ -2485,7 +2494,7 @@ export class FuwutaiComponent implements OnInit {
2485 2494
       this.incomingService.removePhoneNumber();
2486 2495
     }
2487 2496
     if (this.incomingService.getPhoneNumber()) {
2488
-      this.getWebsocketPhone();
2497
+      this.getWebsocketPhone(this.incomingService.getPhoneNumber());
2489 2498
     }else{
2490 2499
       this.websocketLoading = false;
2491 2500
     }