diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java index d4276b3..37b4cf6 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java @@ -12,6 +12,7 @@ import org.dromara.business.mapper.BusinessAlertMapper; import org.dromara.business.service.IBusinessAlertService; import org.dromara.business.service.IBusinessAlertStatisticsService; import org.dromara.common.core.exception.ServiceException; +import org.dromara.common.mybatis.enums.DataScopeType; import org.dromara.common.redis.utils.RedisUtils; import org.dromara.common.satoken.utils.LoginHelper; import org.dromara.system.api.RemoteDataScopeService; @@ -775,20 +776,32 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist } private void createPermissions(BusinessAlertBo businessAlertBo) { - Long roleId = Optional.ofNullable(LoginHelper.getLoginUser()) - .map(LoginUser::getRoles) - .filter(roles -> !roles.isEmpty()) - .map(List::getFirst) - .map(RoleDTO::getRoleId) - .orElse(null); - - String roleCustom = remoteDataScopeService.getRoleCustom(roleId); - if (roleCustom.equalsIgnoreCase("-1")){ - businessAlertBo.setDeptIdList(ListUtil.empty()); - }else { - businessAlertBo.setDeptIdList(Arrays.stream(roleCustom.split(",")) - .map(Long::parseLong) - .collect(Collectors.toList())); + RoleDTO roleDTO = LoginHelper.getLoginUser().getRoles().getFirst(); + + //自定义权限 + if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.CUSTOM.getCode())){ + String roleCustom = remoteDataScopeService.getRoleCustom(roleDTO.getRoleId()); + if (roleCustom.equalsIgnoreCase("-1")){ + businessAlertBo.setDeptIdList(ListUtil.empty()); + }else { + businessAlertBo.setDeptIdList(Arrays.stream(roleCustom.split(",")) + .map(Long::parseLong) + .collect(Collectors.toList())); + } + } else if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.DEPT_AND_CHILD.getCode())) { + //部门及其以下 + String deptAndChild = remoteDataScopeService.getDeptAndChild(LoginHelper.getDeptId()); + if (deptAndChild.equalsIgnoreCase("-1")){ + businessAlertBo.setDeptIdList(ListUtil.empty()); + }else { + businessAlertBo.setDeptIdList(Arrays.stream(deptAndChild.split(",")) + .map(Long::parseLong) + .collect(Collectors.toList())); + } + + } else if (roleDTO.getDataScope().equalsIgnoreCase(DataScopeType.DEPT.getCode())) { + //本部门 + businessAlertBo.setDeptIdList(List.of(LoginHelper.getDeptId())); } } }