2018-01-09 16:50:39 +08:00
|
|
|
|
package com.nis.web.service.configuration;
|
|
|
|
|
|
|
2018-04-11 13:45:04 +08:00
|
|
|
|
import java.util.ArrayList;
|
2018-05-24 19:33:59 +08:00
|
|
|
|
import java.util.Date;
|
2018-04-08 16:15:06 +08:00
|
|
|
|
import java.util.List;
|
2018-05-29 18:51:56 +08:00
|
|
|
|
import java.util.Map;
|
2018-08-07 13:05:00 +08:00
|
|
|
|
import java.util.Properties;
|
2018-04-08 16:15:06 +08:00
|
|
|
|
|
2018-05-24 19:33:59 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2018-05-29 18:51:56 +08:00
|
|
|
|
import org.springframework.beans.BeanUtils;
|
2018-02-23 09:54:28 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2018-08-07 13:05:00 +08:00
|
|
|
|
import org.springframework.context.i18n.LocaleContextHolder;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
import org.springframework.stereotype.Service;
|
2018-02-25 18:43:20 +08:00
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
2018-01-09 16:50:39 +08:00
|
|
|
|
|
2018-07-03 14:55:36 +08:00
|
|
|
|
import com.nis.domain.FunctionRegionDict;
|
2018-08-25 01:55:10 +08:00
|
|
|
|
import com.nis.domain.Page;
|
2019-01-04 18:28:57 +06:00
|
|
|
|
import com.nis.domain.basics.AsnGroupInfo;
|
2018-06-05 17:28:45 +08:00
|
|
|
|
import com.nis.domain.callback.InlineIp;
|
2018-04-08 16:15:06 +08:00
|
|
|
|
import com.nis.domain.configuration.AreaIpCfg;
|
2019-01-06 11:24:49 +08:00
|
|
|
|
import com.nis.domain.configuration.AsnKeywordCfg;
|
2018-02-23 09:54:28 +08:00
|
|
|
|
import com.nis.domain.configuration.BaseIpCfg;
|
2019-01-06 11:24:49 +08:00
|
|
|
|
import com.nis.domain.configuration.BaseStringCfg;
|
2018-08-24 20:55:20 +08:00
|
|
|
|
import com.nis.domain.configuration.CfgIndexInfo;
|
2018-05-24 19:33:59 +08:00
|
|
|
|
import com.nis.domain.configuration.IpPortCfg;
|
2018-08-24 20:55:20 +08:00
|
|
|
|
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
2018-05-29 18:51:56 +08:00
|
|
|
|
import com.nis.domain.maat.MaatCfg;
|
|
|
|
|
|
import com.nis.domain.maat.MaatCfg.DigestCfg;
|
|
|
|
|
|
import com.nis.domain.maat.MaatCfg.GroupCfg;
|
|
|
|
|
|
import com.nis.domain.maat.MaatCfg.IpCfg;
|
|
|
|
|
|
import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
|
|
|
|
|
|
import com.nis.domain.maat.MaatCfg.StringCfg;
|
2018-06-07 13:27:57 +08:00
|
|
|
|
import com.nis.domain.maat.ToMaatBean;
|
|
|
|
|
|
import com.nis.domain.maat.ToMaatResult;
|
2018-05-24 19:33:59 +08:00
|
|
|
|
import com.nis.exceptions.MaatConvertException;
|
|
|
|
|
|
import com.nis.util.ConfigServiceUtil;
|
2018-08-07 13:05:00 +08:00
|
|
|
|
import com.nis.util.Configurations;
|
2018-03-26 14:43:58 +08:00
|
|
|
|
import com.nis.util.Constants;
|
2018-07-02 16:04:41 +08:00
|
|
|
|
import com.nis.util.DictUtils;
|
2018-05-24 19:33:59 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
2019-01-04 18:28:57 +06:00
|
|
|
|
import com.nis.web.dao.basics.AsnGroupInfoDao;
|
2018-09-29 21:46:17 +08:00
|
|
|
|
import com.nis.web.dao.basics.AsnIpCfgDao;
|
2018-04-08 16:15:06 +08:00
|
|
|
|
import com.nis.web.dao.configuration.AreaIpCfgDao;
|
2018-02-23 09:54:28 +08:00
|
|
|
|
import com.nis.web.dao.configuration.IpCfgDao;
|
2018-08-24 20:55:20 +08:00
|
|
|
|
import com.nis.web.dao.configuration.StringCfgDao;
|
2018-11-11 19:36:53 +08:00
|
|
|
|
import com.nis.web.dao.specific.ConfigGroupInfoDao;
|
2018-08-24 20:55:20 +08:00
|
|
|
|
import com.nis.web.security.UserUtils;
|
2018-02-23 09:54:28 +08:00
|
|
|
|
import com.nis.web.service.CrudService;
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* IP相关配置事务类
|
|
|
|
|
|
* @author dell
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Service
|
2018-02-23 09:54:28 +08:00
|
|
|
|
public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
protected IpCfgDao ipCfgDao;
|
2018-04-08 16:15:06 +08:00
|
|
|
|
@Autowired
|
2018-08-24 20:55:20 +08:00
|
|
|
|
protected StringCfgDao stringCfgDao;
|
|
|
|
|
|
@Autowired
|
2018-04-08 16:15:06 +08:00
|
|
|
|
protected AreaIpCfgDao areaIpCfgDao;
|
2018-09-29 21:46:17 +08:00
|
|
|
|
@Autowired
|
2018-11-11 19:36:53 +08:00
|
|
|
|
//protected SpecificServiceCfgDao specificServiceCfgDao;
|
2019-01-04 18:28:57 +06:00
|
|
|
|
protected AsnGroupInfoDao asnGroupInfoDao;
|
|
|
|
|
|
@Autowired
|
2018-11-11 19:36:53 +08:00
|
|
|
|
protected ConfigGroupInfoDao configGroupInfoDao;
|
2018-09-29 21:46:17 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AsnIpCfgDao asnIpCfgDao;
|
2018-02-23 09:54:28 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* addIpCfg(新增IP类配置)
|
|
|
|
|
|
* (继承BaseIpCfg这个类方可使用)
|
|
|
|
|
|
* @param baseIpCfg
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*int
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
2018-03-05 16:30:16 +08:00
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
2018-06-02 17:40:14 +08:00
|
|
|
|
public void addIpCfg(BaseIpCfg cfg){
|
2018-05-24 19:33:59 +08:00
|
|
|
|
//调用服务接口获取compileId
|
|
|
|
|
|
Integer compileId = 0;
|
|
|
|
|
|
try {
|
|
|
|
|
|
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
|
|
|
|
|
if(!StringUtil.isEmpty(compileIds)){
|
|
|
|
|
|
compileId = compileIds.get(0);
|
|
|
|
|
|
}
|
2018-08-22 15:07:13 +08:00
|
|
|
|
} catch (MaatConvertException e) {
|
2018-05-24 19:33:59 +08:00
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("获取编译ID出错");
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
if(compileId!=0){
|
2018-06-02 17:40:14 +08:00
|
|
|
|
cfg.setCompileId(compileId);
|
2018-06-04 14:42:52 +08:00
|
|
|
|
setAreaEffectiveIds(cfg);
|
|
|
|
|
|
if(cfg.getAreaCfg()!=null&&cfg.getAreaCfg().size()>0){
|
|
|
|
|
|
for(AreaIpCfg c:cfg.getAreaCfg()){
|
|
|
|
|
|
c.initDefaultValue();
|
|
|
|
|
|
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
|
|
|
|
|
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
|
|
|
|
|
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
|
|
|
|
|
c.setTableName(AreaIpCfg.getTablename());
|
2018-06-02 17:40:14 +08:00
|
|
|
|
}
|
2018-06-04 14:42:52 +08:00
|
|
|
|
this.saveIpBatch(cfg.getAreaCfg());
|
2018-06-02 17:40:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
ipCfgDao.insert(cfg);
|
2018-05-24 19:33:59 +08:00
|
|
|
|
}else{
|
2018-08-22 15:07:13 +08:00
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>: compileId is 0");
|
2018-05-24 19:33:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-23 09:54:28 +08:00
|
|
|
|
}
|
2018-08-24 20:55:20 +08:00
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
|
|
|
|
|
public void saveIpCfg(CfgIndexInfo entity){
|
|
|
|
|
|
//设置区域运营商信息
|
|
|
|
|
|
setAreaEffectiveIds(entity);
|
|
|
|
|
|
|
|
|
|
|
|
entity.setIsValid(0);
|
|
|
|
|
|
entity.setIsAudit(0);
|
|
|
|
|
|
|
|
|
|
|
|
if(entity.getCfgId()==null){
|
|
|
|
|
|
Integer compileId = 0;
|
|
|
|
|
|
try {
|
|
|
|
|
|
List<Integer> idList = ConfigServiceUtil.getId(1, 1);
|
|
|
|
|
|
if(idList!=null && idList.size()>0){
|
|
|
|
|
|
compileId = idList.get(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (MaatConvertException e) {
|
|
|
|
|
|
logger.info("获取编译ID出错");
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
|
|
|
|
|
}
|
|
|
|
|
|
entity.setCompileId(compileId);
|
|
|
|
|
|
entity.setCreateTime(new Date());
|
|
|
|
|
|
entity.setCreatorId(entity.getCurrentUser().getId());
|
2019-01-16 14:33:29 +06:00
|
|
|
|
//保存asn组织信息 字符串域信息
|
|
|
|
|
|
handleAsn(entity.getAsnKeywords(), entity);
|
2018-08-24 20:55:20 +08:00
|
|
|
|
ipCfgDao.saveCfgIndex(entity);
|
|
|
|
|
|
if(entity.getIpPortList()!=null){
|
|
|
|
|
|
for(IpPortCfg cfg:entity.getIpPortList()){
|
2018-10-15 19:17:55 +08:00
|
|
|
|
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
|
2018-08-24 20:55:20 +08:00
|
|
|
|
ipCfgDao.saveIpPortCfg(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(entity.getNtcSubscribeIdCfgList()!=null){
|
|
|
|
|
|
for(NtcSubscribeIdCfg cfg:entity.getNtcSubscribeIdCfgList()){
|
|
|
|
|
|
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
|
|
|
|
|
|
stringCfgDao.saveSubscribeIdCfg(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//保存区域IP信息
|
|
|
|
|
|
if(entity.getAreaCfg()!=null){
|
|
|
|
|
|
for(AreaIpCfg cfg:entity.getAreaCfg()){
|
|
|
|
|
|
cfg.initDefaultValue();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
|
|
|
|
|
|
areaIpCfgDao.saveAreaIpCfg(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-01-16 14:33:29 +06:00
|
|
|
|
|
2018-08-24 20:55:20 +08:00
|
|
|
|
}else{
|
2018-08-25 11:55:40 +08:00
|
|
|
|
entity.setEditTime(new Date());
|
|
|
|
|
|
entity.setEditorId(entity.getCurrentUser().getId());
|
2019-01-16 14:33:29 +06:00
|
|
|
|
//保存asn组织信息 字符串域信息
|
|
|
|
|
|
handleAsn(entity.getAsnKeywords(), entity);
|
2018-08-24 20:55:20 +08:00
|
|
|
|
ipCfgDao.updateCfgIndex(entity);
|
2019-01-16 14:33:29 +06:00
|
|
|
|
entity.setCreateTime(new Date());
|
|
|
|
|
|
entity.setCreatorId(entity.getCurrentUser().getId());
|
2018-08-24 20:55:20 +08:00
|
|
|
|
//无效子配置后,再新增子配置
|
|
|
|
|
|
ipCfgDao.deleteIpCfg(entity);
|
|
|
|
|
|
stringCfgDao.deleteSubscribeIdCfgByCfgIndexInfo(entity);
|
|
|
|
|
|
AreaIpCfg area = new AreaIpCfg();
|
|
|
|
|
|
area.setCompileId(entity.getCompileId());
|
|
|
|
|
|
area.setFunctionId(entity.getFunctionId());
|
|
|
|
|
|
areaIpCfgDao.deleteAreaIpCfg(area);
|
|
|
|
|
|
if(entity.getIpPortList()!=null){
|
|
|
|
|
|
for(IpPortCfg cfg:entity.getIpPortList()){
|
2018-10-15 19:17:55 +08:00
|
|
|
|
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
|
2018-08-24 20:55:20 +08:00
|
|
|
|
ipCfgDao.saveIpPortCfg(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(entity.getNtcSubscribeIdCfgList()!=null){
|
|
|
|
|
|
for(NtcSubscribeIdCfg cfg:entity.getNtcSubscribeIdCfgList()){
|
|
|
|
|
|
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
|
|
|
|
|
|
stringCfgDao.saveSubscribeIdCfg(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//保存区域IP信息
|
|
|
|
|
|
if(entity.getAreaCfg()!=null){
|
|
|
|
|
|
for(AreaIpCfg cfg:entity.getAreaCfg()){
|
|
|
|
|
|
cfg.initDefaultValue();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"});
|
|
|
|
|
|
areaIpCfgDao.saveAreaIpCfg(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-01-16 14:33:29 +06:00
|
|
|
|
handleAsn(entity.getAsnKeywords(), entity);
|
2019-01-06 11:24:49 +08:00
|
|
|
|
//保存asn组织信息 字符串域信息
|
2019-01-16 14:33:29 +06:00
|
|
|
|
/*if(StringUtils.isNotBlank(entity.getUserRegion4())){
|
2019-01-06 11:24:49 +08:00
|
|
|
|
List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
|
|
|
|
|
|
FunctionRegionDict regionDict=null;
|
|
|
|
|
|
for(FunctionRegionDict dict:functionRegionDicts) {
|
|
|
|
|
|
if("asn".equals(dict.getConfigServiceType())) {
|
|
|
|
|
|
regionDict=dict;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(regionDict!=null) {
|
|
|
|
|
|
//先删除asn keyword
|
|
|
|
|
|
String org=entity.getUserRegion4();
|
|
|
|
|
|
stringCfgDao.deleteAsnKeyword(entity);
|
|
|
|
|
|
List<AsnGroupInfo> asnGroupInfos=asnGroupInfoDao.getValidConfigGroupInfoByName(org);
|
|
|
|
|
|
for(AsnGroupInfo info:asnGroupInfos) {
|
|
|
|
|
|
BaseStringCfg<AsnKeywordCfg> asnKeywordCfg=new AsnKeywordCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, asnKeywordCfg,new String[]{"cfgId","cfgDesc","cfgRegionCode","cfgType","userRegion1","userRegion2","userRegion3"});
|
|
|
|
|
|
asnKeywordCfg.setTableName(AsnKeywordCfg.getTablename());
|
|
|
|
|
|
asnKeywordCfg.setCfgKeywords("AS"+info.getAsnId());
|
|
|
|
|
|
asnKeywordCfg.setExprType(0);
|
|
|
|
|
|
asnKeywordCfg.setMatchMethod(3);
|
|
|
|
|
|
asnKeywordCfg.setExType("0");
|
|
|
|
|
|
asnKeywordCfg.setIsHexbin(0);
|
|
|
|
|
|
asnKeywordCfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
|
|
|
|
|
asnKeywordCfg.setCfgType(regionDict.getConfigRegionValue());
|
|
|
|
|
|
asnKeywordCfg.setCreateTime(entity.getCreateTime());
|
|
|
|
|
|
asnKeywordCfg.setCreatorId(UserUtils.getUser().getId());
|
|
|
|
|
|
asnKeywordCfg.setFunctionId(regionDict.getFunctionId());
|
|
|
|
|
|
asnKeywordCfg.setEditorId(entity.getEditorId());
|
|
|
|
|
|
asnKeywordCfg.setEditTime(entity.getEditTime());
|
|
|
|
|
|
asnKeywordCfg.setCompileId(entity.getCompileId());
|
|
|
|
|
|
stringCfgDao.saveStringCfgBatch(asnKeywordCfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-16 14:33:29 +06:00
|
|
|
|
}*/
|
2018-08-24 20:55:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void updateIpCfgValid(Integer isValid,String ids,Integer functionId){
|
|
|
|
|
|
String[] idArray = ids.split(",");
|
|
|
|
|
|
for(String id :idArray){
|
2018-08-31 16:08:17 +08:00
|
|
|
|
CfgIndexInfo entity = new CfgIndexInfo();
|
2018-08-24 20:55:20 +08:00
|
|
|
|
entity.setCfgId(Long.parseLong(id));
|
|
|
|
|
|
entity.setIsValid(isValid);
|
|
|
|
|
|
entity.setEditorId(UserUtils.getUser().getId());
|
|
|
|
|
|
entity.setEditTime(new Date());
|
|
|
|
|
|
entity.setTableName(CfgIndexInfo.getTablename());
|
|
|
|
|
|
entity.setFunctionId(functionId);
|
|
|
|
|
|
ipCfgDao.updateCfgValid(entity);
|
|
|
|
|
|
//查询子配置
|
2018-11-28 19:23:38 +08:00
|
|
|
|
entity = this.getIpPortCfg(Long.parseLong(id),entity.getCompileId());
|
2018-08-24 20:55:20 +08:00
|
|
|
|
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
|
|
|
|
|
|
IpPortCfg cfg = new IpPortCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
|
|
|
|
|
cfg.setTableName(IpPortCfg.getTablename());
|
|
|
|
|
|
ipCfgDao.updateCfgValid(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(entity.getNtcSubscribeIdCfgList()!=null && entity.getNtcSubscribeIdCfgList().size()>0)
|
|
|
|
|
|
{
|
|
|
|
|
|
NtcSubscribeIdCfg cfg = new NtcSubscribeIdCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
|
|
|
|
|
cfg.setTableName(NtcSubscribeIdCfg.getTablename());
|
|
|
|
|
|
ipCfgDao.updateCfgValid(cfg);
|
|
|
|
|
|
}
|
2019-01-06 11:24:49 +08:00
|
|
|
|
if(entity.getAsnKeywords()!=null && entity.getAsnKeywords().size()>0)
|
|
|
|
|
|
{
|
|
|
|
|
|
AsnKeywordCfg cfg = new AsnKeywordCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
|
|
|
|
|
cfg.setTableName(AsnKeywordCfg.getTablename());
|
|
|
|
|
|
ipCfgDao.updateCfgValid(cfg);
|
|
|
|
|
|
}
|
2018-08-24 20:55:20 +08:00
|
|
|
|
//保存区域IP信息
|
|
|
|
|
|
if(entity.getAreaCfg()!=null && entity.getAreaCfg().size()>0){
|
|
|
|
|
|
AreaIpCfg cfg = new AreaIpCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
|
|
|
|
|
cfg.setTableName(AreaIpCfg.getTablename());
|
|
|
|
|
|
ipCfgDao.updateCfgValid(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-02-23 09:54:28 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* updateIpCfg(更新IP类配置)
|
|
|
|
|
|
* (继承BaseIpCfg这个类方可使用)
|
|
|
|
|
|
* @param baseIpCfg
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*int
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
2018-03-05 16:30:16 +08:00
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
2018-06-02 17:40:14 +08:00
|
|
|
|
public void updateIpCfg(BaseIpCfg cfg){
|
|
|
|
|
|
AreaIpCfg area=new AreaIpCfg();
|
|
|
|
|
|
area.setCompileId(cfg.getCompileId());
|
|
|
|
|
|
area.setFunctionId(cfg.getFunctionId());
|
|
|
|
|
|
areaIpCfgDao.deleteAreaIpCfg(area);
|
|
|
|
|
|
//区域IPsetAreaEffectiveIds设置
|
2018-06-04 14:42:52 +08:00
|
|
|
|
setAreaEffectiveIds(cfg);
|
|
|
|
|
|
Date date=new Date();
|
|
|
|
|
|
if(cfg.getAreaCfg()!=null&&cfg.getAreaCfg().size()>0){
|
|
|
|
|
|
for(AreaIpCfg c:cfg.getAreaCfg()){
|
|
|
|
|
|
c.initDefaultValue();
|
|
|
|
|
|
BeanUtils.copyProperties(cfg, c,new String[]{"cfgId","ipType","direction",
|
|
|
|
|
|
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
|
|
|
|
|
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
|
|
|
|
|
c.setTableName(AreaIpCfg.getTablename());
|
|
|
|
|
|
c.setCreatorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
c.setCreateTime(date);
|
|
|
|
|
|
}
|
|
|
|
|
|
this.saveIpBatch(cfg.getAreaCfg());
|
|
|
|
|
|
}
|
|
|
|
|
|
ipCfgDao.update(cfg);
|
2018-11-19 16:36:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
@Deprecated
|
2018-06-04 14:42:52 +08:00
|
|
|
|
public void audit(BaseIpCfg cfg) throws Exception{
|
|
|
|
|
|
//更新IP配置与区域IP的状态
|
|
|
|
|
|
List<BaseIpCfg> beans=new ArrayList<>();
|
|
|
|
|
|
beans.add(cfg);
|
2018-07-03 15:54:14 +08:00
|
|
|
|
ipCfgDao.audit(cfg);
|
2018-06-04 14:42:52 +08:00
|
|
|
|
List<BaseIpCfg> beans1=new ArrayList<>();
|
|
|
|
|
|
List<AreaIpCfg> areaIpCfgList=areaIpCfgDao.getByCompileId(cfg.getCompileId());
|
|
|
|
|
|
for(AreaIpCfg area:areaIpCfgList){
|
|
|
|
|
|
BeanUtils.copyProperties(cfg,area ,new String[]{"cfgRegionCode"
|
|
|
|
|
|
,"cfgType"
|
|
|
|
|
|
,"cfgId"
|
|
|
|
|
|
,"ipType"
|
|
|
|
|
|
,"ipPattern"
|
|
|
|
|
|
,"srcIpAddress"
|
|
|
|
|
|
,"portPattern"
|
|
|
|
|
|
,"srcPort"
|
|
|
|
|
|
,"destPort"
|
|
|
|
|
|
,"protocol"
|
|
|
|
|
|
,"direction"
|
|
|
|
|
|
,"protocolId"
|
|
|
|
|
|
});
|
|
|
|
|
|
beans1.add(area);
|
|
|
|
|
|
}
|
|
|
|
|
|
this.auditIpBatch(beans1);
|
|
|
|
|
|
List<MaatCfg> configCompileList = new ArrayList<>();
|
|
|
|
|
|
List<GroupCfg> groupRelationList = new ArrayList<>();
|
|
|
|
|
|
List<IpCfg> ipRegionList = new ArrayList<>();
|
|
|
|
|
|
List<StringCfg> strRegionList = new ArrayList<>();
|
|
|
|
|
|
List<NumBoundaryCfg> numRegionList = new ArrayList<>();
|
|
|
|
|
|
List<DigestCfg> digestRegionList = new ArrayList<>();
|
|
|
|
|
|
List<IpCfg> areaIpRegionList = new ArrayList<>();
|
|
|
|
|
|
ToMaatBean maatBean = new ToMaatBean();
|
|
|
|
|
|
MaatCfg maatCfg = new MaatCfg();
|
|
|
|
|
|
maatCfg.initDefaultValue();
|
|
|
|
|
|
BeanUtils.copyProperties(cfg, maatCfg);
|
|
|
|
|
|
String json="";
|
2018-07-03 14:55:36 +08:00
|
|
|
|
//获取region
|
|
|
|
|
|
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
|
|
|
|
|
|
int maatType=0;
|
|
|
|
|
|
//判断下发类型是走maat还是callback
|
2018-08-07 13:05:00 +08:00
|
|
|
|
String regionValue=cfg.getCfgType();
|
|
|
|
|
|
if(regionValue!=null) {
|
|
|
|
|
|
for(FunctionRegionDict region:dictList) {
|
|
|
|
|
|
if(regionValue.equals(region.getConfigRegionValue())) {
|
|
|
|
|
|
maatType=region.getIsMaat();
|
|
|
|
|
|
break;
|
2018-07-03 15:54:14 +08:00
|
|
|
|
}
|
2018-07-03 14:55:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-08-07 13:05:00 +08:00
|
|
|
|
Properties props=this.getMsgProp();
|
2018-07-03 14:55:36 +08:00
|
|
|
|
if(cfg.getIsAudit()==Constants.AUDIT_YES){
|
|
|
|
|
|
if(maatType==Constants.CALLBACK_TYPE){
|
2018-06-05 17:28:45 +08:00
|
|
|
|
List<InlineIp> ipList=new ArrayList<>();
|
2018-06-22 15:59:47 +08:00
|
|
|
|
InlineIp ip=convertCallBackIp(cfg,null);
|
2018-06-05 17:28:45 +08:00
|
|
|
|
ipList.add(ip);
|
2018-06-04 14:42:52 +08:00
|
|
|
|
//调用服务接口下发配置数据
|
2018-06-05 17:28:45 +08:00
|
|
|
|
json=gsonToJson(ipList);
|
2018-06-25 11:10:55 +08:00
|
|
|
|
logger.info("IP配置下发配置参数:"+json);
|
2018-06-04 14:42:52 +08:00
|
|
|
|
//调用服务接口下发配置
|
|
|
|
|
|
try {
|
|
|
|
|
|
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
|
|
|
|
|
if(result!=null){
|
2018-06-25 11:10:55 +08:00
|
|
|
|
logger.info("IP配置配置下发响应信息:"+result.getMsg());
|
2018-06-04 14:42:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
2018-06-25 11:10:55 +08:00
|
|
|
|
logger.error("IP配置配置下发失败",e);
|
2018-06-04 14:42:52 +08:00
|
|
|
|
throw e;
|
|
|
|
|
|
}
|
2018-07-03 14:55:36 +08:00
|
|
|
|
}else if(maatType==Constants.MAAT_TYPE){
|
2018-06-04 14:42:52 +08:00
|
|
|
|
Map<String,List> map = cfgConvert(ipRegionList,beans,1,cfg,groupRelationList);
|
|
|
|
|
|
ipRegionList=map.get("dstList");
|
|
|
|
|
|
groupRelationList=map.get("groupList");
|
2018-06-06 11:00:33 +08:00
|
|
|
|
numRegionList=map.get("numRegionList")==null?new ArrayList<>():map.get("numRegionList");
|
2018-06-04 14:42:52 +08:00
|
|
|
|
Map<String,List> areaMap = cfgConvert(areaIpRegionList,beans1,1,cfg,groupRelationList);
|
|
|
|
|
|
groupRelationList=areaMap.get("groupList");
|
|
|
|
|
|
areaIpRegionList=areaMap.get("dstList");
|
2018-10-06 12:16:12 +08:00
|
|
|
|
//maatCfg.setAreaEffectiveIds(StringUtils.isBlank(cfg.getAreaEffectiveIds())?"0":cfg.getAreaEffectiveIds());
|
2018-06-04 14:42:52 +08:00
|
|
|
|
maatCfg.setAction(cfg.getAction());
|
|
|
|
|
|
maatCfg.setAuditTime(cfg.getAuditTime());
|
|
|
|
|
|
maatCfg.setIpRegionList(ipRegionList);
|
|
|
|
|
|
maatCfg.setStrRegionList(strRegionList);
|
|
|
|
|
|
maatCfg.setNumRegionList(numRegionList);
|
|
|
|
|
|
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
|
|
|
|
|
maatCfg.setDigestRegionList(digestRegionList);
|
|
|
|
|
|
maatCfg.setGroupRelationList(groupRelationList);
|
|
|
|
|
|
maatCfg.setGroupNum(groupRelationList.size());
|
|
|
|
|
|
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
2018-06-28 16:29:28 +08:00
|
|
|
|
if(Constants.SERVICE_IP_MULITIPLEX==cfg.getServiceId().intValue()){
|
2018-06-28 17:19:06 +08:00
|
|
|
|
String region=Constants.USERREGION_IR_STRATEGY+"="+cfg.getDnsStrategyId()+Constants.USER_REGION_SPLIT
|
|
|
|
|
|
+Constants.USERREGION_IR_TYPE+"="+cfg.getIrType();
|
|
|
|
|
|
maatCfg.setUserRegion(region);
|
2018-06-28 16:29:28 +08:00
|
|
|
|
}else if(Constants.SERVICE_IP_RATELIMIT==cfg.getServiceId().intValue()){
|
|
|
|
|
|
maatCfg.setUserRegion(Constants.USERREGION_RATE_LIMIT+"="+cfg.getRatelimit());
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
//限速需要发Droprate=0.001 ,暂不支持Bandwidth=200kbps
|
|
|
|
|
|
if(cfg.getAction().equals(Constants.RATELIMIT_ACTION)){
|
|
|
|
|
|
if(cfg.getUserRegion1().equals("0")){//丢包率
|
|
|
|
|
|
cfg.setUserRegion2(StringUtil.isEmpty(cfg.getUserRegion2()) ? "":cfg.getUserRegion2());
|
|
|
|
|
|
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+cfg.getUserRegion2());
|
|
|
|
|
|
}else if(cfg.getUserRegion1().equals("1")){//带宽
|
|
|
|
|
|
cfg.setUserRegion3(StringUtil.isEmpty(cfg.getUserRegion3()) ? "":cfg.getUserRegion3());
|
|
|
|
|
|
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY+"="+cfg.getUserRegion3());
|
|
|
|
|
|
}
|
|
|
|
|
|
}else {
|
|
|
|
|
|
if(!StringUtil.isEmpty(cfg.getUserRegion1())){
|
|
|
|
|
|
String userRegion = "";
|
|
|
|
|
|
if(cfg.getUserRegion1().startsWith(Constants.REDIRECT_RESPONSE_CODE_STARTWITH)){
|
|
|
|
|
|
userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+cfg.getUserRegion1()+
|
|
|
|
|
|
Constants.USER_REGION_SPLIT+
|
|
|
|
|
|
Constants.REDIRECT_URL_KEY+"="+cfg.getUserRegion2();
|
|
|
|
|
|
}else{
|
|
|
|
|
|
userRegion = Constants.REDIRECT_RESPONSE_CODE_KEY+"="+cfg.getUserRegion1()+
|
2018-07-06 14:57:05 +08:00
|
|
|
|
Constants.USER_REGION_SPLIT+
|
2018-09-29 21:46:17 +08:00
|
|
|
|
Constants.REDIRECT_CONTENT_KEY+"="+cfg.getUserRegion2();
|
|
|
|
|
|
}
|
|
|
|
|
|
maatCfg.setUserRegion(userRegion);
|
2018-07-06 14:57:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-04 14:42:52 +08:00
|
|
|
|
configCompileList.add(maatCfg);
|
|
|
|
|
|
maatBean.setOpAction(Constants.INSERT_ACTION);
|
|
|
|
|
|
maatBean.setConfigCompileList(configCompileList);
|
|
|
|
|
|
maatBean.setAuditTime(cfg.getAuditTime());
|
|
|
|
|
|
maatBean.setCreatorName(cfg.getCurrentUser().getName());
|
|
|
|
|
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
|
|
|
|
|
//调用服务接口下发配置数据
|
|
|
|
|
|
json=gsonToJson(maatBean);
|
2018-06-25 11:10:55 +08:00
|
|
|
|
logger.info("IP配置下发配置参数:"+json);
|
2018-06-04 14:42:52 +08:00
|
|
|
|
//调用服务接口下发配置
|
|
|
|
|
|
try {
|
|
|
|
|
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
|
|
|
|
|
if(result!=null){
|
2018-06-25 11:10:55 +08:00
|
|
|
|
logger.info("IP配置配置下发响应信息:"+result.getMsg());
|
2018-06-02 17:40:14 +08:00
|
|
|
|
}
|
2018-06-04 14:42:52 +08:00
|
|
|
|
} catch (Exception e) {
|
2018-06-25 11:10:55 +08:00
|
|
|
|
logger.error("IP配置配置下发失败",e);
|
2018-06-04 14:42:52 +08:00
|
|
|
|
throw e;
|
2018-06-02 17:40:14 +08:00
|
|
|
|
}
|
2018-08-07 13:05:00 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+props.getProperty("unknown_cfg_type"));
|
2018-06-02 17:40:14 +08:00
|
|
|
|
}
|
2018-07-09 10:57:00 +08:00
|
|
|
|
}else if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){
|
|
|
|
|
|
if(maatType==Constants.CALLBACK_TYPE){
|
2018-06-05 17:28:45 +08:00
|
|
|
|
List<InlineIp> ipList=new ArrayList<>();
|
2018-06-22 15:59:47 +08:00
|
|
|
|
InlineIp ip=convertCallBackIp(cfg,null);
|
2018-06-05 17:28:45 +08:00
|
|
|
|
ipList.add(ip);
|
2018-06-04 14:42:52 +08:00
|
|
|
|
//调用服务接口取消配置
|
2018-06-05 17:28:45 +08:00
|
|
|
|
json=gsonToJson(ipList);
|
2018-06-04 14:42:52 +08:00
|
|
|
|
logger.info("IP管控配置参数:"+json);
|
|
|
|
|
|
//调用服务接口取消配置
|
|
|
|
|
|
try {
|
|
|
|
|
|
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
2018-06-25 11:10:55 +08:00
|
|
|
|
logger.info("IP配置取消配置响应信息:"+result.getMsg());
|
2018-06-04 14:42:52 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
2018-06-25 11:10:55 +08:00
|
|
|
|
logger.info("IP配置取消配置失败");
|
2018-06-04 14:42:52 +08:00
|
|
|
|
throw e;
|
|
|
|
|
|
}
|
2018-07-09 10:57:00 +08:00
|
|
|
|
}else if(maatType==Constants.MAAT_TYPE){
|
2018-06-04 14:42:52 +08:00
|
|
|
|
maatCfg.setCompileId(cfg.getCompileId());
|
|
|
|
|
|
maatCfg.setServiceId(cfg.getServiceId());
|
|
|
|
|
|
maatCfg.setIsValid(0);//无效
|
|
|
|
|
|
configCompileList.add(maatCfg);
|
|
|
|
|
|
maatBean.setConfigCompileList(configCompileList);
|
|
|
|
|
|
maatBean.setAuditTime(cfg.getAuditTime());
|
|
|
|
|
|
maatBean.setCreatorName(cfg.getCurrentUser().getName());
|
|
|
|
|
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
|
|
|
|
|
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
|
|
|
|
|
//调用服务接口取消配置
|
|
|
|
|
|
json=gsonToJson(maatBean);
|
|
|
|
|
|
logger.info("IP管控配置参数:"+json);
|
|
|
|
|
|
//调用服务接口取消配置
|
|
|
|
|
|
try {
|
|
|
|
|
|
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
|
|
|
|
|
logger.info("IP管控取消配置响应信息:"+result.getMsg());
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("IP管控取消配置失败");
|
|
|
|
|
|
throw e;
|
2018-06-02 17:40:14 +08:00
|
|
|
|
}
|
2018-08-07 13:05:00 +08:00
|
|
|
|
}else {
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+props.getProperty("unknown_cfg_type"));
|
2018-06-02 17:40:14 +08:00
|
|
|
|
}
|
2018-04-08 16:15:06 +08:00
|
|
|
|
}
|
2018-06-04 14:42:52 +08:00
|
|
|
|
}
|
2018-08-24 20:55:20 +08:00
|
|
|
|
public void auditIpCfg(CfgIndexInfo entity,Integer isAudit) throws MaatConvertException{
|
2018-08-25 11:42:24 +08:00
|
|
|
|
Properties props=this.getMsgProp();
|
2018-08-24 20:55:20 +08:00
|
|
|
|
//修改数据库审核状态信息
|
|
|
|
|
|
entity.setTableName(CfgIndexInfo.getTablename());
|
2018-10-29 18:19:56 +08:00
|
|
|
|
entity.setIsAudit(isAudit);
|
2018-08-24 20:55:20 +08:00
|
|
|
|
ipCfgDao.auditCfg(entity);
|
|
|
|
|
|
ToMaatBean maatBean = new ToMaatBean();
|
|
|
|
|
|
MaatCfg maatCfg = new MaatCfg();
|
|
|
|
|
|
List<MaatCfg> configCompileList = new ArrayList();
|
|
|
|
|
|
List<GroupCfg> groupRelationList = new ArrayList();
|
|
|
|
|
|
List<IpCfg> ipRegionList = new ArrayList();
|
|
|
|
|
|
List<StringCfg> strRegionList = new ArrayList();
|
|
|
|
|
|
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
|
|
|
|
|
List<DigestCfg> digestRegionList = new ArrayList();
|
|
|
|
|
|
List<IpCfg> areaIpRegionList = new ArrayList();
|
2018-08-25 11:42:24 +08:00
|
|
|
|
//获取region
|
|
|
|
|
|
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
|
|
|
|
|
|
int maatType=0;
|
2018-08-24 20:55:20 +08:00
|
|
|
|
//查询子配置并修改审核状态
|
2018-11-28 19:23:38 +08:00
|
|
|
|
entity = this.getIpPortCfg(entity.getCfgId(),entity.getCompileId());
|
2018-08-24 20:55:20 +08:00
|
|
|
|
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
|
2018-08-25 11:42:24 +08:00
|
|
|
|
//判断下发类型是走maat还是callback
|
|
|
|
|
|
String regionValue=entity.getIpPortList().get(0).getCfgType();
|
|
|
|
|
|
if(regionValue!=null) {
|
|
|
|
|
|
for(FunctionRegionDict region:dictList) {
|
|
|
|
|
|
if(regionValue.equals(region.getConfigRegionValue())) {
|
|
|
|
|
|
maatType=region.getIsMaat();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-10-15 15:26:43 +08:00
|
|
|
|
for(IpPortCfg cfg:entity.getIpPortList()) {
|
2018-10-30 11:29:37 +08:00
|
|
|
|
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId","cfgType","userRegion1","userRegion2","userRegion3","userRegion4","userRegion5"});
|
2018-10-29 18:19:56 +08:00
|
|
|
|
cfg.setTableName(IpPortCfg.getTablename());
|
|
|
|
|
|
ipCfgDao.auditCfg(cfg);
|
|
|
|
|
|
/*BeanUtils.copyProperties(entity, cfg, new String[]{"userRegion1","userRegion2","userRegion3","userRegion4","userRegion5","ipType","direction",
|
2018-10-15 16:18:36 +08:00
|
|
|
|
"protocol","protocolId","areaEffectiveIds","cfgRegionCode",
|
|
|
|
|
|
"cfgType","ipPattern","srcIpAddress","portPattern","srcPort","destIpAddress","destPort"});
|
2018-10-15 15:26:43 +08:00
|
|
|
|
cfg.setTableName(IpPortCfg.getTablename());
|
2018-10-29 18:19:56 +08:00
|
|
|
|
ipCfgDao.auditCfg(cfg);*/
|
2018-10-15 15:26:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(isAudit==1&&maatType==Constants.MAAT_TYPE){
|
2018-08-24 20:55:20 +08:00
|
|
|
|
Map<String,List> map = cfgConvert(ipRegionList,entity.getIpPortList(),1,entity,groupRelationList);
|
|
|
|
|
|
groupRelationList=map.get("groupList");
|
|
|
|
|
|
ipRegionList=map.get("dstList");
|
|
|
|
|
|
if(map.get("numRegionList")!=null){
|
|
|
|
|
|
numRegionList.addAll(map.get("numRegionList"));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-01-16 14:33:29 +06:00
|
|
|
|
}else{
|
|
|
|
|
|
maatType=1;
|
2018-08-24 20:55:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(entity.getNtcSubscribeIdCfgList()!=null && entity.getNtcSubscribeIdCfgList().size()>0){
|
|
|
|
|
|
NtcSubscribeIdCfg cfg = new NtcSubscribeIdCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
|
|
|
|
|
cfg.setTableName(NtcSubscribeIdCfg.getTablename());
|
|
|
|
|
|
ipCfgDao.auditCfg(cfg);
|
2018-10-15 15:26:43 +08:00
|
|
|
|
if(isAudit==1&&maatType==Constants.MAAT_TYPE){
|
2018-08-24 20:55:20 +08:00
|
|
|
|
Map<String,List> map = cfgConvert(strRegionList,entity.getNtcSubscribeIdCfgList(),2,entity,groupRelationList);
|
|
|
|
|
|
groupRelationList=map.get("groupList");
|
|
|
|
|
|
strRegionList=map.get("dstList");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-01-16 14:33:29 +06:00
|
|
|
|
//asn配置下发
|
2019-02-18 10:39:49 +08:00
|
|
|
|
auditAsnCfgForIpAddr(groupRelationList,strRegionList,entity,entity.getAsnKeywords());
|
2018-08-24 20:55:20 +08:00
|
|
|
|
//保存区域IP信息
|
|
|
|
|
|
List<AreaIpCfg> areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
|
|
|
|
|
|
if(!StringUtil.isEmpty(areaIpCfgList)){
|
|
|
|
|
|
AreaIpCfg cfg = new AreaIpCfg();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
|
|
|
|
|
cfg.setTableName(AreaIpCfg.getTablename());
|
|
|
|
|
|
ipCfgDao.auditCfg(cfg);
|
2018-10-15 15:26:43 +08:00
|
|
|
|
if(isAudit==1&&maatType==Constants.MAAT_TYPE){
|
2018-08-24 20:55:20 +08:00
|
|
|
|
Map<String,List> map = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList);
|
|
|
|
|
|
groupRelationList=map.get("groupList");
|
|
|
|
|
|
areaIpRegionList=map.get("dstList");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//构造提交综合服务参数格式,一条配置提交一次综合服务
|
|
|
|
|
|
if(isAudit==1){
|
2018-08-25 11:42:24 +08:00
|
|
|
|
if(maatType==Constants.CALLBACK_TYPE){
|
|
|
|
|
|
List<InlineIp> ipList=new ArrayList<>();
|
|
|
|
|
|
for(IpPortCfg cfg :entity.getIpPortList()) {
|
2018-10-15 15:26:43 +08:00
|
|
|
|
Integer ipsecProtocol=null;
|
2018-10-15 19:17:55 +08:00
|
|
|
|
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
2018-08-25 11:42:24 +08:00
|
|
|
|
InlineIp ip=convertCallBackIp(cfg,null);
|
2018-10-15 15:26:43 +08:00
|
|
|
|
if(ipsecProtocol!=null) {
|
|
|
|
|
|
ip.setProtocol(ipsecProtocol);
|
|
|
|
|
|
}
|
2018-08-25 11:42:24 +08:00
|
|
|
|
ipList.add(ip);
|
|
|
|
|
|
}
|
|
|
|
|
|
//调用服务接口下发配置数据
|
|
|
|
|
|
String json=gsonToJson(ipList);
|
|
|
|
|
|
logger.info("IP配置下发配置参数:"+json);
|
|
|
|
|
|
//调用服务接口下发配置
|
|
|
|
|
|
try {
|
|
|
|
|
|
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
|
|
|
|
|
if(result!=null){
|
|
|
|
|
|
logger.info("IP配置配置下发响应信息:"+result.getMsg());
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("IP配置配置下发失败",e);
|
|
|
|
|
|
throw e;
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(maatType==Constants.MAAT_TYPE){
|
|
|
|
|
|
maatCfg.initDefaultValue();
|
|
|
|
|
|
BeanUtils.copyProperties(entity, maatCfg);
|
|
|
|
|
|
maatCfg.setAction(entity.getAction());
|
|
|
|
|
|
maatCfg.setAuditTime(entity.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(entity.getIsValid());
|
|
|
|
|
|
|
|
|
|
|
|
configCompileList.add(maatCfg);
|
|
|
|
|
|
maatBean.setConfigCompileList(configCompileList);
|
|
|
|
|
|
maatBean.setAuditTime(entity.getAuditTime());
|
|
|
|
|
|
maatBean.setCreatorName(entity.getCurrentUser().getName());
|
|
|
|
|
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
|
|
|
|
|
maatBean.setOpAction(Constants.INSERT_ACTION);
|
2018-10-11 19:09:28 +08:00
|
|
|
|
//限速需要发Droprate=0.001 ,暂不支持Bandwidth=200kbps
|
|
|
|
|
|
if(entity.getAction().equals(Constants.RATELIMIT_ACTION)){
|
|
|
|
|
|
if(entity.getUserRegion1().equals("0")){//丢包率
|
|
|
|
|
|
entity.setUserRegion2(StringUtil.isEmpty(entity.getUserRegion2()) ? "":entity.getUserRegion2());
|
|
|
|
|
|
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_DROPRATE_USER_REGION_KEY+"="+entity.getUserRegion2());
|
|
|
|
|
|
}else if(entity.getUserRegion1().equals("1")){//带宽
|
|
|
|
|
|
entity.setUserRegion3(StringUtil.isEmpty(entity.getUserRegion3()) ? "":entity.getUserRegion3());
|
|
|
|
|
|
maatCfg.setUserRegion(Constants.INTERCEPT_IP_RATELIMIT_BANDWITH_USER_REGION_KEY+"="+entity.getUserRegion3());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-08-25 11:42:24 +08:00
|
|
|
|
//调用服务接口下发配置数据
|
|
|
|
|
|
String json=gsonToJson(maatBean);
|
|
|
|
|
|
logger.info("ip配置下发配置参数:"+json);
|
|
|
|
|
|
//调用服务接口下发配置
|
|
|
|
|
|
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
|
|
|
|
|
logger.info("ip配置下发响应信息:"+result.getMsg());
|
|
|
|
|
|
}else {
|
|
|
|
|
|
throw new RuntimeException("<spring:message code=\"request_service_failed\"/>:"+props.getProperty("unknown_cfg_type"));
|
|
|
|
|
|
}
|
2018-08-24 20:55:20 +08:00
|
|
|
|
}else if(isAudit==3){
|
2018-08-25 11:42:24 +08:00
|
|
|
|
if(maatType==Constants.CALLBACK_TYPE){
|
|
|
|
|
|
List<InlineIp> ipList=new ArrayList<>();
|
|
|
|
|
|
for(IpPortCfg cfg :entity.getIpPortList()) {
|
2018-10-15 15:26:43 +08:00
|
|
|
|
Integer ipsecProtocol=null;
|
2018-10-15 19:17:55 +08:00
|
|
|
|
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
|
2018-08-25 11:42:24 +08:00
|
|
|
|
InlineIp ip=convertCallBackIp(cfg,null);
|
2018-10-15 15:26:43 +08:00
|
|
|
|
if(ipsecProtocol!=null) {
|
|
|
|
|
|
ip.setProtocol(ipsecProtocol);
|
|
|
|
|
|
}
|
2018-08-25 11:42:24 +08:00
|
|
|
|
ipList.add(ip);
|
|
|
|
|
|
}
|
|
|
|
|
|
//调用服务接口下发配置数据
|
|
|
|
|
|
String json=gsonToJson(ipList);
|
|
|
|
|
|
logger.info("IP配置下发配置参数:"+json);
|
|
|
|
|
|
//调用服务接口下发配置
|
|
|
|
|
|
try {
|
2018-08-25 14:05:11 +08:00
|
|
|
|
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
2018-08-25 11:42:24 +08:00
|
|
|
|
if(result!=null){
|
|
|
|
|
|
logger.info("IP配置配置下发响应信息:"+result.getMsg());
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("IP配置配置下发失败",e);
|
|
|
|
|
|
throw e;
|
|
|
|
|
|
}
|
|
|
|
|
|
}else if(maatType==Constants.MAAT_TYPE){
|
|
|
|
|
|
maatCfg.setCompileId(entity.getCompileId());
|
|
|
|
|
|
maatCfg.setServiceId(entity.getServiceId());
|
|
|
|
|
|
maatCfg.setIsValid(0);//无效
|
2019-01-16 14:33:29 +06:00
|
|
|
|
configCompileList.add(addKeepGroupList(maatCfg,entity));
|
2018-08-25 11:42:24 +08:00
|
|
|
|
maatBean.setConfigCompileList(configCompileList);
|
|
|
|
|
|
maatBean.setAuditTime(entity.getAuditTime());
|
|
|
|
|
|
maatBean.setCreatorName(entity.getCurrentUser().getName());
|
|
|
|
|
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
|
|
|
|
|
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
|
|
|
|
|
//调用服务接口取消配置
|
|
|
|
|
|
String json=gsonToJson(maatBean);
|
|
|
|
|
|
logger.info("ip配置下发配置参数:"+json);
|
|
|
|
|
|
//调用服务接口下发配置
|
|
|
|
|
|
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
|
|
|
|
|
logger.info("ip配置取消配置响应信息:"+result.getMsg());
|
|
|
|
|
|
}else {
|
|
|
|
|
|
throw new RuntimeException("<spring:message code=\"request_service_failed\"/>:"+props.getProperty("unknown_cfg_type"));
|
|
|
|
|
|
}
|
2018-08-24 20:55:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param isAudit
|
|
|
|
|
|
* @param isValid
|
|
|
|
|
|
* @param ids cfgId
|
|
|
|
|
|
* @param functionId
|
|
|
|
|
|
*/
|
2019-01-06 11:24:49 +08:00
|
|
|
|
|
|
|
|
|
|
// @Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
|
|
|
|
|
// @Deprecated
|
|
|
|
|
|
// public void auditAsnCfg(CfgIndexInfo entity,Integer isAudit){
|
|
|
|
|
|
// entity.setTableName(CfgIndexInfo.getTablename());
|
|
|
|
|
|
// entity.setIsAudit(isAudit);
|
|
|
|
|
|
// ipCfgDao.auditCfg(entity);
|
|
|
|
|
|
// ToMaatBean maatBean = new ToMaatBean();
|
|
|
|
|
|
//
|
|
|
|
|
|
// List<MaatCfg> configCompileList = new ArrayList<>();
|
|
|
|
|
|
//
|
|
|
|
|
|
// if(isAudit==Constants.AUDIT_YES) {
|
|
|
|
|
|
// List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
|
|
|
|
|
|
// if(asnKeywordCfgs!=null&&asnKeywordCfgs.size()>0) {
|
|
|
|
|
|
// MaatCfg maatCfg = new MaatCfg();
|
|
|
|
|
|
// List<GroupCfg> groupRelationList = new ArrayList<>();
|
|
|
|
|
|
// List<IpCfg> ipRegionList = new ArrayList<>();
|
|
|
|
|
|
// List<StringCfg> strRegionList = new ArrayList<>();
|
|
|
|
|
|
// List<NumBoundaryCfg> numRegionList = new ArrayList<>();
|
|
|
|
|
|
// List<DigestCfg> digestRegionList = new ArrayList<>();
|
|
|
|
|
|
// List<IpCfg> areaIpRegionList = new ArrayList<>();
|
|
|
|
|
|
// maatCfg.initDefaultValue();
|
|
|
|
|
|
// BeanUtils.copyProperties(entity, maatCfg);
|
|
|
|
|
|
// maatCfg.setAction(entity.getAction());
|
|
|
|
|
|
// maatCfg.setAuditTime(entity.getAuditTime());
|
|
|
|
|
|
//
|
|
|
|
|
|
// maatCfg.setNumRegionList(numRegionList);
|
|
|
|
|
|
// maatCfg.setDigestRegionList(digestRegionList);
|
|
|
|
|
|
// maatCfg.setGroupRelationList(groupRelationList);
|
|
|
|
|
|
// maatCfg.setAreaIpRegionList(areaIpRegionList);
|
|
|
|
|
|
// maatCfg.setIsValid(entity.getIsValid());
|
|
|
|
|
|
// //group
|
|
|
|
|
|
// List<Integer> groupIds=ConfigServiceUtil.getId(2, 1);
|
|
|
|
|
|
// GroupCfg groupCfg=new GroupCfg();
|
|
|
|
|
|
// groupCfg.setCompileId(entity.getCompileId());
|
|
|
|
|
|
// //groupCfg.setGroupId(Integer.parseInt(entity.getUserRegion4()));
|
|
|
|
|
|
// groupCfg.setGroupId(groupIds.get(0));
|
|
|
|
|
|
// groupCfg.setIsValid(Constants.VALID_YES);
|
|
|
|
|
|
// groupCfg.setAuditTime(entity.getAuditTime());
|
|
|
|
|
|
// groupRelationList.add(groupCfg);
|
|
|
|
|
|
// maatCfg.setGroupNum(groupRelationList.size());
|
|
|
|
|
|
// maatCfg.setIpRegionList(ipRegionList);
|
|
|
|
|
|
// List<Integer> regions=ConfigServiceUtil.getId(3, asnKeywordCfgs.size());
|
|
|
|
|
|
// int index=0;
|
|
|
|
|
|
// List<FunctionRegionDict> functionRegionDicts=DictUtils.getFunctionRegionDictList(entity.getFunctionId());
|
|
|
|
|
|
// String cfgType=null;
|
|
|
|
|
|
// for(FunctionRegionDict dict:functionRegionDicts) {
|
|
|
|
|
|
// if("asn".equals(dict.getConfigServiceType())) {
|
|
|
|
|
|
// cfgType=dict.getCfgType();
|
2019-01-04 18:28:57 +06:00
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2019-01-06 11:24:49 +08:00
|
|
|
|
// for(AsnKeywordCfg keyword:asnKeywordCfgs) {
|
|
|
|
|
|
// StringCfg cfg=new StringCfg();
|
|
|
|
|
|
// BeanUtils.copyProperties(keyword, cfg);
|
|
|
|
|
|
// cfg.setRegionId(index);
|
|
|
|
|
|
// //需要根据文档
|
|
|
|
|
|
// //cfg.setCfgType(StringUtils.isBlank(cfgType)?"NTC_ASN_NUMBER":cfgType);
|
|
|
|
|
|
// cfg.setGroupId(groupIds.get(0));
|
|
|
|
|
|
// cfg.setAuditTime(entity.getAuditTime());
|
|
|
|
|
|
// cfg.setIsValid(entity.getIsValid());
|
|
|
|
|
|
// cfg.setRegionId(regions.get(index));
|
|
|
|
|
|
// //cfg.setGroupId(Integer.parseInt(entity.getUserRegion4()));
|
|
|
|
|
|
// strRegionList.add(cfg);
|
|
|
|
|
|
// index++;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// maatCfg.setStrRegionList(strRegionList);
|
|
|
|
|
|
// configCompileList.add(maatCfg);
|
2019-01-04 18:28:57 +06:00
|
|
|
|
// maatBean.setConfigCompileList(configCompileList);
|
|
|
|
|
|
// maatBean.setAuditTime(entity.getAuditTime());
|
|
|
|
|
|
// maatBean.setCreatorName(entity.getCurrentUser().getName());
|
|
|
|
|
|
// maatBean.setVersion(Constants.MAAT_VERSION);
|
|
|
|
|
|
// maatBean.setOpAction(Constants.INSERT_ACTION);
|
|
|
|
|
|
//
|
|
|
|
|
|
// //调用服务接口下发配置数据
|
|
|
|
|
|
// String json=gsonToJson(maatBean);
|
2019-01-06 11:24:49 +08:00
|
|
|
|
// logger.info("ipaddr asn配置下发配置参数:"+json);
|
2019-01-04 18:28:57 +06:00
|
|
|
|
// //调用服务接口下发配置
|
|
|
|
|
|
// ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
2019-01-06 11:24:49 +08:00
|
|
|
|
// logger.info("ipaddr asn配置下发响应信息:"+result.getMsg());
|
|
|
|
|
|
//// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// }else if(isAudit==Constants.AUDIT_NOT_YES) {//取消审核通过
|
|
|
|
|
|
// MaatCfg maatCfg = new MaatCfg();
|
|
|
|
|
|
// maatCfg.setCompileId(entity.getCompileId());
|
|
|
|
|
|
// maatCfg.setServiceId(entity.getServiceId());
|
|
|
|
|
|
// maatCfg.setIsValid(0);//无效
|
|
|
|
|
|
// configCompileList.add(maatCfg);
|
|
|
|
|
|
// maatBean.setConfigCompileList(configCompileList);
|
|
|
|
|
|
// maatBean.setAuditTime(entity.getAuditTime());
|
|
|
|
|
|
// maatBean.setCreatorName(entity.getCurrentUser().getName());
|
|
|
|
|
|
// maatBean.setVersion(Constants.MAAT_VERSION);
|
|
|
|
|
|
// maatBean.setOpAction(Constants.UPDATE_ACTION);
|
|
|
|
|
|
// //调用服务接口取消配置
|
|
|
|
|
|
// String json=gsonToJson(maatBean);
|
|
|
|
|
|
// logger.info("ipaddr asn取消下发配置参数:"+json);
|
|
|
|
|
|
// //调用服务接口下发配置
|
|
|
|
|
|
// ToMaatResult result = ConfigServiceUtil.put(json,1);
|
|
|
|
|
|
// logger.info("ipaddr asn取消配置响应信息:"+result.getMsg());
|
|
|
|
|
|
// }else {
|
|
|
|
|
|
// throw new RuntimeException("unknown isAudit value "+isAudit);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// }
|
2018-05-24 19:33:59 +08:00
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
2018-06-02 17:40:14 +08:00
|
|
|
|
public void deleteIp(String ids,String compileIds,int functionId){
|
|
|
|
|
|
if(StringUtils.isNotBlank(compileIds)){
|
2018-06-14 16:09:17 +08:00
|
|
|
|
for(String compileId:compileIds.split(",")){//强转数字,防止注入
|
|
|
|
|
|
Integer.parseInt(compileId);
|
2018-06-02 17:40:14 +08:00
|
|
|
|
}
|
2018-06-14 16:55:54 +08:00
|
|
|
|
ipCfgDao.deleteByCompileIds(new BaseIpCfg().getCurrentUser().getId(),AreaIpCfg.getTablename(),compileIds);
|
2018-06-02 17:40:14 +08:00
|
|
|
|
}
|
2018-05-24 19:33:59 +08:00
|
|
|
|
List<BaseIpCfg> ipCfgs=new ArrayList<BaseIpCfg>();
|
|
|
|
|
|
Date date =new Date();
|
|
|
|
|
|
if(StringUtils.isNotBlank(ids)){
|
|
|
|
|
|
for(String idStr:ids.split(",")){
|
|
|
|
|
|
if(StringUtils.isNotBlank(idStr)){
|
|
|
|
|
|
BaseIpCfg cfg=new BaseIpCfg();
|
|
|
|
|
|
cfg.setCfgId(Long.parseLong(idStr));
|
|
|
|
|
|
cfg.setTableName(IpPortCfg.getTablename());
|
|
|
|
|
|
cfg.setEditorId(cfg.getCurrentUser().getId());
|
|
|
|
|
|
cfg.setEditTime(date);
|
|
|
|
|
|
cfg.setIsValid(Constants.VALID_DEL);
|
|
|
|
|
|
ipCfgs.add(cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.deleteBatch(ipCfgs, IpCfgDao.class);
|
2018-02-25 18:43:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* deleteIpCfg(删除IP类配置)
|
|
|
|
|
|
* (继承BaseIpCfg这个类方可使用)
|
|
|
|
|
|
* @param baseIpCfg
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*int
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
2018-03-05 16:30:16 +08:00
|
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
2018-04-11 13:45:04 +08:00
|
|
|
|
public void deleteIpCfg(List<BaseIpCfg> baseIpCfg, List<AreaIpCfg> areaCfg){
|
|
|
|
|
|
List<BaseIpCfg> cfgs=new ArrayList<>();
|
2018-04-10 10:42:24 +08:00
|
|
|
|
if(areaCfg!=null&&areaCfg.size()>0){
|
2018-05-21 19:42:24 +08:00
|
|
|
|
cfgs.addAll(areaCfg);
|
2018-04-11 13:45:04 +08:00
|
|
|
|
this.deleteBatch(cfgs,IpCfgDao.class);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(baseIpCfg!=null&&baseIpCfg.size()>0){
|
|
|
|
|
|
this.deleteBatch(baseIpCfg, IpCfgDao.class);
|
2018-04-10 10:42:24 +08:00
|
|
|
|
}
|
2018-04-11 13:45:04 +08:00
|
|
|
|
|
2018-02-23 09:54:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* getIpCfg(根据IP与类名获取IP配置)
|
|
|
|
|
|
* (继承BaseIpCfg这个类方可使用)
|
|
|
|
|
|
* @param clazz
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*BaseIpCfg
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public BaseIpCfg getIpCfgById(BaseIpCfg baseIpCfg){
|
2018-03-26 14:43:58 +08:00
|
|
|
|
return ipCfgDao.getById(baseIpCfg.getTableName(), baseIpCfg.getCfgId());
|
2018-02-25 18:43:20 +08:00
|
|
|
|
}
|
2018-11-28 19:23:38 +08:00
|
|
|
|
public CfgIndexInfo getIpPortCfg(Long cfgId,Integer compileId){
|
|
|
|
|
|
CfgIndexInfo entity = ipCfgDao.getCfgIndexInfo(cfgId,compileId);
|
2018-08-24 20:55:20 +08:00
|
|
|
|
List<IpPortCfg> ipPortList = ipCfgDao.getIpPortList(entity);
|
|
|
|
|
|
List<NtcSubscribeIdCfg> subscribeIdList = stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity);
|
|
|
|
|
|
entity.setIpPortList(ipPortList);
|
|
|
|
|
|
entity.setNtcSubscribeIdCfgList(subscribeIdList);
|
2019-01-18 11:14:05 +06:00
|
|
|
|
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
|
|
|
|
|
|
entity.setAsnKeywords(asnKeywordCfgs);
|
2018-10-15 10:14:01 +08:00
|
|
|
|
return entity;
|
|
|
|
|
|
}
|
|
|
|
|
|
public CfgIndexInfo exportIpInfo(CfgIndexInfo entity){
|
|
|
|
|
|
List<IpPortCfg> ipPortList = ipCfgDao.getIpPortList(entity);
|
|
|
|
|
|
entity.setIpPortList(ipPortList);
|
2019-01-18 11:14:05 +06:00
|
|
|
|
List<AsnKeywordCfg> asnKeywordCfgs=stringCfgDao.findAsnKeywordCfgList(entity);
|
|
|
|
|
|
entity.setAsnKeywords(asnKeywordCfgs);
|
2018-08-24 20:55:20 +08:00
|
|
|
|
return entity;
|
|
|
|
|
|
}
|
2018-05-21 19:42:24 +08:00
|
|
|
|
public BaseIpCfg getIpCfgById(String tableName,long id){
|
|
|
|
|
|
return ipCfgDao.getById(tableName, id);
|
|
|
|
|
|
}
|
2018-02-25 18:43:20 +08:00
|
|
|
|
public Integer getIsValid(BaseIpCfg baseIpCfg){
|
2018-03-26 14:43:58 +08:00
|
|
|
|
return ipCfgDao.getIsValid(baseIpCfg);
|
2018-02-25 18:43:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
public Integer getIsValid(String tableName, long id){
|
|
|
|
|
|
return ipCfgDao.getIsValid(tableName,id);
|
|
|
|
|
|
}
|
|
|
|
|
|
public Integer getIsAudit(BaseIpCfg baseIpCfg){
|
2018-03-26 14:43:58 +08:00
|
|
|
|
return ipCfgDao.getIsAudit(baseIpCfg);
|
2018-02-25 18:43:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
public Integer getIsAudit(String tableName, long id){
|
|
|
|
|
|
return ipCfgDao.getIsAudit(tableName,id);
|
2018-02-23 09:54:28 +08:00
|
|
|
|
}
|
2018-06-22 16:30:59 +08:00
|
|
|
|
public List<AreaIpCfg> getAreaCfgByCompileId(/*int functionId,*/int compileId){
|
2018-04-08 16:15:06 +08:00
|
|
|
|
return areaIpCfgDao.getByCompileId(compileId);
|
|
|
|
|
|
}
|
2018-06-22 16:30:59 +08:00
|
|
|
|
public List<BaseIpCfg> getListByComileId(String tableName,int functionId,String ids){
|
|
|
|
|
|
return ipCfgDao.getListByComileId(tableName,functionId,ids);
|
2018-05-24 19:33:59 +08:00
|
|
|
|
}
|
2018-06-22 16:30:59 +08:00
|
|
|
|
public List<BaseIpCfg> getListByCfgId(String tableName,int functionId,String ids){
|
|
|
|
|
|
return ipCfgDao.getListByCfgId(tableName,functionId,ids);
|
2018-04-11 13:45:04 +08:00
|
|
|
|
}
|
2018-07-01 15:32:27 +08:00
|
|
|
|
public Integer getCompileId(){
|
|
|
|
|
|
//调用服务接口获取compileId
|
|
|
|
|
|
Integer compileId = 0;
|
|
|
|
|
|
try {
|
|
|
|
|
|
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
|
|
|
|
|
if(!StringUtil.isEmpty(compileIds)){
|
|
|
|
|
|
compileId = compileIds.get(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("获取编译ID出错");
|
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
return compileId;
|
|
|
|
|
|
}
|
2018-07-03 14:55:36 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* getListByCfgIdWithName(这里用一句话描述这个方法的作用)
|
|
|
|
|
|
* (这里描述这个方法适用条件 – 可选)
|
|
|
|
|
|
* @param tablename
|
|
|
|
|
|
* @param functionId
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*List<BaseIpCfg>
|
|
|
|
|
|
* @exception
|
|
|
|
|
|
* @since 1.0.0
|
|
|
|
|
|
*/
|
|
|
|
|
|
public List<BaseIpCfg> getListByCfgIdWithName(String tablename, Integer functionId, String ids) {
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
return ipCfgDao.getListByCfgIdWithName(tablename,functionId,ids);
|
|
|
|
|
|
}
|
2018-08-07 13:05:00 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取国际化配置文件
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public Properties getMsgProp(){
|
|
|
|
|
|
Properties msgProp = new Properties();
|
|
|
|
|
|
try {
|
|
|
|
|
|
String language = LocaleContextHolder.getLocale().getLanguage();
|
2018-12-19 17:45:03 +08:00
|
|
|
|
if (language.equals("zh_cn") || language.equals("zh")) {
|
|
|
|
|
|
msgProp=Configurations.getMsgPropZh();
|
|
|
|
|
|
} else if (language.equals("ru")) {
|
|
|
|
|
|
msgProp=Configurations.getMsgPropRu();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
msgProp=Configurations.getMsgPropEn();
|
2018-08-07 13:05:00 +08:00
|
|
|
|
}
|
2018-12-19 17:45:03 +08:00
|
|
|
|
|
2018-08-07 13:05:00 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
msgProp = null;
|
2018-12-19 17:45:03 +08:00
|
|
|
|
logger.error("未知i18n消息配置文件,请确定文件是否存在!", e);
|
2018-08-07 13:05:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
return msgProp;
|
|
|
|
|
|
}
|
2018-08-25 11:42:24 +08:00
|
|
|
|
public Page<CfgIndexInfo> getIpCfgList(Page<CfgIndexInfo> page, CfgIndexInfo entity) {
|
2018-08-25 01:55:10 +08:00
|
|
|
|
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
|
|
|
|
|
|
entity.setPage(page);
|
2018-08-25 11:42:24 +08:00
|
|
|
|
List<CfgIndexInfo> list = ipCfgDao.getIpCfgList(entity);
|
2018-08-25 01:55:10 +08:00
|
|
|
|
page.setList(list);
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
2018-11-29 15:49:47 +08:00
|
|
|
|
|
2018-12-17 03:30:34 +08:00
|
|
|
|
public List<CfgIndexInfo> getByIdsList(String ids) {
|
|
|
|
|
|
List<CfgIndexInfo> list = ipCfgDao.getByIdsList(ids);
|
|
|
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-09 16:50:39 +08:00
|
|
|
|
}
|