Преглед на файлове

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

wangyaxiang преди 1 година
родител
ревизия
a8f76889db

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

@@ -5,6 +5,7 @@ import com.dashitech.businessdata.dao.IDepartmentDAO;
5 5
 import com.dashitech.businessdata.dao.IDictionaryDAO;
6 6
 import com.dashitech.businessdata.dao.IHospitalConfigDAO;
7 7
 import com.dashitech.businessdata.entity.CallLogEntity;
8
+import com.dashitech.businessdata.entity.DictionaryEntity;
8 9
 import com.dashitech.businessdata.entity.HospitalConfig;
9 10
 import com.dashitech.callcenter.webSocket.service.PhoneWebSocket;
10 11
 import com.dashitech.utils.JsonUtil;
@@ -12,6 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
12 13
 import net.sf.json.JSONObject;
13 14
 import org.apache.commons.lang.StringUtils;
14 15
 import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.context.annotation.Configuration;
15 17
 import org.springframework.stereotype.Service;
16 18
 
17 19
 import java.io.DataInputStream;
@@ -105,7 +107,7 @@ public class HandlerThread  {
105 107
                         reset = "addrec";
106 108
                     }
107 109
                 }
108
-                if (data != null && data.length() >= 10) {
110
+                if (data != null && data.length() >= 10){
109 111
                     String dataStr = "";
110 112
                     if (reset.equals("addrec")){
111 113
                         dataStr = "{\"cmd\":\""+reset+"\",\"error\":\"0\", \"timestamp\":\""+(System.currentTimeMillis() / 1000)+"\"}";
@@ -113,8 +115,18 @@ public class HandlerThread  {
113 115
                         dataStr = "{\"cmd\":\""+reset+"\", \"timestamp\":\""+(System.currentTimeMillis() / 1000)+"\"}";
114 116
                     }
115 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 130
                         dataStr = "{\"cmd\":\"loginres\", \"error\":\"0\", \"timestamp\":\"" + (System.currentTimeMillis() / 1000) + "\"}";
119 131
                     }
120 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 8
 import com.dashitech.utils.JsonUtil;
9 9
 import com.fasterxml.jackson.databind.ObjectMapper;
10 10
 import net.sf.json.JSONObject;
11
+import org.apache.commons.logging.Log;
12
+import org.apache.commons.logging.LogFactory;
11 13
 import org.atmosphere.cache.UUIDBroadcasterCache;
12 14
 import org.atmosphere.client.TrackMessageSizeInterceptor;
13 15
 import org.atmosphere.config.service.WebSocketHandlerService;
@@ -18,6 +20,7 @@ import org.atmosphere.websocket.WebSocketProcessor;
18 20
 import org.springframework.beans.factory.annotation.Autowired;
19 21
 import org.springframework.stereotype.Service;
20 22
 
23
+import javax.servlet.annotation.WebServlet;
21 24
 import java.io.IOException;
22 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 35
 @Service
33 36
 @WebSocketHandlerService(path = "/webSocket/message/phone", interceptors = {
34 37
         TrackMessageSizeInterceptor.class,  //校验消息大小,验证数据完整性,需要前端参数配合
@@ -38,7 +41,7 @@ import java.util.*;
38 41
         atmosphereConfig = {"org.atmosphere.websocket.WebSocketProtocol=org.atmosphere.websocket.protocol.StreamingHttpProtocol"})
39 42
 public class PhoneWebSocket extends CacheHandlerAdapter {
40 43
     public final static WebSocketSender webSocketSender = new WebSocketSender();
41
-
44
+    private static Log log = LogFactory.getLog(PhoneWebSocket.class);
42 45
     private static IDictionaryDAO dictionaryDAO;
43 46
     @Autowired
44 47
     public void setDictionaryDAO(IDictionaryDAO dictionaryDAO) {
@@ -83,6 +86,11 @@ public class PhoneWebSocket extends CacheHandlerAdapter {
83 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 94
         JSONObject jsonObject = JsonUtil.toJSONObject(data);
87 95
         String identity = jsonObject.optString("userCount");
88 96
         String[] nameAndPhone = identity.split("\\|");

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

@@ -1,7 +1,7 @@
1 1
 mysql2.spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
2 2
 #\u8F6C\u8FD0\u4E1A\u52A1\u5E93\u6570\u636E\u6E90
3 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 5
 #mysql2.spring.datasource.url=jdbc:mysql://192.168.3.108:3306/hsms2_tjzy_0622?autoReconnect=true&useUnicode=true&characterEncoding=utf8
6 6
 mysql2.spring.datasource.username=root
7 7
 mysql2.spring.datasource.password=100100