seimin 3 年之前
父节点
当前提交
e380516acd

+ 50 - 9
package-lock.json

@@ -784,7 +784,7 @@
784
     },
784
     },
785
     "@types/jquery": {
785
     "@types/jquery": {
786
       "version": "3.5.6",
786
       "version": "3.5.6",
787
-      "resolved": "https://registry.nlark.com/@types/jquery/download/@types/jquery-3.5.6.tgz?cache=0&sync_timestamp=1629708196495&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fjquery%2Fdownload%2F%40types%2Fjquery-3.5.6.tgz",
787
+      "resolved": "https://registry.nlark.com/@types/jquery/download/@types/jquery-3.5.6.tgz",
788
       "integrity": "sha1-l6yONtzNitjtPz87SJM2FNn9jPA=",
788
       "integrity": "sha1-l6yONtzNitjtPz87SJM2FNn9jPA=",
789
       "dev": true,
789
       "dev": true,
790
       "requires": {
790
       "requires": {
@@ -822,7 +822,7 @@
822
     },
822
     },
823
     "@types/sizzle": {
823
     "@types/sizzle": {
824
       "version": "2.3.3",
824
       "version": "2.3.3",
825
-      "resolved": "https://registry.nlark.com/@types/sizzle/download/@types/sizzle-2.3.3.tgz?cache=0&sync_timestamp=1629709217852&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fsizzle%2Fdownload%2F%40types%2Fsizzle-2.3.3.tgz",
825
+      "resolved": "https://registry.nlark.com/@types/sizzle/download/@types/sizzle-2.3.3.tgz?cache=0&sync_timestamp=1621243834244&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fsizzle%2Fdownload%2F%40types%2Fsizzle-2.3.3.tgz",
826
       "integrity": "sha1-/14vGQKWnTBSJaBHyKD9XJFc6+8=",
826
       "integrity": "sha1-/14vGQKWnTBSJaBHyKD9XJFc6+8=",
827
       "dev": true
827
       "dev": true
828
     },
828
     },
@@ -1396,6 +1396,41 @@
1396
       "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
1396
       "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
1397
       "dev": true
1397
       "dev": true
1398
     },
1398
     },
1399
+    "atmosphere.js": {
1400
+      "version": "2.3.6",
1401
+      "resolved": "https://registry.npmmirror.com/atmosphere.js/download/atmosphere.js-2.3.6.tgz",
1402
+      "integrity": "sha1-177Y28qZHNOhQ8XzAjDJCU3/Zfs=",
1403
+      "requires": {
1404
+        "eventsource": "^0.1.6",
1405
+        "npm": "^6.2.0",
1406
+        "ws": "^1.0.1",
1407
+        "xmlhttprequest": "^1.8.0"
1408
+      },
1409
+      "dependencies": {
1410
+        "eventsource": {
1411
+          "version": "0.1.6",
1412
+          "resolved": "https://registry.npm.taobao.org/eventsource/download/eventsource-0.1.6.tgz?cache=0&sync_timestamp=1616041716084&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Feventsource%2Fdownload%2Feventsource-0.1.6.tgz",
1413
+          "integrity": "sha1-Cs7ehJ7X3RzMMsgRuxG5RNTykjI=",
1414
+          "requires": {
1415
+            "original": ">=0.0.5"
1416
+          }
1417
+        },
1418
+        "ultron": {
1419
+          "version": "1.0.2",
1420
+          "resolved": "https://registry.npm.taobao.org/ultron/download/ultron-1.0.2.tgz",
1421
+          "integrity": "sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po="
1422
+        },
1423
+        "ws": {
1424
+          "version": "1.1.5",
1425
+          "resolved": "https://registry.npmmirror.com/ws/download/ws-1.1.5.tgz?cache=0&sync_timestamp=1633200058938&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2Fws%2Fdownload%2Fws-1.1.5.tgz",
1426
+          "integrity": "sha1-y9nm514J/F0skAFfIfDECHXg3VE=",
1427
+          "requires": {
1428
+            "options": ">=0.0.5",
1429
+            "ultron": "1.0.x"
1430
+          }
1431
+        }
1432
+      }
1433
+    },
1399
     "atob": {
1434
     "atob": {
1400
       "version": "2.1.2",
1435
       "version": "2.1.2",
1401
       "resolved": "https://registry.npm.taobao.org/atob/download/atob-2.1.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fatob%2Fdownload%2Fatob-2.1.2.tgz",
1436
       "resolved": "https://registry.npm.taobao.org/atob/download/atob-2.1.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fatob%2Fdownload%2Fatob-2.1.2.tgz",
@@ -5244,7 +5279,7 @@
5244
     },
5279
     },
5245
     "jquery": {
5280
     "jquery": {
5246
       "version": "3.6.0",
5281
       "version": "3.6.0",
5247
-      "resolved": "https://registry.npm.taobao.org/jquery/download/jquery-3.6.0.tgz",
5282
+      "resolved": "https://registry.npm.taobao.org/jquery/download/jquery-3.6.0.tgz?cache=0&sync_timestamp=1614705838607&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjquery%2Fdownload%2Fjquery-3.6.0.tgz",
5248
       "integrity": "sha1-xyoJ8Vwb3OFC9J2/EXC9+K2sJHA="
5283
       "integrity": "sha1-xyoJ8Vwb3OFC9J2/EXC9+K2sJHA="
5249
     },
5284
     },
5250
     "js-tokens": {
5285
     "js-tokens": {
@@ -9862,11 +9897,15 @@
9862
         }
9897
         }
9863
       }
9898
       }
9864
     },
9899
     },
