| 
					
				 | 
			
			
				@@ -2,6 +2,7 @@ package com.kmall.admin.haikong.client; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.core.date.DateUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.config.HaiKongProperties; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.kmall.admin.haikong.constant.HaiKongWareSystemUrlEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.dto.Criteria; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.dto.WareQueryStockParamDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.kmall.admin.haikong.utils.OkHttpUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -37,9 +38,40 @@ public class HaiKongWarehouseTemplate { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param wareQueryStockParamDTO 请求数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return  响应数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public String queryWarehouseStock(WareQueryStockParamDTO wareQueryStockParamDTO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        haiKongProperties.getWareUrl(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public String queryWarehouseStock(WareQueryStockParamDTO wareQueryStockParamDTO) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String xmlStr = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            xmlStr = XmlUtils.toXml(wareQueryStockParamDTO, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.error("请求一步达仓库系统格式化请求数据错误!", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new Exception(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String url = haiKongProperties.getWareUrl() + "?method=" + HaiKongWareSystemUrlEnum.QUERY_INVENTORY.getDomain() + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "&format=xml" + "&sign_method=md5" + "&customerId=" + haiKongProperties.getWareCustomerId() + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "×tamp=" + DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss") + 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                "&app_key=" + haiKongProperties.getWareAppId() + "&v=1.0"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String signUrl = WareSysSignUtils.getSignRequest(url, xmlStr, "GREE1001"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Request.Builder builder = new Request.Builder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RequestBody requestBody = RequestBody.create(MediaType.parse(org.springframework.http.MediaType.TEXT_XML_VALUE), xmlStr); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String response = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Request request = builder.post(requestBody) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .url(signUrl) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .build(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            response = OkHttpUtils.retry(request, 3); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("请求一步达仓库系统查询库存成功!响应:{}", response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.error("请求一步达仓库系统出现错误!", e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new Exception(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return response; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |