|
|
@@ -2,7 +2,9 @@ package com.mes.ui;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.mes.util.Base64Utils;
|
|
|
import com.mes.util.JdbcUtils;
|
|
|
+import com.mes.util.QmParam;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
@@ -10,6 +12,7 @@ import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.MalformedURLException;
|
|
|
import java.net.URL;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Properties;
|
|
|
@@ -291,4 +294,84 @@ public class DataUtil {
|
|
|
}
|
|
|
return resp;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ // 发送气密数据
|
|
|
+ public static JSONObject sendQualityParam(String user, String sn, String oprno, String lineSn, QmParam qmParam) {
|
|
|
+ try {
|
|
|
+ String enconding = "UTF-8";
|
|
|
+ InputStream is = ClassLoader.getSystemResourceAsStream("config/config.properties");
|
|
|
+ Properties pro = new Properties();
|
|
|
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, enconding));
|
|
|
+ pro.load(br);
|
|
|
+ String mes_server_ip = pro.getProperty("mes.server_ip");
|
|
|
+ String url = "http://"+mes_server_ip+":8980/js/a/mes/mesProductRecord/qmresult";
|
|
|
+ // 根据服务器端代码,对特定参数进行Base64编码
|
|
|
+ //测试压
|
|
|
+ String testPressureBase64 = Base64Utils.getBase64(qmParam.getTestPressure() != null ? qmParam.getTestPressure() : "");
|
|
|
+ // 泄露值
|
|
|
+ String leakValBase64 = Base64Utils.getBase64(qmParam.getLeakVal() != null ? qmParam.getLeakVal() : "");
|
|
|
+ // 测试时间
|
|
|
+ String testTimeBase64 = Base64Utils.getBase64(qmParam.getCsDuration() != null ? qmParam.getCsDuration() : "");
|
|
|
+ String titleBase64 = Base64Utils.getBase64(MesClient.mes_gw_des != null ? MesClient.mes_gw_des : "");
|
|
|
+
|
|
|
+ log.info("服务器端需要Base64编码的参数: testPressure='{}'->'{}', leakVal='{}'->'{}', testTime='{}'->'{}', title='{}'->'{}'"
|
|
|
+ , qmParam.getTestPressure(), testPressureBase64, qmParam.getLeakVal(), leakValBase64
|
|
|
+ , qmParam.getCsDuration(), testTimeBase64, MesClient.mes_gw_des, titleBase64);
|
|
|
+
|
|
|
+ String params = "__ajax=json&oprno="+ URLEncoder.encode(oprno != null ? oprno : "", "UTF-8")
|
|
|
+ +"&lineSn="+URLEncoder.encode(lineSn != null ? lineSn : "", "UTF-8")
|
|
|
+ +"&sn="+URLEncoder.encode(sn != null ? sn : "", "UTF-8")
|
|
|
+ +"&workNum="+URLEncoder.encode(user != null ? user : "", "UTF-8")
|
|
|
+ +"&cxm="+URLEncoder.encode("1" != null ? "1" : "", "UTF-8")
|
|
|
+ +"&result="+URLEncoder.encode(qmParam.getTestResult() != null ? qmParam.getTestResult() : "", "UTF-8")
|
|
|
+ +"&testPressure="+URLEncoder.encode(testPressureBase64, "UTF-8")
|
|
|
+ +"&testPressureUnit="+URLEncoder.encode(qmParam.getTestPressureUnit() != null ? qmParam.getTestPressureUnit() : "", "UTF-8")
|
|
|
+ +"&leakVal="+URLEncoder.encode(leakValBase64, "UTF-8")
|
|
|
+ +"&leakValUnit="+URLEncoder.encode(qmParam.getLeakValUnit() != null ? qmParam.getLeakValUnit() : "", "UTF-8")
|
|
|
+ +"&testTime="+URLEncoder.encode(testTimeBase64, "UTF-8")
|
|
|
+ +"&title="+URLEncoder.encode(titleBase64, "UTF-8")
|
|
|
+ +"&remark="+URLEncoder.encode(qmParam.getRemark() != null ? qmParam.getRemark() : "", "UTF-8")
|
|
|
+ +"&deviceType="+URLEncoder.encode(qmParam.getDeviceType() != null ? qmParam.getDeviceType() : "", "UTF-8")
|
|
|
+ // 添加服务器端期望的参数
|
|
|
+ +"&cq="+URLEncoder.encode("", "UTF-8")
|
|
|
+ +"&by="+URLEncoder.encode("", "UTF-8")
|
|
|
+ +"&cs="+URLEncoder.encode("", "UTF-8")
|
|
|
+ +"&leakRate="+URLEncoder.encode("", "UTF-8")
|
|
|
+ +"&leakRateUnit="+URLEncoder.encode("", "UTF-8")
|
|
|
+ +"&type="+URLEncoder.encode("", "UTF-8");
|
|
|
+
|
|
|
+ // 添加sessionid
|
|
|
+// if (MesClient.sessionid != null && !MesClient.sessionid.isEmpty()) {
|
|
|
+// params += "&__sid=" + MesClient.sessionid;
|
|
|
+// }
|
|
|
+ log.info("params="+params);
|
|
|
+ String result = doPost(url,params);
|
|
|
+ log.info("result="+result);
|
|
|
+
|
|
|
+ // 检查result是否为null或空
|
|
|
+ if(result == null || result.trim().isEmpty()) {
|
|
|
+ log.error("HTTP请求返回结果为空,请检查服务器连接和参数格式");
|
|
|
+ log.info("压力值: '{}', 压力单位: '{}', 泄漏值: '{}', 泄漏单位: '{}'",
|
|
|
+ qmParam.getTestPressure(), qmParam.getTestPressureUnit(), qmParam.getLeakVal(), qmParam.getLeakValUnit());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(result.equalsIgnoreCase("false")) {
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ try {
|
|
|
+ return JSONObject.parseObject(result);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("解析JSON响应失败: {}, 原始响应: {}", e.getMessage(), result);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("发送气密数据异常: " + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|