From e6e5a67f94513e90da40cc28f21d0d2c6d9cbe7d Mon Sep 17 00:00:00 2001 From: zhuo <2089219845@qq.com> Date: 星期二, 15 四月 2025 17:34:01 +0800 Subject: [PATCH] 修改ifs对接方法 --- ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java | 124 ++++++++++++++--------------------------- 1 files changed, 43 insertions(+), 81 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..ca4d3a9 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 @@ -10,6 +10,7 @@ import com.ruoyi.common.config.IfsProperties; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Component; import java.util.List; @@ -30,12 +31,10 @@ /** * 鏌ヨ閲囪喘璁㈠崟鏈楠� */ - 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(String inAttr) { - String body = HttpRequest.get(getStock(inAttr)).execute().body(); + String procedureName = "QUERY_POL_RECEIPT_STD"; + JSONObject stockMap = getJsonObject(procedureName, inAttr); + String body = HttpRequest.post(ifsProperties.getCustorderPort()).form(stockMap).execute().body(); ObjectMapper objectMapper = new ObjectMapper(); try { Map map = objectMapper.readValue(body, Map.class); @@ -49,39 +48,15 @@ } } + + /** * 鐧昏閲囪喘妫�楠岀粨鏋淪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 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()); - } + return getResult("REGIST_INSPECTION_RESULTS_STD", inAttr, ifsProperties.getCustorder(), "鐧昏閲囪喘妫�楠岀粨鏋�-->"); } - - /** - * 妫�楠屽悗绉诲簱 - */ - private String getMoveReceiptApi(String inAttr) { - - return ifsProperties.getCustorder() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=MOVE_RECEIPT_STD&userId=lims_user&inAttr=" + inAttr; - } /** * 鍘熸潗鏂欐楠�-妫�楠屽悗绉诲簱 @@ -90,63 +65,21 @@ * @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()); - } + return getResult("MOVE_RECEIPT_STD", inAttr, ifsProperties.getCustorder(), "妫�楠屽悗绉诲簱-->"); } - /** - * 閲囪喘鎺ユ敹鏇存敼鎵瑰彿 - */ - 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()); - } + return getResult("MODIFY_PURCH_RECEIPT_LOT_STD", inAttr, ifsProperties.getCustorder(), "淇敼閲囪喘璁㈠崟鎵规鍙�-->"); } - /** - * 鏌ヨ搴撳瓨鏁版嵁 - */ - private String getIfsStockApi(String inAttr) { - - return ifsProperties.getCustorderPort() + "contract=" + ifsProperties.getContract() + "&contractKey=" + ifsProperties.getContractKeyGet() + "&procedureName=QUERY_INVENTORY_INFO_STD&userId=lims_user&inAttr=" + inAttr; - } /** * 鏌ヨ搴撳瓨鏁版嵁 @@ -155,14 +88,27 @@ * @return */ public Result getIfsStock(String inAttr) { + return getResult("QUERY_INVENTORY_INFO_STD", inAttr, ifsProperties.getCustorderPort(), "鏌ヨ搴撳瓨淇℃伅-->"); + } + + + /** + * 閫氱敤鎺ュ彛 + * @param procedureName 鏂规硶鍚� + * @param inAttr 浼犲弬 + * @param url 鍦板潃 + * @param image 娑堟伅 + * @return + */ + private Result<?> getResult(String procedureName, String inAttr, String url, String image) { 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 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 +123,20 @@ return Result.fail(e.getMessage()); } } + + /** + * 鑾峰彇娣诲姞璇锋眰淇℃伅 + * @param procedureName 缁撴瀯鍚嶇О + * @param inAttr 璇锋眰鍙傛暟 + * @return + */ + private JSONObject getJsonObject(String procedureName, String inAttr) { + JSONObject stockMap = new JSONObject(); + stockMap.put("procedureName", procedureName); + stockMap.put("contract", ifsProperties.getContract()); + stockMap.put("contractKey", ifsProperties.getContractKeyPost()); + stockMap.put("userId", "lims_user"); + stockMap.put("inAttr", inAttr); + return stockMap; + } } -- Gitblit v1.9.3