2017-12-19 14:55:52 +08:00
|
|
|
|
package com.nis.web.service.restful;
|
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.ibatis.session.ExecutorType;
|
|
|
|
|
|
import org.apache.ibatis.session.SqlSession;
|
|
|
|
|
|
import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
|
import com.nis.domain.restful.ConfigCompile;
|
|
|
|
|
|
import com.nis.domain.restful.ConfigCompileTest;
|
|
|
|
|
|
import com.nis.domain.restful.ConfigGroupRelation;
|
2018-02-28 10:13:39 +08:00
|
|
|
|
import com.nis.domain.restful.DigestRegion;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
import com.nis.domain.restful.IpRegion;
|
|
|
|
|
|
import com.nis.domain.restful.NumRegion;
|
|
|
|
|
|
import com.nis.domain.restful.StrRegion;
|
|
|
|
|
|
import com.nis.restful.CompileJudgeCode;
|
|
|
|
|
|
import com.nis.restful.RestBusinessCode;
|
|
|
|
|
|
import com.nis.restful.RestServiceException;
|
|
|
|
|
|
import com.nis.util.CompileVal;
|
|
|
|
|
|
import com.nis.util.Configurations;
|
|
|
|
|
|
import com.nis.util.OracleErrorCodeUtil;
|
|
|
|
|
|
import com.nis.util.StringUtil;
|
|
|
|
|
|
import com.nis.util.StringUtils;
|
|
|
|
|
|
import com.nis.web.dao.ConfigCompileDao;
|
|
|
|
|
|
import com.nis.web.dao.ConfigGroupRelationDao;
|
|
|
|
|
|
import com.nis.web.dao.IpRegionDao;
|
|
|
|
|
|
import com.nis.web.dao.NumRegionDao;
|
|
|
|
|
|
import com.nis.web.dao.StrRegionDao;
|
|
|
|
|
|
import com.nis.web.service.BaseService;
|
|
|
|
|
|
import com.nis.web.service.SaveRequestLogThread;
|
|
|
|
|
|
import com.nis.web.service.SpringContextHolder;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @ClassName: ControlService
|
|
|
|
|
|
* @Description: TODO(编译配置持久化)
|
|
|
|
|
|
* @author (zx)
|
|
|
|
|
|
* @date 2016年9月6日 下午1:08:12
|
|
|
|
|
|
* @version V1.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class ConfigSourcesService extends BaseService {
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 存放多线程异常信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
private static List<Exception> msgList = new ArrayList<Exception>();
|
|
|
|
|
|
|
|
|
|
|
|
public static List<Exception> getMsgList() {
|
|
|
|
|
|
return msgList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void setMsgList(List<Exception> msgList) {
|
|
|
|
|
|
ConfigSourcesService.msgList = msgList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected final Logger logger1 = Logger.getLogger(this.getClass());
|
|
|
|
|
|
private Map<Integer, Map<String, String>> map;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ConfigCompileDao configCompileDao;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IpRegionDao ipRegionDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private NumRegionDao numRegionDao;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ConfigGroupRelationDao configGroupRelationDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private StrRegionDao strRegionDao;
|
|
|
|
|
|
|
|
|
|
|
|
public static Map<Integer, Map<String, String>> getTableRelation() {
|
|
|
|
|
|
Map<Integer, Map<String, String>> tableMap = new HashMap<Integer, Map<String, String>>();
|
|
|
|
|
|
Map<String, String> typeMap = new HashMap<String, String>();
|
2018-02-09 17:49:14 +08:00
|
|
|
|
typeMap.put("REUSE_IP", "ip");
|
|
|
|
|
|
typeMap.put("HID_CONTENT", "ip");
|
|
|
|
|
|
typeMap.put("GSB_PZ_IP", "ip");
|
|
|
|
|
|
typeMap.put("FAKE_REGION_EXTEND", "str");
|
2018-03-29 10:34:23 +08:00
|
|
|
|
typeMap.put("KEYWORD_RANDOM_REGION", "str");
|
2018-02-28 10:13:39 +08:00
|
|
|
|
typeMap.put("CTRL_URL_REGION", "str");
|
|
|
|
|
|
typeMap.put("CTRL_VOIP_BLACKACCOUNT_REGION", "str");
|
|
|
|
|
|
typeMap.put("CTRL_MEDIA_FILE_FP", "digest");
|
2018-02-09 17:49:14 +08:00
|
|
|
|
tableMap.put(0, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
typeMap.put("DF_IP_PORT", "ip");
|
2018-02-28 10:13:39 +08:00
|
|
|
|
typeMap.put("GSB_PZ_IP", "ip");//IP复用
|
2018-03-29 10:34:23 +08:00
|
|
|
|
typeMap.put("CTRL_MEDIA_FILE_FP", "digest");
|
2017-12-19 14:55:52 +08:00
|
|
|
|
tableMap.put(1, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("FX_IP_PORT", "ip");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
2018-02-28 10:13:39 +08:00
|
|
|
|
typeMap.put("GSB_PZ_IP", "ip");//网站伪造
|
2017-12-19 14:55:52 +08:00
|
|
|
|
tableMap.put(2, typeMap);
|
|
|
|
|
|
|
2018-03-29 10:34:23 +08:00
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("CTRL_VOIP_BLACKACCOUNT_REGION", "str");
|
|
|
|
|
|
tableMap.put(118, typeMap);
|
|
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DF_HTTP_REQ_HDR", "str");
|
|
|
|
|
|
typeMap.put("DF_HTTP_URL", "str");
|
2018-02-28 10:13:39 +08:00
|
|
|
|
typeMap.put("GSB_PZ_IP", "ip");//内容篡改
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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");
|
2018-02-28 10:13:39 +08:00
|
|
|
|
typeMap.put("GSB_PZ_IP", "ip");//随机丢包
|
2018-03-29 10:34:23 +08:00
|
|
|
|
typeMap.put("CTRL_URL_REGION", "str");
|
2017-12-19 14:55:52 +08:00
|
|
|
|
tableMap.put(4, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DF_HTTP_REQ_BODY", "str");
|
|
|
|
|
|
typeMap.put("DF_HTTP_RES_BODY", "str");
|
|
|
|
|
|
tableMap.put(5, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DF_MAIL_HDR", "str");
|
|
|
|
|
|
typeMap.put("DF_MAIL_BODY", "str");
|
|
|
|
|
|
tableMap.put(13, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DF_DNS_REGION", "str");
|
|
|
|
|
|
tableMap.put(6, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DF_FTP_URL", "str");
|
|
|
|
|
|
tableMap.put(14, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
tableMap.put(7, typeMap);
|
|
|
|
|
|
tableMap.put(8, typeMap);
|
|
|
|
|
|
tableMap.put(9, typeMap);
|
|
|
|
|
|
tableMap.put(10, typeMap);
|
|
|
|
|
|
tableMap.put(11, typeMap);
|
|
|
|
|
|
typeMap.put("DF_SSL_REGION", "str");
|
|
|
|
|
|
tableMap.put(12, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("FX_HTTP_REQ_HDR", "str");
|
|
|
|
|
|
typeMap.put("FX_HTTP_URL", "str");
|
|
|
|
|
|
tableMap.put(15, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("FX_DNS_REGION", "str");
|
|
|
|
|
|
tableMap.put(16, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("DJ_IP_PORT", "ip");
|
|
|
|
|
|
typeMap.put("DJ_IP_PKT_BIN", "str");
|
|
|
|
|
|
tableMap.put(48, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_REQ_HDR", "str");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_URL", "str");
|
|
|
|
|
|
tableMap.put(49, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_RES_HDR", "str");
|
|
|
|
|
|
tableMap.put(50, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_REQ_BODY", "str");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_RES_BODY", "str");
|
|
|
|
|
|
tableMap.put(51, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DJ_MAIL_HDR", "str");
|
|
|
|
|
|
typeMap.put("DJ_MAIL_BODY", "str");
|
|
|
|
|
|
tableMap.put(60, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DJ_DNS_RES_REGION", "str");
|
|
|
|
|
|
typeMap.put("DJ_DNS_REQ_REGION", "str");
|
|
|
|
|
|
tableMap.put(52, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DJ_FTP_URL", "str");
|
|
|
|
|
|
tableMap.put(53, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
tableMap.put(54, typeMap);
|
|
|
|
|
|
tableMap.put(55, typeMap);
|
|
|
|
|
|
tableMap.put(56, typeMap);
|
|
|
|
|
|
tableMap.put(57, typeMap);
|
|
|
|
|
|
tableMap.put(58, typeMap);
|
|
|
|
|
|
typeMap.put("DJ_SSL_REGION", "str");
|
|
|
|
|
|
tableMap.put(59, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DF_L2TP_URL", "str");
|
|
|
|
|
|
tableMap.put(32, typeMap);
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DF_PPTP_URL", "str");
|
|
|
|
|
|
tableMap.put(33, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
// 20161109新增业务类型
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DF_HTTP_REQ_HDR", "str");
|
|
|
|
|
|
typeMap.put("DF_HTTP_REQ_BODY", "str");
|
|
|
|
|
|
typeMap.put("DF_HTTP_URL", "str");
|
|
|
|
|
|
tableMap.put(17, 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("DF_HTTP_RES_BODY", "str");
|
|
|
|
|
|
typeMap.put("DF_HTTP_URL", "str");
|
|
|
|
|
|
tableMap.put(18, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_REQ_HDR", "str");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_REQ_BODY", "str");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_URL", "str");
|
|
|
|
|
|
tableMap.put(61, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_RES_HDR", "str");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_RES_BODY", "str");
|
|
|
|
|
|
typeMap.put("DJ_HTTP_URL", "str");
|
|
|
|
|
|
tableMap.put(62, typeMap);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typeMap = new HashMap<String, String>();
|
|
|
|
|
|
typeMap.put("UNIVERSAL_PROTO_TYPE", "num");
|
|
|
|
|
|
typeMap.put("UNIVERSAL_IP", "ip");
|
|
|
|
|
|
tableMap.put(35, typeMap);
|
|
|
|
|
|
tableMap.put(36, typeMap);
|
|
|
|
|
|
tableMap.put(37, typeMap);
|
|
|
|
|
|
return tableMap;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量(mybatis方式)修改配置业务逻辑-->1:先进行基础配置验证传过来的json串是否符合格式(配置分组关系前端不能设置为无效,程序会根据传过来的编译配置和域配置等信息自动设置为无效).
|
|
|
|
|
|
* 符合要求调用updateConfigCompile方法继续验证
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param compileList
|
|
|
|
|
|
* 编译配置集合
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void updateConfigSource(SaveRequestLogThread thread, long start, List<ConfigCompile> configSource,
|
|
|
|
|
|
Date opTime, StringBuffer sb) {
|
|
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
|
|
|
|
|
SqlSession batchSqlSession = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
|
|
|
|
|
if (null != configSource && configSource.size() > 0) {
|
|
|
|
|
|
for (ConfigCompile config : configSource) {
|
|
|
|
|
|
String msg = CompileVal.compileIsOk(config, true, sb);
|
|
|
|
|
|
if (msg != CompileJudgeCode.CompileIsOk.getErrorReason()) {
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
updateConfigCompile(thread, start, config, batchSqlSession, opTime, sb);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("编译配置不能为空" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置不能为空" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
logger1.info("数据保存到数据库提交事务开始");
|
|
|
|
|
|
batchSqlSession.commit();
|
|
|
|
|
|
logger1.info("数据保存到数据库成功");
|
|
|
|
|
|
} catch (RestServiceException e) {
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
thread.setExceptionInfo(e.getMessage() + " " + e.getCause() + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, e.getMessage() + sb.toString(),
|
|
|
|
|
|
e.getErrorCode());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
String errorCode = OracleErrorCodeUtil.getOraCode(e);
|
|
|
|
|
|
if (!StringUtils.isEmpty(errorCode)) {
|
|
|
|
|
|
logger1.error("数据更新发生异常!");
|
|
|
|
|
|
thread.setExceptionInfo(e.getMessage() + " " + e.getCause() + sb.toString());
|
|
|
|
|
|
OracleErrorCodeUtil.throwExceptionInfo(thread, System.currentTimeMillis() - start, errorCode);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("数据更新发生异常" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "数据更新发生异常" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
if (batchSqlSession != null) {
|
|
|
|
|
|
batchSqlSession.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量(mybatis方式)修改配置业务逻辑-->2:判断配置在数据库中是否已经是无效了如果是无效则提示不能修改无效的配置为有效(因为如果数据库中的编译配置与配置分组关系以及域配置均是无效,传过来的数据是编译配置和配置分组关系是有效,域配置是无效,这样会将数据库中无效的编译配置置为有效,这是不允许的)
|
|
|
|
|
|
* 3:如果编译配置置为无效将所有的配置分组关系置为无效,不修改域配置状态(分组复用考虑,域可能被其他的组引用)
|
|
|
|
|
|
* 4:如果编译配置为有效,域配置为无效,则先获取该编译配置下各个配置分组关系下的所有有效的域配置信息和所有无效的域配置信息,如果数据库中有效的域配置信息和前端传过来置为无效的的域配置信息个数,id都相等,则将对应域配置,配置分组关系,编译配置均置为无效
|
|
|
|
|
|
*
|
|
|
|
|
|
* 20161124讨论暂时先去掉2步骤,因为界面目前传过来的数据编译配置,配置分组关系,域配置均是无效,所以就不执行第2步骤了影响性能(方法内注释的代码,如果以后业务需要调整打开下面代码即可)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param compileList
|
|
|
|
|
|
* 编译配置集合
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
public void updateConfigCompile(SaveRequestLogThread thread, long start, ConfigCompile config,
|
|
|
|
|
|
SqlSession batchSqlSession, Date opTime, StringBuffer sb) throws Exception {
|
|
|
|
|
|
List<IpRegion> ipRegionList = config.getIpRegionList();
|
|
|
|
|
|
List<StrRegion> strRegionList = config.getStrRegionList();
|
|
|
|
|
|
List<NumRegion> numRegionList = config.getNumRegionList();
|
|
|
|
|
|
List<ConfigGroupRelation> groupRelationList = config.getGroupRelationList();
|
|
|
|
|
|
if (config.getIsValid() == 1) {
|
|
|
|
|
|
if (groupRelationList == null || groupRelationList.size() == 0) {
|
|
|
|
|
|
thread.setExceptionInfo("配置分组数量不能为空" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "配置分组数量不能为空" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
if ((ipRegionList == null || ipRegionList.size() == 0)
|
|
|
|
|
|
&& (strRegionList == null || strRegionList.size() == 0)
|
|
|
|
|
|
&& (numRegionList == null || numRegionList.size() == 0)) {
|
|
|
|
|
|
thread.setExceptionInfo("域配置数量不能全部为空" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
"域配置数量不能全部为空" + sb.toString(), RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConfigCompile configCompile =
|
|
|
|
|
|
// configCompileDao.queryConfigCompileById(config.getCompileId());//
|
|
|
|
|
|
// 先判断该条编译配置数据库中状态是否为无效,如果无效则提示用户不能将无效状态改为有效状态
|
|
|
|
|
|
// if (configCompile.getIsValid() == 1) {// 数据库中编译配置为有效状态才可以进行修改操作
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 1:编译配置置为无效,需要将其下所有配置分组置为无效,如果数据中将域配置置为了无效则将域配置置为无效,否则不修改域配置是否生效标志
|
|
|
|
|
|
* 2:编译配置置为有效,不修改编译配置状态(编译配置不能从无效变有效,只能从有效变无效)仅修改编译配置其他属性,
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
List<ConfigGroupRelation> queryCompileGroupByPID = configGroupRelationDao
|
|
|
|
|
|
.queryCompileGroupByPID(config.getCompileId());
|
|
|
|
|
|
|
|
|
|
|
|
if (null == queryCompileGroupByPID || queryCompileGroupByPID.size() == 0) {
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
"配置id为" + config.getCompileId() + "的配置在数据库中找不到对应的配置分组关系,请检查json串是否正确" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (config.getIsValid() == 0) {// 编译配置修改为无效,需要将所有的配置分组置为无效
|
|
|
|
|
|
if (null != queryCompileGroupByPID && queryCompileGroupByPID.size() > 0) {
|
|
|
|
|
|
for (ConfigGroupRelation configGroupRelation : queryCompileGroupByPID) {
|
|
|
|
|
|
configGroupRelation.setIsValid(0);
|
|
|
|
|
|
configGroupRelation.setOpTime(opTime);
|
|
|
|
|
|
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(ConfigGroupRelationDao.class)
|
|
|
|
|
|
.updateConfigGroupRelation(configGroupRelation);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
config.setLastUpdate(new Date());
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(ConfigCompileDao.class).updateConfigCompile(config);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
regionUpdate(thread, start, config, queryCompileGroupByPID, batchSqlSession, opTime, sb);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// } else {// 数据库中编译配置为无效状态不能进行操作
|
|
|
|
|
|
// throw new RestServiceException(thread, System.currentTimeMillis() -
|
|
|
|
|
|
// start, "不能修改无效的编译配置信息",
|
|
|
|
|
|
// RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取编译配置下所有的配置分组关系对应的有效,无效域配置id
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param config
|
|
|
|
|
|
* 编译配置对象
|
|
|
|
|
|
* @param queryCompileGroupByPID
|
|
|
|
|
|
* 当前编译下所有的配置分组关系
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void regionUpdate(SaveRequestLogThread thread, long start, ConfigCompile config,
|
|
|
|
|
|
List<ConfigGroupRelation> queryCompileGroupByPID, SqlSession batchSqlSession, Date opTime, StringBuffer sb)
|
|
|
|
|
|
throws Exception {
|
|
|
|
|
|
Map<String, Map<Long, List<Long>>> regionMap = getRegionList(thread, System.currentTimeMillis() - start, config,
|
|
|
|
|
|
queryCompileGroupByPID, batchSqlSession, sb);
|
|
|
|
|
|
Map<Long, List<Long>> validMap = regionMap.get("validMap");// 获取该编译配置下所有的配置分组关系及组下有效的域配置id
|
|
|
|
|
|
Map<Long, List<Long>> noValidMap = regionMap.get("noValidMap");// 获取该编译配置下所有的配置分组关系及组下无效的域配置id
|
|
|
|
|
|
List<IpRegion> ipRegionList = config.getIpRegionList();// 获取编译下所有ip类域配置(要修改的数据)
|
|
|
|
|
|
List<StrRegion> strRegionList = config.getStrRegionList();// 获取编译下所有字符串类域配置(要修改的数据
|
|
|
|
|
|
List<NumRegion> numRegionList = config.getNumRegionList();// 获取编译下所有数值类域配置(要修改的数据
|
|
|
|
|
|
int num = 0;
|
|
|
|
|
|
for (Long regionId : validMap.keySet()) {// 遍历配置分组
|
|
|
|
|
|
List<Long> validList = validMap.get(regionId);// 获取配置分组下有效的域配置id
|
|
|
|
|
|
List<Long> noValidList = noValidMap.get(regionId);// 获取配置分组下无效的域配置id
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
if (null != ipRegionList && ipRegionList.size() > 0) {
|
|
|
|
|
|
List<String> tableList = new ArrayList<String>();
|
|
|
|
|
|
for (IpRegion ipRegion : ipRegionList) {
|
|
|
|
|
|
if (ipRegion.getGroupId().equals(regionId)) {
|
|
|
|
|
|
if (null != validList && validList.contains(ipRegion.getRegionId())) {
|
|
|
|
|
|
if (ipRegion.getIsValid() == 0) {
|
|
|
|
|
|
ipRegion.setOpTime(opTime);
|
|
|
|
|
|
ipRegion.setLastUpdate(new Date());
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(IpRegionDao.class).updateIpRegion(ipRegion);
|
|
|
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
|
|
|
if (!tableList.contains(ipRegion.getTableName())) {
|
|
|
|
|
|
tableList.add(ipRegion.getTableName());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (null != noValidList && noValidList.contains(ipRegion.getRegionId())) {
|
|
|
|
|
|
String msg = "不能修改无效的ip类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ ipRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg,
|
|
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
String msg = "找不到对应的的ip类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ ipRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg,
|
|
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (null != strRegionList && strRegionList.size() > 0) {
|
|
|
|
|
|
List<String> tableList = new ArrayList<String>();
|
|
|
|
|
|
for (StrRegion strRegion : strRegionList) {
|
|
|
|
|
|
if (strRegion.getGroupId().equals(regionId)) {
|
|
|
|
|
|
if (null != validList && validList.contains(strRegion.getRegionId())) {
|
|
|
|
|
|
if (strRegion.getIsValid() == 0) {
|
|
|
|
|
|
strRegion.setOpTime(opTime);
|
|
|
|
|
|
strRegion.setLastUpdate(new Date());
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(StrRegionDao.class).updateStrRegion(strRegion);
|
|
|
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
|
|
|
if (!tableList.contains(strRegion.getTableName())) {
|
|
|
|
|
|
tableList.add(strRegion.getTableName());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (null != noValidList && noValidList.contains(strRegion.getRegionId())) {
|
|
|
|
|
|
String msg = "不能修改无效的字符串类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ strRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg,
|
|
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
String msg = "找不到对应的的字符串类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ strRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg,
|
|
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionList && numRegionList.size() > 0) {
|
|
|
|
|
|
List<String> tableList = new ArrayList<String>();
|
|
|
|
|
|
for (NumRegion numRegion : numRegionList) {
|
|
|
|
|
|
if (numRegion.getGroupId().equals(regionId)) {
|
|
|
|
|
|
if (null != validList && validList.contains(numRegion.getRegionId())) {
|
|
|
|
|
|
if (numRegion.getIsValid() == 0) {
|
|
|
|
|
|
numRegion.setOpTime(opTime);
|
|
|
|
|
|
numRegion.setLastUpdate(new Date());
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(NumRegionDao.class).updateNumRegion(numRegion);
|
|
|
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
|
|
|
if (!tableList.contains(numRegion.getTableName())) {
|
|
|
|
|
|
tableList.add(numRegion.getTableName());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (null != noValidList && noValidList.contains(numRegion.getRegionId())) {
|
|
|
|
|
|
String msg = "不能修改无效的数值类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ numRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg,
|
|
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
String msg = "找不到对应的的数值类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ numRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg,
|
|
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (count == validList.size()) {// 数据库中当前配置分组下有效的域配置,均被修改为无效,所以要将该配置分组置为无效
|
|
|
|
|
|
List<ConfigGroupRelation> groupRelationList = config.getGroupRelationList();
|
|
|
|
|
|
for (ConfigGroupRelation configGroupRelation : groupRelationList) {
|
|
|
|
|
|
if (configGroupRelation.getGroupId().equals(regionId)) {
|
|
|
|
|
|
num++;
|
|
|
|
|
|
configGroupRelation.setIsValid(0);
|
|
|
|
|
|
configGroupRelation.setOpTime(opTime);
|
|
|
|
|
|
configGroupRelation.setLastUpdate(new Date());
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(ConfigGroupRelationDao.class)
|
|
|
|
|
|
.updateConfigGroupRelation(configGroupRelation);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (num == validMap.size()) {// 所有的域均是无效的所有的组均是无效,需要将编译配置置为无效
|
|
|
|
|
|
config.setIsValid(0);
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(ConfigCompileDao.class).updateConfigCompile(config);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, Map<Long, List<Long>>> getRegionList(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
ConfigCompile config, List<ConfigGroupRelation> queryCompileGroupByPID, SqlSession batchSqlSession,
|
|
|
|
|
|
StringBuffer sb) {
|
|
|
|
|
|
Map<String, Map<Long, List<Long>>> map = new HashMap<String, Map<Long, List<Long>>>();
|
|
|
|
|
|
Map<Integer, Map<String, String>> tableRelationMap = getTableRelation();
|
|
|
|
|
|
Map<String, String> updateTableMap = tableRelationMap.get(config.getService().intValue());// 根据service获取需要操作的域配置表
|
|
|
|
|
|
if (null == updateTableMap) {
|
|
|
|
|
|
thread.setExceptionInfo("找不到编译对应的service" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
"找不到编译对应的service" + sb.toString(), RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Long[] groupId = new Long[queryCompileGroupByPID.size()];
|
|
|
|
|
|
for (int i = 0; i < queryCompileGroupByPID.size(); i++) {
|
|
|
|
|
|
groupId[i] = queryCompileGroupByPID.get(i).getGroupId();
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取当前编译下所有的域配置信息
|
|
|
|
|
|
List<IpRegion> ipRegionExistList = new ArrayList<IpRegion>();
|
|
|
|
|
|
List<StrRegion> strRegionExistList = new ArrayList<StrRegion>();
|
|
|
|
|
|
List<NumRegion> numRegionExistList = new ArrayList<NumRegion>();
|
|
|
|
|
|
for (String tableName : updateTableMap.keySet()) {
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("ip")) {
|
|
|
|
|
|
List<IpRegion> queryIpRegionByGroupId = ipRegionDao.queryIpRegionByGroupId(tableName, groupId);
|
|
|
|
|
|
ipRegionExistList.addAll(queryIpRegionByGroupId);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("num")) {
|
|
|
|
|
|
numRegionExistList.addAll(numRegionDao.queryNumRegionByGroupId(tableName, groupId));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("str")) {
|
|
|
|
|
|
strRegionExistList.addAll(strRegionDao.queryStrRegionByGroupId(tableName, groupId));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Map<Long, List<Long>> validMap = new HashMap<Long, List<Long>>();// 获取当前编译下所有的组,及每个组下面的有效域配置
|
|
|
|
|
|
Map<Long, List<Long>> noValidMap = new HashMap<Long, List<Long>>();// 获取当前编译下所有的组,及每个组下面的无效域配置
|
|
|
|
|
|
for (IpRegion ipRegion : ipRegionExistList) {
|
|
|
|
|
|
if (ipRegion.getIsValid() == 1) {
|
|
|
|
|
|
List<Long> validRegionList = null;
|
|
|
|
|
|
if (validMap.get(ipRegion.getGroupId()) == null) {
|
|
|
|
|
|
validRegionList = new ArrayList<Long>();
|
|
|
|
|
|
validRegionList.add(ipRegion.getRegionId());
|
|
|
|
|
|
validMap.put(ipRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
validRegionList = validMap.get(ipRegion.getGroupId());
|
|
|
|
|
|
// if (!validRegionList.contains(ipRegion.getRegionId())) {
|
|
|
|
|
|
validRegionList.add(ipRegion.getRegionId());
|
|
|
|
|
|
validMap.put(ipRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ipRegion.getIsValid() == 0) {
|
|
|
|
|
|
List<Long> noValidRegionList = null;
|
|
|
|
|
|
if (noValidMap.get(ipRegion.getGroupId()) == null) {
|
|
|
|
|
|
noValidRegionList = new ArrayList<Long>();
|
|
|
|
|
|
noValidRegionList.add(ipRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(ipRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
noValidRegionList = noValidMap.get(ipRegion.getGroupId());
|
|
|
|
|
|
// if (!noValidRegionList.contains(ipRegion.getRegionId()))
|
|
|
|
|
|
// {
|
|
|
|
|
|
noValidRegionList.add(ipRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(ipRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (StrRegion strRegion : strRegionExistList) {
|
|
|
|
|
|
if (strRegion.getIsValid() == 1) {
|
|
|
|
|
|
List<Long> validRegionList = null;
|
|
|
|
|
|
if (validMap.get(strRegion.getGroupId()) == null) {
|
|
|
|
|
|
validRegionList = new ArrayList<Long>();
|
|
|
|
|
|
|
|
|
|
|
|
validRegionList.add(strRegion.getRegionId());
|
|
|
|
|
|
|
|
|
|
|
|
validMap.put(strRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
validRegionList = validMap.get(strRegion.getGroupId());
|
|
|
|
|
|
// if (!validRegionList.contains(strRegion.getRegionId())) {
|
|
|
|
|
|
validRegionList.add(strRegion.getRegionId());
|
|
|
|
|
|
validMap.put(strRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strRegion.getIsValid() == 0) {
|
|
|
|
|
|
List<Long> noValidRegionList = null;
|
|
|
|
|
|
if (noValidMap.get(strRegion.getGroupId()) == null) {
|
|
|
|
|
|
noValidRegionList = new ArrayList<Long>();
|
|
|
|
|
|
noValidRegionList.add(strRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(strRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
noValidRegionList = noValidMap.get(strRegion.getGroupId());
|
|
|
|
|
|
// if (!noValidRegionList.contains(strRegion.getRegionId()))
|
|
|
|
|
|
// {
|
|
|
|
|
|
noValidRegionList.add(strRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(strRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (NumRegion numRegion : numRegionExistList) {
|
|
|
|
|
|
if (numRegion.getIsValid() == 1) {
|
|
|
|
|
|
List<Long> validRegionList = null;
|
|
|
|
|
|
if (validMap.get(numRegion.getGroupId()) == null) {
|
|
|
|
|
|
validRegionList = new ArrayList<Long>();
|
|
|
|
|
|
validRegionList.add(numRegion.getRegionId());
|
|
|
|
|
|
validMap.put(numRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
validRegionList = validMap.get(numRegion.getGroupId());
|
|
|
|
|
|
// if (!validRegionList.contains(numRegion.getRegionId())) {
|
|
|
|
|
|
validRegionList.add(numRegion.getRegionId());
|
|
|
|
|
|
validMap.put(numRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (numRegion.getIsValid() == 0) {
|
|
|
|
|
|
List<Long> noValidRegionList = null;
|
|
|
|
|
|
if (noValidMap.get(numRegion.getGroupId()) == null) {
|
|
|
|
|
|
noValidRegionList = new ArrayList<Long>();
|
|
|
|
|
|
noValidRegionList.add(numRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(numRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
noValidRegionList = noValidMap.get(numRegion.getGroupId());
|
|
|
|
|
|
// if (!noValidRegionList.contains(numRegion.getRegionId()))
|
|
|
|
|
|
// {
|
|
|
|
|
|
noValidRegionList.add(numRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(numRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
map.put("noValidMap", noValidMap);
|
|
|
|
|
|
map.put("validMap", validMap);
|
|
|
|
|
|
return map;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量插入配置编译数据在数据库中循环
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param configSource
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void insertConfigSourceData(SaveRequestLogThread thread, long _start, List<ConfigCompile> configSource,
|
|
|
|
|
|
StringBuffer sb) {
|
|
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
|
|
|
|
|
SqlSession batchSqlSession = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
// batchSqlSession =
|
|
|
|
|
|
// sqlSessionFactory.openSession(ExecutorType.SIMPLE, false);
|
|
|
|
|
|
batchSqlSession = sqlSessionFactory.openSession();
|
|
|
|
|
|
int index = 150;
|
|
|
|
|
|
int count = configSource.size() % index == 0 ? configSource.size() / index
|
|
|
|
|
|
: configSource.size() / index + 1;
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
|
|
int start = i * index;
|
|
|
|
|
|
int end = i * index + index;
|
|
|
|
|
|
if (end > configSource.size()) {
|
|
|
|
|
|
end = configSource.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
List<ConfigCompile> compileList = configSource.subList(start, end);
|
|
|
|
|
|
insertConfigComLileData(thread, _start, compileList, sb);
|
|
|
|
|
|
// logger1.info(insertConfigComLile);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
logger1.info("数据保存到数据库提交事务开始");
|
|
|
|
|
|
batchSqlSession.commit();
|
|
|
|
|
|
logger1.info("数据保存到数据库成功");
|
|
|
|
|
|
|
|
|
|
|
|
} catch (RestServiceException e) {
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
thread.setExceptionInfo(e.getMessage() + " " + e.getCause() + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - _start, e.getMessage() + sb.toString(),
|
|
|
|
|
|
e.getErrorCode());
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
String errorCode = OracleErrorCodeUtil.getOraCode(e);
|
|
|
|
|
|
if (!StringUtils.isEmpty(errorCode)) {
|
|
|
|
|
|
thread.setExceptionInfo("数据保存发生异常" + sb.toString());
|
|
|
|
|
|
OracleErrorCodeUtil.throwExceptionInfo(thread, System.currentTimeMillis() - _start, errorCode);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("数据保存发生异常" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - _start, "数据保存发生异常" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
if (batchSqlSession != null) {
|
|
|
|
|
|
batchSqlSession.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 验证数据是否符合要求 插入编译配置数据 验证分组配置数据 验证域配置数据 方法二 数据库中循环
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param configCompileList
|
|
|
|
|
|
* @param batchSqlSession
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
private String insertConfigComLileData(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
List<ConfigCompile> configCompileList, StringBuffer sb) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
|
|
|
|
|
|
Map<String, List<StrRegion>> strRegionMap = new HashMap<String, List<StrRegion>>();
|
|
|
|
|
|
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>>();
|
|
|
|
|
|
|
|
|
|
|
|
for (ConfigCompile configCompile : configCompileList) {
|
|
|
|
|
|
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());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strRegionMap.containsKey(strRegion.getTableName())) {
|
|
|
|
|
|
strRegionMap.get(strRegion.getTableName()).add(strRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strRegionList.add(strRegion);
|
|
|
|
|
|
strRegionMap.put(strRegion.getTableName(), strRegionList);
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strStongRegionMap.containsKey(strRegion.getTableName())) {
|
|
|
|
|
|
strStongRegionMap.get(strRegion.getTableName()).add(strRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strStrongRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strStrongRegionList.add(strRegion);
|
|
|
|
|
|
strStongRegionMap.put(strRegion.getTableName(), strStrongRegionList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ipRegionMap.containsKey(ipRegion.getTableName())) {
|
|
|
|
|
|
ipRegionMap.get(ipRegion.getTableName()).add(ipRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<IpRegion> ipRegionList = new ArrayList<IpRegion>();
|
|
|
|
|
|
ipRegionList.add(ipRegion);
|
|
|
|
|
|
ipRegionMap.put(ipRegion.getTableName(), ipRegionList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (numRegionMap.containsKey(numRegion.getTableName())) {
|
|
|
|
|
|
numRegionMap.get(numRegion.getTableName()).add(numRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<NumRegion> numRegionList = new ArrayList<NumRegion>();
|
|
|
|
|
|
numRegionList.add(numRegion);
|
|
|
|
|
|
numRegionMap.put(numRegion.getTableName(), numRegionList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
configCompileDao.saveCompileBatch(configCompileList);
|
|
|
|
|
|
if (groupRelationList.size() > 0) {
|
|
|
|
|
|
for (ConfigGroupRelation group : groupRelationList) {
|
|
|
|
|
|
configGroupRelationDao.saveConfigGroupRelation(group);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (String str : strRegionMap.keySet()) {
|
|
|
|
|
|
strRegionDao.saveStrRegionBatch(strRegionMap.get(str).get(0).getTableName(), strRegionMap.get(str));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (String strStrong : strStongRegionMap.keySet()) {
|
|
|
|
|
|
strRegionDao.saveStrStrongRegionBatch(strStongRegionMap.get(strStrong).get(0).getTableName(),
|
|
|
|
|
|
strStongRegionMap.get(strStrong));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (String ip : ipRegionMap.keySet()) {
|
|
|
|
|
|
ipRegionDao.saveIpRegionBatch(ipRegionMap.get(ip).get(0).getTableName(), ipRegionMap.get(ip));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (String num : numRegionMap.keySet()) {
|
|
|
|
|
|
numRegionDao.saveNumRegionBatch(numRegionMap.get(num).get(0).getTableName(), numRegionMap.get(num));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "编译配置数据验证成功";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
public Page<ConfigCompileTest> queryAllCompile(Page<ConfigCompileTest> page, ConfigCompileTest entity)
|
|
|
|
|
|
throws SQLException {
|
|
|
|
|
|
entity.setPage(page);
|
|
|
|
|
|
page.setList(configCompileDao.queryAllCompile(entity.getSearchEndTime(), entity.getSearchStartTime(),
|
|
|
|
|
|
entity.getService(), entity.getCompileId()));
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<ConfigCompileTest> queryAllCompile(ConfigCompileTest entity) {
|
|
|
|
|
|
return configCompileDao.queryAllCompile(entity.getSearchEndTime(), entity.getSearchStartTime(),
|
|
|
|
|
|
entity.getService(), entity.getCompileId());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<ConfigCompileTest> queryConfigCompileByIdArr(String compileIdArr) {
|
|
|
|
|
|
return configCompileDao.queryConfigCompileByIdArr(compileIdArr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<ConfigGroupRelation> getGroupByCompile(long compileId) {
|
|
|
|
|
|
return configGroupRelationDao.queryCompileGroupByPID(compileId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<StrRegion> getStrRegionByGId(List<String> tableList, Long[] groupId) {
|
|
|
|
|
|
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
if (null != tableList && tableList.size() > 0) {
|
|
|
|
|
|
for (String tableName : tableList) {
|
|
|
|
|
|
List<StrRegion> queryStrRegionByGroupId = null;
|
|
|
|
|
|
if (isStrStrongRegion(tableName)) {
|
|
|
|
|
|
queryStrRegionByGroupId = strRegionDao.queryStrStrongRegionByGroupId(tableName, groupId);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
queryStrRegionByGroupId = strRegionDao.queryStrRegionByGroupId(tableName, groupId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (null != queryStrRegionByGroupId && queryStrRegionByGroupId.size() > 0) {
|
|
|
|
|
|
for (StrRegion strRegion : queryStrRegionByGroupId) {
|
|
|
|
|
|
strRegion.setTableName(tableName);
|
|
|
|
|
|
strRegionList.add(strRegion);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return strRegionList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<IpRegion> getIpRegionByGId(String table, Long[] groupId) {
|
|
|
|
|
|
List<IpRegion> queryIpRegionByGroupId = ipRegionDao.queryIpRegionByGroupId(table, groupId);
|
|
|
|
|
|
for (IpRegion ipRegion : queryIpRegionByGroupId) {
|
|
|
|
|
|
ipRegion.setTableName(table);
|
|
|
|
|
|
}
|
|
|
|
|
|
return queryIpRegionByGroupId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<NumRegion> getNumRegionByGId(String table, Long[] groupId) {
|
|
|
|
|
|
List<NumRegion> queryNumRegionByGroupId = numRegionDao.queryNumRegionByGroupId(table, groupId);
|
|
|
|
|
|
for (NumRegion numRegion : queryNumRegionByGroupId) {
|
|
|
|
|
|
numRegion.setTableName(table);
|
|
|
|
|
|
}
|
|
|
|
|
|
return queryNumRegionByGroupId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isStrStrongRegion(String tableName) {
|
|
|
|
|
|
if (null != tableName && !tableName.equals("")) {
|
|
|
|
|
|
tableName = tableName.toUpperCase();
|
|
|
|
|
|
List<String> tableList = new ArrayList<String>();
|
|
|
|
|
|
tableList.add("DF_HTTP_REQ_HDR");
|
|
|
|
|
|
tableList.add("FX_HTTP_REQ_HDR");
|
|
|
|
|
|
tableList.add("DF_HTTP_RES_HDR");
|
|
|
|
|
|
tableList.add("DF_DNS_REGION");
|
|
|
|
|
|
tableList.add("FX_DNS_REGION");
|
|
|
|
|
|
tableList.add("DF_SSL_REGION");
|
|
|
|
|
|
tableList.add("DF_MAIL_HDR");
|
|
|
|
|
|
tableList.add("DF_MAIL_BODY");
|
|
|
|
|
|
|
|
|
|
|
|
tableList.add("DJ_HTTP_REQ_HDR");
|
|
|
|
|
|
tableList.add("DJ_HTTP_RES_HDR");
|
|
|
|
|
|
tableList.add("DJ_DNS_REQ_REGION");
|
|
|
|
|
|
tableList.add("DJ_DNS_RES_REGION");
|
|
|
|
|
|
tableList.add("DJ_SSL_REGION");
|
|
|
|
|
|
tableList.add("DJ_MAIL_HDR");
|
|
|
|
|
|
tableList.add("DJ_MAIL_BODY");
|
|
|
|
|
|
// tableList.add("DF_L2TP_URL");//20161021数据库中该表改为普通字符串表
|
|
|
|
|
|
// tableList.add("DF_PPTP_URL");//20161021数据库中该表改为普通字符串表
|
|
|
|
|
|
if (tableList.contains(tableName)) {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, String> getTableMap(Integer service) {
|
|
|
|
|
|
if (map == null || map.size() == 0) {
|
|
|
|
|
|
map = getTableRelation();
|
|
|
|
|
|
}
|
|
|
|
|
|
return map.get(service);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Map<Integer, Map<String, String>> getMap() {
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setMap(Map<Integer, Map<String, String>> map) {
|
|
|
|
|
|
this.map = map;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/**
|
|
|
|
|
|
* jdbc方式添加和修改
|
|
|
|
|
|
*/
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
public String saveByJDBCThread(SaveRequestLogThread thread, long start, List<ConfigCompile> configCompileList,
|
|
|
|
|
|
StringBuffer sb) {
|
|
|
|
|
|
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
|
|
|
|
|
|
Map<String, List<StrRegion>> strRegionMap = new HashMap<String, List<StrRegion>>();
|
|
|
|
|
|
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>>();
|
2018-02-28 10:13:39 +08:00
|
|
|
|
Map<String, List<DigestRegion>> digestRegionMap = new HashMap<String, List<DigestRegion>>();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (ConfigCompile configCompile : configCompileList) {
|
|
|
|
|
|
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());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strRegionMap.containsKey(strRegion.getTableName())) {
|
|
|
|
|
|
strRegionMap.get(strRegion.getTableName()).add(strRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strRegionList.add(strRegion);
|
|
|
|
|
|
strRegionMap.put(strRegion.getTableName(), strRegionList);
|
|
|
|
|
|
}
|
|
|
|
|
|
} 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());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strStongRegionMap.containsKey(strRegion.getTableName())) {
|
|
|
|
|
|
strStongRegionMap.get(strRegion.getTableName()).add(strRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strStrongRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strStrongRegionList.add(strRegion);
|
|
|
|
|
|
strStongRegionMap.put(strRegion.getTableName(), strStrongRegionList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ipRegionMap.containsKey(ipRegion.getTableName())) {
|
|
|
|
|
|
ipRegionMap.get(ipRegion.getTableName()).add(ipRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<IpRegion> ipRegionList = new ArrayList<IpRegion>();
|
|
|
|
|
|
ipRegionList.add(ipRegion);
|
|
|
|
|
|
ipRegionMap.put(ipRegion.getTableName(), ipRegionList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (numRegionMap.containsKey(numRegion.getTableName())) {
|
|
|
|
|
|
numRegionMap.get(numRegion.getTableName()).add(numRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<NumRegion> numRegionList = new ArrayList<NumRegion>();
|
|
|
|
|
|
numRegionList.add(numRegion);
|
|
|
|
|
|
numRegionMap.put(numRegion.getTableName(), numRegionList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-28 10:13:39 +08:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
if (null != configCompileList && configCompileList.size() > 0) {
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != groupRelationList && groupRelationList.size() > 0) {
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != strRegionMap && strRegionMap.size() > 0) {
|
|
|
|
|
|
count += strRegionMap.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != strStongRegionMap && strStongRegionMap.size() > 0) {
|
|
|
|
|
|
count += strStongRegionMap.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != ipRegionMap && ipRegionMap.size() > 0) {
|
|
|
|
|
|
count += ipRegionMap.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionMap && numRegionMap.size() > 0) {
|
|
|
|
|
|
count += numRegionMap.size();
|
|
|
|
|
|
}
|
2018-02-28 10:13:39 +08:00
|
|
|
|
|
|
|
|
|
|
if (null != digestRegionMap && digestRegionMap.size() > 0) {
|
|
|
|
|
|
count += digestRegionMap.size();
|
|
|
|
|
|
}
|
2017-12-19 14:55:52 +08:00
|
|
|
|
|
|
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
|
|
|
|
|
Connection conn = sqlSessionFactory.openSession().getConnection();
|
|
|
|
|
|
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
|
|
|
|
|
SaveCompileByJDBCThread compile = new SaveCompileByJDBCThread(conn, latch, start);
|
|
|
|
|
|
compile.setCompileList(configCompileList);
|
|
|
|
|
|
Thread compileThread = new Thread(compile);
|
|
|
|
|
|
compileThread.start();
|
|
|
|
|
|
if (groupRelationList.size() > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
SaveCompileByJDBCThread group = new SaveCompileByJDBCThread(conn, latch, start);
|
|
|
|
|
|
group.setGroupList(groupRelationList);
|
|
|
|
|
|
|
|
|
|
|
|
Thread groupThread = new Thread(group);
|
|
|
|
|
|
groupThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strRegionMap.size() > 0) {
|
|
|
|
|
|
for (String str : strRegionMap.keySet()) {
|
|
|
|
|
|
|
|
|
|
|
|
SaveCompileByJDBCThread strRegion = new SaveCompileByJDBCThread(false, str, conn, latch, start);
|
|
|
|
|
|
strRegion.setStrRegionList(strRegionMap.get(str));
|
|
|
|
|
|
Thread strThread = new Thread(strRegion);
|
|
|
|
|
|
strThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strStongRegionMap.size() > 0) {
|
|
|
|
|
|
for (String strStrong : strStongRegionMap.keySet()) {
|
|
|
|
|
|
SaveCompileByJDBCThread strongRegion = new SaveCompileByJDBCThread(true, strStrong, conn, latch,
|
|
|
|
|
|
start);
|
|
|
|
|
|
strongRegion.setStrRegionList(strStongRegionMap.get(strStrong));
|
|
|
|
|
|
Thread strongStrThread = new Thread(strongRegion);
|
|
|
|
|
|
strongStrThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ipRegionMap.size() > 0) {
|
|
|
|
|
|
for (String ip : ipRegionMap.keySet()) {
|
|
|
|
|
|
SaveCompileByJDBCThread ipRegion = new SaveCompileByJDBCThread(ip, conn, latch, start);
|
|
|
|
|
|
ipRegion.setIpRegionList(ipRegionMap.get(ip));
|
|
|
|
|
|
Thread ipThread = new Thread(ipRegion);
|
|
|
|
|
|
ipThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (numRegionMap.size() > 0) {
|
|
|
|
|
|
for (String num : numRegionMap.keySet()) {
|
|
|
|
|
|
SaveCompileByJDBCThread numRegion = new SaveCompileByJDBCThread(num, conn, latch, start);
|
|
|
|
|
|
numRegion.setNumRegionList(numRegionMap.get(num));
|
|
|
|
|
|
Thread numThread = new Thread(numRegion);
|
|
|
|
|
|
numThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-28 10:13:39 +08:00
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
try {
|
|
|
|
|
|
latch.await();
|
|
|
|
|
|
if (msgList.size() > 0) {
|
|
|
|
|
|
conn.rollback();
|
|
|
|
|
|
return "error";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
conn.commit();
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
thread.setExceptionInfo(e.toString());
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
if (!(e instanceof RestServiceException)) {
|
|
|
|
|
|
e = new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据插入失败",
|
|
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
throw ((RestServiceException) e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量(jdbc多线程方式)修改配置业务逻辑-->1:先进行基础配置验证传过来的json串是否符合格式(配置分组关系前端不能设置为无效,程序会根据传过来的编译配置和域配置等信息自动设置为无效).
|
|
|
|
|
|
* 2:判断配置在数据库中是否已经是无效了如果是无效则提示不能修改无效的配置为有效(因为如果数据库中的编译配置与配置分组关系以及域配置均是无效,传过来的数据是编译配置和配置分组关系是有效,域配置是无效,这样会将数据库中无效的编译配置置为有效,这是不允许的)
|
|
|
|
|
|
* 3:如果编译配置置为无效将所有的配置分组关系置为无效,不修改域配置状态(分组复用考虑,域可能被其他的组引用)
|
|
|
|
|
|
* 4:如果编译配置为有效,域配置为无效,则先获取该编译配置下各个配置分组关系下的所有有效的域配置信息和所有无效的域配置信息,如果数据库中有效的域配置信息和前端传过来置为无效的的域配置信息个数,id都相等,则将对应域配置,配置分组关系,编译配置均置为无效
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
* 20161124讨论暂时先去掉2步骤,因为界面目前传过来的数据编译配置,配置分组关系,域配置均是无效,所以就不执行第2步骤了影响性能(方法内注释的代码,如果以后业务需要调整打开下面代码即可)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param compileList
|
|
|
|
|
|
* 编译配置集合
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String updateByJDBCThread(SaveRequestLogThread thread, long start, List<ConfigCompile> compileList,
|
|
|
|
|
|
Date opTime, StringBuffer sb) {
|
|
|
|
|
|
List<ConfigCompile> compileAllList = new ArrayList<ConfigCompile>();
|
|
|
|
|
|
List<ConfigGroupRelation> groupRelationAllList = new ArrayList<ConfigGroupRelation>();
|
|
|
|
|
|
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>>();
|
|
|
|
|
|
if (null != compileList && compileList.size() > 0) {
|
|
|
|
|
|
for (ConfigCompile config : compileList) {
|
|
|
|
|
|
String msg = CompileVal.compileIsOk(config, true, sb);
|
|
|
|
|
|
if (msg != CompileJudgeCode.CompileIsOk.getErrorReason()) {
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
List<IpRegion> ipRegionList = config.getIpRegionList();// 获取编译下所有ip类域配置(要修改的数据)
|
|
|
|
|
|
List<StrRegion> strRegionList = config.getStrRegionList();// 获取编译下所有字符串类域配置(要修改的数据
|
|
|
|
|
|
List<NumRegion> numRegionList = config.getNumRegionList();// 获取编译下所有数值类域配置(要修改的数据
|
|
|
|
|
|
List<ConfigGroupRelation> groupRelationList = config.getGroupRelationList();
|
|
|
|
|
|
if (config.getIsValid() == 1) {
|
|
|
|
|
|
if (groupRelationList == null || groupRelationList.size() == 0) {
|
|
|
|
|
|
thread.setExceptionInfo("配置分组数量不能为空" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
"配置分组数量不能为空" + sb.toString(), RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
if ((ipRegionList == null || ipRegionList.size() == 0)
|
|
|
|
|
|
&& (strRegionList == null || strRegionList.size() == 0)
|
|
|
|
|
|
&& (numRegionList == null || numRegionList.size() == 0)) {
|
|
|
|
|
|
thread.setExceptionInfo("域配置数量不能全部为空" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
"域配置数量不能全部为空" + sb.toString(), RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConfigCompile configCompile =
|
|
|
|
|
|
// configCompileDao.queryConfigCompileById(config.getCompileId());//
|
|
|
|
|
|
// 先判断该条编译配置数据库中状态是否为无效,如果无效则提示用户不能将无效状态改为有效状态
|
|
|
|
|
|
// if (configCompile.getIsValid() == 1) {//
|
|
|
|
|
|
// 数据库中编译配置为有效状态才可以进行修改操作
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 1:编译配置置为无效,需要将其下所有配置分组置为无效,如果数据中将域配置置为了无效则将域配置置为无效,否则不修改域配置是否生效标志
|
|
|
|
|
|
* 2:编译配置置为有效,不修改编译配置状态(编译配置不能从无效变有效,只能从有效变无效)仅修改编译配置其他属性,
|
|
|
|
|
|
*/
|
|
|
|
|
|
List<ConfigGroupRelation> queryCompileGroupByPID = configGroupRelationDao
|
|
|
|
|
|
.queryCompileGroupByPID(config.getCompileId());
|
|
|
|
|
|
|
|
|
|
|
|
if (null == queryCompileGroupByPID || queryCompileGroupByPID.size() == 0) {
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
"配置id为" + config.getCompileId() + "的配置在数据库中找不到对应的配置分组关系,请检查json串是否正确" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (config.getIsValid() == 0) {// 编译配置修改为无效,需要将所有的配置分组置为无效
|
|
|
|
|
|
if (null != queryCompileGroupByPID && queryCompileGroupByPID.size() > 0) {
|
|
|
|
|
|
for (ConfigGroupRelation configGroupRelation : queryCompileGroupByPID) {
|
|
|
|
|
|
configGroupRelation.setIsValid(0);
|
|
|
|
|
|
|
|
|
|
|
|
groupRelationAllList.add(configGroupRelation);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Map<Long, List<Long>>> regionMap = getRegionList(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, config, queryCompileGroupByPID, sb);
|
|
|
|
|
|
Map<Long, List<Long>> validMap = regionMap.get("validMap");// 获取该编译配置下所有的配置分组关系及组下有效的域配置id
|
|
|
|
|
|
Map<Long, List<Long>> noValidMap = regionMap.get("noValidMap");// 获取该编译配置下所有的配置分组关系及组下无效的域配置id
|
|
|
|
|
|
|
|
|
|
|
|
int num = 0;
|
|
|
|
|
|
for (Long regionId : validMap.keySet()) {// 遍历配置分组
|
|
|
|
|
|
List<Long> validList = validMap.get(regionId);// 获取配置分组下有效的域配置id
|
|
|
|
|
|
List<Long> noValidList = noValidMap.get(regionId);// 获取配置分组下无效的域配置id
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
if (null != ipRegionList && ipRegionList.size() > 0) {
|
|
|
|
|
|
for (IpRegion ipRegion : ipRegionList) {
|
|
|
|
|
|
if (ipRegion.getGroupId().equals(regionId)) {
|
|
|
|
|
|
if (null != validList && validList.contains(ipRegion.getRegionId())) {
|
|
|
|
|
|
if (ipRegion.getIsValid() == 0) {
|
|
|
|
|
|
ipRegion.setLastUpdate(new Date());
|
|
|
|
|
|
if (ipRegionMap.containsKey(ipRegion.getTableName())) {
|
|
|
|
|
|
ipRegionMap.get(ipRegion.getTableName()).add(ipRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<IpRegion> ipList = new ArrayList<IpRegion>();
|
|
|
|
|
|
ipList.add(ipRegion);
|
|
|
|
|
|
ipRegionMap.put(ipRegion.getTableName(), ipList);
|
|
|
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (null != noValidList && noValidList.contains(ipRegion.getRegionId())) {
|
|
|
|
|
|
String errorMsg = "不能修改无效的ip类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ ipRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg, RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
String errorMsg = "找不到对应的的ip类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ ipRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg, RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (null != strRegionList && strRegionList.size() > 0) {
|
|
|
|
|
|
for (StrRegion strRegion : strRegionList) {
|
|
|
|
|
|
if (strRegion.getGroupId().equals(regionId)) {
|
|
|
|
|
|
if (null != validList && validList.contains(strRegion.getRegionId())) {
|
|
|
|
|
|
if (strRegion.getIsValid() == 0) {
|
|
|
|
|
|
|
|
|
|
|
|
strRegion.setLastUpdate(new Date());
|
|
|
|
|
|
if (strRegionMap.containsKey(strRegion.getTableName())) {
|
|
|
|
|
|
strRegionMap.get(strRegion.getTableName()).add(strRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strList.add(strRegion);
|
|
|
|
|
|
strRegionMap.put(strRegion.getTableName(), strList);
|
|
|
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (null != noValidList && noValidList.contains(strRegion.getRegionId())) {
|
|
|
|
|
|
String errorMsg = "不能修改无效的字符串类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ strRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg, RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
String errorMsg = "找不到对应的的字符串类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ strRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg, RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionList && numRegionList.size() > 0) {
|
|
|
|
|
|
for (NumRegion numRegion : numRegionList) {
|
|
|
|
|
|
if (numRegion.getGroupId().equals(regionId)) {
|
|
|
|
|
|
if (null != validList && validList.contains(numRegion.getRegionId())) {
|
|
|
|
|
|
if (numRegion.getIsValid() == 0) {
|
|
|
|
|
|
|
|
|
|
|
|
numRegion.setLastUpdate(new Date());
|
|
|
|
|
|
if (numRegionMap.containsKey(numRegion.getTableName())) {
|
|
|
|
|
|
numRegionMap.get(numRegion.getTableName()).add(numRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<NumRegion> numList = new ArrayList<NumRegion>();
|
|
|
|
|
|
numList.add(numRegion);
|
|
|
|
|
|
numRegionMap.put(numRegion.getTableName(), numList);
|
|
|
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (null != noValidList && noValidList.contains(numRegion.getRegionId())) {
|
|
|
|
|
|
String errorMsg = "不能修改无效的数值类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ numRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg, RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
String errorMsg = "找不到对应的的数值类域配置compile为" + config.getCompileId() + "regionid为"
|
|
|
|
|
|
+ numRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg, RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (count == validList.size()) {// 数据库中当前配置分组下有效的域配置,均被修改为无效,所以要将该配置分组置为无效
|
|
|
|
|
|
for (ConfigGroupRelation configGroupRelation : groupRelationList) {
|
|
|
|
|
|
if (configGroupRelation.getGroupId().equals(regionId)) {
|
|
|
|
|
|
num++;
|
|
|
|
|
|
configGroupRelation.setIsValid(0);
|
|
|
|
|
|
|
|
|
|
|
|
configGroupRelation.setLastUpdate(new Date());
|
|
|
|
|
|
groupRelationAllList.add(configGroupRelation);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (num == validMap.size()) {// 所有的域均是无效的所有的组均是无效,需要将编译配置置为无效
|
|
|
|
|
|
config.setIsValid(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// } else {// 数据库中编译配置为无效状态不能进行操作
|
|
|
|
|
|
// throw new RestServiceException(thread,
|
|
|
|
|
|
// System.currentTimeMillis() - start,"不能修改无效的编译配置信息,配置id为" +
|
|
|
|
|
|
// configCompile.getCompileId(),RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
// }
|
|
|
|
|
|
compileAllList.add(config);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("编译配置不能为空" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置不能为空" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 程序是否入库,测试分析数据的时间
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
if (null != compileAllList && compileAllList.size() > 0) {
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != groupRelationAllList && groupRelationAllList.size() > 0) {
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != strRegionMap && strRegionMap.size() > 0) {
|
|
|
|
|
|
count += strRegionMap.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != ipRegionMap && ipRegionMap.size() > 0) {
|
|
|
|
|
|
count += ipRegionMap.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionMap && numRegionMap.size() > 0) {
|
|
|
|
|
|
count += numRegionMap.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
|
|
|
|
|
Connection conn = sqlSessionFactory.openSession().getConnection();
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
|
|
|
|
|
UpdateCompileByJDBCThread compileThread = new UpdateCompileByJDBCThread(conn, latch, start, opTime);
|
|
|
|
|
|
compileThread.setCompileList(compileAllList);
|
|
|
|
|
|
Thread compile = new Thread(compileThread);
|
|
|
|
|
|
compile.start();
|
|
|
|
|
|
|
|
|
|
|
|
if (null != groupRelationAllList && groupRelationAllList.size() > 0) {
|
|
|
|
|
|
UpdateCompileByJDBCThread groupThread = new UpdateCompileByJDBCThread(conn, latch, start, opTime);
|
|
|
|
|
|
groupThread.setGroupList(groupRelationAllList);
|
|
|
|
|
|
Thread group = new Thread(groupThread);
|
|
|
|
|
|
group.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != strRegionMap && strRegionMap.size() > 0) {
|
|
|
|
|
|
for (String str : strRegionMap.keySet()) {
|
|
|
|
|
|
UpdateCompileByJDBCThread strRegion = new UpdateCompileByJDBCThread(str, conn, latch, start,
|
|
|
|
|
|
opTime);
|
|
|
|
|
|
strRegion.setStrRegionList(strRegionMap.get(str));
|
|
|
|
|
|
Thread strThread = new Thread(strRegion);
|
|
|
|
|
|
strThread.start();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (null != ipRegionMap && ipRegionMap.size() > 0) {
|
|
|
|
|
|
for (String ip : ipRegionMap.keySet()) {
|
|
|
|
|
|
UpdateCompileByJDBCThread ipRegion = new UpdateCompileByJDBCThread(ip, conn, latch, start, opTime);
|
|
|
|
|
|
ipRegion.setIpRegionList(ipRegionMap.get(ip));
|
|
|
|
|
|
Thread ipThread = new Thread(ipRegion);
|
|
|
|
|
|
ipThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionMap && numRegionMap.size() > 0) {
|
|
|
|
|
|
for (String num : numRegionMap.keySet()) {
|
|
|
|
|
|
UpdateCompileByJDBCThread numRegion = new UpdateCompileByJDBCThread(num, conn, latch, start,
|
|
|
|
|
|
opTime);
|
|
|
|
|
|
numRegion.setNumRegionList(numRegionMap.get(num));
|
|
|
|
|
|
Thread numThread = new Thread(numRegion);
|
|
|
|
|
|
numThread.start();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
latch.await();
|
|
|
|
|
|
if (msgList.size() > 0) {
|
|
|
|
|
|
conn.rollback();
|
|
|
|
|
|
return "error";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
conn.commit();
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
thread.setExceptionInfo(e.toString());
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
if (!(e instanceof RestServiceException)) {
|
|
|
|
|
|
e = new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据修改失败",
|
|
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
throw ((RestServiceException) e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量(jdbc多线程方式)修改配置业务逻辑-->1:先进行基础配置验证传过来的json串是否符合格式(配置分组关系前端不能设置为无效,程序会根据传过来的编译配置和域配置等信息自动设置为无效).
|
|
|
|
|
|
* 2:判断配置在数据库中是否已经是无效了如果是无效则提示不能修改无效的配置为有效(因为如果数据库中的编译配置与配置分组关系以及域配置均是无效,传过来的数据是编译配置和配置分组关系是有效,域配置是无效,这样会将数据库中无效的编译配置置为有效,这是不允许的)
|
|
|
|
|
|
* 3:如果编译配置置为无效将所有的配置分组关系置为无效,不修改域配置状态(分组复用考虑,域可能被其他的组引用)
|
|
|
|
|
|
* 4:如果编译配置为有效,域配置为无效,则先获取该编译配置下各个配置分组关系下的所有有效的域配置信息和所有无效的域配置信息,如果数据库中有效的域配置信息和前端传过来置为无效的的域配置信息个数,id都相等,则将对应域配置,配置分组关系,编译配置均置为无效
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
* 20161124讨论暂时先去掉2步骤,因为界面目前传过来的数据编译配置,配置分组关系,域配置均是无效,所以就不执行第2步骤了影响性能(方法内注释的代码,如果以后业务需要调整打开下面代码即可)
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
* 20161215讨论确定修改时前端发过来的配置都是无效的不会存在即有无效又有有效的情况,且配置中的个数与添加时保持一致,即添加时插入了1条编译配置2条配置分组关系3条域配置,在修改时也会传过来1条编译配置2条配置分组关系3条域配置,不会多或者少配置
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
* 2017-1-16:和杨老师讨论确定存在分组复用情况,当编译配置置为无效,需要将其下所有配置分组置为无效,如果数据中将域配置置为了无效则将域配置置为无效,否则不修改域配置是否生效标志
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param compileList
|
|
|
|
|
|
* 编译配置集合
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String updateByJDBCThread12(SaveRequestLogThread thread, long start, List<ConfigCompile> compileList,
|
|
|
|
|
|
Date opTime, StringBuffer sb) {
|
|
|
|
|
|
List<ConfigCompile> compileAllList = new ArrayList<ConfigCompile>();
|
|
|
|
|
|
List<ConfigGroupRelation> groupRelationAllList = new ArrayList<ConfigGroupRelation>();
|
|
|
|
|
|
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>>();
|
2018-02-28 10:13:39 +08:00
|
|
|
|
Map<String, List<DigestRegion>> digestRegionMap = new HashMap<String, List<DigestRegion>>();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (null != compileList && compileList.size() > 0) {
|
|
|
|
|
|
for (ConfigCompile config : compileList) {
|
|
|
|
|
|
String msg = CompileVal.compileIsOk(config, true, sb);
|
|
|
|
|
|
if (msg != CompileJudgeCode.CompileIsOk.getErrorReason()) {
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 1:编译配置置为无效,需要将其下所有配置分组置为无效,如果数据中将域配置置为了无效则将域配置置为无效,否则不修改域配置是否生效标志
|
|
|
|
|
|
* 2:编译配置置为有效,不修改编译配置状态(编译配置不能从无效变有效,只能从有效变无效)仅修改编译配置其他属性,
|
|
|
|
|
|
*/
|
|
|
|
|
|
List<ConfigGroupRelation> groupRelationList = config.getGroupRelationList();
|
|
|
|
|
|
if (config.getIsValid() == 0) {// 编译配置修改为无效,需要将所有的配置分组置为无效
|
|
|
|
|
|
if (null != groupRelationList && groupRelationList.size() > 0) {
|
|
|
|
|
|
for (ConfigGroupRelation configGroupRelation : groupRelationList) {
|
|
|
|
|
|
configGroupRelation.setIsValid(0);
|
|
|
|
|
|
groupRelationAllList.add(configGroupRelation);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
List<IpRegion> ipRegionList = config.getIpRegionList();// 获取编译下所有ip类域配置(要修改的数据)
|
|
|
|
|
|
if (null != ipRegionList && ipRegionList.size() > 0) {
|
|
|
|
|
|
for (IpRegion ipRegion : ipRegionList) {
|
|
|
|
|
|
if (ipRegion.getIsValid() == 0) {
|
|
|
|
|
|
if (ipRegionMap.containsKey(ipRegion.getTableName())) {
|
|
|
|
|
|
ipRegionMap.get(ipRegion.getTableName()).add(ipRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<IpRegion> ipList = new ArrayList<IpRegion>();
|
|
|
|
|
|
ipList.add(ipRegion);
|
|
|
|
|
|
ipRegionMap.put(ipRegion.getTableName(), ipList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
List<StrRegion> strRegionList = config.getStrRegionList();// 获取编译下所有字符串类域配置(要修改的数据
|
|
|
|
|
|
if (null != strRegionList && strRegionList.size() > 0) {
|
|
|
|
|
|
for (StrRegion strRegion : strRegionList) {
|
|
|
|
|
|
if (strRegion.getIsValid() == 0) {
|
|
|
|
|
|
if (strRegionMap.containsKey(strRegion.getTableName())) {
|
|
|
|
|
|
strRegionMap.get(strRegion.getTableName()).add(strRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strList.add(strRegion);
|
|
|
|
|
|
strRegionMap.put(strRegion.getTableName(), strList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
List<NumRegion> numRegionList = config.getNumRegionList();// 获取编译下所有数值类域配置(要修改的数据
|
|
|
|
|
|
if (null != numRegionList && numRegionList.size() > 0) {
|
|
|
|
|
|
for (NumRegion numRegion : numRegionList) {
|
|
|
|
|
|
if (numRegion.getIsValid() == 0) {
|
|
|
|
|
|
if (numRegionMap.containsKey(numRegion.getTableName())) {
|
|
|
|
|
|
numRegionMap.get(numRegion.getTableName()).add(numRegion);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<NumRegion> numList = new ArrayList<NumRegion>();
|
|
|
|
|
|
numList.add(numRegion);
|
|
|
|
|
|
numRegionMap.put(numRegion.getTableName(), numList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-28 10:13:39 +08:00
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 14:55:52 +08:00
|
|
|
|
compileAllList.add(config);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("编译配置不能为空" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置不能为空" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 程序是否入库,测试分析数据的时间
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
if (null != compileAllList && compileAllList.size() > 0) {
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != groupRelationAllList && groupRelationAllList.size() > 0) {
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != strRegionMap && strRegionMap.size() > 0) {
|
|
|
|
|
|
count += strRegionMap.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != ipRegionMap && ipRegionMap.size() > 0) {
|
|
|
|
|
|
count += ipRegionMap.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionMap && numRegionMap.size() > 0) {
|
|
|
|
|
|
count += numRegionMap.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
|
|
|
|
|
Connection conn = sqlSessionFactory.openSession().getConnection();
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
|
|
|
|
|
UpdateCompileByJDBCThread compileThread = new UpdateCompileByJDBCThread(conn, latch, start, opTime);
|
|
|
|
|
|
compileThread.setCompileList(compileAllList);
|
|
|
|
|
|
Thread compile = new Thread(compileThread);
|
|
|
|
|
|
compile.start();
|
|
|
|
|
|
|
|
|
|
|
|
if (null != groupRelationAllList && groupRelationAllList.size() > 0) {
|
|
|
|
|
|
UpdateCompileByJDBCThread groupThread = new UpdateCompileByJDBCThread(conn, latch, start, opTime);
|
|
|
|
|
|
groupThread.setGroupList(groupRelationAllList);
|
|
|
|
|
|
Thread group = new Thread(groupThread);
|
|
|
|
|
|
group.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != strRegionMap && strRegionMap.size() > 0) {
|
|
|
|
|
|
for (String str : strRegionMap.keySet()) {
|
|
|
|
|
|
UpdateCompileByJDBCThread strRegion = new UpdateCompileByJDBCThread(str, conn, latch, start,
|
|
|
|
|
|
opTime);
|
|
|
|
|
|
strRegion.setStrRegionList(strRegionMap.get(str));
|
|
|
|
|
|
Thread strThread = new Thread(strRegion);
|
|
|
|
|
|
strThread.start();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (null != ipRegionMap && ipRegionMap.size() > 0) {
|
|
|
|
|
|
for (String ip : ipRegionMap.keySet()) {
|
|
|
|
|
|
UpdateCompileByJDBCThread ipRegion = new UpdateCompileByJDBCThread(ip, conn, latch, start, opTime);
|
|
|
|
|
|
ipRegion.setIpRegionList(ipRegionMap.get(ip));
|
|
|
|
|
|
Thread ipThread = new Thread(ipRegion);
|
|
|
|
|
|
ipThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionMap && numRegionMap.size() > 0) {
|
|
|
|
|
|
for (String num : numRegionMap.keySet()) {
|
|
|
|
|
|
UpdateCompileByJDBCThread numRegion = new UpdateCompileByJDBCThread(num, conn, latch, start,
|
|
|
|
|
|
opTime);
|
|
|
|
|
|
numRegion.setNumRegionList(numRegionMap.get(num));
|
|
|
|
|
|
Thread numThread = new Thread(numRegion);
|
|
|
|
|
|
numThread.start();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-02-28 10:13:39 +08:00
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 14:55:52 +08:00
|
|
|
|
try {
|
|
|
|
|
|
latch.await();
|
|
|
|
|
|
if (msgList.size() > 0) {
|
|
|
|
|
|
conn.rollback();
|
|
|
|
|
|
return "error";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
conn.commit();
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
thread.setExceptionInfo(e.toString());
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
if (!(e instanceof RestServiceException)) {
|
|
|
|
|
|
e = new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据修改失败",
|
|
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
throw ((RestServiceException) e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Description:只填写compile信息,根据compileId对compile以及与Group的对应关系进行配置状态更新操作
|
|
|
|
|
|
* @author (zdx)
|
|
|
|
|
|
* @date 2017年8月16日 上午11:21:53
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* @param compileList
|
|
|
|
|
|
* @param opTime
|
|
|
|
|
|
* @param sb
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String updateByJDBCThread3(SaveRequestLogThread thread, long start, List<ConfigCompile> compileList,
|
|
|
|
|
|
Date opTime, StringBuffer sb) {
|
|
|
|
|
|
List<ConfigCompile> compileAllList = new ArrayList<ConfigCompile>();
|
|
|
|
|
|
if (null != compileList && compileList.size() > 0) {
|
|
|
|
|
|
for (ConfigCompile config : compileList) {
|
|
|
|
|
|
String msg = checkCompileOptForUpdate(config);
|
2017-12-22 15:22:11 +08:00
|
|
|
|
if (config.getOpTime()==null) {
|
|
|
|
|
|
config.setOpTime(opTime);
|
|
|
|
|
|
}
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (!msg.equals("ok")) {
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
compileAllList.add(config);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("编译配置不能为空" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置不能为空" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 程序是否入库,测试分析数据的时间
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
if (null != compileAllList && compileAllList.size() > 0) {
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
count += 1; //将所有compile与Group的对应关系都置为失效 zdx20170814
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
|
|
|
|
|
Connection conn = sqlSessionFactory.openSession().getConnection();
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
|
|
|
|
|
|
|
|
|
|
|
UpdateCompileByJDBCThread compileThread = new UpdateCompileByJDBCThread(conn, latch, start, opTime);
|
|
|
|
|
|
compileThread.setCompileList(compileAllList);
|
|
|
|
|
|
Thread compile = new Thread(compileThread);
|
|
|
|
|
|
compile.start();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UpdateCompileByJDBCThread groupThread = new UpdateCompileByJDBCThread(conn, latch, start, opTime);
|
|
|
|
|
|
groupThread.setCompileList(compileAllList);
|
|
|
|
|
|
//仅用做判定线程执行时选择执行方法 zdx20170816
|
|
|
|
|
|
groupThread.setGroupList(new ArrayList<ConfigGroupRelation>());
|
|
|
|
|
|
Thread group = new Thread(groupThread);
|
|
|
|
|
|
group.start();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
latch.await();
|
|
|
|
|
|
if (msgList.size() > 0) {
|
|
|
|
|
|
conn.rollback();
|
|
|
|
|
|
return "error";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
conn.commit();
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
thread.setExceptionInfo(e.toString());
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
if (!(e instanceof RestServiceException)) {
|
|
|
|
|
|
e = new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置数据修改失败",
|
|
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
throw ((RestServiceException) e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Description:验证compileId+isValid
|
|
|
|
|
|
* @author (zdx)
|
|
|
|
|
|
* @date 2017年8月16日 上午11:48:46
|
|
|
|
|
|
* @param config
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private String checkCompileOptForUpdate(ConfigCompile config) {
|
|
|
|
|
|
if (StringUtil.isEmpty(config.getCompileId())) {
|
|
|
|
|
|
return "compileId字段不能为空";
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtil.isEmpty(config.getIsValid())) {
|
|
|
|
|
|
return "编译配置id为" + config.getCompileId()+"的IsValid字段不能为空";
|
|
|
|
|
|
}
|
|
|
|
|
|
if (config.getIsValid() != 0) {
|
|
|
|
|
|
return "编译配置id为" + config.getCompileId() + "的配置在修改时不能为有效";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取编译配置下所有的配置分组关系对应的有效,无效域配置id
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param config
|
|
|
|
|
|
* 编译配置对象
|
|
|
|
|
|
* @param queryCompileGroupByPID
|
|
|
|
|
|
* 当前编译下所有的配置分组关系
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Map<String, Map<Long, List<Long>>> getRegionList(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
ConfigCompile config, List<ConfigGroupRelation> queryCompileGroupByPID, StringBuffer sb) {
|
|
|
|
|
|
Map<String, Map<Long, List<Long>>> map = new HashMap<String, Map<Long, List<Long>>>();
|
|
|
|
|
|
Map<Integer, Map<String, String>> tableRelationMap = getTableRelation();
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> updateTableMap = tableRelationMap.get(config.getService().intValue());// 根据service获取需要操作的域配置表
|
|
|
|
|
|
if (null == updateTableMap || updateTableMap.size() == 0) {
|
|
|
|
|
|
thread.setExceptionInfo("找不到编译对应的service" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
|
|
|
|
|
"找不到编译对应的service" + sb.toString(), RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Long[] groupId = new Long[queryCompileGroupByPID.size()];
|
|
|
|
|
|
for (int i = 0; i < queryCompileGroupByPID.size(); i++) {
|
|
|
|
|
|
groupId[i] = queryCompileGroupByPID.get(i).getGroupId();
|
|
|
|
|
|
}
|
|
|
|
|
|
// 获取当前编译下所有的域配置信息
|
|
|
|
|
|
List<IpRegion> ipRegionExistList = new ArrayList<IpRegion>();
|
|
|
|
|
|
List<StrRegion> strRegionExistList = new ArrayList<StrRegion>();
|
|
|
|
|
|
List<NumRegion> numRegionExistList = new ArrayList<NumRegion>();
|
|
|
|
|
|
for (String tableName : updateTableMap.keySet()) {
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("ip")) {
|
|
|
|
|
|
ipRegionExistList.addAll(ipRegionDao.queryIpRegionByGroupId(tableName, groupId));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("num")) {
|
|
|
|
|
|
numRegionExistList.addAll(numRegionDao.queryNumRegionByGroupId(tableName, groupId));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("str")) {
|
|
|
|
|
|
strRegionExistList.addAll(strRegionDao.queryStrRegionByGroupId(tableName, groupId));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Map<Long, List<Long>> validMap = new HashMap<Long, List<Long>>();// 获取当前编译下所有的组,及每个组下面的有效域配置
|
|
|
|
|
|
Map<Long, List<Long>> noValidMap = new HashMap<Long, List<Long>>();// 获取当前编译下所有的组,及每个组下面的无效域配置
|
|
|
|
|
|
for (IpRegion ipRegion : ipRegionExistList) {
|
|
|
|
|
|
if (ipRegion.getIsValid() == 1) {
|
|
|
|
|
|
List<Long> validRegionList = null;
|
|
|
|
|
|
if (validMap.get(ipRegion.getGroupId()) == null) {
|
|
|
|
|
|
validRegionList = new ArrayList<Long>();
|
|
|
|
|
|
validRegionList.add(ipRegion.getRegionId());
|
|
|
|
|
|
validMap.put(ipRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
validRegionList = validMap.get(ipRegion.getGroupId());
|
|
|
|
|
|
// if (!validRegionList.contains(ipRegion.getRegionId())) {
|
|
|
|
|
|
validRegionList.add(ipRegion.getRegionId());
|
|
|
|
|
|
validMap.put(ipRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ipRegion.getIsValid() == 0) {
|
|
|
|
|
|
List<Long> noValidRegionList = null;
|
|
|
|
|
|
if (noValidMap.get(ipRegion.getGroupId()) == null) {
|
|
|
|
|
|
noValidRegionList = new ArrayList<Long>();
|
|
|
|
|
|
noValidRegionList.add(ipRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(ipRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
noValidRegionList = noValidMap.get(ipRegion.getGroupId());
|
|
|
|
|
|
// if (!noValidRegionList.contains(ipRegion.getRegionId()))
|
|
|
|
|
|
// {
|
|
|
|
|
|
noValidRegionList.add(ipRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(ipRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (StrRegion strRegion : strRegionExistList) {
|
|
|
|
|
|
if (strRegion.getIsValid() == 1) {
|
|
|
|
|
|
List<Long> validRegionList = null;
|
|
|
|
|
|
if (validMap.get(strRegion.getGroupId()) == null) {
|
|
|
|
|
|
validRegionList = new ArrayList<Long>();
|
|
|
|
|
|
|
|
|
|
|
|
validRegionList.add(strRegion.getRegionId());
|
|
|
|
|
|
|
|
|
|
|
|
validMap.put(strRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
validRegionList = validMap.get(strRegion.getGroupId());
|
|
|
|
|
|
// if (!validRegionList.contains(strRegion.getRegionId())) {
|
|
|
|
|
|
validRegionList.add(strRegion.getRegionId());
|
|
|
|
|
|
validMap.put(strRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strRegion.getIsValid() == 0) {
|
|
|
|
|
|
List<Long> noValidRegionList = null;
|
|
|
|
|
|
if (noValidMap.get(strRegion.getGroupId()) == null) {
|
|
|
|
|
|
noValidRegionList = new ArrayList<Long>();
|
|
|
|
|
|
noValidRegionList.add(strRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(strRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
noValidRegionList = noValidMap.get(strRegion.getGroupId());
|
|
|
|
|
|
// if (!noValidRegionList.contains(strRegion.getRegionId()))
|
|
|
|
|
|
// {
|
|
|
|
|
|
noValidRegionList.add(strRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(strRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (NumRegion numRegion : numRegionExistList) {
|
|
|
|
|
|
if (numRegion.getIsValid() == 1) {
|
|
|
|
|
|
List<Long> validRegionList = null;
|
|
|
|
|
|
if (validMap.get(numRegion.getGroupId()) == null) {
|
|
|
|
|
|
validRegionList = new ArrayList<Long>();
|
|
|
|
|
|
validRegionList.add(numRegion.getRegionId());
|
|
|
|
|
|
validMap.put(numRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
validRegionList = validMap.get(numRegion.getGroupId());
|
|
|
|
|
|
// if (!validRegionList.contains(numRegion.getRegionId())) {
|
|
|
|
|
|
validRegionList.add(numRegion.getRegionId());
|
|
|
|
|
|
validMap.put(numRegion.getGroupId(), validRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (numRegion.getIsValid() == 0) {
|
|
|
|
|
|
List<Long> noValidRegionList = null;
|
|
|
|
|
|
if (noValidMap.get(numRegion.getGroupId()) == null) {
|
|
|
|
|
|
noValidRegionList = new ArrayList<Long>();
|
|
|
|
|
|
noValidRegionList.add(numRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(numRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
noValidRegionList = noValidMap.get(numRegion.getGroupId());
|
|
|
|
|
|
// if (!noValidRegionList.contains(numRegion.getRegionId()))
|
|
|
|
|
|
// {
|
|
|
|
|
|
noValidRegionList.add(numRegion.getRegionId());
|
|
|
|
|
|
noValidMap.put(numRegion.getGroupId(), noValidRegionList);
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
map.put("noValidMap", noValidMap);
|
|
|
|
|
|
map.put("validMap", validMap);
|
|
|
|
|
|
return map;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
public String configModifySources(List<ConfigCompile> configCompileList) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
for (ConfigCompile configCompile : configCompileList) {
|
|
|
|
|
|
Long compileId = configCompile.getCompileId();
|
|
|
|
|
|
if (null != compileId) {
|
|
|
|
|
|
configCompileDao.updateConfigCompile(configCompile);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return "idIsNull";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String setCompileInvalid(ConfigCompile configCompile) throws Exception {
|
|
|
|
|
|
configCompileDao.setCompileInvalid(configCompile.getCompileId(), 0);
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String setCompileValid(ConfigCompile configCompile) throws Exception {
|
|
|
|
|
|
configCompileDao.setCompileInvalid(configCompile.getCompileId(), 1);
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|