2017-12-19 14:55:52 +08:00
|
|
|
|
package com.nis.web.service.restful;
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
import java.beans.IntrospectionException;
|
2018-05-25 19:37:05 +08:00
|
|
|
|
import java.beans.PropertyDescriptor;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
2018-05-25 19:37:05 +08:00
|
|
|
|
import java.lang.reflect.Method;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
|
import java.sql.SQLException;
|
2018-05-24 17:22:38 +08:00
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.HashMap;
|
2018-05-24 17:22:38 +08:00
|
|
|
|
import java.util.Iterator;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
2018-05-24 17:22:38 +08:00
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
2018-06-04 15:14:52 +08:00
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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;
|
|
|
|
|
|
|
2018-05-24 17:22:38 +08:00
|
|
|
|
import com.google.gson.JsonArray;
|
|
|
|
|
|
import com.google.gson.JsonObject;
|
|
|
|
|
|
import com.google.gson.JsonParser;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
import com.nis.domain.Page;
|
2018-05-24 17:22:38 +08:00
|
|
|
|
import com.nis.domain.restful.CommonSourceFieldCfg;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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;
|
2018-05-25 19:37:05 +08:00
|
|
|
|
import com.nis.domain.restful.MaatConfig;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
import com.nis.domain.restful.NumRegion;
|
|
|
|
|
|
import com.nis.domain.restful.StrRegion;
|
|
|
|
|
|
import com.nis.restful.RestBusinessCode;
|
|
|
|
|
|
import com.nis.restful.RestServiceException;
|
2018-05-24 17:22:38 +08:00
|
|
|
|
import com.nis.util.BasicProvingUtil;
|
2018-05-25 19:37:05 +08:00
|
|
|
|
import com.nis.util.CamelUnderlineUtil;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
import com.nis.util.CompileVal;
|
|
|
|
|
|
import com.nis.util.Configurations;
|
2018-06-01 10:27:03 +08:00
|
|
|
|
import com.nis.util.Constants;
|
2018-06-28 18:52:23 +08:00
|
|
|
|
import com.nis.util.JsonMapper;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
import com.nis.util.OracleErrorCodeUtil;
|
2018-05-24 17:22:38 +08:00
|
|
|
|
import com.nis.util.ReadCommSourceXmlUtil;
|
2018-06-01 10:27:03 +08:00
|
|
|
|
import com.nis.util.ServiceAndRDBIndexReal;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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;
|
|
|
|
|
|
|
2018-06-22 10:48:53 +08:00
|
|
|
|
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-24 17:22:38 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
ConfigRedisService configRedisService;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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-06-01 10:27:03 +08:00
|
|
|
|
typeMap.put("MM_AV_IP", "ip");
|
2018-05-25 19:37:05 +08:00
|
|
|
|
tableMap.put(80, typeMap);
|
|
|
|
|
|
tableMap.put(144, typeMap);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-25 19:37:05 +08:00
|
|
|
|
typeMap = new HashMap<String, String>();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
typeMap.put("MM_AV_URL", "str");
|
2018-05-25 19:37:05 +08:00
|
|
|
|
tableMap.put(81, typeMap);
|
|
|
|
|
|
tableMap.put(145, typeMap);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-25 19:37:05 +08:00
|
|
|
|
typeMap = new HashMap<String, String>();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
typeMap.put("MM_PIC_IP", "ip");
|
2018-05-25 19:37:05 +08:00
|
|
|
|
tableMap.put(82, typeMap);
|
|
|
|
|
|
tableMap.put(146, typeMap);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-25 19:37:05 +08:00
|
|
|
|
typeMap = new HashMap<String, String>();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
typeMap.put("MM_PIC_URL", "str");
|
2018-05-25 19:37:05 +08:00
|
|
|
|
tableMap.put(83, typeMap);
|
|
|
|
|
|
tableMap.put(147, typeMap);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-25 19:37:05 +08:00
|
|
|
|
typeMap = new HashMap<String, String>();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
typeMap.put("MM_VOIP_IP", "ip");
|
2018-05-25 19:37:05 +08:00
|
|
|
|
tableMap.put(84, typeMap);
|
|
|
|
|
|
tableMap.put(148, typeMap);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-25 19:37:05 +08:00
|
|
|
|
typeMap = new HashMap<String, String>();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
typeMap.put("MM_VOIP_ACCOUNT", "str");
|
2018-05-25 19:37:05 +08:00
|
|
|
|
tableMap.put(85, typeMap);
|
|
|
|
|
|
tableMap.put(149, typeMap);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-25 19:37:05 +08:00
|
|
|
|
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);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-02-09 17:49:14 +08:00
|
|
|
|
typeMap = new HashMap<String, String>();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
typeMap.put("DF_IP_PORT", "ip");
|
2018-07-04 17:03:04 +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-07-04 17:03:04 +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);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
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-07-04 17:03:04 +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-07-04 17:03:04 +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");
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-06-01 10:27:03 +08:00
|
|
|
|
typeMap.put("WHITE_LIST_IP", "ip");
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 批量(mybatis方式)修改配置业务逻辑-->1:先进行基础配置验证传过来的json串是否符合格式(配置分组关系前端不能设置为无效,
|
|
|
|
|
|
* 程序会根据传过来的编译配置和域配置等信息自动设置为无效). 符合要求调用updateConfigCompile方法继续验证
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param compileList
|
|
|
|
|
|
* 编译配置集合
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public void updateConfigSource(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
List<ConfigCompile> configSource, Date opTime, StringBuffer sb) {
|
|
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder
|
|
|
|
|
|
.getBean(SqlSessionFactory.class);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
SqlSession batchSqlSession = null;
|
|
|
|
|
|
try {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH,
|
|
|
|
|
|
false);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (null != configSource && configSource.size() > 0) {
|
|
|
|
|
|
for (ConfigCompile config : configSource) {
|
|
|
|
|
|
String msg = CompileVal.compileIsOk(config, true, sb);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!"ok".equals(msg)) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg
|
|
|
|
|
|
+ sb.toString(),
|
|
|
|
|
|
CompileVal.getBusinessCode());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
updateConfigCompile(thread, start, config, batchSqlSession,
|
|
|
|
|
|
opTime, sb);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("编译配置不能为空" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "编译配置不能为空"
|
|
|
|
|
|
+ sb.toString(),
|
|
|
|
|
|
CompileVal.getBusinessCode());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
logger1.info("数据保存到数据库提交事务开始");
|
|
|
|
|
|
batchSqlSession.commit();
|
|
|
|
|
|
logger1.info("数据保存到数据库成功");
|
|
|
|
|
|
} catch (RestServiceException e) {
|
|
|
|
|
|
logger1.error(e);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
thread.setExceptionInfo(e.getMessage() + " " + e.getCause()
|
|
|
|
|
|
+ sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- start, e.getMessage() + sb.toString(), e.getErrorCode());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
String errorCode = OracleErrorCodeUtil.getOraCode(e);
|
|
|
|
|
|
if (!StringUtils.isEmpty(errorCode)) {
|
|
|
|
|
|
logger1.error("数据更新发生异常!");
|
2018-07-04 17:03:04 +08:00
|
|
|
|
thread.setExceptionInfo(e.getMessage() + " " + e.getCause()
|
|
|
|
|
|
+ sb.toString());
|
|
|
|
|
|
OracleErrorCodeUtil.throwExceptionInfo(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, errorCode);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("数据更新发生异常" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "数据更新发生异常"
|
|
|
|
|
|
+ sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
if (batchSqlSession != null) {
|
|
|
|
|
|
batchSqlSession.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 批量(mybatis方式)修改配置业务逻辑-->2:判断配置在数据库中是否已经是无效了如果是无效则提示不能修改无效的配置为有效(
|
|
|
|
|
|
* 因为如果数据库中的编译配置与配置分组关系以及域配置均是无效
|
|
|
|
|
|
* ,传过来的数据是编译配置和配置分组关系是有效,域配置是无效,这样会将数据库中无效的编译配置置为有效,这是不允许的)
|
2017-12-19 14:55:52 +08:00
|
|
|
|
* 3:如果编译配置置为无效将所有的配置分组关系置为无效,不修改域配置状态(分组复用考虑,域可能被其他的组引用)
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 4:如果编译配置为有效,域配置为无效,则先获取该编译配置下各个配置分组关系下的所有有效的域配置信息和所有无效的域配置信息,
|
|
|
|
|
|
* 如果数据库中有效的域配置信息和前端传过来置为无效的的域配置信息个数,id都相等,则将对应域配置,配置分组关系,编译配置均置为无效
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 20161124讨论暂时先去掉2步骤,因为界面目前传过来的数据编译配置,配置分组关系,域配置均是无效,所以就不执行第2步骤了影响性能(
|
|
|
|
|
|
* 方法内注释的代码,如果以后业务需要调整打开下面代码即可)
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param compileList
|
|
|
|
|
|
* 编译配置集合
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public void updateConfigCompile(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
ConfigCompile config, SqlSession batchSqlSession, Date opTime,
|
|
|
|
|
|
StringBuffer sb) throws Exception {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
List<IpRegion> ipRegionList = config.getIpRegionList();
|
|
|
|
|
|
List<StrRegion> strRegionList = config.getStrRegionList();
|
|
|
|
|
|
List<NumRegion> numRegionList = config.getNumRegionList();
|
2018-07-04 17:03:04 +08:00
|
|
|
|
List<ConfigGroupRelation> groupRelationList = config
|
|
|
|
|
|
.getGroupRelationList();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (config.getIsValid() == 1) {
|
|
|
|
|
|
if (groupRelationList == null || groupRelationList.size() == 0) {
|
|
|
|
|
|
thread.setExceptionInfo("配置分组数量不能为空" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "配置分组数量不能为空"
|
|
|
|
|
|
+ sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "域配置数量不能全部为空"
|
|
|
|
|
|
+ sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConfigCompile configCompile =
|
|
|
|
|
|
// configCompileDao.queryConfigCompileById(config.getCompileId());//
|
|
|
|
|
|
// 先判断该条编译配置数据库中状态是否为无效,如果无效则提示用户不能将无效状态改为有效状态
|
|
|
|
|
|
// if (configCompile.getIsValid() == 1) {// 数据库中编译配置为有效状态才可以进行修改操作
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 1:编译配置置为无效,需要将其下所有配置分组置为无效,如果数据中将域配置置为了无效则将域配置置为无效,否则不修改域配置是否生效标志
|
|
|
|
|
|
* 2:编译配置置为有效,不修改编译配置状态(编译配置不能从无效变有效,只能从有效变无效)仅修改编译配置其他属性,
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
List<ConfigGroupRelation> queryCompileGroupByPID = configGroupRelationDao
|
|
|
|
|
|
.queryCompileGroupByPID(config.getCompileId());
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null == queryCompileGroupByPID
|
|
|
|
|
|
|| queryCompileGroupByPID.size() == 0) {
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- start, "配置id为" + config.getCompileId()
|
|
|
|
|
|
+ "的配置在数据库中找不到对应的配置分组关系,请检查json串是否正确" + sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (config.getIsValid() == 0) {// 编译配置修改为无效,需要将所有的配置分组置为无效
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != queryCompileGroupByPID
|
|
|
|
|
|
&& queryCompileGroupByPID.size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (ConfigGroupRelation configGroupRelation : queryCompileGroupByPID) {
|
|
|
|
|
|
configGroupRelation.setIsValid(0);
|
|
|
|
|
|
configGroupRelation.setOpTime(opTime);
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false")
|
|
|
|
|
|
.equals("true")) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
batchSqlSession.getMapper(ConfigGroupRelationDao.class)
|
|
|
|
|
|
.updateConfigGroupRelation(configGroupRelation);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// config.setLastUpdate(new Date());
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals(
|
|
|
|
|
|
"true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(ConfigCompileDao.class)
|
|
|
|
|
|
.updateConfigCompile(config);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
regionUpdate(thread, start, config, queryCompileGroupByPID,
|
|
|
|
|
|
batchSqlSession, opTime, sb);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// } else {// 数据库中编译配置为无效状态不能进行操作
|
|
|
|
|
|
// throw new RestServiceException(thread, System.currentTimeMillis() -
|
|
|
|
|
|
// start, "不能修改无效的编译配置信息",
|
|
|
|
|
|
// RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取编译配置下所有的配置分组关系对应的有效,无效域配置id
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param config
|
|
|
|
|
|
* 编译配置对象
|
|
|
|
|
|
* @param queryCompileGroupByPID
|
|
|
|
|
|
* 当前编译下所有的配置分组关系
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public void regionUpdate(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
ConfigCompile config,
|
|
|
|
|
|
List<ConfigGroupRelation> queryCompileGroupByPID,
|
|
|
|
|
|
SqlSession batchSqlSession, Date opTime, StringBuffer sb)
|
2017-12-19 14:55:52 +08:00
|
|
|
|
throws Exception {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Map<String, Map<Long, List<Long>>> regionMap = getRegionList(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, config,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != validList
|
|
|
|
|
|
&& validList.contains(ipRegion.getRegionId())) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (ipRegion.getIsValid() == 0) {
|
|
|
|
|
|
ipRegion.setOpTime(opTime);
|
|
|
|
|
|
ipRegion.setLastUpdate(new Date());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty(
|
|
|
|
|
|
"isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession
|
|
|
|
|
|
.getMapper(IpRegionDao.class)
|
|
|
|
|
|
.updateIpRegion(ipRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
count++;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!tableList
|
|
|
|
|
|
.contains(ipRegion.getTableName())) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
tableList.add(ipRegion.getTableName());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else if (null != noValidList
|
|
|
|
|
|
&& noValidList.contains(ipRegion.getRegionId())) {
|
|
|
|
|
|
String msg = "不能修改无效的ip类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId() + "regionid为"
|
2017-12-19 14:55:52 +08:00
|
|
|
|
+ ipRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
} else {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String msg = "找不到对应的的ip类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId() + "regionid为"
|
2017-12-19 14:55:52 +08:00
|
|
|
|
+ ipRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != validList
|
|
|
|
|
|
&& validList.contains(strRegion.getRegionId())) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (strRegion.getIsValid() == 0) {
|
|
|
|
|
|
strRegion.setOpTime(opTime);
|
|
|
|
|
|
strRegion.setLastUpdate(new Date());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty(
|
|
|
|
|
|
"isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(
|
|
|
|
|
|
StrRegionDao.class)
|
|
|
|
|
|
.updateStrRegion(strRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
count++;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!tableList.contains(strRegion
|
|
|
|
|
|
.getTableName())) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
tableList.add(strRegion.getTableName());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else if (null != noValidList
|
|
|
|
|
|
&& noValidList
|
|
|
|
|
|
.contains(strRegion.getRegionId())) {
|
|
|
|
|
|
String msg = "不能修改无效的字符串类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId() + "regionid为"
|
2017-12-19 14:55:52 +08:00
|
|
|
|
+ strRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
} else {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String msg = "找不到对应的的字符串类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId() + "regionid为"
|
2017-12-19 14:55:52 +08:00
|
|
|
|
+ strRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != validList
|
|
|
|
|
|
&& validList.contains(numRegion.getRegionId())) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (numRegion.getIsValid() == 0) {
|
|
|
|
|
|
numRegion.setOpTime(opTime);
|
|
|
|
|
|
numRegion.setLastUpdate(new Date());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty(
|
|
|
|
|
|
"isCommit", "false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(
|
|
|
|
|
|
NumRegionDao.class)
|
|
|
|
|
|
.updateNumRegion(numRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
count++;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!tableList.contains(numRegion
|
|
|
|
|
|
.getTableName())) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
tableList.add(numRegion.getTableName());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else if (null != noValidList
|
|
|
|
|
|
&& noValidList
|
|
|
|
|
|
.contains(numRegion.getRegionId())) {
|
|
|
|
|
|
String msg = "不能修改无效的数值类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId() + "regionid为"
|
2017-12-19 14:55:52 +08:00
|
|
|
|
+ numRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
} else {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String msg = "找不到对应的的数值类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId() + "regionid为"
|
2017-12-19 14:55:52 +08:00
|
|
|
|
+ numRegion.getRegionId() + sb.toString();
|
|
|
|
|
|
thread.setExceptionInfo(msg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (count == validList.size()) {// 数据库中当前配置分组下有效的域配置,均被修改为无效,所以要将该配置分组置为无效
|
2018-07-04 17:03:04 +08:00
|
|
|
|
List<ConfigGroupRelation> groupRelationList = config
|
|
|
|
|
|
.getGroupRelationList();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (ConfigGroupRelation configGroupRelation : groupRelationList) {
|
|
|
|
|
|
if (configGroupRelation.getGroupId().equals(regionId)) {
|
|
|
|
|
|
num++;
|
|
|
|
|
|
configGroupRelation.setIsValid(0);
|
|
|
|
|
|
configGroupRelation.setOpTime(opTime);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty("isCommit",
|
|
|
|
|
|
"false").equals("true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(
|
|
|
|
|
|
ConfigGroupRelationDao.class)
|
|
|
|
|
|
.updateConfigGroupRelation(
|
|
|
|
|
|
configGroupRelation);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (num == validMap.size()) {// 所有的域均是无效的所有的组均是无效,需要将编译配置置为无效
|
|
|
|
|
|
config.setIsValid(0);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false").equals(
|
|
|
|
|
|
"true")) {
|
|
|
|
|
|
batchSqlSession.getMapper(ConfigCompileDao.class)
|
|
|
|
|
|
.updateConfigCompile(config);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public Map<String, Map<Long, List<Long>>> getRegionList(
|
|
|
|
|
|
SaveRequestLogThread thread, long start, ConfigCompile config,
|
|
|
|
|
|
List<ConfigGroupRelation> queryCompileGroupByPID,
|
|
|
|
|
|
SqlSession batchSqlSession, StringBuffer sb) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
Map<String, Map<Long, List<Long>>> map = new HashMap<String, Map<Long, List<Long>>>();
|
|
|
|
|
|
Map<Integer, Map<String, String>> tableRelationMap = getTableRelation();
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Map<String, String> updateTableMap = tableRelationMap.get(config
|
|
|
|
|
|
.getService().intValue());// 根据service获取需要操作的域配置表
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (null == updateTableMap) {
|
|
|
|
|
|
thread.setExceptionInfo("找不到编译对应的service" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- start, "找不到编译对应的service" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
List<IpRegion> queryIpRegionByGroupId = ipRegionDao
|
|
|
|
|
|
.queryIpRegionByGroupId(tableName, groupId);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
ipRegionExistList.addAll(queryIpRegionByGroupId);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("num")) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
numRegionExistList.addAll(numRegionDao.queryNumRegionByGroupId(
|
|
|
|
|
|
tableName, groupId));
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("str")) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionExistList.addAll(strRegionDao.queryStrRegionByGroupId(
|
|
|
|
|
|
tableName, groupId));
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2017-12-19 14:55:52 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 批量插入配置编译数据在数据库中循环
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param configSource
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public void insertConfigSourceData(SaveRequestLogThread thread,
|
|
|
|
|
|
long _start, List<ConfigCompile> configSource, StringBuffer sb) {
|
|
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder
|
|
|
|
|
|
.getBean(SqlSessionFactory.class);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
SqlSession batchSqlSession = null;
|
|
|
|
|
|
try {
|
|
|
|
|
|
// batchSqlSession =
|
|
|
|
|
|
// sqlSessionFactory.openSession(ExecutorType.SIMPLE, false);
|
|
|
|
|
|
batchSqlSession = sqlSessionFactory.openSession();
|
|
|
|
|
|
int index = 150;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
int count = configSource.size() % index == 0 ? configSource.size()
|
|
|
|
|
|
/ index : configSource.size() / index + 1;
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
|
|
int start = i * index;
|
|
|
|
|
|
int end = i * index + index;
|
|
|
|
|
|
if (end > configSource.size()) {
|
|
|
|
|
|
end = configSource.size();
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
List<ConfigCompile> compileList = configSource.subList(start,
|
|
|
|
|
|
end);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
insertConfigComLileData(thread, _start, compileList, sb);
|
|
|
|
|
|
// logger1.info(insertConfigComLile);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
logger1.info("数据保存到数据库提交事务开始");
|
|
|
|
|
|
batchSqlSession.commit();
|
|
|
|
|
|
logger1.info("数据保存到数据库成功");
|
|
|
|
|
|
|
|
|
|
|
|
} catch (RestServiceException e) {
|
|
|
|
|
|
logger1.error(e);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
thread.setExceptionInfo(e.getMessage() + " " + e.getCause()
|
|
|
|
|
|
+ sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- _start, e.getMessage() + sb.toString(), e.getErrorCode());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger1.error(e);
|
|
|
|
|
|
String errorCode = OracleErrorCodeUtil.getOraCode(e);
|
|
|
|
|
|
if (!StringUtils.isEmpty(errorCode)) {
|
|
|
|
|
|
thread.setExceptionInfo("数据保存发生异常" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
OracleErrorCodeUtil.throwExceptionInfo(thread,
|
|
|
|
|
|
System.currentTimeMillis() - _start, errorCode);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("数据保存发生异常" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - _start, "数据保存发生异常"
|
|
|
|
|
|
+ sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
if (batchSqlSession != null) {
|
|
|
|
|
|
batchSqlSession.close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 验证数据是否符合要求 插入编译配置数据 验证分组配置数据 验证域配置数据 方法二 数据库中循环
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param configCompileList
|
|
|
|
|
|
* @param batchSqlSession
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
private String insertConfigComLileData(SaveRequestLogThread thread,
|
|
|
|
|
|
long start, List<ConfigCompile> configCompileList, StringBuffer sb)
|
|
|
|
|
|
throws Exception {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
|
|
|
|
|
|
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);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!"ok".equals(msg)) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(msg);
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
msg + sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != configCompile.getGroupRelationList()
|
|
|
|
|
|
&& configCompile.getGroupRelationList().size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
groupRelationList.addAll(configCompile.getGroupRelationList());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
logger1.error("配置分组数量不能为空" + sb.toString());
|
|
|
|
|
|
thread.setExceptionInfo("配置分组数量不能为空" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "配置分组数量不能为空"
|
|
|
|
|
|
+ sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != configCompile.getStrRegionList()
|
|
|
|
|
|
&& configCompile.getStrRegionList().size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (StrRegion strRegion : configCompile.getStrRegionList()) {
|
|
|
|
|
|
if (!isStrStrongRegion(strRegion.getTableName())) {
|
|
|
|
|
|
if (strRegion.getRegionId() == null) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "字符类域配置id不能为空 ,表名---"
|
|
|
|
|
|
+ strRegion.getTableName() + ""
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(errorMsg);
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strRegionMap.containsKey(strRegion.getTableName())) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionMap.get(strRegion.getTableName()).add(
|
|
|
|
|
|
strRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strRegionList.add(strRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionMap.put(strRegion.getTableName(),
|
|
|
|
|
|
strRegionList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (strRegion.getRegionId() == null) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "增强字符类域配置id不能为空 ,表名---"
|
|
|
|
|
|
+ strRegion.getTableName() + ""
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(errorMsg);
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (strStongRegionMap.containsKey(strRegion
|
|
|
|
|
|
.getTableName())) {
|
|
|
|
|
|
strStongRegionMap.get(strRegion.getTableName())
|
|
|
|
|
|
.add(strRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strStrongRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strStrongRegionList.add(strRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strStongRegionMap.put(strRegion.getTableName(),
|
|
|
|
|
|
strStrongRegionList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != configCompile.getIpRegionList()
|
|
|
|
|
|
&& configCompile.getIpRegionList().size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (IpRegion ipRegion : configCompile.getIpRegionList()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!ipRegion.getTableName().toUpperCase()
|
|
|
|
|
|
.equals("DJ_IP_PORT")) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
ipRegion.setProtocol(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ipRegion.getRegionId() == null) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "ip类域配置id不能为空 ,表名---"
|
|
|
|
|
|
+ ipRegion.getTableName() + "" + sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(errorMsg);
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, errorMsg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != configCompile.getNumRegionList()
|
|
|
|
|
|
&& configCompile.getNumRegionList().size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (NumRegion numRegion : configCompile.getNumRegionList()) {
|
|
|
|
|
|
if (numRegion.getRegionId() == null) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "数值类域配置id不能为空 ,表名---"
|
|
|
|
|
|
+ numRegion.getTableName() + "" + sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(errorMsg);
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, errorMsg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (numRegionMap.containsKey(numRegion.getTableName())) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
numRegionMap.get(numRegion.getTableName()).add(
|
|
|
|
|
|
numRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<NumRegion> numRegionList = new ArrayList<NumRegion>();
|
|
|
|
|
|
numRegionList.add(numRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
numRegionMap.put(numRegion.getTableName(),
|
|
|
|
|
|
numRegionList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false")
|
|
|
|
|
|
.equals("true")) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
configCompileDao.saveCompileBatch(configCompileList);
|
|
|
|
|
|
if (groupRelationList.size() > 0) {
|
|
|
|
|
|
for (ConfigGroupRelation group : groupRelationList) {
|
|
|
|
|
|
configGroupRelationDao.saveConfigGroupRelation(group);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (String str : strRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionDao.saveStrRegionBatch(strRegionMap.get(str).get(0)
|
|
|
|
|
|
.getTableName(), strRegionMap.get(str));
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
for (String strStrong : strStongRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionDao.saveStrStrongRegionBatch(
|
|
|
|
|
|
strStongRegionMap.get(strStrong).get(0).getTableName(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
strStongRegionMap.get(strStrong));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (String ip : ipRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
ipRegionDao.saveIpRegionBatch(ipRegionMap.get(ip).get(0)
|
|
|
|
|
|
.getTableName(), ipRegionMap.get(ip));
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
for (String num : numRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
numRegionDao.saveNumRegionBatch(numRegionMap.get(num).get(0)
|
|
|
|
|
|
.getTableName(), numRegionMap.get(num));
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "编译配置数据验证成功";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2017-12-19 14:55:52 +08:00
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public Page<ConfigCompileTest> queryAllCompile(
|
|
|
|
|
|
Page<ConfigCompileTest> page, ConfigCompileTest entity)
|
2017-12-19 14:55:52 +08:00
|
|
|
|
throws SQLException {
|
|
|
|
|
|
entity.setPage(page);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
page.setList(configCompileDao.queryAllCompile(
|
|
|
|
|
|
entity.getSearchEndTime(), entity.getSearchStartTime(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
entity.getService(), entity.getCompileId()));
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<ConfigCompileTest> queryAllCompile(ConfigCompileTest entity) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
return configCompileDao.queryAllCompile(entity.getSearchEndTime(),
|
|
|
|
|
|
entity.getSearchStartTime(), entity.getService(),
|
|
|
|
|
|
entity.getCompileId());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<ConfigCompileTest> queryConfigCompileByIdArr(String compileIdArr) {
|
|
|
|
|
|
return configCompileDao.queryConfigCompileByIdArr(compileIdArr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<ConfigGroupRelation> getGroupByCompile(long compileId) {
|
|
|
|
|
|
return configGroupRelationDao.queryCompileGroupByPID(compileId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public List<StrRegion> getStrRegionByGId(List<String> tableList,
|
|
|
|
|
|
Long[] groupId) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
if (null != tableList && tableList.size() > 0) {
|
|
|
|
|
|
for (String tableName : tableList) {
|
|
|
|
|
|
List<StrRegion> queryStrRegionByGroupId = null;
|
|
|
|
|
|
if (isStrStrongRegion(tableName)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
queryStrRegionByGroupId = strRegionDao
|
|
|
|
|
|
.queryStrStrongRegionByGroupId(tableName, groupId);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
queryStrRegionByGroupId = strRegionDao
|
|
|
|
|
|
.queryStrRegionByGroupId(tableName, groupId);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != queryStrRegionByGroupId
|
|
|
|
|
|
&& queryStrRegionByGroupId.size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (StrRegion strRegion : queryStrRegionByGroupId) {
|
|
|
|
|
|
strRegion.setTableName(tableName);
|
|
|
|
|
|
strRegionList.add(strRegion);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return strRegionList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<IpRegion> getIpRegionByGId(String table, Long[] groupId) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
List<IpRegion> queryIpRegionByGroupId = ipRegionDao
|
|
|
|
|
|
.queryIpRegionByGroupId(table, groupId);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (IpRegion ipRegion : queryIpRegionByGroupId) {
|
|
|
|
|
|
ipRegion.setTableName(table);
|
|
|
|
|
|
}
|
|
|
|
|
|
return queryIpRegionByGroupId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<NumRegion> getNumRegionByGId(String table, Long[] groupId) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
List<NumRegion> queryNumRegionByGroupId = numRegionDao
|
|
|
|
|
|
.queryNumRegionByGroupId(table, groupId);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-05-25 19:37:05 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @Description:
|
|
|
|
|
|
* @author (zdx)
|
|
|
|
|
|
* @date 2018年5月25日 下午3:49:46
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* @param configCompileList
|
|
|
|
|
|
* @param sb
|
|
|
|
|
|
* @return
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public String saveMaatConfig(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
List<ConfigCompile> configCompileList, StringBuffer sb) {
|
|
|
|
|
|
// List<MaatConfig> maatConfigList = new ArrayList<MaatConfig>();
|
|
|
|
|
|
// List<Integer> serviceList = new ArrayList<Integer>();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
|
|
|
|
|
|
CompileVal.setBusinessCode(null);
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
for (ConfigCompile configCompile : configCompileList) {
|
|
|
|
|
|
Integer service = Integer.valueOf(configCompile.getService()
|
|
|
|
|
|
.toString());
|
|
|
|
|
|
MaatConfig maatConfig = new MaatConfig();
|
|
|
|
|
|
String msg = CompileVal.compileIsOk(configCompile, false, sb);
|
|
|
|
|
|
if (!"ok".equals(msg)) {
|
|
|
|
|
|
logger1.error(msg);
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg
|
|
|
|
|
|
+ sb.toString(),
|
|
|
|
|
|
CompileVal.getBusinessCode());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!(null != configCompile.getGroupRelationList() && configCompile
|
|
|
|
|
|
.getGroupRelationList().size() > 0)) {
|
|
|
|
|
|
logger1.error("配置分组列表不能为空" + sb.toString());
|
|
|
|
|
|
thread.setExceptionInfo("配置分组数量不能为空" + sb.toString());
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "配置分组列表不能为空"
|
|
|
|
|
|
+ sb.toString(),
|
|
|
|
|
|
RestBusinessCode.CompileGroupIsNull.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != configCompile.getStrRegionList()
|
|
|
|
|
|
&& configCompile.getStrRegionList().size() > 0) {
|
|
|
|
|
|
for (StrRegion strRegion : configCompile.getStrRegionList()) {
|
|
|
|
|
|
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.RegionIdIsNull.getValue());
|
|
|
|
|
|
}
|
2018-05-25 19:37:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != configCompile.getIpRegionList()
|
|
|
|
|
|
&& configCompile.getIpRegionList().size() > 0) {
|
|
|
|
|
|
for (IpRegion ipRegion : configCompile.getIpRegionList()) {
|
|
|
|
|
|
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.RegionIdIsNull.getValue());
|
|
|
|
|
|
}
|
2018-05-25 19:37:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
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.RegionIdIsNull.getValue());
|
|
|
|
|
|
}
|
2018-05-25 19:37:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +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.RegionIdIsNull.getValue());
|
|
|
|
|
|
}
|
2018-05-25 19:37:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
if (null != configCompile.getIpClientRangeList()
|
|
|
|
|
|
&& configCompile.getIpClientRangeList().size() > 0) {
|
|
|
|
|
|
for (IpRegion ipRegion : configCompile
|
|
|
|
|
|
.getIpClientRangeList()) {
|
|
|
|
|
|
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.RegionIdIsNull.getValue());
|
|
|
|
|
|
}
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
maatConfig.setService(service);
|
|
|
|
|
|
// 编译
|
|
|
|
|
|
maatConfig.setCompileMap(convertObjectToMap(configCompile,
|
|
|
|
|
|
ConfigCompile.class));
|
|
|
|
|
|
// 分组
|
|
|
|
|
|
List<Map<String, String>> dstMaplList = null;
|
|
|
|
|
|
if (!StringUtil.isEmpty(configCompile.getGroupRelationList())) {
|
|
|
|
|
|
dstMaplList = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
for (ConfigGroupRelation group : configCompile
|
|
|
|
|
|
.getGroupRelationList()) {
|
|
|
|
|
|
dstMaplList.add(convertObjectToMap(group,
|
|
|
|
|
|
ConfigGroupRelation.class));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
maatConfig.setGroupMapList(dstMaplList);
|
|
|
|
|
|
// 字符串域
|
|
|
|
|
|
dstMaplList = null;
|
|
|
|
|
|
List<Map<String, String>> strongMapList = null;
|
|
|
|
|
|
if (!StringUtil.isEmpty(configCompile.getStrRegionList())) {
|
|
|
|
|
|
dstMaplList = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
for (StrRegion region : configCompile.getStrRegionList()) {
|
|
|
|
|
|
if (StringUtil.isEmpty(region.getDistrict())) {
|
|
|
|
|
|
dstMaplList.add(convertObjectToMap(region,
|
|
|
|
|
|
StrRegion.class));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (StringUtil.isEmpty(strongMapList)) {
|
|
|
|
|
|
strongMapList = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
}
|
|
|
|
|
|
strongMapList.add(convertObjectToMap(region,
|
|
|
|
|
|
StrRegion.class));
|
2018-06-04 16:31:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-05-25 19:37:05 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
maatConfig.setStrRegionMapList(dstMaplList);
|
|
|
|
|
|
// 增强字符串域
|
|
|
|
|
|
if (!StringUtil.isEmpty(strongMapList)
|
|
|
|
|
|
&& strongMapList.size() > 0) {
|
|
|
|
|
|
maatConfig.setStrStrRegionMapList((strongMapList));
|
|
|
|
|
|
}
|
|
|
|
|
|
// 数值域
|
|
|
|
|
|
dstMaplList = null;
|
|
|
|
|
|
if (!StringUtil.isEmpty(configCompile.getNumRegionList())) {
|
|
|
|
|
|
dstMaplList = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
for (NumRegion region : configCompile.getNumRegionList()) {
|
|
|
|
|
|
dstMaplList.add(convertObjectToMap(region,
|
|
|
|
|
|
NumRegion.class));
|
|
|
|
|
|
}
|
2018-05-25 19:37:05 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
maatConfig.setNumRegionMapList(dstMaplList);
|
|
|
|
|
|
|
|
|
|
|
|
// Ip域
|
|
|
|
|
|
dstMaplList = null;
|
|
|
|
|
|
if (!StringUtil.isEmpty(configCompile.getIpRegionList())) {
|
|
|
|
|
|
dstMaplList = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
for (IpRegion region : configCompile.getIpRegionList()) {
|
|
|
|
|
|
dstMaplList.add(convertObjectToMap(region,
|
|
|
|
|
|
IpRegion.class));
|
|
|
|
|
|
}
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
maatConfig.setIpRegionMapList(dstMaplList);
|
|
|
|
|
|
|
|
|
|
|
|
// 摘要类域
|
|
|
|
|
|
dstMaplList = null;
|
|
|
|
|
|
if (!StringUtil.isEmpty(configCompile.getDigestRegionList())) {
|
|
|
|
|
|
dstMaplList = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
for (DigestRegion region : configCompile
|
|
|
|
|
|
.getDigestRegionList()) {
|
|
|
|
|
|
dstMaplList.add(convertObjectToMap(region,
|
|
|
|
|
|
DigestRegion.class));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
maatConfig.setFileDigestRegionMapList(dstMaplList);
|
|
|
|
|
|
|
|
|
|
|
|
// 文本相似性域
|
|
|
|
|
|
// dstMaplList = null;
|
|
|
|
|
|
// maatConfig.setFileLikeRegionMapList(dstMaplList);
|
|
|
|
|
|
|
|
|
|
|
|
// 生效范围IP域
|
|
|
|
|
|
dstMaplList = null;
|
|
|
|
|
|
if (!StringUtil.isEmpty(configCompile.getIpClientRangeList())) {
|
|
|
|
|
|
dstMaplList = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
for (IpRegion region : configCompile.getIpClientRangeList()) {
|
|
|
|
|
|
dstMaplList.add(convertObjectToMap(region,
|
|
|
|
|
|
IpRegion.class));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
maatConfig.setIpClientRangeMapList(dstMaplList);
|
|
|
|
|
|
|
|
|
|
|
|
if (maatMap.containsKey(service)) {
|
|
|
|
|
|
maatMap.get(service).add(maatConfig);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<MaatConfig> maatCfgList = new ArrayList<MaatConfig>();
|
|
|
|
|
|
maatCfgList.add(maatConfig);
|
|
|
|
|
|
maatMap.put(service, maatCfgList);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 调用接口入redis
|
|
|
|
|
|
|
|
|
|
|
|
Iterator serviceIterator = maatMap.keySet().iterator();
|
|
|
|
|
|
while (serviceIterator.hasNext()) {
|
|
|
|
|
|
Integer service = Integer.valueOf(serviceIterator.next()
|
|
|
|
|
|
.toString());
|
|
|
|
|
|
List<Integer> dbIndexList = ServiceAndRDBIndexReal
|
|
|
|
|
|
.getRedisDBByService(service);
|
|
|
|
|
|
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
|
|
|
|
|
|
for (Integer dbIndex : dbIndexList) {
|
|
|
|
|
|
// 分发到阀门有些业务需要添加编译属性到域配置
|
|
|
|
|
|
List<MaatConfig> newMaatConfigList = new ArrayList<MaatConfig>();
|
|
|
|
|
|
newMaatConfigList.addAll(maatMap.get(service));
|
|
|
|
|
|
if (dbIndex.intValue() == ServiceAndRDBIndexReal
|
|
|
|
|
|
.getValveDBIndex().intValue()) {
|
|
|
|
|
|
Map<Integer, Map<String, String[]>> maatToValueMap = ServiceAndRDBIndexReal
|
|
|
|
|
|
.getMaatToValveMap();
|
|
|
|
|
|
if (maatToValueMap.containsKey(service)) {
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, String[]> regionAndFiledMap = maatToValueMap
|
|
|
|
|
|
.get(service);
|
|
|
|
|
|
// for (MaatConfig maatConfig :
|
|
|
|
|
|
// newMaatConfigList) {
|
|
|
|
|
|
for (int i = 0; i < newMaatConfigList.size(); i++) {
|
|
|
|
|
|
MaatConfig maatConfig = newMaatConfigList
|
|
|
|
|
|
.get(i);
|
|
|
|
|
|
MaatConfig newMaatConfig = (MaatConfig) JsonMapper
|
|
|
|
|
|
.fromJsonString(JsonMapper
|
|
|
|
|
|
.toJsonString(maatConfig),
|
|
|
|
|
|
MaatConfig.class);
|
|
|
|
|
|
Iterator iterator = regionAndFiledMap
|
|
|
|
|
|
.keySet().iterator();
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
|
|
String regionName = iterator.next()
|
|
|
|
|
|
.toString();
|
|
|
|
|
|
PropertyDescriptor pd;
|
|
|
|
|
|
try {
|
|
|
|
|
|
pd = new PropertyDescriptor(
|
|
|
|
|
|
regionName + "MapList",
|
|
|
|
|
|
MaatConfig.class);
|
|
|
|
|
|
Method method = pd.getReadMethod();
|
|
|
|
|
|
Object object = method
|
|
|
|
|
|
.invoke(newMaatConfig);
|
|
|
|
|
|
|
|
|
|
|
|
if (object != null) {
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, String>> listMaps = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
listMaps.addAll((List<Map<String, String>>) object);
|
|
|
|
|
|
String[] fields = regionAndFiledMap
|
|
|
|
|
|
.get(regionName);
|
|
|
|
|
|
for (String fieldName : fields) {
|
|
|
|
|
|
String value = newMaatConfig
|
|
|
|
|
|
.getCompileMap()
|
|
|
|
|
|
.get(fieldName
|
|
|
|
|
|
.toLowerCase());
|
|
|
|
|
|
if (!StringUtil
|
|
|
|
|
|
.isEmpty(value)) {
|
|
|
|
|
|
for (Map<String, String> map : listMaps) {
|
|
|
|
|
|
map.put(fieldName
|
|
|
|
|
|
.toLowerCase(),
|
|
|
|
|
|
value);
|
|
|
|
|
|
}
|
2018-06-28 18:52:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
method = pd.getWriteMethod();
|
|
|
|
|
|
method.invoke(newMaatConfig,
|
|
|
|
|
|
listMaps);
|
2018-06-28 18:52:23 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
newMaatConfigList.set(i,
|
|
|
|
|
|
newMaatConfig);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
CompileVal.setBusinessCode(30000);
|
|
|
|
|
|
e = new RuntimeException(
|
|
|
|
|
|
"未找到域列表,请检查域类型是否正确!");
|
|
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
2018-06-28 18:52:23 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-06-28 18:52:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
if (configMap.containsKey(dbIndex)) {
|
|
|
|
|
|
configMap.get(dbIndex).addAll(newMaatConfigList);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<MaatConfig> list = new ArrayList<MaatConfig>();
|
|
|
|
|
|
list.addAll(newMaatConfigList);
|
|
|
|
|
|
configMap.put(dbIndex, list);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-06-28 18:52:23 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
RuntimeException e = new RuntimeException(
|
|
|
|
|
|
"service与写入数据库序号映射关系不存在");
|
|
|
|
|
|
CompileVal.setBusinessCode(30000);
|
|
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
return "error";
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
2018-06-11 15:06:47 +08:00
|
|
|
|
try {
|
|
|
|
|
|
logger1.info("---------------调用maat配置新增接口---------------------");
|
|
|
|
|
|
configRedisService.saveMaatConfig(configMap);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
if (e.getMessage().startsWith("后台错误:")) {
|
|
|
|
|
|
CompileVal.setBusinessCode(30000);
|
|
|
|
|
|
}
|
2018-06-11 15:06:47 +08:00
|
|
|
|
logger1.error(e.getMessage());
|
|
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
|
|
|
|
|
}
|
2018-05-25 19:37:05 +08:00
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
private Map<String, String> convertObjectToMap(Object obj, Class clazz)
|
|
|
|
|
|
throws IntrospectionException, IllegalAccessException,
|
|
|
|
|
|
IllegalArgumentException, InvocationTargetException {
|
|
|
|
|
|
Map<String, String> dstMap = new HashMap<String, String>();
|
|
|
|
|
|
Field[] fields = obj.getClass().getDeclaredFields();
|
|
|
|
|
|
for (Field field : fields) {
|
|
|
|
|
|
if ("serialVersionUID".equals(field.getName()))
|
|
|
|
|
|
continue;
|
|
|
|
|
|
String dstName = CamelUnderlineUtil.camelToUnderline(field
|
|
|
|
|
|
.getName());
|
|
|
|
|
|
PropertyDescriptor pd;
|
|
|
|
|
|
pd = new PropertyDescriptor(field.getName(), clazz);
|
|
|
|
|
|
Method method = pd.getReadMethod();
|
|
|
|
|
|
Object dstObject = method.invoke(obj);
|
|
|
|
|
|
if (dstObject instanceof Date) {
|
|
|
|
|
|
dstObject = convertToTimeStamp16((Date) dstObject);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (dstObject instanceof ArrayList) {
|
|
|
|
|
|
dstObject = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
dstMap.put(dstName,
|
|
|
|
|
|
StringUtil.isEmpty(dstObject) ? "" : dstObject.toString());
|
2018-05-25 19:37:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
return dstMap;
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
public String updateConfigSources(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
List<ConfigCompile> compileList, Date opTime, StringBuffer sb) {
|
2018-06-02 13:01:27 +08:00
|
|
|
|
Map<Integer, List<Long>> compileMap = new HashMap<Integer, List<Long>>();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
if (null != compileList && compileList.size() > 0) {
|
|
|
|
|
|
for (ConfigCompile config : compileList) {
|
|
|
|
|
|
String msg = checkCompileOptForUpdate(config);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (config.getOpTime() == null) {
|
2018-06-01 10:27:03 +08:00
|
|
|
|
config.setOpTime(opTime);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!msg.equals("ok")) {
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg
|
|
|
|
|
|
+ sb.toString(),
|
|
|
|
|
|
CompileVal.getBusinessCode());
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
// compileAllList.add(config);
|
2018-06-02 13:01:27 +08:00
|
|
|
|
if (compileMap.containsKey(config.getService())) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
compileMap.get(config.getService()).add(
|
|
|
|
|
|
config.getCompileId());
|
2018-06-02 13:01:27 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<Long> idList = new ArrayList<Long>();
|
|
|
|
|
|
idList.add(config.getCompileId());
|
|
|
|
|
|
compileMap.put(config.getService(), idList);
|
|
|
|
|
|
}
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-06-01 10:27:03 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("编译配置不能为空" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- start, "编译配置不能为空" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.CompileIsNull.getValue());
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
2018-06-02 13:01:27 +08:00
|
|
|
|
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
|
|
|
|
|
Iterator serviceIterator = compileMap.keySet().iterator();
|
|
|
|
|
|
while (serviceIterator.hasNext()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Integer service = Integer
|
|
|
|
|
|
.valueOf(serviceIterator.next().toString());
|
|
|
|
|
|
List<Integer> dbIndexList = ServiceAndRDBIndexReal
|
|
|
|
|
|
.getRedisDBByService(service);
|
|
|
|
|
|
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
|
2018-06-04 17:52:20 +08:00
|
|
|
|
for (Integer dbIndex : dbIndexList) {
|
|
|
|
|
|
if (restMap.containsKey(dbIndex)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
restMap.get(dbIndex).put(service,
|
|
|
|
|
|
compileMap.get(service));
|
|
|
|
|
|
} else {
|
2018-06-04 17:52:20 +08:00
|
|
|
|
Map<Integer, List<Long>> map = new HashMap<Integer, List<Long>>();
|
|
|
|
|
|
map.put(service, compileMap.get(service));
|
|
|
|
|
|
restMap.put(dbIndex, map);
|
|
|
|
|
|
}
|
2018-06-02 13:01:27 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
RuntimeException e = new RuntimeException("service值为" + service
|
|
|
|
|
|
+ ",与写入数据库序号映射关系不存在");
|
|
|
|
|
|
CompileVal.setBusinessCode(30000);
|
2018-06-04 17:52:20 +08:00
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
2018-06-02 13:01:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
try {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!configRedisService.delMaatConfig(restMap)) {
|
2018-06-02 13:01:27 +08:00
|
|
|
|
RuntimeException e = new RuntimeException("不存在映射关系");
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(30000);
|
2018-06-02 13:01:27 +08:00
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
logger1.error(e.getMessage());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
if (e.getMessage().startsWith("后台错误:")) {
|
|
|
|
|
|
CompileVal.setBusinessCode(30000);
|
|
|
|
|
|
}
|
2018-06-02 13:01:27 +08:00
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
public String saveByJDBCThread(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
List<ConfigCompile> configCompileList, StringBuffer sb) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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>>();
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (ConfigCompile configCompile : configCompileList) {
|
|
|
|
|
|
String msg = CompileVal.compileIsOk(configCompile, false, sb);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!"ok".equals(msg)) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(msg);
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
msg + sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != configCompile.getGroupRelationList()
|
|
|
|
|
|
&& configCompile.getGroupRelationList().size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
groupRelationList.addAll(configCompile.getGroupRelationList());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
logger1.error("配置分组数量不能为空" + sb.toString());
|
|
|
|
|
|
thread.setExceptionInfo("配置分组数量不能为空" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "配置分组数量不能为空"
|
|
|
|
|
|
+ sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != configCompile.getStrRegionList()
|
|
|
|
|
|
&& configCompile.getStrRegionList().size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (StrRegion strRegion : configCompile.getStrRegionList()) {
|
|
|
|
|
|
if (!isStrStrongRegion(strRegion.getTableName())) {
|
|
|
|
|
|
if (strRegion.getRegionId() == null) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "字符类域配置id不能为空 ,表名---"
|
|
|
|
|
|
+ strRegion.getTableName() + ""
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(errorMsg);
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strRegionMap.containsKey(strRegion.getTableName())) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionMap.get(strRegion.getTableName()).add(
|
|
|
|
|
|
strRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strRegionList.add(strRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionMap.put(strRegion.getTableName(),
|
|
|
|
|
|
strRegionList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (strRegion.getRegionId() == null) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "增强字符类域配置id不能为空 ,表名---"
|
|
|
|
|
|
+ strRegion.getTableName() + ""
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(errorMsg);
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
errorMsg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (strStongRegionMap.containsKey(strRegion
|
|
|
|
|
|
.getTableName())) {
|
|
|
|
|
|
strStongRegionMap.get(strRegion.getTableName())
|
|
|
|
|
|
.add(strRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strStrongRegionList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strStrongRegionList.add(strRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strStongRegionMap.put(strRegion.getTableName(),
|
|
|
|
|
|
strStrongRegionList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != configCompile.getIpRegionList()
|
|
|
|
|
|
&& configCompile.getIpRegionList().size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (IpRegion ipRegion : configCompile.getIpRegionList()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!ipRegion.getTableName().toUpperCase()
|
|
|
|
|
|
.equals("DJ_IP_PORT")) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
ipRegion.setProtocol(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (ipRegion.getRegionId() == null) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "ip类域配置id不能为空 ,表名---"
|
|
|
|
|
|
+ ipRegion.getTableName() + "" + sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(errorMsg);
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, errorMsg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != configCompile.getNumRegionList()
|
|
|
|
|
|
&& configCompile.getNumRegionList().size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (NumRegion numRegion : configCompile.getNumRegionList()) {
|
|
|
|
|
|
if (numRegion.getRegionId() == null) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "数值类域配置id不能为空 ,表名---"
|
|
|
|
|
|
+ numRegion.getTableName() + "" + sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
logger1.error(errorMsg);
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, errorMsg,
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (numRegionMap.containsKey(numRegion.getTableName())) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
numRegionMap.get(numRegion.getTableName()).add(
|
|
|
|
|
|
numRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<NumRegion> numRegionList = new ArrayList<NumRegion>();
|
|
|
|
|
|
numRegionList.add(numRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
numRegionMap.put(numRegion.getTableName(),
|
|
|
|
|
|
numRegionList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
if (null != configCompile.getDigestRegionList()
|
|
|
|
|
|
&& configCompile.getDigestRegionList().size() > 0) {
|
|
|
|
|
|
for (DigestRegion digestRegion : configCompile
|
|
|
|
|
|
.getDigestRegionList()) {
|
2018-02-28 10:13:39 +08:00
|
|
|
|
if (digestRegion.getRegionId() == null) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "摘要类域配置id不能为空 ,表名---"
|
|
|
|
|
|
+ digestRegion.getTableName() + ""
|
|
|
|
|
|
+ sb.toString();
|
2018-02-28 10:13:39 +08:00
|
|
|
|
logger1.error(errorMsg);
|
|
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, errorMsg,
|
2018-02-28 10:13:39 +08:00
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (digestRegionMap
|
|
|
|
|
|
.containsKey(digestRegion.getTableName())) {
|
|
|
|
|
|
digestRegionMap.get(digestRegion.getTableName()).add(
|
|
|
|
|
|
digestRegion);
|
2018-02-28 10:13:39 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<DigestRegion> digestRegionList = new ArrayList<DigestRegion>();
|
|
|
|
|
|
digestRegionList.add(digestRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
digestRegionMap.put(digestRegion.getTableName(),
|
|
|
|
|
|
digestRegionList);
|
2018-02-28 10:13:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false")
|
|
|
|
|
|
.equals("true")) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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-07-04 17:03:04 +08:00
|
|
|
|
|
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
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder
|
|
|
|
|
|
.getBean(SqlSessionFactory.class);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
Connection conn = sqlSessionFactory.openSession().getConnection();
|
|
|
|
|
|
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SaveCompileByJDBCThread compile = new SaveCompileByJDBCThread(conn,
|
|
|
|
|
|
latch, start);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
compile.setCompileList(configCompileList);
|
|
|
|
|
|
Thread compileThread = new Thread(compile);
|
|
|
|
|
|
compileThread.start();
|
|
|
|
|
|
if (groupRelationList.size() > 0) {
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SaveCompileByJDBCThread group = new SaveCompileByJDBCThread(
|
|
|
|
|
|
conn, latch, start);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
group.setGroupList(groupRelationList);
|
|
|
|
|
|
|
|
|
|
|
|
Thread groupThread = new Thread(group);
|
|
|
|
|
|
groupThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strRegionMap.size() > 0) {
|
|
|
|
|
|
for (String str : strRegionMap.keySet()) {
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SaveCompileByJDBCThread strRegion = new SaveCompileByJDBCThread(
|
|
|
|
|
|
false, str, conn, latch, start);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
strRegion.setStrRegionList(strRegionMap.get(str));
|
|
|
|
|
|
Thread strThread = new Thread(strRegion);
|
|
|
|
|
|
strThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (strStongRegionMap.size() > 0) {
|
|
|
|
|
|
for (String strStrong : strStongRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SaveCompileByJDBCThread strongRegion = new SaveCompileByJDBCThread(
|
|
|
|
|
|
true, strStrong, conn, latch, start);
|
|
|
|
|
|
strongRegion.setStrRegionList(strStongRegionMap
|
|
|
|
|
|
.get(strStrong));
|
2017-12-19 14:55:52 +08:00
|
|
|
|
Thread strongStrThread = new Thread(strongRegion);
|
|
|
|
|
|
strongStrThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ipRegionMap.size() > 0) {
|
|
|
|
|
|
for (String ip : ipRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SaveCompileByJDBCThread ipRegion = new SaveCompileByJDBCThread(
|
|
|
|
|
|
ip, conn, latch, start);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
ipRegion.setIpRegionList(ipRegionMap.get(ip));
|
|
|
|
|
|
Thread ipThread = new Thread(ipRegion);
|
|
|
|
|
|
ipThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (numRegionMap.size() > 0) {
|
|
|
|
|
|
for (String num : numRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SaveCompileByJDBCThread numRegion = new SaveCompileByJDBCThread(
|
|
|
|
|
|
num, conn, latch, start);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SaveCompileByJDBCThread digestRegion = new SaveCompileByJDBCThread(
|
|
|
|
|
|
digest, conn, latch, start);
|
|
|
|
|
|
digestRegion.setDigestRegionList(digestRegionMap
|
|
|
|
|
|
.get(digest));
|
2018-02-28 10:13:39 +08:00
|
|
|
|
Thread digestThread = new Thread(digestRegion);
|
|
|
|
|
|
digestThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
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)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
e = new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "编译配置数据插入失败",
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
throw ((RestServiceException) e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
private String convertToTimeStamp16(Date date) {
|
|
|
|
|
|
// sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
|
|
|
|
return date.getTime() + "000";
|
2018-05-25 19:37:05 +08:00
|
|
|
|
}
|
2017-12-19 14:55:52 +08:00
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2017-12-19 14:55:52 +08:00
|
|
|
|
/**
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 批量(jdbc多线程方式)修改配置业务逻辑-->1:先进行基础配置验证传过来的json串是否符合格式(配置分组关系前端不能设置为无效,
|
|
|
|
|
|
* 程序会根据传过来的编译配置和域配置等信息自动设置为无效).
|
|
|
|
|
|
* 2:判断配置在数据库中是否已经是无效了如果是无效则提示不能修改无效的配置为有效(因为如果数据库中的编译配置与配置分组关系以及域配置均是无效
|
|
|
|
|
|
* ,传过来的数据是编译配置和配置分组关系是有效,域配置是无效,这样会将数据库中无效的编译配置置为有效,这是不允许的)
|
2017-12-19 14:55:52 +08:00
|
|
|
|
* 3:如果编译配置置为无效将所有的配置分组关系置为无效,不修改域配置状态(分组复用考虑,域可能被其他的组引用)
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 4:如果编译配置为有效,域配置为无效,则先获取该编译配置下各个配置分组关系下的所有有效的域配置信息和所有无效的域配置信息,
|
|
|
|
|
|
* 如果数据库中有效的域配置信息和前端传过来置为无效的的域配置信息个数,id都相等,则将对应域配置,配置分组关系,编译配置均置为无效
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 20161124讨论暂时先去掉2步骤,因为界面目前传过来的数据编译配置,配置分组关系,域配置均是无效,所以就不执行第2步骤了影响性能(
|
|
|
|
|
|
* 方法内注释的代码,如果以后业务需要调整打开下面代码即可)
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param compileList
|
|
|
|
|
|
* 编译配置集合
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public String updateByJDBCThread(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
List<ConfigCompile> compileList, Date opTime, StringBuffer sb) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!"ok".equals(msg)) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg
|
|
|
|
|
|
+ sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
List<IpRegion> ipRegionList = config.getIpRegionList();// 获取编译下所有ip类域配置(要修改的数据)
|
|
|
|
|
|
List<StrRegion> strRegionList = config.getStrRegionList();// 获取编译下所有字符串类域配置(要修改的数据
|
|
|
|
|
|
List<NumRegion> numRegionList = config.getNumRegionList();// 获取编译下所有数值类域配置(要修改的数据
|
2018-07-04 17:03:04 +08:00
|
|
|
|
List<ConfigGroupRelation> groupRelationList = config
|
|
|
|
|
|
.getGroupRelationList();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (config.getIsValid() == 1) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (groupRelationList == null
|
|
|
|
|
|
|| groupRelationList.size() == 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo("配置分组数量不能为空" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
"配置分组数量不能为空" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error
|
|
|
|
|
|
.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
if ((ipRegionList == null || ipRegionList.size() == 0)
|
|
|
|
|
|
&& (strRegionList == null || strRegionList.size() == 0)
|
|
|
|
|
|
&& (numRegionList == null || numRegionList.size() == 0)) {
|
|
|
|
|
|
thread.setExceptionInfo("域配置数量不能全部为空" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
"域配置数量不能全部为空" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.config_integrity_error
|
|
|
|
|
|
.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ConfigCompile configCompile =
|
|
|
|
|
|
// configCompileDao.queryConfigCompileById(config.getCompileId());//
|
|
|
|
|
|
// 先判断该条编译配置数据库中状态是否为无效,如果无效则提示用户不能将无效状态改为有效状态
|
|
|
|
|
|
// if (configCompile.getIsValid() == 1) {//
|
|
|
|
|
|
// 数据库中编译配置为有效状态才可以进行修改操作
|
|
|
|
|
|
/**
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 1:编译配置置为无效,需要将其下所有配置分组置为无效,如果数据中将域配置置为了无效则将域配置置为无效,
|
|
|
|
|
|
* 否则不修改域配置是否生效标志
|
2017-12-19 14:55:52 +08:00
|
|
|
|
* 2:编译配置置为有效,不修改编译配置状态(编译配置不能从无效变有效,只能从有效变无效)仅修改编译配置其他属性,
|
|
|
|
|
|
*/
|
|
|
|
|
|
List<ConfigGroupRelation> queryCompileGroupByPID = configGroupRelationDao
|
|
|
|
|
|
.queryCompileGroupByPID(config.getCompileId());
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null == queryCompileGroupByPID
|
|
|
|
|
|
|| queryCompileGroupByPID.size() == 0) {
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "配置id为"
|
|
|
|
|
|
+ config.getCompileId()
|
|
|
|
|
|
+ "的配置在数据库中找不到对应的配置分组关系,请检查json串是否正确"
|
|
|
|
|
|
+ sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (config.getIsValid() == 0) {// 编译配置修改为无效,需要将所有的配置分组置为无效
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != queryCompileGroupByPID
|
|
|
|
|
|
&& queryCompileGroupByPID.size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
for (ConfigGroupRelation configGroupRelation : queryCompileGroupByPID) {
|
|
|
|
|
|
configGroupRelation.setIsValid(0);
|
|
|
|
|
|
|
|
|
|
|
|
groupRelationAllList.add(configGroupRelation);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Map<String, Map<Long, List<Long>>> regionMap = getRegionList(
|
|
|
|
|
|
thread, System.currentTimeMillis() - start, config,
|
|
|
|
|
|
queryCompileGroupByPID, sb);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
Map<Long, List<Long>> validMap = regionMap.get("validMap");// 获取该编译配置下所有的配置分组关系及组下有效的域配置id
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Map<Long, List<Long>> noValidMap = regionMap
|
|
|
|
|
|
.get("noValidMap");// 获取该编译配置下所有的配置分组关系及组下无效的域配置id
|
2017-12-19 14:55:52 +08:00
|
|
|
|
|
|
|
|
|
|
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)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != validList
|
|
|
|
|
|
&& validList.contains(ipRegion
|
|
|
|
|
|
.getRegionId())) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (ipRegion.getIsValid() == 0) {
|
|
|
|
|
|
ipRegion.setLastUpdate(new Date());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (ipRegionMap
|
|
|
|
|
|
.containsKey(ipRegion
|
|
|
|
|
|
.getTableName())) {
|
|
|
|
|
|
ipRegionMap
|
|
|
|
|
|
.get(ipRegion
|
|
|
|
|
|
.getTableName())
|
|
|
|
|
|
.add(ipRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<IpRegion> ipList = new ArrayList<IpRegion>();
|
|
|
|
|
|
ipList.add(ipRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
ipRegionMap
|
|
|
|
|
|
.put(ipRegion
|
|
|
|
|
|
.getTableName(),
|
|
|
|
|
|
ipList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else if (null != noValidList
|
|
|
|
|
|
&& noValidList.contains(ipRegion
|
|
|
|
|
|
.getRegionId())) {
|
|
|
|
|
|
String errorMsg = "不能修改无效的ip类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId()
|
|
|
|
|
|
+ "regionid为"
|
|
|
|
|
|
+ ipRegion.getRegionId()
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis()
|
|
|
|
|
|
- start, errorMsg,
|
|
|
|
|
|
RestBusinessCode.missing_args
|
|
|
|
|
|
.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "找不到对应的的ip类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId()
|
|
|
|
|
|
+ "regionid为"
|
|
|
|
|
|
+ ipRegion.getRegionId()
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis()
|
|
|
|
|
|
- start, errorMsg,
|
|
|
|
|
|
RestBusinessCode.missing_args
|
|
|
|
|
|
.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (null != strRegionList && strRegionList.size() > 0) {
|
|
|
|
|
|
for (StrRegion strRegion : strRegionList) {
|
|
|
|
|
|
if (strRegion.getGroupId().equals(regionId)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != validList
|
|
|
|
|
|
&& validList.contains(strRegion
|
|
|
|
|
|
.getRegionId())) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (strRegion.getIsValid() == 0) {
|
|
|
|
|
|
|
|
|
|
|
|
strRegion.setLastUpdate(new Date());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (strRegionMap
|
|
|
|
|
|
.containsKey(strRegion
|
|
|
|
|
|
.getTableName())) {
|
|
|
|
|
|
strRegionMap
|
|
|
|
|
|
.get(strRegion
|
|
|
|
|
|
.getTableName())
|
|
|
|
|
|
.add(strRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strList.add(strRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionMap.put(strRegion
|
|
|
|
|
|
.getTableName(),
|
|
|
|
|
|
strList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else if (null != noValidList
|
|
|
|
|
|
&& noValidList.contains(strRegion
|
|
|
|
|
|
.getRegionId())) {
|
|
|
|
|
|
String errorMsg = "不能修改无效的字符串类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId()
|
|
|
|
|
|
+ "regionid为"
|
|
|
|
|
|
+ strRegion.getRegionId()
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis()
|
|
|
|
|
|
- start, errorMsg,
|
|
|
|
|
|
RestBusinessCode.missing_args
|
|
|
|
|
|
.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "找不到对应的的字符串类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId()
|
|
|
|
|
|
+ "regionid为"
|
|
|
|
|
|
+ strRegion.getRegionId()
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis()
|
|
|
|
|
|
- start, errorMsg,
|
|
|
|
|
|
RestBusinessCode.missing_args
|
|
|
|
|
|
.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionList && numRegionList.size() > 0) {
|
|
|
|
|
|
for (NumRegion numRegion : numRegionList) {
|
|
|
|
|
|
if (numRegion.getGroupId().equals(regionId)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != validList
|
|
|
|
|
|
&& validList.contains(numRegion
|
|
|
|
|
|
.getRegionId())) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (numRegion.getIsValid() == 0) {
|
|
|
|
|
|
|
|
|
|
|
|
numRegion.setLastUpdate(new Date());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (numRegionMap
|
|
|
|
|
|
.containsKey(numRegion
|
|
|
|
|
|
.getTableName())) {
|
|
|
|
|
|
numRegionMap
|
|
|
|
|
|
.get(numRegion
|
|
|
|
|
|
.getTableName())
|
|
|
|
|
|
.add(numRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<NumRegion> numList = new ArrayList<NumRegion>();
|
|
|
|
|
|
numList.add(numRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
numRegionMap.put(numRegion
|
|
|
|
|
|
.getTableName(),
|
|
|
|
|
|
numList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else if (null != noValidList
|
|
|
|
|
|
&& noValidList.contains(numRegion
|
|
|
|
|
|
.getRegionId())) {
|
|
|
|
|
|
String errorMsg = "不能修改无效的数值类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId()
|
|
|
|
|
|
+ "regionid为"
|
|
|
|
|
|
+ numRegion.getRegionId()
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis()
|
|
|
|
|
|
- start, errorMsg,
|
|
|
|
|
|
RestBusinessCode.missing_args
|
|
|
|
|
|
.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String errorMsg = "找不到对应的的数值类域配置compile为"
|
|
|
|
|
|
+ config.getCompileId()
|
|
|
|
|
|
+ "regionid为"
|
|
|
|
|
|
+ numRegion.getRegionId()
|
|
|
|
|
|
+ sb.toString();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo(errorMsg);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis()
|
|
|
|
|
|
- start, errorMsg,
|
|
|
|
|
|
RestBusinessCode.missing_args
|
|
|
|
|
|
.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (count == validList.size()) {// 数据库中当前配置分组下有效的域配置,均被修改为无效,所以要将该配置分组置为无效
|
|
|
|
|
|
for (ConfigGroupRelation configGroupRelation : groupRelationList) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (configGroupRelation.getGroupId().equals(
|
|
|
|
|
|
regionId)) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
num++;
|
|
|
|
|
|
configGroupRelation.setIsValid(0);
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
groupRelationAllList
|
|
|
|
|
|
.add(configGroupRelation);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
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());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- start, "编译配置不能为空" + sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 程序是否入库,测试分析数据的时间
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false")
|
|
|
|
|
|
.equals("true")) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder
|
|
|
|
|
|
.getBean(SqlSessionFactory.class);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
Connection conn = sqlSessionFactory.openSession().getConnection();
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread compileThread = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
compileThread.setCompileList(compileAllList);
|
|
|
|
|
|
Thread compile = new Thread(compileThread);
|
|
|
|
|
|
compile.start();
|
|
|
|
|
|
|
|
|
|
|
|
if (null != groupRelationAllList && groupRelationAllList.size() > 0) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread groupThread = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
groupThread.setGroupList(groupRelationAllList);
|
|
|
|
|
|
Thread group = new Thread(groupThread);
|
|
|
|
|
|
group.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != strRegionMap && strRegionMap.size() > 0) {
|
|
|
|
|
|
for (String str : strRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread strRegion = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
str, conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
strRegion.setStrRegionList(strRegionMap.get(str));
|
|
|
|
|
|
Thread strThread = new Thread(strRegion);
|
|
|
|
|
|
strThread.start();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (null != ipRegionMap && ipRegionMap.size() > 0) {
|
|
|
|
|
|
for (String ip : ipRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread ipRegion = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
ip, conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
ipRegion.setIpRegionList(ipRegionMap.get(ip));
|
|
|
|
|
|
Thread ipThread = new Thread(ipRegion);
|
|
|
|
|
|
ipThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionMap && numRegionMap.size() > 0) {
|
|
|
|
|
|
for (String num : numRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread numRegion = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
num, conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
e = new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "编译配置数据修改失败",
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
throw ((RestServiceException) e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 批量(jdbc多线程方式)修改配置业务逻辑-->1:先进行基础配置验证传过来的json串是否符合格式(配置分组关系前端不能设置为无效,
|
|
|
|
|
|
* 程序会根据传过来的编译配置和域配置等信息自动设置为无效).
|
|
|
|
|
|
* 2:判断配置在数据库中是否已经是无效了如果是无效则提示不能修改无效的配置为有效(因为如果数据库中的编译配置与配置分组关系以及域配置均是无效
|
|
|
|
|
|
* ,传过来的数据是编译配置和配置分组关系是有效,域配置是无效,这样会将数据库中无效的编译配置置为有效,这是不允许的)
|
2017-12-19 14:55:52 +08:00
|
|
|
|
* 3:如果编译配置置为无效将所有的配置分组关系置为无效,不修改域配置状态(分组复用考虑,域可能被其他的组引用)
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 4:如果编译配置为有效,域配置为无效,则先获取该编译配置下各个配置分组关系下的所有有效的域配置信息和所有无效的域配置信息,
|
|
|
|
|
|
* 如果数据库中有效的域配置信息和前端传过来置为无效的的域配置信息个数,id都相等,则将对应域配置,配置分组关系,编译配置均置为无效
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 20161124讨论暂时先去掉2步骤,因为界面目前传过来的数据编译配置,配置分组关系,域配置均是无效,所以就不执行第2步骤了影响性能(
|
|
|
|
|
|
* 方法内注释的代码,如果以后业务需要调整打开下面代码即可)
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 20161215讨论确定修改时前端发过来的配置都是无效的不会存在即有无效又有有效的情况,且配置中的个数与添加时保持一致,
|
|
|
|
|
|
* 即添加时插入了1条编译配置2条配置分组关系3条域配置,在修改时也会传过来1条编译配置2条配置分组关系3条域配置,不会多或者少配置
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 2017-1-16:和杨老师讨论确定存在分组复用情况,当编译配置置为无效,需要将其下所有配置分组置为无效,
|
|
|
|
|
|
* 如果数据中将域配置置为了无效则将域配置置为无效,否则不修改域配置是否生效标志
|
2017-12-19 14:55:52 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param compileList
|
|
|
|
|
|
* 编译配置集合
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public String updateByJDBCThread12(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
List<ConfigCompile> compileList, Date opTime, StringBuffer sb) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!"ok".equals(msg)) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg
|
|
|
|
|
|
+ sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-07-04 17:03:04 +08:00
|
|
|
|
* 1:编译配置置为无效,需要将其下所有配置分组置为无效,如果数据中将域配置置为了无效则将域配置置为无效,
|
|
|
|
|
|
* 否则不修改域配置是否生效标志
|
2017-12-19 14:55:52 +08:00
|
|
|
|
* 2:编译配置置为有效,不修改编译配置状态(编译配置不能从无效变有效,只能从有效变无效)仅修改编译配置其他属性,
|
|
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
List<ConfigGroupRelation> groupRelationList = config
|
|
|
|
|
|
.getGroupRelationList();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (config.getIsValid() == 0) {// 编译配置修改为无效,需要将所有的配置分组置为无效
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (null != groupRelationList
|
|
|
|
|
|
&& groupRelationList.size() > 0) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (ipRegionMap.containsKey(ipRegion
|
|
|
|
|
|
.getTableName())) {
|
|
|
|
|
|
ipRegionMap.get(ipRegion.getTableName())
|
|
|
|
|
|
.add(ipRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<IpRegion> ipList = new ArrayList<IpRegion>();
|
|
|
|
|
|
ipList.add(ipRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
ipRegionMap.put(ipRegion.getTableName(),
|
|
|
|
|
|
ipList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
List<StrRegion> strRegionList = config.getStrRegionList();// 获取编译下所有字符串类域配置(要修改的数据
|
|
|
|
|
|
if (null != strRegionList && strRegionList.size() > 0) {
|
|
|
|
|
|
for (StrRegion strRegion : strRegionList) {
|
|
|
|
|
|
if (strRegion.getIsValid() == 0) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (strRegionMap.containsKey(strRegion
|
|
|
|
|
|
.getTableName())) {
|
|
|
|
|
|
strRegionMap.get(strRegion.getTableName())
|
|
|
|
|
|
.add(strRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<StrRegion> strList = new ArrayList<StrRegion>();
|
|
|
|
|
|
strList.add(strRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionMap.put(strRegion.getTableName(),
|
|
|
|
|
|
strList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
List<NumRegion> numRegionList = config.getNumRegionList();// 获取编译下所有数值类域配置(要修改的数据
|
|
|
|
|
|
if (null != numRegionList && numRegionList.size() > 0) {
|
|
|
|
|
|
for (NumRegion numRegion : numRegionList) {
|
|
|
|
|
|
if (numRegion.getIsValid() == 0) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (numRegionMap.containsKey(numRegion
|
|
|
|
|
|
.getTableName())) {
|
|
|
|
|
|
numRegionMap.get(numRegion.getTableName())
|
|
|
|
|
|
.add(numRegion);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<NumRegion> numList = new ArrayList<NumRegion>();
|
|
|
|
|
|
numList.add(numRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
numRegionMap.put(numRegion.getTableName(),
|
|
|
|
|
|
numList);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
List<DigestRegion> digestRegionList = config
|
|
|
|
|
|
.getDigestRegionList();// 获取编译下所有摘要类域配置(要修改的数据
|
2018-02-28 10:13:39 +08:00
|
|
|
|
if (null != digestRegionList && digestRegionList.size() > 0) {
|
|
|
|
|
|
for (DigestRegion digestRegion : digestRegionList) {
|
|
|
|
|
|
if (digestRegion.getIsValid() == 0) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (digestRegionMap.containsKey(digestRegion
|
|
|
|
|
|
.getTableName())) {
|
|
|
|
|
|
digestRegionMap.get(
|
|
|
|
|
|
digestRegion.getTableName()).add(
|
|
|
|
|
|
digestRegion);
|
2018-02-28 10:13:39 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
List<DigestRegion> digestList = new ArrayList<DigestRegion>();
|
|
|
|
|
|
digestList.add(digestRegion);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
digestRegionMap.put(
|
|
|
|
|
|
digestRegion.getTableName(),
|
|
|
|
|
|
digestList);
|
2018-02-28 10:13:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-12-19 14:55:52 +08:00
|
|
|
|
compileAllList.add(config);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("编译配置不能为空" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- start, "编译配置不能为空" + sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 程序是否入库,测试分析数据的时间
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false")
|
|
|
|
|
|
.equals("true")) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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();
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder
|
|
|
|
|
|
.getBean(SqlSessionFactory.class);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
Connection conn = sqlSessionFactory.openSession().getConnection();
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread compileThread = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
compileThread.setCompileList(compileAllList);
|
|
|
|
|
|
Thread compile = new Thread(compileThread);
|
|
|
|
|
|
compile.start();
|
|
|
|
|
|
|
|
|
|
|
|
if (null != groupRelationAllList && groupRelationAllList.size() > 0) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread groupThread = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
groupThread.setGroupList(groupRelationAllList);
|
|
|
|
|
|
Thread group = new Thread(groupThread);
|
|
|
|
|
|
group.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != strRegionMap && strRegionMap.size() > 0) {
|
|
|
|
|
|
for (String str : strRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread strRegion = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
str, conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
strRegion.setStrRegionList(strRegionMap.get(str));
|
|
|
|
|
|
Thread strThread = new Thread(strRegion);
|
|
|
|
|
|
strThread.start();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (null != ipRegionMap && ipRegionMap.size() > 0) {
|
|
|
|
|
|
for (String ip : ipRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread ipRegion = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
ip, conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
ipRegion.setIpRegionList(ipRegionMap.get(ip));
|
|
|
|
|
|
Thread ipThread = new Thread(ipRegion);
|
|
|
|
|
|
ipThread.start();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (null != numRegionMap && numRegionMap.size() > 0) {
|
|
|
|
|
|
for (String num : numRegionMap.keySet()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread numRegion = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
num, conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread digestRegion = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
num, conn, latch, start, opTime);
|
2018-02-28 10:13:39 +08:00
|
|
|
|
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)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
e = new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "编译配置数据修改失败",
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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
|
|
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public String updateByJDBCThread3(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
List<ConfigCompile> compileList, Date opTime, StringBuffer sb) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
List<ConfigCompile> compileAllList = new ArrayList<ConfigCompile>();
|
|
|
|
|
|
if (null != compileList && compileList.size() > 0) {
|
|
|
|
|
|
for (ConfigCompile config : compileList) {
|
|
|
|
|
|
String msg = checkCompileOptForUpdate(config);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (config.getOpTime() == null) {
|
2017-12-22 15:22:11 +08:00
|
|
|
|
config.setOpTime(opTime);
|
|
|
|
|
|
}
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (!msg.equals("ok")) {
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, msg
|
|
|
|
|
|
+ sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
compileAllList.add(config);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
thread.setExceptionInfo("编译配置不能为空" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- start, "编译配置不能为空" + sb.toString(),
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.config_integrity_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
// 程序是否入库,测试分析数据的时间
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (Configurations.getStringProperty("isCommit", "false")
|
|
|
|
|
|
.equals("true")) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
int count = 0;
|
|
|
|
|
|
if (null != compileAllList && compileAllList.size() > 0) {
|
|
|
|
|
|
count += 1;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
count += 1; // 将所有compile与Group的对应关系都置为失效 zdx20170814
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
SqlSessionFactory sqlSessionFactory = SpringContextHolder
|
|
|
|
|
|
.getBean(SqlSessionFactory.class);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
Connection conn = sqlSessionFactory.openSession().getConnection();
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(count);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
UpdateCompileByJDBCThread compileThread = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
compileThread.setCompileList(compileAllList);
|
|
|
|
|
|
Thread compile = new Thread(compileThread);
|
|
|
|
|
|
compile.start();
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
UpdateCompileByJDBCThread groupThread = new UpdateCompileByJDBCThread(
|
|
|
|
|
|
conn, latch, start, opTime);
|
2017-12-19 14:55:52 +08:00
|
|
|
|
groupThread.setCompileList(compileAllList);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// 仅用做判定线程执行时选择执行方法 zdx20170816
|
2017-12-19 14:55:52 +08:00
|
|
|
|
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)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
e = new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "编译配置数据修改失败",
|
2017-12-19 14:55:52 +08:00
|
|
|
|
RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
throw ((RestServiceException) e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Description:验证compileId+isValid
|
|
|
|
|
|
* @author (zdx)
|
|
|
|
|
|
* @date 2017年8月16日 上午11:48:46
|
|
|
|
|
|
* @param config
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
private String checkCompileOptForUpdate(ConfigCompile config) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (StringUtil.isEmpty(config.getCompileId())) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.CompileIdIsNull.getValue());
|
|
|
|
|
|
return RestBusinessCode.CompileIdIsNull.getErrorReason();
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-06-01 10:27:03 +08:00
|
|
|
|
if (StringUtil.isEmpty(config.getService())) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.ServiceIsNull.getValue());
|
|
|
|
|
|
return RestBusinessCode.ServiceIsNull.getErrorReason();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (StringUtil.isEmpty(config.getIsValid())) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.IsValidIsNull.getValue());
|
|
|
|
|
|
return "编译配置id为" + config.getCompileId() + "的IsValid字段不能为空";
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (config.getIsValid() != 0) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.IsValidIsF.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
return "编译配置id为" + config.getCompileId() + "的配置在修改时不能为有效";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取编译配置下所有的配置分组关系对应的有效,无效域配置id
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param thread
|
|
|
|
|
|
* 保存异常信息入库对象
|
|
|
|
|
|
* @param start
|
|
|
|
|
|
* 进入controller的时间
|
|
|
|
|
|
* @param config
|
|
|
|
|
|
* 编译配置对象
|
|
|
|
|
|
* @param queryCompileGroupByPID
|
|
|
|
|
|
* 当前编译下所有的配置分组关系
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public Map<String, Map<Long, List<Long>>> getRegionList(
|
|
|
|
|
|
SaveRequestLogThread thread, long start, ConfigCompile config,
|
|
|
|
|
|
List<ConfigGroupRelation> queryCompileGroupByPID, StringBuffer sb) {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
Map<String, Map<Long, List<Long>>> map = new HashMap<String, Map<Long, List<Long>>>();
|
|
|
|
|
|
Map<Integer, Map<String, String>> tableRelationMap = getTableRelation();
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Map<String, String> updateTableMap = tableRelationMap.get(config
|
|
|
|
|
|
.getService().intValue());// 根据service获取需要操作的域配置表
|
2017-12-19 14:55:52 +08:00
|
|
|
|
if (null == updateTableMap || updateTableMap.size() == 0) {
|
|
|
|
|
|
thread.setExceptionInfo("找不到编译对应的service" + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- start, "找不到编译对应的service" + sb.toString(),
|
|
|
|
|
|
RestBusinessCode.missing_args.getValue());
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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")) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
ipRegionExistList.addAll(ipRegionDao.queryIpRegionByGroupId(
|
|
|
|
|
|
tableName, groupId));
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("num")) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
numRegionExistList.addAll(numRegionDao.queryNumRegionByGroupId(
|
|
|
|
|
|
tableName, groupId));
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (updateTableMap.get(tableName).equals("str")) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
strRegionExistList.addAll(strRegionDao.queryStrRegionByGroupId(
|
|
|
|
|
|
tableName, groupId));
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// ////////////////////////////////////////////////////////////////////////////
|
2017-12-19 14:55:52 +08:00
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public String configModifySources(List<ConfigCompile> configCompileList)
|
|
|
|
|
|
throws Exception {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
|
|
|
|
|
|
for (ConfigCompile configCompile : configCompileList) {
|
|
|
|
|
|
Long compileId = configCompile.getCompileId();
|
|
|
|
|
|
if (null != compileId) {
|
|
|
|
|
|
configCompileDao.updateConfigCompile(configCompile);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return "idIsNull";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
public String saveCommonSources(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
String jsonString, StringBuffer sb) {
|
|
|
|
|
|
CompileVal.setBusinessCode(null);
|
|
|
|
|
|
JsonArray jsonObjectList = new JsonParser().parse(jsonString)
|
|
|
|
|
|
.getAsJsonArray();
|
|
|
|
|
|
Map<Integer, List<Map<String, String>>> dstMaps = new HashMap<Integer, List<Map<String, String>>>();
|
2018-05-24 17:22:38 +08:00
|
|
|
|
for (int i = 0; i < jsonObjectList.size(); i++) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
JsonObject jsonObj = (JsonObject) jsonObjectList.get(i);
|
|
|
|
|
|
Map<String, Object> srcMap = JSONObject.fromObject(JSONObject
|
|
|
|
|
|
.fromObject((jsonObj.toString())));
|
|
|
|
|
|
if (srcMap.containsKey("service")) {
|
|
|
|
|
|
Map<String, String> dstMap = new HashMap<String, String>();
|
|
|
|
|
|
List<CommonSourceFieldCfg> commonSourceFieldCfgList = ReadCommSourceXmlUtil
|
|
|
|
|
|
.getCommonSourceCfgByService(srcMap.get("service")
|
|
|
|
|
|
.toString().trim());
|
2018-05-24 17:22:38 +08:00
|
|
|
|
if (StringUtil.isEmpty(commonSourceFieldCfgList)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
logger1.error(RestBusinessCode.ServiceIsWrong.getErrorReason()+",请检查service配置是否正确");
|
2018-05-24 17:22:38 +08:00
|
|
|
|
thread.setExceptionInfo("请检查service配置是否正确");
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
"请检查service配置是否正确",
|
|
|
|
|
|
RestBusinessCode.ServiceIsWrong.getValue());
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// 获取IP类型
|
2018-06-07 18:37:30 +08:00
|
|
|
|
Integer ipType = null;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String ipTypeName = "";
|
2018-07-06 18:07:16 +08:00
|
|
|
|
|
|
|
|
|
|
Integer action = null;
|
2018-06-07 18:37:30 +08:00
|
|
|
|
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (commonSourceFieldCfg.getDstName().equals("ip_type")) {
|
|
|
|
|
|
String dstVal = srcMap.get(
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName()).toString();
|
2018-06-07 18:37:30 +08:00
|
|
|
|
ipTypeName = commonSourceFieldCfg.getSrcName();
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// regexp 特殊格式正则验证
|
2018-06-07 18:37:30 +08:00
|
|
|
|
Boolean valFlag = true;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!StringUtil.isEmpty(commonSourceFieldCfg
|
|
|
|
|
|
.getRegexp())) {
|
|
|
|
|
|
Pattern pattern = Pattern
|
|
|
|
|
|
.compile(commonSourceFieldCfg.getRegexp());
|
2018-06-07 18:37:30 +08:00
|
|
|
|
Matcher matcher = pattern.matcher(dstVal);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
valFlag = valFlag & matcher.matches();
|
2018-06-07 18:37:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (!valFlag) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
logger1.error(RestBusinessCode.IpTypeIsWrong
|
|
|
|
|
|
.getErrorReason());
|
|
|
|
|
|
thread.setExceptionInfo(RestBusinessCode.IpTypeIsWrong
|
|
|
|
|
|
.getErrorReason());
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
RestBusinessCode.IpTypeIsWrong
|
|
|
|
|
|
.getErrorReason(),
|
|
|
|
|
|
RestBusinessCode.IpTypeIsWrong
|
|
|
|
|
|
.getValue());
|
2018-06-07 18:37:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
ipType = Integer.parseInt(dstVal);
|
|
|
|
|
|
}
|
2018-07-06 18:07:16 +08:00
|
|
|
|
//验证service与action是否匹配
|
|
|
|
|
|
if (commonSourceFieldCfg.getDstName().equals("action")) {
|
|
|
|
|
|
String dstVal = srcMap.get(
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName()).toString().trim();
|
|
|
|
|
|
if (Integer.valueOf(dstVal).compareTo(ServiceAndRDBIndexReal.getActionByService(Integer.valueOf(srcMap.get("service")
|
|
|
|
|
|
.toString().trim())))!=0) {
|
|
|
|
|
|
logger1.error(RestBusinessCode.ServiceUnmatchAction
|
|
|
|
|
|
.getErrorReason());
|
|
|
|
|
|
thread.setExceptionInfo(RestBusinessCode.ServiceUnmatchAction
|
|
|
|
|
|
.getErrorReason());
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
RestBusinessCode.ServiceUnmatchAction
|
|
|
|
|
|
.getErrorReason(),
|
|
|
|
|
|
RestBusinessCode.ServiceUnmatchAction
|
|
|
|
|
|
.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-07 18:37:30 +08:00
|
|
|
|
}
|
2018-05-24 17:22:38 +08:00
|
|
|
|
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// 是否必填
|
|
|
|
|
|
if (commonSourceFieldCfg.getIsRequired()
|
|
|
|
|
|
&& !srcMap.containsKey(commonSourceFieldCfg
|
|
|
|
|
|
.getSrcName())) {
|
|
|
|
|
|
logger1.error(commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数不能为空");
|
|
|
|
|
|
thread.setExceptionInfo(commonSourceFieldCfg
|
|
|
|
|
|
.getSrcName() + "参数不能为空");
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName() + "参数不能为空",
|
|
|
|
|
|
RestBusinessCode.FieldIsNull.getValue());
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// 字段类型 String Number Date Ip Port
|
|
|
|
|
|
String dstStr = StringUtil.isEmpty(srcMap
|
|
|
|
|
|
.get(commonSourceFieldCfg.getSrcName())) ? commonSourceFieldCfg
|
|
|
|
|
|
.getDefaultVal() : srcMap.get(
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName()).toString();
|
|
|
|
|
|
if (!StringUtil.isEmpty(dstStr) && dstStr.startsWith("[")
|
|
|
|
|
|
&& dstStr.endsWith("]")) {
|
|
|
|
|
|
dstStr = srcMap.get(
|
|
|
|
|
|
dstStr.substring(1, dstStr.length() - 1))
|
|
|
|
|
|
.toString();
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
switch (commonSourceFieldCfg.getFieldType()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
case "Number":
|
|
|
|
|
|
if (!StringUtil.isNumeric(dstStr)) {
|
|
|
|
|
|
logger1.error(commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数不能格式不正确,必需是数值型");
|
|
|
|
|
|
thread.setExceptionInfo(commonSourceFieldCfg
|
|
|
|
|
|
.getSrcName() + "参数不能格式不正确,必需是数值型");
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数不能格式不正确,必需是数值型",
|
|
|
|
|
|
RestBusinessCode.MastNumberic.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "Date":
|
|
|
|
|
|
try {
|
|
|
|
|
|
// sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
|
|
|
|
System.out.println("--------------------TimeZone:"
|
|
|
|
|
|
+ sdf.getTimeZone());
|
|
|
|
|
|
Date date = sdf.parse(dstStr);
|
|
|
|
|
|
dstStr = date.getTime() + "000";
|
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
|
// TODO Auto-generated catch block
|
|
|
|
|
|
logger1.error(commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数格式不正确,必须是日期型");
|
|
|
|
|
|
thread.setExceptionInfo(commonSourceFieldCfg
|
|
|
|
|
|
.getSrcName() + "参数格式不正确,必须是日期型");
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数不能格式不正确,必须是日期型",
|
|
|
|
|
|
RestBusinessCode.MastDate.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "Ip":
|
|
|
|
|
|
if (!BasicProvingUtil.isIpOrIpMask(dstStr, ipType)) {
|
|
|
|
|
|
logger1.error(commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数格式不正确或与" + ipTypeName + "不一致");
|
|
|
|
|
|
thread.setExceptionInfo(commonSourceFieldCfg
|
|
|
|
|
|
.getSrcName()
|
|
|
|
|
|
+ "参数格式不正确或与"
|
|
|
|
|
|
+ ipTypeName
|
|
|
|
|
|
+ "不一致");
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数格式不正确或与" + ipTypeName + "不一致",
|
|
|
|
|
|
RestBusinessCode.IpIsUnMatchType.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case "Port":
|
|
|
|
|
|
if (!BasicProvingUtil.isPortOrPortMask(dstStr)) {
|
|
|
|
|
|
logger1.error(commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数格式不正确,不是合法的Port");
|
|
|
|
|
|
thread.setExceptionInfo(commonSourceFieldCfg
|
|
|
|
|
|
.getSrcName() + "参数格式不正确,不是合法的Port");
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数不能格式不正确,不是合法的Port",
|
|
|
|
|
|
RestBusinessCode.PortIsNotVal.getValue());
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// range取值范围验证
|
|
|
|
|
|
if (!StringUtil.isEmpty(commonSourceFieldCfg.getRange())) {
|
|
|
|
|
|
String[] range = commonSourceFieldCfg.getRange().split(
|
|
|
|
|
|
"-");
|
2018-06-22 10:48:53 +08:00
|
|
|
|
Boolean flag = false;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (range.length == 2) {
|
|
|
|
|
|
if (!(Long.valueOf(range[0]).compareTo(
|
|
|
|
|
|
Long.valueOf(dstStr)) <= 0 && Long.valueOf(
|
|
|
|
|
|
range[1]).compareTo(Long.valueOf(dstStr)) >= 0)) {
|
2018-06-22 10:48:53 +08:00
|
|
|
|
flag = true;
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
} else if (commonSourceFieldCfg.getRange().startsWith(
|
|
|
|
|
|
"-")) {// 只有最大值限制
|
|
|
|
|
|
if (Long.valueOf(range[0]).compareTo(
|
|
|
|
|
|
Long.valueOf(dstStr)) <= 0) {
|
2018-06-22 10:48:53 +08:00
|
|
|
|
flag = true;
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else if (commonSourceFieldCfg.getRange()
|
|
|
|
|
|
.endsWith("-")) {// 只有最小值限制
|
|
|
|
|
|
if (Long.valueOf(range[0]).compareTo(
|
|
|
|
|
|
Long.valueOf(dstStr)) >= 0) {
|
2018-06-22 10:48:53 +08:00
|
|
|
|
flag = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (flag) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
logger1.error(commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数不在有效范围("
|
|
|
|
|
|
+ commonSourceFieldCfg.getRange() + ")");
|
|
|
|
|
|
thread.setExceptionInfo(commonSourceFieldCfg
|
|
|
|
|
|
.getSrcName()
|
|
|
|
|
|
+ "参数不在有效范围("
|
|
|
|
|
|
+ commonSourceFieldCfg.getRange() + ")");
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数不在有效范围("
|
|
|
|
|
|
+ commonSourceFieldCfg.getRange()
|
|
|
|
|
|
+ ")",
|
|
|
|
|
|
RestBusinessCode.ValueInWrongRange.getValue());
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// regexp 特殊格式正则验证
|
2018-05-24 17:22:38 +08:00
|
|
|
|
Boolean valFlag = true;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (!StringUtil.isEmpty(commonSourceFieldCfg.getRegexp())) {
|
|
|
|
|
|
Pattern pattern = Pattern.compile(commonSourceFieldCfg
|
|
|
|
|
|
.getRegexp());
|
2018-05-24 17:22:38 +08:00
|
|
|
|
Matcher matcher = pattern.matcher(dstStr);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
valFlag = valFlag & matcher.matches();
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (valFlag) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
dstMap.put(commonSourceFieldCfg.getDstName(), dstStr);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
logger1.error(commonSourceFieldCfg.getSrcName()
|
|
|
|
|
|
+ "参数格式与正则(" + commonSourceFieldCfg.getRegexp()
|
|
|
|
|
|
+ ")不匹配");
|
|
|
|
|
|
thread.setExceptionInfo(commonSourceFieldCfg
|
|
|
|
|
|
.getSrcName()
|
|
|
|
|
|
+ "参数格式与正则("
|
|
|
|
|
|
+ commonSourceFieldCfg.getRegexp() + ")不匹配");
|
|
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
commonSourceFieldCfg.getSrcName() + "参数格式与正则("
|
|
|
|
|
|
+ commonSourceFieldCfg.getRegexp()
|
|
|
|
|
|
+ ")不匹配",
|
|
|
|
|
|
RestBusinessCode.ValueInWrongRegexp.getValue());
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
if (StringUtil.isEmpty(dstMaps.get(Integer.valueOf(srcMap.get(
|
|
|
|
|
|
"service").toString())))) {
|
|
|
|
|
|
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
2018-05-24 17:22:38 +08:00
|
|
|
|
list.add(dstMap);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
dstMaps.put(
|
|
|
|
|
|
Integer.valueOf(srcMap.get("service").toString()),
|
|
|
|
|
|
list);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<Map<String, String>> list = dstMaps.get(Integer
|
|
|
|
|
|
.valueOf(srcMap.get("service").toString()));
|
2018-05-24 17:22:38 +08:00
|
|
|
|
list.add(dstMap);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else {
|
2018-05-24 17:22:38 +08:00
|
|
|
|
thread.setExceptionInfo("service参数不能为空");
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start, "service参数不能为空",
|
|
|
|
|
|
RestBusinessCode.ServiceIsNull.getValue());
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-01 10:27:03 +08:00
|
|
|
|
logger1.info("------------------调用非maat配置新增接口-------------------");
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// 按service分库
|
2018-06-01 10:27:03 +08:00
|
|
|
|
Map<Integer, List<Map<String, String>>> configMap = new HashMap<Integer, List<Map<String, String>>>();
|
|
|
|
|
|
Iterator serviceIterator = dstMaps.keySet().iterator();
|
|
|
|
|
|
while (serviceIterator.hasNext()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Integer service = Integer
|
|
|
|
|
|
.valueOf(serviceIterator.next().toString());
|
|
|
|
|
|
List<Integer> dbIndexList = ServiceAndRDBIndexReal
|
|
|
|
|
|
.getRedisDBByService(service);
|
|
|
|
|
|
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
|
2018-06-04 17:52:20 +08:00
|
|
|
|
for (Integer dbIndex : dbIndexList) {
|
|
|
|
|
|
if (configMap.containsKey(dbIndex)) {
|
|
|
|
|
|
configMap.get(dbIndex).addAll(dstMaps.get(service));
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else {
|
2018-06-04 17:52:20 +08:00
|
|
|
|
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
|
|
|
|
|
|
list.addAll(dstMaps.get(service));
|
|
|
|
|
|
configMap.put(dbIndex, list);
|
|
|
|
|
|
}
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
RuntimeException e = new RuntimeException(
|
|
|
|
|
|
"service与写入数据库序号映射关系不存在");
|
|
|
|
|
|
CompileVal.setBusinessCode(30000);
|
2018-06-04 17:52:20 +08:00
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
2018-06-11 15:06:47 +08:00
|
|
|
|
try {
|
|
|
|
|
|
configRedisService.saveUnMaatConfig(configMap);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
logger1.error(e.getMessage());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
if (e.getMessage().startsWith("后台错误:")) {
|
|
|
|
|
|
CompileVal.setBusinessCode(30000);
|
|
|
|
|
|
}
|
2018-06-11 15:06:47 +08:00
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-24 17:22:38 +08:00
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
public String updateCommonSources(SaveRequestLogThread thread, long start,
|
|
|
|
|
|
String jsonString, Date opTime, StringBuffer sb) {
|
2018-06-04 15:14:52 +08:00
|
|
|
|
JsonArray jsonObjectList = null;
|
|
|
|
|
|
try {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
jsonObjectList = new JsonParser().parse(jsonString)
|
|
|
|
|
|
.getAsJsonArray();
|
2018-06-04 15:14:52 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
logger1.error(e.getMessage());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(30000);
|
2018-06-04 15:14:52 +08:00
|
|
|
|
thread.setExceptionInfo(e.getMessage() + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread, System.currentTimeMillis()
|
|
|
|
|
|
- start, e.getMessage() + sb.toString(),
|
|
|
|
|
|
CompileVal.getBusinessCode());
|
2018-06-04 15:14:52 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// <service,cfgIdList>
|
2018-06-02 13:01:27 +08:00
|
|
|
|
Map<Integer, List<Long>> cfgMap = new HashMap<Integer, List<Long>>();
|
2018-06-04 15:14:52 +08:00
|
|
|
|
for (int i = 0; i < jsonObjectList.size(); i++) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
JsonObject jsonObj = (JsonObject) jsonObjectList.get(i);
|
|
|
|
|
|
Map<String, Object> srcMap = JSONObject.fromObject(JSONObject
|
|
|
|
|
|
.fromObject((jsonObj.toString())));
|
2018-06-04 15:14:52 +08:00
|
|
|
|
String msg = checkOptForUpdate(srcMap);
|
|
|
|
|
|
if (!msg.equals("ok")) {
|
|
|
|
|
|
thread.setExceptionInfo(msg + sb.toString());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
throw new RestServiceException(thread,
|
|
|
|
|
|
System.currentTimeMillis() - start,
|
|
|
|
|
|
msg + sb.toString(),
|
|
|
|
|
|
CompileVal.getBusinessCode());
|
2018-06-04 15:14:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
Integer service = Integer.valueOf(srcMap.get("service").toString());
|
|
|
|
|
|
Long cfgId = Long.valueOf(srcMap.get("cfgId").toString());
|
|
|
|
|
|
if (cfgMap.containsKey(service)) {
|
|
|
|
|
|
cfgMap.get(service).add(cfgId);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
List<Long> idList = new ArrayList<Long>();
|
|
|
|
|
|
idList.add(cfgId);
|
|
|
|
|
|
cfgMap.put(service, idList);
|
2018-06-02 13:01:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-06-02 13:01:27 +08:00
|
|
|
|
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
|
|
|
|
|
Iterator serviceIterator = cfgMap.keySet().iterator();
|
|
|
|
|
|
while (serviceIterator.hasNext()) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Integer service = Integer
|
|
|
|
|
|
.valueOf(serviceIterator.next().toString());
|
|
|
|
|
|
List<Integer> dbIndexList = ServiceAndRDBIndexReal
|
|
|
|
|
|
.getRedisDBByService(service);
|
|
|
|
|
|
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
|
2018-06-04 17:52:20 +08:00
|
|
|
|
for (Integer dbIndex : dbIndexList) {
|
|
|
|
|
|
if (restMap.containsKey(dbIndex)) {
|
|
|
|
|
|
restMap.get(dbIndex).put(service, cfgMap.get(service));
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else {
|
2018-06-04 17:52:20 +08:00
|
|
|
|
Map<Integer, List<Long>> map = new HashMap<Integer, List<Long>>();
|
|
|
|
|
|
map.put(service, cfgMap.get(service));
|
|
|
|
|
|
restMap.put(dbIndex, map);
|
|
|
|
|
|
}
|
2018-06-02 13:01:27 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
RuntimeException e = new RuntimeException(
|
|
|
|
|
|
"service与写入数据库序号映射关系不存在");
|
|
|
|
|
|
CompileVal.setBusinessCode(30000);
|
2018-06-04 17:52:20 +08:00
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
2018-06-02 13:01:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-11 15:06:47 +08:00
|
|
|
|
try {
|
|
|
|
|
|
configRedisService.delUnMaatConfig(restMap);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
// TODO: handle exception
|
|
|
|
|
|
logger1.error(e.getMessage());
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.unknow_error.getValue());
|
|
|
|
|
|
if (e.getMessage().startsWith("后台错误:")) {
|
|
|
|
|
|
CompileVal.setBusinessCode(30000);
|
|
|
|
|
|
}
|
2018-06-11 15:06:47 +08:00
|
|
|
|
msgList.add(e);
|
|
|
|
|
|
return "error";
|
|
|
|
|
|
}
|
2018-06-02 13:01:27 +08:00
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-06-04 15:14:52 +08:00
|
|
|
|
private String checkOptForUpdate(Map<String, Object> srcMap) {
|
|
|
|
|
|
String cfgId = srcMap.get("cfgId").toString();
|
|
|
|
|
|
String service = srcMap.get("service").toString();
|
|
|
|
|
|
String isValid = srcMap.get("isValid").toString();
|
|
|
|
|
|
if (StringUtil.isEmpty(cfgId)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.CfgIdIsNull.getValue());
|
|
|
|
|
|
return RestBusinessCode.CfgIdIsNull.getErrorReason();
|
|
|
|
|
|
} else if (!StringUtil.isNumeric(cfgId)) {
|
|
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.MastNumberic.getValue());
|
|
|
|
|
|
return "cfgId字段格式不正确,"+RestBusinessCode.MastNumberic.getErrorReason();
|
2018-06-02 13:01:27 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-06-04 15:14:52 +08:00
|
|
|
|
if (StringUtil.isEmpty(service)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.ServiceIsNull.getValue());
|
|
|
|
|
|
return RestBusinessCode.ServiceIsNull.getErrorReason();
|
|
|
|
|
|
} else if (!StringUtil.isNumeric(service)) {
|
|
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.MastNumberic.getValue());
|
|
|
|
|
|
return "service字段格式不正确,"+RestBusinessCode.MastNumberic.getErrorReason();
|
2018-06-02 13:01:27 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-06-04 15:14:52 +08:00
|
|
|
|
if (StringUtil.isEmpty(isValid)) {
|
2018-07-04 17:03:04 +08:00
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.IsValidIsNull.getValue());
|
|
|
|
|
|
return "配置id为" + srcMap.get("cfgId") + "的isValid字段不能为空";
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (!StringUtil.isNumeric(service)) {
|
|
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.IsValidInWrongRange.getValue());
|
|
|
|
|
|
return RestBusinessCode.IsValidInWrongRange.getErrorReason();
|
|
|
|
|
|
} else if (!isValid.equals("0")) {
|
|
|
|
|
|
CompileVal.setBusinessCode(RestBusinessCode.IsValidIsF.getValue());
|
|
|
|
|
|
return RestBusinessCode.IsValidIsF.getErrorReason();
|
2018-06-04 15:14:52 +08:00
|
|
|
|
}
|
2018-06-02 13:01:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
private boolean isIp(String ipStr) {
|
|
|
|
|
|
if (!(BasicProvingUtil.isIpOrIpMask(ipStr, 4) || BasicProvingUtil
|
|
|
|
|
|
.isIpOrIpMask(ipStr, 6))) {
|
2018-05-24 17:22:38 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2018-05-24 17:22:38 +08:00
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
public String setCompileInvalid(ConfigCompile configCompile)
|
|
|
|
|
|
throws Exception {
|
2017-12-19 14:55:52 +08:00
|
|
|
|
configCompileDao.setCompileInvalid(configCompile.getCompileId(), 0);
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String setCompileValid(ConfigCompile configCompile) throws Exception {
|
|
|
|
|
|
configCompileDao.setCompileInvalid(configCompile.getCompileId(), 1);
|
|
|
|
|
|
return "ok";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-07-04 17:03:04 +08:00
|
|
|
|
public String getDigestGen(String realPath, String filePath)
|
|
|
|
|
|
throws Exception {
|
2018-06-01 10:27:03 +08:00
|
|
|
|
System.out.println("----------------getDigestGen");
|
2018-07-04 17:03:04 +08:00
|
|
|
|
String content = "";
|
|
|
|
|
|
String digestGenToolPath = Constants.DIGEST_GEN_TOOL_PATH;
|
|
|
|
|
|
String chmodCommond = "chmod +x " + realPath + digestGenToolPath;// 执行权限命令
|
|
|
|
|
|
// System.out.println("----------------chmodCommod:"+chmodCommond);
|
|
|
|
|
|
String commondStr = realPath + digestGenToolPath + " -f " + filePath; // 执行
|
|
|
|
|
|
// 执行摘要获取命令 digest -f /home/aa.txt
|
|
|
|
|
|
// System.out.println("------------commondStr:"+commondStr);
|
2018-06-01 10:27:03 +08:00
|
|
|
|
Runtime.getRuntime().exec(chmodCommond);
|
2018-07-04 17:03:04 +08:00
|
|
|
|
Process p = Runtime.getRuntime().exec(commondStr);
|
|
|
|
|
|
byte[] b = new byte[1024];
|
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
while (p.getInputStream().read(b) != -1) {
|
|
|
|
|
|
sb.append(new String(b, "UTF-8"));
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
content = sb.toString();
|
2018-06-01 10:27:03 +08:00
|
|
|
|
if (!StringUtil.isBlank(content)) {
|
|
|
|
|
|
content = StringUtil.stripAll(content);
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
// System.out.println("-------------------->>"+content);
|
|
|
|
|
|
String[] digestGenReslt = content.split(" ");
|
|
|
|
|
|
if (digestGenReslt.length >= 4
|
|
|
|
|
|
&& !StringUtil.isEmpty(digestGenReslt[3])) {
|
|
|
|
|
|
return digestGenReslt[3];
|
2018-06-01 10:27:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2018-07-04 17:03:04 +08:00
|
|
|
|
|
2017-12-19 14:55:52 +08:00
|
|
|
|
}
|