Browse Source

Merge branch 'master' of http://git.dashitech.com/seimin/zy-pc

maotao 4 months ago
parent
commit
c10fe29b59

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

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

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

@@ -2,7 +2,7 @@
2
  * @Author: seimin
2
  * @Author: seimin
3
  * @Date: 2024-03-11 11:11:09
3
  * @Date: 2024-03-11 11:11:09
4
  * @LastEditors: seimin
4
  * @LastEditors: seimin
5
- * @LastEditTime: 2024-09-24 16:38:23
5
+ * @LastEditTime: 2024-11-28 03:03:38
6
  * @Description: 录音盒websocket服务
6
  * @Description: 录音盒websocket服务
7
  */
7
  */
8
 import { Injectable } from "@angular/core";
8
 import { Injectable } from "@angular/core";
@@ -60,15 +60,17 @@ export class WebsocketPhoneService {
60
       console.log("ws连接关闭" + new Date().toLocaleString(), this.isHandler);
60
       console.log("ws连接关闭" + new Date().toLocaleString(), this.isHandler);
61
       this.ws = null;
61
       this.ws = null;
62
       console.log(response)
62
       console.log(response)
63
-      if (!this.isHandler && response.status === 408) {
63
+      if (!this.isHandler && response.status === 408 && sessionStorage.getItem('phoneNumber')) {
64
         this.reconnect(this.url, this.urlParams);
64
         this.reconnect(this.url, this.urlParams);
65
+      }else{
66
+        this.updateProperty(false);
65
       }
67
       }
66
     };
68
     };
67
 
69
 
68
     request.onError = (response) => {
70
     request.onError = (response) => {
69
       console.log("ws连接错误", this.isHandler);
71
       console.log("ws连接错误", this.isHandler);
70
       this.ws = null;
72
       this.ws = null;
71
-      if (response.status === 0) {
73
+      if (response.status === 0 && sessionStorage.getItem('phoneNumber')) {
72
         this.reconnect(this.url, this.urlParams);
74
         this.reconnect(this.url, this.urlParams);
73
       }
75
       }
74
     };
76
     };
@@ -119,4 +121,17 @@ export class WebsocketPhoneService {
119
       this.ws.close();
121
       this.ws.close();
120
     }
122
     }
121
   }
123
   }
124
+
125
+  // 创建一个Subject来发送和接收数据
126
+  private updateData = new Subject<any>();
127
+
128
+  // 提供一个方法来发送数据
129
+  updateProperty(data: any) {
130
+    this.updateData.next(data);
131
+  }
132
+
133
+  // 提供一个方法来订阅数据
134
+  getDataUpdate(): Subject<any> {
135
+    return this.updateData;
136
+  }
122
 }
137
 }

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

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

+ 26 - 12
src/app/views/fuwutai/fuwutai.component.ts

@@ -116,7 +116,12 @@ export class FuwutaiComponent implements OnInit {
116
     private http: HttpClient,
116
     private http: HttpClient,
117
     public route: ActivatedRoute,
117
     public route: ActivatedRoute,
118
     public incomingService: WebsocketIncomingService,
118
     public incomingService: WebsocketIncomingService,
119
-  ) {}
119
+  ) {
120
+    // 在组件中订阅服务的Observable
121
+    this.phones.getDataUpdate().subscribe(data => {
122
+      this.websocketLoading = data;
123
+    });
124
+  }
120
   validateFormZy!: FormGroup;
125
   validateFormZy!: FormGroup;
121
   validateFormQt!: FormGroup;
126
   validateFormQt!: FormGroup;
122
   // ---------------------------------------
127
   // ---------------------------------------
