feat:feature-REQ/2129 重新修改清洗ouId的逻辑,注册cmp账号时过滤掉ouId = 0的情况
This commit is contained in:
parent
afd0f29c01
commit
1fc56cd565
@ -112,6 +112,11 @@
|
||||
<groupId>cn.axzo.im.center</groupId>
|
||||
<artifactId>im-center-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.axzo.tyr</groupId>
|
||||
<artifactId>tyr-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -55,8 +55,8 @@ public class PrivateController {
|
||||
}
|
||||
|
||||
@PostMapping("/private/im-account/ou-id/update")
|
||||
public Object updateImAccountOuId(@RequestParam("param") String param) throws Exception {
|
||||
return updateImAccountOuIdJob.execute(param);
|
||||
public Object updateImAccountOuId(@RequestBody UpdateImAccountOuIdJob.UpdateImAccountOuIdParam param) throws Exception {
|
||||
return updateImAccountOuIdJob.execute(JSONObject.toJSONString(param));
|
||||
}
|
||||
|
||||
@PostMapping("/private/account-register/page")
|
||||
|
||||
@ -189,6 +189,12 @@ public class MessageTask {
|
||||
if (StringUtils.isNotBlank(this.getImAccount())) {
|
||||
return this.getImAccount();
|
||||
}
|
||||
|
||||
// 因为模板消息发给工人端的时候会带ouId
|
||||
if (appType == AppTypeEnum.CM) {
|
||||
return this.getPersonId() + "_" + this.getAppType().getCode();
|
||||
}
|
||||
|
||||
return this.getPersonId() + "_" + this.getAppType().getCode() + "_" + this.getOuId();
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,9 +4,10 @@ import cn.axzo.im.center.common.enums.AccountTypeEnum;
|
||||
import cn.axzo.im.center.common.enums.AppTypeEnum;
|
||||
import cn.axzo.im.entity.AccountRegister;
|
||||
import cn.axzo.im.service.AccountRegisterService;
|
||||
import cn.axzo.maokai.api.client.OrganizationalNodeUserApi;
|
||||
import cn.axzo.maokai.api.vo.request.OrganizationalNodeUserBasicQueryVO;
|
||||
import cn.axzo.maokai.api.vo.response.OrganizationalNodeUserBasicVO;
|
||||
import cn.axzo.tyr.client.feign.TyrSaasRoleUserApi;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserParam;
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
@ -30,7 +31,6 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -45,7 +45,7 @@ public class UpdateImAccountOuIdJob extends IJobHandler {
|
||||
@Autowired
|
||||
private AccountRegisterService accountRegisterService;
|
||||
@Autowired
|
||||
private OrganizationalNodeUserApi organizationalNodeUserApi;
|
||||
private TyrSaasRoleUserApi tyrSaasRoleUserApi;
|
||||
|
||||
private static final Integer DEFAULT_PAGE_SIZE = 500;
|
||||
|
||||
@ -63,13 +63,15 @@ public class UpdateImAccountOuIdJob extends IJobHandler {
|
||||
.ids(updateImAccountOuIdParam.getIds())
|
||||
.appType(AppTypeEnum.CMP.getCode())
|
||||
.accountType(AccountTypeEnum.USER.getCode())
|
||||
.accountWrapperEW("cmp")
|
||||
.page(pageNumber++)
|
||||
.pageSize(DEFAULT_PAGE_SIZE)
|
||||
.build();
|
||||
|
||||
Page<AccountRegisterService.AccountRegisterDTO> page = accountRegisterService.page(req);
|
||||
if (CollectionUtils.isNotEmpty(page.getRecords())) {
|
||||
Map<String, OrganizationalNodeUserBasicVO> nodeUsers = listNodeUsers(page.getRecords());
|
||||
|
||||
Map<String, Long> nodeUsers = listNodeUsers(page.getRecords());
|
||||
|
||||
updateAccountRegister(page.getRecords(), nodeUsers);
|
||||
}
|
||||
@ -82,17 +84,22 @@ public class UpdateImAccountOuIdJob extends IJobHandler {
|
||||
return ReturnT.SUCCESS;
|
||||
}
|
||||
|
||||
private void updateAccountRegister(List<AccountRegisterService.AccountRegisterDTO> accountRegisters, Map<String, OrganizationalNodeUserBasicVO> nodeUsers) {
|
||||
private void updateAccountRegister(List<AccountRegisterService.AccountRegisterDTO> accountRegisters, Map<String, Long> nodeUsers) {
|
||||
List<AccountRegister> update = accountRegisters.stream()
|
||||
.filter(accountRegister -> nodeUsers.get(accountRegister.getAccountId()) != null)
|
||||
.map(accountRegister -> {
|
||||
OrganizationalNodeUserBasicVO nodeUser = nodeUsers.get(accountRegister.getAccountId());
|
||||
Long ouId = nodeUsers.get(accountRegister.getAccountId());
|
||||
|
||||
if (ouId == null) {
|
||||
return null;
|
||||
}
|
||||
AccountRegister result = new AccountRegister();
|
||||
result.setId(accountRegister.getId());
|
||||
result.setOuId(nodeUser.getOrganizationalUnitId());
|
||||
result.setOuId(ouId);
|
||||
result.setUpdateAt(new Date());
|
||||
return result;
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(accountRegisters)) {
|
||||
log.info("updateImAccountOuIdJob: no data update");
|
||||
@ -102,7 +109,7 @@ public class UpdateImAccountOuIdJob extends IJobHandler {
|
||||
accountRegisterService.updateBatchById(update);
|
||||
}
|
||||
|
||||
private Map<String, OrganizationalNodeUserBasicVO> listNodeUsers(List<AccountRegisterService.AccountRegisterDTO> accountRegisters) {
|
||||
private Map<String, Long> listNodeUsers(List<AccountRegisterService.AccountRegisterDTO> accountRegisters) {
|
||||
if (CollectionUtils.isEmpty(accountRegisters)) {
|
||||
return Collections.EMPTY_MAP;
|
||||
}
|
||||
@ -115,19 +122,21 @@ public class UpdateImAccountOuIdJob extends IJobHandler {
|
||||
if (CollectionUtils.isEmpty(accountIds)) {
|
||||
return Collections.EMPTY_MAP;
|
||||
}
|
||||
OrganizationalNodeUserBasicQueryVO queryVO = new OrganizationalNodeUserBasicQueryVO();
|
||||
queryVO.setPersonIds(accountIds);
|
||||
List<OrganizationalNodeUserBasicVO> nodeUsers = organizationalNodeUserApi.queryUserBasic(queryVO).getData();
|
||||
|
||||
return nodeUsers.stream()
|
||||
.collect(Collectors.toMap(e -> e.getPersonId().toString(), Function.identity(), (f, s) -> s));
|
||||
return accountIds.stream()
|
||||
.map(e -> {
|
||||
Optional<SaasRoleUserDTO> user = tyrSaasRoleUserApi.roleUserList(RoleUserParam.builder().personId(e).build()).getData().stream().findFirst();
|
||||
return Pair.of(e.toString(), user.map(SaasRoleUserDTO::getOuId).orElse(null));
|
||||
})
|
||||
.filter(e -> e.getValue() != null)
|
||||
.collect(Collectors.toMap(Pair::getKey, Pair::getValue));
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
static class UpdateImAccountOuIdParam {
|
||||
public static class UpdateImAccountOuIdParam {
|
||||
private List<Long> ids;
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,6 +68,9 @@ public interface AccountRegisterService extends IService<AccountRegister> {
|
||||
@CriteriaField(field = "accountType", operator = Operator.EQ)
|
||||
private String accountType;
|
||||
|
||||
@CriteriaField(field = "accountWrapper", operator = Operator.EW)
|
||||
private String accountWrapperEW;
|
||||
|
||||
@CriteriaField(ignore = true)
|
||||
private boolean needOuInfo;
|
||||
|
||||
|
||||
@ -341,7 +341,7 @@ public class AccountService {
|
||||
.appType(appTypeEnum.getCode())
|
||||
.accountId(accountAbsentQuery.getPersonId())
|
||||
.build();
|
||||
if (appTypeEnum == AppTypeEnum.CMP) {
|
||||
if (appTypeEnum == AppTypeEnum.CMP && accountAbsentQuery.getOuId() != 0) {
|
||||
listAccountRegisterParam.setOuId(accountAbsentQuery.getOuId());
|
||||
}
|
||||
List<AccountRegisterService.AccountRegisterDTO> accountRegisters = accountRegisterService.list(listAccountRegisterParam);
|
||||
@ -368,7 +368,7 @@ public class AccountService {
|
||||
userAccountReq.setUserId(accountAbsentQuery.getPersonId());
|
||||
userAccountReq.setNickName(DEFAULT_NICK_NAME + accountAbsentQuery.getPersonId());
|
||||
// 管理版需要根据ou注册IM账号,做数据隔离
|
||||
if (appTypeEnum == AppTypeEnum.CMP) {
|
||||
if (appTypeEnum == AppTypeEnum.CMP && accountAbsentQuery.getOuId() != 0) {
|
||||
userAccountReq.setOrganizationalUnitId(accountAbsentQuery.getOuId());
|
||||
}
|
||||
UserAccountResp accountResp = generateAccount(userAccountReq, iNotifyService);
|
||||
|
||||
@ -267,8 +267,14 @@ public class MessageTaskServiceImpl extends ServiceImpl<MessageTaskMapper, Messa
|
||||
.accountIds(personIds)
|
||||
.build())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(accountRegister -> accountRegister.getAccountId() +
|
||||
"_" + accountRegister.getAppType() + "_" + accountRegister.getOuId(), AccountRegister::getImAccount, (f, s) -> f));
|
||||
.collect(Collectors.toMap(accountRegister -> {
|
||||
if (Objects.equals(accountRegister.getAppType(), AppTypeEnum.CM.getCode())) {
|
||||
return accountRegister.getAccountId() +
|
||||
"_" + accountRegister.getAppType();
|
||||
}
|
||||
return accountRegister.getAccountId() +
|
||||
"_" + accountRegister.getAppType() + "_" + accountRegister.getOuId();
|
||||
}, AccountRegister::getImAccount, (f, s) -> f));
|
||||
}
|
||||
|
||||
private Map<String, AccountRegisterService.AccountRegisterDTO> listImAccount(List<MessageTask.ReceivePerson> receivePersons) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user