perf: 定时报告发送组织角色
This commit is contained in:
parent
e6dc17d99d
commit
5d373c147b
@ -10,6 +10,8 @@ public interface ExtAuthService {
|
||||
|
||||
Set<Long> userIdsByRD(AuthURD request);
|
||||
|
||||
Set<String> userNamesByRD(AuthURD request);
|
||||
|
||||
AuthURD resourceTarget(String resourceId);
|
||||
|
||||
List<AuthItem> dataSourceIdByUser(Long userId);
|
||||
|
||||
@ -43,6 +43,21 @@ public class ExtAuthServiceImpl implements ExtAuthService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> userNamesByRD(AuthURD request) {
|
||||
Set<String> result = new HashSet<>();
|
||||
List<Long> roleIds = request.getRoleIds();
|
||||
List<Long> deptIds = request.getDeptIds();
|
||||
if (!CollectionUtils.isEmpty(roleIds)) {
|
||||
result.addAll(extAuthMapper.queryUserNameWithRoleIds(roleIds));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(deptIds)) {
|
||||
result.addAll(extAuthMapper.queryUserNameWithDeptIds(deptIds));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthURD resourceTarget(String resourceId) {
|
||||
AuthURD authURD = new AuthURD();
|
||||
|
||||
@ -71,6 +71,10 @@ public class AuthUtils {
|
||||
return userIds;
|
||||
}
|
||||
|
||||
public static Set<String> accountByURD(AuthURD request) {
|
||||
return extAuthService.userNamesByRD(request);
|
||||
}
|
||||
|
||||
public static List<String> parentResources(String resourceId, String type) {
|
||||
return extAuthService.parentResource(resourceId, type);
|
||||
}
|
||||
|
||||
@ -11,8 +11,10 @@ import java.util.List;
|
||||
public interface ExtAuthMapper {
|
||||
|
||||
List<Long> queryUserIdWithRoleIds(@Param("roleIds") List<Long> roleIds);
|
||||
List<String> queryUserNameWithRoleIds(@Param("roleIds") List<Long> roleIds);
|
||||
|
||||
List<Long> queryUserIdWithDeptIds(@Param("deptIds") List<Long> deptIds);
|
||||
List<String> queryUserNameWithDeptIds(@Param("deptIds") List<Long> deptIds);
|
||||
|
||||
List<SysAuth> queryByResource(@Param("resourceId") String resourceId);
|
||||
|
||||
|
||||
@ -16,6 +16,16 @@
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="queryUserNameWithRoleIds" resultType="java.lang.String" >
|
||||
select su.username
|
||||
from sys_user su
|
||||
left join sys_users_roles sur on sur.user_id = su.user_id
|
||||
where sur.role_id in
|
||||
<foreach collection="roleIds" item="roleId" open='(' separator=',' close=')'>
|
||||
#{roleId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryUserIdWithDeptIds" resultType="java.lang.Long" >
|
||||
select user_id
|
||||
@ -26,6 +36,15 @@
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="queryUserNameWithDeptIds" resultType="java.lang.String" >
|
||||
select username
|
||||
from sys_user
|
||||
where dept_id in
|
||||
<foreach collection="deptIds" item="deptId" open='(' separator=',' close=')'>
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryByResource" resultMap="io.dataease.plugins.common.base.mapper.SysAuthMapper.BaseResultMap" >
|
||||
select a.*
|
||||
|
||||
@ -6,6 +6,7 @@ import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.service.impl.AuthUserServiceImpl;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.dto.PermissionProxy;
|
||||
import io.dataease.dto.chart.ViewOption;
|
||||
@ -45,10 +46,7 @@ import org.springframework.web.util.HtmlUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service("emailTaskHandler")
|
||||
@ -158,8 +156,24 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
}
|
||||
|
||||
private void formatReci(XpackEmailTemplateDTO emailTemplateDTO) {
|
||||
String reciUsers = emailTemplateDTO.getReciUsers();
|
||||
String roleList = emailTemplateDTO.getRoleList();
|
||||
String orgList = emailTemplateDTO.getOrgList();
|
||||
AuthURD authURD = new AuthURD();
|
||||
if (StringUtils.isNotBlank(roleList)) {
|
||||
authURD.setRoleIds(Arrays.stream(roleList.split(",")).map(Long::parseLong).collect(Collectors.toList()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(orgList)) {
|
||||
authURD.setDeptIds(Arrays.stream(orgList.split(",")).map(Long::parseLong).collect(Collectors.toList()));
|
||||
}
|
||||
Set<String> accountSet = AuthUtils.accountByURD(authURD);
|
||||
if (accountSet == null) accountSet = new HashSet<>();
|
||||
if (StringUtils.isNotBlank(reciUsers)) {
|
||||
accountSet.addAll(Arrays.stream(reciUsers.split(",")).collect(Collectors.toSet()));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(accountSet)) {
|
||||
emailTemplateDTO.setReciUsers(String.join(",", accountSet));
|
||||
}
|
||||
}
|
||||
|
||||
@Async("priorityExecutor")
|
||||
@ -182,7 +196,9 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
token = tokenByUser(user);
|
||||
XpackPixelEntity xpackPixelEntity = buildPixel(emailTemplateDTO);
|
||||
// 下面继续执行发送邮件的
|
||||
formatReci(emailTemplateDTO);
|
||||
if (StringUtils.isNotBlank(emailTemplateDTO.getRoleList()) || StringUtils.isNotBlank(emailTemplateDTO.getOrgList()))
|
||||
formatReci(emailTemplateDTO);
|
||||
LogUtil.info(String.format("recipients list is [%s]", emailTemplateDTO.getReciUsers()));
|
||||
String recipients = emailTemplateDTO.getRecipients();
|
||||
String reciUsers = emailTemplateDTO.getReciUsers();
|
||||
Integer extWaitTime = emailTemplateDTO.getExtWaitTime();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user