From 850748b4e101f35ebcc2443b447400682fe35609 Mon Sep 17 00:00:00 2001 From: nyoung <12190070+nyoungo@user.noreply.gitee.com> Date: Thu, 5 Sep 2024 23:23:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=B6=85=E6=97=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/constant/UserConstants.java | 6 +++--- .../module/rescue/utils/RedissonDelayQueue.java | 16 ++++++++++------ .../system/service/permission/RoleService.java | 5 ++++- .../service/permission/RoleServiceImpl.java | 8 ++++++++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/constant/UserConstants.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/constant/UserConstants.java index 2bc14568..fc02b58f 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/constant/UserConstants.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/constant/UserConstants.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.constant; /** * 用户常量信息 - * + * * @author ruoyi */ public class UserConstants @@ -53,7 +53,7 @@ public class UserConstants /** Layout组件标识 */ public final static String LAYOUT = "Layout"; - + /** ParentView组件标识 */ public final static String PARENT_VIEW = "ParentView"; @@ -82,5 +82,5 @@ public class UserConstants public static final String RESCUE_DRIVER = "jysj"; /** 救援定时任务时间 */ - public static final Integer RESCUE_TIME = 3 * 60; + public static final Integer RESCUE_TIME = 30; } diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java index 1458dab3..0f31807a 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java @@ -1,9 +1,13 @@ package cn.iocoder.yudao.module.rescue.utils; +import cn.hutool.extra.spring.SpringUtil; +import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.module.appBase.domain.SysAnnouncement; import cn.iocoder.yudao.module.appBase.service.ISysAnnouncementService; import cn.iocoder.yudao.module.constant.UserConstants; import cn.iocoder.yudao.module.rescue.dto.TaskDto; +import cn.iocoder.yudao.module.system.api.permission.PermissionApi; +import cn.iocoder.yudao.module.system.api.permission.RoleApi; import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; import cn.iocoder.yudao.module.system.service.permission.PermissionService; @@ -54,7 +58,7 @@ public class RedissonDelayQueue { @Resource private RoleService roleService; @Resource - private PermissionService permissionService; + private PermissionApi permissionService; /** * 初始化方法,在 Spring 容器加载后自动执行。 @@ -90,11 +94,11 @@ public class RedissonDelayQueue { sysAnnouncement.setTitle("有救援订单超时请立即处理"); sysAnnouncement.setContent("有救援订单超时请立即处理"); announcementService.insertSysAnnouncements(sysAnnouncement); - + TenantContextHolder.setIgnore(true); // 发送订单信息给其他人 经理 总调度 将这俩人指定 救援其他通知人 角色 - RoleDO roleDO = roleService.queryRole("rescueOtherNotify"); - if(null!=roleDO){ - List userIds = permissionService.getUserIdByRoleId(roleDO.getId()); + RoleDO roleInfo = roleService.getRoleByCodeWithoutTenant("rescueOtherNotify"); + if(null!=roleInfo){ + List userIds = permissionService.getUserIdByRoleId(roleInfo.getId()); if(!userIds.isEmpty()){ // 发消息 SysAnnouncement otherAnnouncement = new SysAnnouncement(); @@ -105,7 +109,7 @@ public class RedissonDelayQueue { announcementService.insertSysAnnouncements(otherAnnouncement); } } - + TenantContextHolder.setIgnore(false); /** 两个值虽然一样,但避免无法删除一直存在问题,干脆重新来过 */ // 移除原来的 removeAllTasks(taskDto.getRescueInfoId()); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java index c0eee42b..7d15d9ab 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleService.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.system.service.permission; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; @@ -144,5 +146,6 @@ public interface RoleService { * @param ids 角色编号数组 */ void validateRoleList(Collection ids); - + @TenantIgnore + RoleDO getRoleByCodeWithoutTenant(String rescueOtherNotify); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java index a9343151..2e28d26d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java @@ -11,6 +11,8 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore; +import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; +import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; @@ -312,6 +314,12 @@ public class RoleServiceImpl implements RoleService { }); } + @Override + public RoleDO getRoleByCodeWithoutTenant(String code) { + TenantContextHolder.setIgnore(true); + return roleMapper.selectByCode(code); + } + /** * 获得自身的代理对象,解决 AOP 生效问题 * From 28146606fe49ec796112d2a4032ea73e6cd67d70 Mon Sep 17 00:00:00 2001 From: nyoung <12190070+nyoungo@user.noreply.gitee.com> Date: Thu, 5 Sep 2024 23:23:59 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=B6=85=E6=97=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/iocoder/yudao/module/constant/UserConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/constant/UserConstants.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/constant/UserConstants.java index fc02b58f..76836e4e 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/constant/UserConstants.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/constant/UserConstants.java @@ -82,5 +82,5 @@ public class UserConstants public static final String RESCUE_DRIVER = "jysj"; /** 救援定时任务时间 */ - public static final Integer RESCUE_TIME = 30; + public static final Integer RESCUE_TIME = 3 * 60; } From 2ac02c19d3e049e1963479d61b118dd14260a457 Mon Sep 17 00:00:00 2001 From: nyoung <12190070+nyoungo@user.noreply.gitee.com> Date: Thu, 5 Sep 2024 23:53:10 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B6=85=E6=97=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java index 0f31807a..a444430b 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java @@ -114,7 +114,7 @@ public class RedissonDelayQueue { // 移除原来的 removeAllTasks(taskDto.getRescueInfoId()); // 在新创建定时任务 - offerTask(task, UserConstants.RESCUE_TIME); +// offerTask(task, UserConstants.RESCUE_TIME); } catch (Exception e) { // 记录并打印异常信息 log.error("发生错误", e); From 09201931a47d08ebd47766a0cd89ccaa490883f7 Mon Sep 17 00:00:00 2001 From: nyoung <12190070+nyoungo@user.noreply.gitee.com> Date: Thu, 5 Sep 2024 23:54:59 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B6=85=E6=97=B6=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java index a444430b..0f31807a 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/utils/RedissonDelayQueue.java @@ -114,7 +114,7 @@ public class RedissonDelayQueue { // 移除原来的 removeAllTasks(taskDto.getRescueInfoId()); // 在新创建定时任务 -// offerTask(task, UserConstants.RESCUE_TIME); + offerTask(task, UserConstants.RESCUE_TIME); } catch (Exception e) { // 记录并打印异常信息 log.error("发生错误", e);