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