1805 lines
71 KiB
Java
1805 lines
71 KiB
Java
package com.nis.web.service.configuration;
|
||
|
||
import java.util.ArrayList;
|
||
import java.util.Date;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import org.springframework.beans.BeanUtils;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Service;
|
||
import org.springframework.transaction.annotation.Transactional;
|
||
|
||
import com.nis.domain.Page;
|
||
import com.nis.domain.configuration.AppByteCfg;
|
||
import com.nis.domain.configuration.AppDomainCfg;
|
||
import com.nis.domain.configuration.AppHeaderCfg;
|
||
import com.nis.domain.configuration.AppHttpCfg;
|
||
import com.nis.domain.configuration.AppIpCfg;
|
||
import com.nis.domain.configuration.AppPolicyCfg;
|
||
import com.nis.domain.configuration.AppSslCertCfg;
|
||
import com.nis.domain.configuration.AppTcpCfg;
|
||
import com.nis.domain.configuration.AppTopicDomainCfg;
|
||
import com.nis.domain.configuration.AreaIpCfg;
|
||
import com.nis.domain.configuration.IpPortCfg;
|
||
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||
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;
|
||
import com.nis.domain.maat.ToMaatBean;
|
||
import com.nis.domain.maat.ToMaatResult;
|
||
import com.nis.exceptions.MaatConvertException;
|
||
import com.nis.util.ConfigServiceUtil;
|
||
import com.nis.util.Constants;
|
||
import com.nis.util.DictUtils;
|
||
import com.nis.util.StringUtil;
|
||
import com.nis.util.StringUtils;
|
||
import com.nis.web.dao.configuration.AppCfgDao;
|
||
import com.nis.web.dao.configuration.AreaIpCfgDao;
|
||
import com.nis.web.dao.configuration.StringCfgDao;
|
||
import com.nis.web.security.UserUtils;
|
||
import com.nis.web.service.BaseService;
|
||
|
||
/**
|
||
* 特定协议相关配置事务类
|
||
*
|
||
* @author dell
|
||
*
|
||
*/
|
||
@Service
|
||
public class AppCfgService extends BaseService {
|
||
@Autowired
|
||
protected AppCfgDao appCfgDao;
|
||
@Autowired
|
||
protected AreaIpCfgDao areaIpCfgDao;
|
||
@Autowired
|
||
protected StringCfgDao stringcfgDao;
|
||
|
||
public Page<AppPolicyCfg> findAppPolicyList(Page<AppPolicyCfg> page, AppPolicyCfg entity) {
|
||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
|
||
entity.setPage(page);
|
||
List<AppPolicyCfg> list = appCfgDao.findAppPolicyList(entity);
|
||
page.setList(list);
|
||
return page;
|
||
}
|
||
|
||
public Page<AppIpCfg> findAppIpList(Page<AppIpCfg> page, AppIpCfg entity) {
|
||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
|
||
entity.setPage(page);
|
||
List<AppIpCfg> list = appCfgDao.findAppIpList(entity);
|
||
page.setList(list);
|
||
return page;
|
||
}
|
||
|
||
public Page<AppHttpCfg> findAppHttpList(Page<AppHttpCfg> page, AppHttpCfg entity) {
|
||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
|
||
entity.setPage(page);
|
||
List<AppHttpCfg> list = appCfgDao.findAppHttpList(entity);
|
||
page.setList(list);
|
||
return page;
|
||
}
|
||
|
||
public Page<AppDomainCfg> findAppDomainList(Page<AppDomainCfg> page, AppDomainCfg entity) {
|
||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
|
||
entity.setPage(page);
|
||
List<AppDomainCfg> list = appCfgDao.findAppDomainList(entity);
|
||
page.setList(list);
|
||
return page;
|
||
}
|
||
|
||
// 主题网站列表
|
||
public Page<AppTopicDomainCfg> findAppTopicDomainList(Page<AppTopicDomainCfg> page, AppTopicDomainCfg entity) {
|
||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
|
||
entity.setPage(page);
|
||
List<AppTopicDomainCfg> list = appCfgDao.findAppTopicDomainList(entity);
|
||
page.setList(list);
|
||
return page;
|
||
}
|
||
|
||
public Page<AppByteCfg> findAppByteList(Page<AppByteCfg> page, AppByteCfg entity) {
|
||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
|
||
entity.setPage(page);
|
||
List<AppByteCfg> list = appCfgDao.findAppByteList(entity);
|
||
page.setList(list);
|
||
return page;
|
||
}
|
||
|
||
public Page<AppSslCertCfg> findAppSslList(Page<AppSslCertCfg> page, AppSslCertCfg entity) {
|
||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
|
||
entity.setPage(page);
|
||
List<AppSslCertCfg> list = appCfgDao.findAppSslList(entity);
|
||
page.setList(list);
|
||
return page;
|
||
}
|
||
|
||
public Page<AppTcpCfg> findAppTcpList(Page<AppTcpCfg> page, AppTcpCfg entity) {
|
||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
|
||
entity.setPage(page);
|
||
List<AppTcpCfg> list = appCfgDao.findAppTcpList(entity);
|
||
page.setList(list);
|
||
return page;
|
||
}
|
||
|
||
public AppTcpCfg getAppTcpCfg(Long cfgId) {
|
||
return appCfgDao.getAppTcpCfg(cfgId);
|
||
}
|
||
|
||
public AppPolicyCfg getAppPolicyCfg(Long cfgId) {
|
||
AppPolicyCfg policy = appCfgDao.getAppPolicyCfg(cfgId);
|
||
List<IpPortCfg> ipPortList = appCfgDao.getAppPolicyIpList(policy);
|
||
// 查询关键字
|
||
if (policy.getCompileId() != null) {
|
||
NtcSubscribeIdCfg ntcSubscribeIdCfg = new NtcSubscribeIdCfg();
|
||
ntcSubscribeIdCfg.setCompileId(policy.getCompileId());
|
||
List<NtcSubscribeIdCfg> ntcList = stringcfgDao.findSubscribeIdCfgList(ntcSubscribeIdCfg);
|
||
policy.setNtcSubscribeIdCfgList(ntcList);
|
||
}
|
||
|
||
policy.setIpPortList(ipPortList);
|
||
return policy;
|
||
}
|
||
|
||
public AppIpCfg getAppIpCfg(Long cfgId) {
|
||
return appCfgDao.getAppIpCfg(cfgId);
|
||
}
|
||
|
||
public AppHttpCfg getAppHttpCfg(Long cfgId) {
|
||
return appCfgDao.getAppHttpCfg(cfgId);
|
||
}
|
||
|
||
public AppDomainCfg getAppDomainCfg(Long cfgId) {
|
||
return appCfgDao.getAppDomainCfg(cfgId);
|
||
}
|
||
|
||
// 主题网站form
|
||
public AppTopicDomainCfg getAppTopicDomainCfg(Long cfgId) {
|
||
return appCfgDao.getAppTopicDomainCfg(cfgId);
|
||
}
|
||
|
||
public AppByteCfg getAppByteCfg(Long cfgId) {
|
||
return appCfgDao.getAppByteCfg(cfgId);
|
||
}
|
||
|
||
public AppSslCertCfg getAppSslCfg(Long cfgId) {
|
||
return appCfgDao.getAppSslCfg(cfgId);
|
||
}
|
||
|
||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||
public void saveOrUpdateAppPolicyCfg(AppPolicyCfg entity) throws Exception {
|
||
// 设置区域运营商信息
|
||
setAreaEffectiveIds(entity);
|
||
|
||
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 (Exception e) {
|
||
e.printStackTrace();
|
||
logger.info("获取编译ID出错");
|
||
throw new MaatConvertException(e.getMessage());
|
||
}
|
||
entity.setCompileId(compileId);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
// 设置SubscribeID域配置参数
|
||
if (entity != null && entity.getNtcSubscribeIdCfgList() != null) {
|
||
for (NtcSubscribeIdCfg cfg : entity.getNtcSubscribeIdCfgList()) {
|
||
entity.setExprType(cfg.getExprType());
|
||
entity.setIsHexbin(cfg.getIsHexbin());
|
||
entity.setMatchMethod(cfg.getMatchMethod());
|
||
entity.setCfgKeywords(cfg.getCfgKeywords());
|
||
}
|
||
}
|
||
entity.initDefaultValue();
|
||
appCfgDao.insertAppPolicyCfg(entity);
|
||
// 保存策略IP配置
|
||
if (entity != null && entity.getIpPortList() != null) {
|
||
for (IpPortCfg cfg : entity.getIpPortList()) {
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgRegionCode", "cfgType" });
|
||
appCfgDao.insertAppPolicyIpCfg(cfg);
|
||
}
|
||
}
|
||
// 保存关键字配置
|
||
if (entity != null && entity.getNtcSubscribeIdCfgList() != null) {
|
||
for (NtcSubscribeIdCfg cfg : entity.getNtcSubscribeIdCfgList()) {
|
||
if (StringUtils.isNotBlank(cfg.getCfgKeywords())) {
|
||
entity.setCfgKeywords(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);
|
||
}
|
||
}
|
||
|
||
} else {
|
||
entity.setEditorId(entity.getCurrentUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
// 设置SubscribeID域配置参数
|
||
if (entity != null && entity.getNtcSubscribeIdCfgList() != null) {
|
||
for (NtcSubscribeIdCfg cfg : entity.getNtcSubscribeIdCfgList()) {
|
||
entity.setExprType(cfg.getExprType());
|
||
entity.setIsHexbin(cfg.getIsHexbin());
|
||
entity.setMatchMethod(cfg.getMatchMethod());
|
||
}
|
||
}
|
||
appCfgDao.updateAppPolicyCfg(entity);
|
||
|
||
appCfgDao.deleteAppPolicyIpCfg(entity);
|
||
if (entity != null && entity.getNtcSubscribeIdCfgList() != null
|
||
&& entity.getNtcSubscribeIdCfgList().size() > 0) {
|
||
for (NtcSubscribeIdCfg ntcSubscribeIdCfg : entity.getNtcSubscribeIdCfgList()) {
|
||
ntcSubscribeIdCfg.setCompileId(entity.getCompileId());
|
||
stringcfgDao.deleteSubscribeIdCfg(ntcSubscribeIdCfg);
|
||
}
|
||
}
|
||
// 删除旧的区域IP,新增新的区域IP
|
||
AreaIpCfg area = new AreaIpCfg();
|
||
area.setCompileId(entity.getCompileId());
|
||
area.setFunctionId(entity.getFunctionId());
|
||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
// 保存策略IP配置
|
||
if (entity.getIpPortList() != null) {
|
||
for (IpPortCfg cfg : entity.getIpPortList()) {
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgRegionCode", "cfgType" });
|
||
appCfgDao.insertAppPolicyIpCfg(cfg);
|
||
}
|
||
}
|
||
if (entity != null && entity.getNtcSubscribeIdCfgList() != null) {
|
||
for (NtcSubscribeIdCfg cfg : entity.getNtcSubscribeIdCfgList()) {
|
||
if (StringUtils.isNotBlank(cfg.getCfgKeywords())) {
|
||
entity.setCfgKeywords(cfg.getCfgKeywords());
|
||
BeanUtils.copyProperties(entity, cfg,
|
||
new String[] { "cfgRegionCode", "cfgType", "exprType", "matchMethod", "isHexbin" });
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||
public void saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception {
|
||
// 设置区域运营商信息
|
||
setAreaEffectiveIds(entity);
|
||
|
||
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);
|
||
}
|
||
entity.setCompileId(compileId);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.insertAppIpCfg(entity);
|
||
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg,
|
||
new String[] { "cfgRegionCode", "cfgType", "ipType", "isAreaEffective",
|
||
"areaEffectiveIds", "protocol", "portPattern", "srcPort", "destPort",
|
||
"direction", "destIpAddress", "srcIpAddress", "ipPattern" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.info("获取编译ID出错");
|
||
throw new MaatConvertException(e.getMessage());
|
||
}
|
||
} else {
|
||
entity.setEditorId(entity.getCurrentUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.updateAppIpCfg(entity);
|
||
// 删除旧的区域IP,新增新的区域IP
|
||
AreaIpCfg area = new AreaIpCfg();
|
||
area.setCompileId(entity.getCompileId());
|
||
area.setFunctionId(entity.getFunctionId());
|
||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg,
|
||
new String[] { "cfgRegionCode", "cfgType", "ipType", "isAreaEffective", "areaEffectiveIds",
|
||
"protocol", "portPattern", "srcPort", "destPort", "direction", "destIpAddress",
|
||
"srcIpAddress", "ipPattern" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||
public void saveOrUpdateAppHttpCfg(AppHttpCfg entity) throws Exception {
|
||
// 设置区域运营商信息
|
||
setAreaEffectiveIds(entity);
|
||
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);
|
||
}
|
||
entity.setCompileId(compileId);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.insertAppHttpCfg(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgRegionCode", "cfgType" });
|
||
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.info("获取编译ID出错");
|
||
throw new MaatConvertException(e.getMessage());
|
||
}
|
||
} else {
|
||
entity.setEditorId(entity.getCurrentUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.updateAppHttpCfg(entity);
|
||
|
||
// 删除旧的区域IP,新增新的区域IP
|
||
AreaIpCfg area = new AreaIpCfg();
|
||
area.setCompileId(entity.getCompileId());
|
||
area.setFunctionId(entity.getFunctionId());
|
||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||
public void saveOrUpdateAppDomainCfg(AppDomainCfg entity) throws Exception {
|
||
// 设置区域运营商信息
|
||
setAreaEffectiveIds(entity);
|
||
|
||
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);
|
||
}
|
||
entity.setCompileId(compileId);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.insertAppDomainCfg(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.info("获取编译ID出错");
|
||
throw new MaatConvertException(e.getMessage());
|
||
}
|
||
} else {
|
||
entity.setEditorId(entity.getCurrentUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.updateAppDomainCfg(entity);
|
||
// 删除旧的区域IP,新增新的区域IP
|
||
AreaIpCfg area = new AreaIpCfg();
|
||
area.setCompileId(entity.getCompileId());
|
||
area.setFunctionId(entity.getFunctionId());
|
||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 主题网站新增 修改
|
||
public void saveOrUpdateAppTopicDomainCfg(AppTopicDomainCfg entity) throws Exception {
|
||
// 设置区域运营商信息
|
||
setAreaEffectiveIds(entity);
|
||
|
||
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);
|
||
}
|
||
entity.setCompileId(compileId);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.insertAppTopicDomainCfg(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.info("获取编译ID出错");
|
||
throw new MaatConvertException(e.getMessage());
|
||
}
|
||
} else {
|
||
entity.setEditorId(entity.getCurrentUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.updateAppTopicDomainCfg(entity);
|
||
// 删除旧的区域IP,新增新的区域IP
|
||
AreaIpCfg area = new AreaIpCfg();
|
||
area.setCompileId(entity.getCompileId());
|
||
area.setFunctionId(entity.getFunctionId());
|
||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||
public void saveOrUpdateAppByteCfg(AppByteCfg entity) throws Exception {
|
||
// 设置区域运营商信息
|
||
setAreaEffectiveIds(entity);
|
||
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);
|
||
}
|
||
entity.setCompileId(compileId);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.insertAppByteCfg(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.info("获取编译ID出错");
|
||
throw new MaatConvertException(e.getMessage());
|
||
}
|
||
} else {
|
||
entity.setEditorId(entity.getCurrentUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.updateAppByteCfg(entity);
|
||
// 删除旧的区域IP,新增新的区域IP
|
||
AreaIpCfg area = new AreaIpCfg();
|
||
area.setCompileId(entity.getCompileId());
|
||
area.setFunctionId(entity.getFunctionId());
|
||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||
public void saveOrUpdateAppSslCfg(AppSslCertCfg entity) throws Exception {
|
||
// 设置区域运营商信息
|
||
setAreaEffectiveIds(entity);
|
||
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);
|
||
}
|
||
entity.setCompileId(compileId);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.insertAppSslCfg(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.info("获取编译ID出错");
|
||
throw new MaatConvertException(e.getMessage());
|
||
}
|
||
} else {
|
||
entity.setEditorId(entity.getCurrentUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.updateAppSslCfg(entity);
|
||
|
||
// 删除旧的区域IP,新增新的区域IP
|
||
AreaIpCfg area = new AreaIpCfg();
|
||
area.setCompileId(entity.getCompileId());
|
||
area.setFunctionId(entity.getFunctionId());
|
||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||
public void saveOrUpdateAppTcpeCfg(AppTcpCfg entity) throws Exception {
|
||
// 设置区域运营商信息
|
||
setAreaEffectiveIds(entity);
|
||
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);
|
||
}
|
||
entity.setCompileId(compileId);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.insertAppTcpCfg(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.info("获取编译ID出错");
|
||
throw new MaatConvertException(e.getMessage());
|
||
}
|
||
} else {
|
||
entity.setEditorId(entity.getCurrentUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.updateAppTcpCfg(entity);
|
||
// 删除旧的区域IP,新增新的区域IP
|
||
AreaIpCfg area = new AreaIpCfg();
|
||
area.setCompileId(entity.getCompileId());
|
||
area.setFunctionId(entity.getFunctionId());
|
||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
public void auditAppTcpCfg(AppTcpCfg entity, Integer isAudit) {
|
||
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();
|
||
entity.setTableName(AppTcpCfg.getTablename());
|
||
appCfgDao.auditCfg(entity);
|
||
|
||
if (isAudit == 1) {
|
||
List<AppTcpCfg> list = new ArrayList();
|
||
list.add(entity);
|
||
Map<String, List> map = cfgConvert(numRegionList, list, 4, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
numRegionList = map.get("dstList");
|
||
}
|
||
/*
|
||
* //保存区域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()); appCfgDao.auditCfg(cfg);
|
||
* if(isAudit==1){ Map<String,List> map =
|
||
* cfgConvert(areaIpRegionList,areaIpCfgList,4,entity,groupRelationList);
|
||
* groupRelationList=map.get("groupList"); areaIpRegionList=map.get("dstList");
|
||
* } }
|
||
*/
|
||
// 构造提交综合服务参数格式,一条配置提交一次综合服务
|
||
if (isAudit == 1) {
|
||
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());
|
||
// 设置APP自定义域
|
||
String userRegion = "APP_ID=" + entity.getAppCode();
|
||
maatCfg.setUserRegion(userRegion);
|
||
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);
|
||
// 调用服务接口下发配置数据
|
||
String json = gsonToJson(maatBean);
|
||
logger.info("app SSL配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||
logger.info("app TCP配置下发响应信息:" + result.getMsg());
|
||
|
||
} else if (isAudit == 3) {
|
||
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("app TCP配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||
logger.info("app TCP配置取消配置响应信息:" + result.getMsg());
|
||
}
|
||
}
|
||
|
||
public void auditAppPolicyCfg(AppPolicyCfg entity, Integer isAudit) {
|
||
String configType = entity.getConfigType();
|
||
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();
|
||
entity.setTableName(AppPolicyCfg.getTablename());
|
||
List<NtcSubscribeIdCfg> ntcList = new ArrayList();
|
||
appCfgDao.auditCfg(entity);
|
||
// 更新关键字表状态
|
||
if (entity.getCompileId() != null) {
|
||
NtcSubscribeIdCfg ntc = new NtcSubscribeIdCfg();
|
||
ntc.setCompileId(entity.getCompileId());
|
||
ntc.setIsAudit(entity.getIsAudit());
|
||
ntc.setIsValid(entity.getIsValid());
|
||
ntc.setAuditorId(UserUtils.getUser().getId());
|
||
ntc.setAuditTime(entity.getAuditTime());
|
||
stringcfgDao.updateSubscribeIdCfg(ntc);
|
||
}
|
||
|
||
if (isAudit == 1) {
|
||
StringBuffer cfgKeywords = new StringBuffer();
|
||
if (entity.getBehavCode() != null) {
|
||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equalsIgnoreCase(configType)) {
|
||
cfgKeywords.append(Constants.APP_ID_REGION + "=" + entity.getAppCode());
|
||
} else if (Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equalsIgnoreCase(configType)
|
||
|| Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL.equalsIgnoreCase(configType)) {
|
||
cfgKeywords.append(Constants.PROTO_ID_REGION + "=" + entity.getAppCode());
|
||
}
|
||
cfgKeywords.append(Constants.KEYWORD_EXPR);
|
||
cfgKeywords.append(Constants.BEHAV_ID_REGION + "=" + entity.getBehavCode());
|
||
// entity.setCfgKeywords(entity.getAppCode()+Constants.KEYWORD_EXPR+entity.getBehavCode());
|
||
} else {
|
||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equalsIgnoreCase(configType)) {
|
||
cfgKeywords.append(Constants.APP_ID_REGION + "=" + entity.getAppCode());
|
||
} else if (Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equalsIgnoreCase(configType)
|
||
|| Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL.equalsIgnoreCase(configType)) {
|
||
cfgKeywords.append(Constants.PROTO_ID_REGION + "=" + entity.getAppCode());
|
||
}
|
||
// entity.setCfgKeywords(entity.getAppCode()+"");
|
||
}
|
||
entity.setCfgKeywords(cfgKeywords.toString());
|
||
List<AppPolicyCfg> list = new ArrayList();
|
||
list.add(entity);
|
||
Map<String, List> map = cfgConvert(strRegionList, list, 2, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
strRegionList = map.get("dstList");
|
||
}
|
||
|
||
// 查询子配置并修改审核状态
|
||
entity = this.getAppPolicyCfg(entity.getCfgId());
|
||
if (entity.getIpPortList() != null && entity.getIpPortList().size() > 0) {
|
||
IpPortCfg cfg = new IpPortCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(IpPortCfg.getTablename());
|
||
appCfgDao.auditCfg(cfg);
|
||
if (isAudit == 1) {
|
||
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"));
|
||
}
|
||
}
|
||
}
|
||
if (entity.getNtcSubscribeIdCfgList() != null && entity.getNtcSubscribeIdCfgList().size() > 0) {
|
||
if (isAudit == 1) {
|
||
Map<String, List> ntcMap = cfgConvert(strRegionList, entity.getNtcSubscribeIdCfgList(), 2, entity,
|
||
groupRelationList);
|
||
groupRelationList = ntcMap.get("groupList");
|
||
strRegionList = ntcMap.get("dstList");
|
||
}
|
||
}
|
||
|
||
// 保存区域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());
|
||
appCfgDao.auditCfg(cfg);
|
||
if (isAudit == 1) {
|
||
Map<String, List> map = cfgConvert(areaIpRegionList, areaIpCfgList, 1, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
areaIpRegionList = map.get("dstList");
|
||
}
|
||
}
|
||
// 构造提交综合服务参数格式,一条配置提交一次综合服务
|
||
if (isAudit == 1) {
|
||
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());
|
||
String userRegion = null;
|
||
if (Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equalsIgnoreCase(configType)) {
|
||
// 设置APP自定义域
|
||
userRegion = Constants.APP_ID_REGION + "=" + entity.getAppCode();
|
||
if (entity.getBehavCode() != null) {
|
||
userRegion += Constants.USER_REGION_SPLIT + Constants.BEHAV_ID_REGION + "=" + entity.getBehavCode();
|
||
}
|
||
} else if (Constants.SPECIFIC_SERVICE_CFG_TYPE_BASIC_PROTOCOL.equalsIgnoreCase(configType)) {
|
||
userRegion = Constants.PROTO_ID_REGION + "=" + entity.getAppCode();
|
||
} else if (Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equalsIgnoreCase(configType)) {
|
||
userRegion = Constants.PROTO_ID_REGION + "=" + entity.getAppCode();
|
||
if (entity.getBehavCode() != null) {
|
||
userRegion += Constants.USER_REGION_SPLIT + Constants.BEHAV_ID_REGION + "=" + entity.getBehavCode();
|
||
}
|
||
|
||
}
|
||
// 限速业务需要设置
|
||
String actionCode = DictUtils.getDictCode("SERVICE_ACTION", "action_ratelimit");
|
||
if (!actionCode.equals("默认")) {
|
||
if (entity.getAction().equals(Integer.parseInt(actionCode))) {
|
||
userRegion += Constants.USER_REGION_SPLIT + Constants.RATE_LIMIT_REGION + "="
|
||
+ entity.getRatelimit();
|
||
}
|
||
}
|
||
maatCfg.setUserRegion(userRegion);
|
||
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);
|
||
// 调用服务接口下发配置数据
|
||
String json = gsonToJson(maatBean);
|
||
logger.info("app策略配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||
logger.info("app策略配置下发响应信息:" + result.getMsg());
|
||
|
||
} else if (isAudit == 3) {
|
||
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("app策略配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||
logger.info("app策略配置取消配置响应信息:" + result.getMsg());
|
||
}
|
||
}
|
||
|
||
public void auditAppIpCfg(AppIpCfg entity, Integer isAudit) {
|
||
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();
|
||
entity.setTableName(AppIpCfg.getTablename());
|
||
appCfgDao.auditCfg(entity);
|
||
if (isAudit == 1) {
|
||
List<AppIpCfg> list = new ArrayList();
|
||
list.add(entity);
|
||
Map<String, List> map = cfgConvert(ipRegionList, list, 1, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
ipRegionList = map.get("dstList");
|
||
}
|
||
// 保存区域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());
|
||
appCfgDao.auditCfg(cfg);
|
||
if (isAudit == 1) {
|
||
Map<String, List> map = cfgConvert(areaIpRegionList, areaIpCfgList, 1, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
areaIpRegionList = map.get("dstList");
|
||
}
|
||
}
|
||
// 构造提交综合服务参数格式,一条配置提交一次综合服务
|
||
if (isAudit == 1) {
|
||
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());
|
||
// 设置APP自定义域
|
||
String userRegion = "APP_ID=" + entity.getAppCode();
|
||
maatCfg.setUserRegion(userRegion);
|
||
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);
|
||
// 调用服务接口下发配置数据
|
||
String json = gsonToJson(maatBean);
|
||
logger.info("app协议IP配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||
logger.info("app协议IP配置下发响应信息:" + result.getMsg());
|
||
|
||
} else if (isAudit == 3) {
|
||
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("app协议IP配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||
logger.info("app协议IP配置取消配置响应信息:" + result.getMsg());
|
||
}
|
||
}
|
||
|
||
public void auditAppHttpCfg(AppHttpCfg entity, Integer isAudit) {
|
||
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();
|
||
entity.setTableName(AppHttpCfg.getTablename());
|
||
appCfgDao.auditCfg(entity);
|
||
|
||
if (isAudit == 1) {
|
||
List<AppHttpCfg> list = new ArrayList();
|
||
list.add(entity);
|
||
Map<String, List> map = cfgConvert(strRegionList, list, 2, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
strRegionList = map.get("dstList");
|
||
}
|
||
// 保存区域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());
|
||
appCfgDao.auditCfg(cfg);
|
||
if (isAudit == 1) {
|
||
Map<String, List> map = cfgConvert(areaIpRegionList, areaIpCfgList, 1, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
areaIpRegionList = map.get("dstList");
|
||
}
|
||
}
|
||
// 构造提交综合服务参数格式,一条配置提交一次综合服务
|
||
if (isAudit == 1) {
|
||
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());
|
||
// 设置APP自定义域
|
||
String userRegion = "APP_ID=" + entity.getAppCode();
|
||
maatCfg.setUserRegion(userRegion);
|
||
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);
|
||
// 调用服务接口下发配置数据
|
||
String json = gsonToJson(maatBean);
|
||
logger.info("app HTTP配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||
logger.info("app HTTP配置下发响应信息:" + result.getMsg());
|
||
|
||
} else if (isAudit == 3) {
|
||
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("app HTTP配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||
logger.info("app HTTP配置取消配置响应信息:" + result.getMsg());
|
||
}
|
||
}
|
||
|
||
public void auditAppDomainCfg(AppDomainCfg entity, Integer isAudit) {
|
||
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();
|
||
entity.setTableName(AppDomainCfg.getTablename());
|
||
appCfgDao.auditCfg(entity);
|
||
if (isAudit == 1) {
|
||
entity.setCfgKeywords(entity.getDomain());
|
||
List<AppDomainCfg> list = new ArrayList();
|
||
list.add(entity);
|
||
Map<String, List> map = cfgConvert(strRegionList, list, 2, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
strRegionList = map.get("dstList");
|
||
}
|
||
// 保存区域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());
|
||
appCfgDao.auditCfg(cfg);
|
||
if (isAudit == 1) {
|
||
Map<String, List> map = cfgConvert(areaIpRegionList, areaIpCfgList, 1, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
areaIpRegionList = map.get("dstList");
|
||
}
|
||
}
|
||
// 构造提交综合服务参数格式,一条配置提交一次综合服务
|
||
if (isAudit == 1) {
|
||
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());
|
||
// 设置APP自定义域
|
||
String userRegion = "APP_ID=" + entity.getAppCode() + Constants.USER_REGION_SPLIT + "DOMAIN_ID="
|
||
+ entity.getCompileId() + Constants.USER_REGION_SPLIT + "DOMAIN_STR="
|
||
+ keywordsEscape(entity.getDomain());
|
||
maatCfg.setUserRegion(userRegion);
|
||
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);
|
||
// 调用服务接口下发配置数据
|
||
String json = gsonToJson(maatBean);
|
||
logger.info("app域名配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||
logger.info("app域名配置下发响应信息:" + result.getMsg());
|
||
|
||
} else if (isAudit == 3) {
|
||
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("app域名配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||
logger.info("app域名配置取消配置响应信息:" + result.getMsg());
|
||
}
|
||
}
|
||
|
||
// app主题网站配置审核
|
||
public void auditAppTopicDomainCfg(AppTopicDomainCfg entity, Integer isAudit) {
|
||
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();
|
||
entity.setTableName(AppTopicDomainCfg.getTablename());
|
||
appCfgDao.auditCfg(entity);
|
||
// 域名为关键字
|
||
if (isAudit == 1) {
|
||
entity.setCfgKeywords(entity.getDomain());
|
||
List<AppTopicDomainCfg> list = new ArrayList();
|
||
list.add(entity);
|
||
Map<String, List> map = cfgConvert(strRegionList, list, 2, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
strRegionList = map.get("dstList");
|
||
}
|
||
// 保存区域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());
|
||
appCfgDao.auditCfg(cfg);
|
||
if (isAudit == 1) {
|
||
Map<String, List> map = cfgConvert(areaIpRegionList, areaIpCfgList, 1, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
areaIpRegionList = map.get("dstList");
|
||
}
|
||
}
|
||
// 构造提交综合服务参数格式,一条配置提交一次综合服务
|
||
if (isAudit == 1) {
|
||
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());
|
||
|
||
// 设置APP自定义域
|
||
// "APP_ID="+entity.getAppCode()+Constants.USER_REGION_SPLIT+
|
||
String userRegion = "DOMAIN_ID=" + entity.getCompileId() + Constants.USER_REGION_SPLIT + "DOMAIN_STR="
|
||
+ keywordsEscape(entity.getDomain());
|
||
|
||
maatCfg.setUserRegion(userRegion);
|
||
|
||
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);
|
||
// 调用服务接口下发配置数据
|
||
String json = gsonToJson(maatBean);
|
||
logger.info("app主题网站配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||
logger.info("app主题网站配置下发响应信息:" + result.getMsg());
|
||
|
||
} else if (isAudit == 3) {
|
||
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("app主题网站配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||
logger.info("app主题网站配置取消配置响应信息:" + result.getMsg());
|
||
}
|
||
}
|
||
|
||
public void auditAppByteCfg(AppByteCfg entity, Integer isAudit) {
|
||
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();
|
||
entity.setTableName(AppByteCfg.getTablename());
|
||
appCfgDao.auditCfg(entity);
|
||
|
||
if (isAudit == 1) {
|
||
entity.setCfgKeywords(entity.getBytes());
|
||
List<AppByteCfg> list = new ArrayList();
|
||
list.add(entity);
|
||
Map<String, List> map = cfgConvert(strRegionList, list, 2, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
strRegionList = map.get("dstList");
|
||
}
|
||
// 保存区域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());
|
||
appCfgDao.auditCfg(cfg);
|
||
if (isAudit == 1) {
|
||
Map<String, List> map = cfgConvert(areaIpRegionList, areaIpCfgList, 1, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
areaIpRegionList = map.get("dstList");
|
||
}
|
||
}
|
||
// 构造提交综合服务参数格式,一条配置提交一次综合服务
|
||
if (isAudit == 1) {
|
||
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());
|
||
// 设置用户自定义域
|
||
String userRegion = "APP_ID=" + entity.getAppCode();
|
||
maatCfg.setUserRegion(userRegion);
|
||
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);
|
||
// 调用服务接口下发配置数据
|
||
String json = gsonToJson(maatBean);
|
||
logger.info("app字节配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||
logger.info("app字节配置下发响应信息:" + result.getMsg());
|
||
|
||
} else if (isAudit == 3) {
|
||
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("app字节配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||
logger.info("app字节配置取消配置响应信息:" + result.getMsg());
|
||
}
|
||
}
|
||
|
||
public void auditAppSslCfg(AppSslCertCfg entity, Integer isAudit) {
|
||
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();
|
||
entity.setTableName(AppSslCertCfg.getTablename());
|
||
appCfgDao.auditCfg(entity);
|
||
|
||
if (isAudit == 1) {
|
||
List<AppSslCertCfg> list = new ArrayList();
|
||
list.add(entity);
|
||
Map<String, List> map = cfgConvert(strRegionList, list, 3, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
strRegionList = map.get("dstList");
|
||
}
|
||
// 保存区域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());
|
||
appCfgDao.auditCfg(cfg);
|
||
if (isAudit == 1) {
|
||
Map<String, List> map = cfgConvert(areaIpRegionList, areaIpCfgList, 1, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
areaIpRegionList = map.get("dstList");
|
||
}
|
||
}
|
||
// 构造提交综合服务参数格式,一条配置提交一次综合服务
|
||
if (isAudit == 1) {
|
||
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());
|
||
// 设置APP自定义域
|
||
String userRegion = "APP_ID=" + entity.getAppCode();
|
||
maatCfg.setUserRegion(userRegion);
|
||
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);
|
||
// 调用服务接口下发配置数据
|
||
String json = gsonToJson(maatBean);
|
||
logger.info("app SSL配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||
logger.info("app SSL配置下发响应信息:" + result.getMsg());
|
||
|
||
} else if (isAudit == 3) {
|
||
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("app SSL配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||
logger.info("app SSL配置取消配置响应信息:" + result.getMsg());
|
||
}
|
||
}
|
||
|
||
public void updateAppPolicyCfgValid(Integer isValid, String ids, Integer functionId) {
|
||
AppPolicyCfg entity = new AppPolicyCfg();
|
||
String[] idArray = ids.split(",");
|
||
for (String id : idArray) {
|
||
entity.setCfgId(Long.parseLong(id));
|
||
entity.setIsValid(isValid);
|
||
entity.setEditorId(UserUtils.getUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setTableName(AppPolicyCfg.getTablename());
|
||
entity.setFunctionId(functionId);
|
||
appCfgDao.updateCfgValid(entity);
|
||
|
||
// 查询子配置
|
||
entity = this.getAppPolicyCfg(Long.parseLong(id));
|
||
if (entity.getIpPortList() != null && entity.getIpPortList().size() > 0) {
|
||
IpPortCfg cfg = new IpPortCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(IpPortCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
// 删除关键字
|
||
if (entity.getNtcSubscribeIdCfgList() != null && entity.getNtcSubscribeIdCfgList().size() > 0) {
|
||
NtcSubscribeIdCfg ntcSubscribeIdCfg = new NtcSubscribeIdCfg();
|
||
BeanUtils.copyProperties(entity, ntcSubscribeIdCfg, new String[] { "cfgId" });
|
||
stringcfgDao.updateSubscribeIdCfg(ntcSubscribeIdCfg);
|
||
}
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null && entity.getAreaCfg().size() > 0) {
|
||
AreaIpCfg cfg = new AreaIpCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(AreaIpCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public void updateAppIpCfgValid(Integer isValid, String ids, Integer functionId) {
|
||
AppIpCfg entity = new AppIpCfg();
|
||
String[] idArray = ids.split(",");
|
||
for (String id : idArray) {
|
||
entity.setCfgId(Long.parseLong(id));
|
||
entity.setIsValid(isValid);
|
||
entity.setEditorId(UserUtils.getUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setTableName(AppIpCfg.getTablename());
|
||
entity.setFunctionId(functionId);
|
||
appCfgDao.updateCfgValid(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null && entity.getAreaCfg().size() > 0) {
|
||
AreaIpCfg cfg = new AreaIpCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(AreaIpCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public void updateAppTcpCfgValid(Integer isValid, String ids, Integer functionId) {
|
||
AppTcpCfg entity = new AppTcpCfg();
|
||
String[] idArray = ids.split(",");
|
||
for (String id : idArray) {
|
||
entity.setCfgId(Long.parseLong(id));
|
||
entity.setIsValid(isValid);
|
||
entity.setEditorId(UserUtils.getUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setTableName(AppTcpCfg.getTablename());
|
||
entity.setFunctionId(functionId);
|
||
appCfgDao.updateCfgValid(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null && entity.getAreaCfg().size() > 0) {
|
||
AreaIpCfg cfg = new AreaIpCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(AreaIpCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public void updateAppHttpCfgValid(Integer isValid, String ids, Integer functionId) {
|
||
AppHttpCfg entity = new AppHttpCfg();
|
||
String[] idArray = ids.split(",");
|
||
for (String id : idArray) {
|
||
entity.setCfgId(Long.parseLong(id));
|
||
entity.setIsValid(isValid);
|
||
entity.setEditorId(UserUtils.getUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setTableName(AppHttpCfg.getTablename());
|
||
entity.setFunctionId(functionId);
|
||
appCfgDao.updateCfgValid(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null && entity.getAreaCfg().size() > 0) {
|
||
AreaIpCfg cfg = new AreaIpCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(AreaIpCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public void updateAppDomainCfgValid(Integer isValid, String ids, Integer functionId) {
|
||
AppDomainCfg entity = new AppDomainCfg();
|
||
String[] idArray = ids.split(",");
|
||
for (String id : idArray) {
|
||
entity.setCfgId(Long.parseLong(id));
|
||
entity.setIsValid(isValid);
|
||
entity.setEditorId(UserUtils.getUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setTableName(AppDomainCfg.getTablename());
|
||
entity.setFunctionId(functionId);
|
||
appCfgDao.updateCfgValid(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null && entity.getAreaCfg().size() > 0) {
|
||
AreaIpCfg cfg = new AreaIpCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(AreaIpCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
// 主题网站配置删除
|
||
public void updateAppTopicDomainCfgValid(Integer isValid, String ids, Integer functionId) {
|
||
AppTopicDomainCfg entity = new AppTopicDomainCfg();
|
||
String[] idArray = ids.split(",");
|
||
for (String id : idArray) {
|
||
entity.setCfgId(Long.parseLong(id));
|
||
entity.setIsValid(isValid);
|
||
entity.setEditorId(UserUtils.getUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setTableName(AppTopicDomainCfg.getTablename());
|
||
entity.setFunctionId(functionId);
|
||
appCfgDao.updateCfgValid(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null && entity.getAreaCfg().size() > 0) {
|
||
AreaIpCfg cfg = new AreaIpCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(AreaIpCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public void updateAppByteCfgValid(Integer isValid, String ids, Integer functionId) {
|
||
AppByteCfg entity = new AppByteCfg();
|
||
String[] idArray = ids.split(",");
|
||
for (String id : idArray) {
|
||
entity.setCfgId(Long.parseLong(id));
|
||
entity.setIsValid(isValid);
|
||
entity.setEditorId(UserUtils.getUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setTableName(AppByteCfg.getTablename());
|
||
entity.setFunctionId(functionId);
|
||
appCfgDao.updateCfgValid(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null && entity.getAreaCfg().size() > 0) {
|
||
AreaIpCfg cfg = new AreaIpCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(AreaIpCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public void updateAppSslCfgValid(Integer isValid, String ids, Integer functionId) {
|
||
AppSslCertCfg entity = new AppSslCertCfg();
|
||
String[] idArray = ids.split(",");
|
||
for (String id : idArray) {
|
||
entity.setCfgId(Long.parseLong(id));
|
||
entity.setIsValid(isValid);
|
||
entity.setEditorId(UserUtils.getUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setTableName(AppSslCertCfg.getTablename());
|
||
entity.setFunctionId(functionId);
|
||
appCfgDao.updateCfgValid(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null && entity.getAreaCfg().size() > 0) {
|
||
AreaIpCfg cfg = new AreaIpCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(AreaIpCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public void updateAppHeaderCfgValid(Integer isValid, String ids, Integer functionId) {
|
||
AppHeaderCfg entity = new AppHeaderCfg();
|
||
String[] idArray = ids.split(",");
|
||
for (String id : idArray) {
|
||
entity.setCfgId(Long.parseLong(id));
|
||
entity.setIsValid(isValid);
|
||
entity.setEditorId(UserUtils.getUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setTableName(AppHeaderCfg.getTablename());
|
||
entity.setFunctionId(functionId);
|
||
appCfgDao.updateCfgValid(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null && entity.getAreaCfg().size() > 0) {
|
||
AreaIpCfg cfg = new AreaIpCfg();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgId" });
|
||
cfg.setTableName(AreaIpCfg.getTablename());
|
||
appCfgDao.updateCfgValid(cfg);
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public Page<AppHeaderCfg> findAppHeaderList(Page<AppHeaderCfg> page, AppHeaderCfg entity) {
|
||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(), "r"));
|
||
entity.setPage(page);
|
||
List<AppHeaderCfg> list = appCfgDao.findAppHeaderList(entity);
|
||
page.setList(list);
|
||
return page;
|
||
}
|
||
|
||
public AppHeaderCfg getAppHeaderCfg(Long cfgId) {
|
||
return appCfgDao.getAppHeaderCfg(cfgId);
|
||
}
|
||
|
||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||
public void saveOrUpdateAppHeaderCfg(AppHeaderCfg entity) throws Exception {
|
||
// 设置区域运营商信息
|
||
setAreaEffectiveIds(entity);
|
||
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);
|
||
}
|
||
entity.setCompileId(compileId);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.insertAppHeaderCfg(entity);
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
logger.info("获取编译ID出错");
|
||
throw new MaatConvertException(e.getMessage());
|
||
}
|
||
} else {
|
||
entity.setEditorId(entity.getCurrentUser().getId());
|
||
entity.setEditTime(new Date());
|
||
entity.setIsValid(0);
|
||
entity.setIsAudit(0);
|
||
appCfgDao.updateAppHeaderCfg(entity);
|
||
|
||
// 删除旧的区域IP,新增新的区域IP
|
||
AreaIpCfg area = new AreaIpCfg();
|
||
area.setCompileId(entity.getCompileId());
|
||
area.setFunctionId(entity.getFunctionId());
|
||
areaIpCfgDao.deleteAreaIpCfg(area);
|
||
entity.setCreateTime(new Date());
|
||
entity.setCreatorId(entity.getCurrentUser().getId());
|
||
// 保存区域IP信息
|
||
if (entity.getAreaCfg() != null) {
|
||
for (AreaIpCfg cfg : entity.getAreaCfg()) {
|
||
cfg.initDefaultValue();
|
||
BeanUtils.copyProperties(entity, cfg, new String[] { "cfgDesc", "cfgRegionCode", "cfgType" });
|
||
areaIpCfgDao.saveAreaIpCfg(cfg);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public void auditAppHeaderCfg(AppHeaderCfg entity, Integer isAudit) {
|
||
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();
|
||
entity.setTableName(AppHeaderCfg.getTablename());
|
||
appCfgDao.auditCfg(entity);
|
||
|
||
if (isAudit == 1) {
|
||
List<AppHeaderCfg> list = new ArrayList();
|
||
list.add(entity);
|
||
Map<String, List> map = cfgConvert(strRegionList, list, 3, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
strRegionList = map.get("dstList");
|
||
}
|
||
// 保存区域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());
|
||
appCfgDao.auditCfg(cfg);
|
||
if (isAudit == 1) {
|
||
Map<String, List> map = cfgConvert(areaIpRegionList, areaIpCfgList, 1, entity, groupRelationList);
|
||
groupRelationList = map.get("groupList");
|
||
areaIpRegionList = map.get("dstList");
|
||
}
|
||
}
|
||
// 构造提交综合服务参数格式,一条配置提交一次综合服务
|
||
if (isAudit == 1) {
|
||
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());
|
||
// 设置APP自定义域
|
||
String userRegion = "APP_ID=" + entity.getAppCode();
|
||
maatCfg.setUserRegion(userRegion);
|
||
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);
|
||
// 调用服务接口下发配置数据
|
||
String json = gsonToJson(maatBean);
|
||
logger.info("app Header配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||
logger.info("app Header配置下发响应信息:" + result.getMsg());
|
||
|
||
} else if (isAudit == 3) {
|
||
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("app Header配置下发配置参数:" + json);
|
||
// 调用服务接口下发配置
|
||
ToMaatResult result = ConfigServiceUtil.put(json, 1);
|
||
logger.info("app Header配置取消配置响应信息:" + result.getMsg());
|
||
}
|
||
}
|
||
}
|