From 4f3a98f19143865cdc1de4791e8a95d96bd40c65 Mon Sep 17 00:00:00 2001 From: maven <2163098428@qq.com> Date: 星期五, 01 八月 2025 13:27:59 +0800 Subject: [PATCH] yys 密码已重置 --- ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java | 142 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 0 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 new file mode 100644 index 0000000..ca4d3a9 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/api/IfsApiUtils.java @@ -0,0 +1,142 @@ +package com.ruoyi.common.utils.api; + +import cn.hutool.http.HttpRequest; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.ruoyi.common.core.domain.Result; +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; +import java.util.Map; + +/** + * @Author zhuo + * @Date 2024/9/29 + */ +@Slf4j +@AllArgsConstructor +@Component +public class IfsApiUtils { + + private IfsProperties ifsProperties; + + + /** + * 鏌ヨ閲囪喘璁㈠崟鏈楠� + */ + public List<Map<String, Object>> getInventory(String inAttr) { + 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); + 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 + */ + public Result getProcurementResults(String inAttr) { + return getResult("REGIST_INSPECTION_RESULTS_STD", inAttr, ifsProperties.getCustorder(), "鐧昏閲囪喘妫�楠岀粨鏋�-->"); + } + + + /** + * 鍘熸潗鏂欐楠�-妫�楠屽悗绉诲簱 + * + * @param inAttr + * @return + */ + public Result moveReceipt(String inAttr) { + return getResult("MOVE_RECEIPT_STD", inAttr, ifsProperties.getCustorder(), "妫�楠屽悗绉诲簱-->"); + } + + + /** + * 鍘熸潗鏂欐楠�-閲囪喘鎺ユ敹鏇存敼鎵瑰彿 + * + * @param inAttr + * @return + */ + public Result updateMoveReceiptLot(String inAttr) { + return getResult("MODIFY_PURCH_RECEIPT_LOT_STD", inAttr, ifsProperties.getCustorder(), "淇敼閲囪喘璁㈠崟鎵规鍙�-->"); + } + + + + /** + * 鏌ヨ搴撳瓨鏁版嵁 + * + * @param inAttr + * @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", procedureName); + stockMap.put("contract", ifsProperties.getContract()); + stockMap.put("contractKey", ifsProperties.getContractKeyPost()); + stockMap.put("userId", "lims_user"); + stockMap.put("inAttr", inAttr); + 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); + 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()); + } + } + + /** + * 鑾峰彇娣诲姞璇锋眰淇℃伅 + * @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