Browse Source

iot数据sdv和prim分离导致deamon出bug,修复0.0.40

menglu 3 years ago
parent
commit
c9d021ba0d

+ 2 - 2
ibms-data-sdk/pom.xml

@@ -2,7 +2,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>com.persagy</groupId>
 	<artifactId>ibms-data-sdk</artifactId>
-	<version>0.0.5</version>
+	<version>0.0.6</version>
 
 	<repositories>
 		<repository>
@@ -214,7 +214,7 @@
 		<dependency>
 			<groupId>com.persagy</groupId>
 			<artifactId>sailfish</artifactId>
-			<version>0.0.39</version>
+			<version>0.0.40</version>
 		</dependency>
 	</dependencies>
 

+ 10 - 14
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDLoadUtil.java

@@ -251,17 +251,15 @@ public class RWDLoadUtil {
 								ObjectInfoList.add(new ObjectInfo(obj, obj_id, Key));
 								// 表号功能号改为null
 								{
-									SceneDataValue sdv = new SceneDataValue(null, null, null, null);
-									sdv.finish = true;
-									sdv.value_prim = new SceneDataPrimitive();
-									sdv.value_prim.change = true;
-									SceneDataValue exist_sdv = RepositoryContainer.RepositoryProject.point2sdv.putIfAbsent(point, sdv);
+									SceneDataPrimitive sdv = new SceneDataPrimitive();
+									sdv.change = true;
+									SceneDataPrimitive exist_sdv = RepositoryContainer.RepositoryProject.point2sdv.putIfAbsent(point, sdv);
 									if (exist_sdv == null) {
 										RepositoryContainer.RepositoryProject.sdv2point.putIfAbsent(sdv, point);
 									}
 								}
-								SceneDataValue data = RepositoryContainer.RepositoryProject.point2sdv.get(point);
-								infoValue.value_prim = data.value_prim;
+								SceneDataPrimitive data = RepositoryContainer.RepositoryProject.point2sdv.get(point);
+								infoValue.value_prim = data;
 								{
 									SceneDataValue sdv = new SceneDataValue(null, null, null, null);
 									sdv.finish = true;
@@ -288,17 +286,15 @@ public class RWDLoadUtil {
 								ObjectInfoList.add(new ObjectInfo(obj, obj_id, Key));
 								// 表号功能号改为null
 								{
-									SceneDataValue sdv = new SceneDataValue(null, null, null, null);
-									sdv.finish = true;
-									sdv.value_prim = new SceneDataPrimitive();
-									sdv.value_prim.change = true;
-									SceneDataValue exist_sdv = RepositoryContainer.RepositoryProject.set2sdv.putIfAbsent(point, sdv);
+									SceneDataPrimitive sdv = new SceneDataPrimitive();
+									sdv.change = true;
+									SceneDataPrimitive exist_sdv = RepositoryContainer.RepositoryProject.set2sdv.putIfAbsent(point, sdv);
 									if (exist_sdv == null) {
 										RepositoryContainer.RepositoryProject.sdv2set.putIfAbsent(sdv, point);
 									}
 								}
-								SceneDataValue data = RepositoryContainer.RepositoryProject.set2sdv.get(point);
-								infoValue.value_prim = data.value_prim;
+								SceneDataPrimitive data = RepositoryContainer.RepositoryProject.set2sdv.get(point);
+								infoValue.value_prim = data;
 								{
 									SceneDataValue sdv = new SceneDataValue(null, null, null, null);
 									sdv.finish = true;

+ 7 - 6
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RepositoryImpl.java

@@ -10,6 +10,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.persagy.ibms.core.data.SceneDataObject;
+import com.persagy.ibms.core.data.SceneDataPrimitive;
 import com.persagy.ibms.core.data.SceneDataSet;
 import com.persagy.ibms.core.data.SceneDataValue;
 import com.persagy.ibms.core.util.RWDUtil;
@@ -78,11 +79,11 @@ public class RepositoryImpl extends RepositoryBase {
 		this.RepositoryProject = RepositoryProject;
 	}
 
-	public ConcurrentHashMap<SceneDataValue, String> sdv2point() {
+	public ConcurrentHashMap<SceneDataPrimitive, String> sdv2point() {
 		return RepositoryProject.sdv2point;
 	}
 
-	public ConcurrentHashMap<SceneDataValue, String> sdv2set() {
+	public ConcurrentHashMap<SceneDataPrimitive, String> sdv2set() {
 		return RepositoryProject.sdv2set;
 	}
 
@@ -281,15 +282,15 @@ public class RepositoryImpl extends RepositoryBase {
 		// 加入计算队列
 		if (this.enable_factor) {
 			for (String point : this.RepositoryProject.point2sdv.keySet()) {
-				SceneDataValue sdv = this.RepositoryProject.point2sdv.get(point);
-				if (sdv.value_prim.value != null) {
+				SceneDataPrimitive sdv = this.RepositoryProject.point2sdv.get(point);
+				if (sdv.value != null) {
 					item_count++;
 					affect_count += this.ProcessIOT(point);
 				}
 			}
 			for (String point : this.RepositoryProject.set2sdv.keySet()) {
-				SceneDataValue sdv = this.RepositoryProject.set2sdv.get(point);
-				if (sdv.value_prim.value != null) {
+				SceneDataPrimitive sdv = this.RepositoryProject.set2sdv.get(point);
+				if (sdv.value != null) {
 					item_count++;
 					affect_count += this.ProcessIOT(point);
 				}

+ 5 - 4
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RepositoryProject.java

@@ -7,6 +7,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
 
 import com.alibaba.fastjson.JSONObject;
 import com.persagy.ibms.core.data.SceneDataObject;
+import com.persagy.ibms.core.data.SceneDataPrimitive;
 import com.persagy.ibms.core.data.SceneDataSet;
 import com.persagy.ibms.core.data.SceneDataValue;
 import com.persagy.ibms.core.util.LogOfDownload;
@@ -22,12 +23,12 @@ public class RepositoryProject {
 	public Map<String, String> resourceMap_valid = new ConcurrentHashMap<String, String>();
 
 	// IOT采集数据
-	public ConcurrentHashMap<String, SceneDataValue> point2sdv = new ConcurrentHashMap<String, SceneDataValue>();
-	public ConcurrentHashMap<SceneDataValue, String> sdv2point = new ConcurrentHashMap<SceneDataValue, String>();
+	public ConcurrentHashMap<String, SceneDataPrimitive> point2sdv = new ConcurrentHashMap<String, SceneDataPrimitive>();
+	public ConcurrentHashMap<SceneDataPrimitive, String> sdv2point = new ConcurrentHashMap<SceneDataPrimitive, String>();
 	public ConcurrentHashMap<String, List<SceneDataObject>> point2curve = new ConcurrentHashMap<String, List<SceneDataObject>>();
 	// IOT设置数据
-	public ConcurrentHashMap<String, SceneDataValue> set2sdv = new ConcurrentHashMap<String, SceneDataValue>();
-	public ConcurrentHashMap<SceneDataValue, String> sdv2set = new ConcurrentHashMap<SceneDataValue, String>();
+	public ConcurrentHashMap<String, SceneDataPrimitive> set2sdv = new ConcurrentHashMap<String, SceneDataPrimitive>();
+	public ConcurrentHashMap<SceneDataPrimitive, String> sdv2set = new ConcurrentHashMap<SceneDataPrimitive, String>();
 	// 报警数据
 	public SceneDataSet alarmArray = new SceneDataSet(false, true);
 	public ConcurrentHashMap<String, SceneDataValue> id2alarmList = new ConcurrentHashMap<String, SceneDataValue>();

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

@@ -81,15 +81,13 @@ public class IOTWebSocketClient extends WebSocketClient {
 					String value = splits[i + 3];
 					String point = meter + "-" + funcid;
 					try {
-						SceneDataValue sdvInner = new SceneDataValue(null, null, null, null);
-						sdvInner.finish = true;
-						sdvInner.value_prim = new SceneDataPrimitive();
-						sdvInner.value_prim.change = true;
-						SceneDataValue exist_sdv = RepositoryContainer.RepositoryProject.point2sdv.putIfAbsent(point, sdvInner);
+						SceneDataPrimitive sdvInner = new SceneDataPrimitive();
+						sdvInner.change = true;
+						SceneDataPrimitive exist_sdv = RepositoryContainer.RepositoryProject.point2sdv.putIfAbsent(point, sdvInner);
 						if (exist_sdv == null) {
 							RepositoryContainer.RepositoryProject.sdv2point.putIfAbsent(sdvInner, point);
 						}
-						SceneDataValue data = RepositoryContainer.RepositoryProject.point2sdv.get(point);
+						SceneDataPrimitive data = RepositoryContainer.RepositoryProject.point2sdv.get(point);
 						if (type.equals("iot")) {
 							if (value.endsWith(".0")) {
 								value = value.substring(0, value.length() - ".0".length());
@@ -104,8 +102,8 @@ public class IOTWebSocketClient extends WebSocketClient {
 									valueNew = value;
 								}
 							}
-							boolean valueEqual = valueNew.equals(data.value_prim.value);
-							data.value_prim.value = valueNew;
+							boolean valueEqual = valueNew.equals(data.value);
+							data.value = valueNew;
 							// 加入计算队列
 							if (!valueEqual) {
 								Repository.ProcessIOT(point);
@@ -149,7 +147,7 @@ public class IOTWebSocketClient extends WebSocketClient {
 												{
 													SceneDataValue existItem_sdv = new SceneDataValue(null, existItem, "连接状态", null);
 													existItem_sdv.value_prim = new SceneDataPrimitive();
-													existItem.put("连接状态", sdvInner);
+													existItem.put("连接状态", existItem_sdv);
 												}
 												sdv_connect.value_array.set.add(existItem);
 											}
@@ -164,7 +162,7 @@ public class IOTWebSocketClient extends WebSocketClient {
 								}
 							}
 						} else if (type.equals("text")) {
-							data.value_prim.value = value;
+							data.value = value;
 						}
 					} catch (Exception e) {
 						log.error(e.getMessage(), e);
@@ -182,15 +180,13 @@ public class IOTWebSocketClient extends WebSocketClient {
 					String value = splits[i + 3];
 					String point = meter + "-" + funcid;
 					try {
-						SceneDataValue sdvInner = new SceneDataValue(null, null, null, null);
-						sdvInner.finish = true;
-						sdvInner.value_prim = new SceneDataPrimitive();
-						sdvInner.value_prim.change = true;
-						SceneDataValue exist_sdv = RepositoryContainer.RepositoryProject.set2sdv.putIfAbsent(point, sdvInner);
+						SceneDataPrimitive sdvInner = new SceneDataPrimitive();
+						sdvInner.change = true;
+						SceneDataPrimitive exist_sdv = RepositoryContainer.RepositoryProject.set2sdv.putIfAbsent(point, sdvInner);
 						if (exist_sdv == null) {
 							RepositoryContainer.RepositoryProject.sdv2set.putIfAbsent(sdvInner, point);
 						}
-						SceneDataValue data = RepositoryContainer.RepositoryProject.set2sdv.get(point);
+						SceneDataPrimitive data = RepositoryContainer.RepositoryProject.set2sdv.get(point);
 						if (value.endsWith(".0")) {
 							value = value.substring(0, value.length() - ".0".length());
 						}
@@ -204,8 +200,8 @@ public class IOTWebSocketClient extends WebSocketClient {
 								valueNew = value;
 							}
 						}
-						boolean valueEqual = valueNew.equals(data.value_prim.value);
-						data.value_prim.value = valueNew;
+						boolean valueEqual = valueNew.equals(data.value);
+						data.value = valueNew;
 						// 加入计算队列
 						if (!valueEqual) {
 							Repository.ProcessIOT(point);