From 7589b5a6b2d771bd42416fd8ce445bb058ce0edb Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 24 Feb 2022 17:23:19 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/commons/tools/redis/RedisKeys.java | 3 +++ .../src/main/java/com/epmet/redis/GovMenuRedis.java | 11 ++++++++++- .../com/epmet/service/impl/GovMenuServiceImpl.java | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index fe03008b81..876cc61ccd 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -733,4 +733,7 @@ public class RedisKeys { return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId); } + public static String getCustomerMenuList(String customerId, Integer type) { + return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId)+type; + } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java index 361d6c3014..8f6a61da6c 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java @@ -71,4 +71,13 @@ public class GovMenuRedis { return (Set)redisUtils.get(key); } -} \ No newline at end of file + public void setCustomerMenuList(String customerId, Integer type, List govMenuDTOS) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + redisUtils.set(key,govMenuDTOS,RedisUtils.DEFAULT_EXPIRE); + } + + public List getCustomerMenuList(String customerId, Integer type) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + return (List)redisUtils.get(key); + } +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java index 4e4c142b55..8eb3bcf5e2 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java @@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.*; @@ -208,9 +209,15 @@ public class GovMenuServiceImpl extends BaseServiceImpl getCustomerMenuList(String customerId, Integer type) { + List govMenuDTOS = govMenuRedis.getCustomerMenuList(customerId,type); + if (!CollectionUtils.isEmpty(govMenuDTOS)){ + return govMenuDTOS; + } List menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage()); List dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); - return TreeUtils.buildTree(dtoList); + govMenuDTOS = TreeUtils.buildTree(dtoList); + govMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS); + return govMenuDTOS; } @Override From 5d9828085ccbf592f44f973282de0a5354421b4b Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 25 Feb 2022 10:32:13 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=85=8D=E7=BD=AEpc=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=97=B6=20=E5=88=A0=E9=99=A4=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/redis/RedisKeys.java | 2 +- .../com/epmet/redis/GovCustomerMenuRedis.java | 57 ++++++++++++++++--- .../java/com/epmet/redis/GovMenuRedis.java | 10 ---- .../impl/GovCustomerMenuServiceImpl.java | 6 +- .../service/impl/GovMenuServiceImpl.java | 8 +-- 5 files changed, 59 insertions(+), 24 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 876cc61ccd..0798627046 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -734,6 +734,6 @@ public class RedisKeys { } public static String getCustomerMenuList(String customerId, Integer type) { - return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId)+type; + return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId).concat(":type:")+type; } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java index 2333a6bd48..3cc19b8ae2 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java @@ -17,31 +17,72 @@ package com.epmet.redis; +import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisUtils; +import com.epmet.dto.GovMenuDTO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.List; + /** * 客户菜单配置表 * * @author generator generator@elink-cn.com * @since v1.0.0 2021-03-16 */ +@Slf4j @Component public class GovCustomerMenuRedis { @Autowired private RedisUtils redisUtils; - - public void delete(Object[] ids) { - + /** + * desc:保存客户菜单缓存 + * @param customerId + * @param type + * @see com.epmet.enums.MenuTypeEnum + */ + public void setCustomerMenuList(String customerId, Integer type, List govMenuDTOS) { + if (checkParam(customerId, type)) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + redisUtils.set(key, govMenuDTOS, RedisUtils.DEFAULT_EXPIRE); + } + } + /** + * desc:获取客户菜单缓存 + * @param customerId + * @param type + * @see com.epmet.enums.MenuTypeEnum + */ + public List getCustomerMenuList(String customerId, Integer type) { + if (checkParam(customerId, type)) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + return (List) redisUtils.get(key); + } + return null; } - public void set(){ + /** + * desc:删除客户菜单缓存 + * @param customerId + * @param type + * @see com.epmet.enums.MenuTypeEnum + */ + public void delCustomerMenu(String customerId, Integer type) { + if (checkParam(customerId, type)) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + redisUtils.delete(key); + } } - public String get(String id){ - return null; + private boolean checkParam(String customerId, Integer type) { + if (StringUtils.isBlank(customerId) || type == null){ + log.warn("checkParam fail, param is null"); + return false; + } + return true; } - -} \ No newline at end of file +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java index 8f6a61da6c..b96405de2e 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java @@ -70,14 +70,4 @@ public class GovMenuRedis { String key = RedisKeys.getUserPermissionsKey(userId, app, client); return (Set)redisUtils.get(key); } - - public void setCustomerMenuList(String customerId, Integer type, List govMenuDTOS) { - String key = RedisKeys.getCustomerMenuList(customerId, type); - redisUtils.set(key,govMenuDTOS,RedisUtils.DEFAULT_EXPIRE); - } - - public List getCustomerMenuList(String customerId, Integer type) { - String key = RedisKeys.getCustomerMenuList(customerId, type); - return (List)redisUtils.get(key); - } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java index 8d7ef26acc..95e4f2f8d2 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java @@ -20,14 +20,15 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.GovCustomerMenuDao; import com.epmet.dto.GovCustomerMenuDTO; import com.epmet.dto.form.MenuConfigFormDTO; import com.epmet.entity.GovCustomerMenuEntity; +import com.epmet.enums.MenuTypeEnum; import com.epmet.redis.GovCustomerMenuRedis; import com.epmet.service.GovCustomerMenuService; import org.apache.commons.lang3.StringUtils; @@ -105,6 +106,7 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl govCustomerMenuRedis.delCustomerMenu(customerId, MenuTypeEnum.MENU.value())); } @Override diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java index 8eb3bcf5e2..eb9467e926 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java @@ -33,7 +33,7 @@ import com.epmet.dao.GovMenuDao; import com.epmet.dto.GovMenuDTO; import com.epmet.entity.GovMenuEntity; import com.epmet.enums.MenuTypeEnum; -import com.epmet.feign.EpmetUserFeignClient; +import com.epmet.redis.GovCustomerMenuRedis; import com.epmet.redis.GovMenuRedis; import com.epmet.service.*; import org.apache.commons.lang3.StringUtils; @@ -58,7 +58,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl getCustomerMenuList(String customerId, Integer type) { - List govMenuDTOS = govMenuRedis.getCustomerMenuList(customerId,type); + List govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type); if (!CollectionUtils.isEmpty(govMenuDTOS)){ return govMenuDTOS; } List menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage()); List dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); govMenuDTOS = TreeUtils.buildTree(dtoList); - govMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS); + govCustomerMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS); return govMenuDTOS; } From 321a7bcb43be195bad2eef71a7b61369b08bf1f6 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 25 Feb 2022 14:37:54 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=BA=A7=E5=88=AB?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java index 6ce851a45e..868c6e0185 100644 --- a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/interceptor/ScanApiAuthInterceptor.java @@ -33,7 +33,7 @@ public class ScanApiAuthInterceptor implements HandlerInterceptor { String ip = IpUtils.getIpAddr(request); SetOperations setOperations = redisTemplate.opsForSet(); if (!setOperations.isMember(RedisKeys.getWhiteList(), ip)) { - log.warn("preHandle ip:{} is not in whitelist", ip); + log.error("preHandle ip:{} 不在白名单内", ip); String result = JSON.toJSONString(new Result<>().error(EpmetErrorCode.ERR401.getCode(), EpmetErrorCode.ERR401.getMsg())); responseJson(response, result); return false; From 9919509c6fb70966943c2253c07ccf2649430551 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 25 Feb 2022 15:23:00 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=8C=AA=E8=B5=B0=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/commons/tools/filter/LogMsgSendFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java index d0ba1f61de..9f6be36819 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/filter/LogMsgSendFilter.java @@ -66,6 +66,7 @@ public class LogMsgSendFilter extends LevelFilter { } if (StringUtils.isNotBlank(activeEnv)) { + stringBuilder.append("告警环境:").append(activeEnv); stringBuilder.append("\n"); } @@ -112,7 +113,6 @@ public class LogMsgSendFilter extends LevelFilter { if (!flag) { logger.warn("msgSender.sendMsg fail,param:{}", stringBuilder.toString()); } - stringBuilder.append("告警环境:").append(activeEnv); } catch (Exception e) { logger.warn("decide exception", e); } From a6ca2de18f549edc1e04c41a54d654adfc04bcde Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Fri, 25 Feb 2022 17:28:36 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BB=93=E6=A1=88?= =?UTF-8?q?=E6=97=B6=E5=8F=AA=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AE=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=B8=8E=E8=80=97=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ProjectServiceImpl.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index e6e70e2c73..6a591d9e8d 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -453,10 +453,12 @@ public class ProjectServiceImpl extends BaseServiceImpl Date: Fri, 25 Feb 2022 17:37:22 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8F=98=E5=8A=A8=20up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/mq/ProjectChangedCustomListener.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java index c4c0138ad0..a096dc3307 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg; import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; @@ -111,12 +112,19 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently String customerId = msgObj.getCustomerId(); distributedLock = SpringContextUtils.getBean(DistributedLock.class); lock = distributedLock.getLock(String.format("lock:project_changed:%s:%s", customerId, msgObj.getProjectId()) - ,30L, 30L, TimeUnit.SECONDS); + ,60L, 60L, TimeUnit.SECONDS); if (StringUtils.isBlank(customerId)){ logger.error("consumer project_changed fail,msg:{}",customerId); return; } + //睡一秒 要不然那边执行不完 + try { + Thread.sleep(NumConstant.ONE_THOUSAND); + } catch (InterruptedException e) { + log.error("consumeMessage exception",e); + } + ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO(); extractOriginFormDTO.setCustomerId(customerId);