Просмотр исходного кода

报警列表、报警数量、iot采用同样的方式,sdv不一样共享value的方式

menglu 3 лет назад
Родитель
Сommit
45fc0912e3

+ 18 - 11
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDAlarmUtil.java

@@ -536,20 +536,27 @@ public class RWDAlarmUtil {
 				}
 			}
 			alarmCount.value_prim.value = alarmList.value_array.set.size();
+		}
 
-			RepositoryImpl Repository = RepositoryContainer.instance;
+		RepositoryImpl Repository = RepositoryContainer.instance;
+		if (Repository.enable_factor) {
 			Repository.addWaitCompute(RepositoryContainer.RepositoryProject.alarmArray);
-			try {
-				String path_alarmList = PathUtil.getDataPath(alarmList);
-				String path_alarmCount = PathUtil.getDataPath(alarmCount);
-				log.warn(path_alarmList);
-				log.warn(path_alarmCount);
-			} catch (Exception e) {
+			if (Repository.id2sdv.containsKey(objId)) {
+				SceneDataObject objSDV = Repository.id2sdv.get(objId);
+				SceneDataValue sv_alarmList = objSDV.get("报警列表");
+				SceneDataValue sv_alarmCount = objSDV.get("报警数量");
+				try {
+					String path_alarmList = PathUtil.getDataPath(sv_alarmList);
+					String path_alarmCount = PathUtil.getDataPath(sv_alarmCount);
+					log.warn(path_alarmList);
+					log.warn(path_alarmCount);
+				} catch (Exception e) {
+				}
+				// Repository.ComputeOccur(sv_alarmList);
+				// Repository.ComputeOccur(sv_alarmCount);
+				Repository.addWaitCompute(sv_alarmList);
+				Repository.addWaitCompute(sv_alarmCount);
 			}
-			Repository.ComputeOccur(alarmList);
-			Repository.ComputeOccur(alarmCount);
-			Repository.addWaitCompute(alarmList);
-			Repository.addWaitCompute(alarmCount);
 		}
 	}
 

+ 13 - 2
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDLoadUtil.java

@@ -533,7 +533,12 @@ public class RWDLoadUtil {
 					RepositoryContainer.RepositoryProject.id2alarmList.putIfAbsent(objId, sv_alarmList);
 				}
 				SceneDataValue alarmList = RepositoryContainer.RepositoryProject.id2alarmList.get(objId);