9900
+    "options": {
9901
+      "version": "0.0.6",
9902
+      "resolved": "https://registry.npm.taobao.org/options/download/options-0.0.6.tgz",
9903
+      "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8="
9904
+    },
9865
     "original": {
9905
     "original": {
9866
       "version": "1.0.2",
9906
       "version": "1.0.2",
9867
       "resolved": "https://registry.npm.taobao.org/original/download/original-1.0.2.tgz",
9907
       "resolved": "https://registry.npm.taobao.org/original/download/original-1.0.2.tgz",
9868
       "integrity": "sha1-5EKmHP/hxf0gpl8yYcJmY7MD8l8=",
9908
       "integrity": "sha1-5EKmHP/hxf0gpl8yYcJmY7MD8l8=",
9869
-      "dev": true,
9870
       "requires": {
9909
       "requires": {
9871
         "url-parse": "^1.4.3"
9910
         "url-parse": "^1.4.3"
9872
       }
9911
       }
@@ -10660,8 +10699,7 @@
10660
     "querystringify": {
10699
     "querystringify": {
10661
       "version": "2.2.0",
10700
       "version": "2.2.0",
10662
       "resolved": "https://registry.nlark.com/querystringify/download/querystringify-2.2.0.tgz",
10701
       "resolved": "https://registry.nlark.com/querystringify/download/querystringify-2.2.0.tgz",
10663
-      "integrity": "sha1-M0WUG0FTy50ILY7uTNogFqmu9/Y=",
10664
-      "dev": true
10702
+      "integrity": "sha1-M0WUG0FTy50ILY7uTNogFqmu9/Y="
10665
     },
10703
     },
10666
     "randombytes": {
10704
     "randombytes": {
10667
       "version": "2.1.0",
10705
       "version": "2.1.0",
@@ -10905,8 +10943,7 @@
10905
     "requires-port": {
10943
     "requires-port": {
10906
       "version": "1.0.0",
10944
       "version": "1.0.0",
10907
       "resolved": "https://registry.npm.taobao.org/requires-port/download/requires-port-1.0.0.tgz",
10945
       "resolved": "https://registry.npm.taobao.org/requires-port/download/requires-port-1.0.0.tgz",
10908
-      "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=",
10909
-      "dev": true
10946
+      "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
10910
     },
10947
     },
10911
     "resolve": {
10948
     "resolve": {
10912
       "version": "1.20.0",
10949
       "version": "1.20.0",
@@ -12755,7 +12792,6 @@
12755
       "version": "1.5.1",
12792
       "version": "1.5.1",
12756
       "resolved": "https://registry.npm.taobao.org/url-parse/download/url-parse-1.5.1.tgz",
12793
       "resolved": "https://registry.npm.taobao.org/url-parse/download/url-parse-1.5.1.tgz",
12757
       "integrity": "sha1-1fqYkK+KXh8nSiyYN2UQ9kJfbjs=",
12794
       "integrity": "sha1-1fqYkK+KXh8nSiyYN2UQ9kJfbjs=",
12758
-      "dev": true,
12759
       "requires": {
12795
       "requires": {
12760
         "querystringify": "^2.1.1",
12796
         "querystringify": "^2.1.1",
12761
         "requires-port": "^1.0.0"
12797
         "requires-port": "^1.0.0"
@@ -13660,6 +13696,11 @@
13660
       "integrity": "sha1-vpuuHIoEbnazESdyY0fQrXACvrM=",
13696
       "integrity": "sha1-vpuuHIoEbnazESdyY0fQrXACvrM=",
13661
       "dev": true
13697
       "dev": true
13662
     },
13698
     },
13699
+    "xmlhttprequest": {
13700
+      "version": "1.8.0",
13701
+      "resolved": "https://registry.npm.taobao.org/xmlhttprequest/download/xmlhttprequest-1.8.0.tgz",
13702
+      "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw="
13703
+    },
13663
     "xmlhttprequest-ssl": {
13704
     "xmlhttprequest-ssl": {
13664
       "version": "1.5.5",
13705
       "version": "1.5.5",
13665
       "resolved": "https://registry.nlark.com/xmlhttprequest-ssl/download/xmlhttprequest-ssl-1.5.5.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fxmlhttprequest-ssl%2Fdownload%2Fxmlhttprequest-ssl-1.5.5.tgz",
13706
       "resolved": "https://registry.nlark.com/xmlhttprequest-ssl/download/xmlhttprequest-ssl-1.5.5.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fxmlhttprequest-ssl%2Fdownload%2Fxmlhttprequest-ssl-1.5.5.tgz",

+ 1 - 0
package.json

@@ -24,6 +24,7 @@
24
     "@angular/router": "~8.1.1",
24
     "@angular/router": "~8.1.1",
25
     "@types/crypto-js": "^3.1.47",
25
     "@types/crypto-js": "^3.1.47",
26
     "@types/overlayscrollbars": "^1.12.1",
26
     "@types/overlayscrollbars": "^1.12.1",
27
+    "atmosphere.js": "2.3.6",
27
     "core-js": "^3.18.2",
28
     "core-js": "^3.18.2",
28
     "crypto-js": "^3.3.0",
29
     "crypto-js": "^3.3.0",
29
     "datatables.net": "^1.11.3",
30
     "datatables.net": "^1.11.3",

+ 106 - 0
src/app/services/websocket-index.service.ts

@@ -0,0 +1,106 @@
1
+import { Injectable } from "@angular/core";
2
+import { Subject, Observable, from } from "rxjs";
3
+import * as Atmosphere from "atmosphere.js";
4
+
5
+@Injectable({
6
+  providedIn: "root",
7
+})
8
+export class WebsocketIndexService {
9
+  constructor() {}
10
+  private lockReconnect = false; //避免ws重复连接
11
+  ws; //定义websocket
12
+  private url = ""; //ws连接地址
13
+  private urlParams; //ws连接传参
14
+  private isHandler = false; //是否手动
15
+  private subject;
16
+  // 连接websocket
17
+  connectWs(url, data): Observable<any> {
18
+    this.url = url;
19
+    this.urlParams = data;
20
+    this.subject = new Subject<any>();
21
+    let request: any = {
22
+      url,
23
+      contentType: "application/json",
24
+      shared: true, // 标签共享
25
+      trackMessageLength: true, //校验数据完整性
26
+      transport: "websocket",
27
+    };
28
+
29
+    request.onOpen = (response) => {
30
+      console.log("ws连接成功" + new Date().toLocaleString());
31
+      this.heartCheck.reset().start(this);
32
+      this.ws.push(JSON.stringify(data));
33
+    };
34
+
35
+    request.onMessage = (response) => {
36
+      this.heartCheck.reset().start(this);
37
+      let message = response.responseBody;
38
+      try {
39
+        // alert(message);
40
+        console.log("收到消息" + message);
41
+        if (message !== "pong") {
42
+          this.subject.next(JSON.parse(message));
43
+        }
44
+      } catch (e) {
45
+        console.log("This doesn't look like a valid JSON: ", message);
46
+        return;
47
+      }
48
+    };
49
+
50
+    request.onClose = (response) => {
51
+      console.log("ws连接关闭" + new Date().toLocaleString(), this.isHandler);
52
+      this.heartCheck.reset();
53
+      if (!this.isHandler) {
54
+        this.reconnect(this.url, this.urlParams);
55
+      }
56
+    };
57
+
58
+    request.onError = (response) => {
59
+      console.log("ws连接错误", this.isHandler);
60
+      this.heartCheck.reset();
61
+      if (!this.isHandler) {
62
+        this.reconnect(this.url, this.urlParams);
63
+      }
64
+    };
65
+
66
+    this.ws = Atmosphere.subscribe(request);
67
+    return this.subject.asObservable();
68
+  }
69
+  //断线重连
70
+  private reconnect(url, data) {
71
+    if (this.lockReconnect) return;
72
+    this.lockReconnect = true;
73
+    setTimeout(() => {
74
+      //没连接上会一直重连,设置延迟避免请求过多
75
+      this.connectWs(url, data);
76
+      this.lockReconnect = false;
77
+    }, 15000);
78
+  }
79
+  private heartCheck = {
80
+    timeout: 60000, //1分钟发一次心跳
81
+    timeoutObj: null,
82
+    serverTimeoutObj: null,
83
+    reset: function () {
84
+      clearTimeout(this.timeoutObj);
85
+      clearTimeout(this.serverTimeoutObj);
86
+      return this;
87
+    },
88
+    start: function (_this) {
89
+      this.timeoutObj = setTimeout(() => {
90
+        //这里发送一个心跳,后端收到后,返回一个心跳消息,
91
+        //onmessage拿到返回的心跳就说明连接正常
92
+        _this.ws.push("ping");
93
+        this.serverTimeoutObj = setTimeout(() => {
94
+          //如果超过一定时间还没重置,说明后端主动断开了
95
+          _this.closeWs(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
96
+        }, this.timeout);
97
+      }, this.timeout);
98
+    },
99
+  };
100
+
101
+  // 断开websocket
102
+  closeWs(flag: boolean = false) {
103
+    this.isHandler = flag;
104
+    this.ws.close();
105
+  }
106
+}

+ 106 - 0
src/app/services/websocket-main.service.ts

@@ -0,0 +1,106 @@
1
+import { Injectable } from "@angular/core";
2
+import { Subject, Observable, from } from "rxjs";
3
+import * as Atmosphere from "atmosphere.js";
4
+
5
+@Injectable({
6
+  providedIn: "root",
7
+})
8
+export class WebsocketMainService {
9
+  constructor() {}
10
+  private lockReconnect = false; //避免ws重复连接
11
+  ws; //定义websocket
12
+  private url = ""; //ws连接地址
13
+  private urlParams; //ws连接传参
14
+  private isHandler = false; //是否手动
15
+  private subject;
16
+  // 连接websocket
17
+  connectWs(url, data): Observable<any> {
18
+    this.url = url;
19
+    this.urlParams = data;
20
+    this.subject = new Subject<any>();
21
+    let request: any = {
22
+      url,
23
+      contentType: "application/json",
24
+      shared: true, // 标签共享
25
+      trackMessageLength: true, //校验数据完整性
26
+      transport: "websocket",
27
+    };
28
+
29
+    request.onOpen = (response) => {
30
+      console.log("ws连接成功" + new Date().toLocaleString());
31
+      this.heartCheck.reset().start(this);
32
+      this.ws.push(JSON.stringify(data));
33
+    };
34
+
35
+    request.onMessage = (response) => {
36
+      this.heartCheck.reset().start(this);
37
+      let message = response.responseBody;
38
+      try {
39
+        // alert(message);
40
+        console.log("收到消息" + message);
41
+        if (message !== "pong") {
42
+          this.subject.next(JSON.parse(message));
43
+        }
44
+      } catch (e) {
45
+        console.log("This doesn't look like a valid JSON: ", message);
46
+        return;
47
+      }
48
+    };
49
+
50
+    request.onClose = (response) => {
51
+      console.log("ws连接关闭" + new Date().toLocaleString(),this.isHandler);
52
+      this.heartCheck.reset();
53
+      if (!this.isHandler) {
54
+        this.reconnect(this.url, this.urlParams);
55
+      }
56
+    };
57
+
58
+    request.onError = (response) => {
59
+      console.log("ws连接错误",this.isHandler);
60
+      this.heartCheck.reset();
61
+      if (!this.isHandler) {
62
+        this.reconnect(this.url, this.urlParams);
63
+      }
64
+    };
65
+
66
+    this.ws = Atmosphere.subscribe(request);
67
+    return this.subject.asObservable();
68
+  }
69
+  //断线重连
70
+  private reconnect(url, data) {
71
+    if (this.lockReconnect) return;
72
+    this.lockReconnect = true;
73
+    setTimeout(() => {
74
+      //没连接上会一直重连,设置延迟避免请求过多
75
+      this.connectWs(url, data);
76
+      this.lockReconnect = false;
77
+    }, 15000);
78
+  }
79
+  private heartCheck = {
80
+    timeout: 60000, //1分钟发一次心跳
81
+    timeoutObj: null,
82
+    serverTimeoutObj: null,
83
+    reset: function () {
84
+      clearTimeout(this.timeoutObj);
85
+      clearTimeout(this.serverTimeoutObj);
86
+      return this;
87
+    },
88
+    start: function (_this) {
89
+      this.timeoutObj = setTimeout(() => {
90
+        //这里发送一个心跳,后端收到后,返回一个心跳消息,
91
+        //onmessage拿到返回的心跳就说明连接正常
92
+        _this.ws.push("ping");
93
+        this.serverTimeoutObj = setTimeout(() => {
94
+          //如果超过一定时间还没重置,说明后端主动断开了
95
+          _this.closeWs(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
96
+        }, this.timeout);
97
+      }, this.timeout);
98
+    },
99
+  };
100
+
101
+  // 断开websocket
102
+  closeWs(flag: boolean = false) {
103
+    this.isHandler = flag;
104
+    this.ws.close();
105
+  }
106
+}

+ 106 - 0
src/app/services/websocket-nurse.service.ts

@@ -0,0 +1,106 @@
1
+import { Injectable } from "@angular/core";
2
+import { Subject, Observable, from } from "rxjs";
3
+import * as Atmosphere from "atmosphere.js";
4
+
5
+@Injectable({
6
+  providedIn: "root",
7
+})
8
+export class WebsocketNurseService {
9
+  constructor() {}
10
+  private lockReconnect = false; //避免ws重复连接
11
+  ws; //定义websocket
12
+  private url = ""; //ws连接地址
13
+  private urlParams; //ws连接传参
14
+  private isHandler = false; //是否手动
15
+  private subject;
16
+  // 连接websocket
17
+  connectWs(url, data): Observable<any> {
18
+    this.url = url;
19
+    this.urlParams = data;
20
+    this.subject = new Subject<any>();
21
+    let request: any = {
22
+      url,
23
+      contentType: "application/json",
24
+      shared: true, // 标签共享
25
+      trackMessageLength: true, //校验数据完整性
26
+      transport: "websocket",
27
+    };
28
+
29
+    request.onOpen = (response) => {
30
+      console.log("ws连接成功" + new Date().toLocaleString());
31
+      this.heartCheck.reset().start(this);
32
+      this.ws.push(JSON.stringify(data));
33
+    };
34
+
35
+    request.onMessage = (response) => {
36
+      this.heartCheck.reset().start(this);
37
+      let message = response.responseBody;
38
+      try {
39
+        // alert(message);
40
+        console.log("收到消息" + message);
41
+        if (message !== "pong") {
42
+          this.subject.next(JSON.parse(message));
43
+        }
44
+      } catch (e) {
45
+        console.log("This doesn't look like a valid JSON: ", message);
46
+        return;
47
+      }
48
+    };
49
+
50
+    request.onClose = (response) => {
51
+      console.log("ws连接关闭" + new Date().toLocaleString(),this.isHandler);
52
+      this.heartCheck.reset();
53
+      if (!this.isHandler) {
54
+        this.reconnect(this.url, this.urlParams);
55
+      }
56
+    };
57
+
58
+    request.onError = (response) => {
59
+      console.log("ws连接错误",this.isHandler);
60
+      this.heartCheck.reset();
61
+      if (!this.isHandler) {
62
+        this.reconnect(this.url, this.urlParams);
63
+      }
64
+    };
65
+
66
+    this.ws = Atmosphere.subscribe(request);
67
+    return this.subject.asObservable();
68
+  }
69
+  //断线重连
70
+  private reconnect(url, data) {
71
+    if (this.lockReconnect) return;
72
+    this.lockReconnect = true;
73
+    setTimeout(() => {
74
+      //没连接上会一直重连,设置延迟避免请求过多
75
+      this.connectWs(url, data);
76
+      this.lockReconnect = false;
77
+    }, 15000);
78
+  }
79
+  private heartCheck = {
80
+    timeout: 60000, //1分钟发一次心跳
81
+    timeoutObj: null,
82
+    serverTimeoutObj: null,
83
+    reset: function () {
84
+      clearTimeout(this.timeoutObj);
85
+      clearTimeout(this.serverTimeoutObj);
86
+      return this;
87
+    },
88
+    start: function (_this) {
89
+      this.timeoutObj = setTimeout(() => {
90
+        //这里发送一个心跳,后端收到后,返回一个心跳消息,
91
+        //onmessage拿到返回的心跳就说明连接正常
92
+        _this.ws.push("ping");
93
+        this.serverTimeoutObj = setTimeout(() => {
94
+          //如果超过一定时间还没重置,说明后端主动断开了
95
+          _this.closeWs(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
96
+        }, this.timeout);
97
+      }, this.timeout);
98
+    },
99
+  };
100
+
101
+  // 断开websocket
102
+  closeWs(flag: boolean = false) {
103
+    this.isHandler = flag;
104
+    this.ws.close();
105
+  }
106
+}

+ 88 - 47
src/app/services/websocket-phone.service.ts

@@ -1,65 +1,106 @@
1
-import { Injectable } from '@angular/core';
2
-import { Subject, Observable, from } from 'rxjs';
1
+import { Injectable } from "@angular/core";
2
+import { Subject, Observable, from } from "rxjs";
3
+import * as Atmosphere from "atmosphere.js";
3
 
4
 
4
 @Injectable({
5
 @Injectable({
5
-  providedIn: 'root'
6
+  providedIn: "root",
6
 })
7
 })
7
 export class WebsocketPhoneService {
8
 export class WebsocketPhoneService {
8
-
9
-  constructor() { }
10
-
11
-
12
-  ws: WebSocket;//定义websocket
9
+  constructor() {}
10
+  private lockReconnect = false; //避免ws重复连接
11
+  ws; //定义websocket
12
+  private url = ""; //ws连接地址
13
+  private urlParams; //ws连接传参
14
+  private isHandler = false; //是否手动
13
   private subject;
15
   private subject;
14
-  flag = 1;//是否自动重连,1,正常,2,关闭,3,重连
15
   // 连接websocket
16
   // 连接websocket
16
   connectWs(url, data): Observable<any> {
17
   connectWs(url, data): Observable<any> {
17
-    var postData = data;
18
-    if (this.ws != null) { this.ws.close() };
19
-    if (this.subject) { this.subject = null };
20
-    this.ws = new WebSocket(url);
18
+    this.url = url;
19
+    this.urlParams = data;
21
     this.subject = new Subject<any>();
20
     this.subject = new Subject<any>();
22
-    let that = this;
23
-    this.ws.onopen = function (event) {
24
-      //socket 开启后执行,可以向后端传递信息
25
-      var sendData = JSON.stringify(postData)
26
-      that.ws.send(sendData);
27
-      console.log('open')
28
-    }
29
-    this.ws.onmessage = function (event) {
30
-      //socket 获取后端传递到前端的信息
31
-      console.log('onmessage')
32
-      if (event.data && event.data.length > 1) {
33
-        try {
34
-          that.subject.next(JSON.parse(event.data));
35
-        } catch (error) {
36
-          console.error('返回的值是'+event.data+',无法解析');
21
+    let request: any = {
22
+      url,
23
+      contentType: "application/json",
24
+      shared: true, // 标签共享
25
+      trackMessageLength: true, //校验数据完整性
26
+      transport: "websocket",
27
+    };
28
+
29
+    request.onOpen = (response) => {
30
+      console.log("ws连接成功" + new Date().toLocaleString());
31
+      this.heartCheck.reset().start(this);
32
+      this.ws.push(JSON.stringify(data));
33
+    };
34
+
35
+    request.onMessage = (response) => {
36
+      this.heartCheck.reset().start(this);
37
+      let message = response.responseBody;
38
+      try {
39
+        // alert(message);
40
+        console.log("收到消息" + message);
41
+        if (message !== "pong") {
42
+          this.subject.next(JSON.parse(message));
37
         }
43
         }
44
+      } catch (e) {
45
+        console.log("This doesn't look like a valid JSON: ", message);
46
+        return;
38
       }
47
       }
39
-    }
48
+    };
40
 
49
 
41
-    this.ws.onerror = function (event) {
42
-      //socket error信息
43
-      console.log('error')
50
+    request.onClose = (response) => {
51
+      console.log("ws连接关闭" + new Date().toLocaleString(),this.isHandler);
52
+      this.heartCheck.reset();
53
+      if (!this.isHandler) {
54
+        this.reconnect(this.url, this.urlParams);
55
+      }
56
+    };
44
 
57
 
45
-    }
46
-    this.ws.onclose = function (event) {
47
-      //socket 关闭后执行
48
-      console.log('close')
49
-      console.log('websocket 断开: ' + event.code + ' ' + event.reason + ' ' + event.wasClean)
50
-      if(event.wasClean){
51
-        that.flag = 2;
52
-      }else{
53
-        that.flag = 3;
58
+    request.onError = (response) => {
59
+      console.log("ws连接错误",this.isHandler);
60
+      this.heartCheck.reset();
61
+      if (!this.isHandler) {
62
+        this.reconnect(this.url, this.urlParams);
54
       }
63
       }
55
-    }
64
+    };
56
 
65
 
57
-    return that.subject.asObservable();
66
+    this.ws = Atmosphere.subscribe(request);
67
+    return this.subject.asObservable();
58
   }
68
   }
69
+  //断线重连
70
+  private reconnect(url, data) {
71
+    if (this.lockReconnect) return;
72
+    this.lockReconnect = true;
73
+    setTimeout(() => {
74
+      //没连接上会一直重连,设置延迟避免请求过多
75
+      this.connectWs(url, data);
76
+      this.lockReconnect = false;
77
+    }, 15000);
78
+  }
79
+  private heartCheck = {
80
+    timeout: 60000, //1分钟发一次心跳
81
+    timeoutObj: null,
82
+    serverTimeoutObj: null,
83
+    reset: function () {
84
+      clearTimeout(this.timeoutObj);
85
+      clearTimeout(this.serverTimeoutObj);
86
+      return this;
87
+    },
88
+    start: function (_this) {
89
+      this.timeoutObj = setTimeout(() => {
90
+        //这里发送一个心跳,后端收到后,返回一个心跳消息,
91
+        //onmessage拿到返回的心跳就说明连接正常
92
+        _this.ws.push("ping");
93
+        this.serverTimeoutObj = setTimeout(() => {
94
+          //如果超过一定时间还没重置,说明后端主动断开了
95
+          _this.closeWs(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
96
+        }, this.timeout);
97
+      }, this.timeout);
98
+    },
99
+  };
59
 
100
 
60
-  // 断开websocket,true关闭,false,断线重连
61
-  closeWs() {
62
-    this.ws.close()
101
+  // 断开websocket
102
+  closeWs(flag: boolean = false) {
103
+    this.isHandler = flag;
104
+    this.ws.close();
63
   }
105
   }
64
 }
106
 }
65
-

+ 106 - 0
src/app/services/websocket-ser.service.ts

@@ -0,0 +1,106 @@
1
+import { Injectable } from "@angular/core";
2
+import { Subject, Observable, from } from "rxjs";
3
+import * as Atmosphere from "atmosphere.js";
4
+
5
+@Injectable({
6
+  providedIn: "root",
7
+})
8
+export class WebsocketSerService {
9
+  constructor() {}
10
+  private lockReconnect = false; //避免ws重复连接
11
+  ws; //定义websocket
12
+  private url = ""; //ws连接地址
13
+  private urlParams; //ws连接传参
14
+  private isHandler = false; //是否手动
15
+  private subject;
16
+  // 连接websocket
17
+  connectWs(url, data): Observable<any> {
18
+    this.url = url;
19
+    this.urlParams = data;
20
+    this.subject = new Subject<any>();
21
+    let request: any = {
22
+      url,
23
+      contentType: "application/json",
24
+      shared: true, // 标签共享
25
+      trackMessageLength: true, //校验数据完整性
26
+      transport: "websocket",
27
+    };
28
+
29
+    request.onOpen = (response) => {
30
+      console.log("ws连接成功" + new Date().toLocaleString());
31
+      this.heartCheck.reset().start(this);
32
+      this.ws.push(JSON.stringify(data));
33
+    };
34
+
35
+    request.onMessage = (response) => {
36
+      this.heartCheck.reset().start(this);
37
+      let message = response.responseBody;
38
+      try {
39
+        // alert(message);
40
+        console.log("收到消息" + message);
41
+        if (message !== "pong") {
42
+          this.subject.next(JSON.parse(message));
43
+        }
44
+      } catch (e) {
45
+        console.log("This doesn't look like a valid JSON: ", message);
46
+        return;
47
+      }
48
+    };
49
+
50
+    request.onClose = (response) => {
51
+      console.log("ws连接关闭" + new Date().toLocaleString(),this.isHandler);
52
+      this.heartCheck.reset();
53
+      if (!this.isHandler) {
54
+        this.reconnect(this.url, this.urlParams);
55
+      }
56
+    };
57
+
58
+    request.onError = (response) => {
59
+      console.log("ws连接错误",this.isHandler);
60
+      this.heartCheck.reset();
61
+      if (!this.isHandler) {
62
+        this.reconnect(this.url, this.urlParams);
63
+      }
64
+    };
65
+
66
+    this.ws = Atmosphere.subscribe(request);
67
+    return this.subject.asObservable();
68
+  }
69
+  //断线重连
70
+  private reconnect(url, data) {
71
+    if (this.lockReconnect) return;
72
+    this.lockReconnect = true;
73
+    setTimeout(() => {
74
+      //没连接上会一直重连,设置延迟避免请求过多
75
+      this.connectWs(url, data);
76
+      this.lockReconnect = false;
77
+    }, 15000);
78
+  }
79
+  private heartCheck = {
80
+    timeout: 60000, //1分钟发一次心跳
81
+    timeoutObj: null,
82
+    serverTimeoutObj: null,
83
+    reset: function () {
84
+      clearTimeout(this.timeoutObj);
85
+      clearTimeout(this.serverTimeoutObj);
86
+      return this;
87
+    },
88
+    start: function (_this) {
89
+      this.timeoutObj = setTimeout(() => {
90
+        //这里发送一个心跳,后端收到后,返回一个心跳消息,
91
+        //onmessage拿到返回的心跳就说明连接正常
92
+        _this.ws.push("ping");
93
+        this.serverTimeoutObj = setTimeout(() => {
94
+          //如果超过一定时间还没重置,说明后端主动断开了
95
+          _this.closeWs(); //如果onclose会执行reconnect,我们执行ws.close()就行了.如果直接执行reconnect 会触发onclose导致重连两次
96
+        }, this.timeout);
97
+      }, this.timeout);
98
+    },
99
+  };
100
+
101
+  // 断开websocket
102
+  closeWs(flag: boolean = false) {
103
+    this.isHandler = flag;
104
+    this.ws.close();
105
+  }
106
+}

+ 0 - 56
src/app/services/websocket.service.ts

@@ -1,56 +0,0 @@
1
-import { Injectable } from '@angular/core';
2
-import { Subject, Observable } from 'rxjs';
3
-
4
-@Injectable({
5
-  providedIn: 'root'
6
-})
7
-export class WebsocketService {
8
-
9
-  constructor() { }
10
-  ws: WebSocket;//定义websocket
11
-  private subject;
12
-  // 连接websocket
13
-  connectWs(url, data): Observable<any> {
14
-    var postData = data;
15
-    if (this.ws != null) { this.ws.close() };
16
-    if (this.subject) { this.subject = null };
17
-    this.ws = new WebSocket(url);
18
-    this.subject = new Subject<any>();
19
-    let that = this;
20
-    this.ws.onopen = function (event) {
21
-      //socket 开启后执行,可以向后端传递信息
22
-      var sendData = JSON.stringify(postData)
23
-      that.ws.send(sendData);
24
-      console.log('open')
25
-    }
26
-    this.ws.onmessage = function (event) {
27
-      //socket 获取后端传递到前端的信息
28
-      console.log('onmessage')
29
-      if (event.data && event.data.length > 1) {
30
-        that.subject.next(JSON.parse(event.data));
31
-      }
32
-    }
33
-
34
-    this.ws.onerror = function (event) {
35
-      //socket error信息
36
-      console.log('error')
37
-
38
-    }
39
-    this.ws.onclose = function (event) {
40
-      //socket 关闭后执行
41
-      console.log('close')
42
-    }
43
-
44
-    return that.subject.asObservable();
45
-  }
46
-
47
-  // 断开websocket
48
-  closeWs() {
49
-    this.ws.close()
50
-  }
51
-
52
-
53
-
54
-
55
-
56
-}

+ 24 - 36
src/app/views/fuwutai/fuwutai.component.ts

@@ -9,8 +9,8 @@ import { FormBuilder, FormGroup, Validators } from "@angular/forms";
9
 import { Router } from "@angular/router";
9
 import { Router } from "@angular/router";
10
 
10
 
11
 import { MainService } from "../../services/main.service";
11
 import { MainService } from "../../services/main.service";
12
-import { WebsocketService } from "../../services/websocket.service";
13
 import { WebsocketPhoneService } from "../../services/websocket-phone.service";
12
 import { WebsocketPhoneService } from "../../services/websocket-phone.service";
13
+import { WebsocketSerService } from "../../services/websocket-ser.service";
14
 import http from "../../../assets/js/http";
14
 import http from "../../../assets/js/http";
15
 
15
 
16
 import { NzMessageService } from "ng-zorro-antd/message";
16
 import { NzMessageService } from "ng-zorro-antd/message";
@@ -104,8 +104,8 @@ export class FuwutaiComponent implements OnInit {
104
     private mainService: MainService,
104
     private mainService: MainService,
105
     private msg: NzMessageService,
105
     private msg: NzMessageService,
106
     private notification: NzNotificationService,
106
     private notification: NzNotificationService,
107
-    private webs: WebsocketService,
108
-    private phones: WebsocketPhoneService
107
+    private phones: WebsocketPhoneService,
108
+    private sers: WebsocketSerService
109
   ) {}
109
   ) {}
110
   validateFormZy!: FormGroup;
110
   validateFormZy!: FormGroup;
111
   validateFormQt!: FormGroup;
111
   validateFormQt!: FormGroup;
@@ -521,7 +521,7 @@ export class FuwutaiComponent implements OnInit {
521
       workOrderRemark: [null], //工单备注
521
       workOrderRemark: [null], //工单备注
522
     });
522
     });
523
 
523
 
524
-    this.getWebsocket();
524
+    this.getWebsocketSer();
525
     this.initRole();
525
     this.initRole();
526
     this.initLogin();
526
     this.initLogin();
527
     this.retract();
527
     this.retract();
@@ -539,12 +539,12 @@ export class FuwutaiComponent implements OnInit {
539
     this.getUnassignedBuilding2();
539
     this.getUnassignedBuilding2();
540
   }
540
   }
541
   ngOnDestroy() {
541
   ngOnDestroy() {
542
-    console.log("关闭ser", this.webs.ws);
543
     clearInterval(this.refreshTimerId);
542
     clearInterval(this.refreshTimerId);
544
-    clearInterval(this.timerWS);
545
-    this.webs.closeWs();
546
     if (this.phones.ws) {
543
     if (this.phones.ws) {
547
-      this.phones.closeWs();
544
+      this.phones.closeWs(true);
545
+    }
546
+    if (this.sers.ws) {
547
+      this.sers.closeWs(true);
548
     }
548
     }
549
   }
549
   }
550
   unassignedSearchCon: string = ""; //未分派搜索框内容
550
   unassignedSearchCon: string = ""; //未分派搜索框内容
@@ -608,39 +608,25 @@ export class FuwutaiComponent implements OnInit {
608
   }
608
   }
609
 
609
 
610
   // 连接websocket
610
   // 连接websocket
611
-  getWebsocket() {
612
-    let that = this;
613
-    this.webs
614
-      .connectWs(http.fwtWs, { userCount: that.user.user.account })
615
-      .subscribe((data) => {
616
-        console.log(data);
617
-        if (data && data.content) {
618
-          that.createBasicNotification(data);
611
+  getWebsocketSer() {
612
+    this.sers
613
+      .connectWs(http.fwtWs, { userCount: this.user.user.account })
614
+      .subscribe((result) => {
615
+        console.log(result);
616
+        if (result && result.content) {
617
+          this.createBasicNotification(result);
619
         }
618
         }
620
-        that.windowResize();
619
+        this.windowResize();
621
       });
620
       });
622
   }
621
   }
623
-  // 监听ws
624
-  timerWS = null;
625
-  listenWs() {
626
-    clearInterval(this.timerWS);
627
-    this.timerWS = setInterval(() => {
628
-      console.log(this.phones.flag);
629
-      if (this.phones.flag == 3) {
630
-        this.getWebsocketPhone();
631
-      }
632
-    }, 15000);
633
-  }
634
   // 连接websocket---phone
622
   // 连接websocket---phone
635
   getWebsocketPhone() {
623
   getWebsocketPhone() {
636
-    this.listenWs();
637
     let userCount =
624
     let userCount =
638
       this.user.user.account + "|" + this.phoneNumListSelected.join("_");
625
       this.user.user.account + "|" + this.phoneNumListSelected.join("_");
639
     this.phones.connectWs(http.phoneWs, { userCount }).subscribe((data) => {
626
     this.phones.connectWs(http.phoneWs, { userCount }).subscribe((data) => {
640
-      // data = { status: 201, phone: '013581394342' };//ceshi
627
+      // data = { status: 201, phone: '013581394341' };//ceshi
641
       console.log(data);
628
       console.log(data);
642
       if (data.status == 200 && data.phone) {
629
       if (data.status == 200 && data.phone) {
643
-        this.phones.flag = 1;
644
         localStorage.setItem("phones", data.phone);
630
         localStorage.setItem("phones", data.phone);
645
         this.phoneNumListBind = data.phone.split("_");
631
         this.phoneNumListBind = data.phone.split("_");
646
         this.phoneNumListBind.forEach((item) => {
632
         this.phoneNumListBind.forEach((item) => {
@@ -697,16 +683,18 @@ export class FuwutaiComponent implements OnInit {
697
   //确定绑定
683
   //确定绑定
698
   bindingOk() {
684
   bindingOk() {
699
     if (this.phoneNumListSelected.length > 0) {
685
     if (this.phoneNumListSelected.length > 0) {
700
-      // setInterval(() => {
701
-      this.getWebsocketPhone(); //ceshi
702
-      // }, 5000)
686
+      if (this.phones.ws) {
687
+        this.phones.closeWs(true);
688
+      }
689
+      this.getWebsocketPhone();
703
     } else {
690
     } else {
691
+      localStorage.removeItem("phones");
704
       this.binding = 3;
692
       this.binding = 3;
705
       this.phoneNumList.forEach((item) => {
693
       this.phoneNumList.forEach((item) => {
706
         item.checked = false;
694
         item.checked = false;
707
       });
695
       });
708
       if (this.phones.ws) {
696
       if (this.phones.ws) {
709
-        this.phones.closeWs();
697
+        this.phones.closeWs(true);
710
       }
698
       }
711
     }
699
     }
712
   }
700
   }
@@ -2187,7 +2175,7 @@ export class FuwutaiComponent implements OnInit {
2187
           that.showPromptModal("保存", true, "");
2175
           that.showPromptModal("保存", true, "");
2188
           // 关闭phone的websocket
2176
           // 关闭phone的websocket
2189
           if (this.phones.ws) {
2177
           if (this.phones.ws) {
2190
-            this.phones.closeWs();
2178
+            this.phones.closeWs(true);
2191
           }
2179
           }
2192
           this.getPhoneNum(false);
2180
           this.getPhoneNum(false);
2193
           that.user.user.scope = data.data;
2181
           that.user.user.scope = data.data;

+ 212 - 225
src/app/views/home/home.component.ts

@@ -1,90 +1,77 @@
1
-import { Component, OnInit, ViewChild } from '@angular/core';
2
-import { ActivatedRoute, Router } from "@angular/router"
3
-import { FormBuilder, Validators, FormGroup } from '@angular/forms';
1
+import { Component, OnInit, ViewChild } from "@angular/core";
2
+import { Router } from "@angular/router";
3
+import { FormBuilder, Validators, FormGroup } from "@angular/forms";
4
 
4
 
5
 import { MainService } from "../../services/main.service";
5
 import { MainService } from "../../services/main.service";
6
-import { MyServiceService } from "../../services/my-service.service";
6
+// import { MyServiceService } from "../../services/my-service.service";
7
+import { WebsocketIndexService } from "../../services/websocket-index.service";
7
 import http from "../../../assets/js/http";
8
 import http from "../../../assets/js/http";
8
-import { OverlayScrollbarsComponent } from 'overlayscrollbars-ngx';
9
-import { ToolService } from '../../services/tool.service';
10
-
9
+import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
10
+import { ToolService } from "../../services/tool.service";
11
 
11
 
12
 @Component({
12
 @Component({
13
-  selector: 'app-home',
14
-  templateUrl: './home.component.html',
15
-  styleUrls: ['./home.component.less']
13
+  selector: "app-home",
14
+  templateUrl: "./home.component.html",
15
+  styleUrls: ["./home.component.less"],
16
 })
16
 })
17
 export class HomeComponent implements OnInit {
17
 export class HomeComponent implements OnInit {
18
-  @ViewChild('osComponentRef1', { read: OverlayScrollbarsComponent, static: false })
18
+  @ViewChild("osComponentRef1", {
19
+    read: OverlayScrollbarsComponent,
20
+    static: false,
21
+  })
19
   osComponentRef1: OverlayScrollbarsComponent;
22
   osComponentRef1: OverlayScrollbarsComponent;
20
-  @ViewChild('osComponentRef2', { read: OverlayScrollbarsComponent, static: false })
23
+  @ViewChild("osComponentRef2", {
24
+    read: OverlayScrollbarsComponent,
25
+    static: false,
26
+  })
21
   osComponentRef2: OverlayScrollbarsComponent;
27
   osComponentRef2: OverlayScrollbarsComponent;
22
-  constructor(private fb: FormBuilder, private route: ActivatedRoute, private router: Router, private mainService: MainService, private myService: MyServiceService, private tool: ToolService) {
23
-  }
28
+  constructor(
29
+    private fb: FormBuilder,
30
+    private router: Router,
31
+    private mainService: MainService,
32
+    // private myService: MyServiceService,
33
+    private myService: WebsocketIndexService,
34
+    private tool: ToolService
35
+  ) {}
24
 
36
 
25
   ngOnInit() {
37
   ngOnInit() {
26
     let that = this;
38
     let that = this;
27
-    that.initForm()
28
-    that.getAllHos()
29
-    that.connectWs()
39
+    that.initForm();
40
+    that.getAllHos();
41
+    // that.connectWs();
42
+    this.getWebsocketIndex();
30
   }
43
   }
31
 
44
 
32
-  ws: WebSocket;//定义websocket
33
-  validateForm: FormGroup;//新增/编辑表单
34
-
35
-  promptContent: string;//操作提示框提示信息
36
-  ifSuccess: boolean;//操作成功/失败
37
-  promptInfo: string;//操作结果提示信息
38
-  promptModalShow: boolean;//操作提示框是否展示
39
-
40
-
41
-  //socket连接
42
-  wsData;//socket返回的数据
43
-  groupOrders = [];//当前各小组工单执行情况
44
-  userSituation: any = {};//用户信息
45
-  orderSituation: any = {};//工单信息
46
-  connectWs() {
47
-    if (this.ws != null) { this.ws.close() };
48
-    this.ws = new WebSocket(http.homeWs);
49
-    let that = this;
50
-    this.ws.onopen = function (event) {
51
-      //socket 开启后执行,可以向后端传递信息
52
-      var data = JSON.stringify({ hosIds: that.hosIds })
53
-      that.ws.send(data);
54
-    }
55
-    this.ws.onmessage = function (event) {
56
-      //socket 获取后端传递到前端的信息
57
-      if (event.data && event.data.length > 1) {
58
-        that.wsData = JSON.parse(event.data)
59
-        if (that.wsData.groupOrders && that.wsData.groupOrders.status == 200) {
60
-          that.groupOrders = that.wsData.groupOrders.data;
45
+  validateForm: FormGroup; //新增/编辑表单
46
+
47
+  promptContent: string; //操作提示框提示信息
48
+  ifSuccess: boolean; //操作成功/失败
49
+  promptInfo: string; //操作结果提示信息
50
+  promptModalShow: boolean; //操作提示框是否展示
51
+  //连接ws
52
+  groupOrders = []; //当前各小组工单执行情况
53
+  userSituation: any = {}; //用户信息
54
+  orderSituation: any = {}; //工单信息
55
+  getWebsocketIndex() {
56
+    this.myService
57
+      .connectWs(http.homeWs, { hosIds: this.hosIds })
58
+      .subscribe((result) => {
59
+        console.log(result);
60
+        if (result.groupOrders && result.groupOrders.status == 200) {
61
+          this.groupOrders = result.groupOrders.data;
61
         }
62
         }
62
-        if (that.wsData.userSituation) {
63
-          that.userSituation = that.wsData.userSituation;
63
+        if (result.userSituation) {
64
+          this.userSituation = result.userSituation;
64
         }
65
         }
65
-        if (that.wsData.orderSituation) {
66
-          that.orderSituation = that.wsData.orderSituation;
66
+        if (result.orderSituation) {
67
+          this.orderSituation = result.orderSituation;
67
         }
68
         }
68
-      }
69
-    }
70
-
71
-    this.ws.onerror = function (event) {
72
-      //socket error信息
73
-      console.log('error')
74
-    }
75
-    this.ws.onclose = function () {
76
-      //socket 关闭后执行
77
-      setTimeout(() => {
78
-        that.connectWs();
79
-      }, 15000);
80
-    }
69
+      });
81
   }
70
   }
82
-
83
   ngOnDestroy() {
71
   ngOnDestroy() {
84
-    clearInterval(this.moveId)
85
-    clearInterval(this.moveId1)
86
-    console.log('首页关闭')
87
-    this.ws.close()
72
+    clearInterval(this.moveId);
73
+    clearInterval(this.moveId1);
74
+    this.myService.closeWs(true);
88
   }
75
   }
89
   // 小组好评
76
   // 小组好评
90
   groupInfo = [];
77
   groupInfo = [];
@@ -95,18 +82,20 @@ export class HomeComponent implements OnInit {
95
       hosIds: that.hosIds,
82
       hosIds: that.hosIds,
96
     };
83
     };
97
     this.loading1 = true;
84
     this.loading1 = true;
98
-    that.mainService.postCustom('index', 'groupEvaTop', postData).subscribe(data => {
99
-      this.loading1 = false;
100
-      that.groupInfo = data.data || []
101
-      if (data.data && data.data.length) {
102
-        data.data.forEach(e => {
103
-          e.value = e.percent
104
-        });
105
-        this.groupChart(data.data)
106
-      } else {
107
-        this.groupChart([])
108
-      }
109
-    })
85
+    that.mainService
86
+      .postCustom("index", "groupEvaTop", postData)
87
+      .subscribe((data) => {
88
+        this.loading1 = false;
89
+        that.groupInfo = data.data || [];
90
+        if (data.data && data.data.length) {
91
+          data.data.forEach((e) => {
92
+            e.value = e.percent;
93
+          });
94
+          this.groupChart(data.data);
95
+        } else {
96
+          this.groupChart([]);
97
+        }
98
+      });
110
   }
99
   }
111
   // 好评Echarts
100
   // 好评Echarts
112
   groupOption;
101
   groupOption;
@@ -114,12 +103,12 @@ export class HomeComponent implements OnInit {
114
     let labels = [];
103
     let labels = [];
115
     let nums = [];
104
     let nums = [];
116
     if (datas.length) {
105
     if (datas.length) {
117
-      datas.forEach(e => {
118
-        labels.push(e.name)
119
-        nums.push(e.percent - 0)
106
+      datas.forEach((e) => {
107
+        labels.push(e.name);
108
+        nums.push(e.percent - 0);
120
       });
109
       });
121
     }
110
     }
122
-    console.log(labels, nums)
111
+    console.log(labels, nums);
123
     var dataShadow = [];
112
     var dataShadow = [];
124
 
113
 
125
     for (var i = 0; i < datas.length; i++) {
114
     for (var i = 0; i < datas.length; i++) {
@@ -127,140 +116,137 @@ export class HomeComponent implements OnInit {
127
     }
116
     }
128
     this.groupOption = {
117
     this.groupOption = {
129
       grid: {
118
       grid: {
130
-        left: '10',
131
-        right: '100',
132
-        top: '0',
133
-        bottom: '0',
134
-        containLabel: true
119
+        left: "10",
120
+        right: "100",
121
+        top: "0",
122
+        bottom: "0",
123
+        containLabel: true,
135
       },
124
       },
136
       xAxis: {
125
       xAxis: {
137
-        show: ''
126
+        show: "",
138
       },
127
       },
139
       yAxis: {
128
       yAxis: {
140
-        type: 'category',
129
+        type: "category",
141
         data: labels,
130
         data: labels,
142
         axisLabel: {
131
         axisLabel: {
143
           margin: 15,
132
           margin: 15,
144
           textStyle: {
133
           textStyle: {
145
-            color: '#666'
146
-          }
134
+            color: "#666",
135
+          },
147
         },
136
         },
148
         axisTick: {
137
         axisTick: {
149
           lineStyle: {
138
           lineStyle: {
150
-            color: '#fff'
151
-          }
139
+            color: "#fff",
140
+          },
152
         },
141
         },
153
         axisLine: {
142
         axisLine: {
154
           lineStyle: {
143
           lineStyle: {
155
-            color: '#fff'
156
-          }
157
-        }
144
+            color: "#fff",
145
+          },
146
+        },
158
       },
147
       },
159
       series: [
148
       series: [
160
-        { // For shadow
161
-          type: 'bar',
149
+        {
150
+          // For shadow
151
+          type: "bar",
162
           itemStyle: {
152
           itemStyle: {
163
-            color: 'rgba(0,0,0,0.04)'
153
+            color: "rgba(0,0,0,0.04)",
164
           },
154
           },
165
-          barGap: '-100%',
166
-          barCategoryGap: '26',
167
-          barWidth: '26',
155
+          barGap: "-100%",
156
+          barCategoryGap: "26",
157
+          barWidth: "26",
168
           data: dataShadow,
158
           data: dataShadow,
169
-          animation: false
159
+          animation: false,
170
         },
160
         },
171
         {
161
         {
172
-          name: '建单总数',
173
-          type: 'bar',
162
+          name: "建单总数",
163
+          type: "bar",
174
           data: nums,
164
           data: nums,
175
           label: {
165
           label: {
176
             show: true,
166
             show: true,
177
-            position: 'right',
178
-            formatter: '{c} % '
167
+            position: "right",
168
+            formatter: "{c} % ",
179
           },
169
           },
180
           itemStyle: {
170
           itemStyle: {
181
             normal: {
171
             normal: {
182
               //每根柱子颜色设置
172
               //每根柱子颜色设置
183
-              color: '#49b856'
184
-            }
173
+              color: "#49b856",
174
+            },
185
           },
175
           },
186
-          barCategoryGap: '26',
187
-          barWidth: '26'
188
-        }
189
-      ]
176
+          barCategoryGap: "26",
177
+          barWidth: "26",
178
+        },
179
+      ],
190
     };
180
     };
191
   }
181
   }
192
 
182
 
193
-
194
   // 近一周异常工单
183
   // 近一周异常工单
195
   abOrders: Array<any> = [];
184
   abOrders: Array<any> = [];
196
   loading2 = false;
185
   loading2 = false;
197
   getAbnormityOrders() {
186
   getAbnormityOrders() {
198
     let that = this;
187
     let that = this;
199
     this.loading2 = true;
188
     this.loading2 = true;
200
-    that.mainService.postCustom('index', 'abnormityOrders', { hosIds: that.hosIds }).subscribe(data => {
201
-      this.loading2 = false;
202
-      that.abOrders = data.data || [];
203
-    })
189
+    that.mainService
190
+      .postCustom("index", "abnormityOrders", { hosIds: that.hosIds })
191
+      .subscribe((data) => {
192
+        this.loading2 = false;
193
+        that.abOrders = data.data || [];
194
+      });
204
   }
195
   }
205
 
196
 
206
   // 工单详情
197
   // 工单详情
207
   // 查看
198
   // 查看
208
   orderDetail(id) {
199
   orderDetail(id) {
209
-    this.router.navigateByUrl('/main/home/orderDetail/' + id);
200
+    this.router.navigateByUrl("/main/home/orderDetail/" + id);
210
   }
201
   }
211
 
202
 
212
-
213
-
214
   // swiper 轮播图
203
   // swiper 轮播图
215
-  swiperArr = []
204
+  swiperArr = [];
216
   swiperTop: number = 0;
205
   swiperTop: number = 0;
217
   moveId: any;
206
   moveId: any;
218
   index: number = 0;
207
   index: number = 0;
219
   startSwiper(length) {
208
   startSwiper(length) {
220
     let that = this;
209
     let that = this;
221
-    clearInterval(that.moveId)
210
+    clearInterval(that.moveId);
222
     setInterval(() => {
211
     setInterval(() => {
223
       that.index++;
212
       that.index++;
224
-      clearInterval(that.moveId)
213
+      clearInterval(that.moveId);
225
       that.moveId = setInterval(() => {
214
       that.moveId = setInterval(() => {
226
-        if (that.swiperTop > (-32 * that.index)) {
215
+        if (that.swiperTop > -32 * that.index) {
227
           that.swiperTop--;
216
           that.swiperTop--;
228
         }
217
         }
229
-        if (that.swiperTop <= length * (-32)) {
230
-          that.swiperTop = 0
231
-          that.index = 0
232
-          clearInterval(that.moveId)
218
+        if (that.swiperTop <= length * -32) {
219
+          that.swiperTop = 0;
220
+          that.index = 0;
221
+          clearInterval(that.moveId);
233
         }
222
         }
234
       }, 20);
223
       }, 20);
235
     }, 2000);
224
     }, 2000);
236
-
237
   }
225
   }
238
 
226
 
239
-  swiperArr1 = [1, 2, 3]
227
+  swiperArr1 = [1, 2, 3];
240
   swiperTop1: number = 0;
228
   swiperTop1: number = 0;
241
   moveId1: any;
229
   moveId1: any;
242
   index1: number = 0;
230
   index1: number = 0;
243
   startSwiper1(length) {
231
   startSwiper1(length) {
244
     let that = this;
232
     let that = this;
245
-    clearInterval(that.moveId1)
233
+    clearInterval(that.moveId1);
246
     setInterval(() => {
234
     setInterval(() => {
247
       that.index1++;
235
       that.index1++;
248
-      clearInterval(that.moveId1)
236
+      clearInterval(that.moveId1);
249
       that.moveId1 = setInterval(() => {
237
       that.moveId1 = setInterval(() => {
250
-        if (that.swiperTop1 > (-32 * that.index1)) {
238
+        if (that.swiperTop1 > -32 * that.index1) {
251
           that.swiperTop1--;
239
           that.swiperTop1--;
252
         }
240
         }
253
-        if (that.swiperTop1 <= length * (-32)) {
254
-          that.swiperTop1 = 0
255
-          that.index1 = 0
256
-          clearInterval(that.moveId1)
241
+        if (that.swiperTop1 <= length * -32) {
242
+          that.swiperTop1 = 0;
243
+          that.index1 = 0;
244
+          clearInterval(that.moveId1);
257
         }
245
         }
258
       }, 20);
246
       }, 20);
259
     }, 2000);
247
     }, 2000);
260
-
261
   }
248
   }
262
 
249
 
263
-
264
   // 切换工单差评/最新意见
250
   // 切换工单差评/最新意见
265
   thisTab = 1;
251
   thisTab = 1;
266
   checkTab(tab) {
252
   checkTab(tab) {
@@ -272,7 +258,7 @@ export class HomeComponent implements OnInit {
272
 
258
 
273
   // 展开收起
259
   // 展开收起
274
   isOpen: boolean = false;
260
   isOpen: boolean = false;
275
-  coopOpenId;//当前展开/收起id
261
+  coopOpenId; //当前展开/收起id
276
   more(id) {
262
   more(id) {
277
     if (this.coopOpenId == id) {
263
     if (this.coopOpenId == id) {
278
       this.isOpen = !this.isOpen;
264
       this.isOpen = !this.isOpen;
@@ -283,37 +269,36 @@ export class HomeComponent implements OnInit {
283
   }
269
   }
284
 
270
 
285
   // 获取当前登录人所有院区
271
   // 获取当前登录人所有院区
286
-  hosIds: string = '';//院区id
287
-  hosName: string = '';//当前院区名称
272
+  hosIds: string = ""; //院区id
273
+  hosName: string = ""; //当前院区名称
288
   getAllHos() {
274
   getAllHos() {
289
     let hos: any = this.tool.getCurrentHospital();
275
     let hos: any = this.tool.getCurrentHospital();
290
     this.hosName = hos.hosName;
276
     this.hosName = hos.hosName;
291
-    this.hosIds = hos.id + '';
292
-    this.refreshList()
293
-    this.getGroupCount()
294
-    this.getAbnormityOrders()
277
+    this.hosIds = hos.id + "";
278
+    this.refreshList();
279
+    this.getGroupCount();
280
+    this.getAbnormityOrders();
295
   }
281
   }
296
 
282
 
297
-
298
   // 翻页获取当前列表
283
   // 翻页获取当前列表
299
   getPageList() {
284
   getPageList() {
300
     if (this.thisTab == 1) {
285
     if (this.thisTab == 1) {
301
-      this.getBadList()
286
+      this.getBadList();
302
     } else if (this.thisTab == 2) {
287
     } else if (this.thisTab == 2) {
303
-      this.getAdviceList()
288
+      this.getAdviceList();
304
     }
289
     }
305
   }
290
   }
306
   // 刷新页面右侧列表
291
   // 刷新页面右侧列表
307
   refreshList() {
292
   refreshList() {
308
-    this.getAdviceList()
309
-    this.getBadList()
293
+    this.getAdviceList();
294
+    this.getBadList();
310
   }
295
   }
311
   // 差评表格数据
296
   // 差评表格数据
312
   listIdx = 1;
297
   listIdx = 1;
313
   listLength = 0;
298
   listLength = 0;
314
-  badNum = 0;//差评数量
315
-  badList = [];//差评列表
316
-  Loading: boolean = true;//差评loading
299
+  badNum = 0; //差评数量
300
+  badList = []; //差评列表
301
+  Loading: boolean = true; //差评loading
317
   getBadList() {
302
   getBadList() {
318
     var that = this;
303
     var that = this;
319
     that.Loading = true;
304
     that.Loading = true;
@@ -322,40 +307,41 @@ export class HomeComponent implements OnInit {
322
       sum: 10,
307
       sum: 10,
323
       badEvaluationHandle: {
308
       badEvaluationHandle: {
324
         hosIds: that.hosIds,
309
         hosIds: that.hosIds,
325
-        handleStatus: { id: "286" }//未调解
310
+        handleStatus: { id: "286" }, //未调解
326
       },
311
       },
327
-    }
328
-    that.mainService.getFetchDataList('adviceCollection', 'badEvaluationHandle', data).subscribe(data => {
329
-      that.badList = data.list;
330
-      that.Loading = false;
331
-      that.listLength = that.badNum = data.totalNum;
332
-    })
333
-
312
+    };
313
+    that.mainService
314
+      .getFetchDataList("adviceCollection", "badEvaluationHandle", data)
315
+      .subscribe((data) => {
316
+        that.badList = data.list;
317
+        that.Loading = false;
318
+        that.listLength = that.badNum = data.totalNum;
319
+      });
334
   }
320
   }
335
 
321
 
336
-
337
   // 意见列表
322
   // 意见列表
338
   adviceList = [];
323
   adviceList = [];
339
-  adviceNum = 0;//意见数量
324
+  adviceNum = 0; //意见数量
340
   getAdviceList() {
325
   getAdviceList() {
341
     this.Loading = true;
326
     this.Loading = true;
342
     let data = {
327
     let data = {
343
       idx: this.listIdx - 1,
328
       idx: this.listIdx - 1,
344
       sum: 10,
329
       sum: 10,
345
       advice: {
330
       advice: {
346
-        replaceFlag: 0,//未回复
347
-        hosIds: this.hosIds
331
+        replaceFlag: 0, //未回复
332
+        hosIds: this.hosIds,
348
       },
333
       },
349
-    }
334
+    };
350
 
335
 
351
-    this.mainService.getFetchDataList('adviceCollection', 'advice', data).subscribe(data => {
352
-      this.adviceList = data.list;
353
-      this.Loading = false;
354
-      this.listLength = this.adviceNum = data.totalNum;
355
-    })
336
+    this.mainService
337
+      .getFetchDataList("adviceCollection", "advice", data)
338
+      .subscribe((data) => {
339
+        this.adviceList = data.list;
340
+        this.Loading = false;
341
+        this.listLength = this.adviceNum = data.totalNum;
342
+      });
356
   }
343
   }
357
 
344
 
358
-
359
   // 初始化新增form表单
345
   // 初始化新增form表单
360
   initForm() {
346
   initForm() {
361
     this.validateForm = this.fb.group({
347
     this.validateForm = this.fb.group({
@@ -375,31 +361,28 @@ export class HomeComponent implements OnInit {
375
       badEvaluationHandle: {
361
       badEvaluationHandle: {
376
         id: that.coopId,
362
         id: that.coopId,
377
         mediationUser: { id: that.validateForm.value.user },
363
         mediationUser: { id: that.validateForm.value.user },
378
-      }
379
-    }
380
-    that.mainService.postCustom('adviceCollection', 'updData/badEvaluationHandle', postData).subscribe(data => {
381
-      that.hideDesModal()
382
-      that.btnLoading = false;
383
-      if (data.status == 200) {
384
-        that.showPromptModal('指派', true, '');
385
-        that.initForm()
386
-        that.listIdx = 1;
387
-
388
-        that.getBadList()
389
-      } else {
390
-        that.showPromptModal('指派', false, data.msg);
391
-      }
392
-    })
393
-
394
-
364
+      },
365
+    };
366
+    that.mainService
367
+      .postCustom("adviceCollection", "updData/badEvaluationHandle", postData)
368
+      .subscribe((data) => {
369
+        that.hideDesModal();
370
+        that.btnLoading = false;
371
+        if (data.status == 200) {
372
+          that.showPromptModal("指派", true, "");
373
+          that.initForm();
374
+          that.listIdx = 1;
375
+
376
+          that.getBadList();
377
+        } else {
378
+          that.showPromptModal("指派", false, data.msg);
379
+        }
380
+      });
395
   }
381
   }
396
 
382
 
397
-
398
-
399
-
400
   // 回复弹框
383
   // 回复弹框
401
-  modal: boolean = false;//回复模态框
402
-  replyCon: any;//意见内容
384
+  modal: boolean = false; //回复模态框
385
+  replyCon: any; //意见内容
403
   reply(data) {
386
   reply(data) {
404
     this.modal = true;
387
     this.modal = true;
405
     this.replyCon = data;
388
     this.replyCon = data;
@@ -408,14 +391,15 @@ export class HomeComponent implements OnInit {
408
     this.modal = false;
391
     this.modal = false;
409
   }
392
   }
410
 
393
 
411
-
412
   // 指派人员
394
   // 指派人员
413
-  allDesUser: any = [];//所有支助人员
395
+  allDesUser: any = []; //所有支助人员
414
   getAllDesUser(id) {
396
   getAllDesUser(id) {
415
     let that = this;
397
     let that = this;
416
-    that.mainService.getHosUser('getUsersByPermission', id).subscribe(data => {
417
-      that.allDesUser = data.data || []
418
-    })
398
+    that.mainService
399
+      .getHosUser("getUsersByPermission", id)
400
+      .subscribe((data) => {
401
+        that.allDesUser = data.data || [];
402
+      });
419
   }
403
   }
420
 
404
 
421
   // 指派
405
   // 指派
@@ -424,7 +408,7 @@ export class HomeComponent implements OnInit {
424
   designate(id, hosId) {
408
   designate(id, hosId) {
425
     this.desModal = true;
409
     this.desModal = true;
426
     this.coopId = id;
410
     this.coopId = id;
427
-    this.getAllDesUser(hosId)
411
+    this.getAllDesUser(hosId);
428
   }
412
   }
429
   hideDesModal() {
413
   hideDesModal() {
430
     this.desModal = false;
414
     this.desModal = false;
@@ -432,12 +416,13 @@ export class HomeComponent implements OnInit {
432
 
416
 
433
   // 调解
417
   // 调解
434
   detail(id) {
418
   detail(id) {
435
-    this.router.navigate(['/main/home/appraiseDetail/' + id], { fragment: 'tj' });
419
+    this.router.navigate(["/main/home/appraiseDetail/" + id], {
420
+      fragment: "tj",
421
+    });
436
   }
422
   }
437
 
423
 
438
-
439
   // 回复
424
   // 回复
440
-  adviceSubContent: string;//回复内容
425
+  adviceSubContent: string; //回复内容
441
   btnLoading: boolean = false;
426
   btnLoading: boolean = false;
442
   submitReplyForm() {
427
   submitReplyForm() {
443
     let that = this;
428
     let that = this;
@@ -447,30 +432,32 @@ export class HomeComponent implements OnInit {
447
       advice: {
432
       advice: {
448
         id: that.replyCon.id,
433
         id: that.replyCon.id,
449
         replyUser: { id: that.replyCon.createUser.id },
434
         replyUser: { id: that.replyCon.createUser.id },
450
-        replyContent: that.adviceSubContent
451
-      }
452
-    }
453
-    that.mainService.postCustom('adviceCollection', 'updData/advice', postData).subscribe(data => {
454
-      that.btnLoading = false;
455
-      that.adviceSubContent = '';
456
-      if (data.status == 200) {
457
-        that.showPromptModal('回复', true, '');
458
-        that.hideModal()
459
-        that.listIdx = 1;
460
-        that.getAdviceList()
461
-      } else {
462
-        that.showPromptModal('回复', false, data.msg);
463
-      }
464
-    })
435
+        replyContent: that.adviceSubContent,
436
+      },
437
+    };
438
+    that.mainService
439
+      .postCustom("adviceCollection", "updData/advice", postData)
440
+      .subscribe((data) => {
441
+        that.btnLoading = false;
442
+        that.adviceSubContent = "";
443
+        if (data.status == 200) {
444
+          that.showPromptModal("回复", true, "");
445
+          that.hideModal();
446
+          that.listIdx = 1;
447
+          that.getAdviceList();
448
+        } else {
449
+          that.showPromptModal("回复", false, data.msg);
450
+        }
451
+      });
465
   }
452
   }
466
 
453
 
467
   // 跳转到指定页面
454
   // 跳转到指定页面
468
   toMenu(type, title) {
455
   toMenu(type, title) {
469
-    if (type == 'orderManagement') {
470
-      this.router.navigate(['/main/' + type], { fragment: 'yc' })
456
+    if (type == "orderManagement") {
457
+      this.router.navigate(["/main/" + type], { fragment: "yc" });
471
       return;
458
       return;
472
     }
459
     }
473
-    this.router.navigateByUrl('/main/' + type);
460
+    this.router.navigateByUrl("/main/" + type);
474
   }
461
   }
475
 
462
 
476
   // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)
463
   // 展示信息提示框(con:提示信息,success:操作是否成功,promptInfo:操作结果提示信息)

+ 3 - 4
src/app/views/hushijiandan/hushijiandan.component.ts

@@ -15,7 +15,7 @@ import { Router } from "@angular/router";
15
 
15
 
16
 import http from "../../../assets/js/http";
16
 import http from "../../../assets/js/http";
17
 import { MainService } from "../../services/main.service";
17
 import { MainService } from "../../services/main.service";
18
-import { WebsocketService } from "../../services/websocket.service";
18
+import { WebsocketNurseService } from "../../services/websocket-nurse.service";
19
 
19
 
20
 import { NzMessageService } from "ng-zorro-antd/message";
20
 import { NzMessageService } from "ng-zorro-antd/message";
21
 import { NzNotificationService } from "ng-zorro-antd/notification";
21
 import { NzNotificationService } from "ng-zorro-antd/notification";
@@ -100,7 +100,7 @@ export class HushijiandanComponent implements OnInit {
100
     private mainService: MainService,
100
     private mainService: MainService,
101
     private msg: NzMessageService,
101
     private msg: NzMessageService,
102
     private notification: NzNotificationService,
102
     private notification: NzNotificationService,
103
-    private webs: WebsocketService,
103
+    private webs: WebsocketNurseService,
104
     private tool: ToolService
104
     private tool: ToolService
105
   ) {
105
   ) {
106
     this.othersListOptions = {
106
     this.othersListOptions = {
@@ -193,13 +193,12 @@ export class HushijiandanComponent implements OnInit {
193
     // 工单列表倒计时 end
193
     // 工单列表倒计时 end
194
   }
194
   }
195
   ngOnDestroy() {
195
   ngOnDestroy() {
196
-    console.log("关闭护士端", this.webs.ws);
197
     clearInterval(this.moveId);
196
     clearInterval(this.moveId);
198
     clearInterval(this.moveId1);
197
     clearInterval(this.moveId1);
199
     clearInterval(this.msgTimerId);
198
     clearInterval(this.msgTimerId);
200
     clearInterval(this.logTimer);
199
     clearInterval(this.logTimer);
201
     clearInterval(this.orderListTimer);
200
     clearInterval(this.orderListTimer);
202
-    this.webs.closeWs();
201
+    this.webs.closeWs(true);
203
   }
202
   }
204
   loginUser: any = localStorage.getItem("user")
203
   loginUser: any = localStorage.getItem("user")
205
     ? JSON.parse(localStorage.getItem("user")).user
204
     ? JSON.parse(localStorage.getItem("user")).user

+ 3 - 3
src/app/views/main/main.component.ts

@@ -3,7 +3,7 @@ import { NavigationEnd, Router } from "@angular/router";
3
 import { MainService } from "../../services/main.service";
3
 import { MainService } from "../../services/main.service";
4
 
4
 
5
 import { NzMessageService } from "ng-zorro-antd/message";
5
 import { NzMessageService } from "ng-zorro-antd/message";
6
-import { WebsocketService } from "../../services/websocket.service";
6
+import { WebsocketMainService } from "../../services/websocket-main.service";
7
 import http from "../../../assets/js/http";
7
 import http from "../../../assets/js/http";
8
 
8
 
9
 import { NzNotificationService } from "ng-zorro-antd/notification";
9
 import { NzNotificationService } from "ng-zorro-antd/notification";
@@ -38,7 +38,7 @@ export class MainComponent implements OnInit {
38
     private mainService: MainService,
38
     private mainService: MainService,
39
     private msg: NzMessageService,
39
     private msg: NzMessageService,
40
     private notification: NzNotificationService,
40
     private notification: NzNotificationService,
41
-    private webs: WebsocketService,
41
+    private webs: WebsocketMainService,
42
     private tool: ToolService
42
     private tool: ToolService
43
   ) {}
43
   ) {}
44
   ngOnInit() {
44
   ngOnInit() {
@@ -59,7 +59,7 @@ export class MainComponent implements OnInit {
59
     //取消路由监听
59
     //取消路由监听
60
     this.routerEventsListener.unsubscribe();
60
     this.routerEventsListener.unsubscribe();
61
     // 断掉连接
61
     // 断掉连接
62
-    this.webs.closeWs();
62
+    this.webs.closeWs(true);
63
   }
63
   }
64
   // 根据url高亮菜单baba
64
   // 根据url高亮菜单baba
65
   highlightMenuByUrl() {
65
   highlightMenuByUrl() {