修改maat通用配置存储接口
This commit is contained in:
@@ -47,11 +47,11 @@ public class ConfigCompile implements Serializable {
|
|||||||
@ApiModelProperty(value = "保障期", required = false)
|
@ApiModelProperty(value = "保障期", required = false)
|
||||||
private Integer guaranteeId;
|
private Integer guaranteeId;
|
||||||
@ApiModelProperty(value = "事件", required = false)
|
@ApiModelProperty(value = "事件", required = false)
|
||||||
private Integer affAirId;
|
private Integer affairId;
|
||||||
@ApiModelProperty(value = "子话题", required = false)
|
@ApiModelProperty(value = "子话题", required = false)
|
||||||
private Integer topIcId;
|
private Integer topicId;
|
||||||
@ApiModelProperty(value = "是否黑名单", required = true)
|
@ApiModelProperty(value = "是否黑名单", required = true)
|
||||||
private Long doBlackList;
|
private Long doBlacklist;
|
||||||
@ApiModelProperty(value = "是否生成日志", required = true)
|
@ApiModelProperty(value = "是否生成日志", required = true)
|
||||||
private Integer doLog;
|
private Integer doLog;
|
||||||
@ApiModelProperty(value = "生效范围", required = true)
|
@ApiModelProperty(value = "生效范围", required = true)
|
||||||
@@ -180,16 +180,16 @@ public class ConfigCompile implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* @return doBlackList
|
* @return doBlackList
|
||||||
*/
|
*/
|
||||||
public Long getDoBlackList() {
|
public Long getDoBlacklist() {
|
||||||
return doBlackList;
|
return doBlacklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param doBlackList
|
* @param doBlackList
|
||||||
* 要设置的 doBlackList
|
* 要设置的 doBlackList
|
||||||
*/
|
*/
|
||||||
public void setDoBlackList(Long doBlackList) {
|
public void setDoBlacklist(Long doBlacklist) {
|
||||||
this.doBlackList = doBlackList;
|
this.doBlacklist = doBlacklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -445,20 +445,20 @@ public class ConfigCompile implements Serializable {
|
|||||||
this.guaranteeId = guaranteeId;
|
this.guaranteeId = guaranteeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getAffAirId() {
|
public Integer getAffairId() {
|
||||||
return affAirId;
|
return affairId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAffAirId(Integer affAirId) {
|
public void setAffairId(Integer affairId) {
|
||||||
this.affAirId = affAirId;
|
this.affairId = affairId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getTopIcId() {
|
public Integer getTopicId() {
|
||||||
return topIcId;
|
return topicId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTopIcId(Integer topIcId) {
|
public void setTopicId(Integer topicId) {
|
||||||
this.topIcId = topIcId;
|
this.topicId = topicId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
|
|||||||
56
src/main/java/com/nis/util/CamelUnderlineUtil.java
Normal file
56
src/main/java/com/nis/util/CamelUnderlineUtil.java
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.nis.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName:CamelUnderlineUtil
|
||||||
|
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||||
|
* @author (zdx)
|
||||||
|
* @date 2018年5月25日 下午4:44:54
|
||||||
|
* @version V1.0
|
||||||
|
*/
|
||||||
|
public class CamelUnderlineUtil {
|
||||||
|
|
||||||
|
private static final char UNDERLINE ='_';
|
||||||
|
public static String camelToUnderline(String param) {
|
||||||
|
|
||||||
|
if (StringUtil.isEmpty(param)) {
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int len = param.length();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
char c = param.charAt(i);
|
||||||
|
if (Character.isUpperCase(c)) {
|
||||||
|
sb.append(UNDERLINE);
|
||||||
|
sb.append(Character.toLowerCase(c));
|
||||||
|
} else {
|
||||||
|
sb.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String underlineToCamel(String param){
|
||||||
|
|
||||||
|
if (StringUtil.isEmpty(param)) {
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int len = param.length();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
char c = param.charAt(i);
|
||||||
|
if (c==UNDERLINE) {
|
||||||
|
if(++i<len){
|
||||||
|
sb.append(Character.toUpperCase(param.charAt(i)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sb.append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -447,8 +447,8 @@ public class CompileJudge {
|
|||||||
if (null == configCompile.getAction()) {
|
if (null == configCompile.getAction()) {
|
||||||
return "id为" + compileId + "的编译配置中action不能为空";
|
return "id为" + compileId + "的编译配置中action不能为空";
|
||||||
}
|
}
|
||||||
if (null == configCompile.getDoBlackList()) {
|
if (null == configCompile.getDoBlacklist()) {
|
||||||
return "id为" + compileId + "的编译配置中doBlackList不能为空";
|
return "id为" + compileId + "的编译配置中doBlacklist不能为空";
|
||||||
}
|
}
|
||||||
if (null == configCompile.getDoLog()) {
|
if (null == configCompile.getDoLog()) {
|
||||||
return "id为" + compileId + "的编译配置中doLog不能为空";
|
return "id为" + compileId + "的编译配置中doLog不能为空";
|
||||||
|
|||||||
@@ -423,8 +423,8 @@ public class CompileVal {
|
|||||||
if (null == configCompile.getAction()) {
|
if (null == configCompile.getAction()) {
|
||||||
return "id为" + compileId + "的编译配置中action不能为空";
|
return "id为" + compileId + "的编译配置中action不能为空";
|
||||||
}
|
}
|
||||||
if (null == configCompile.getDoBlackList()) {
|
if (null == configCompile.getDoBlacklist()) {
|
||||||
return "id为" + compileId + "的编译配置中doBlackList不能为空";
|
return "id为" + compileId + "的编译配置中doBlacklist不能为空";
|
||||||
}
|
}
|
||||||
if (null == configCompile.getDoLog()) {
|
if (null == configCompile.getDoLog()) {
|
||||||
return "id为" + compileId + "的编译配置中doLog不能为空";
|
return "id为" + compileId + "的编译配置中doLog不能为空";
|
||||||
@@ -686,8 +686,8 @@ public class CompileVal {
|
|||||||
&& configCompile.getAction() != 6 && configCompile.getAction() != 7) {
|
&& configCompile.getAction() != 6 && configCompile.getAction() != 7) {
|
||||||
return "编译配置id为" + compileId + "的配置中action的值只能是1(阻断),2(监测),5(封堵白名单),6(监测白名单),7(封堵监测都白名单)";
|
return "编译配置id为" + compileId + "的配置中action的值只能是1(阻断),2(监测),5(封堵白名单),6(监测白名单),7(封堵监测都白名单)";
|
||||||
}
|
}
|
||||||
if (configCompile.getDoBlackList() != 1) {
|
if (configCompile.getDoBlacklist() != 1) {
|
||||||
return "编译配置id为" + compileId + "的配置中doBlackList的值只能是1";
|
return "编译配置id为" + compileId + "的配置中doBlacklist的值只能是1";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configCompile.getDoLog() != 0 && configCompile.getDoLog() != 1 && configCompile.getDoLog() != 2) {
|
if (configCompile.getDoLog() != 0 && configCompile.getDoLog() != 1 && configCompile.getDoLog() != 2) {
|
||||||
|
|||||||
@@ -219,30 +219,7 @@ public class ConfigSourcesController extends BaseRestController {
|
|||||||
// 验证配置编译数据
|
// 验证配置编译数据
|
||||||
validateConfigSource(thread, start, configSource);
|
validateConfigSource(thread, start, configSource);
|
||||||
Long benginTime = System.currentTimeMillis();
|
Long benginTime = System.currentTimeMillis();
|
||||||
String msg = configSourcesService.saveByJDBCThread(thread, start, configSource.getConfigCompileList(), sb);
|
configSourcesService.saveMaatConfig(thread, start, configSource.getConfigCompileList(), sb);
|
||||||
if (msg.equals("error")) {
|
|
||||||
String errorCode = "";
|
|
||||||
Exception exception = ConfigSourcesService.getMsgList().get(0);
|
|
||||||
String str = exception.getMessage();
|
|
||||||
if (null != str && str.length() > 0) {
|
|
||||||
int index = str.toUpperCase().indexOf("ORA-");
|
|
||||||
if (index != -1) {
|
|
||||||
errorCode = str.substring(index + 4, index + 9);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil.throwExceptionInfo(errorCode);
|
|
||||||
for (int errorNum : throwExceptionInfo.keySet()) {
|
|
||||||
if (errorNum == 998) {
|
|
||||||
thread.setExceptionInfo(exception.toString());
|
|
||||||
} else {
|
|
||||||
thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
|
|
||||||
}
|
|
||||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
||||||
throwExceptionInfo.get(errorNum), errorNum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// configSourcesService.insertConfigSourceData(thread, start,
|
|
||||||
// configSource.getConfigCompileList(), sb);
|
|
||||||
|
|
||||||
Long endSaveTime = System.currentTimeMillis();
|
Long endSaveTime = System.currentTimeMillis();
|
||||||
Long time = (endSaveTime - benginTime) / 1000;
|
Long time = (endSaveTime - benginTime) / 1000;
|
||||||
|
|||||||
@@ -584,9 +584,9 @@ public class ConfigTestController extends BaseRestController {
|
|||||||
configCompile.setContLabel("0");
|
configCompile.setContLabel("0");
|
||||||
configCompile.setTaskId(0);
|
configCompile.setTaskId(0);
|
||||||
configCompile.setGuaranteeId(0);
|
configCompile.setGuaranteeId(0);
|
||||||
configCompile.setAffAirId(0);
|
configCompile.setAffairId(0);
|
||||||
configCompile.setTopIcId(0);
|
configCompile.setTopicId(0);
|
||||||
configCompile.setDoBlackList(0l);
|
configCompile.setDoBlacklist(0l);
|
||||||
configCompile.setDoLog(0);
|
configCompile.setDoLog(0);
|
||||||
configCompile.setEffectiveRange("0");
|
configCompile.setEffectiveRange("0");
|
||||||
configCompile.setConfigPercent(100l);
|
configCompile.setConfigPercent(100l);
|
||||||
|
|||||||
@@ -243,9 +243,9 @@ public class SaveConfigTestController extends BaseRestController {
|
|||||||
configCompile.setContLabel("0");
|
configCompile.setContLabel("0");
|
||||||
configCompile.setTaskId(0);
|
configCompile.setTaskId(0);
|
||||||
configCompile.setGuaranteeId(0);
|
configCompile.setGuaranteeId(0);
|
||||||
configCompile.setAffAirId(0);
|
configCompile.setAffairId(0);
|
||||||
configCompile.setTopIcId(0);
|
configCompile.setTopicId(0);
|
||||||
configCompile.setDoBlackList(1l);
|
configCompile.setDoBlacklist(1l);
|
||||||
configCompile.setDoLog(0);
|
configCompile.setDoLog(0);
|
||||||
configCompile.setEffectiveRange("0");
|
configCompile.setEffectiveRange("0");
|
||||||
configCompile.setConfigPercent(100l);
|
configCompile.setConfigPercent(100l);
|
||||||
|
|||||||
@@ -279,8 +279,8 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
maatKey = keyBF.toString();
|
maatKey = keyBF.toString();
|
||||||
// System.out.println(keyBF.toString());
|
System.out.println(keyBF.toString());
|
||||||
// System.out.println(valBF.toString());
|
System.out.println(valBF.toString());
|
||||||
redisTemplate.opsForValue().set(maatKey.toUpperCase(), valBF.toString());
|
redisTemplate.opsForValue().set(maatKey.toUpperCase(), valBF.toString());
|
||||||
// redisTemplate.boundValueOps(keyBF.toString()).set(valBF.toString());
|
// redisTemplate.boundValueOps(keyBF.toString()).set(valBF.toString());
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
package com.nis.web.service.restful;
|
package com.nis.web.service.restful;
|
||||||
|
|
||||||
|
import java.beans.IntrospectionException;
|
||||||
|
import java.beans.PropertyDescriptor;
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
@@ -34,12 +40,14 @@ import com.nis.domain.restful.ConfigCompileTest;
|
|||||||
import com.nis.domain.restful.ConfigGroupRelation;
|
import com.nis.domain.restful.ConfigGroupRelation;
|
||||||
import com.nis.domain.restful.DigestRegion;
|
import com.nis.domain.restful.DigestRegion;
|
||||||
import com.nis.domain.restful.IpRegion;
|
import com.nis.domain.restful.IpRegion;
|
||||||
|
import com.nis.domain.restful.MaatConfig;
|
||||||
import com.nis.domain.restful.NumRegion;
|
import com.nis.domain.restful.NumRegion;
|
||||||
import com.nis.domain.restful.StrRegion;
|
import com.nis.domain.restful.StrRegion;
|
||||||
import com.nis.restful.CompileJudgeCode;
|
import com.nis.restful.CompileJudgeCode;
|
||||||
import com.nis.restful.RestBusinessCode;
|
import com.nis.restful.RestBusinessCode;
|
||||||
import com.nis.restful.RestServiceException;
|
import com.nis.restful.RestServiceException;
|
||||||
import com.nis.util.BasicProvingUtil;
|
import com.nis.util.BasicProvingUtil;
|
||||||
|
import com.nis.util.CamelUnderlineUtil;
|
||||||
import com.nis.util.CompileVal;
|
import com.nis.util.CompileVal;
|
||||||
import com.nis.util.Configurations;
|
import com.nis.util.Configurations;
|
||||||
import com.nis.util.OracleErrorCodeUtil;
|
import com.nis.util.OracleErrorCodeUtil;
|
||||||
@@ -100,6 +108,36 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
public static Map<Integer, Map<String, String>> getTableRelation() {
|
public static Map<Integer, Map<String, String>> getTableRelation() {
|
||||||
Map<Integer, Map<String, String>> tableMap = new HashMap<Integer, Map<String, String>>();
|
Map<Integer, Map<String, String>> tableMap = new HashMap<Integer, Map<String, String>>();
|
||||||
Map<String, String> typeMap = new HashMap<String, String>();
|
Map<String, String> typeMap = new HashMap<String, String>();
|
||||||
|
typeMap.put("AV_CONT_IP_PORT", "ip");
|
||||||
|
tableMap.put(80, typeMap);
|
||||||
|
tableMap.put(144, typeMap);
|
||||||
|
|
||||||
|
typeMap = new HashMap<String, String>();
|
||||||
|
typeMap.put("AV_CONT_URL", "str");
|
||||||
|
tableMap.put(81, typeMap);
|
||||||
|
tableMap.put(145, typeMap);
|
||||||
|
|
||||||
|
typeMap = new HashMap<String, String>();
|
||||||
|
typeMap.put("AV_PIC_IP_PORT", "ip");
|
||||||
|
tableMap.put(82, typeMap);
|
||||||
|
tableMap.put(146, typeMap);
|
||||||
|
|
||||||
|
typeMap = new HashMap<String, String>();
|
||||||
|
typeMap.put("AV_PIC_URL", "str");
|
||||||
|
tableMap.put(83, typeMap);
|
||||||
|
tableMap.put(147, typeMap);
|
||||||
|
|
||||||
|
typeMap = new HashMap<String, String>();
|
||||||
|
typeMap.put("AV_VoIP_IP_PORT", "ip");
|
||||||
|
tableMap.put(84, typeMap);
|
||||||
|
tableMap.put(148, typeMap);
|
||||||
|
|
||||||
|
typeMap = new HashMap<String, String>();
|
||||||
|
typeMap.put("AV_VoIP_ACCOUNT", "str");
|
||||||
|
tableMap.put(85, typeMap);
|
||||||
|
tableMap.put(149, typeMap);
|
||||||
|
|
||||||
|
typeMap = new HashMap<String, String>();
|
||||||
typeMap.put("REUSE_IP", "ip");
|
typeMap.put("REUSE_IP", "ip");
|
||||||
typeMap.put("HID_CONTENT", "ip");
|
typeMap.put("HID_CONTENT", "ip");
|
||||||
typeMap.put("GSB_PZ_IP", "ip");
|
typeMap.put("GSB_PZ_IP", "ip");
|
||||||
@@ -1056,11 +1094,220 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
this.map = map;
|
this.map = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/**
|
/**
|
||||||
* jdbc方式添加和修改
|
*
|
||||||
|
* @Description:
|
||||||
|
* @author (zdx)
|
||||||
|
* @date 2018年5月25日 下午3:49:46
|
||||||
|
* @param thread
|
||||||
|
* @param start
|
||||||
|
* @param configCompileList
|
||||||
|
* @param sb
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
public String saveMaatConfig(SaveRequestLogThread thread, long start, List<ConfigCompile> configCompileList,
|
||||||
|
StringBuffer sb) {
|
||||||
|
List<MaatConfig> maatConfigList = new ArrayList<MaatConfig>();
|
||||||
|
List<Integer> serviceList = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
for (ConfigCompile configCompile : configCompileList) {
|
||||||
|
serviceList.add(Integer.valueOf(configCompile.getService().toString()));
|
||||||
|
MaatConfig maatConfig = new MaatConfig();
|
||||||
|
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
|
||||||
|
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
|
||||||
|
List<StrRegion> strStrongRegionList = new ArrayList<StrRegion>();
|
||||||
|
List<IpRegion> ipRegionList =new ArrayList<IpRegion>();
|
||||||
|
List<NumRegion> numRegionList = new ArrayList<NumRegion>();
|
||||||
|
List<DigestRegion> digestRegionList = new ArrayList<DigestRegion>();
|
||||||
|
String msg = CompileVal.compileIsOk(configCompile, false, sb);
|
||||||
|
if (msg != CompileJudgeCode.CompileIsOk.getErrorReason()) {
|
||||||
|
logger1.error(msg);
|
||||||
|
thread.setExceptionInfo(msg + sb.toString());
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg + sb.toString(),
|
||||||
|
RestBusinessCode.config_integrity_error.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (null != configCompile.getGroupRelationList() && configCompile.getGroupRelationList().size() > 0) {
|
||||||
|
groupRelationList.addAll(configCompile.getGroupRelationList());
|
||||||
|
} else {
|
||||||
|
logger1.error("配置分组数量不能为空" + sb.toString());
|
||||||
|
thread.setExceptionInfo("配置分组数量不能为空" + sb.toString());
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "配置分组数量不能为空" + sb.toString(),
|
||||||
|
RestBusinessCode.missing_args.getValue());
|
||||||
|
}
|
||||||
|
if (null != configCompile.getStrRegionList() && configCompile.getStrRegionList().size() > 0) {
|
||||||
|
for (StrRegion strRegion : configCompile.getStrRegionList()) {
|
||||||
|
if (!isStrStrongRegion(strRegion.getTableName())) {
|
||||||
|
if (strRegion.getRegionId() == null) {
|
||||||
|
String errorMsg = "字符类域配置id不能为空 ,表名---" + strRegion.getTableName() + "" + sb.toString();
|
||||||
|
logger1.error(errorMsg);
|
||||||
|
thread.setExceptionInfo(errorMsg);
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
|
||||||
|
RestBusinessCode.missing_args.getValue());
|
||||||
|
}
|
||||||
|
strRegionList.add(strRegion);
|
||||||
|
} else {
|
||||||
|
if (strRegion.getRegionId() == null) {
|
||||||
|
String errorMsg = "增强字符类域配置id不能为空 ,表名---" + strRegion.getTableName() + "" + sb.toString();
|
||||||
|
logger1.error(errorMsg);
|
||||||
|
thread.setExceptionInfo(errorMsg);
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
|
||||||
|
RestBusinessCode.missing_args.getValue());
|
||||||
|
}
|
||||||
|
strStrongRegionList.add(strRegion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != configCompile.getIpRegionList() && configCompile.getIpRegionList().size() > 0) {
|
||||||
|
for (IpRegion ipRegion : configCompile.getIpRegionList()) {
|
||||||
|
if (!ipRegion.getTableName().toUpperCase().equals("DJ_IP_PORT")) {
|
||||||
|
ipRegion.setProtocol(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ipRegion.getRegionId() == null) {
|
||||||
|
String errorMsg = "ip类域配置id不能为空 ,表名---" + ipRegion.getTableName() + "" + sb.toString();
|
||||||
|
logger1.error(errorMsg);
|
||||||
|
thread.setExceptionInfo(errorMsg);
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
|
||||||
|
RestBusinessCode.missing_args.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
ipRegionList.add(ipRegion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != configCompile.getNumRegionList() && configCompile.getNumRegionList().size() > 0) {
|
||||||
|
for (NumRegion numRegion : configCompile.getNumRegionList()) {
|
||||||
|
if (numRegion.getRegionId() == null) {
|
||||||
|
String errorMsg = "数值类域配置id不能为空 ,表名---" + numRegion.getTableName() + "" + sb.toString();
|
||||||
|
logger1.error(errorMsg);
|
||||||
|
thread.setExceptionInfo(errorMsg);
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
|
||||||
|
RestBusinessCode.missing_args.getValue());
|
||||||
|
}
|
||||||
|
numRegionList.add(numRegion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (null != configCompile.getDigestRegionList() && configCompile.getDigestRegionList().size() > 0) {
|
||||||
|
for (DigestRegion digestRegion : configCompile.getDigestRegionList()) {
|
||||||
|
if (digestRegion.getRegionId() == null) {
|
||||||
|
String errorMsg = "摘要类域配置id不能为空 ,表名---" + digestRegion.getTableName() + "" + sb.toString();
|
||||||
|
logger1.error(errorMsg);
|
||||||
|
thread.setExceptionInfo(errorMsg);
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
|
||||||
|
RestBusinessCode.missing_args.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
digestRegionList.add(digestRegion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
maatConfig.setService(Integer.valueOf(configCompile.getService().toString()));
|
||||||
|
//编译
|
||||||
|
maatConfig.setCompileMap(convertObjectToMap(configCompile, ConfigCompile.class));
|
||||||
|
//分组
|
||||||
|
List<Map<String, String>> dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(groupRelationList)) {
|
||||||
|
dstMaplList = new ArrayList<Map<String,String>>();
|
||||||
|
for (ConfigGroupRelation group : groupRelationList) {
|
||||||
|
dstMaplList.add(convertObjectToMap(group, ConfigGroupRelation.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setGroupMapList(dstMaplList);
|
||||||
|
//字符串域
|
||||||
|
dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(strRegionList)) {
|
||||||
|
dstMaplList = new ArrayList<Map<String,String>>();
|
||||||
|
for (StrRegion region : strRegionList) {
|
||||||
|
dstMaplList.add(convertObjectToMap(region, StrRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setStrRegionMapList(dstMaplList);
|
||||||
|
//增强字符串域
|
||||||
|
dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(strStrongRegionList)) {
|
||||||
|
dstMaplList = new ArrayList<Map<String,String>>();
|
||||||
|
for (StrRegion region : strStrongRegionList) {
|
||||||
|
dstMaplList.add(convertObjectToMap(region, StrRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setStrStrRegionMapList((dstMaplList));
|
||||||
|
//数值域
|
||||||
|
dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(numRegionList)) {
|
||||||
|
dstMaplList = new ArrayList<Map<String,String>>();
|
||||||
|
for (NumRegion region : numRegionList) {
|
||||||
|
dstMaplList.add(convertObjectToMap(region, NumRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setNumRegionMapList(dstMaplList);
|
||||||
|
|
||||||
|
//Ip域
|
||||||
|
dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(ipRegionList)) {
|
||||||
|
dstMaplList = new ArrayList<Map<String,String>>();
|
||||||
|
for (IpRegion region : ipRegionList) {
|
||||||
|
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maatConfig.setIpRegionMapList(dstMaplList);
|
||||||
|
|
||||||
|
//摘要类域
|
||||||
|
dstMaplList = null;
|
||||||
|
if (!StringUtil.isEmpty(digestRegionList)) {
|
||||||
|
dstMaplList = new ArrayList<Map<String,String>>();
|
||||||
|
for (DigestRegion region : digestRegionList) {
|
||||||
|
dstMaplList.add(convertObjectToMap(region, DigestRegion.class));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
maatConfig.setFileDigestRegionMapList(dstMaplList);
|
||||||
|
dstMaplList = null;
|
||||||
|
//文本相似性域
|
||||||
|
maatConfig.setFileLikeRegionMapList(dstMaplList);
|
||||||
|
maatConfigList.add(maatConfig);
|
||||||
|
}
|
||||||
|
if (!StringUtil.isEmpty(serviceList)&&serviceList.size()!=1) {
|
||||||
|
String errorMsg = "只能添加单一service配置信息列表";
|
||||||
|
logger1.error(errorMsg);
|
||||||
|
thread.setExceptionInfo(errorMsg);
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
|
||||||
|
RestBusinessCode.op_action_error.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
//调用接口入redis
|
||||||
|
configRedisService.saveMaatConfig(maatConfigList, serviceList.get(0));
|
||||||
|
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
|
private Map<String, String> convertObjectToMap(Object obj,Class clazz){
|
||||||
|
Map<String,String> dstMap = new HashMap<String, String>();
|
||||||
|
try {
|
||||||
|
Field[] fields= obj.getClass().getDeclaredFields();
|
||||||
|
for (Field field : fields) {
|
||||||
|
if("serialVersionUID".equals(field.getName()))
|
||||||
|
continue;
|
||||||
|
String dstName = CamelUnderlineUtil.camelToUnderline(field.getName());
|
||||||
|
PropertyDescriptor pd;
|
||||||
|
pd = new PropertyDescriptor(field.getName(), clazz);
|
||||||
|
Method method = pd.getReadMethod();
|
||||||
|
Object dstObject = method.invoke(obj);
|
||||||
|
if (dstObject instanceof Date) {
|
||||||
|
dstObject = convertToTimeStamp16((Date)dstObject);
|
||||||
|
}if(dstObject instanceof ArrayList){
|
||||||
|
dstObject = "";
|
||||||
|
}
|
||||||
|
dstMap.put(dstName, StringUtil.isEmpty(dstObject)?"":dstObject.toString());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
logger1.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return dstMap;
|
||||||
|
}
|
||||||
public String saveByJDBCThread(SaveRequestLogThread thread, long start, List<ConfigCompile> configCompileList,
|
public String saveByJDBCThread(SaveRequestLogThread thread, long start, List<ConfigCompile> configCompileList,
|
||||||
StringBuffer sb) {
|
StringBuffer sb) {
|
||||||
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
|
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
|
||||||
@@ -1186,7 +1433,7 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (null != configCompileList && configCompileList.size() > 0) {
|
if (null != configCompileList && configCompileList.size() > 0) {
|
||||||
@@ -1298,6 +1545,12 @@ public class ConfigSourcesService extends BaseService {
|
|||||||
}
|
}
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String convertToTimeStamp16(Date date){
|
||||||
|
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
return date.getTime()+"000";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class JDBCTest {
|
|||||||
count++;
|
count++;
|
||||||
Object[] obj = new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
Object[] obj = new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(), compile.getDoBlackList(),
|
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(), compile.getDoBlacklist(),
|
||||||
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
||||||
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
||||||
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() };
|
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() };
|
||||||
|
|||||||
@@ -181,8 +181,8 @@ public class JDBCThreadTest implements Runnable {
|
|||||||
count++;
|
count++;
|
||||||
Object[] obj = new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
Object[] obj = new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(),
|
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(),
|
||||||
compile.getDoBlackList(), compile.getDoLog(), compile.getEffectiveRange(),
|
compile.getDoBlacklist(), compile.getDoLog(), compile.getEffectiveRange(),
|
||||||
compile.getActiveSys(), compile.getConfigPercent(), compile.getConfigOption(),
|
compile.getActiveSys(), compile.getConfigPercent(), compile.getConfigOption(),
|
||||||
compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(), compile.getIsValid(),
|
compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(), compile.getIsValid(),
|
||||||
compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() };
|
compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() };
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class SpringJDBCTest {
|
|||||||
for (ConfigCompile compile : compileList) {
|
for (ConfigCompile compile : compileList) {
|
||||||
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(), compile.getDoBlackList(),
|
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(), compile.getDoBlacklist(),
|
||||||
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
||||||
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
||||||
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
|
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class SpringJDBCThreadTest implements Runnable {
|
|||||||
for (ConfigCompile compile : compileList) {
|
for (ConfigCompile compile : compileList) {
|
||||||
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(), compile.getDoBlackList(),
|
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(), compile.getDoBlacklist(),
|
||||||
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
||||||
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
||||||
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
|
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class SpringJDBCThreadTest2 implements Runnable {
|
|||||||
for (ConfigCompile compile : compileList) {
|
for (ConfigCompile compile : compileList) {
|
||||||
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
|
||||||
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
|
||||||
compile.getGuaranteeId(), compile.getAffAirId(), compile.getTopIcId(), compile.getDoBlackList(),
|
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(), compile.getDoBlacklist(),
|
||||||
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
|
||||||
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
|
||||||
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
|
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
|
||||||
|
|||||||
@@ -47,12 +47,12 @@
|
|||||||
|
|
||||||
<p:maatType service="80;82;84;144;146;148">
|
<p:maatType service="80;82;84;144;146;148">
|
||||||
<p:expressions>
|
<p:expressions>
|
||||||
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[cfg_id]</p:keyExpression>
|
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[compile_id]</p:keyExpression>
|
||||||
<p:valueExpression>[cfg_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
|
<p:valueExpression>[compile_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
|
||||||
</p:expressions>
|
</p:expressions>
|
||||||
<p:expressions>
|
<p:expressions>
|
||||||
<p:keyExpression>EFFECTIVE_RULE;:;{group_table_name};,;[group_id]</p:keyExpression>
|
<p:keyExpression>EFFECTIVE_RULE;:;{group_table_name};,;[group_id]</p:keyExpression>
|
||||||
<p:valueExpression>[group_id];\t;[cfg_id];\t;[is_valid];\t;[op_time]</p:valueExpression>
|
<p:valueExpression>[group_id];\t;[compile_id];\t;[is_valid];\t;[op_time]</p:valueExpression>
|
||||||
</p:expressions>
|
</p:expressions>
|
||||||
<p:expressions>
|
<p:expressions>
|
||||||
<p:keyExpression>EFFECTIVE_RULE;:;{ip_region_table_name};,;[region_id]</p:keyExpression>
|
<p:keyExpression>EFFECTIVE_RULE;:;{ip_region_table_name};,;[region_id]</p:keyExpression>
|
||||||
|
|||||||
Reference in New Issue
Block a user