-				objectItem.put("报警列表", alarmList);
+				{
+					SceneDataValue sv_alarmList = new SceneDataValue(Repository, objectItem, "报警列表", null);
+					sv_alarmList.finish = true;
+					sv_alarmList.value_array = alarmList.value_array;
+					objectItem.put("报警列表", sv_alarmList);
+				}
 				{
 					SceneDataValue sv_alarmCount = new SceneDataValue(null, null, "报警数量", null);
 					sv_alarmCount.finish = true;
@@ -543,7 +548,13 @@ public class RWDLoadUtil {
 					RepositoryContainer.RepositoryProject.id2alarmCount.putIfAbsent(objId, sv_alarmCount);
 				}
 				SceneDataValue alarmCount = RepositoryContainer.RepositoryProject.id2alarmCount.get(objId);
-				objectItem.put("报警数量", alarmCount);
+				{
+					SceneDataValue sv_alarmCount = new SceneDataValue(Repository, objectItem, "报警数量", null);
+					sv_alarmCount.finish = true;
+					sv_alarmCount.value_prim = alarmCount.value_prim;
+					objectItem.put("报警数量", sv_alarmCount);
+				}
+				objectArray.setColChange("报警数量");
 				if (use_sample) {
 					if (BKDRHash.getHashCode(objId) % 3 == 0) {
 						JSONObject alarm = FastJsonReaderUtil.Instance().ReadJSONObject(FileUtil.file("alarm_sample.json"));

+ 2 - 5
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDRepositoryUtil.java

@@ -79,12 +79,9 @@ public class RWDRepositoryUtil {
 			Repository.InfoPointRelationArray = RepositoryContainer.instance.InfoPointRelationArray;
 		}
 
-		//清理依赖
-		Repository.clear_children();
+		// 清理依赖
 		Repository.dependency.clear();
-		//构建zkt到rwd的依赖
-		Repository.refresh_children();
-		//构建IOT到对象信息点的依赖
+		//构建依赖关系
 		Repository.refresh_dependency();
 
 		log.warn("LoadConfig");

+ 42 - 16
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RepositoryImpl.java

@@ -183,7 +183,7 @@ public class RepositoryImpl extends RepositoryBase {
 		return result;
 	}
 
-	public void refresh_children() {
+	private void refresh_rwd2zkt() {
 		for (SceneDataObject classItem : this.ZKTClassArray.set) {
 			String ibmsSceneCode = (String) classItem.get("ibmsSceneCode").value_prim.value;
 			String ibmsClassCode = (String) classItem.get("ibmsClassCode").value_prim.value;
@@ -197,14 +197,14 @@ public class RepositoryImpl extends RepositoryBase {
 			SceneDataValue sdv = this.ZKTObjectArrayDic.get(ibmsSceneCode).get(ibmsClassCode);
 			for (SceneDataObject obj : sdv.value_array.set) {
 				if (obj.father != null) {
-					this.sdv2Children.putIfAbsent(obj.father, new CopyOnWriteArrayList<SceneDataObject>());
-					this.sdv2Children.get(obj.father).add(obj);
+					this.dependency.sdv2Children.putIfAbsent(obj.father, new CopyOnWriteArrayList<SceneDataObject>());
+					this.dependency.sdv2Children.get(obj.father).add(obj);
 				}
 			}
 		}
 	}
 
-	public void refresh_dependency() {
+	private void refresh_iot2SetColumn() {
 		for (String key : this.objectArrayDic.keySet()) {
 			if (this.objTypeMap.containsKey(key)) {
 				continue;
@@ -221,7 +221,7 @@ public class RepositoryImpl extends RepositoryBase {
 						String Key = infoCode;
 						SceneDataValue sdv = obj.get(Key);
 						if (sdv != null) {
-							this.dependency.add_iot(sdv, objectArray, Key);
+							this.dependency.add_sdv2SetColumn(sdv, objectArray, Key);
 						}
 					}
 				} else if (RWDUtil.getInfoType(info) == 2) {
@@ -230,7 +230,7 @@ public class RepositoryImpl extends RepositoryBase {
 						String Key = infoCode;
 						SceneDataValue sdv = obj.get(Key);
 						if (sdv != null) {
-							this.dependency.add_iot(sdv, objectArray, Key);
+							this.dependency.add_sdv2SetColumn(sdv, objectArray, Key);
 						}
 					}
 				}
@@ -238,8 +238,31 @@ public class RepositoryImpl extends RepositoryBase {
 		}
 	}
 
-	public void clear_children() {
-		this.sdv2Children.clear();
+	private void refresh_alarm2SetColumn() {
+		for (String classCode : this.objectArrayDic.keySet()) {
+			if (!this.code2objTypeMap.containsKey(classCode)) {
+				continue;
+			}
+			String objType = this.code2objTypeMap.get(classCode);
+			if (!objType.equals("equipment") && !objType.equals("system") && !objType.equals("space")) {
+				continue;
+			}
+			SceneDataSet objectArray = this.objectArrayDic.get(classCode).value_array;
+			for (int i = 0; i < objectArray.set.size(); i++) {
+				SceneDataObject objectItem = objectArray.set.get(i);
+				SceneDataValue sdv = objectItem.get("报警数量");
+				this.dependency.add_sdv2SetColumn(sdv, objectArray, "报警数量");
+			}
+		}
+	}
+
+	public void refresh_dependency() {
+		// 构建zkt到rwd的依赖
+		this.refresh_rwd2zkt();
+		// 构建IOT到对象信息点的依赖
+		this.refresh_iot2SetColumn();
+		// 构建报警数量到对象信息点的依赖
+		this.refresh_alarm2SetColumn();
 	}
 
 	public int[] recomputeIOT() {
@@ -252,14 +275,14 @@ public class RepositoryImpl extends RepositoryBase {
 				SceneDataValue sdv = RepositoryContainer.RepositoryProject.point2sdv.get(point);
 				if (sdv.value_prim.value != null) {
 					item_count++;
-					affect_count += this.recompute_point(point);
+					affect_count += this.ProcessIOT(point);
 				}
 			}
 			for (String point : RepositoryContainer.RepositoryProject.set2sdv.keySet()) {
 				SceneDataValue sdv = RepositoryContainer.RepositoryProject.set2sdv.get(point);
 				if (sdv.value_prim.value != null) {
 					item_count++;
-					affect_count += this.recompute_point(point);
+					affect_count += this.ProcessIOT(point);
 				}
 			}
 		}
@@ -289,13 +312,16 @@ public class RepositoryImpl extends RepositoryBase {
 		return counts;
 	}
 
-	public int recompute_point(String point) {
+	public int ProcessIOT(String point) {
 		int add_count = 0;
-		if (this.point2ObjectInfoList.containsKey(point)) {
-			List<ObjectInfo> ObjectInfoList = this.point2ObjectInfoList.get(point);
-			for (ObjectInfo ObjectInfo : ObjectInfoList) {
-				SceneDataValue sdv = ObjectInfo.obj.get(ObjectInfo.infoCode);
-				add_count += this.addWaitCompute(sdv);
+		if (this.enable_factor) {
+			if (this.point2ObjectInfoList.containsKey(point)) {
+				List<ObjectInfo> ObjectInfoList = this.point2ObjectInfoList.get(point);
+				for (ObjectInfo ObjectInfo : ObjectInfoList) {
+					SceneDataValue sdv = ObjectInfo.obj.get(ObjectInfo.infoCode);
+					// this.ComputeOccur(sdv);
+					add_count += this.addWaitCompute(sdv);
+				}
 			}
 		}
 		return add_count;

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

@@ -103,8 +103,8 @@ public class IOTWebSocketClient extends WebSocketClient {
 							boolean valueEqual = valueNew.equals(data.value_prim.value);
 							data.value_prim.value = valueNew;
 							// 加入计算队列
-							if (!valueEqual && Repository.enable_factor) {
-								Repository.recompute_point(point);
+							if (!valueEqual) {
+								Repository.ProcessIOT(point);
 							}
 						} else if (type.equals("text")) {
 							data.value_prim.value = value;
@@ -150,8 +150,8 @@ public class IOTWebSocketClient extends WebSocketClient {
 						boolean valueEqual = valueNew.equals(data.value_prim.value);
 						data.value_prim.value = valueNew;
 						// 加入计算队列
-						if (!valueEqual && Repository.enable_factor) {
-							Repository.recompute_point(point);
+						if (!valueEqual) {
+							Repository.ProcessIOT(point);
 						}
 					} catch (Exception e) {
 						log.error(e.getMessage(), e);