Browse Source

1.增加新设备的特性解析
2.增加协和特殊情况支持两台设备

wangyaxiang 2 years ago
parent
commit
a8f76889db

+ 15 - 3
src/main/java/com/dashitech/callcenter/socket/HandlerThread.java

@@ -5,6 +5,7 @@ import com.dashitech.businessdata.dao.IDepartmentDAO;
5
 import com.dashitech.businessdata.dao.IDictionaryDAO;
5
 import com.dashitech.businessdata.dao.IDictionaryDAO;
6
 import com.dashitech.businessdata.dao.IHospitalConfigDAO;
6
 import com.dashitech.businessdata.dao.IHospitalConfigDAO;
7
 import com.dashitech.businessdata.entity.CallLogEntity;
7
 import com.dashitech.businessdata.entity.CallLogEntity;
8
+import com.dashitech.businessdata.entity.DictionaryEntity;
8
 import com.dashitech.businessdata.entity.HospitalConfig;
9
 import com.dashitech.businessdata.entity.HospitalConfig;
9
 import com.dashitech.callcenter.webSocket.service.PhoneWebSocket;
10
 import com.dashitech.callcenter.webSocket.service.PhoneWebSocket;
10
 import com.dashitech.utils.JsonUtil;
11
 import com.dashitech.utils.JsonUtil;
@@ -12,6 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
12
 import net.sf.json.JSONObject;
13
 import net.sf.json.JSONObject;
13
 import org.apache.commons.lang.StringUtils;
14
 import org.apache.commons.lang.StringUtils;
14
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.context.annotation.Configuration;
15
 import org.springframework.stereotype.Service;
17
 import org.springframework.stereotype.Service;
16
 
18
 
17
 import java.io.DataInputStream;
19
 import java.io.DataInputStream;
@@ -105,7 +107,7 @@ public class HandlerThread  {
105
                         reset = "addrec";
107
                         reset = "addrec";
106
                     }
108
                     }
107
                 }
109
                 }
