Jelajahi Sumber

依赖需要刷新

menglu 3 tahun lalu
induk
melakukan
569bf8bff4

+ 1 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/DaemonThread.java

@@ -142,6 +142,7 @@ public class DaemonThread extends Thread {
 				Constant.debug = false;// 调试模式设为true
 				RepositoryImpl Repository = new RepositoryImpl();
 				Repository.use_thread = !Constant.debug;
+				Repository.enable_factor = true;
 				Repository.RepositoryBase = RepositoryContainer.RepositoryBase;
 				RWDRepositoryUtil.DoRepository(Repository, true);
 				RepositoryContainer.instance = Repository;

+ 0 - 3
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/rest/RedirectApi.java

@@ -4,9 +4,6 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
-import io.swagger.annotations.ApiOperation;
-
-@ApiOperation(value = "重定向接口")
 @RestController
 public class RedirectApi {
 

+ 6 - 1
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/rest/RestUtil.java

@@ -72,7 +72,12 @@ public class RestUtil {
 			}
 			Integer read_level = (Integer) sql_json.get("read_level");
 			read_level = read_level == null ? 4 : read_level;
-			Object queryResult = QueryUtil.query(Repository, null, sql_json, new QueryAssist());
+			QueryAssist QueryAssist = new QueryAssist();
+			QueryAssist.rowChangeNeed = true;
+			Object queryResult = QueryUtil.query(Repository, null, sql_json, QueryAssist);
+			JSONObject FactorJSON = QueryAssist.toJSON();
+			log.error("query sql:\n" + JSONObject.toJSONString(sql_json, SerializerFeature.WriteMapNullValue));
+			log.error("query factor:\n" + JSONObject.toJSONString(FactorJSON, SerializerFeature.WriteMapNullValue));
 			if (queryResult instanceof SceneDataSet) {
 				SceneDataSet sdvList = (SceneDataSet) queryResult;
 				SceneDataValue sdv = new SceneDataValue(null, null, null, null);

+ 3 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RWDRepositoryUtil.java

@@ -77,6 +77,9 @@ public class RWDRepositoryUtil {
 			Repository.InfoPointRelationArray = RepositoryContainer.instance.InfoPointRelationArray;
 		}
 
+		Repository.dependency.clear();
+		Repository.refresh_dependency();
+
 		log.warn("LoadConfig");
 		SceneObject sceneObject = new SceneObject();
 		{

+ 39 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/RepositoryImpl.java

@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.persagy.ibms.core.data.SceneDataObject;
 import com.persagy.ibms.core.data.SceneDataSet;
 import com.persagy.ibms.core.data.SceneDataValue;
+import com.persagy.ibms.core.util.RWDUtil;
 import com.persagy.ibms.core.util.RepositoryBase;
 
 public class RepositoryImpl extends RepositoryBase {
@@ -168,4 +169,42 @@ public class RepositoryImpl extends RepositoryBase {
 		}
 		return result;
 	}
+
+	public void refresh_dependency() {
+		for (String key : this.objectArrayDic.keySet()) {
+			if (this.objTypeMap.containsKey(key)) {
+				continue;
+			}
+			String classCode = key;
+			SceneDataSet infoArray = this.infoArrayDic.get(classCode);
+			SceneDataSet objectArray = this.objectArrayDic.get(key);
+			for (int index_info = 0; index_info < infoArray.set.size(); index_info++) {
+				SceneDataObject info = infoArray.set.get(index_info);
+				String infoCode = (String) info.get("code").value_prim.value;
+				if (RWDUtil.getInfoType(info) == 1) {
+					for (int index_object = 0; index_object < objectArray.set.size(); index_object++) {
+						SceneDataObject obj = objectArray.set.get(index_object);
+						String Key = infoCode;
+						SceneDataValue sdv = obj.get(Key);
+						if (sdv != null) {
+							if (this.RepositoryBase.sdv2point.containsKey(sdv)) {
+								this.dependency.add_iot(sdv, objectArray, Key);
+							}
+						}
+					}
+				} else if (RWDUtil.getInfoType(info) == 2) {
+					for (int index_object = 0; index_object < objectArray.set.size(); index_object++) {
+						SceneDataObject obj = objectArray.set.get(index_object);
+						String Key = infoCode;
+						SceneDataValue sdv = obj.get(Key);
+						if (sdv != null) {
+							if (this.RepositoryBase.sdv2set.containsKey(sdv)) {
+								this.dependency.add_iot(sdv, objectArray, Key);
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }

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

@@ -73,9 +73,6 @@ public class IOTWebSocketClient extends WebSocketClient {
 					String meter = splits[i + 1];
 					String funcid = splits[i + 2];
 					String value = splits[i + 3];
-					if (value.endsWith(".0")) {
-						value = value.substring(0, value.length() - ".0".length());
-					}
 					try {
 						SceneDataValue sdvInner = new SceneDataValue(null, null, null, null);
 						sdvInner.finish = true;
@@ -87,6 +84,9 @@ public class IOTWebSocketClient extends WebSocketClient {
 						}
 						SceneDataValue data = RepositoryContainer.RepositoryBase.point2sdv.get(meter + "-" + funcid);
 						if (type.equals("iot")) {
+							if (value.endsWith(".0")) {
+								value = value.substring(0, value.length() - ".0".length());
+							}
 							try {
 								data.value_prim.value = Long.parseLong(value);
 							} catch (Exception e1) {
@@ -113,9 +113,6 @@ public class IOTWebSocketClient extends WebSocketClient {
 					String meter = splits[i + 1];
 					String funcid = splits[i + 2];
 					String value = splits[i + 3];
-					if (value.endsWith(".0")) {
-						value = value.substring(0, value.length() - ".0".length());
-					}
 					try {
 						SceneDataValue sdvInner = new SceneDataValue(null, null, null, null);
 						SceneDataValue exist_sdv = RepositoryContainer.RepositoryBase.set2sdv.putIfAbsent(meter + "-" + funcid, sdvInner);
@@ -123,6 +120,9 @@ public class IOTWebSocketClient extends WebSocketClient {
 							RepositoryContainer.RepositoryBase.sdv2set.putIfAbsent(sdvInner, meter + "-" + funcid);
 						}
 						SceneDataValue data = RepositoryContainer.RepositoryBase.set2sdv.get(meter + "-" + funcid);
+						if (value.endsWith(".0")) {
+							value = value.substring(0, value.length() - ".0".length());
+						}
 						try {
 							data.value_prim.value = Long.parseLong(value);
 						} catch (Exception e1) {