1: 判断公共组下面是否有域配置,没有域配置时就不往下面下发了,避免添加版本号

2:在取消普通类配置时判断当需要保留的groupid为空时继续执行
This commit is contained in:
renkaige
2019-01-15 20:37:53 +06:00
parent ee5698f6cf
commit e4be9d82af
2 changed files with 38 additions and 9 deletions

View File

@@ -1137,8 +1137,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
if (groupAndCompileStr != null && !groupAndCompileStr.trim().equals("")) {
String compileId = getRegionInfo(groupAndCompileStr);// COMPILEGROUP:24070
if (compileId != null && !compileId.trim().equals("")) {
if (isStart || (keepGroupId != null && keepGroupId.size() > 0
&& !keepGroupId.contains(Long.parseLong(groupIdReal)))) {
if (isStart || keepGroupId == null || keepGroupId.size() == 0
|| (keepGroupId != null && keepGroupId.size() > 0
&& !keepGroupId.contains(Long.parseLong(groupIdReal)))) {
// 如果是生效则根据关联关系将组下的域都改为生效
// 如果是失效并且当前组不是需要保留的组,则将该组下的域置为失效
if (compileId.equals(compileStr)) {// 判断编译id是否一致
@@ -2296,7 +2297,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
if (groupIdAndregionIdMap != null && groupIdAndregionIdMap.size() > 0) {
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
transaction.select(idRelaRedisDBIndex);
//获取需要删除的regionkey
// 获取需要删除的regionkey
Set<String> set = new HashSet<>();
Set<Long> groupIdSet = groupIdAndregionIdMap.keySet();
for (Long groupId : groupIdSet) {
@@ -2310,12 +2311,12 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
String[] keyAndDBArr = org.apache.commons.lang.StringUtils.split(regionKey, ";");
for (String keyAndDB : keyAndDBArr) {
String key = keyAndDB.substring(0, keyAndDB.indexOf("-"));
String regionId = key.substring(keyAndDB.indexOf(",")+1);
if(regionId!=null&&!regionId.trim().equals("")) {
if(regionSet.contains(Long.parseLong(regionId))) {
String regionId = key.substring(keyAndDB.indexOf(",") + 1);
if (regionId != null && !regionId.trim().equals("")) {
if (regionSet.contains(Long.parseLong(regionId))) {
set.add(key);
}
}else {
} else {
throw new ServiceRuntimeException("获取公共组下面域配置的id,域配置的key为" + key + ",请检查数据是否正确",
RestBusinessCode.CommonGroupIsNotExist.getValue());
}
@@ -2348,7 +2349,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
transaction.exec();
return true;
} else {
throw new ServiceRuntimeException("删除公共组中域配置时,参数为空,请检查", RestBusinessCode.ConfigSourceIsNull.getValue());
throw new ServiceRuntimeException("删除公共组中域配置时,参数为空,请检查",
RestBusinessCode.ConfigSourceIsNull.getValue());
}

View File

@@ -126,6 +126,10 @@ public class ConfigSourcesService extends BaseService {
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
// 公共组的groupid
Set<Long> commonGroupIdSet = new HashSet<>();
// 判断公共组下面是否有域配置,没有域配置时就不往下面下发了,避免添加版本号
boolean isHaveCommonRegion = false;
for (ConfigCompile configCompile : configCompileList) {
Integer service = Integer.valueOf(configCompile.getService().toString());
MaatConfig maatConfig = new MaatConfig();
@@ -152,6 +156,11 @@ public class ConfigSourcesService extends BaseService {
if (!StringUtil.isEmpty(configCompile.getStrRegionList())) {
dstMaplList = new ArrayList<Map<String, String>>();
for (StrRegion region : configCompile.getStrRegionList()) {
if (commonGroupIdSet.contains(region.getGroupId())) {
isHaveCommonRegion = true;
}
if (StringUtil.isEmpty(region.getDistrict())) {
dstMaplList.add(convertObjectToMap(region, StrRegion.class));
} else {
@@ -172,6 +181,9 @@ public class ConfigSourcesService extends BaseService {
if (!StringUtil.isEmpty(configCompile.getNumRegionList())) {
dstMaplList = new ArrayList<Map<String, String>>();
for (NumRegion region : configCompile.getNumRegionList()) {
if (commonGroupIdSet.contains(region.getGroupId())) {
isHaveCommonRegion = true;
}
dstMaplList.add(convertObjectToMap(region, NumRegion.class));
}
}
@@ -182,6 +194,9 @@ public class ConfigSourcesService extends BaseService {
if (!StringUtil.isEmpty(configCompile.getIpRegionList())) {
dstMaplList = new ArrayList<Map<String, String>>();
for (IpRegion region : configCompile.getIpRegionList()) {
if (commonGroupIdSet.contains(region.getGroupId())) {
isHaveCommonRegion = true;
}
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
}
}
@@ -192,6 +207,9 @@ public class ConfigSourcesService extends BaseService {
if (!StringUtil.isEmpty(configCompile.getDigestRegionList())) {
dstMaplList = new ArrayList<Map<String, String>>();
for (DigestRegion region : configCompile.getDigestRegionList()) {
if (commonGroupIdSet.contains(region.getGroupId())) {
isHaveCommonRegion = true;
}
dstMaplList.add(convertObjectToMap(region, DigestRegion.class));
}
}
@@ -207,6 +225,9 @@ public class ConfigSourcesService extends BaseService {
if (!StringUtil.isEmpty(configCompile.getIpClientRangeList())) {
dstMaplList = new ArrayList<Map<String, String>>();
for (IpRegion region : configCompile.getIpClientRangeList()) {
if (commonGroupIdSet.contains(region.getGroupId())) {
isHaveCommonRegion = true;
}
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
}
}
@@ -258,7 +279,13 @@ public class ConfigSourcesService extends BaseService {
}
}
logger.info("---------------调用Redis maat配置新增接口---------------------");
configRedisService.saveMaatConfig(configMap, new ArrayList<>(commonGroupIdSet));
if (isHaveCommonRegion) {
configRedisService.saveMaatConfig(configMap, new ArrayList<>(commonGroupIdSet));
} else {
configRedisService.saveMaatConfig(configMap, new ArrayList<Long>());//下层有直接使用的地方,不可直接传入null
}
}
/**