批量配置失效、全量下发、各业务全量下发功能提交
This commit is contained in:
@@ -21,8 +21,11 @@ import org.springframework.stereotype.Service;
|
||||
import antlr.StringUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.AsnGroupInfo;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
import com.nis.domain.configuration.AppFeatureIndex;
|
||||
import com.nis.domain.configuration.AppIpCfg;
|
||||
@@ -62,6 +65,7 @@ import com.nis.util.DictUtils;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.util.ServiceConfigTemplateUtil;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.basics.AsnGroupInfoDao;
|
||||
import com.nis.web.dao.configuration.AppCfgDao;
|
||||
import com.nis.web.dao.configuration.CommonPolicyDao;
|
||||
import com.nis.web.dao.configuration.ConfigSynchronizationDao;
|
||||
@@ -69,6 +73,7 @@ import com.nis.web.dao.specific.ConfigGroupInfoDao;
|
||||
import com.nis.web.dao.specific.SpecificServiceCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.BaseService;
|
||||
import com.sun.xml.internal.rngom.util.Utf16;
|
||||
|
||||
/**
|
||||
* 配置全量同步事务类
|
||||
@@ -86,11 +91,14 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
@Autowired
|
||||
protected ConfigGroupInfoDao configGroupInfoDao;
|
||||
@Autowired
|
||||
protected AsnGroupInfoDao asnGroupInfoDao;
|
||||
@Autowired
|
||||
protected AppCfgDao appCfgDao;
|
||||
private boolean lastServiceTag = false;//标识是否是最后一个同步业务
|
||||
private boolean isFinished = false;
|
||||
/**
|
||||
* 配置全量更新下发
|
||||
* @param serviceIdCondition 界面传入的全量同步某一个业务
|
||||
* @param request
|
||||
* @param response
|
||||
* @throws IllegalAccessException
|
||||
@@ -99,11 +107,16 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
* @throws NoSuchFieldException
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public void send(HttpServletRequest request,HttpServletResponse response,BaseCfg cfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
|
||||
public void send(Integer serviceIdCondition,HttpServletRequest request,HttpServletResponse response,BaseCfg cfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
|
||||
long start = System.currentTimeMillis();
|
||||
ServiceConfigTemplateUtil serviceTemplate = new ServiceConfigTemplateUtil();
|
||||
if(cfg==null){
|
||||
List<Map<String,Object>> serviceList = serviceTemplate.getServiceList();
|
||||
List<Map<String,Object>> serviceList =new ArrayList<>();
|
||||
if(StringUtil.isEmpty(serviceIdCondition)) {
|
||||
serviceList= serviceTemplate.getServiceList();
|
||||
}else {
|
||||
serviceList=serviceTemplate.getServiceListByServiceId(serviceIdCondition);
|
||||
}
|
||||
int lastService = 0;
|
||||
lastServiceTag = false;
|
||||
for(Map<String,Object> service:serviceList){
|
||||
@@ -149,7 +162,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
}else{
|
||||
json="[]";
|
||||
}*/
|
||||
JSONObject result = ConfigServiceUtil.configSync(json,Integer.parseInt(serviceType),entity.getServiceId(),entity.getTableName(),"FINISHED");
|
||||
//JSONObject result = ConfigServiceUtil.configSync(json,Integer.parseInt(serviceType),entity.getServiceId(),entity.getTableName(),"FINISHED");
|
||||
}
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
@@ -271,9 +284,9 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
List<String> asnGroupIds = new ArrayList();
|
||||
for(CfgIndexInfo cfg:list){
|
||||
compileIds.add(cfg.getCompileId());
|
||||
if(entity.getServiceId().equals(37)||entity.getServiceId().equals(149)){
|
||||
/*if(entity.getServiceId().equals(37)||entity.getServiceId().equals(149)){
|
||||
asnGroupIds.add(cfg.getUserRegion4());
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if(isUpdateCfg) {
|
||||
@@ -286,17 +299,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
for(Map<String,Object> m:cfgList){
|
||||
String tableName = m.get("tableName").toString();
|
||||
if("1".equals(m.get("cfgType"))){
|
||||
if(tableName.equals("asn_ip_cfg")){
|
||||
if(!StringUtil.isEmpty(asnGroupIds)) {
|
||||
if(isUpdateCfg) { //批量审核时只查询未下发的asnip
|
||||
asnIpList.addAll(configSynchronizationDao.getAsnIpList(asnGroupIds,0));
|
||||
}else { //全量下发时需要检索所有asnip
|
||||
asnIpList.addAll(configSynchronizationDao.getAsnIpList(asnGroupIds,null));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
ipList.addAll(configSynchronizationDao.getIpPortList(tableName, compileIds));
|
||||
}
|
||||
ipList.addAll(configSynchronizationDao.getIpPortList(tableName, compileIds));
|
||||
}else if("2".equals(m.get("cfgType"))){
|
||||
strList.addAll(configSynchronizationDao.getStrList(tableName,compileIds));
|
||||
}else if("3".equals(m.get("cfgType"))){
|
||||
@@ -342,14 +345,14 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
if(userRegionPosition!=null && (userRegionPosition.toString().equals("1")||userRegionPosition.toString().equals("0"))){
|
||||
//通过反射机制获取自定义域字段值
|
||||
String regionColumn = n.get("regionColumn").toString();
|
||||
String regionKey = n.get("regionKey").toString();
|
||||
Object value = "";
|
||||
Class aClass = null;
|
||||
if(userRegionPosition.toString().equals(("0"))){
|
||||
aClass = BaseCfg.class;
|
||||
}else{
|
||||
aClass = CfgIndexInfo.class;
|
||||
}
|
||||
|
||||
Object value = "";
|
||||
if(entity.getServiceId().equals(517)||entity.getServiceId().equals(560)){//代理替换策略
|
||||
String[] regionArray = regionColumn.split(",");
|
||||
for(int r=0;r<regionArray.length;r++){
|
||||
@@ -364,9 +367,21 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
}
|
||||
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
|
||||
}else{
|
||||
Field field = aClass.getDeclaredField(regionColumn);
|
||||
field.setAccessible(true);
|
||||
value = field.get(cfg);
|
||||
if(regionKey.equals("keyring_id") && StringUtil.isEmpty(value)){
|
||||
value = "0";
|
||||
}else if(regionKey.equals("DOMAIN_STR")) {
|
||||
if(!StringUtil.isEmpty(strList)) {
|
||||
value = strList.get(0).getCfgKeywords();
|
||||
}
|
||||
}else {
|
||||
if(regionKey.equals("DOMAIN_ID") && StringUtil.isEmpty(strList)) {
|
||||
value="";
|
||||
}else {
|
||||
Field field = aClass.getDeclaredField(regionColumn);
|
||||
field.setAccessible(true);
|
||||
value = field.get(cfg);
|
||||
}
|
||||
}
|
||||
if(!StringUtil.isEmpty(value)){
|
||||
if(StringUtil.isEmpty(n.get("regionKey"))){
|
||||
userRegion = value.toString();
|
||||
@@ -376,7 +391,6 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
}
|
||||
}
|
||||
}
|
||||
// System.out.println("userRegionList:"+n.get("regionKey")+","+n.get("regionColumn")+","+n.get("handleType"));
|
||||
}
|
||||
if(userRegion.endsWith(Constants.USER_REGION_SPLIT)){
|
||||
userRegion = userRegion.substring(0, userRegion.length()-1);
|
||||
@@ -452,7 +466,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
//调用服务接口配置全量更新
|
||||
isFinished = ((!hasData)&&lastServiceTag)?true:false;
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
}
|
||||
}
|
||||
return hasData;
|
||||
@@ -623,7 +637,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
//调用服务接口配置全量更新
|
||||
isFinished = ((!hasData)&&lastServiceTag)?true:false;
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
}
|
||||
}
|
||||
return hasData;
|
||||
@@ -812,7 +826,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
//调用服务接口配置全量更新
|
||||
isFinished = ((!hasData)&&lastServiceTag)?true:false;
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
// JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
//TODO 联调时打开 JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
}
|
||||
}
|
||||
return hasData;
|
||||
@@ -982,7 +996,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
//调用服务接口配置全量更新
|
||||
isFinished = ((!hasData)&&lastServiceTag)?true:false;
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
}
|
||||
}
|
||||
return hasData;
|
||||
@@ -1029,14 +1043,49 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
public void handleSingleMaatData(int cfgType,List<Map<String,Object>>userRegionList,
|
||||
Page<T> page,BaseCfg entity,HttpServletRequest request,HttpServletResponse response,
|
||||
boolean isUpdateCfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||
|
||||
boolean hasData = true;
|
||||
//APP IP按配置Id批量下发[服务端只支持maat和回调类格式的json串]
|
||||
List<ConfigGroupInfo> groupInfos=new ArrayList<>();
|
||||
//ASN IP按配置Id全量下发[服务端只支持maat和回调类格式的json串]
|
||||
List<AsnGroupInfo> asnGroupInfos=new ArrayList<>();
|
||||
if(entity.getServiceId().equals(1028)){
|
||||
ConfigGroupInfo groupInfo=new ConfigGroupInfo();
|
||||
groupInfo.setIsIssued(1);//全量下发只用获取已下发的group信息
|
||||
groupInfo.setGroupType(1);
|
||||
groupInfos=configGroupInfoDao.findAllList(groupInfo);//每一批次下发都取一次最新的group_info信息
|
||||
if(StringUtil.isEmpty(groupInfos)){
|
||||
hasData=false;
|
||||
}
|
||||
}
|
||||
if(entity.getServiceId().equals(400)){
|
||||
AsnGroupInfo groupInfo=new AsnGroupInfo();
|
||||
groupInfo.setIsValid(1);//全量下发只用获取已下发的group信息
|
||||
asnGroupInfos=asnGroupInfoDao.findAsnGroupInfoList(groupInfo);//每一批次下发都取一次最新的group_info信息
|
||||
if(StringUtil.isEmpty(asnGroupInfos)){
|
||||
hasData=false;
|
||||
}
|
||||
}
|
||||
|
||||
while(hasData){
|
||||
entity.setPage(page);
|
||||
List list = Lists.newArrayList();
|
||||
if(cfgType==1){
|
||||
if(entity.getServiceId().equals(1028)){
|
||||
page.setPageSize(-1);
|
||||
page.setPageNo(1);
|
||||
page.setLastPage(true);
|
||||
entity.setPage(page);
|
||||
entity.setCompileId(groupInfos.get(0).getCompileId());
|
||||
entity.setGroupId(groupInfos.get(0).getGroupId());
|
||||
list = configSynchronizationDao.getAppIpFeatureList(entity);
|
||||
}else if(entity.getServiceId().equals(400)){
|
||||
page.setPageSize(-1);
|
||||
page.setPageNo(1);
|
||||
page.setLastPage(true);
|
||||
entity.setPage(page);
|
||||
entity.setCompileId(asnGroupInfos.get(0).getCompileId());
|
||||
entity.setGroupId(asnGroupInfos.get(0).getGroupId());
|
||||
list = configSynchronizationDao.getAsnIpList(entity);
|
||||
}else{
|
||||
list = configSynchronizationDao.getIpPortListByService(entity);
|
||||
}
|
||||
@@ -1047,18 +1096,11 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
}
|
||||
if(!StringUtil.isEmpty(list)){
|
||||
if(entity.getServiceId().equals(1028)){
|
||||
ConfigGroupInfo groupInfo=new ConfigGroupInfo();
|
||||
groupInfo.setIsIssued(1);//全量下发只用获取已下发的group信息
|
||||
List<ConfigGroupInfo> groupInfos=configGroupInfoDao.findAllList(groupInfo);//每一批次下发都取一次最新的group_info信息
|
||||
Map<Integer, Integer> compileGroups=new HashMap<>();
|
||||
if(!StringUtil.isEmpty(groupInfos)) {
|
||||
for (ConfigGroupInfo configGroupInfo : groupInfos) {
|
||||
compileGroups.put(configGroupInfo.getCompileId(), configGroupInfo.getGroupId());
|
||||
}
|
||||
}
|
||||
entity.setCompileGroupMap(compileGroups);
|
||||
hasData=auditAppIpData(userRegionList,
|
||||
page,entity,list,hasData,isUpdateCfg);
|
||||
}else if(entity.getServiceId().equals(400)){
|
||||
hasData=auditAsnIpData(userRegionList,
|
||||
page,entity,list,hasData,isUpdateCfg);
|
||||
}else{
|
||||
hasData=auditSingleMaatData(cfgType,userRegionList,
|
||||
page,entity,list,hasData,isUpdateCfg);
|
||||
@@ -1070,6 +1112,30 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
}else{
|
||||
hasData = false;
|
||||
}
|
||||
//ASN IP
|
||||
if(entity.getServiceId().equals(400)){
|
||||
//处理完成一个compile,删除一个Group
|
||||
if(!StringUtil.isEmpty(asnGroupInfos)){
|
||||
asnGroupInfos.remove(0);
|
||||
}
|
||||
if(asnGroupInfos.size() > 0) {
|
||||
hasData=true;
|
||||
}else {
|
||||
hasData=false;
|
||||
}
|
||||
}
|
||||
//APP IP
|
||||
if(entity.getServiceId().equals(1028)){
|
||||
//处理完成一个compile,删除一个Group
|
||||
if(!StringUtil.isEmpty(groupInfos)){
|
||||
groupInfos.remove(0);
|
||||
}
|
||||
if(groupInfos.size() > 0) {
|
||||
hasData=true;
|
||||
}else {
|
||||
hasData=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -1125,7 +1191,8 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
areaIpRegionList = new ArrayList();
|
||||
List<DdosIpCfg> list1 = new ArrayList();
|
||||
String userRegion = "";
|
||||
//处理自定义域
|
||||
//处理自定义域【DDOS自定义域组成json结构】
|
||||
Map ddosUserRegion= new HashMap();
|
||||
if(userRegionList!=null){
|
||||
for(Map<String,Object> n:userRegionList){
|
||||
Object userRegionPosition = n.get("userRegionPosition");
|
||||
@@ -1142,17 +1209,21 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
Field field = aClass.getDeclaredField(regionColumn);
|
||||
field.setAccessible(true);
|
||||
value = field.get(cfg);
|
||||
|
||||
if(!StringUtil.isEmpty(value)){
|
||||
if(StringUtil.isEmpty(n.get("regionKey"))){
|
||||
userRegion = value.toString();
|
||||
}else{
|
||||
userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
|
||||
//userRegion += n.get("regionKey")+"="+value+Constants.USER_REGION_SPLIT;
|
||||
ddosUserRegion.put(n.get("regionKey"), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(userRegion.endsWith(Constants.USER_REGION_SPLIT)){
|
||||
userRegion = userRegion.substring(0, userRegion.length()-1);
|
||||
}else if(!StringUtil.isEmpty(ddosUserRegion)){
|
||||
userRegion = new Gson().toJson(ddosUserRegion);
|
||||
}
|
||||
}
|
||||
if(isUpdateCfg && !StringUtil.isEmpty(cfg) && !StringUtil.isEmpty(cfg.getCompileId())) {
|
||||
@@ -1211,7 +1282,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
//调用服务接口配置全量更新
|
||||
isFinished = ((!hasData)&&lastServiceTag)?true:false;
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1419,7 +1490,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
//调用服务接口配置全量更新
|
||||
isFinished = ((!hasData)&&lastServiceTag)?true:false;
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1427,7 +1498,8 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
}
|
||||
/**
|
||||
* 处理app ip特征(分组复用)配置
|
||||
* 批量下发:【第一次下发为正常配置下发,非第一次下发为分组复用接口下发】
|
||||
* 全量下发(全量下发接口只支持maat和回调类的json字符串格式)
|
||||
* TODO 批量下发:【第一次下发为正常配置下发,非第一次下发为分组复用接口下发】
|
||||
* @param serviceId
|
||||
* @param request
|
||||
* @param response
|
||||
@@ -1455,34 +1527,30 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
configCompileList = new ArrayList();
|
||||
List<Integer> regionIds= new ArrayList();//存储app ip域id
|
||||
List<Integer> compileIds= new ArrayList();//存储app compileId
|
||||
Map<Integer, Integer> compileGroups=new HashMap<>();
|
||||
compileGroups=entity.getCompileGroupMap();
|
||||
Integer isIssued=entity.getCompileIsIssued();//批量下发时使用,需要用来判断是否走分组复用接口
|
||||
|
||||
//同一编译IP的分组
|
||||
Map<Integer,List<AppIpCfg>> dataMap=new HashMap<>();
|
||||
Integer compileId=entity.getCompileId();
|
||||
Integer groupId=entity.getGroupId();
|
||||
List<AppIpCfg> ipList=new ArrayList<>();
|
||||
for(int i=0;i<list.size();i++){
|
||||
AppIpCfg cfg = new AppIpCfg();
|
||||
BeanUtils.copyProperties(list.get(i), cfg);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
|
||||
cfg.setGroupId(compileGroups.get(cfg.getCompileId()));
|
||||
if(dataMap.containsKey(cfg.getCompileId())) {
|
||||
dataMap.get(cfg.getCompileId()).add(cfg);
|
||||
}else {
|
||||
List<AppIpCfg> ipList=new ArrayList<>();
|
||||
ipList.add(cfg);
|
||||
dataMap.put(cfg.getCompileId(), ipList);
|
||||
}
|
||||
if(isUpdateCfg) {
|
||||
cfg.setGroupId(groupId);
|
||||
ipList.add(cfg);
|
||||
/*if(isUpdateCfg) {
|
||||
if(!compileIds.contains(cfg.getCompileId())) {
|
||||
compileIds.add(cfg.getCompileId());
|
||||
}
|
||||
if(!StringUtil.isEmpty(cfg.getUserRegion1())) {
|
||||
regionIds.add(Integer.parseInt(cfg.getUserRegion1()));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
dataMap.put(compileId, ipList);
|
||||
for(List<AppIpCfg> entitys:dataMap.values()) {
|
||||
maatCfg = new MaatCfg();
|
||||
reuseMaatBean = new GroupReuseAddBean();
|
||||
@@ -1609,8 +1677,196 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
}else {
|
||||
//调用服务接口配置全量更新
|
||||
isFinished = ((!hasData)&&lastServiceTag)?true:false;
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+compileId+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
}
|
||||
|
||||
}
|
||||
return hasData;
|
||||
}
|
||||
/**
|
||||
* 处理ASN ip配置
|
||||
* 全量下发(全量下发接口只支持maat和回调类的json字符串格式)
|
||||
* TODO 批量下发:【第一次下发为正常配置下发,非第一次下发为分组复用接口下发】
|
||||
* @param serviceId
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
public boolean auditAsnIpData(List<Map<String,Object>>userRegionList,
|
||||
Page<T> page,
|
||||
BaseCfg entity,
|
||||
List<T> list,
|
||||
boolean hasData,
|
||||
boolean isUpdateCfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||
|
||||
ToMaatBean maatBean;
|
||||
GroupReuseAddBean reuseMaatBean;
|
||||
MaatCfg maatCfg;
|
||||
List<MaatCfg> configCompileList;
|
||||
List<GroupCfg> groupRelationList;
|
||||
List<IpCfg> ipRegionList;
|
||||
List<StringCfg> strRegionList;
|
||||
List<NumBoundaryCfg> numRegionList;
|
||||
List<DigestCfg> digestRegionList;
|
||||
List<IpCfg> areaIpRegionList;
|
||||
|
||||
maatBean = new ToMaatBean();
|
||||
reuseMaatBean = new GroupReuseAddBean();
|
||||
configCompileList = new ArrayList();
|
||||
List<Integer> regionIds= new ArrayList();//存储app ip域id
|
||||
List<Integer> compileIds= new ArrayList();//存储app compileId
|
||||
Integer isIssued=entity.getCompileIsIssued();//批量下发时使用,需要用来判断是否走分组复用接口
|
||||
|
||||
//同一编译IP的分组
|
||||
Map<Integer,List<AsnIpCfg>> dataMap=new HashMap<>();
|
||||
Integer compileId=entity.getCompileId();
|
||||
Integer groupId=entity.getGroupId();
|
||||
List<AsnIpCfg> ipList=new ArrayList<>();
|
||||
for(int i=0;i<list.size();i++){
|
||||
AsnIpCfg cfg = new AsnIpCfg();
|
||||
BeanUtils.copyProperties(list.get(i), cfg);
|
||||
cfg.setIsValid(entity.getIsValid());
|
||||
cfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime()) ? cfg.getAuditTime():entity.getAuditTime());
|
||||
cfg.setGroupId(groupId);
|
||||
ipList.add(cfg);
|
||||
/*if(isUpdateCfg) {
|
||||
if(!compileIds.contains(cfg.getCompileId())) {
|
||||
compileIds.add(cfg.getCompileId());
|
||||
}
|
||||
if(!StringUtil.isEmpty(cfg.getUserRegion1())) {
|
||||
regionIds.add(Integer.parseInt(cfg.getUserRegion1()));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
dataMap.put(compileId, ipList);
|
||||
for(List<AsnIpCfg> entitys:dataMap.values()) {
|
||||
maatCfg = new MaatCfg();
|
||||
reuseMaatBean = new GroupReuseAddBean();
|
||||
maatCfg.initDefaultValue();
|
||||
groupRelationList = new ArrayList();
|
||||
ipRegionList = new ArrayList();
|
||||
strRegionList = new ArrayList();
|
||||
numRegionList = new ArrayList();
|
||||
digestRegionList = new ArrayList();
|
||||
areaIpRegionList = new ArrayList();
|
||||
|
||||
/*if(configGroupInfo==null) {
|
||||
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
||||
specificServiceCfg.setGroupId(groupId);
|
||||
configGroupInfo = new ConfigGroupInfo();
|
||||
configGroupInfo.setGroupId(specificServiceCfg.getGroupId());
|
||||
configGroupInfo.setGroupName(specificServiceCfg.getSpecServiceName());
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setCompileId(entitys.get(0).getCompileId());
|
||||
configGroupInfo.setGroupType(1);
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||
//更新group_id
|
||||
specificServiceCfg.setOpTime(new Date());
|
||||
specificServiceCfgDao.update(specificServiceCfg);
|
||||
}*/
|
||||
|
||||
if(isUpdateCfg && (isIssued.equals(1) || entity.getIsValid().equals(0))) {
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
/*groupReuseCfg.setUserRegion(userRegion);*/
|
||||
groupReuseCfg.setServiceId(entitys.get(0).getServiceId());
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(entitys,entity.getIsValid(),entitys.get(0).getGroupId()));
|
||||
groupReuseCfg.setIpRegionList(ipRegionList);
|
||||
groupReuseCfg.setStrRegionList(strRegionList);
|
||||
groupReuseCfg.setNumRegionList(numRegionList);
|
||||
groupReuseList.add(groupReuseCfg);
|
||||
reuseMaatBean.setGroupReuseCfgList(groupReuseList);
|
||||
reuseMaatBean.setAuditTime(StringUtil.isEmpty(entity.getAuditTime())?entitys.get(0).getAuditTime():entity.getAuditTime());
|
||||
reuseMaatBean.setCreatorName(entitys.get(0).getCurrentUser().getName());
|
||||
reuseMaatBean.setVersion(Constants.MAAT_VERSION);
|
||||
if(entity.getIsValid().equals(0)) {
|
||||
reuseMaatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
}else {
|
||||
reuseMaatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
}
|
||||
}else {
|
||||
GroupCfg groupCfg=new GroupCfg();
|
||||
groupCfg.setCompileId(entitys.get(0).getCompileId());
|
||||
groupCfg.setGroupId(entitys.get(0).getGroupId());
|
||||
groupCfg.setIsValid(Constants.VALID_YES);
|
||||
groupCfg.setAuditTime(StringUtil.isEmpty(entity.getAuditTime())?entitys.get(0).getAuditTime():entity.getAuditTime());
|
||||
groupRelationList.add(groupCfg);
|
||||
BeanUtils.copyProperties(entitys.get(0), maatCfg);
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(entitys,Constants.VALID_YES,entitys.get(0).getGroupId()));
|
||||
maatCfg.setAction(entitys.get(0).getAction());
|
||||
maatCfg.setAuditTime(entitys.get(0).getAuditTime());
|
||||
maatCfg.setIpRegionList(ipRegionList);
|
||||
maatCfg.setStrRegionList(strRegionList);
|
||||
maatCfg.setNumRegionList(numRegionList);
|
||||
maatCfg.setDigestRegionList(digestRegionList);
|
||||
maatCfg.setGroupRelationList(groupRelationList);
|
||||
maatCfg.setGroupNum(groupRelationList.size());
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setIsValid(entitys.get(0).getIsValid());
|
||||
// 设置asn自定义域
|
||||
String userRegion = "ASN_ID=AS" + entitys.get(0).getUserRegion1()/*+Constants.USER_REGION_SPLIT+"ASEV_ID="+businessType*/;
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
configCompileList.add(maatCfg);
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(entitys.get(0).getAuditTime());
|
||||
maatBean.setCreatorName(entitys.get(0).getCurrentUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if(isUpdateCfg) {
|
||||
if(!StringUtil.isEmpty(regionIds)) {
|
||||
commonPolicyDao.auditCfgBatch(entity.getTableName(), entity, regionIds, null);
|
||||
}
|
||||
if(isIssued.equals(0) && entity.getIsValid().equals(1)) {//group第一次下发需要修改状态为已下发
|
||||
if(!StringUtil.isEmpty(compileIds)) {
|
||||
commonPolicyDao.auditCfgBatch("config_group_info", entity, compileIds, null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
page.setList(list);
|
||||
if(page.getLast()==page.getPageNo()){
|
||||
hasData = false;
|
||||
}
|
||||
if(!StringUtil.isEmpty(configCompileList.size())){
|
||||
String json=gsonToJson(maatBean);
|
||||
//调用服务接口下发配置数据
|
||||
if(isUpdateCfg) {
|
||||
|
||||
if(isIssued.equals(1)) {//已下发过的compile或配置取消直接走ip复用接口
|
||||
json=gsonToJson(reuseMaatBean);
|
||||
if(entity.getIsValid().equals(0)) {
|
||||
logger.info("app ip批量失效:"+json);
|
||||
//调用服务接口同步回调类配置
|
||||
ToMaatResult result = ConfigServiceUtil.put(json, 3);
|
||||
if(result!=null){
|
||||
logger.info("app ip批量失效响应信息:"+result.getMsg());
|
||||
}
|
||||
}else {
|
||||
logger.info("app ip批量生效:"+json);
|
||||
//调用服务接口同步回调类配置
|
||||
ToMaatResult result = ConfigServiceUtil.postGroupReuseSources(json);
|
||||
if(result!=null){
|
||||
logger.info("app ip批量生效响应信息:"+result.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}else {//未下发过的compile直接走正常maat配置接口
|
||||
// logger.info("配置批量下发:"+json);
|
||||
//调用服务接口同步回调类配置
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||
if(result!=null){
|
||||
logger.info("配置批量下发响应信息:"+result.getMsg());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//调用服务接口配置全量更新
|
||||
isFinished = ((!hasData)&&lastServiceTag)?true:false;
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+compileId+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,isFinished?"FINISHED":null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1762,7 +2018,7 @@ public class ConfigSynchronizationService extends BaseService{
|
||||
FileUtils.writeToFile("/home/ceiec/configSync/"+DateUtils.getDate("yyyy-MM-dd")+"/"+entity.getServiceId()+"_"+page.getPageNo()+"_"+System.currentTimeMillis()+".json", json, false);
|
||||
//调用服务接口同步回调类配置
|
||||
isFinished = ((!hasData)&&lastServiceTag)?true:false;
|
||||
JSONObject result = ConfigServiceUtil.configSync(json,2,entity.getServiceId(),entity.getTableName(),isFinished?"FINISHED":null);
|
||||
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSync(json,2,entity.getServiceId(),entity.getTableName(),isFinished?"FINISHED":null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user