diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java index edeb7ef2..825d5097 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/ConfigCacheService.java @@ -68,6 +68,23 @@ public class ConfigCacheService { return Objects.equals(contentMd5, md5); } + /** + * check TpId. + * + * @param groupKey + * @param tpId + * @param clientIdentify + * @return + */ + public static boolean checkTpId(String groupKey, String tpId, String clientIdentify) { + Map cacheItemMap = Optional.ofNullable(CLIENT_CONFIG_CACHE.get(groupKey)).orElse(new HashMap<>()); + CacheItem cacheItem; + if (CollectionUtil.isNotEmpty(cacheItemMap) && (cacheItem = cacheItemMap.get(clientIdentify)) != null) { + return Objects.equals(tpId, cacheItem.configAllInfo.getTpId()); + } + return Boolean.FALSE; + } + /** * Get Md5. * diff --git a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/HisRunDataServiceImpl.java b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/HisRunDataServiceImpl.java index 1c4c93af..3e97ef57 100644 --- a/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/HisRunDataServiceImpl.java +++ b/hippo4j-config/src/main/java/cn/hippo4j/config/service/biz/impl/HisRunDataServiceImpl.java @@ -32,6 +32,7 @@ import cn.hippo4j.config.model.biz.monitor.MonitorActiveRespDTO; import cn.hippo4j.config.model.biz.monitor.MonitorQueryReqDTO; import cn.hippo4j.config.model.biz.monitor.MonitorRespDTO; import cn.hippo4j.config.monitor.QueryMonitorExecuteChoose; +import cn.hippo4j.config.service.ConfigCacheService; import cn.hippo4j.config.service.biz.HisRunDataService; import cn.hippo4j.common.toolkit.BeanUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -150,11 +151,14 @@ public class HisRunDataServiceImpl extends ServiceImpl { HisRunDataInfo hisRunDataInfo = BeanUtil.convert(each, HisRunDataInfo.class); String[] parseKey = GroupKey.parseKey(each.getGroupKey()); - hisRunDataInfo.setTpId(parseKey[0]); - hisRunDataInfo.setItemId(parseKey[1]); - hisRunDataInfo.setTenantId(parseKey[2]); - hisRunDataInfo.setInstanceId(parseKey[3]); - hisRunDataInfos.add(hisRunDataInfo); + boolean checkFlag = ConfigCacheService.checkTpId(each.getGroupKey(), parseKey[0], parseKey[3]); + if (checkFlag) { + hisRunDataInfo.setTpId(parseKey[0]); + hisRunDataInfo.setItemId(parseKey[1]); + hisRunDataInfo.setTenantId(parseKey[2]); + hisRunDataInfo.setInstanceId(parseKey[3]); + hisRunDataInfos.add(hisRunDataInfo); + } }); this.saveBatch(hisRunDataInfos); }