2018-01-09 16:50:39 +08:00
|
|
|
|
package com.nis.web.service.configuration;
|
|
|
|
|
|
|
2018-04-03 11:12:49 +08:00
|
|
|
|
import java.lang.annotation.Annotation;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.List;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
import java.util.Map;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import org.springframework.stereotype.Service;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
2018-04-03 11:12:49 +08:00
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
import com.google.gson.GsonBuilder;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
|
import com.nis.domain.ServiceConfigInfo;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
import com.nis.domain.configuration.AppComplexKeywordCfg;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import com.nis.domain.configuration.AppIdCfg;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
import com.nis.domain.configuration.AppStringCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.AreaIpCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.BaseIpCfg;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import com.nis.domain.configuration.AppIdCfg.AppFeaturesIndex;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
import com.nis.domain.maat.AppMaatCfg;
|
|
|
|
|
|
import com.nis.domain.specific.ConfigGroupInfo;
|
|
|
|
|
|
import com.nis.domain.specific.SpecificServiceCfg;
|
|
|
|
|
|
import com.nis.domain.specific.SpecificServiceHostCfg;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import com.nis.main.ConvertTool;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
import com.nis.util.Constants;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
|
|
|
|
|
import com.nis.web.dao.configuration.AppCfgDao;
|
|
|
|
|
|
import com.nis.web.dao.configuration.ComplexStringCfgDao;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
import com.nis.web.dao.configuration.IpCfgDao;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import com.nis.web.dao.configuration.StringCfgDao;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
import com.nis.web.dao.specific.SpecificServiceCfgDao;
|
|
|
|
|
|
import com.nis.web.dao.specific.SpecificServiceHostCfgDao;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
import com.nis.web.dao.systemService.ServiceConfigInfoDao;
|
|
|
|
|
|
import com.nis.web.service.CrudService;
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 特定协议相关配置事务类
|
|
|
|
|
|
* @author dell
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Service
|
2018-03-29 17:24:21 +08:00
|
|
|
|
public class AppCfgService extends CrudService<AppCfgDao,AppIdCfg> {
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AppCfgDao appCfgDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ServiceConfigInfoDao serviceConfigInfoDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected StringCfgDao stringCfgDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected ComplexStringCfgDao complexStringCfgDao;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private SpecificServiceCfgDao specificServiceCfgDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private SpecificServiceHostCfgDao specificServiceHostCfgDao;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected IpCfgDao ipCfgDao;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
|
|
|
|
|
|
public Page<AppIdCfg> findPage(Page<AppIdCfg> page, AppIdCfg entity) {
|
|
|
|
|
|
entity.setPage(page);
|
|
|
|
|
|
List<AppIdCfg> list = dao.findList(entity);
|
|
|
|
|
|
page.setList(list);
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
|
|
|
|
|
public AppIdCfg findAppIdCfg(AppIdCfg entity) {
|
|
|
|
|
|
//查询协议关联特征表
|
|
|
|
|
|
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId());
|
2018-04-03 11:12:49 +08:00
|
|
|
|
List<AppComplexKeywordCfg> complexList = new ArrayList();
|
|
|
|
|
|
List<AppStringCfg> strList = new ArrayList();
|
2018-03-29 17:24:21 +08:00
|
|
|
|
if(!StringUtil.isEmpty(featuresTableList)){
|
|
|
|
|
|
for(AppFeaturesIndex features:featuresTableList){
|
|
|
|
|
|
if(features.getFeaturesTableType().equals(4)){//增强字符串特征配置
|
2018-04-03 11:12:49 +08:00
|
|
|
|
List<AppComplexKeywordCfg> complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(
|
2018-03-29 17:24:21 +08:00
|
|
|
|
features.getFeaturesTable(),features.getFeaturesCompileId());
|
|
|
|
|
|
complexList.addAll(complexFeaturesList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if(features.getFeaturesTableType().equals(2)){//普通字符串特征配置
|
2018-04-03 11:12:49 +08:00
|
|
|
|
List<AppStringCfg> strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId(
|
2018-03-29 17:24:21 +08:00
|
|
|
|
features.getFeaturesTable(),features.getFeaturesCompileId());
|
|
|
|
|
|
strList.addAll(strFeaturesCfgList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
entity.setComplexFeaturesList(complexList);
|
|
|
|
|
|
entity.setStrFeaturesCfgList(strList);
|
|
|
|
|
|
return entity;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* addAppCfg(新增IP类配置)
|
|
|
|
|
|
* (继承AppIdCfg这个类方可使用)
|
|
|
|
|
|
* @param cfg
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*int
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
|
|
|
|
|
public int addAppCfg(AppIdCfg cfg) throws Exception{
|
|
|
|
|
|
//通过配置转换工具获取compileId
|
|
|
|
|
|
Integer appCompileId = 0;
|
|
|
|
|
|
int cfgId = 0;
|
|
|
|
|
|
appCompileId = new ConvertTool().getCompileId();
|
|
|
|
|
|
cfg.setCompileId(appCompileId);
|
|
|
|
|
|
cfgId = appCfgDao.insert(cfg);
|
|
|
|
|
|
if(cfg.getComplexFeaturesList()!=null){
|
2018-04-03 11:12:49 +08:00
|
|
|
|
for(AppComplexKeywordCfg c:cfg.getComplexFeaturesList()){
|
2018-03-29 17:24:21 +08:00
|
|
|
|
Integer featuresCompileId = new ConvertTool().getCompileId();
|
|
|
|
|
|
AppFeaturesIndex f = new AppFeaturesIndex();
|
|
|
|
|
|
f.setAppCompileId(cfg.getCompileId());
|
|
|
|
|
|
f.setFeaturesCompileId(featuresCompileId);
|
|
|
|
|
|
f.setFeaturesTableType(4);
|
|
|
|
|
|
f.setFeaturesTable(c.getTableName());
|
|
|
|
|
|
appCfgDao.insertFeatures(f);
|
|
|
|
|
|
|
|
|
|
|
|
c.setTableName(c.getTableName());
|
|
|
|
|
|
// c.initDefaultValue();
|
|
|
|
|
|
c.setAction(cfg.getAction());
|
|
|
|
|
|
c.setServiceId(cfg.getServiceId());
|
|
|
|
|
|
c.setCompileId(featuresCompileId);
|
|
|
|
|
|
c.setCreateTime(cfg.getCreateTime());
|
|
|
|
|
|
c.setCreatorId(cfg.getCreatorId());
|
|
|
|
|
|
c.setIsAudit(cfg.getIsAudit());
|
|
|
|
|
|
c.setIsValid(cfg.getIsValid());
|
|
|
|
|
|
c.setIsAreaEffective(cfg.getIsAreaEffective());
|
|
|
|
|
|
c.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
|
|
|
|
|
|
c.setAttribute(cfg.getAttribute());
|
|
|
|
|
|
c.setLable(cfg.getLable());
|
|
|
|
|
|
c.setClassify(cfg.getClassify());
|
|
|
|
|
|
c.setRequestId(cfg.getRequestId());
|
|
|
|
|
|
c.setCfgDesc(cfg.getCfgDesc());
|
|
|
|
|
|
complexStringCfgDao.insert(c);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(cfg.getStrFeaturesCfgList()!=null){
|
2018-04-03 11:12:49 +08:00
|
|
|
|
for(AppStringCfg s:cfg.getStrFeaturesCfgList()){
|
2018-03-29 17:24:21 +08:00
|
|
|
|
Integer featuresCompileId = new ConvertTool().getCompileId();
|
|
|
|
|
|
AppFeaturesIndex f = new AppFeaturesIndex();
|
|
|
|
|
|
f.setAppCompileId(cfg.getCompileId());
|
|
|
|
|
|
f.setFeaturesCompileId(featuresCompileId);
|
|
|
|
|
|
f.setFeaturesTableType(2);
|
|
|
|
|
|
f.setFeaturesTable(s.getTableName());
|
|
|
|
|
|
appCfgDao.insertFeatures(f);
|
|
|
|
|
|
s.setTableName(s.getTableName());
|
|
|
|
|
|
// s.initDefaultValue();
|
|
|
|
|
|
s.setAction(cfg.getAction());
|
|
|
|
|
|
s.setServiceId(cfg.getServiceId());
|
|
|
|
|
|
s.setCompileId(featuresCompileId);
|
|
|
|
|
|
s.setCreateTime(cfg.getCreateTime());
|
|
|
|
|
|
s.setCreatorId(cfg.getCreatorId());
|
|
|
|
|
|
s.setIsAudit(cfg.getIsAudit());
|
|
|
|
|
|
s.setIsValid(cfg.getIsValid());
|
|
|
|
|
|
s.setIsAreaEffective(cfg.getIsAreaEffective());
|
|
|
|
|
|
s.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
|
|
|
|
|
|
s.setAttribute(cfg.getAttribute());
|
|
|
|
|
|
s.setLable(cfg.getLable());
|
|
|
|
|
|
s.setClassify(cfg.getClassify());
|
|
|
|
|
|
s.setRequestId(cfg.getRequestId());
|
|
|
|
|
|
s.setCfgDesc(cfg.getCfgDesc());
|
|
|
|
|
|
stringCfgDao.insert(s);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return cfgId;
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* updateAppCfg(更新IP类配置)
|
|
|
|
|
|
* (继承AppIdCfg这个类方可使用)
|
|
|
|
|
|
* @param cfg
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*int
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
|
|
|
|
|
public int updateAppCfg(AppIdCfg cfg) throws Exception{
|
|
|
|
|
|
if(cfg.getComplexFeaturesList()!=null){
|
2018-04-03 11:12:49 +08:00
|
|
|
|
for(AppComplexKeywordCfg c:cfg.getComplexFeaturesList()){
|
2018-03-29 17:24:21 +08:00
|
|
|
|
Integer featuresCompileId = 0;
|
|
|
|
|
|
c.setIsAreaEffective(cfg.getIsAreaEffective());
|
|
|
|
|
|
c.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
|
|
|
|
|
|
c.setAttribute(cfg.getAttribute());
|
|
|
|
|
|
c.setLable(cfg.getLable());
|
|
|
|
|
|
c.setClassify(cfg.getClassify());
|
|
|
|
|
|
c.setRequestId(cfg.getRequestId());
|
|
|
|
|
|
c.setCfgDesc(cfg.getCfgDesc());
|
|
|
|
|
|
c.setEditorId(cfg.getEditorId());
|
|
|
|
|
|
c.setEditTime(cfg.getEditTime());
|
|
|
|
|
|
if(c.getCompileId()==null){
|
|
|
|
|
|
featuresCompileId = new ConvertTool().getCompileId();
|
|
|
|
|
|
AppFeaturesIndex f = new AppFeaturesIndex();
|
|
|
|
|
|
f.setAppCompileId(cfg.getCompileId());
|
|
|
|
|
|
f.setFeaturesCompileId(featuresCompileId);
|
|
|
|
|
|
f.setFeaturesTableType(4);
|
|
|
|
|
|
f.setFeaturesTable(c.getTableName());
|
|
|
|
|
|
appCfgDao.insertFeatures(f);
|
|
|
|
|
|
c.setTableName(c.getTableName());
|
|
|
|
|
|
c.setAction(cfg.getAction());
|
|
|
|
|
|
c.setServiceId(cfg.getServiceId());
|
|
|
|
|
|
c.setCompileId(featuresCompileId);
|
|
|
|
|
|
c.setCreateTime(new Date());
|
|
|
|
|
|
c.setCreatorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
c.setIsAudit(cfg.getIsAudit());
|
|
|
|
|
|
c.setIsValid(cfg.getIsValid());
|
|
|
|
|
|
complexStringCfgDao.insert(c);
|
|
|
|
|
|
}else{
|
2018-04-03 11:12:49 +08:00
|
|
|
|
complexStringCfgDao.updateByPrimaryKeySelective(c);
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(cfg.getStrFeaturesCfgList()!=null){
|
2018-04-03 11:12:49 +08:00
|
|
|
|
for(AppStringCfg s:cfg.getStrFeaturesCfgList()){
|
2018-03-29 17:24:21 +08:00
|
|
|
|
Integer featuresCompileId = 0;
|
|
|
|
|
|
s.setIsAreaEffective(cfg.getIsAreaEffective());
|
|
|
|
|
|
s.setAreaEffectiveIds(cfg.getAreaEffectiveIds());
|
|
|
|
|
|
s.setAttribute(cfg.getAttribute());
|
|
|
|
|
|
s.setLable(cfg.getLable());
|
|
|
|
|
|
s.setClassify(cfg.getClassify());
|
|
|
|
|
|
s.setRequestId(cfg.getRequestId());
|
|
|
|
|
|
s.setCfgDesc(cfg.getCfgDesc());
|
|
|
|
|
|
s.setEditorId(cfg.getEditorId());
|
|
|
|
|
|
s.setEditTime(cfg.getEditTime());
|
|
|
|
|
|
if(s.getCompileId()==null){
|
|
|
|
|
|
featuresCompileId = new ConvertTool().getCompileId();
|
|
|
|
|
|
AppFeaturesIndex f = new AppFeaturesIndex();
|
|
|
|
|
|
f.setAppCompileId(cfg.getCompileId());
|
|
|
|
|
|
f.setFeaturesCompileId(featuresCompileId);
|
|
|
|
|
|
f.setFeaturesTableType(2);
|
|
|
|
|
|
f.setFeaturesTable(s.getTableName());
|
|
|
|
|
|
appCfgDao.insertFeatures(f);
|
|
|
|
|
|
s.setTableName(s.getTableName());
|
|
|
|
|
|
s.setAction(cfg.getAction());
|
|
|
|
|
|
s.setServiceId(cfg.getServiceId());
|
|
|
|
|
|
s.setCompileId(featuresCompileId);
|
|
|
|
|
|
s.setCreateTime(new Date());
|
|
|
|
|
|
s.setCreatorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
s.setIsAudit(cfg.getIsAudit());
|
|
|
|
|
|
s.setIsValid(cfg.getIsValid());
|
|
|
|
|
|
stringCfgDao.insert(s);
|
|
|
|
|
|
}else{
|
2018-04-03 11:12:49 +08:00
|
|
|
|
stringCfgDao.updateByPrimaryKeySelective(s);
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return appCfgDao.updateByPrimaryKeySelective(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* auditAppCfg(审核IP类配置)
|
|
|
|
|
|
* (继承AppIdCfg这个类方可使用)
|
|
|
|
|
|
* @param cfg
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*int
|
2018-04-03 11:12:49 +08:00
|
|
|
|
* @throws Exception
|
2018-03-29 17:24:21 +08:00
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
2018-04-08 17:19:43 +08:00
|
|
|
|
public int auditAppCfg(String[] cfgIds,Integer auditState) throws Exception{
|
|
|
|
|
|
for(String id:cfgIds){
|
|
|
|
|
|
boolean sendFlag = false;
|
|
|
|
|
|
AppIdCfg appCfg = appCfgDao.getById(Long.parseLong(id));
|
2018-04-03 11:12:49 +08:00
|
|
|
|
|
2018-04-08 17:19:43 +08:00
|
|
|
|
//给需要修改的配置字段赋值
|
|
|
|
|
|
appCfg.setIsAudit(auditState);
|
|
|
|
|
|
appCfg.setAuditorId(appCfg.getCurrentUser().getId());
|
|
|
|
|
|
appCfg.setAuditTime(new Date());
|
|
|
|
|
|
if(auditState==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0
|
|
|
|
|
|
appCfg.setIsValid(Constants.VALID_NO);
|
|
|
|
|
|
}else if(auditState==Constants.AUDIT_YES){//审核通过,设置有效标志为1
|
|
|
|
|
|
appCfg.setIsValid(Constants.VALID_YES);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(appCfg.getCompileId()==0){
|
|
|
|
|
|
logger.error("转换出错,未获取到正确的compileId");
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(appCfg.getCompileId());
|
|
|
|
|
|
List<AppStringCfg> strList = new ArrayList();
|
|
|
|
|
|
List<AppComplexKeywordCfg> complexList = new ArrayList();
|
|
|
|
|
|
List<SpecificServiceHostCfg> hostList =new ArrayList();
|
|
|
|
|
|
List<BaseIpCfg> areaList = new ArrayList();
|
|
|
|
|
|
ConfigGroupInfo group = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Gson gson=new GsonBuilder().disableHtmlEscaping()
|
|
|
|
|
|
.excludeFieldsWithoutExposeAnnotation()
|
|
|
|
|
|
.create();
|
|
|
|
|
|
|
|
|
|
|
|
//配置审核状态即将改变后的状态
|
|
|
|
|
|
if(Constants.AUDIT_NOT_YES==auditState||
|
|
|
|
|
|
Constants.AUDIT_YES==auditState){//审核通过,取消审核通过需要发到maat
|
|
|
|
|
|
|
|
|
|
|
|
if(Constants.AUDIT_YES==auditState){//审核通过
|
|
|
|
|
|
if(StringUtil.isEmpty(featuresTableList)){
|
|
|
|
|
|
SpecificServiceCfg protocol = specificServiceCfgDao.getBySpecServiceId(appCfg.getAppId().intValue());
|
|
|
|
|
|
group = specificServiceCfgDao.getConfigGroupInfoByGroupId(protocol.getGroupId());
|
|
|
|
|
|
//featuresTableList为空的时候,该service只有特定服务IP一个配置表
|
|
|
|
|
|
ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId());
|
|
|
|
|
|
if(group==null){
|
|
|
|
|
|
throw new RuntimeException("配置审核失败,未获取社交应用服务器IP所属分组信息");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(group.getIsIssued()==0){
|
|
|
|
|
|
//如果分组信息尚未下发,则下发IP
|
|
|
|
|
|
group.setGroupId(protocol.getGroupId());
|
|
|
|
|
|
group.setIsIssued(1);
|
|
|
|
|
|
SpecificServiceHostCfg hostCfg = new SpecificServiceHostCfg();
|
|
|
|
|
|
hostCfg.setSpecServiceId(protocol.getSpecServiceId());
|
|
|
|
|
|
hostList = specificServiceHostCfgDao.findSpecHostList(hostCfg);
|
|
|
|
|
|
|
|
|
|
|
|
for(SpecificServiceHostCfg host:hostList){
|
|
|
|
|
|
SpecificServiceCfg specServiceCfg = specificServiceCfgDao.getBySpecServiceId(host.getSpecServiceId());
|
|
|
|
|
|
host.setProtocolId(0);
|
|
|
|
|
|
host.setGroupId(specServiceCfg.getGroupId());
|
|
|
|
|
|
if(StringUtil.isEmpty(serviceCfg)){
|
|
|
|
|
|
host.setMaatTable("DF_PROTOCOL_APP");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
host.setMaatTable(serviceCfg.getMaatTable());
|
|
|
|
|
|
}
|
2018-04-03 13:54:05 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
SpecificServiceHostCfg host = new SpecificServiceHostCfg();
|
|
|
|
|
|
host.setGroupId(protocol.getGroupId());
|
|
|
|
|
|
hostList.add(host);
|
2018-04-03 13:54:05 +08:00
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//生效区域列表信息
|
|
|
|
|
|
if(appCfg.getIsAreaEffective()==1){
|
|
|
|
|
|
if(StringUtil.isEmpty(appCfg.getAreaEffectiveIds())){
|
|
|
|
|
|
BaseIpCfg ipCfg = new BaseIpCfg();
|
|
|
|
|
|
ipCfg.setCompileId(appCfg.getCompileId());
|
|
|
|
|
|
ipCfg.setTableName("area_ip_cfg");
|
|
|
|
|
|
areaList = ipCfgDao.findList(ipCfg);
|
|
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
for(AppFeaturesIndex featuresCfg:featuresTableList){
|
|
|
|
|
|
if(featuresCfg.getFeaturesTableType()==2){
|
|
|
|
|
|
List<AppStringCfg> list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
|
|
|
|
|
|
for(AppStringCfg cfg:list){
|
|
|
|
|
|
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
|
|
|
|
|
|
if(!StringUtil.isEmpty(cList)){
|
|
|
|
|
|
for(ServiceConfigInfo c:cList){
|
|
|
|
|
|
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
|
|
|
|
|
|
cfg.setMaatTable(c.getMaatTable());
|
|
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
cfg.setCompileId(featuresCfg.getFeaturesCompileId());
|
|
|
|
|
|
strList.add(cfg);
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
if(featuresCfg.getFeaturesTableType()==4){
|
|
|
|
|
|
List<AppComplexKeywordCfg> list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
|
|
|
|
|
|
for(AppComplexKeywordCfg cfg:list){
|
|
|
|
|
|
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
|
|
|
|
|
|
if(!StringUtil.isEmpty(cList)){
|
|
|
|
|
|
for(ServiceConfigInfo c:cList){
|
|
|
|
|
|
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
|
|
|
|
|
|
cfg.setMaatTable(c.getMaatTable());
|
|
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
|
|
|
|
|
|
cfg.setCompileId(featuresCfg.getFeaturesCompileId());
|
|
|
|
|
|
complexList.add(cfg);
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
AppMaatCfg maatCfg = new AppMaatCfg();
|
|
|
|
|
|
if(StringUtil.isEmpty(featuresTableList)){
|
|
|
|
|
|
maatCfg.setIpCfg(hostList);
|
|
|
|
|
|
maatCfg.setAreaCfg(areaList);
|
|
|
|
|
|
if(appCfg.getCompileId()==0){
|
|
|
|
|
|
throw new RuntimeException("转换出错,未获取到正确的compileId");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
maatCfg.setCompileId(appCfg.getCompileId());
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{//特征配置
|
|
|
|
|
|
maatCfg.setStrCfg(strList);
|
|
|
|
|
|
maatCfg.setComplexStrCfg(complexList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(appCfg.getAction()==null){
|
|
|
|
|
|
throw new RuntimeException("转换出错,未获取到正确的action");
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}else{
|
2018-04-08 17:19:43 +08:00
|
|
|
|
maatCfg.setAction(appCfg.getAction());
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
if(appCfg.getIsAreaEffective()==null){
|
|
|
|
|
|
throw new RuntimeException("转换出错,未获取到正确的isAreaEffective");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
maatCfg.setIsAreaEffective(appCfg.getIsAreaEffective());
|
|
|
|
|
|
}
|
|
|
|
|
|
if(appCfg.getIsValid()==null){
|
|
|
|
|
|
throw new RuntimeException("转换出错,未获取到正确的isValid");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
maatCfg.setIsValid(appCfg.getIsValid());
|
|
|
|
|
|
}
|
|
|
|
|
|
if(appCfg.getRequestId()==null){
|
|
|
|
|
|
throw new RuntimeException("转换出错,未获取到正确的requestId");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
maatCfg.setRequestId(appCfg.getRequestId());
|
|
|
|
|
|
}
|
|
|
|
|
|
if(appCfg.getServiceId()==null){
|
|
|
|
|
|
throw new RuntimeException("转换出错,未获取到正确的serviceId");
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}else{
|
2018-04-08 17:19:43 +08:00
|
|
|
|
maatCfg.setServiceId(appCfg.getServiceId());
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
maatCfg.setSpecificServiceId(appCfg.getAppId());
|
|
|
|
|
|
maatCfg.setAreaEffectiveIds(appCfg.getAreaEffectiveIds()==null?"":appCfg.getAreaEffectiveIds());
|
|
|
|
|
|
maatCfg.setAttribute(appCfg.getAttribute()==null?"":appCfg.getAttribute());
|
|
|
|
|
|
maatCfg.setClassify(appCfg.getClassify()==null?"":appCfg.getClassify());
|
|
|
|
|
|
maatCfg.setLable(appCfg.getLable()==null?"":appCfg.getLable());
|
|
|
|
|
|
String json=gson.toJson(maatCfg);
|
|
|
|
|
|
//下发maat
|
|
|
|
|
|
// new ConvertTool().saveAppConfig(json);
|
|
|
|
|
|
sendFlag = true;
|
|
|
|
|
|
|
|
|
|
|
|
}else{//取消审核通过
|
|
|
|
|
|
AppMaatCfg maatCfg = new AppMaatCfg();
|
|
|
|
|
|
if(StringUtil.isEmpty(featuresTableList)){
|
|
|
|
|
|
ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId());
|
|
|
|
|
|
maatCfg.setMaatTable(serviceCfg.getMaatTable());
|
|
|
|
|
|
if(appCfg.getCompileId()==0){
|
|
|
|
|
|
throw new RuntimeException("转换出错,未获取到正确的compileId");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
maatCfg.setCompileId(appCfg.getCompileId());
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{//特征配置
|
|
|
|
|
|
for(AppFeaturesIndex featuresCfg:featuresTableList){
|
|
|
|
|
|
if(featuresCfg.getFeaturesTableType()==2){
|
|
|
|
|
|
List<AppStringCfg> list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
|
|
|
|
|
|
for(AppStringCfg cfg:list){
|
|
|
|
|
|
AppStringCfg strCfg = new AppStringCfg();
|
|
|
|
|
|
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
|
|
|
|
|
|
if(!StringUtil.isEmpty(cList)){
|
|
|
|
|
|
for(ServiceConfigInfo c:cList){
|
|
|
|
|
|
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
|
|
|
|
|
|
strCfg.setMaatTable(c.getMaatTable());
|
|
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
strCfg.setCompileId(featuresCfg.getFeaturesCompileId());
|
|
|
|
|
|
strList.add(strCfg);
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
if(featuresCfg.getFeaturesTableType()==4){
|
|
|
|
|
|
List<AppComplexKeywordCfg> list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId());
|
|
|
|
|
|
for(AppComplexKeywordCfg cfg:list){
|
|
|
|
|
|
AppComplexKeywordCfg complexCfg = new AppComplexKeywordCfg();
|
|
|
|
|
|
List<ServiceConfigInfo> cList = serviceConfigInfoDao.findList(appCfg.getServiceId());
|
|
|
|
|
|
if(!StringUtil.isEmpty(cList)){
|
|
|
|
|
|
for(ServiceConfigInfo c:cList){
|
|
|
|
|
|
if(c.getTableName().equals(featuresCfg.getFeaturesTable())){
|
|
|
|
|
|
complexCfg.setMaatTable(c.getMaatTable());
|
|
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
|
|
|
|
|
|
complexCfg.setCompileId(featuresCfg.getFeaturesCompileId());
|
|
|
|
|
|
complexList.add(complexCfg);
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
maatCfg.setStrCfg(strList);
|
|
|
|
|
|
maatCfg.setComplexStrCfg(complexList);
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
|
|
|
|
|
|
String json=gson.toJson(maatCfg);
|
|
|
|
|
|
//下发maat
|
|
|
|
|
|
// new ConvertTool().saveAppConfig(json);
|
|
|
|
|
|
sendFlag = true;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-08 17:19:43 +08:00
|
|
|
|
}else{
|
2018-04-03 11:12:49 +08:00
|
|
|
|
sendFlag = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-08 17:19:43 +08:00
|
|
|
|
if(sendFlag){
|
|
|
|
|
|
//修改appId配置审核下发状态
|
|
|
|
|
|
appCfgDao.audit(appCfg);
|
|
|
|
|
|
//修改特定服务IP分组下发状态
|
|
|
|
|
|
specificServiceCfgDao.updateConfigGroupInfobyGroupId(group);
|
|
|
|
|
|
//修改特征表配置审核下发状态
|
|
|
|
|
|
for(AppFeaturesIndex cfg:featuresTableList){
|
|
|
|
|
|
appCfgDao.auditFeaturesTable(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), appCfg.getIsValid(),
|
|
|
|
|
|
appCfg.getIsAudit(), appCfg.getAuditorId(), appCfg.getAuditTime());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return 0;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
return 1;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* deleteAppCfg(删除IP类配置)
|
|
|
|
|
|
* (继承AppIdCfg这个类方可使用)
|
|
|
|
|
|
* @param cfg
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*int
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
2018-04-08 17:19:43 +08:00
|
|
|
|
public int deleteAppCfg(String[] cfgIds){
|
|
|
|
|
|
for(String id : cfgIds){
|
|
|
|
|
|
AppIdCfg entity = appCfgDao.getById(Long.parseLong(id));
|
|
|
|
|
|
entity.setEditorId(entity.getCurrentUser().getId());
|
|
|
|
|
|
entity.setEditTime(new Date());
|
|
|
|
|
|
entity.setIsValid(Constants.VALID_DEL);
|
|
|
|
|
|
Integer status = appCfgDao.updateValid(entity);
|
|
|
|
|
|
if(status==1){
|
|
|
|
|
|
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId());
|
|
|
|
|
|
for(AppFeaturesIndex cfg:featuresTableList){
|
|
|
|
|
|
status = appCfgDao.updateFeaturesTableValid(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(),
|
|
|
|
|
|
entity.getIsValid(), entity.getEditorId(), entity.getEditTime());
|
|
|
|
|
|
if(status==0){
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
return 0;
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-08 17:19:43 +08:00
|
|
|
|
return 1;
|
2018-03-29 17:24:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* getAppCfg(根据IP与类名获取IP配置)
|
|
|
|
|
|
* (继承AppIdCfg这个类方可使用)
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*AppIdCfg
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public AppIdCfg getAppCfgById(long id){
|
|
|
|
|
|
return appCfgDao.getById(id);
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* getAppCfg(根据IP与类名获取IP配置)
|
|
|
|
|
|
* (继承AppIdCfg这个类方可使用)
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*AppIdCfg
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public AppIdCfg getAppCfgById(AppIdCfg cfg){
|
|
|
|
|
|
cfg = appCfgDao.get(cfg);
|
|
|
|
|
|
List<AppFeaturesIndex> featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(cfg.getCompileId());
|
2018-04-03 11:12:49 +08:00
|
|
|
|
List<AppComplexKeywordCfg> complexList = new ArrayList();
|
|
|
|
|
|
List<AppStringCfg> strList = new ArrayList();
|
2018-03-29 17:24:21 +08:00
|
|
|
|
if(!StringUtil.isEmpty(featuresTableList)){
|
|
|
|
|
|
for(AppFeaturesIndex features:featuresTableList){
|
|
|
|
|
|
if(features.getFeaturesTableType().equals(4)){//增强字符串特征配置
|
2018-04-03 11:12:49 +08:00
|
|
|
|
List<AppComplexKeywordCfg> complexFeaturesList = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(
|
2018-03-29 17:24:21 +08:00
|
|
|
|
features.getFeaturesTable(),features.getFeaturesCompileId());
|
|
|
|
|
|
complexList.addAll(complexFeaturesList);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if(features.getFeaturesTableType().equals(2)){//普通字符串特征配置
|
2018-04-03 11:12:49 +08:00
|
|
|
|
List<AppStringCfg> strFeaturesCfgList = appCfgDao.getStrFeaturesCfgListByCompileId(
|
2018-03-29 17:24:21 +08:00
|
|
|
|
features.getFeaturesTable(),features.getFeaturesCompileId());
|
|
|
|
|
|
strList.addAll(strFeaturesCfgList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
cfg.setComplexFeaturesList(complexList);
|
|
|
|
|
|
cfg.setStrFeaturesCfgList(strList);
|
|
|
|
|
|
return cfg;
|
|
|
|
|
|
}
|
|
|
|
|
|
public Integer getIsValid(Long cfgId){
|
|
|
|
|
|
return appCfgDao.getIsValid(cfgId);
|
|
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
public Integer getIsValid(String tableName, long id){
|
2018-03-29 17:24:21 +08:00
|
|
|
|
return appCfgDao.getIsValid(tableName,id);
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-03-29 17:24:21 +08:00
|
|
|
|
public Integer getIsAudit(Long cfgId){
|
|
|
|
|
|
return appCfgDao.getIsAudit(cfgId);
|
|
|
|
|
|
}
|
2018-04-03 11:12:49 +08:00
|
|
|
|
public Integer getIsAudit(String tableName, long id){
|
2018-03-29 17:24:21 +08:00
|
|
|
|
return appCfgDao.getIsAudit(tableName,id);
|
2018-04-03 11:12:49 +08:00
|
|
|
|
}
|
2018-01-09 16:50:39 +08:00
|
|
|
|
}
|