Prechádzať zdrojové kódy

text类型的数据加入iot计算

menglu 2 rokov pred
rodič
commit
1a474c2477

+ 22 - 22
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/websocket/IOTWebSocketClient.java

@@ -78,9 +78,9 @@ public class IOTWebSocketClient extends WebSocketClient {
 			if ("iot".equals(type) || "text".equals(type)) {
 				String message = json.getString("data");
 				// String message = GZIPCompressUtil.uncompress(arg0);
-//				 log.info("打印日志:"+message);
+				// log.info("打印日志:"+message);
 
-				String[] splits = message.split(";",-1);
+				String[] splits = message.split(";", -1);
 				recent_count += splits.length / 4;
 				for (int i = 0; i < splits.length; i += 4) {
 					String time = splits[i + 0];
@@ -89,7 +89,7 @@ public class IOTWebSocketClient extends WebSocketClient {
 					String value = splits[i + 3];
 					String point = meter + "-" + funcid;
 					/** 处理空数据 */
-					if("".equals(value)||"null".equals(value)||value == null){
+					if ("".equals(value) || "null".equals(value) || value == null) {
 						value = null;
 					}
 
@@ -101,11 +101,11 @@ public class IOTWebSocketClient extends WebSocketClient {
 							RepositoryContainer.RepositoryProject.sdv2point.putIfAbsent(sdvInner, point);
 						}
 						SceneDataPrimitive data = RepositoryContainer.RepositoryProject.point2sdv.get(point);
+						Object valueNew;
 						if ("iot".equals(type)) {
-							if (value!=null&&value.endsWith(".0")) {
+							if (value != null && value.endsWith(".0")) {
 								value = value.substring(0, value.length() - ".0".length());
 							}
-							Object valueNew;
 							try {
 								valueNew = Long.parseLong(value);
 							} catch (Exception e1) {
@@ -128,21 +128,6 @@ public class IOTWebSocketClient extends WebSocketClient {
 									valueNew = value;
 								}
 							}
-							boolean valueEqual;
-							if (valueNew==null){
-								valueEqual = false;
-							} else  {
-								valueEqual = valueNew.equals(data.value);
-							}
-							data.value = valueNew;
-							// 加入计算队列
-							if (!valueEqual) {
-								recent_change_count++;
-								int affect_count = Repository.ProcessIOT(point);
-								if (affect_count > 0) {
-									recent_affect_count++;
-								}
-							}
 							// 检查是否子系统连接状态
 							if (meter.startsWith("subsystem_connect_status_")) {
 								String subsystem = meter.substring("subsystem_connect_status_".length());
@@ -196,8 +181,23 @@ public class IOTWebSocketClient extends WebSocketClient {
 									}
 								}
 							}
-						} else if (type.equals("text")) {
-							data.value = value;
+						} else {// "text".equals(type)
+							valueNew = value;
+						}
+						boolean valueEqual;
+						if (valueNew == null) {
+							valueEqual = false;
+						} else {
+							valueEqual = valueNew.equals(data.value);
+						}
+						data.value = valueNew;
+						// 加入计算队列
+						if (!valueEqual) {
+							recent_change_count++;
+							int affect_count = Repository.ProcessIOT(point);
+							if (affect_count > 0) {
+								recent_affect_count++;
+							}
 						}
 					} catch (Exception e) {
 						log.error(e.getMessage(), e);