From b56bed065a3ce1339f5717c96e39920621a17b19 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 25 Oct 2022 12:03:03 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=BB=84=E7=BB=87ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java index 7179573098..f7af284abc 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java @@ -80,16 +80,15 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService for (UserData u : data) { CustomerStaffInfoDTOCache staffInfo = CustomerStaffRedis.getStaffInfoByMobile(customerId, u.getMobileTelephoneNumber()); DataSyncUserDataEntity entity = ConvertUtils.sourceToTarget(u, DataSyncUserDataEntity.class); + entity.setOrganizationId(org.getOrganizationId()); entity.setCustomerId(customerId); entity.setRemark(""); if (null == staffInfo){ entity.setStatus(NumConstant.ZERO_STR); - entity.setOrganizationId(""); entity.setStaffId(""); }else { CustomerStaffInfoCacheResult staffInfo1 = CustomerStaffRedis.getStaffInfo(customerId, staffInfo.getUserId()); entity.setStatus(NumConstant.ONE_STR); - entity.setOrganizationId(null == staffInfo1 ? "" : staffInfo1.getAgencyId()); entity.setStaffId(staffInfo.getUserId()); } needInsert.add(entity); From 47c5a4d4bce0b76aa582980e9450b03c53b7b051 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 25 Oct 2022 13:25:02 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=AC=E6=9C=BA?= =?UTF-8?q?=E7=BB=84=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联调 From e7adc2f69ee3b082de1ade9b9be51c6d4a406e93 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 25 Oct 2022 14:24:12 +0800 Subject: [PATCH 3/6] MOBILE_TELEPHONE_NUMBER --- .../src/main/resources/mapper/yantai/DataSyncUserDataDao.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/yantai/DataSyncUserDataDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/yantai/DataSyncUserDataDao.xml index 8e7241fcd4..c989699e9f 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/yantai/DataSyncUserDataDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/yantai/DataSyncUserDataDao.xml @@ -37,7 +37,7 @@ else o.ORGANIZATIO_NABBREVIATION end)as orgName, u.USER_NAME AS userName, - u.TELEPHONE_NUMBER AS telephoneNumber, + u.MOBILE_TELEPHONE_NUMBER AS telephoneNumber, u.GENDER AS gender, u.`STATUS` AS status, IFNULL(u.STAFF_ID,'') AS staffId, From f1824bf0abd103589321a5e90e90f2d72d044786 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 25 Oct 2022 14:30:42 +0800 Subject: [PATCH 4/6] emm --- .../commons/tools/utils/api/yt/OrgData.java | 13 ++++++ .../yantai/DataSyncUserAndOrgServiceImpl.java | 41 +++++++++++++++---- .../epmet/dao/yantai/DataSyncOrgDataDao.java | 2 + .../epmet/dao/yantai/DataSyncUserDataDao.java | 3 ++ .../epmet/service/DataSyncOrgDataService.java | 2 + .../service/DataSyncUserDataService.java | 2 + .../impl/DataSyncOrgDataServiceImpl.java | 6 +++ .../impl/DataSyncUserDataServiceImpl.java | 5 +++ .../db/migration/V0.0.18__yt_alter_sync.sql | 1 + .../mapper/yantai/DataSyncOrgDataDao.xml | 6 +++ .../mapper/yantai/DataSyncUserDataDao.xml | 6 +++ 11 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.18__yt_alter_sync.sql diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/api/yt/OrgData.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/api/yt/OrgData.java index 6c7ea48907..b5b7e96e09 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/api/yt/OrgData.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/api/yt/OrgData.java @@ -74,6 +74,19 @@ public class OrgData implements Serializable { */ private String unifiedSocialCreditId; + /** + * 上级ID + */ + private String pid; + /** + * orgId全路径 + */ + private String pids; + + /** + * 上级组织名 + */ + private String parentOrgName; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java index f7af284abc..5f2ae5c4fc 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java @@ -63,6 +63,11 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService @Override public Boolean yanTaiSyncUser(String organizationId) { String customerId = YT_CUSTOMER_ID; + // 先删除 旧数据 + Integer delSize = NumConstant.ZERO; + do { + delSize = dataSyncUserDataService.deleteByCustomerId(customerId); + }while (delSize == NumConstant.ONE_THOUSAND); // 缓存初始化staffs epmetUserOpenFeignClient.allCustomerStaffInCache(customerId); Integer no = NumConstant.ONE; @@ -106,19 +111,34 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService @Override public Boolean yanTaiSyncOrg(String organizationId) { + // 先删除 旧数据 + Integer delSize = NumConstant.ZERO; + do { + delSize = dataSyncOrgDataService.deleteByCustomerId(YT_CUSTOMER_ID); + }while (delSize == NumConstant.ONE_THOUSAND); + List needInsert = new ArrayList<>(); + // 根组织 + OrgData rootOrg = YantaiApi.getOuInfoByOuGuid(organizationId); + if (null == rootOrg){ + log.error("未查询到根组织:"+organizationId); + return true; + } + rootOrg.setPid(""); + rootOrg.setPids(""); + rootOrg.setNameOfOrganization(""); + needInsert.add(rootOrg); List data = YantaiApi.getChildOuInfoByGuid(organizationId); if (CollectionUtils.isNotEmpty(data)){ - List needInsert = new ArrayList<>(); data.forEach(d -> { + d.setPid(organizationId); + d.setPids(organizationId.concat(":").concat(d.getOrganizationId())); + d.setNameOfOrganization(rootOrg.getNameOfOrganization()); needInsert.add(d); - disposeYanTaiSyncOrg(d.getOrganizationId(),needInsert); + disposeYanTaiSyncOrg(d,needInsert); }); List entities = needInsert.stream().map(m -> { DataSyncOrgDataEntity entity = ConvertUtils.sourceToTarget(m, DataSyncOrgDataEntity.class); entity.setCustomerId(YT_CUSTOMER_ID); - entity.setPid(""); - entity.setParentOrgName(""); - entity.setPids(""); return entity; }).collect(Collectors.toList()); dataSyncOrgDataService.insertBatch(entities, NumConstant.ONE_HUNDRED); @@ -126,12 +146,15 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService return false; } - public void disposeYanTaiSyncOrg(String organizationId, List needInsert){ - List data = YantaiApi.getChildOuInfoByGuid(organizationId); + public void disposeYanTaiSyncOrg(OrgData orgData, List needInsert){ + List data = YantaiApi.getChildOuInfoByGuid(orgData.getOrganizationId()); if (CollectionUtils.isNotEmpty(data)){ - needInsert.addAll(data); data.forEach(d -> { - disposeYanTaiSyncOrg(d.getOrganizationId(),needInsert); + d.setPid(orgData.getOrganizationId()); + d.setPids(orgData.getPids().concat(":").concat(d.getOrganizationId())); + d.setNameOfOrganization(orgData.getNameOfOrganization()); + needInsert.add(d); + disposeYanTaiSyncOrg(d,needInsert); }); } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncOrgDataDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncOrgDataDao.java index b0b0529b62..b9f2a0eca4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncOrgDataDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncOrgDataDao.java @@ -24,4 +24,6 @@ public interface DataSyncOrgDataDao extends BaseDao { List queryList(@Param("pid") String pid); List getAllList(@Param("customerId") String customerId); + + Integer deleteByCustomerId(@Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncUserDataDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncUserDataDao.java index f1bc42e2e8..b36d45240b 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncUserDataDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/yantai/DataSyncUserDataDao.java @@ -38,4 +38,7 @@ public interface DataSyncUserDataDao extends BaseDao { @Param("staffId")String staffId, @Param("name")String name, @Param("mobile")String mobile); + + Integer deleteByCustomerId(@Param("customerId")String customerId); + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DataSyncOrgDataService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DataSyncOrgDataService.java index 3a3d40fe2d..72b77a4888 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DataSyncOrgDataService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/DataSyncOrgDataService.java @@ -75,4 +75,6 @@ public interface DataSyncOrgDataService extends BaseService + + delete from data_sync_org_data + where customer_id = #{customerId} + and del_flag = 0 + limit 1000 + From d9922197aa2ffd88445661ad16bea20167c9ce1e Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 25 Oct 2022 14:33:13 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=8A=A0=E4=BF=A9=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/db/migration/V0.0.18__yt_alter_sync.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.18__yt_alter_sync.sql b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.18__yt_alter_sync.sql index 73315b0673..930f3df2e4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.18__yt_alter_sync.sql +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.18__yt_alter_sync.sql @@ -1 +1,4 @@ -alter table data_sync_org_data modify column PIDS varchar(1024) comment '所有上级组织。不包含本身!如果是根组织,此列为空串' \ No newline at end of file +alter table data_sync_org_data modify column PIDS varchar(1024) comment '所有上级组织。不包含本身!如果是根组织,此列为空串'; + +CREATE INDEX idx_data_sync_orgid on data_sync_org_data(ORGANIZATION_ID); +CREATE INDEX idx_data_sync_userorgid on data_sync_user_data(ORGANIZATION_ID); \ No newline at end of file From 195e2c617d04ca24dcbf83294782ecaa100aaf08 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 25 Oct 2022 15:04:07 +0800 Subject: [PATCH 6/6] emm --- .../controller/yantai/DataSyncUserAndOrgServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java index 5f2ae5c4fc..16d281ed0c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/yantai/DataSyncUserAndOrgServiceImpl.java @@ -67,7 +67,7 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService Integer delSize = NumConstant.ZERO; do { delSize = dataSyncUserDataService.deleteByCustomerId(customerId); - }while (delSize == NumConstant.ONE_THOUSAND); + }while (null != delSize && delSize == NumConstant.ONE_THOUSAND); // 缓存初始化staffs epmetUserOpenFeignClient.allCustomerStaffInCache(customerId); Integer no = NumConstant.ONE; @@ -115,7 +115,7 @@ public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService Integer delSize = NumConstant.ZERO; do { delSize = dataSyncOrgDataService.deleteByCustomerId(YT_CUSTOMER_ID); - }while (delSize == NumConstant.ONE_THOUSAND); + }while (null != delSize && delSize == NumConstant.ONE_THOUSAND); List needInsert = new ArrayList<>(); // 根组织 OrgData rootOrg = YantaiApi.getOuInfoByOuGuid(organizationId);