From f8ec7d5573071299423991827cac76c5f2c7f9fa Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Tue, 31 Oct 2023 15:56:50 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/common/helper/UserInfoHelper.java | 2 -- .../common/helper/impl/UserInfoHelperImpl.java | 24 --------------- .../task/EarlyWarningInstanceNotStartTask.java | 6 ++-- .../ningdatech/pmapi/sys/manage/RoleManage.java | 35 +++++++++++++++++----- 4 files changed, 30 insertions(+), 37 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java index 8a5f493..26c0f69 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java @@ -47,6 +47,4 @@ public interface UserInfoHelper { * @return */ String getUserEmpPosUnitCode(Long userId); - - List getUsersByRoleType(String roleType); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java index 24e947c..f8fcd4f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java @@ -4,8 +4,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.google.common.collect.Lists; -import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; import com.ningdatech.pmapi.organization.model.entity.DingOrganization; @@ -14,7 +12,6 @@ import com.ningdatech.pmapi.organization.service.IDingOrganizationService; import com.ningdatech.pmapi.sys.mapper.RoleMapper; import com.ningdatech.pmapi.sys.model.entity.Role; import com.ningdatech.pmapi.sys.model.entity.UserRole; -import com.ningdatech.pmapi.sys.service.IRoleService; import com.ningdatech.pmapi.sys.service.IUserRoleService; import com.ningdatech.pmapi.user.constant.UserAvailableEnum; import com.ningdatech.pmapi.user.entity.UserInfo; @@ -43,9 +40,6 @@ public class UserInfoHelperImpl implements UserInfoHelper { private final IUserRoleService iUserRoleService; private final RoleMapper roleMapper; - private final IRoleService roleService; - - @Override public String getOrganizationCode(Long userId) { UserFullInfoDTO userFullInfo = getUserFullInfo(userId); @@ -238,22 +232,4 @@ public class UserInfoHelperImpl implements UserInfoHelper { UserFullInfoDTO userFullInfo = getUserFullInfo(userId); return userFullInfo.getEmpPosUnitCode(); } - - @Override - public List getUsersByRoleType(String roleType) { - Role regionRole = roleService.getOne(Wrappers.lambdaQuery(Role.class) - .eq(Role::getCode, roleType) - .last(BizConst.LIMIT_1)); - if(Objects.isNull(regionRole)){ - return Collections.emptyList(); - } - List userRoles = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class) - .eq(UserRole::getRoleId, regionRole.getId())); - if(CollUtil.isEmpty(userRoles)){ - return Collections.emptyList(); - } - List userIds = userRoles.stream().map(UserRole::getUserId) - .collect(Collectors.toList()); - return userInfoService.listByIds(userIds); - } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java index 10c64d6..1cda344 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/scheduler/task/EarlyWarningInstanceNotStartTask.java @@ -8,7 +8,6 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.common.enumeration.CommonEnum; -import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; import com.ningdatech.pmapi.projectdeclared.model.entity.Operation; import com.ningdatech.pmapi.projectdeclared.service.IContractService; @@ -19,6 +18,7 @@ import com.ningdatech.pmapi.projectlib.model.entity.ProjectRenewalFundDeclaratio import com.ningdatech.pmapi.projectlib.service.IProjectRenewalFundDeclarationService; import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.sys.manage.EarlyWarningManage; +import com.ningdatech.pmapi.sys.manage.RoleManage; import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; import com.ningdatech.pmapi.user.service.IUserInfoService; @@ -66,7 +66,7 @@ public class EarlyWarningInstanceNotStartTask { private final IProjectRenewalFundDeclarationService renewalFundDeclarationService; - private final UserInfoHelper userInfoHelper; + private final RoleManage roleManage; @Scheduled(cron = "0 0/2 * * * ?") public void doEarlyWarningDeclared() throws UnknownHostException { @@ -414,7 +414,7 @@ public class EarlyWarningInstanceNotStartTask { for(ProjectRenewalFundDeclaration needToWaringProject : needToWaringProjects){ Project project = projectService.getProjectByCode(needToWaringProject.getProjectCode()); //去预警通知 发给区管 - List users = userInfoHelper.getUsersByRoleType(RoleEnum.REGION_MANAGER.name()); + List users = roleManage.getUsersByRoleType(RoleEnum.REGION_MANAGER.name()); for(UserInfo user : users){ earlyWarningManage.doEarlyWarning(noticeMethod,noticeContent,time,null, needToWaringProject.getUpdateOn(),user.getEmployeeCode(),project, diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/RoleManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/RoleManage.java index 7397dc7..8e7d9c7 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/RoleManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/sys/manage/RoleManage.java @@ -1,27 +1,26 @@ package com.ningdatech.pmapi.sys.manage; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ningdatech.basic.model.PageVo; import com.ningdatech.basic.util.CollUtils; +import com.ningdatech.pmapi.common.constant.BizConst; import com.ningdatech.pmapi.sys.model.dto.MenuDataScopeDTO; -import com.ningdatech.pmapi.sys.model.entity.Menu; -import com.ningdatech.pmapi.sys.model.entity.Role; -import com.ningdatech.pmapi.sys.model.entity.RoleMenu; -import com.ningdatech.pmapi.sys.model.entity.RoleMenuDatascope; +import com.ningdatech.pmapi.sys.model.entity.*; import com.ningdatech.pmapi.sys.model.req.RolePageReq; import com.ningdatech.pmapi.sys.model.vo.MenuRoleVO; import com.ningdatech.pmapi.sys.model.vo.RoleVO; -import com.ningdatech.pmapi.sys.service.IMenuService; -import com.ningdatech.pmapi.sys.service.IRoleMenuDatascopeService; -import com.ningdatech.pmapi.sys.service.IRoleMenuService; -import com.ningdatech.pmapi.sys.service.IRoleService; +import com.ningdatech.pmapi.sys.service.*; +import com.ningdatech.pmapi.user.entity.UserInfo; +import com.ningdatech.pmapi.user.service.IUserInfoService; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -43,6 +42,10 @@ public class RoleManage { private final IRoleMenuService roleMenuService; private final IRoleMenuDatascopeService roleMenuDatascopeService; + private final IUserRoleService iUserRoleService; + + private final IUserInfoService userInfoService; + public PageVo queryList(RolePageReq rolePageReq) { Page page = rolePageReq.page(); LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Role.class); @@ -87,4 +90,20 @@ public class RoleManage { }); } + public List getUsersByRoleType(String roleType) { + Role regionRole = roleService.getOne(Wrappers.lambdaQuery(Role.class) + .eq(Role::getCode, roleType) + .last(BizConst.LIMIT_1)); + if(Objects.isNull(regionRole)){ + return Collections.emptyList(); + } + List userRoles = iUserRoleService.list(Wrappers.lambdaQuery(UserRole.class) + .eq(UserRole::getRoleId, regionRole.getId())); + if(CollUtil.isEmpty(userRoles)){ + return Collections.emptyList(); + } + List userIds = userRoles.stream().map(UserRole::getUserId) + .collect(Collectors.toList()); + return userInfoService.listByIds(userIds); + } }