From e50a43bb067adff10cd1dcc81349b1aafdfda882 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期四, 22 一月 2026 13:18:44 +0800
Subject: [PATCH] 业务管理:IFS域区分【ZTNS】和【KJNS】
---
ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java | 180 +++++++++++++++++++++++++++--------------------------------
1 files changed, 82 insertions(+), 98 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java
index 81bed96..a5736cc 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java
@@ -6,12 +6,15 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.ruoyi.common.config.ifs.IfsConfig;
import com.ruoyi.common.core.domain.Result;
-import com.ruoyi.common.config.IfsProperties;
+import com.ruoyi.common.config.ifs.IfsProperties;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -24,64 +27,46 @@
@Component
public class IfsApiUtils {
- private IfsProperties ifsProperties;
+ private IfsConfig ifsConfig;
+ public IfsProperties getPropByContract(String contract){
+ return ifsConfig.getProps().stream().filter(f-> StringUtils.equals(contract,f.getContract())).findFirst().orElse(new IfsProperties());
+ }
/**
* 鏌ヨ閲囪喘璁㈠崟鏈楠�
*/
- private String getStock(String inAttr) {
- return ifsProperties.getCustorderPort() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=QUERY_POL_RECEIPT_STD&userId=lims_user&inAttr=" + inAttr;
+ public List<Map<String, Object>> getInventory(Map<String,Object> inAttrMap) {
+ List<Map<String, Object>> maps = new ArrayList<>();
+ ifsConfig.getProps().forEach(ifsProp->{
+ String procedureName = "QUERY_POL_RECEIPT_STD";
+ inAttrMap.put("LOCATION_NO",ifsProp.getTobeInspectedLocation());
+ String inAttr = JSONUtil.toJsonStr(inAttrMap);
+ JSONObject stockMap = getJsonObject(procedureName, inAttr,ifsProp.getContract(),ifsProp.getContractKeyPost());
+ String body = HttpRequest.post(ifsProp.getCustorderPort()).form(stockMap).execute().body();
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ Map map = objectMapper.readValue(body, Map.class);
+ maps.addAll(objectMapper.readValue(JSONUtil.toJsonStr(map.get("LIST_INFO")), new TypeReference<List<Map<String, Object>>>() {
+ }));
+ log.info("鑾峰彇閲囪喘璁㈠崟-->>" + maps);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ });
+ return maps;
}
- public List<Map<String, Object>> getInventory(String inAttr) {
- String body = HttpRequest.get(getStock(inAttr)).execute().body();
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- Map map = objectMapper.readValue(body, Map.class);
- List<Map<String, Object>> maps = objectMapper.readValue(JSONUtil.toJsonStr(map.get("LIST_INFO")), new TypeReference<List<Map<String, Object>>>() {
- });
- log.info("鑾峰彇閲囪喘璁㈠崟-->>" + maps);
- return maps;
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
+
/**
* 鐧昏閲囪喘妫�楠岀粨鏋淪TD
*/
- private String ProcurementResultsURL(String inAttr) {
- return ifsProperties.getCustorder() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=REGIST_INSPECTION_RESULTS_STD&userId=lims_user&inAttr=" + inAttr;
+ public Result getProcurementResults(String contract,String inAttr) {
+ return getResult(contract,"REGIST_INSPECTION_RESULTS_STD", inAttr, "GET", "鐧昏閲囪喘妫�楠岀粨鏋�-->");
}
- public Result getProcurementResults(String inAttr) {
- String body = HttpRequest.get(ProcurementResultsURL(inAttr)).execute().body();
- log.info("鐧昏閲囪喘妫�楠岀粨鏋�-->" + body);
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- Map map = objectMapper.readValue(body, Map.class);
- String successFlag = map.get("SuccessFlag").toString();
- if (Integer.valueOf(successFlag) == 1) {
- return Result.success(map);
- } else {
- return Result.fail(map.get("ErrorMsg").toString());
- }
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- return Result.fail(e.getMessage());
- }
- }
-
-
- /**
- * 妫�楠屽悗绉诲簱
- */
- private String getMoveReceiptApi(String inAttr) {
-
- return ifsProperties.getCustorder() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=MOVE_RECEIPT_STD&userId=lims_user&inAttr=" + inAttr;
- }
/**
* 鍘熸潗鏂欐楠�-妫�楠屽悗绉诲簱
@@ -89,64 +74,22 @@
* @param inAttr
* @return
*/
- public Result moveReceipt(String inAttr) {
- String body = HttpRequest.get(getMoveReceiptApi(inAttr)).execute().body();
- log.info("妫�楠屽悗绉诲簱-->" + body);
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- Map map = objectMapper.readValue(body, Map.class);
- String successFlag = map.get("SuccessFlag").toString();
- if (Integer.valueOf(successFlag) == 1) {
- return Result.success(map);
- } else {
- return Result.fail(map.get("ErrorMsg").toString());
- }
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- return Result.fail(e.getMessage());
- }
+ public Result moveReceipt(String contract,String inAttr) {
+ return getResult(contract,"MOVE_RECEIPT_STD", inAttr, "GET", "妫�楠屽悗绉诲簱-->");
}
- /**
- * 閲囪喘鎺ユ敹鏇存敼鎵瑰彿
- */
- private String getMoveReceiptLotApi(String inAttr) {
-
- return ifsProperties.getCustorder() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=MODIFY_PURCH_RECEIPT_LOT_STD&userId=lims_user&inAttr=" + inAttr;
- }
/**
- * 鍘熸潗鏂欐楠�-妫�楠屽悗绉诲簱
+ * 鍘熸潗鏂欐楠�-閲囪喘鎺ユ敹鏇存敼鎵瑰彿
*
* @param inAttr
* @return
*/
- public Result updateMoveReceiptLot(String inAttr) {
- String body = HttpRequest.get(getMoveReceiptLotApi(inAttr)).execute().body();
- log.info("淇敼閲囪喘璁㈠崟鎵规鍙�-->" + body);
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- Map map = objectMapper.readValue(body, Map.class);
- String successFlag = map.get("SuccessFlag").toString();
- if (Integer.valueOf(successFlag) == 1) {
- return Result.success(map);
- } else {
- return Result.fail(map.get("ErrorMsg").toString());
- }
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- return Result.fail(e.getMessage());
- }
+ public Result updateMoveReceiptLot(String contract,String inAttr) {
+ return getResult(contract,"MODIFY_PURCH_RECEIPT_LOT_STD", inAttr, "GET", "淇敼閲囪喘璁㈠崟鎵规鍙�-->");
}
- /**
- * 鏌ヨ搴撳瓨鏁版嵁
- */
- private String getIfsStockApi(String inAttr) {
-
- return ifsProperties.getCustorderPort() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=QUERY_INVENTORY_INFO_STD&userId=lims_user&inAttr=" + inAttr;
- }
/**
* 鏌ヨ搴撳瓨鏁版嵁
@@ -154,15 +97,40 @@
* @param inAttr
* @return
*/
- public Result getIfsStock(String inAttr) {
+ public Result getIfsStock(String contract,String inAttr) {
+ return getResult(contract,"QUERY_INVENTORY_INFO_STD", inAttr, "POST", "鏌ヨ搴撳瓨淇℃伅-->");
+ }
+
+ /**
+ * 搴撳瓨鐗╂枡鎵规灞炴�ф柊澧炰慨鏀规帴鍙�
+ *
+ * @param inAttr
+ * @return
+ */
+ public Result importPartLotAttr(String contract,String inAttr) {
+ return getResult(contract,"IMPORT_PART_LOT_ATTR_STD", inAttr, "GET", "搴撳瓨鐗╂枡鎵规灞炴�ф柊澧炰慨鏀规帴鍙�-->");
+ }
+
+ /**
+ * 閫氱敤鎺ュ彛
+ * @param contract IFS鍩�
+ * @param procedureName 鏂规硶鍚�
+ * @param inAttr 浼犲弬
+ * @param urlType 璇锋眰绫诲瀷锛圙ET/POST锛�
+ * @param image 娑堟伅
+ * @return
+ */
+ private Result<?> getResult(String contract,String procedureName, String inAttr, String urlType, String image) {
+ IfsProperties ifsProperties = getPropByContract(contract);
JSONObject stockMap = new JSONObject();
- stockMap.put("procedureName", "QUERY_INVENTORY_INFO_STD");
+ stockMap.put("procedureName", procedureName);
stockMap.put("contract", ifsProperties.getContract());
stockMap.put("contractKey", ifsProperties.getContractKeyPost());
- stockMap.put("userId", "userId");
+ stockMap.put("userId", "lims_user");
stockMap.put("inAttr", inAttr);
- String body = HttpRequest.post(ifsProperties.getCustorderPort()).form(stockMap).execute().body();
- log.info("鏌ヨ搴撳瓨淇℃伅-->" + body);
+ String url = StringUtils.equals("GET",urlType)?ifsProperties.getCustorder():ifsProperties.getCustorderPort();
+ String body = HttpRequest.post(url).form(stockMap).execute().body();
+ log.info(image + body);
ObjectMapper objectMapper = new ObjectMapper();
try {
Map map = objectMapper.readValue(body, Map.class);
@@ -177,4 +145,20 @@
return Result.fail(e.getMessage());
}
}
+
+ /**
+ * 鑾峰彇娣诲姞璇锋眰淇℃伅
+ * @param procedureName 缁撴瀯鍚嶇О
+ * @param inAttr 璇锋眰鍙傛暟
+ * @return
+ */
+ private JSONObject getJsonObject(String procedureName, String inAttr,String contract,String contractKeyPost) {
+ JSONObject stockMap = new JSONObject();
+ stockMap.put("procedureName", procedureName);
+ stockMap.put("contract", contract);
+ stockMap.put("contractKey", contractKeyPost);
+ stockMap.put("userId", "lims_user");
+ stockMap.put("inAttr", inAttr);
+ return stockMap;
+ }
}
--
Gitblit v1.9.3