108
-                if (data != null && data.length() >= 10) {
110
+                if (data != null && data.length() >= 10){
109
                     String dataStr = "";
111
                     String dataStr = "";
110
                     if (reset.equals("addrec")){
112
                     if (reset.equals("addrec")){
111
                         dataStr = "{\"cmd\":\""+reset+"\",\"error\":\"0\", \"timestamp\":\""+(System.currentTimeMillis() / 1000)+"\"}";
113
                         dataStr = "{\"cmd\":\""+reset+"\",\"error\":\"0\", \"timestamp\":\""+(System.currentTimeMillis() / 1000)+"\"}";
@@ -113,8 +115,18 @@ public class HandlerThread  {
113
                         dataStr = "{\"cmd\":\""+reset+"\", \"timestamp\":\""+(System.currentTimeMillis() / 1000)+"\"}";
115
                         dataStr = "{\"cmd\":\""+reset+"\", \"timestamp\":\""+(System.currentTimeMillis() / 1000)+"\"}";
114
                     }
116
                     }
115
                     if (data.indexOf("loginreq") >= 0){
117
                     if (data.indexOf("loginreq") >= 0){
116
-                        his = JsonUtil.toJSONObject(data).getString("sernelNo");
117
-                        his = callLogDAO.selectSernelNo("sernelNo",his);
118
+                        //{"cmd":"loginreq","ipaddr":"192.168.25.37","serialNo":"21380501019804","recordNumber":4,"webport":80,"filestoretype":0}his
119
+                        if(JsonUtil.toJSONObject(data).containsKey("serialNo")){
120
+                            his = JsonUtil.toJSONObject(data).getString("serialNo");
121
+                        }else{
122
+                            his = JsonUtil.toJSONObject(data).getString("sernelNo");
123
+                        }
124
+                        // 设备 21040501017523 写死支持 院区1
125
+                        if(his.equals("21040501017523")){
126
+                            his = "1";
127
+                        }else{
128
+                            his = callLogDAO.selectSernelNo("sernelNo",his);
129
+                        }
118
                         dataStr = "{\"cmd\":\"loginres\", \"error\":\"0\", \"timestamp\":\"" + (System.currentTimeMillis() / 1000) + "\"}";
130
                         dataStr = "{\"cmd\":\"loginres\", \"error\":\"0\", \"timestamp\":\"" + (System.currentTimeMillis() / 1000) + "\"}";
119
                     }
131
                     }
120
                     System.out.println("redate>>"+dataStr+"his"+his);
132
                     System.out.println("redate>>"+dataStr+"his"+his);

+ 10 - 2
src/main/java/com/dashitech/callcenter/webSocket/service/PhoneWebSocket.java

@@ -8,6 +8,8 @@ import com.dashitech.callcenter.webSocket.core.WebSocketSender;
8
 import com.dashitech.utils.JsonUtil;
8
 import com.dashitech.utils.JsonUtil;
9
 import com.fasterxml.jackson.databind.ObjectMapper;
9
 import com.fasterxml.jackson.databind.ObjectMapper;
10
 import net.sf.json.JSONObject;
10
 import net.sf.json.JSONObject;
11
+import org.apache.commons.logging.Log;
12
+import org.apache.commons.logging.LogFactory;
11
 import org.atmosphere.cache.UUIDBroadcasterCache;
13
 import org.atmosphere.cache.UUIDBroadcasterCache;
12
 import org.atmosphere.client.TrackMessageSizeInterceptor;
14
 import org.atmosphere.client.TrackMessageSizeInterceptor;
13
 import org.atmosphere.config.service.WebSocketHandlerService;
15
 import org.atmosphere.config.service.WebSocketHandlerService;
@@ -18,6 +20,7 @@ import org.atmosphere.websocket.WebSocketProcessor;
18
 import org.springframework.beans.factory.annotation.Autowired;
20
 import org.springframework.beans.factory.annotation.Autowired;
19
 import org.springframework.stereotype.Service;
21
 import org.springframework.stereotype.Service;
20
 
22
 
23
+import javax.servlet.annotation.WebServlet;
21
 import java.io.IOException;
24
 import java.io.IOException;
22
 import java.util.*;
25
 import java.util.*;
23
 
26
 
@@ -28,7 +31,7 @@ import java.util.*;
28
 /**
31
 /**
29
  * 给前端推送消息
32
  * 给前端推送消息
30
  */
33
  */
31
-//@WebServlet(name="phoneWebSocket",urlPatterns="/webSocket")
34
+@WebServlet(name="phoneWebSocket",urlPatterns="/webSocket")
32
 @Service
35
 @Service
33
 @WebSocketHandlerService(path = "/webSocket/message/phone", interceptors = {
36
 @WebSocketHandlerService(path = "/webSocket/message/phone", interceptors = {
34
         TrackMessageSizeInterceptor.class,  //校验消息大小,验证数据完整性,需要前端参数配合
37
         TrackMessageSizeInterceptor.class,  //校验消息大小,验证数据完整性,需要前端参数配合
@@ -38,7 +41,7 @@ import java.util.*;
38
         atmosphereConfig = {"org.atmosphere.websocket.WebSocketProtocol=org.atmosphere.websocket.protocol.StreamingHttpProtocol"})
41
         atmosphereConfig = {"org.atmosphere.websocket.WebSocketProtocol=org.atmosphere.websocket.protocol.StreamingHttpProtocol"})
39
 public class PhoneWebSocket extends CacheHandlerAdapter {
42
 public class PhoneWebSocket extends CacheHandlerAdapter {
40
     public final static WebSocketSender webSocketSender = new WebSocketSender();
43
     public final static WebSocketSender webSocketSender = new WebSocketSender();
41
-
44
+    private static Log log = LogFactory.getLog(PhoneWebSocket.class);
42
     private static IDictionaryDAO dictionaryDAO;
45
     private static IDictionaryDAO dictionaryDAO;
43
     @Autowired
46
     @Autowired
44
     public void setDictionaryDAO(IDictionaryDAO dictionaryDAO) {
47
     public void setDictionaryDAO(IDictionaryDAO dictionaryDAO) {
@@ -83,6 +86,11 @@ public class PhoneWebSocket extends CacheHandlerAdapter {
83
                 webSocketSender.setCache(this.getCACHE());
86
                 webSocketSender.setCache(this.getCACHE());
84
             }
87
             }
85
         }
88
         }
89
+    //    log.info("data:" + data);
90
+        if(data.equals("ping")){
91
+            webSocket.resource().getResponse().getWriter().write("pong");
92
+            return;
93
+        }
86
         JSONObject jsonObject = JsonUtil.toJSONObject(data);
94
         JSONObject jsonObject = JsonUtil.toJSONObject(data);
87
         String identity = jsonObject.optString("userCount");
95
         String identity = jsonObject.optString("userCount");
88
         String[] nameAndPhone = identity.split("\\|");
96
         String[] nameAndPhone = identity.split("\\|");

+ 1 - 1
src/main/resources/application.properties

@@ -1,7 +1,7 @@
1
 mysql2.spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
1
 mysql2.spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
2
 #\u8F6C\u8FD0\u4E1A\u52A1\u5E93\u6570\u636E\u6E90
2
 #\u8F6C\u8FD0\u4E1A\u52A1\u5E93\u6570\u636E\u6E90
3
 mysql2.spring.datasource.driver-class-name=com.mysql.jdbc.Driver
3
 mysql2.spring.datasource.driver-class-name=com.mysql.jdbc.Driver
4
-mysql2.spring.datasource.url=jdbc:mysql://localhost:3306/hsms2_1129?autoReconnect=true&useUnicode=true&characterEncoding=utf8
4
+mysql2.spring.datasource.url=jdbc:mysql://localhost:3306/hsms2?autoReconnect=true&useUnicode=true&characterEncoding=utf8
5
 #mysql2.spring.datasource.url=jdbc:mysql://192.168.3.108:3306/hsms2_tjzy_0622?autoReconnect=true&useUnicode=true&characterEncoding=utf8
5
 #mysql2.spring.datasource.url=jdbc:mysql://192.168.3.108:3306/hsms2_tjzy_0622?autoReconnect=true&useUnicode=true&characterEncoding=utf8
6
 mysql2.spring.datasource.username=root
6
 mysql2.spring.datasource.username=root
7
 mysql2.spring.datasource.password=100100
7
 mysql2.spring.datasource.password=100100