|
@@ -1,6 +1,7 @@
|
|
package com.persagy.ibms.data.sdk.websocket;
|
|
package com.persagy.ibms.data.sdk.websocket;
|
|
|
|
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
|
import org.java_websocket.client.WebSocketClient;
|
|
import org.java_websocket.client.WebSocketClient;
|
|
@@ -8,7 +9,9 @@ import org.java_websocket.handshake.ServerHandshake;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
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.SceneDataPrimitive;
|
|
|
|
+import com.persagy.ibms.core.data.SceneDataSet;
|
|
import com.persagy.ibms.core.data.SceneDataValue;
|
|
import com.persagy.ibms.core.data.SceneDataValue;
|
|
import com.persagy.ibms.data.sdk.service.websocket.server.WebSocketUtil;
|
|
import com.persagy.ibms.data.sdk.service.websocket.server.WebSocketUtil;
|
|
import com.persagy.ibms.data.sdk.util.RepositoryContainer;
|
|
import com.persagy.ibms.data.sdk.util.RepositoryContainer;
|
|
@@ -52,6 +55,7 @@ public class IOTWebSocketClient extends WebSocketClient {
|
|
@Override
|
|
@Override
|
|
public void onMessage(String arg0) {
|
|
public void onMessage(String arg0) {
|
|
try {
|
|
try {
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
RepositoryImpl Repository = RepositoryContainer.instance;
|
|
RepositoryImpl Repository = RepositoryContainer.instance;
|
|
Date currTime = new Date();
|
|
Date currTime = new Date();
|
|
if (currTime.getTime() / (1000L * 60) != lastTime.getTime() / (1000L * 60)) {
|
|
if (currTime.getTime() / (1000L * 60) != lastTime.getTime() / (1000L * 60)) {
|
|
@@ -71,7 +75,7 @@ public class IOTWebSocketClient extends WebSocketClient {
|
|
String[] splits = message.split(";");
|
|
String[] splits = message.split(";");
|
|
recent_count += splits.length / 4;
|
|
recent_count += splits.length / 4;
|
|
for (int i = 0; i < splits.length; i += 4) {
|
|
for (int i = 0; i < splits.length; i += 4) {
|
|
- // String time = splits[i + 0];
|
|
|
|
|
|
+ String time = splits[i + 0];
|
|
String meter = splits[i + 1];
|
|
String meter = splits[i + 1];
|
|
String funcid = splits[i + 2];
|
|
String funcid = splits[i + 2];
|
|
String value = splits[i + 3];
|
|
String value = splits[i + 3];
|
|
@@ -86,6 +90,7 @@ public class IOTWebSocketClient extends WebSocketClient {
|
|
RepositoryContainer.RepositoryProject.sdv2point.putIfAbsent(sdvInner, point);
|
|
RepositoryContainer.RepositoryProject.sdv2point.putIfAbsent(sdvInner, point);
|
|
}
|
|
}
|
|
SceneDataValue data = RepositoryContainer.RepositoryProject.point2sdv.get(point);
|
|
SceneDataValue data = RepositoryContainer.RepositoryProject.point2sdv.get(point);
|
|
|
|
+ data.value_prim.value = value;
|
|
if (type.equals("iot")) {
|
|
if (type.equals("iot")) {
|
|
if (value.endsWith(".0")) {
|
|
if (value.endsWith(".0")) {
|
|
value = value.substring(0, value.length() - ".0".length());
|
|
value = value.substring(0, value.length() - ".0".length());
|
|
@@ -106,6 +111,59 @@ public class IOTWebSocketClient extends WebSocketClient {
|
|
if (!valueEqual) {
|
|
if (!valueEqual) {
|
|
Repository.ProcessIOT(point);
|
|
Repository.ProcessIOT(point);
|
|
}
|
|
}
|
|
|
|
+ // 检查是否子系统连接状态
|
|
|
|
+ if (meter.startsWith("subsystem_connect_status_")) {
|
|
|
|
+ String subsystem = meter.substring("subsystem_connect_status_".length());
|
|
|
|
+ int index_sub = subsystem.indexOf('_');
|
|
|
|
+ String product;
|
|
|
|
+ String tail = "";
|
|
|
|
+ if (index_sub == -1) {
|
|
|
|
+ product = subsystem;
|
|
|
|
+ } else {
|
|
|
|
+ product = subsystem.substring(0, index_sub);
|
|
|
|
+ tail = subsystem.substring(index_sub + 1);
|
|
|
|
+ }
|
|
|
|
+ for (SceneDataObject sdo_connect : Repository.subsystem_connect_status.set) {
|
|
|
|
+ String ibmsSceneCode = (String) sdo_connect.get("ibmsSceneCode").value_prim.value;
|
|
|
|
+ if (product.equals(ibmsSceneCode)) {
|
|
|
|
+ SceneDataValue sdv_connect = sdo_connect.get("连接状态");
|
|
|
|
+ if (tail != null && tail.length() > 0) {
|
|
|
|
+ if (sdv_connect.value_array == null) {
|
|
|
|
+ sdv_connect.value_array = new SceneDataSet(false);
|
|
|
|
+ }
|
|
|
|
+ SceneDataObject existItem = null;
|
|
|
|
+ for (SceneDataObject connectInner : sdv_connect.value_array.set) {
|
|
|
|
+ String nameInner = (String) connectInner.get("名称").value_prim.value;
|
|
|
|
+ if (nameInner.equals(tail)) {
|
|
|
|
+ existItem = connectInner;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (existItem == null) {
|
|
|
|
+ existItem = new SceneDataObject(null, null, null, sdv_connect, null, null, null);
|
|
|
|
+ {
|
|
|
|
+ SceneDataValue existItem_sdv = new SceneDataValue(null, existItem, "名称", null);
|
|
|
|
+ existItem_sdv.value_prim = new SceneDataPrimitive();
|
|
|
|
+ existItem_sdv.value_prim.value = tail;
|
|
|
|
+ existItem.put("名称", existItem_sdv);
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ SceneDataValue existItem_sdv = new SceneDataValue(null, existItem, "连接状态", null);
|
|
|
|
+ existItem_sdv.value_prim = new SceneDataPrimitive();
|
|
|
|
+ existItem.put("连接状态", sdvInner);
|
|
|
|
+ }
|
|
|
|
+ sdv_connect.value_array.set.add(existItem);
|
|
|
|
+ }
|
|
|
|
+ SceneDataValue connect_sdv_tmp = existItem.get("连接状态");
|
|
|
|
+ connect_sdv_tmp.value_prim.value = valueNew;
|
|
|
|
+ connect_sdv_tmp.last_compute_time = sdf.parse(time);
|
|
|
|
+ } else {
|
|
|
|
+ sdv_connect.value_prim.value = valueNew;
|
|
|
|
+ sdv_connect.last_compute_time = sdf.parse(time);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
} else if (type.equals("text")) {
|
|
} else if (type.equals("text")) {
|
|
data.value_prim.value = value;
|
|
data.value_prim.value = value;
|
|
}
|
|
}
|