Browse Source

update:数据质量,子系统掉线或对接系统出问题,接收 iot-project 传的空数据

zhangweixin 2 years ago
parent
commit
0f0c1f5cd1

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

@@ -211,8 +211,11 @@ public class DaemonThread extends Thread {
 
 				try {
 					for (String url : Constant.iot_websocket_url) {
+						/** IOT  WebSocket   URL地址 */
+//						String serviceUrl = url + "?projectId=" + RepositoryContainer.RepositoryProject.projectId.substring(2)
+//								+ "&type=iot,text,pointset";
 						String serviceUrl = url + "?projectId=" + RepositoryContainer.RepositoryProject.projectId.substring(2)
-								+ "&type=iot,text,pointset";
+								+ "&type=iot,pointset,text&getFullData=true";
 						log.warn("********************************" + "\t" + "iot-websocket" + "\n" + serviceUrl);
 						IOTWebSocketClient client = new IOTWebSocketClient(new URI(serviceUrl));
 						client.connect();

+ 2 - 0
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/service/rest/RestUtil.java

@@ -30,6 +30,7 @@ import com.persagy.ibms.core.util.QueryUtil;
 import com.persagy.ibms.core.util.RecursiveUtil;
 import com.persagy.ibms.data.sdk.util.*;
 
+import lombok.ToString;
 import lombok.extern.slf4j.Slf4j;
 
 @Slf4j
@@ -230,6 +231,7 @@ public class RestUtil {
 	public static String get_control_value(String param) {
 		RepositoryImpl Repository = RepositoryContainer.instance;
 		JSONObject result = new JSONObject();
+
 		try {
 			JSONArray path = JSON.parseArray(param);
 			log.info("path: " + path);

+ 9 - 1
ibms-data-sdk/src/main/java/com/persagy/ibms/data/sdk/util/ControlUtil.java

@@ -67,7 +67,7 @@ public class ControlUtil {
 				if (first_info_value == null) {
 					first_info_value = info_value;
 				} else {
-					if (!first_info_value.equals(info_value)) {
+					if (!first_info_value.toString().equals(info_value)) {
 						all_equal = false;
 						break;
 					}
@@ -314,6 +314,8 @@ public class ControlUtil {
 
 	private static void saveBatchOperationLog(JSONArray postParam) throws Exception {
 		String post_url = Constant.zkt_control_url + "/operationLog/saveBatchOperationLog";
+		System.out.println("保存日志url:"+post_url );
+		System.out.println("保存日志boby:"+postParam.toJSONString() );
 		String post_result = HttpClientUtil.instance("zkt_control").post(post_url, postParam.toJSONString());
 		JSONObject result = JSON.parseObject(post_result);
 		log.debug(result.toJSONString());
@@ -397,7 +399,10 @@ public class ControlUtil {
 		if (Constant.control_mode.equals("sync")) {
 			String post_url = Constant.iot_project_url + "/sync_pointsetbatch_post";
 			log.debug(postJSON.toJSONString());
+			System.out.println("url1:"+post_url);
+			System.out.println("boby1:"+postJSON.toJSONString());
 			String post_result = HttpClientUtil.instance("iot_project").post(post_url, postJSON.toJSONString());
+			System.out.println("result1:"+postJSON.toJSONString());
 			JSONObject result = JSON.parseObject(post_result);
 			JSONArray result_points = (JSONArray) result.get("points");
 			log.debug(post_result);
@@ -406,6 +411,9 @@ public class ControlUtil {
 			String post_url = Constant.iot_project_url + "/pointsetbatch_post";
 			log.debug(postJSON.toJSONString());
 			String post_result = HttpClientUtil.instance("iot_project").post(post_url, postJSON.toJSONString());
+			System.out.println("url1:"+post_url);
+			System.out.println("boby1:"+postJSON.toJSONString());
+			System.out.println("result2:"+postJSON.toJSONString());
 			JSONObject result = JSON.parseObject(post_result);
 			JSONArray result_points = (JSONArray) result.get("points");
 			for (int i = 0; i < result_points.size(); i++) {

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

@@ -75,12 +75,12 @@ public class IOTWebSocketClient extends WebSocketClient {
 			JSONObject json = (JSONObject) JSON.parse(arg0);
 			WebSocketUtil.ProcessIOTReceived(json);
 			String type = json.getString("type");
-			if (type.equals("iot") || type.equals("text")) {
+			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(";");
+				String[] splits = message.split(";",-1);
 				recent_count += splits.length / 4;
 				for (int i = 0; i < splits.length; i += 4) {
 					String time = splits[i + 0];
@@ -88,6 +88,11 @@ public class IOTWebSocketClient extends WebSocketClient {
 					String funcid = splits[i + 2];
 					String value = splits[i + 3];
 					String point = meter + "-" + funcid;
+					/** 处理空数据 */
+					if("".equals(value)||"null".equals(value)||value == null){
+						value = null;
+					}
+
 					try {
 						SceneDataPrimitive sdvInner = new SceneDataPrimitive();
 						sdvInner.change = true;
@@ -96,8 +101,8 @@ public class IOTWebSocketClient extends WebSocketClient {
 							RepositoryContainer.RepositoryProject.sdv2point.putIfAbsent(sdvInner, point);
 						}
 						SceneDataPrimitive data = RepositoryContainer.RepositoryProject.point2sdv.get(point);
-						if (type.equals("iot")) {
-							if (value.endsWith(".0")) {
+						if ("iot".equals(type)) {
+							if (value!=null&&value.endsWith(".0")) {
 								value = value.substring(0, value.length() - ".0".length());
 							}
 							Object valueNew;
@@ -123,7 +128,12 @@ public class IOTWebSocketClient extends WebSocketClient {
 									valueNew = value;
 								}
 							}
-							boolean valueEqual = valueNew.equals(data.value);
+							boolean valueEqual;
+							if (valueNew==null){
+								valueEqual = false;
+							} else  {
+								valueEqual = valueNew.equals(data.value);
+							}
 							data.value = valueNew;
 							// 加入计算队列
 							if (!valueEqual) {