@@ -804,6 +809,7 @@ export class FuwutaiComponent implements OnInit {
804
     TLWSA.onOpenreturn = (err) => {
809
     TLWSA.onOpenreturn = (err) => {
805
       err = Number(err);
810
       err = Number(err);
806
       if (!err) {
811
       if (!err) {
812
+        _this.incomingService.setPhoneNumber(TLWSA.phoneNumber);
807
         _this.websocketLoading = false;
813
         _this.websocketLoading = false;
808
         _this.cancelBindExtensionNumber();
814
         _this.cancelBindExtensionNumber();
809
         console.log('呼叫中心连接成功-----seimin');
815
         console.log('呼叫中心连接成功-----seimin');
@@ -888,12 +894,17 @@ export class FuwutaiComponent implements OnInit {
888
       clearTimeout(timer);
894
       clearTimeout(timer);
889
       if(location.hash === '#/dispatchingDesk'){
895
       if(location.hash === '#/dispatchingDesk'){
890
         console.log('与服务器网络连接中断-----seimin');
896
         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)
897
+        if(this.incomingService.getPhoneNumber()){
898
+          _this.msg.info('与服务器网络连接中断,2分钟后重连')
899
+          console.log('2分钟后自动重连-----seimin')
900
+          timer = setTimeout(function () {
901
+            //连接
902
+            TLWSA.phoneNumber = _this.incomingService.getPhoneNumber();
903
+            tlwsa.tlaOpen(_this.incomingService.getSocketUrl());
904
+          }, 120000)
905
+        }else{
906
+          _this.websocketLoading = false;
907
+        }
897
       }
908
       }
898
     }
909
     }
899
     //签入回调函数
910
     //签入回调函数
@@ -1349,14 +1360,15 @@ export class FuwutaiComponent implements OnInit {
1349
 
1360
 
1350
   showBindExtensionNumber() {
1361
   showBindExtensionNumber() {
1351
     this.showBindExtensionNumberModal = true;
1362
     this.showBindExtensionNumberModal = true;
1363
+    this.websocketLoading = false;
1352
   }
1364
   }
1353
 
1365
 
1354
   // 保存绑定分机-签入
1366
   // 保存绑定分机-签入
1355
   checkIn(phoneNumber){
1367
   checkIn(phoneNumber){
1356
     this.websocketLoading = true;
1368
     this.websocketLoading = true;
1357
-    this.incomingService.setPhoneNumber(phoneNumber);
1369
+    // this.incomingService.setPhoneNumber(phoneNumber);
1358
     this.incomingService.closeWs(true);
1370
     this.incomingService.closeWs(true);
1359
-    this.getWebsocketPhone();
1371
+    this.getWebsocketPhone(phoneNumber);
1360
   }
1372
   }
1361
 
1373
 
1362
   // 签出
1374
   // 签出
@@ -1385,11 +1397,11 @@ export class FuwutaiComponent implements OnInit {
1385
     // tel1: '',//目的号码对象
1397
     // tel1: '',//目的号码对象
1386
     // tel2: '',//转接坐席对象
1398
     // tel2: '',//转接坐席对象
1387
   }
1399
   }
1388
-  getWebsocketPhone() {
1400
+  getWebsocketPhone(phoneNumber) {
1389
     const sign = this.incomingService.getSign();
1401
     const sign = this.incomingService.getSign();
1390
     if(sign === 'box'){
1402
     if(sign === 'box'){
1391
       // 录音盒
1403
       // 录音盒
1392
-      this.incomingService.connectWs().subscribe((data) => {
1404
+      this.incomingService.connectWs(phoneNumber).subscribe((data) => {
1393
         // data = { status: 201, phone: '013581394341' };//ceshi
1405
         // data = { status: 201, phone: '013581394341' };//ceshi
1394
         console.log(data);
1406
         console.log(data);
1395
         console.log(this.incidentModel);
1407
         console.log(this.incidentModel);
@@ -1397,6 +1409,7 @@ export class FuwutaiComponent implements OnInit {
1397
 
1409
 
1398
         // 200签入 201摘机 202来电
1410
         // 200签入 201摘机 202来电
1399
         if (data.status == 200 && data.phone) {
1411
         if (data.status == 200 && data.phone) {
1412
+          this.incomingService.setPhoneNumber(phoneNumber);
1400
           this.incidentModel = {};
1413
           this.incidentModel = {};
1401
           this.incidentMsg = {};
1414
           this.incidentMsg = {};
1402
           this.incidentModel.callID = data.callId || undefined;
1415
           this.incidentModel.callID = data.callId || undefined;
@@ -1426,6 +1439,7 @@ export class FuwutaiComponent implements OnInit {
1426
       // 呼叫中心----start
1439
       // 呼叫中心----start
1427
       this.preState = '';
1440
       this.preState = '';
1428
       //连接
1441
       //连接
1442
+      TLWSA.phoneNumber = phoneNumber;
1429
       tlwsa.tlaOpen(this.incomingService.getSocketUrl());
1443
       tlwsa.tlaOpen(this.incomingService.getSocketUrl());
1430
     }else{
1444
     }else{
1431
       this.websocketLoading = false;
1445
       this.websocketLoading = false;
@@ -2485,7 +2499,7 @@ export class FuwutaiComponent implements OnInit {
2485
       this.incomingService.removePhoneNumber();
2499
       this.incomingService.removePhoneNumber();
2486
     }
2500
     }
2487
     if (this.incomingService.getPhoneNumber()) {
2501
     if (this.incomingService.getPhoneNumber()) {
2488
-      this.getWebsocketPhone();
2502
+      this.getWebsocketPhone(this.incomingService.getPhoneNumber());
2489
     }else{
2503
     }else{
2490
       this.websocketLoading = false;
2504
       this.websocketLoading = false;
2491
     }
2505
     }