From c096585fe916e97ec84af2ef8568a3a627e9fd9f Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Wed, 28 May 2025 19:35:51 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD]=20=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E5=92=8C=E6=B6=88=E6=81=AFSQL=E5=A2=9E=E5=8A=A0=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1431295429672960]通知和消息SQL增加缓存 http://192.168.0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947543042/1431295429672960 --- .../cache/NeatLogicConcurrentSafeCache.java | 6 ++- .../message/dao/mapper/MessageMapper.xml | 2 + .../message/dto/MessageHandlerVo.java | 5 ++- .../framework/message/dto/MessageVo.java | 6 ++- .../message/dto/TriggerMessageCountVo.java | 6 ++- .../dao/mapper/SystemNoticeMapper.java | 2 +- .../dao/mapper/SystemNoticeMapper.xml | 7 +++- .../dto/SystemNoticeRecipientVo.java | 5 ++- .../service/SystemNoticeServiceImpl.java | 37 ++++++++++--------- 9 files changed, 48 insertions(+), 28 deletions(-) diff --git a/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java b/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java index 270679736..84f311e2b 100644 --- a/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java +++ b/src/main/java/neatlogic/framework/dao/cache/NeatLogicConcurrentSafeCache.java @@ -141,8 +141,8 @@ public class NeatLogicConcurrentSafeCache implements Cache { } if (flag) { if (obj != null) { - if (LOCAL_LOCK_MAP.containsValue(lock)) { - logger.error("NeatLogicConcurrentSafeCache.LOCAL_LOCK_MAP中的锁对象没有被正常移除"); + if (LOCAL_LOCK_MAP.get(lockKey) == lock) { + logger.error("NeatLogicConcurrentSafeCache.LOCAL_LOCK_MAP中的锁对象没有被正常移除,lockKey = " + lockKey); } // 获取到锁后,从缓存中得到的结果不为null,不会再查询数据库,也不会调用putObject方法,所以要在这里释放该锁 lock.unlock(); @@ -157,6 +157,8 @@ public class NeatLogicConcurrentSafeCache implements Cache { lock.unlock(); } } + } else { + logger.error("NeatLogicConcurrentSafeCache 获取锁超时 lockKey = " + lockKey); } } return obj; diff --git a/src/main/java/neatlogic/framework/message/dao/mapper/MessageMapper.xml b/src/main/java/neatlogic/framework/message/dao/mapper/MessageMapper.xml index 0ed00da6c..1ad914f86 100755 --- a/src/main/java/neatlogic/framework/message/dao/mapper/MessageMapper.xml +++ b/src/main/java/neatlogic/framework/message/dao/mapper/MessageMapper.xml @@ -2,6 +2,8 @@ + + select `id`, @@ -132,7 +134,7 @@ where `system_notice_id` = #{value} - select distinct a.`id` from @@ -141,8 +143,9 @@ on a.`id` = b.`system_notice_id` where a.`status` = 'issued' + AND a.`id` NOT IN (SELECT `system_notice_id` FROM `system_notice_user` WHERE `user_uuid` = #{userUuid}) and b.`uuid` in - + #{item} diff --git a/src/main/java/neatlogic/framework/systemnotice/dto/SystemNoticeRecipientVo.java b/src/main/java/neatlogic/framework/systemnotice/dto/SystemNoticeRecipientVo.java index 8ce137470..3061c4696 100755 --- a/src/main/java/neatlogic/framework/systemnotice/dto/SystemNoticeRecipientVo.java +++ b/src/main/java/neatlogic/framework/systemnotice/dto/SystemNoticeRecipientVo.java @@ -3,6 +3,8 @@ package neatlogic.framework.systemnotice.dto; import neatlogic.framework.common.constvalue.ApiParamType; import neatlogic.framework.restful.annotation.EntityField; +import java.io.Serializable; + /** * @Title: SystemNoticeRecipientVo * @Package: neatlogic.framework.systemnotice.dto @@ -10,7 +12,8 @@ import neatlogic.framework.restful.annotation.EntityField; * @Author: laiwt * @Date: 2021/1/13 17:40 **/ -public class SystemNoticeRecipientVo{ +public class SystemNoticeRecipientVo implements Serializable { + private static final long serialVersionUID = 2910089979265665036L; @EntityField(name = "公告id", type = ApiParamType.LONG) private Long systemNoticeId; @EntityField(name = "通知对象uuid", type = ApiParamType.STRING) diff --git a/src/main/java/neatlogic/module/framework/systemnotice/service/SystemNoticeServiceImpl.java b/src/main/java/neatlogic/module/framework/systemnotice/service/SystemNoticeServiceImpl.java index 239f132ed..3241d2785 100644 --- a/src/main/java/neatlogic/module/framework/systemnotice/service/SystemNoticeServiceImpl.java +++ b/src/main/java/neatlogic/module/framework/systemnotice/service/SystemNoticeServiceImpl.java @@ -104,20 +104,21 @@ public class SystemNoticeServiceImpl implements SystemNoticeService, ISystemNoti @Override public void pullIssuedSystemNotice() { -// List recipientUuidList = getRecipientUuidList(); -// List issuedNoticeList = systemNoticeMapper.getIssuedNoticeIdListByRecipientUuidList(recipientUuidList); -// if (CollectionUtils.isNotEmpty(issuedNoticeList)) { -// List noticeUserVoList = new ArrayList<>(); -// for (Long id : issuedNoticeList) { -// noticeUserVoList.add(new SystemNoticeUserVo(id, UserContext.get().getUserUuid(true))); -// } -// systemNoticeMapper.batchInsertSystemNoticeUser(noticeUserVoList); -// } - String userUuid = UserContext.get().getUserUuid(); - List uuidList = UserContext.get().getUuidList(); - uuidList.add(userUuid); - uuidList.add(UserType.ALL.getValue()); - systemNoticeMapper.insertInsertSystemNoticeUser(userUuid, uuidList); + String userUuid = UserContext.get().getUserUuid(true); + List recipientUuidList = getRecipientUuidList(); + List issuedNoticeList = systemNoticeMapper.getIssuedNoticeIdListByUserUuidAndRecipientUuidList(userUuid, recipientUuidList); + if (CollectionUtils.isNotEmpty(issuedNoticeList)) { + List noticeUserVoList = new ArrayList<>(); + for (Long id : issuedNoticeList) { + noticeUserVoList.add(new SystemNoticeUserVo(id, userUuid)); + } + systemNoticeMapper.batchInsertSystemNoticeUser(noticeUserVoList); + } +// String userUuid = UserContext.get().getUserUuid(); +// List uuidList = UserContext.get().getUuidList(); +// uuidList.add(userUuid); +// uuidList.add(UserType.ALL.getValue()); +// systemNoticeMapper.insertInsertSystemNoticeUser(userUuid, uuidList); } @Override @@ -237,11 +238,11 @@ public class SystemNoticeServiceImpl implements SystemNoticeService, ISystemNoti } private List getRecipientUuidList() { - List uuidList = new ArrayList<>(); - uuidList.add(UserContext.get().getUserUuid(true)); + List uuidList = UserContext.get().getUuidList(); +// uuidList.add(UserContext.get().getUserUuid(true)); uuidList.add(UserType.ALL.getValue()); - uuidList.addAll(teamMapper.getTeamUuidListByUserUuid(UserContext.get().getUserUuid(true))); - uuidList.addAll(roleMapper.getRoleUuidListByUserUuid(UserContext.get().getUserUuid(true))); +// uuidList.addAll(teamMapper.getTeamUuidListByUserUuid(UserContext.get().getUserUuid(true))); +// uuidList.addAll(roleMapper.getRoleUuidListByUserUuid(UserContext.get().getUserUuid(true))); return uuidList; } } -- Gitee