mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-30 09:48:43 +08:00 
			
		
		
		
	Merge remote-tracking branch 'origin/master' into dev
This commit is contained in:
		| @@ -53,7 +53,6 @@ public class YudaoMQAutoConfiguration { | |||||||
|      * 创建 Redis Pub/Sub 广播消费的容器 |      * 创建 Redis Pub/Sub 广播消费的容器 | ||||||
|      */ |      */ | ||||||
|     @Bean |     @Bean | ||||||
|     @Async // 异步化,可降低 2 秒左右的启动时间 |  | ||||||
|     public RedisMessageListenerContainer redisMessageListenerContainer( |     public RedisMessageListenerContainer redisMessageListenerContainer( | ||||||
|             RedisMQTemplate redisMQTemplate, List<AbstractChannelMessageListener<?>> listeners) { |             RedisMQTemplate redisMQTemplate, List<AbstractChannelMessageListener<?>> listeners) { | ||||||
|         // 创建 RedisMessageListenerContainer 对象 |         // 创建 RedisMessageListenerContainer 对象 | ||||||
|   | |||||||
| @@ -86,11 +86,30 @@ public class MenuServiceImpl implements MenuService { | |||||||
|     @Override |     @Override | ||||||
|     @PostConstruct |     @PostConstruct | ||||||
|     public synchronized void initLocalCache() { |     public synchronized void initLocalCache() { | ||||||
|         // 获取菜单列表,如果有更新 |         initLocalCacheIfUpdate(null); | ||||||
|         List<MenuDO> menuList = this.loadMenuIfUpdate(maxUpdateTime); |     } | ||||||
|         if (CollUtil.isEmpty(menuList)) { |  | ||||||
|  |     @Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD) | ||||||
|  |     public void schedulePeriodicRefresh() { | ||||||
|  |         initLocalCacheIfUpdate(this.maxUpdateTime); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 刷新本地缓存 | ||||||
|  |      * | ||||||
|  |      * @param maxUpdateTime 最大更新时间 | ||||||
|  |      *                      1. 如果 maxUpdateTime 为 null,则“强制”刷新缓存 | ||||||
|  |      *                      2. 如果 maxUpdateTime 不为 null,判断自 maxUpdateTime 是否有数据发生变化,有的情况下才刷新缓存 | ||||||
|  |      */ | ||||||
|  |     private void initLocalCacheIfUpdate(LocalDateTime maxUpdateTime) { | ||||||
|  |         // 如果没有增量的数据变化,则不进行本地缓存的刷新 | ||||||
|  |         if (maxUpdateTime != null | ||||||
|  |             && menuMapper.selectCountByUpdateTimeGt(maxUpdateTime) == 0) { | ||||||
|  |             log.info("[initLocalCacheIfUpdate][数据未发生变化({}),本地缓存不刷新]", maxUpdateTime); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |         List<MenuDO> menuList = menuMapper.selectList(); | ||||||
|  |         log.info("[initLocalCacheIfUpdate][缓存菜单,数量为:{}]", menuList.size()); | ||||||
|  |  | ||||||
|         // 构建缓存 |         // 构建缓存 | ||||||
|         ImmutableMap.Builder<Long, MenuDO> menuCacheBuilder = ImmutableMap.builder(); |         ImmutableMap.Builder<Long, MenuDO> menuCacheBuilder = ImmutableMap.builder(); | ||||||
| @@ -103,34 +122,9 @@ public class MenuServiceImpl implements MenuService { | |||||||
|         }); |         }); | ||||||
|         menuCache = menuCacheBuilder.build(); |         menuCache = menuCacheBuilder.build(); | ||||||
|         permissionMenuCache = permMenuCacheBuilder.build(); |         permissionMenuCache = permMenuCacheBuilder.build(); | ||||||
|         maxUpdateTime = CollectionUtils.getMaxValue(menuList, MenuDO::getUpdateTime); |  | ||||||
|         log.info("[initLocalCache][缓存菜单,数量为:{}]", menuList.size()); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD) |         // 设置最新的 maxUpdateTime,用于下次的增量判断 | ||||||
|     public void schedulePeriodicRefresh() { |         this.maxUpdateTime = CollectionUtils.getMaxValue(menuList, MenuDO::getUpdateTime); | ||||||
|         initLocalCache(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * 如果菜单发生变化,从数据库中获取最新的全量菜单。 |  | ||||||
|      * 如果未发生变化,则返回空 |  | ||||||
|      * |  | ||||||
|      * @param maxUpdateTime 当前菜单的最大更新时间 |  | ||||||
|      * @return 菜单列表 |  | ||||||
|      */ |  | ||||||
|     private List<MenuDO> loadMenuIfUpdate(LocalDateTime maxUpdateTime) { |  | ||||||
|         // 第一步,判断是否要更新。 |  | ||||||
|         if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据 |  | ||||||
|             log.info("[loadMenuIfUpdate][首次加载全量菜单]"); |  | ||||||
|         } else { // 判断数据库中是否有更新的菜单 |  | ||||||
|             if (menuMapper.selectCountByUpdateTimeGt(maxUpdateTime) == 0) { |  | ||||||
|                 return null; |  | ||||||
|             } |  | ||||||
|             log.info("[loadMenuIfUpdate][增量加载全量菜单]"); |  | ||||||
|         } |  | ||||||
|         // 第二步,如果有更新,则从数据库加载所有菜单 |  | ||||||
|         return menuMapper.selectList(); |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|   | |||||||
| @@ -1,6 +1,5 @@ | |||||||
| package cn.iocoder.yudao.module.shop.controller.app; | package cn.iocoder.yudao.module.shop.controller.app; | ||||||
|  |  | ||||||
| import cn.hutool.core.date.LocalDateTimeUtil; |  | ||||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||||
| import cn.iocoder.yudao.module.pay.service.notify.vo.PayNotifyOrderReqVO; | import cn.iocoder.yudao.module.pay.service.notify.vo.PayNotifyOrderReqVO; | ||||||
| import cn.iocoder.yudao.module.pay.service.notify.vo.PayRefundOrderReqVO; | import cn.iocoder.yudao.module.pay.service.notify.vo.PayRefundOrderReqVO; | ||||||
| @@ -20,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController; | |||||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||||
| import javax.validation.Valid; | import javax.validation.Valid; | ||||||
| import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||||
| import java.time.temporal.ChronoUnit; |  | ||||||
|  |  | ||||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||||
| import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; | import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; | ||||||
|   | |||||||
| @@ -151,12 +151,14 @@ logging: | |||||||
|     # 配置自己写的 MyBatis Mapper 打印日志 |     # 配置自己写的 MyBatis Mapper 打印日志 | ||||||
|     cn.iocoder.yudao.module.bpm.dal.mysql: debug |     cn.iocoder.yudao.module.bpm.dal.mysql: debug | ||||||
|     cn.iocoder.yudao.module.infra.dal.mysql: debug |     cn.iocoder.yudao.module.infra.dal.mysql: debug | ||||||
|  |     cn.iocoder.yudao.module.infra.dal.mysql.job.JobLogMapper: INFO # 配置 JobLogMapper 的日志级别为 info | ||||||
|     cn.iocoder.yudao.module.pay.dal.mysql: debug |     cn.iocoder.yudao.module.pay.dal.mysql: debug | ||||||
|     cn.iocoder.yudao.module.system.dal.mysql: debug |     cn.iocoder.yudao.module.system.dal.mysql: debug | ||||||
|     cn.iocoder.yudao.module.tool.dal.mysql: debug |     cn.iocoder.yudao.module.tool.dal.mysql: debug | ||||||
|     cn.iocoder.yudao.module.member.dal.mysql: debug |     cn.iocoder.yudao.module.member.dal.mysql: debug | ||||||
|     cn.iocoder.yudao.module.trade.dal.mysql: debug |     cn.iocoder.yudao.module.trade.dal.mysql: debug | ||||||
|     cn.iocoder.yudao.module.promotion.dal.mysql: debug |     cn.iocoder.yudao.module.promotion.dal.mysql: debug | ||||||
|  |  | ||||||
| debug: false | debug: false | ||||||
|  |  | ||||||
| --- #################### 微信公众号、小程序相关配置 #################### | --- #################### 微信公众号、小程序相关配置 #################### | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 xingyu
					xingyu