修改业务类型对应的字符串等域配置有多个校验失败的问题
This commit is contained in:
@@ -175,8 +175,9 @@ public class CompileVal {
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
// if (configCompile.getIsValid() != 0 &&
|
||||
// !regionGroupIdList.contains(numRegion.getGroupId())) {
|
||||
|
||||
if (!StringUtil.isEmpty(numRegion.getTableName())&&!type2TableNameIsOk(configCompile.getService(), numRegion.getTableName())) {
|
||||
|
||||
if (!StringUtil.isEmpty(numRegion.getTableName())
|
||||
&& !type2TableNameIsOk(configCompile.getService(), numRegion.getTableName())) {
|
||||
return "配置id为" + configCompile.getCompileId() + "的配置中numRegionList中的regionid为"
|
||||
+ numRegion.getRegionId() + "的域配置tableName与编译配置业务类型不一致";
|
||||
}
|
||||
@@ -222,7 +223,8 @@ public class CompileVal {
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
// if (configCompile.getIsValid() != 0 &&
|
||||
// !regionGroupIdList.contains(strRegion.getGroupId())) {
|
||||
if (!StringUtil.isEmpty(strRegion.getTableName())&&!type2TableNameIsOk(configCompile.getService(), strRegion.getTableName())) {
|
||||
if (!StringUtil.isEmpty(strRegion.getTableName())
|
||||
&& !type2TableNameIsOk(configCompile.getService(), strRegion.getTableName())) {
|
||||
return "配置id为" + configCompile.getCompileId() + "的配置中strRegionList中的regionid为"
|
||||
+ strRegion.getRegionId() + "的域配置tableName与编译配置业务类型不一致";
|
||||
}
|
||||
@@ -270,7 +272,8 @@ public class CompileVal {
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
// if (configCompile.getIsValid() != 0 &&
|
||||
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
|
||||
if (!StringUtil.isEmpty(ipRegion.getTableName())&&!type2TableNameIsOk(configCompile.getService(), ipRegion.getTableName())) {
|
||||
if (!StringUtil.isEmpty(ipRegion.getTableName())
|
||||
&& !type2TableNameIsOk(configCompile.getService(), ipRegion.getTableName())) {
|
||||
return "配置id为" + configCompile.getCompileId() + "的配置中ipRegionList中的regionid为"
|
||||
+ ipRegion.getRegionId() + "的域配置tableName与编译配置业务类型不一致";
|
||||
}
|
||||
@@ -349,14 +352,15 @@ public class CompileVal {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<IpRegion> ipClientRangeList = configCompile.getIpClientRangeList();
|
||||
|
||||
if (ipClientRangeList != null && ipClientRangeList.size() > 0) {
|
||||
for (IpRegion ipRegion : ipClientRangeList) {
|
||||
// if (configCompile.getIsValid() != 0 &&
|
||||
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
|
||||
if (!StringUtil.isEmpty(ipRegion.getTableName())&&!type2TableNameIsOk(configCompile.getService(), ipRegion.getTableName())) {
|
||||
if (!StringUtil.isEmpty(ipRegion.getTableName())
|
||||
&& !type2TableNameIsOk(configCompile.getService(), ipRegion.getTableName())) {
|
||||
return "配置id为" + configCompile.getCompileId() + "的配置中ipClientRangeList中的regionid为"
|
||||
+ ipRegion.getRegionId() + "的域配置tableName与编译配置业务类型不一致";
|
||||
}
|
||||
@@ -406,10 +410,17 @@ public class CompileVal {
|
||||
public static boolean type2TableNameIsOk(Integer serviceType, String tableName) {
|
||||
if (null != serviceType && null != tableName && !tableName.equals("")) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
Map<Integer, String> sercieNameMap = ServiceAndRDBIndexReal.getSercieNameMap().get(serviceType);
|
||||
Map<Integer, List<String>> sercieNameMap = ServiceAndRDBIndexReal.getSercieNameMap().get(serviceType);
|
||||
if (sercieNameMap != null && sercieNameMap.size() > 0) {
|
||||
for (Integer type : sercieNameMap.keySet()) {
|
||||
list.add(sercieNameMap.get(type).toLowerCase());
|
||||
|
||||
List<String> tableList = sercieNameMap.get(type);
|
||||
if (tableList != null && tableList.size() > 0) {
|
||||
for (String table : tableList) {
|
||||
list.add(table.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -727,10 +738,10 @@ public class CompileVal {
|
||||
public static String serviceConfigCompileVal(ConfigCompile configCompile) {
|
||||
Long compileId = configCompile.getCompileId();
|
||||
Integer action = ServiceAndRDBIndexReal.getActionByService(configCompile.getService());
|
||||
if (StringUtil.isEmpty(action)){
|
||||
return "编译配置id为" + compileId + "的配置中service的值为"+configCompile.getService()+"时action不存在";
|
||||
}else if(action.compareTo(configCompile.getAction())!=0) {
|
||||
return "编译配置id为" + compileId + "的配置中service的值为"+configCompile.getService()+"时action只能为"+action;
|
||||
if (StringUtil.isEmpty(action)) {
|
||||
return "编译配置id为" + compileId + "的配置中service的值为" + configCompile.getService() + "时action不存在";
|
||||
} else if (action.compareTo(configCompile.getAction()) != 0) {
|
||||
return "编译配置id为" + compileId + "的配置中service的值为" + configCompile.getService() + "时action只能为" + action;
|
||||
}
|
||||
if (configCompile.getDoBlacklist() != 1) {
|
||||
return "编译配置id为" + compileId + "的配置中doBlacklist的值只能是1";
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ServiceAndRDBIndexReal {
|
||||
/**
|
||||
* 第一个key是业务类型,第二个key是type(编译配置,分组配置,域配置)value是表名
|
||||
*/
|
||||
private static Map<Integer, Map<Integer, String>> sercieNameMap = new HashMap<Integer, Map<Integer, String>>();
|
||||
private static Map<Integer, Map<Integer, List<String>>> sercieNameMap = new HashMap<Integer, Map<Integer, List<String>>>();
|
||||
|
||||
/**
|
||||
* 非maat结构业务类型与表名对应关系,key是业务类型,value是表名
|
||||
@@ -68,13 +68,20 @@ public class ServiceAndRDBIndexReal {
|
||||
serviceActionMap.put(Integer.valueOf(serviceAction[0]), Integer.valueOf(serviceAction[1]));
|
||||
String type = Configurations.getStringProperty(serviceAction[0], "");
|
||||
if (type != null && !type.trim().equals("")) {
|
||||
Map<Integer, String> typeMap = new HashMap<Integer, String>();
|
||||
Map<Integer, List<String>> typeMap = new HashMap<Integer, List<String>>();
|
||||
String[] typeArrs = type.split(";");
|
||||
for (String typeStr : typeArrs) {
|
||||
String[] typeArr = typeStr.split(":");
|
||||
int tableType = Integer.parseInt(typeArr[0]);
|
||||
String tableNameArr[] = typeArr[1].split(",");
|
||||
for (String tableName : tableNameArr) {
|
||||
typeMap.put(Integer.parseInt(typeArr[0]), tableName.toUpperCase());
|
||||
if (typeMap.containsKey(tableType)) {
|
||||
typeMap.get(tableType).add(tableName.toUpperCase());
|
||||
} else {
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add(tableName.toUpperCase());
|
||||
typeMap.put(tableType, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
sercieNameMap.put(Integer.parseInt(serviceAction[0]), typeMap);
|
||||
@@ -117,19 +124,23 @@ public class ServiceAndRDBIndexReal {
|
||||
* @return
|
||||
*/
|
||||
public static String getMaatTableName(int service, int type, String tableName) {
|
||||
Map<Integer, String> typeMap = sercieNameMap.get(service);
|
||||
Map<Integer, List<String>> typeMap = sercieNameMap.get(service);
|
||||
if (typeMap != null && typeMap.size() > 0) {
|
||||
List<String> tableList = typeMap.get(type);
|
||||
if (tableName == null || tableName.trim().equals("")) {
|
||||
return typeMap.get(type);
|
||||
if (tableList.size() > 1) {
|
||||
logger.error("未从业务类型和表对应关系中,找到业务类型:{},配置类型:{}表名:{}对应的真实表名", service, type, tableName);
|
||||
throw new RuntimeException("业务类型:"+service+",配置类型:"+type+"对应多个表,请输入具体的表名");
|
||||
} else {
|
||||
return tableList.get(0);
|
||||
}
|
||||
} else {
|
||||
String tableNames = typeMap.get(type);
|
||||
String[] split = tableNames.split(",");
|
||||
for (String str : split) {
|
||||
for (String str : tableList) {
|
||||
if (str.toLowerCase().contains(tableName.toLowerCase())) {
|
||||
return str;
|
||||
} else {
|
||||
logger.error(
|
||||
"未从业务类型和表对应关系中,找到业务类型:{},配置类型:{}表名:{}对应的真实表名",service,type,tableName);
|
||||
logger.error("未从业务类型和表对应关系中,找到业务类型:{},配置类型:{}表名:{}对应的真实表名", service, type, tableName);
|
||||
throw new RuntimeException("未从业务类型和表对应关系中,找到业务类型:"+service+",配置类型:"+type+"表名:"+tableName+"对应的真实表名");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,11 +167,12 @@ public class ServiceAndRDBIndexReal {
|
||||
return serviceActionMap.get(service);
|
||||
}
|
||||
|
||||
public static Map<Integer, Map<Integer, String>> getSercieNameMap() {
|
||||
|
||||
public static Map<Integer, Map<Integer, List<String>>> getSercieNameMap() {
|
||||
return sercieNameMap;
|
||||
}
|
||||
|
||||
public static void setSercieNameMap(Map<Integer, Map<Integer, String>> sercieNameMap) {
|
||||
public static void setSercieNameMap(Map<Integer, Map<Integer, List<String>>> sercieNameMap) {
|
||||
ServiceAndRDBIndexReal.sercieNameMap = sercieNameMap;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user