From 83e0034ab5f729afeb2c25e328d63fda31ff01e1 Mon Sep 17 00:00:00 2001
From: dbs <email0099@163.com>
Date: 星期四, 12 十二月 2024 15:45:57 +0800
Subject: [PATCH] 新增MES处理,分发系统名字特定---》MES系统
---
src/main/java/com/itstyle/mdm/utils/MdmApiUtils.java | 73 ++++++++++++++++++++++++++++++++++++
1 files changed, 73 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/itstyle/mdm/utils/MdmApiUtils.java b/src/main/java/com/itstyle/mdm/utils/MdmApiUtils.java
index b3527ae..db3840e 100644
--- a/src/main/java/com/itstyle/mdm/utils/MdmApiUtils.java
+++ b/src/main/java/com/itstyle/mdm/utils/MdmApiUtils.java
@@ -1,5 +1,7 @@
package com.itstyle.mdm.utils;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
import com.itstyle.mdm.entity.HttpClientResult;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
@@ -154,6 +156,77 @@
}
}
+ public static String getMesJson(String json){
+ JSONObject mesResJson=new JSONObject();
+ JSONObject jsonobj=JSONObject.parseObject(json);
+ JSONArray jsonArray = jsonobj.getJSONArray("records");
+ JSONArray mesResDetail=new JSONArray();
+ for(int i=0;i<jsonArray.size();i++){
+ JSONObject rowObject = jsonArray.getJSONObject(i);
+ JSONObject tmp1=new JSONObject();
+ tmp1.put("Tgcoriginalcode",rowObject.getString("tgctwoclasscode"));
+ JSONObject tmp2=new JSONObject();
+ tmp2.put("Code",rowObject.getString("code"));
+ JSONObject tmp3=new JSONObject();
+ tmp3.put("Name",rowObject.getString("name"));
+ JSONObject tmp4=new JSONObject();
+ tmp4.put("Specification",rowObject.getString("specification"));
+ JSONObject tmp5=new JSONObject();
+ tmp5.put("UnitName",rowObject.getString("unitName"));
+ JSONObject tmp6=new JSONObject();
+ tmp6.put("TypeCode",rowObject.getString("typeCode"));
+ JSONObject tmp7=new JSONObject();
+ tmp7.put("SpecificationDisplayName",rowObject.getString("specificationDisplayName"));
+ JSONObject tmp8=new JSONObject();
+ tmp8.put("SupplierName",rowObject.getString("supplierName"));
+ mesResDetail.add(tmp1);
+ mesResDetail.add(tmp2);
+ mesResDetail.add(tmp3);
+ mesResDetail.add(tmp4);
+ mesResDetail.add(tmp5);
+ mesResDetail.add(tmp6);
+ mesResDetail.add(tmp7);
+ mesResDetail.add(tmp8);
+ }
+ mesResJson.put("Records",mesResDetail);
+ return mesResJson.toJSONString();
+ }
+ public static String getMesSoapBody(String json){
+ return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
+ "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">\n" +
+ " <soap12:Body>\n" +
+ " <ReceiveTCG xmlns=\"http://www.hitachi.com/HITPHAMS\">\n" +
+ " <JsonStr><![CDATA["+json+"]]></JsonStr>\n" +
+ " </ReceiveTCG>\n" +
+ " </soap12:Body>\n" +
+ "</soap12:Envelope>";
+ }
+ public static HttpClientResult doPostXmlJson(String url, String xmlStr) throws Exception{
+ // 鍒涘缓httpClient瀵硅薄
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+
+ //绗簩姝ワ細鍒涘缓httpPost瀵硅薄
+ HttpPost httpPost = new HttpPost(url);
+ RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(CONNECT_TIMEOUT).setSocketTimeout(SOCKET_TIMEOUT).build();
+ httpPost.setConfig(requestConfig);
+ //绗笁姝ワ細缁檋ttpPost璁剧疆JSON鏍煎紡鐨勫弬鏁�
+ StringEntity requestEntity = new StringEntity(xmlStr,"utf-8");
+ requestEntity.setContentEncoding("UTF-8");
+ httpPost.setHeader("Content-type", "application/soap+xml; charset=utf-8");
+ httpPost.setEntity(requestEntity);
+
+ // 鍒涘缓httpResponse瀵硅薄
+ CloseableHttpResponse httpResponse = null;
+
+ try {
+ // 鎵ц璇锋眰骞惰幏寰楀搷搴旂粨鏋�
+ return getHttpClientResult(httpResponse, httpClient, httpPost);
+ } finally {
+ // 閲婃斁璧勬簮
+ release(httpResponse, httpClient);
+ }
+ }
+
/**
* Description: 鑾峰緱鍝嶅簲缁撴灉
*
--
Gitblit v1.8.0