添加摘要类域配置
This commit is contained in:
@@ -20,6 +20,7 @@ import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigCompileTest;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.DigestRegion;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
@@ -84,15 +85,20 @@ public class ConfigSourcesService extends BaseService {
|
||||
typeMap.put("HID_CONTENT", "ip");
|
||||
typeMap.put("GSB_PZ_IP", "ip");
|
||||
typeMap.put("FAKE_REGION_EXTEND", "str");
|
||||
typeMap.put("CTRL_URL_REGION", "str");
|
||||
typeMap.put("CTRL_VOIP_BLACKACCOUNT_REGION", "str");
|
||||
typeMap.put("CTRL_MEDIA_FILE_FP", "digest");
|
||||
tableMap.put(0, typeMap);
|
||||
|
||||
typeMap = new HashMap<String, String>();
|
||||
typeMap.put("DF_IP_PORT", "ip");
|
||||
typeMap.put("GSB_PZ_IP", "ip");//IP复用
|
||||
tableMap.put(1, typeMap);
|
||||
|
||||
typeMap = new HashMap<String, String>();
|
||||
typeMap.put("FX_IP_PORT", "ip");
|
||||
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
||||
typeMap.put("GSB_PZ_IP", "ip");//网站伪造
|
||||
tableMap.put(2, typeMap);
|
||||
|
||||
typeMap = new HashMap<String, String>();
|
||||
@@ -100,12 +106,14 @@ public class ConfigSourcesService extends BaseService {
|
||||
typeMap.put("UNIVERSAL_IP", "ip");
|
||||
typeMap.put("DF_HTTP_REQ_HDR", "str");
|
||||
typeMap.put("DF_HTTP_URL", "str");
|
||||
typeMap.put("GSB_PZ_IP", "ip");//内容篡改
|
||||
tableMap.put(3, typeMap);
|
||||
|
||||
typeMap = new HashMap<String, String>();
|
||||
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
||||
typeMap.put("UNIVERSAL_IP", "ip");
|
||||
typeMap.put("DF_HTTP_RES_HDR", "str");
|
||||
typeMap.put("GSB_PZ_IP", "ip");//随机丢包
|
||||
tableMap.put(4, typeMap);
|
||||
|
||||
typeMap = new HashMap<String, String>();
|
||||
@@ -1033,7 +1041,7 @@ public class ConfigSourcesService extends BaseService {
|
||||
Map<String, List<StrRegion>> strStongRegionMap = new HashMap<String, List<StrRegion>>();
|
||||
Map<String, List<IpRegion>> ipRegionMap = new HashMap<String, List<IpRegion>>();
|
||||
Map<String, List<NumRegion>> numRegionMap = new HashMap<String, List<NumRegion>>();
|
||||
|
||||
Map<String, List<DigestRegion>> digestRegionMap = new HashMap<String, List<DigestRegion>>();
|
||||
for (ConfigCompile configCompile : configCompileList) {
|
||||
String msg = CompileVal.compileIsOk(configCompile, false, sb);
|
||||
if (msg != CompileJudgeCode.CompileIsOk.getErrorReason()) {
|
||||
@@ -1130,6 +1138,26 @@ public class ConfigSourcesService extends BaseService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
if (digestRegionMap.containsKey(digestRegion.getTableName())) {
|
||||
digestRegionMap.get(digestRegion.getTableName()).add(digestRegion);
|
||||
} else {
|
||||
List<DigestRegion> digestRegionList = new ArrayList<DigestRegion>();
|
||||
digestRegionList.add(digestRegion);
|
||||
digestRegionMap.put(digestRegion.getTableName(), digestRegionList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
||||
@@ -1152,6 +1180,10 @@ public class ConfigSourcesService extends BaseService {
|
||||
if (null != numRegionMap && numRegionMap.size() > 0) {
|
||||
count += numRegionMap.size();
|
||||
}
|
||||
|
||||
if (null != digestRegionMap && digestRegionMap.size() > 0) {
|
||||
count += digestRegionMap.size();
|
||||
}
|
||||
|
||||
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
Connection conn = sqlSessionFactory.openSession().getConnection();
|
||||
@@ -1208,6 +1240,16 @@ public class ConfigSourcesService extends BaseService {
|
||||
|
||||
}
|
||||
}
|
||||
if (digestRegionMap.size() > 0) {
|
||||
for (String digest : digestRegionMap.keySet()) {
|
||||
SaveCompileByJDBCThread digestRegion = new SaveCompileByJDBCThread(digest, conn, latch, start);
|
||||
digestRegion.setDigestRegionList(digestRegionMap.get(digest));
|
||||
Thread digestThread = new Thread(digestRegion);
|
||||
digestThread.start();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
latch.await();
|
||||
if (msgList.size() > 0) {
|
||||
@@ -1574,6 +1616,7 @@ public class ConfigSourcesService extends BaseService {
|
||||
Map<String, List<StrRegion>> strRegionMap = new HashMap<String, List<StrRegion>>();
|
||||
Map<String, List<IpRegion>> ipRegionMap = new HashMap<String, List<IpRegion>>();
|
||||
Map<String, List<NumRegion>> numRegionMap = new HashMap<String, List<NumRegion>>();
|
||||
Map<String, List<DigestRegion>> digestRegionMap = new HashMap<String, List<DigestRegion>>();
|
||||
if (null != compileList && compileList.size() > 0) {
|
||||
for (ConfigCompile config : compileList) {
|
||||
String msg = CompileVal.compileIsOk(config, true, sb);
|
||||
@@ -1637,6 +1680,21 @@ public class ConfigSourcesService extends BaseService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<DigestRegion> digestRegionList = config.getDigestRegionList();// 获取编译下所有摘要类域配置(要修改的数据
|
||||
if (null != digestRegionList && digestRegionList.size() > 0) {
|
||||
for (DigestRegion digestRegion : digestRegionList) {
|
||||
if (digestRegion.getIsValid() == 0) {
|
||||
if (digestRegionMap.containsKey(digestRegion.getTableName())) {
|
||||
digestRegionMap.get(digestRegion.getTableName()).add(digestRegion);
|
||||
} else {
|
||||
List<DigestRegion> digestList = new ArrayList<DigestRegion>();
|
||||
digestList.add(digestRegion);
|
||||
digestRegionMap.put(digestRegion.getTableName(), digestList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
compileAllList.add(config);
|
||||
}
|
||||
}
|
||||
@@ -1707,7 +1765,15 @@ public class ConfigSourcesService extends BaseService {
|
||||
numThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
if (null != digestRegionMap && digestRegionMap.size() > 0) {
|
||||
for (String num : digestRegionMap.keySet()) {
|
||||
UpdateCompileByJDBCThread digestRegion = new UpdateCompileByJDBCThread(num, conn, latch, start,
|
||||
opTime);
|
||||
digestRegion.setDigestRegionList(digestRegionMap.get(num));
|
||||
Thread digestThread = new Thread(digestRegion);
|
||||
digestThread.start();
|
||||
}
|
||||
}
|
||||
try {
|
||||
latch.await();
|
||||
if (msgList.size() > 0) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -12,11 +11,11 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.DigestRegion;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
import com.nis.util.Configurations;
|
||||
import com.thoughtworks.xstream.core.util.Fields;
|
||||
|
||||
/**
|
||||
* jdbc测试批量插入
|
||||
@@ -36,7 +35,7 @@ public class SaveCompileByJDBCThread implements Runnable {
|
||||
private List<IpRegion> ipRegionList;
|
||||
private List<NumRegion> numRegionList;
|
||||
private List<StrRegion> strRegionList;
|
||||
|
||||
private List<DigestRegion> digestRegionList;
|
||||
|
||||
private Method method = null;
|
||||
public SaveCompileByJDBCThread() {
|
||||
@@ -147,6 +146,14 @@ public class SaveCompileByJDBCThread implements Runnable {
|
||||
public void setStrRegionList(List<StrRegion> strRegionList) {
|
||||
this.strRegionList = strRegionList;
|
||||
}
|
||||
|
||||
public List<DigestRegion> getDigestRegionList() {
|
||||
return digestRegionList;
|
||||
}
|
||||
|
||||
public void setDigestRegionList(List<DigestRegion> digestRegionList) {
|
||||
this.digestRegionList = digestRegionList;
|
||||
}
|
||||
|
||||
public static java.sql.Timestamp utileDate2TimeStamp(java.util.Date udate) {
|
||||
java.sql.Timestamp sqlDate = null;
|
||||
@@ -524,6 +531,25 @@ public class SaveCompileByJDBCThread implements Runnable {
|
||||
// }
|
||||
}
|
||||
|
||||
public static void saveDigestRegion(String name, List<DigestRegion> digestRegionList, Connection conn,
|
||||
List<Exception> msgList) {
|
||||
if (null != digestRegionList && digestRegionList.size() > 0) {
|
||||
try {
|
||||
String fieldName = Configurations.getStringProperty("digestRegionFieldName", "REGION_ID");
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(getSqlStr(name, fieldName));
|
||||
for (DigestRegion numRegion : digestRegionList) {
|
||||
setPsParams(fieldName.split(","),ps,numRegion);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description:根据表名和字段名称构建sql
|
||||
@@ -625,6 +651,8 @@ public class SaveCompileByJDBCThread implements Runnable {
|
||||
}
|
||||
} else if (null != numRegionList && numRegionList.size() > 0) {
|
||||
saveNumRegion(tableName, numRegionList, conn, msgList);
|
||||
} else if (null != digestRegionList && digestRegionList.size() > 0) {
|
||||
saveDigestRegion(tableName, digestRegionList, conn, msgList);
|
||||
}
|
||||
latch.countDown();
|
||||
System.out.println("latchCount=======================" + latch.getCount());
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.DigestRegion;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
@@ -33,6 +34,7 @@ public class UpdateCompileByJDBCThread implements Runnable {
|
||||
private List<IpRegion> ipRegionList;
|
||||
private List<NumRegion> numRegionList;
|
||||
private List<StrRegion> strRegionList;
|
||||
private List<DigestRegion> digestRegionList;
|
||||
private Date opTime;
|
||||
|
||||
public UpdateCompileByJDBCThread() {
|
||||
@@ -136,6 +138,14 @@ public class UpdateCompileByJDBCThread implements Runnable {
|
||||
this.strRegionList = strRegionList;
|
||||
}
|
||||
|
||||
public List<DigestRegion> getDigestRegionList() {
|
||||
return digestRegionList;
|
||||
}
|
||||
|
||||
public void setDigestRegionList(List<DigestRegion> digestRegionList) {
|
||||
this.digestRegionList = digestRegionList;
|
||||
}
|
||||
|
||||
public synchronized static java.sql.Timestamp utileDate2TimeStamp(java.util.Date udate) {
|
||||
java.sql.Timestamp sqlDate = null;
|
||||
long t = udate.getTime();
|
||||
@@ -390,6 +400,55 @@ public class UpdateCompileByJDBCThread implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateDigestRegion(String name, List<DigestRegion> digestRegionList, Connection conn, Date opTime,
|
||||
List<Exception> msgList) {
|
||||
if (null != digestRegionList && digestRegionList.size() > 0) {
|
||||
try {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String fieldName = Configurations.getStringProperty("updateFields", "IS_VALID");
|
||||
String condition = Configurations.getStringProperty("regionId", "REGION_ID");
|
||||
sb.append("update ");
|
||||
sb.append(name);
|
||||
sb.append(" set ");
|
||||
|
||||
String fieldNameObj [] = fieldName.split(",");
|
||||
//加上where条件的参数名称
|
||||
String newParamsStr = fieldName+","+condition;
|
||||
for (int i = 0; i < fieldNameObj.length; i++) {
|
||||
sb.append(fieldNameObj[i]+"=?");
|
||||
if (i+1<fieldNameObj.length) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
|
||||
//是否包含更新时间字段 值为数据库当前时间
|
||||
if (Configurations.getBooleanProperty("hasLastUpdate", true)) {
|
||||
sb.append(", LAST_UPDATE= sysdate");
|
||||
}
|
||||
// + "where GROUP_ID=? and COMPILE_ID=? ");
|
||||
sb.append(" where ");
|
||||
String [] condObjs = condition.split(",");
|
||||
for (int i = 0; i < condObjs.length; i++) {
|
||||
sb.append(condObjs[i]+"=?");
|
||||
if (i+1<condObjs.length) {
|
||||
sb.append(" and ");
|
||||
}
|
||||
}
|
||||
|
||||
conn.setAutoCommit(false);
|
||||
PreparedStatement ps = conn.prepareStatement(sb.toString());
|
||||
for (DigestRegion digestRegion : digestRegionList) {
|
||||
setPsParams(newParamsStr.split(","), ps, digestRegion);
|
||||
ps.addBatch();
|
||||
}
|
||||
ps.executeBatch();
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
msgList.add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @Description: 向PreparedStatement设置参数
|
||||
* @author (zdx)
|
||||
@@ -488,6 +547,8 @@ public class UpdateCompileByJDBCThread implements Runnable {
|
||||
updateStrRegion(tableName, strRegionList, conn, opTime, msgList);
|
||||
} else if (null != numRegionList && numRegionList.size() > 0) {
|
||||
updateNumRegion(tableName, numRegionList, conn, opTime, msgList);
|
||||
} else if (null != digestRegionList && digestRegionList.size() > 0) {
|
||||
updateDigestRegion(tableName, digestRegionList, conn, opTime, msgList);
|
||||
}
|
||||
|
||||
if((null !=compileList && compileList.size() > 0)&&(null != groupList && groupList.size()==0)){
|
||||
|
||||
Reference in New Issue
Block a user