|
@@ -2,10 +2,12 @@ package com.inspur.customer.service.tenant;
|
|
|
|
|
|
|
|
import com.alibaba.cola.exception.BizException;
|
|
import com.alibaba.cola.exception.BizException;
|
|
|
import com.inspur.customer.client.keycloak.KeycloakService;
|
|
import com.inspur.customer.client.keycloak.KeycloakService;
|
|
|
|
|
+import com.inspur.customer.client.org.SmsbDepartmentUserService;
|
|
|
import com.inspur.customer.client.tenant.TenantExceptionInformStrategyService;
|
|
import com.inspur.customer.client.tenant.TenantExceptionInformStrategyService;
|
|
|
import com.inspur.customer.client.tenant.UserInformService;
|
|
import com.inspur.customer.client.tenant.UserInformService;
|
|
|
import com.inspur.customer.context.inform.InformLevelEnum;
|
|
import com.inspur.customer.context.inform.InformLevelEnum;
|
|
|
import com.inspur.customer.context.inform.InformTypeEnum;
|
|
import com.inspur.customer.context.inform.InformTypeEnum;
|
|
|
|
|
+import com.inspur.customer.object.org.SmsbSimpleUserCO;
|
|
|
import com.inspur.customer.object.tenant.InformAddresseeCO;
|
|
import com.inspur.customer.object.tenant.InformAddresseeCO;
|
|
|
import com.inspur.customer.object.keycloak.KeycloakUserCO;
|
|
import com.inspur.customer.object.keycloak.KeycloakUserCO;
|
|
|
import com.inspur.customer.object.tenant.ExceptionInformStrategyCmd;
|
|
import com.inspur.customer.object.tenant.ExceptionInformStrategyCmd;
|
|
@@ -13,11 +15,13 @@ import com.inspur.customer.object.tenant.TenantExceptionInformStrategyCO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
import javax.annotation.Nullable;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author linwenhua
|
|
* @author linwenhua
|
|
@@ -30,6 +34,8 @@ public class UserInformServiceImpl implements UserInformService {
|
|
|
@DubboReference
|
|
@DubboReference
|
|
|
private KeycloakService keycloakService;
|
|
private KeycloakService keycloakService;
|
|
|
@DubboReference
|
|
@DubboReference
|
|
|
|
|
+ private SmsbDepartmentUserService departmentUserService;
|
|
|
|
|
+ @DubboReference
|
|
|
private TenantExceptionInformStrategyService tenantExceptionInformStrategyService;
|
|
private TenantExceptionInformStrategyService tenantExceptionInformStrategyService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -68,6 +74,23 @@ public class UserInformServiceImpl implements UserInformService {
|
|
|
throw new BizException("500", "类型错误");
|
|
throw new BizException("500", "类型错误");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //关联的org需要对该org下的用户进行预警,并且需要用户的接收级别<=异常级别,这里我们用informLevel的id表示级别的递增
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(org)) {
|
|
|
|
|
+ log.debug("users:{}", users);
|
|
|
|
|
+ List<SmsbSimpleUserCO> orgUserList = departmentUserService.listUserByOrgAndInformLevel(tenant, org, informLevel.getId());
|
|
|
|
|
+ List<String> existedUserIdList = users.stream().map(KeycloakUserCO::getId).collect(Collectors.toList());
|
|
|
|
|
+ List<String> orgUserIdList = orgUserList.stream().map(SmsbSimpleUserCO::getUserId).distinct().collect(Collectors.toList());
|
|
|
|
|
+ orgUserIdList.removeAll(existedUserIdList);
|
|
|
|
|
+ log.debug("orgUserIdList:{}", orgUserIdList);
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(orgUserIdList)) {
|
|
|
|
|
+ List<KeycloakUserCO> orgKeyCloakUserList = keycloakService.getUsersByIds(orgUserIdList);
|
|
|
|
|
+ log.debug("orgKeyCloakUserList:{}", orgKeyCloakUserList);
|
|
|
|
|
+ users.addAll(orgKeyCloakUserList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
informAddressee.setUsers(users);
|
|
informAddressee.setUsers(users);
|
|
|
return informAddressee;
|
|
return informAddressee;
|
|
|
}
|
|
}
|