From 47c5a4d4bce0b76aa582980e9450b03c53b7b051 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 25 Oct 2022 13:25:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=AC=E6=9C=BA=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/tools/utils/api/yt/YantaiApi.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/api/yt/YantaiApi.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/api/yt/YantaiApi.java index 95a54779b0..8cf49c6410 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/api/yt/YantaiApi.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/api/yt/YantaiApi.java @@ -50,6 +50,49 @@ public class YantaiApi { */ //private static final String SSO_BACKGROUND_SERVER_URL = "http://120.220.248.247:8081/"; + /** + * desc:根据组织id获取本级组织信息 + * + * @param organizationId + * @return + */ + public static OrgData getOuInfoByOuGuid(String organizationId) { + try { + if (StringUtils.isBlank(organizationId)) { + throw new EpmetException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); + } + //加密 + String organizationIdEn = SM4UtilsForYanTai.dealEncryptData(organizationId); + //pwd = URLEncoder.encode(pwd, "UTF-8"); + String url = SSO_BACKGROUND_SERVER_URL + "person/ouinfo/getOuInfoByOuGuid"; + + Map paramMap = new HashMap<>(); + paramMap.put("organizationId",organizationIdEn); + + log.info("getOuInfoByOuGuid request param:{} url:{}",paramMap, url); + Result result = HttpClientManager.getInstance().sendGet(url, paramMap, getApiHeaderMap()); + log.info("getOuInfoByOuGuid request result:{}", result); + if (!result.success()){ + return new OrgData(); + } + JSONObject jsonObject = JSONObject.parseObject(result.getData()); + String secondCode = jsonObject.getString("code"); + String secondMessage = jsonObject.getString("message"); + if (!"200".equals(secondCode)) { + log.warn("getOuInfoByOuGuid 接口错误"); + return new OrgData(); + } + //解密 + String data = SM4UtilsForYanTai.dealDecryptData(jsonObject.getString("data")); + OrgData orgData = JSON.parseObject(data, OrgData.class); + log.info("getChildOuInfoByGuid request real result:{}", JSON.toJSONString(orgData)); + return orgData; + } catch (Exception e) { + log.error("getChildOuInfoByGuid exception", e); + } + return new OrgData(); + } + /** * desc:根据组织id获取下级组织 * @@ -245,6 +288,8 @@ public class YantaiApi { //getLoginToken("0d554bccfbac4be3846d643252daf92b"); String organizationId = "44e05de9-34fa-48f6-b89f-02838d792cf9"; + OrgData ouInfoByOuGuid = getOuInfoByOuGuid(organizationId); + System.out.println("ouInfoByOuGuid:"+JSON.toJSONString(ouInfoByOuGuid)); List childOuInfoByGuid = getChildOuInfoByGuid(organizationId); System.out.println("childOuInfoByGuid:"+JSON.toJSONString(childOuInfoByGuid)); //先用他说的有人的组织id联调