hou 2 недель назад
Родитель
Сommit
0b6511bdf8

+ 17 - 0
src/com/mes/ui/DataUtil.java

@@ -361,6 +361,7 @@ public class DataUtil {
     }
 
     public static String doPost(String httpUrl, String param) {
+        httpUrl = appendSid(httpUrl);
         HttpURLConnection connection = null;
         InputStream is = null;
         OutputStream os = null;
@@ -463,4 +464,20 @@ public class DataUtil {
             return null;
         }
     }
+
+    private static String appendSid(String url) {
+        if (url == null || url.contains("__sid=") || url.contains("/login")) {
+            return url;
+        }
+        try {
+            String sid = MesClient.sessionid;
+            if (sid == null || sid.length() == 0) {
+                return url;
+            }
+            return url + (url.contains("?") ? "&" : "?") + "__sid=" + sid;
+        } catch (Exception e) {
+            return url;
+        }
+    }
+
 }

+ 3 - 0
src/com/mes/ui/LoginFarme.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
 import com.mes.component.MesRadio;
 import com.mes.component.MesWebView;
 import com.mes.component.MyDialog;
+import com.mes.util.ClientUpgrade;
 import com.mes.util.Base64Utils;
 import com.mes.util.HttpUtils;
 
@@ -92,6 +93,7 @@ public class LoginFarme extends JFrame {
 
     //登录
     public static void login() {
+        ClientUpgrade.checkIfConfigured(MesClient.welcomeWin);
         String user_str = userNameTxt.getText().toString();
         String password_str = userPasswordTxt.getText().toString();
         if(user_str.equalsIgnoreCase("")||password_str.equalsIgnoreCase("")) {
@@ -121,6 +123,7 @@ public class LoginFarme extends JFrame {
     }
     //扫码登录
     public static void scanLogin() {
+        ClientUpgrade.checkIfConfigured(MesClient.welcomeWin);
         //userNameTxt.setText("");
         //userPasswordTxt.setText("");
         String scanContent = JOptionPane.showInputDialog(null, "请扫码工牌二维码");

+ 20 - 0
src/com/mes/ui/MesClient.java

@@ -12,6 +12,8 @@ import com.mes.component.ProductTypePanel;
 import com.mes.component.MesWebView;
 import com.mes.component.MyDialog;
 import com.mes.netty.NettyClient;
+import com.mes.util.ClientVersionUtils;
+import com.mes.util.ClientUpgrade;
 import com.mes.util.ConfigUtil;
 import com.mes.util.DateLocalUtils;
 import com.mes.util.HttpUtils;
@@ -58,6 +60,7 @@ public class MesClient extends JFrame {
     public static int mes_heart_beat_cycle = 10;
     public static int mes_heart_icon_cycle = 1;
     public static String mes_line_sn = "";
+    public static String client_version = "0.0.0"; // 打包发布版本,需和后台 JAR 管理版本号对齐
     public static String mes_gwflag = ""; // 工位标识
 
     public static NettyClient nettyClient;
@@ -196,12 +199,20 @@ public class MesClient extends JFrame {
 
 
     public static void main(String[] args) {
+        if (ClientUpgrade.handleInstallArgs(args)) {
+            return;
+        }
         EventQueue.invokeLater(new Runnable() {
             @Override
             public void run() {
                 try{
                     //鐠囩粯鏋冩禒鍫曞帳缂冿拷
                     readProperty();
+                    if (ClientUpgrade.recoverIncompleteInstall()) {
+                        return;
+                    }
+                    ClientUpgrade.cleanupInstallLeftovers();
+                    ClientUpgrade.checkIfConfigured(null);
 
                     // 閺勫墽銇氶悾宀勬桨
                     mesClientFrame = new MesClient();
@@ -323,10 +334,19 @@ public class MesClient extends JFrame {
     }
 
     //鐠囧鍘ょ純顔芥瀮娴狅拷
+
+    private static String parseClientVersion(String value) {
+        if (value == null || value.trim().isEmpty()) {
+            return "0.0.0";
+        }
+        return ClientVersionUtils.normalize(value.trim());
+    }
+
     private static void readProperty() throws IOException{
         Properties pro = ConfigUtil.loadProperties();
         ConfigUtil.printStartupInfo();
         mes_gw =  pro.getProperty("mes.gw");
+        client_version = parseClientVersion(pro.getProperty("mes.client.version"));
 
 //        mes_gw_des = pro.getProperty("mes.gw_des");
         mes_server_ip = pro.getProperty("mes.server_ip");

Разница между файлами не показана из-за своего большого размера
+ 1091 - 0
src/com/mes/util/ClientUpgrade.java


+ 75 - 0
src/com/mes/util/ClientVersionUtils.java

@@ -0,0 +1,75 @@
+package com.mes.util;
+
+/**
+ * 客户端版本号比较,格式 0.0.0 / 0.0.1。
+ * 没有点的旧数字(如 1)按 0.0.1 处理。
+ */
+public final class ClientVersionUtils {
+
+    private ClientVersionUtils() {
+    }
+
+    public static int compare(String left, String right) {
+        int[] a = parse(left);
+        int[] b = parse(right);
+        int n = Math.max(a.length, b.length);
+        for (int i = 0; i < n; i++) {
+            int va = i < a.length ? a[i] : 0;
+            int vb = i < b.length ? b[i] : 0;
+            if (va != vb) {
+                return va < vb ? -1 : 1;
+            }
+        }
+        return 0;
+    }
+
+    public static boolean isNewer(String latest, String current) {
+        return compare(latest, current) > 0;
+    }
+
+    public static String max(String left, String right) {
+        if (isBlank(left)) {
+            return normalize(right);
+        }
+        if (isBlank(right)) {
+            return normalize(left);
+        }
+        return compare(left, right) >= 0 ? normalize(left) : normalize(right);
+    }
+
+    public static String normalize(String version) {
+        if (isBlank(version)) {
+            return "0.0.0";
+        }
+        int[] parts = parse(version);
+        return parts[0] + "." + parts[1] + "." + parts[2];
+    }
+
+    private static int[] parse(String version) {
+        int[] result = new int[] {0, 0, 0};
+        if (isBlank(version)) {
+            return result;
+        }
+        String[] parts = version.trim().split("\\.");
+        if (parts.length == 1) {
+            result[2] = parseInt(parts[0]);
+            return result;
+        }
+        for (int i = 0; i < parts.length && i < 3; i++) {
+            result[i] = parseInt(parts[i]);
+        }
+        return result;
+    }
+
+    private static int parseInt(String value) {
+        try {
+            return Integer.parseInt(value.trim());
+        } catch (Exception e) {
+            return 0;
+        }
+    }
+
+    private static boolean isBlank(String value) {
+        return value == null || value.trim().length() == 0;
+    }
+}

+ 21 - 0
src/com/mes/util/HttpUtils.java

@@ -1,5 +1,7 @@
 package com.mes.util;
 
+import com.mes.ui.MesClient;
+
 import java.io.*;
 import java.net.HttpURLConnection;
 import java.net.URISyntaxException;
@@ -13,6 +15,7 @@ public class HttpUtils {
 	 */
     //http post请求
     public static String sendRequest(String urlParam) {
+        urlParam = appendSid(urlParam);
 		String requestType = "POST";
         //根据接收内容返回数据结果
     	String ret = "";
@@ -66,6 +69,7 @@ public class HttpUtils {
 
 
     public static String sendPostRequest(String urlParam, String params) {
+        urlParam = appendSid(urlParam);
         String requestType = "POST";
         //根据接收内容返回数据结果
         String ret = "";
@@ -124,6 +128,7 @@ public class HttpUtils {
     }
 
     public static String sendPostRequestJson(String apiUrl, String jsonData) throws IOException {
+        apiUrl = appendSid(apiUrl);
         URL url = new URL(apiUrl);
         HttpURLConnection conn = (HttpURLConnection) url.openConnection();
         conn.setRequestMethod("POST");
@@ -189,4 +194,20 @@ public class HttpUtils {
 
 	
 
+
+    private static String appendSid(String url) {
+        if (url == null || url.contains("__sid=") || url.contains("/login")) {
+            return url;
+        }
+        try {
+            String sid = MesClient.sessionid;
+            if (sid == null || sid.length() == 0) {
+                return url;
+            }
+            return url + (url.contains("?") ? "&" : "?") + "__sid=" + sid;
+        } catch (Exception e) {
+            return url;
+        }
+    }
+
 }

+ 135 - 176
src/com/mes/util/IweldCloudUtilTest.java

@@ -6,11 +6,19 @@ import com.alibaba.fastjson2.JSONObject;
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.util.LinkedHashMap;
+import java.util.Map;
 import java.util.Properties;
 
 public class IweldCloudUtilTest {
 
     private static final long API_INTERVAL_MS = IweldCloudUtil.API_MIN_INTERVAL_MS;
+    /** 说明书:prodCode=0 返回全部设备 */
+    private static final String ALL_DEVICES_PROD_CODE = "0";
+    private static final String ROBOT_RUN_INFO_URL =
+            "https://api.iweldcloud.com/ApiServer/rest/WeldWebService/getRobotRunInfo";
+    private static final String WELDER_RUN_INFO_URL =
+            "https://api.iweldcloud.com/ApiServer/rest/WeldWebService/getWeldRunInfo";
 
     public static void main(String[] args) {
         System.out.println("========== IweldCloud 逻辑测试开始 ==========");
@@ -35,100 +43,148 @@ public class IweldCloudUtilTest {
 
             System.out.println("--- 2. 测试 getWeldListInfo(设备列表) ---");
             String weldListInfo = IweldCloudUtil.fetchWeldListInfo();
+            Map<String, JSONObject> deviceIndex = new LinkedHashMap<String, JSONObject>();
             if (weldListInfo == null) {
                 System.out.println("getWeldListInfo结果: 失败");
             } else {
                 System.out.println("getWeldListInfo结果: 成功");
                 System.out.println("接口状态: " + IweldCloudUtil.describeApiStatus(weldListInfo));
-                printDeviceList(weldListInfo, pro);
+                deviceIndex = printDeviceList(weldListInfo, pro);
             }
             System.out.println();
 
             sleepBetweenRequests();
 
-            System.out.println("--- 3. 测试实时数据接口 ---");
-            String prodCode = pro.getProperty("iweld.prodCode", "0").trim();
-            Boolean fetchOk = IweldCloudUtil.fetchRobotRunInfo();
-            String runInfo = IweldCloudUtil.getRobotRunInfo();
-            System.out.println("prodCode=" + prodCode + " 拉取结果: " + (fetchOk ? "成功" : "失败"));
-            if (fetchOk && runInfo != null && !runInfo.isEmpty()) {
-                System.out.println("接口状态: " + IweldCloudUtil.describeApiStatus(runInfo));
-            } else {
-                System.out.println("接口状态: 响应为空");
-                runInfo = tryAlternateRunInfoApi(pro, prodCode);
-            }
-            System.out.println("原始数据:");
-            System.out.println(runInfo);
-            System.out.println();
+            System.out.println("--- 3. 机器人实时数据 getRobotRunInfo(prodCode=0 全部设备) ---");
+            String robotRunInfo = fetchAllRunInfo(ROBOT_RUN_INFO_URL);
+            printAllRunInfo(robotRunInfo, deviceIndex, "robot");
 
-            if (runInfo != null && !runInfo.isEmpty()) {
-                try {
-                    JSONObject json = JSONObject.parseObject(runInfo);
-                    System.out.println("格式化JSON:");
-                    System.out.println(json.toJSONString());
-                } catch (Exception e) {
-                    System.out.println("响应不是有效JSON");
-                }
-            }
+            sleepBetweenRequests();
+
+            System.out.println("--- 4. 焊机实时数据 getWeldRunInfo(prodCode=0 全部设备) ---");
+            String welderRunInfo = fetchAllRunInfo(WELDER_RUN_INFO_URL);
+            printAllRunInfo(welderRunInfo, deviceIndex, "welder");
+        } catch (Exception e) {
+            System.out.println("测试异常: " + e.getMessage());
+            e.printStackTrace();
+        }
+
+        System.out.println();
+        System.out.println("========== IweldCloud 逻辑测试结束 ==========");
+    }
+
+    private static String fetchAllRunInfo(String baseUrl) {
+        String response = IweldCloudUtil.fetchRunInfoForProdCodeWithUrl(ALL_DEVICES_PROD_CODE, baseUrl);
+        System.out.println("prodCode=" + ALL_DEVICES_PROD_CODE + " 拉取结果: "
+                + (response != null ? "成功" : "失败"));
+        if (response == null) {
+            System.out.println("接口状态: 响应为空");
+            return null;
+        }
+        System.out.println("接口状态: " + IweldCloudUtil.describeApiStatus(response));
+        return response;
+    }
+
+    private static void printAllRunInfo(String runInfo, Map<String, JSONObject> deviceIndex, String apiType) {
+        if (runInfo == null || runInfo.isEmpty()) {
+            System.out.println("无实时数据");
             System.out.println();
+            return;
+        }
 
-            System.out.println("--- 4. 测试参数解析(prodCode) ---");
-            IweldCloudUtil.WelderParams[] welders = IweldCloudUtil.parseWelderParamsFromResponse(runInfo);
-            printWelderParams("焊机1(prodCode=" + prodCode + ")", welders, 0);
+        System.out.println("原始数据:");
+        System.out.println(runInfo);
+        System.out.println();
 
-            String prodCode2 = pro.getProperty("iweld.prodCode2", "").trim();
-            if (!prodCode2.isEmpty()) {
-                sleepBetweenRequests();
+        try {
+            JSONObject json = JSONObject.parseObject(runInfo);
+            System.out.println("格式化JSON:");
+            System.out.println(json.toJSONString());
+            System.out.println();
+
+            JSONArray items = flattenDataItems(json.getJSONArray("dataList"));
+            System.out.println("实时记录条数: " + items.size());
+            for (int i = 0; i < items.size(); i++) {
+                JSONObject item = items.getJSONObject(i);
+                String code = readDeviceCode(item);
+                JSONObject listDevice = deviceIndex.get(code);
+                String name = listDevice != null ? listDevice.getString("D03") : "";
+                String type = listDevice != null ? deviceTypeName(listDevice.getString("D04")) : apiType;
                 System.out.println();
-                System.out.println("--- 5. 测试参数解析(prodCode2) ---");
-                String runInfo2 = IweldCloudUtil.fetchRunInfoForProdCode(prodCode2);
-                System.out.println("prodCode2=" + prodCode2 + " 拉取结果: "
-                        + (runInfo2 != null ? "成功" : "失败"));
-                if (runInfo2 != null) {
-                    System.out.println("接口状态: " + IweldCloudUtil.describeApiStatus(runInfo2));
-                    System.out.println("原始数据:");
-                    System.out.println(runInfo2);
-                    printProgramNameDebug(runInfo2);
-                }
-                // 再试焊机实时接口,对比云平台“在线”是否来自另一套状态
-                sleepBetweenRequests();
-                String welderUrl = "https://api.iweldcloud.com/ApiServer/rest/WeldWebService/getWeldRunInfo";
-                String runInfo2Welder = IweldCloudUtil.fetchRunInfoForProdCodeWithUrl(prodCode2, welderUrl);
-                System.out.println("prodCode2 走 getWeldRunInfo: "
-                        + (runInfo2Welder != null ? "成功" : "失败/无效"));
-                if (runInfo2Welder != null) {
-                    System.out.println("焊机接口原始数据:");
-                    System.out.println(runInfo2Welder);
-                    printProgramNameDebug(runInfo2Welder);
+                System.out.println("[" + (i + 1) + "] 编码=" + (code.isEmpty() ? "(无)" : code)
+                        + ", 名称=" + (name == null || name.isEmpty() ? "(无)" : name)
+                        + ", 类型=" + type);
+                printItemFields(item);
+                IweldCloudUtil.WelderParams params = parseSingleItem(item);
+                if (params != null && params.hasData()) {
+                    System.out.println("  解析参数: " + params);
                 }
-                IweldCloudUtil.WelderParams[] welders2 = IweldCloudUtil.parseWelderParamsFromResponse(runInfo2);
-                printWelderParams("焊机2(prodCode2=" + prodCode2 + ")", welders2, 0);
+            }
+        } catch (Exception e) {
+            System.out.println("解析实时数据失败: " + e.getMessage());
+        }
+        System.out.println();
+    }
 
-                if (welders != null && welders2 != null && welders2[0].hasData()) {
-                    welders[1] = welders2[0];
+    private static JSONArray flattenDataItems(JSONArray dataList) {
+        JSONArray items = new JSONArray();
+        if (dataList == null) {
+            return items;
+        }
+        for (int i = 0; i < dataList.size(); i++) {
+            JSONObject wrapper = dataList.getJSONObject(i);
+            JSONArray nested = wrapper.getJSONArray("list");
+            if (nested != null && !nested.isEmpty()) {
+                for (int j = 0; j < nested.size(); j++) {
+                    items.add(nested.getJSONObject(j));
                 }
-                System.out.println();
-                System.out.println("合并后双焊机参数:");
-                printWelderParams("焊机1", welders, 0);
-                printWelderParams("焊机2", welders, 1);
             } else {
-                printWelderParams("焊机2(dataList第2条)", welders, 1);
+                items.add(wrapper);
             }
-        } catch (Exception e) {
-            System.out.println("测试异常: " + e.getMessage());
-            e.printStackTrace();
         }
+        return items;
+    }
 
-        System.out.println();
-        System.out.println("========== IweldCloud 逻辑测试结束 ==========");
+    private static String readDeviceCode(JSONObject item) {
+        if (item == null) {
+            return "";
+        }
+        String code = item.getString("prodCode");
+        if (code != null && !code.isEmpty()) {
+            return code;
+        }
+        code = item.getString("D01");
+        return code != null ? code : "";
+    }
+
+    private static void printItemFields(JSONObject item) {
+        if (item == null) {
+            return;
+        }
+        for (String key : item.keySet()) {
+            System.out.println("  " + key + "=" + item.get(key));
+        }
+    }
+
+    private static IweldCloudUtil.WelderParams parseSingleItem(JSONObject item) {
+        JSONObject wrapper = new JSONObject();
+        JSONArray dataList = new JSONArray();
+        dataList.add(item);
+        wrapper.put("dataList", dataList);
+        IweldCloudUtil.WelderParams[] welders = IweldCloudUtil.parseWelderParamsFromResponse(wrapper.toJSONString());
+        if (welders == null || welders.length == 0) {
+            return null;
+        }
+        return welders[0];
     }
 
     private static void printConfig(Properties pro) {
         System.out.println("accessKey: " + mask(pro.getProperty("iweld.accessKey", "")));
         System.out.println("loginUrl: " + pro.getProperty("iweld.login.url"));
         System.out.println("device.type: " + pro.getProperty("iweld.device.type", "robot"));
-        System.out.println("prodCode: " + pro.getProperty("iweld.prodCode", "0"));
-        System.out.println("prodCode2: " + pro.getProperty("iweld.prodCode2", "(未配置)"));
+        System.out.println("prodCode(配置): " + pro.getProperty("iweld.prodCode", "0"));
+        System.out.println("prodCode2(配置): " + pro.getProperty("iweld.prodCode2", "(未配置)"));
+        System.out.println("本次实时查询: prodCode=" + ALL_DEVICES_PROD_CODE + "(全部设备)");
         String runInfoUrl = pro.getProperty("iweld.run.info.url", "").trim();
         if (runInfoUrl.isEmpty()) {
             runInfoUrl = pro.getProperty("iweld.robot.run.info.url", "(默认getRobotRunInfo)");
@@ -136,40 +192,20 @@ public class IweldCloudUtilTest {
         System.out.println("runInfoUrl: " + runInfoUrl);
     }
 
-    private static String tryAlternateRunInfoApi(Properties pro, String prodCode) {
-        String currentType = pro.getProperty("iweld.device.type", "robot").trim();
-        String alternateType = "robot".equalsIgnoreCase(currentType) ? "welder" : "robot";
-        System.out.println();
-        System.out.println("提示: 当前接口拉取失败,尝试备用接口(" + alternateType + ")...");
-        sleepBetweenRequests();
-        String alternateUrl = "welder".equalsIgnoreCase(alternateType)
-                ? "https://api.iweldcloud.com/ApiServer/rest/WeldWebService/getWeldRunInfo"
-                : "https://api.iweldcloud.com/ApiServer/rest/WeldWebService/getRobotRunInfo";
-        String response = IweldCloudUtil.fetchRunInfoForProdCodeWithUrl(prodCode, alternateUrl);
-        if (response != null) {
-            System.out.println("备用接口拉取成功,建议将 iweld.device.type 改为 " + alternateType);
-            System.out.println("或设置 iweld.run.info.url=" + alternateUrl);
-            System.out.println("接口状态: " + IweldCloudUtil.describeApiStatus(response));
-            return response;
-        }
-        System.out.println("备用接口也失败,请检查 prodCode 是否正确、设备是否在线");
-        return null;
-    }
-
-    private static void printDeviceList(String weldListInfo, Properties pro) {
+    private static Map<String, JSONObject> printDeviceList(String weldListInfo, Properties pro) {
+        Map<String, JSONObject> deviceIndex = new LinkedHashMap<String, JSONObject>();
         try {
             JSONObject json = JSONObject.parseObject(weldListInfo);
             JSONArray dataList = json.getJSONArray("dataList");
             if (dataList == null || dataList.isEmpty()) {
                 System.out.println("设备列表为空");
-                return;
+                return deviceIndex;
             }
 
             String prodCode = pro.getProperty("iweld.prodCode", "").trim();
             String prodCode2 = pro.getProperty("iweld.prodCode2", "").trim();
             int totalDevices = 0;
-            boolean matched = false;
-            System.out.println("当前配置设备在列表中的类型:");
+            System.out.println("账号下全部设备(D01=制造编码, D03=自定义名称, D04=类型):");
             for (int i = 0; i < dataList.size(); i++) {
                 JSONObject block = dataList.getJSONObject(i);
                 JSONArray list = block.getJSONArray("list");
@@ -180,47 +216,22 @@ public class IweldCloudUtilTest {
                 for (int j = 0; j < list.size(); j++) {
                     JSONObject device = list.getJSONObject(j);
                     String code = device.getString("D01");
-                    if (code == null) {
-                        continue;
-                    }
-                    if (code.equals(prodCode) || code.equals(prodCode2)) {
-                        matched = true;
-                        System.out.println("  " + code + " -> 完整字段: " + device.toJSONString());
-                        System.out.println("     D03=" + device.getString("D03")
-                                + ", D04=" + device.getString("D04")
-                                + " (" + deviceTypeName(device.getString("D04")) + ")"
-                                + ", 常见在线字段: D02=" + device.get("D02")
-                                + ", D05=" + device.get("D05")
-                                + ", D06=" + device.get("D06")
-                                + ", D07=" + device.get("D07")
-                                + ", status=" + device.get("status")
-                                + ", online=" + device.get("online")
-                                + ", runStatus=" + device.get("runStatus"));
+                    if (code != null && !code.isEmpty()) {
+                        deviceIndex.put(code, device);
                     }
+                    boolean configured = code != null && (code.equals(prodCode) || code.equals(prodCode2));
+                    System.out.println("  D01=" + code
+                            + ", D03=" + device.getString("D03")
+                            + ", D04=" + device.getString("D04")
+                            + " (" + deviceTypeName(device.getString("D04")) + ")"
+                            + (configured ? "  [当前配置]" : ""));
                 }
             }
             System.out.println("设备总数: " + totalDevices);
-            if (!matched) {
-                System.out.println("未在设备列表中找到 prodCode/prodCode2,请核对配置编码");
-                System.out.println("账号下全部设备(D01=制造编码, D03=自定义名称, D04=类型):");
-                for (int i = 0; i < dataList.size(); i++) {
-                    JSONObject block = dataList.getJSONObject(i);
-                    JSONArray list = block.getJSONArray("list");
-                    if (list == null) {
-                        continue;
-                    }
-                    for (int j = 0; j < list.size(); j++) {
-                        JSONObject device = list.getJSONObject(j);
-                        System.out.println("  D01=" + device.getString("D01")
-                                + ", D03=" + device.getString("D03")
-                                + ", D04=" + device.getString("D04")
-                                + " (" + deviceTypeName(device.getString("D04")) + ")");
-                    }
-                }
-            }
         } catch (Exception e) {
             System.out.println("解析设备列表失败: " + e.getMessage());
         }
+        return deviceIndex;
     }
 
     private static String deviceTypeName(String d04) {
@@ -236,58 +247,6 @@ public class IweldCloudUtilTest {
         return "未知";
     }
 
-    private static void printWelderParams(String label, IweldCloudUtil.WelderParams[] welders, int index) {
-        if (welders == null || welders.length <= index) {
-            System.out.println(label + ": 无数据");
-            return;
-        }
-        IweldCloudUtil.WelderParams params = welders[index];
-        if (!params.hasData()) {
-            System.out.println(label + ": 未解析到电压/电流/送丝速度(请检查接口类型与字段映射)");
-            return;
-        }
-        System.out.println(label + ": " + params);
-        if (!params.programName.isEmpty()) {
-            System.out.println(label + " 程序名: " + params.programName);
-        }
-    }
-
-    /** 打印原始 JSON 中 programName 相关字段,便于对比两台设备差异 */
-    private static void printProgramNameDebug(String response) {
-        try {
-            JSONObject json = JSONObject.parseObject(response);
-            JSONArray dataList = json.getJSONArray("dataList");
-            if (dataList == null || dataList.isEmpty()) {
-                System.out.println("programName调试: dataList 为空");
-                return;
-            }
-            JSONObject first = dataList.getJSONObject(0);
-            JSONArray nested = first.getJSONArray("list");
-            JSONObject item = (nested != null && !nested.isEmpty()) ? nested.getJSONObject(0) : first;
-            System.out.println("programName调试: containsKey=" + item.containsKey("programName")
-                    + ", raw=" + item.get("programName")
-                    + ", runStatue=" + item.get("runStatue")
-                    + ", currentStatus=" + item.get("currentStatus")
-                    + ", positionNam=" + item.get("positionNam")
-                    + ", keys含program=" + keysContaining(item, "program"));
-        } catch (Exception e) {
-            System.out.println("programName调试失败: " + e.getMessage());
-        }
-    }
-
-    private static String keysContaining(JSONObject item, String keyword) {
-        StringBuilder sb = new StringBuilder();
-        for (String key : item.keySet()) {
-            if (key != null && key.toLowerCase().contains(keyword.toLowerCase())) {
-                if (sb.length() > 0) {
-                    sb.append(", ");
-                }
-                sb.append(key).append("=").append(item.get(key));
-            }
-        }
-        return sb.length() == 0 ? "(无)" : sb.toString();
-    }
-
     private static void sleepBetweenRequests() {
         try {
             Thread.sleep(API_INTERVAL_MS);

+ 3 - 0
src/resources/config/config.properties

@@ -23,3 +23,6 @@ iweld.prodCode2=2026S0084
 # 实时数据接口地址(留空则按 iweld.device.type 自动选择)
 #iweld.run.info.url=
 iweld.robot.run.info.url=https://api.iweldcloud.com/ApiServer/rest/WeldWebService/getRobotRunInfo
+# 打包发布时改成和后台「JAR管理」里填的版本号一致(或更大),格式 0.0.0。
+# 每次打包切记去后台查看对应子工位最新版本,打包时版本号+1
+mes.client.version=0.0.0