|
|
@@ -329,6 +329,42 @@ public class DataUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据客户码查询钢印码
|
|
|
+ * @param customerSn 客户码
|
|
|
+ * @return 钢印码,查询失败返回 null
|
|
|
+ */
|
|
|
+ public static String getSteelSn(String customerSn) {
|
|
|
+ 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/mesProductLaser/getSteelSn";
|
|
|
+ String params = "__ajax=json&customerSn="+customerSn;
|
|
|
+ System.out.println("[查询钢印码] customerSn=" + customerSn);
|
|
|
+ String result = doPost(url, params);
|
|
|
+ System.out.println("[查询钢印码] result=" + result);
|
|
|
+
|
|
|
+ if (result == null || result.equalsIgnoreCase("false") || result.trim().isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ JSONObject jsonResult = JSONObject.parseObject(result);
|
|
|
+ if (jsonResult != null && jsonResult.containsKey("steelSn")) {
|
|
|
+ String steelSn = jsonResult.getString("steelSn");
|
|
|
+ System.out.println("[查询钢印码] steelSn=" + steelSn);
|
|
|
+ return steelSn;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.err.println("[查询钢印码] 异常: " + e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static String doPost(String httpUrl, String param) {
|
|
|
HttpURLConnection connection = null;
|
|
|
InputStream is = null;
|