24282 2 years ago
parent
commit
e1d484522c
2 changed files with 15 additions and 108 deletions
  1. 2 103
      config
  2. 13 5
      src/main/java/com/fjhx/equipment/ConfigurationUpload.java

+ 2 - 103
config

@@ -36,112 +36,11 @@
 {
     "debug": true,
     "serverIp": "a1625d5cc8.iot-mqtts.cn-north-4.myhuaweicloud.com",
-    "deviceId": "62d4ff516b9813541d51f893_test_node_01",
+    "deviceId": "syringe_ipc_syringe_smt",
     "secret": "fjhx2012",
 
     "connectConfigList": [
-        {
-             "equipmentNo": "zsj01",
-             "ipAddress": "192.168.157.20",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj02",
-             "ipAddress": "192.168.157.21",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj03",
-             "ipAddress": "192.168.157.22",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj04",
-             "ipAddress": "192.168.157.23",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj05",
-             "ipAddress": "192.168.157.24",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj06",
-             "ipAddress": "192.168.157.25",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj07",
-             "ipAddress": "192.168.157.26",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj08",
-             "ipAddress": "192.168.157.27",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj09",
-             "ipAddress": "192.168.157.28",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj10",
-             "ipAddress": "192.168.157.29",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "zsj11",
-             "ipAddress": "192.168.157.30",
-             "port": 16664,
-             "type": 1
-        },
-        {
-             "equipmentNo": "gyj01",
-             "ipAddress": "192.168.157.40",
-             "port": 502,
-             "type": 2
-        },
-        {
-             "equipmentNo": "gyj02",
-             "ipAddress": "192.168.157.41",
-             "port": 502,
-             "type": 2
-        },
-        {
-             "equipmentNo": "zzj01",
-             "ipAddress": "192.168.157.60",
-             "port": 502,
-             "type": 3
-        },
-        {
-             "equipmentNo": "zzj02",
-             "ipAddress": "192.168.157.61",
-             "port": 502,
-             "type": 3
-        },
-        {
-             "equipmentNo": "lwt01",
-             "ipAddress": "192.168.157.110",
-             "port": 502,
-             "type": 4
-        },
-        {
-             "equipmentNo": "lwt02",
-             "ipAddress": "192.168.157.111",
-             "port": 502,
-             "type": 4
-        }
+
     ],
 
     "configurationUrl": "http://192.168.1.43:9433/",

+ 13 - 5
src/main/java/com/fjhx/equipment/ConfigurationUpload.java

@@ -1,6 +1,7 @@
 package com.fjhx.equipment;
 
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.io.IORuntimeException;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.cron.CronUtil;
 import cn.hutool.cron.task.Task;
@@ -107,11 +108,18 @@ public class ConfigurationUpload {
         map.put("username", configurationUsername);
         map.put("password", configurationPassword);
 
-        String dataStr = HttpRequest.post(configurationUrl + "api/v1/login")
-                .body(JSONObject.toJSONString(map))
-                .execute()
-                .body();
-        JSONObject data = JSONObject.parseObject(dataStr);
+        JSONObject data;
+        try {
+            String dataStr = HttpRequest.post(configurationUrl + "api/v1/login")
+                    .body(JSONObject.toJSONString(map))
+                    .timeout(5000)
+                    .execute()
+                    .body();
+            data = JSONObject.parseObject(dataStr);
+        } catch (IORuntimeException ioRuntimeException) {
+            MyUtil.errorLog("连接组态软件超时");
+            throw ioRuntimeException;
+        }
 
         Integer code = data.getInteger("code");
         if (code != 0) {