Parcourir la source

12-31 领耀仓库数据对接至美的接口

shenliang il y a 3 ans
Parent
commit
cd9b1584d5

+ 13 - 6
src/main/java/com/uas/eis/serviceImpl/InsertServiceImpl.java

@@ -83,7 +83,11 @@ public class InsertServiceImpl implements InsertService {
         //A0001309
         //LYDF@890cdopBD
         Map<String, Object> dataMaps = new HashMap<>();
-        List<Map<String,Object>> list = baseDao.queryForList(" select to_char(sysdate,'yyyyMMdd')||UUID_SEQ.nextval UUID,pc_custprodcode,pc_mdname_user,qty from prodmdedi_view left join mdkc_vies on pc_prodcode=ba_prodcode");
+        List<Map<String,Object>> list = baseDao.queryForList("select to_char(sysdate,'yyyy-MM-dd hh24:mi:ss') transactionDate,to_char(sysdate,'yyyyMMdd')||UUID_SEQ.nextval UUID, AA.* from ( select pc_custprodcode,pc_mdname_user,nvl(sum(qty),0) qty " +
+                "from prodmdedi_view " +
+                "left join mdkc_vies on pc_prodcode=ba_prodcode " +
+                "where nvl(qty,0)<>0" +
+                "group by  pc_custprodcode,pc_mdname_user ) AA ");
 
         //timestamp	是	long	当前时间戳	当前时间戳
         long timestamp = System.currentTimeMillis();
@@ -101,7 +105,7 @@ public class InsertServiceImpl implements InsertService {
         for (int z = 0; z < list.size(); z++) {
             Map<String, Object> data = new HashMap<>();
             //??sourceId	是	String	供方系统数据id	数据唯一标识,每个供应商每个id数据只允许推送一次,重复会返回有重复数据(建议用uuid,可以百度uuid)
-            data.put("sourceId",list.get(z).get("pc_custprodcode").toString());
+            data.put("sourceId",list.get(z).get("UUID").toString());
             //-demandItemCode	是	String	美的物料编码	美的物料编码必须要有数据 //客户物料编码
             data.put("demandItemCode",list.get(z).get("pc_custprodcode").toString());
             //-organizationCode	是	String	库存组织编码	美的系统库存组织代码,比如:M01
@@ -111,7 +115,8 @@ public class InsertServiceImpl implements InsertService {
             //-supplyItemCode	否	String	供方物料编码	供方系统的物料编码
             //-itemDescription	否	String	物料描述	物料描述
             //-transactionDate	否	String	交易时间	如果为空,系统默认为当前时间
-            data.put("transactionDate",list.get(z).get("pc_custprodcode").toString());
+//            data.put("transactionDate",Long.parseLong(list.get(z).get("UUID").toString()));
+            data.put("transactionDate",list.get(z).get("transactionDate").toString());
             //-reference	否	String	备注信息	备注信息
             //-sourceBill	否	String	来源单据
             datas.add(data);
@@ -120,8 +125,10 @@ public class InsertServiceImpl implements InsertService {
 //正式接口https://gsc.midea.com/gscapp/supplierInventoryInterface/doImport
 
         try {
-            Response response = HttpUtil.doPost("https://gscuat.midea.com/gscapp/supplierInventoryInterface/doImport",
-                    JSON.toJSONString(dataMaps), false, "NoSign");
+          //  System.setProperty("https.protocols", "TLSv1.2,TLSv1.1,SSLv3");
+            String Jsondata = JSON.toJSONString(dataMaps);
+            Response response = HttpUtil.doPostWithHead("https://gsc.midea.com/gscapp/supplierInventoryInterface/doImport",
+                    Jsondata, false, "NoSign");
             String responseText = response.getResponseText();
             com.alibaba.fastjson.JSONObject parseObject = JSONArray.parseObject(responseText);
             String responseCode = parseObject.getString("code");
@@ -132,7 +139,7 @@ public class InsertServiceImpl implements InsertService {
 //                onInquiryDetailUploadSuccess(ids);
 //            } else
 
-        } catch (Exception e) {
+        }catch (Exception e) {
             baseDao.execute("insert into " +
                     "messagelog (ML_ID, ML_DATE, ML_MAN, ML_CONTENT, ML_RESULT) values " +
                     "(messagelog_seq.nextval,to_char(sysdate,'yyyy-MM-dd hh24:mm:mi'),'超级管理员',"+timestamp+",'对接美的失败')");

+ 49 - 2
src/main/java/com/uas/eis/utils/HttpUtil.java

@@ -46,6 +46,7 @@ import org.apache.http.config.RegistryBuilder;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.apache.http.conn.socket.PlainConnectionSocketFactory;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.entity.mime.MultipartEntityBuilder;
@@ -79,7 +80,7 @@ public class HttpUtil {
 	 * @throws KeyManagementException  
 	 */  
 	public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {  
-	    SSLContext sc = SSLContext.getInstance("SSLv3");  
+	    SSLContext sc = SSLContext.getInstance("SSL");
 	  
 	    // 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法  
 	    X509TrustManager trustManager = new X509TrustManager() {  
@@ -101,7 +102,7 @@ public class HttpUtil {
 	        }  
 	    };  
 	  
-	    sc.init(null, new TrustManager[] { trustManager }, null);  
+	    sc.init(null, new TrustManager[] { trustManager }, null);
 	    return sc;  
 	}  
 
@@ -222,6 +223,51 @@ public class HttpUtil {
 		return sendRequest(RequestMethod.POST, url, header, params, sign, null);
 	}
 
+	/**
+	 * 发起http请求
+	 *
+	 * @param method
+	 *            请求方法POST、PUT
+	 * @param url
+	 *            请求链接
+	 * @param datas
+	 *            参数
+	 * @param sign
+	 *            是否签名
+	 * @return
+	 * @throws Exception
+	 */
+	public static Response doPostWithHead(String postUrl, String formData,  boolean sign, String signKey) throws Exception {
+		//采用绕过验证的方式处理https请求
+		SSLContext sslcontext = createIgnoreVerifySSL();
+		//try{
+			SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+		//}catch (Exception e){
+
+		//}
+
+		// 设置协议http和https对应的处理socket链接工厂的对象
+		Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
+				.register("http", PlainConnectionSocketFactory.INSTANCE)
+				.register("https",sslsf)
+				.build();
+		PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
+		HttpClients.custom().setConnectionManager(connManager);
+
+		//创建自定义的httpclient对象
+		CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connManager).build();
+		//CloseableHttpClient httpClient = HttpClients.createDefault();
+		//postUrl = getUrl(postUrl, sign, signKey);
+		HttpPost post = new HttpPost(postUrl);
+		StringEntity postingString = new StringEntity(formData, HTTP.UTF_8);
+		post.setEntity(postingString);
+		post.setHeader("Content-type", "application/json");
+//		post.setHeader("Authorization",authorization);
+		CloseableHttpResponse response = httpClient.execute(post);
+		return Response.getResponse(response);
+	}
+
+
 	/**
 	 * 发送POST请求
 	 * 
@@ -256,6 +302,7 @@ public class HttpUtil {
         post.setEntity(postingString);
         post.setHeader("Content-type", "application/json");
         CloseableHttpResponse response = httpClient.execute(post);
+
         return Response.getResponse(response);
     }
 	

+ 1 - 1
src/main/resources/application-dev.yml

@@ -3,7 +3,7 @@ spring:
     datasource:
         type: org.apache.tomcat.jdbc.pool.DataSource
         driverClassName: oracle.jdbc.OracleDriver
-        username: lydf
+        username: LYDF
         password: select!#%*(
         url: jdbc:oracle:thin:@usoft.f3322.net:11637:orcl
     http:

+ 1 - 1
src/main/resources/application-prod.yml

@@ -3,7 +3,7 @@ spring:
     datasource:
         type: com.alibaba.druid.pool.DruidDataSource
         driverClassName: oracle.jdbc.OracleDriver
-        username: lydf
+        username: LYDF
         password: select!#%*(
         url: jdbc:oracle:thin:@usoft.f3322.net:11637:orcl
     #              url: jdbc:oracle:thin:@127.0.0.1:1521:orcl