Browse Source

【华信科】【富勒WMS对接】【新增测试环境】

wuyx 6 tháng trước cách đây
mục cha
commit
ebf2b42e72

+ 65 - 0
src/main/java/com/uas/eis/config/VwmsConfig.java

@@ -9,6 +9,8 @@ import org.springframework.context.annotation.PropertySource;
 @PropertySource("classpath:vwms.properties")
 @Data
 public class VwmsConfig {
+    private String ev;
+
     @Value("${api_url}")
     private String apiUrl;
 
@@ -29,4 +31,67 @@ public class VwmsConfig {
 
     @Value("${ownerCode}")
     private String ownerCode;
+
+    @Value("${api_url_test}")
+    private String apiUrlTest;
+    @Value("${app_key_test}")
+    private String appKeyTest;
+    @Value("${app_secret_test}")
+    private String appSecretTest;
+    @Value("${customerId_test}")
+    private String customerIdTest;
+    @Value("${ownerCode_test}")
+    private String ownerCodeTest;
+    @Value("${vwms.warehouse.code_test}")
+    private String warehouseCodeTest;
+
+    public String getEv() {
+        return ev;
+    }
+
+    public void setEv(String ev) {
+        this.ev = ev;
+    }
+    public String getApiUrl() {
+        if("test".equals(getEv())){
+            return apiUrlTest;
+        }else {
+            return apiUrl;
+        }
+    }
+    public String getAppKey() {
+        if("test".equals(getEv())){
+            return appKeyTest;
+        }else {
+            return appKey;
+        }
+    }
+    public String getAppSecret() {
+        if("test".equals(getEv())){
+            return appSecretTest;
+        }else {
+            return appSecret;
+        }
+    }
+    public String getCustomerId() {
+        if("test".equals(getEv())){
+            return customerIdTest;
+        }else {
+            return customerId;
+        }
+    }
+    public String getOwnerCode() {
+        if("test".equals(getEv())){
+            return ownerCodeTest;
+        }else {
+            return ownerCode;
+        }
+    }
+    public String getWarehouseCode() {
+        if("test".equals(getEv())){
+            return warehouseCodeTest;
+        }else {
+            return warehouseCode;
+        }
+    }
 }

+ 1 - 0
src/main/java/com/uas/eis/service/DocCommonService.java

@@ -12,6 +12,7 @@ import java.util.Map;
  * @date 2025-03-04
  */
 public interface DocCommonService {
+    public String getMasterEv(String master);
     ProdInout getIO(String master,String id,boolean onlyMain);
     String sendOMoveToWms(ProdInout prodInOut, String masterName);
     String sendOutToWms(ProdInout prodInOut, String masterName);

+ 8 - 0
src/main/java/com/uas/eis/service/Impl/DocCommonServiceImpl.java

@@ -40,6 +40,14 @@ public class DocCommonServiceImpl implements DocCommonService {
     @Autowired
     private ObjectMapper objectMapper;  // 注入Jackson的ObjectMapper
 
+    @Override
+    public String getMasterEv(String master){
+        if(baseDao.checkIf("DATACENTER_P.master","ma_user = '"+master+"' and ma_function like '%测试%' ")){
+            return "test";
+        }else {
+            return "prod";
+        }
+    }
     @Override
     public ProdInout getIO(String master,String id,boolean onlyMain){
         // 查询主表信息

+ 6 - 0
src/main/java/com/uas/eis/service/Impl/ERPServiceImpl.java

@@ -110,6 +110,7 @@ public class ERPServiceImpl implements ERPService {
             retMap.put("message","没有需要同步的商品(品牌需设置对接MWS)。");
             return retMap;
         }
+        vwmsConfig.setEv(docCommonService.getMasterEv(master));
         String outBizCode = "sendProd-"+System.currentTimeMillis();
         for (Map<String, Object> map : list) {
             // 创建ProductReq对象
@@ -342,6 +343,7 @@ public class ERPServiceImpl implements ERPService {
             retMap.put("message","没有需要同步的商品(品牌需设置对接MWS)。");
             return retMap;
         }
+        vwmsConfig.setEv(docCommonService.getMasterEv(master));
         String outBizCode = "sendVend-"+System.currentTimeMillis();
         for (Vendor vend : list) {
             // 创建Req对象
@@ -576,6 +578,7 @@ public class ERPServiceImpl implements ERPService {
             retMap.put("message","没有需要同步的客户。");
             return retMap;
         }
+        vwmsConfig.setEv(docCommonService.getMasterEv(master));
         String outBizCode = "sendCust-"+System.currentTimeMillis();
         for (Customer cust : list) {
             // 创建Req对象
@@ -742,6 +745,7 @@ public class ERPServiceImpl implements ERPService {
             retMap.put("message","WMS单据类型为空或异常,不允许同步。");
             return retMap;
         }
+        vwmsConfig.setEv(docCommonService.getMasterEv(master));
         //构建请求主体
         String masterName = prodInOut.getCurrentMasterName();
         Long piId = prodInOut.getPiId();
@@ -793,6 +797,7 @@ public class ERPServiceImpl implements ERPService {
             retMap.put("message","单据已确认采集,不允许取消。");
             return retMap;
         }
+        vwmsConfig.setEv(docCommonService.getMasterEv(master));
         Long piId = prodInOut.getPiId();
         BaseReq<OrderVastRequest<OrderCancel>> req = new BaseReq();
         OrderVastRequest<OrderCancel> cancelReq = new OrderVastRequest();
@@ -857,6 +862,7 @@ public class ERPServiceImpl implements ERPService {
                 new BeanPropertyRowMapper<>(StockData.class));
         String dataNo = "";
         if(!CollectionUtil.isEmpty(stockDataList)){
+            vwmsConfig.setEv(docCommonService.getMasterEv(master));
             // 每1000条分批处理
             int batchSize = 1000;
             int totalSize = stockDataList.size();

+ 3 - 0
src/main/java/com/uas/eis/utils/HttpUtil.java

@@ -987,6 +987,9 @@ public class HttpUtil {
 				.append("&v=2.0")
 				.append("&_signature=").append(HmacUtils.encode(signMsg, vwmsConfig.getAppSecret()))	// 对请求串进行签名
 				.append("&sign_method=md5").append("&customerId=").append(vwmsConfig.getCustomerId());
+//		System.out.println("postUrl:"+postUrl.toString());
+//		System.out.println("postingString:"+formData.toString());
+//		postUrl = new StringBuilder();
 		HttpPost post = new HttpPost(postUrl.toString());
 		StringEntity postingString = new StringEntity(formData, HTTP.UTF_8);
 		post.setEntity(postingString);

+ 13 - 0
src/main/resources/vwms.properties

@@ -17,6 +17,19 @@ app_key=HXK0225
 customerId=HXK
 vwms.warehouse.code=LH01
 ownerCode=HXK
+#?????????http://113.108.118.106:8443/c1.2/openapi
+#format?json
+#app_key?HXKTEST250605
+#sign?7FEF9247E3A4C94F0E01D2C72ED56EB7
+#sign_method?md5
+#customerId?HXKTEST
+
+api_url_test=http://113.108.118.106:8443/c1.2/openapi
+app_key_test=HXKTEST250605
+app_secret_test=7FEF9247E3A4C94F0E01D2C72ED56EB7
+customerId_test=HXKTEST
+ownerCode_test=HXKTEST
+vwms.warehouse.code_test=HXKTEST
 
 
 

+ 22 - 3
src/test/java/com/uas/eis/UasEisApplicationTests.java

@@ -40,6 +40,25 @@ public class UasEisApplicationTests {
 	private ERPService erpService;
 	@Autowired
 	private VwmsConfig vwmsConfig;
+	@Test
+	public void testSendProdByEv(){
+		// 设置测试数据
+		String master = "DATACENTER";
+		Map<String, Object> result = new HashMap<>();
+		String id = "100072167";
+		String emCode = "ADMIN";
+		String caller = "Product";
+		result = erpService.sendProd(master, id, emCode,caller);
+
+		//客户资料
+		/*String id = "86362";
+		String emCode = "ADMIN";
+		String caller = "Customer!Base";
+		Map<String, Object> result = erpService.sendCust(master, id, emCode,caller);*/
+		System.out.println("result:"+result.toString());
+	}
+
+
 	@Test
 	public void testSendCustError(){
 		// 设置测试数据
@@ -67,12 +86,12 @@ public class UasEisApplicationTests {
 
 
 	@Test
-	public void testSendTH(){
+	public void testSendIO(){
 		// 设置测试数据
 		String master = "HUAXK_P";
-		String id = "50791640";
+		String id = "50791841";
 		String emCode = "E0161";
-		String caller = "ProdInOut!SaleReturn";
+		String caller = "ProdInOut!PurcCheckin";
 		Map<String, Object> result = erpService.sendIO(master, id, emCode,caller);
 		System.out.println("result:"+result.toString());
 	}