Commit aaa553b3 authored by yangyang's avatar yangyang

fix(编辑企业信息): 新增手动刷新用户组的接口

parent ee96ab85
...@@ -2405,6 +2405,58 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -2405,6 +2405,58 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
} }
} }
public void refreshAdminUserRole(List<TzsUserInfo> userInfos, List<String> userId) {
List<String> adminUserIdList;
if (ValidationUtil.isEmpty(userInfos)) {
adminUserIdList = userId;
} else {
List<String> amosUserIdList = userInfos.stream().map(TzsUserInfo::getAmosUserId).collect(Collectors.toList());
adminUserIdList = userId.stream().filter(id -> !amosUserIdList.contains(id)).collect(Collectors.toList());
}
List<RegUnitInfo> regUnitInfos = regUnitInfoService.lambdaQuery().in(RegUnitInfo::getAdminUserId, adminUserIdList).list();
for (RegUnitInfo regUnitInfo : regUnitInfos) {
String useCode = regUnitInfo.getUnitCode();
CompanyModel companyInfo = Privilege.companyClient.queryByCompanyCode(useCode).getResult();
Set<String> appCodesSet = new HashSet<>();
Map<Long, List<Long>> roleSeqMap = new HashMap<>();
Map<Long, List<RoleModel>> orgRoles = new HashMap<>();
List<RoleModel> userRoleList = new ArrayList<>();
List<Long> roleIds = new ArrayList<>();
Set<String> roleNameSet = new HashSet<>();
FeignClientResult<List<RoleModel>> roleListResult = Privilege.roleClient.queryRoleList(null, null);
List<RoleModel> roleModels = roleListResult.getResult();
List<DataDictionary> unitTypeList = regUnitInfoService.setAndGetUnitTypeList();
String[] unitTypeCodes = regUnitInfo.getUnitTypeCode().split(",");
FeignClientResult<AgencyUserModel> userResult = Privilege.agencyUserClient.queryByUserId(regUnitInfo.getAdminUserId());
AgencyUserModel agencyUserModel = userResult.getResult();
Map<String, DataDictionary> dataDictionaryMap = unitTypeList.stream().collect(Collectors.toMap(DataDictionary::getCode, Function.identity(), (k1, k2) -> k1));
for (String typeCode : unitTypeCodes) {
DataDictionary unitType = dataDictionaryMap.get(typeCode);
String appCode = unitType.getTypeDesc() != null ? unitType.getTypeDesc() : "";
String[] appCodes = appCode.split(",");
Collections.addAll(appCodesSet, appCodes);
roleNameSet.add(unitType.getName());
userRoleList.addAll(roleModels.stream()
.filter(r -> unitType.getExtend().contains(r.getSequenceNbr().toString())).collect(Collectors.toList()));
userRoleList.forEach(r -> {
if (!roleIds.contains(r.getSequenceNbr())) {
roleIds.add(r.getSequenceNbr());
}
});
roleSeqMap.put(companyInfo.getSequenceNbr(), roleIds);
orgRoles.put(companyInfo.getSequenceNbr(), userRoleList);
}
agencyUserModel.setAppCodes(new ArrayList<>(appCodesSet));
agencyUserModel.setOrgRoles(orgRoles);
agencyUserModel.setOrgRoleSeqs(roleSeqMap);
userResult = Privilege.agencyUserClient.update(agencyUserModel, regUnitInfo.getAdminUserId());
System.out.println(userResult);
}
}
public void refreshUserGroupInfo(List<String> userId) { public void refreshUserGroupInfo(List<String> userId) {
if (ObjectUtils.isEmpty(userId)) { if (ObjectUtils.isEmpty(userId)) {
return; return;
...@@ -2412,9 +2464,11 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -2412,9 +2464,11 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
// 根据userId获取用户 // 根据userId获取用户
List<TzsUserInfo> userInfos = tzsUserInfoMapper.selectList(new LambdaQueryWrapper<TzsUserInfo>() List<TzsUserInfo> userInfos = tzsUserInfoMapper.selectList(new LambdaQueryWrapper<TzsUserInfo>()
.in(TzsUserInfo::getAmosUserId, userId)); .in(TzsUserInfo::getAmosUserId, userId));
refreshAdminUserRole(userInfos, userId);
if (ObjectUtils.isEmpty(userInfos)) { if (ObjectUtils.isEmpty(userInfos)) {
return; return;
} }
List<String> unitCodes = userInfos.stream().map(TzsUserInfo::getUnitCode).collect(Collectors.toList()); List<String> unitCodes = userInfos.stream().map(TzsUserInfo::getUnitCode).collect(Collectors.toList());
List<RegUnitInfo> regUnitInfos = regUnitInfoService.lambdaQuery().in(RegUnitInfo::getUnitCode, unitCodes).list(); List<RegUnitInfo> regUnitInfos = regUnitInfoService.lambdaQuery().in(RegUnitInfo::getUnitCode, unitCodes).list();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment