wangxichen 19 小时之前
父节点
当前提交
742bdf4825
共有 2 个文件被更改,包括 45 次插入30 次删除
  1. 17 7
      src/com/mes/ui/DataUtil.java
  2. 28 23
      src/com/mes/ui/MesClient.java

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

@@ -343,15 +343,20 @@ public class DataUtil {
             pro.load(br);
             String mes_server_ip = pro.getProperty("mes.server_ip");
 
-            String url = "http://" + mes_server_ip + ":8980/js/a/mes/mesProductRecord/leakpoint";
+            // 漏点通过 pcresult 接口的 ldFlag 参数提交(与 mesclient-qmzl 保持一致)
+            String url = "http://" + mes_server_ip + ":8980/js/a/mes/mesProductRecord/pcresult";
 
             String params = "__ajax=json"
-                    + "&sn=" + URLEncoder.encode(sn != null ? sn : "", "UTF-8")
-                    + "&leakPoints=" + URLEncoder.encode(leakPoints != null ? leakPoints : "", "UTF-8")
-                    + "&remark=" + URLEncoder.encode(remark != null ? remark : "", "UTF-8")
-                    + "&oprno=" + URLEncoder.encode(oprno != null ? oprno : "", "UTF-8")
-                    + "&lineSn=" + URLEncoder.encode(lineSn != null ? lineSn : "", "UTF-8")
-                    + "&workNum=" + URLEncoder.encode(ucode != null ? ucode : "", "UTF-8");
+                    + "&sn=" + formEncode(sn)
+                    + "&oprno=" + formEncode(oprno)
+                    + "&lineSn=" + formEncode(lineSn)
+                    + "&ldFlag=" + formEncode(leakPoints)
+                    + "&ucode=" + formEncode(ucode)
+                    + "&result=NG"
+                    + "&isRepair=0"
+                    + "&craft="
+                    + "&remark=" + formEncode(remark)
+                    + "&ps=";
 
             // 添加sessionid
             if (MesClient.sessionid != null && !MesClient.sessionid.isEmpty()) {
@@ -374,6 +379,11 @@ public class DataUtil {
         }
     }
 
+    // 表单参数编码,null 视为空串
+    private static String formEncode(String value) throws UnsupportedEncodingException {
+        return URLEncoder.encode(value == null ? "" : value, "UTF-8");
+    }
+
     public static String doPost(String httpUrl, String param) {
         HttpURLConnection connection = null;
         InputStream is = null;

+ 28 - 23
src/com/mes/ui/MesClient.java

@@ -1941,15 +1941,7 @@ public class MesClient extends JFrame {
             JSONObject retObj = DataUtil.qmResultData(pendingTestParam);
             if (retObj != null && retObj.get("result") != null && retObj.get("result").toString().equalsIgnoreCase("true")) {
                 // MES提交成功后打印标签
-                if (MesClient.configParam.getPrintLabel().equals("是")) {
-                    String testDate = pendingTestParam.getCreateTime();
-                    PrintUtil.printLabel(
-                        pendingTestParam.getSn(),
-                        pendingTestParam.getParam1() + pendingTestParam.getParam2(),
-                        pendingTestParam.getParam3() + pendingTestParam.getParam4(),
-                        testDate
-                    );
-                }
+                printLabelIfEnabled();
                 resetScanA();
                 setMenuStatus("测试结果上传成功,请扫下一件", 0);
             } else {
@@ -2052,26 +2044,39 @@ public class MesClient extends JFrame {
                     pendingTestParam.getUcode()
             );
 
-            if (leakRet != null && leakRet.get("result") != null && leakRet.get("result").toString().equalsIgnoreCase("true")) {
-                // 3. MES提交成功后打印标签(根据配置决定是否打印NG标签)
-                if (MesClient.configParam.getPrintLabel().equals("是")) {
-                    String testDate = pendingTestParam.getCreateTime();
-                    PrintUtil.printLabel(
-                        pendingTestParam.getSn(),
-                        pendingTestParam.getParam1() + pendingTestParam.getParam2(),
-                        pendingTestParam.getParam3() + pendingTestParam.getParam4(),
-                        testDate
-                    );
-                }
-                resetScanA();
+            boolean leakOk = leakRet != null && leakRet.get("result") != null
+                    && leakRet.get("result").toString().equalsIgnoreCase("true");
+
+            // 3. 测试结果已提交成功即打印标签,不受漏点记录结果影响
+            printLabelIfEnabled();
+            resetScanA();
+
+            if (leakOk) {
                 setMenuStatus("结果上传成功(含漏点记录),请扫下一件", 0);
             } else {
-                log.warn("漏点记录提交失败,但测试结果已提交");
-                resetScanA();
+                log.warn("漏点记录提交失败,但测试结果已提交,标签已打印");
                 setMenuStatus("测试结果已提交,漏点记录失败", 1);
             }
         } else {
             setMenuStatus("测试结果上传失败,请重试", -1);
         }
     }
+
+    /**
+     * 按配置打印标签,需在 resetScanA() 之前调用(依赖 pendingTestParam)
+     */
+    private static void printLabelIfEnabled() {
+        if (pendingTestParam == null) {
+            return;
+        }
+        if (!"是".equals(MesClient.configParam.getPrintLabel())) {
+            return;
+        }
+        PrintUtil.printLabel(
+                pendingTestParam.getSn(),
+                pendingTestParam.getParam1() + pendingTestParam.getParam2(),
+                pendingTestParam.getParam3() + pendingTestParam.getParam4(),
+                pendingTestParam.getCreateTime()
+        );
+    }
 }