|
|
@@ -3,7 +3,6 @@ package com.shkpr.service.bespokegateway.zydma.components;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.global.base.log.LogLevelFlag;
|
|
|
import com.global.base.log.LogPrintMgr;
|
|
|
-import com.shkpr.service.bespokegateway.zydma.domain.*;
|
|
|
import com.shkpr.service.bespokegateway.core.constants.LogFlagBusiType;
|
|
|
import com.shkpr.service.bespokegateway.core.domain.CallingEndpoint;
|
|
|
import com.shkpr.service.bespokegateway.core.domain.IntegrationKey;
|
|
|
@@ -15,7 +14,9 @@ import com.shkpr.service.bespokegateway.core.service.FunctionInfoService;
|
|
|
import com.shkpr.service.bespokegateway.core.service.PersonnelInfoService;
|
|
|
import com.shkpr.service.bespokegateway.core.utils.CallingUtil;
|
|
|
import com.shkpr.service.bespokegateway.zydma.constants.MiddlePlatformMetadata;
|
|
|
+import com.shkpr.service.bespokegateway.zydma.domain.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.http.Header;
|
|
|
import org.apache.http.message.BasicHeader;
|
|
|
@@ -123,14 +124,28 @@ public class InfoSynchronizer {
|
|
|
CallingEndpoint endpoint = callingProperties.getEndpoint(MiddlePlatformMetadata.NAME);
|
|
|
|
|
|
//获取角色
|
|
|
- List<MiddlePlatformRole> roles = getRoles(endpoint);
|
|
|
+ List<MiddlePlatformSubsystem> roles = getRoles(endpoint);
|
|
|
|
|
|
//转换职能对象
|
|
|
- List<FunctionInfo> dates = roles.stream()
|
|
|
- .map(MiddlePlatformRole::toFunctionInfo).collect(Collectors.toList());
|
|
|
+ List<FunctionInfo> dates = new ArrayList<>(roles.stream()
|
|
|
+ .flatMap(subsystem -> subsystem.getRoleList().stream()
|
|
|
+ .map(role -> {
|
|
|
+ FunctionInfo functionInfo = role.toFunctionInfo();
|
|
|
+ functionInfo.setPuid(subsystem.getVisibleValue());
|
|
|
+ return functionInfo;
|
|
|
+ }))
|
|
|
+ //根据uid排序
|
|
|
+ .sorted(Comparator.comparingLong(role -> Long.parseLong(role.getUid())))
|
|
|
+ //根据uid去重
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ FunctionInfo::getUid,
|
|
|
+ Function.identity(),
|
|
|
+ (existing, replacement) -> existing,
|
|
|
+ LinkedHashMap::new
|
|
|
+ )).values());
|
|
|
|
|
|
//批量写入职能
|
|
|
- Boolean upserted = functionInfoService.upsertAll(dates);
|
|
|
+ Boolean upserted = functionInfoService.syncAll(dates);
|
|
|
long end = System.currentTimeMillis();
|
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, BIZ_TYPE, CLASS_NAME
|
|
|
, String.format(
|
|
|
@@ -181,9 +196,9 @@ public class InfoSynchronizer {
|
|
|
* @param endpoint 对接点
|
|
|
* @return 角色列表
|
|
|
*/
|
|
|
- private List<MiddlePlatformRole> getRoles(CallingEndpoint endpoint) {
|
|
|
+ private List<MiddlePlatformSubsystem> getRoles(CallingEndpoint endpoint) {
|
|
|
//结果
|
|
|
- List<MiddlePlatformRole> result = new ArrayList<>();
|
|
|
+ List<MiddlePlatformSubsystem> result = new ArrayList<>();
|
|
|
//请求地址
|
|
|
String url = endpoint.getUrl() + MiddlePlatformMetadata.Uri.GET_GROUP_ROLES;
|
|
|
//参数
|
|
|
@@ -214,22 +229,16 @@ public class InfoSynchronizer {
|
|
|
subsystems.forEach(new Consumer<MiddlePlatformSubsystem>() {
|
|
|
@Override
|
|
|
public void accept(MiddlePlatformSubsystem subsystem) {
|
|
|
- //填入角色
|
|
|
- if (subsystem.getRoleList() != null) result.addAll(subsystem.getRoleList());
|
|
|
+ //填入结果
|
|
|
+ if (MiddlePlatformMetadata.SUBSYSTEMS.contains(subsystem.getVisibleValue()) &&
|
|
|
+ CollectionUtils.isNotEmpty(subsystem.getRoleList()))
|
|
|
+ result.add(subsystem);
|
|
|
//递归子系统
|
|
|
if (subsystem.getChild() != null) subsystem.getChild().forEach(this);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- //根据角色id排序去重
|
|
|
- return new ArrayList<>(result.stream()
|
|
|
- .sorted(Comparator.comparingLong(role -> Long.parseLong(role.getRoleId()))) // 如果是int类型
|
|
|
- .collect(Collectors.toMap(
|
|
|
- MiddlePlatformRole::getRoleId,
|
|
|
- Function.identity(),
|
|
|
- (existing, replacement) -> existing,
|
|
|
- LinkedHashMap::new
|
|
|
- )).values());
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|