This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-ntc/src/main/java/com/nis/web/service/configuration/AvContentCfgService.java
duandongmei bf8db3e47e 音视频文本去掉区域id的单独处理
增加表达式,默认匹配方式为子串匹配
voip列表字符串信息显示属性位置调整
2018-06-11 13:59:42 +08:00

1517 lines
53 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.nis.web.service.configuration;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
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.AreaBean;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.AvVoipAccountCfg;
import com.nis.domain.configuration.AvVoipIpCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.maat.MaatCfg;
import com.nis.domain.maat.ToMaatBean;
import com.nis.domain.maat.ToMaatResult;
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.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.StringUtil;
import com.nis.util.StringUtils;
import com.nis.web.dao.configuration.AreaIpCfgDao;
import com.nis.web.dao.configuration.AvContentCfgDao;
import com.nis.web.security.UserUtils;
import com.nis.web.service.BaseService;
/**
* 音视频文本
* @author dell
*
*/
@Service
public class AvContentCfgService extends BaseService{
@Autowired
protected AvContentCfgDao avContentCfgDao;
@Autowired
protected AreaIpCfgDao areaIpCfgDao;
/********************************voip业务*********************************/
/**
* 查询分页数据
* @param page 分页对象
* @param entity
* @return
*/
public Page<CfgIndexInfo> findPage(Page<CfgIndexInfo> page, CfgIndexInfo entity) {
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
entity.setPage(page);
List<CfgIndexInfo> list=avContentCfgDao.findVoipList(entity);
page.setList(list);
return page;
}
/**
* 根据索引表信息获取voipIpCfg信息
* @param entity
* @return
*/
public List<AvVoipIpCfg> getVoipIpCfgList(CfgIndexInfo entity) {
return avContentCfgDao.findVoipIpCfgList(entity);
}
/**
* 根据索引表信息获取voipAccountCfg信息
* @param entity
* @return
*/
public List<AvVoipAccountCfg> getVoipAccountCfgList(CfgIndexInfo entity) {
return avContentCfgDao.findVoipAccountCfgList(entity);
}
/**
* 根据索引表信息获取voipAccountCfg信息
* @param entity
* @return
*/
public CfgIndexInfo getCfgIndexInfo(CfgIndexInfo entity) {
CfgIndexInfo cfg=avContentCfgDao.getCfgIndexInfo(entity);
List<AvVoipAccountCfg> voipAccounts=new ArrayList<>();
voipAccounts=getVoipAccountCfgList(entity);
if(voipAccounts ==null || voipAccounts.size() <=0){
voipAccounts.add(new AvVoipAccountCfg());
}
List<AvVoipIpCfg> voipIps=new ArrayList<>();
voipIps=getVoipIpCfgList(entity);
if(voipIps ==null || voipIps.size() <=0){
voipIps.add(new AvVoipIpCfg());
}
cfg.setVoipAccounts(voipAccounts);
cfg.setVoipIps(voipIps);
return cfg;
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdateAvVoip(CfgIndexInfo entity,String voipIpIds,String voipAccountIds,String areaCfgIds){
Date createTime=new Date();
//设置区域运营商信息
setAreaEffectiveIds(entity);
//新增
if(entity.getCfgId()==null){
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
entity.setIsValid(0);
entity.setIsAudit(0);
//调用服务接口获取compileId
List<Integer> compileIds = new ArrayList<Integer>();
try {
compileIds = ConfigServiceUtil.getId(1,1);
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
if(compileIds != null && compileIds.size() >0 && compileIds.get(0) != 0){
entity.setCompileId(compileIds.get(0));
//保存avVoipIp
if(entity.getVoipIps() != null && entity.getVoipIps().size() > 0){
for (AvVoipIpCfg voipIp : entity.getVoipIps()) {
entity.setVoipIp(voipIp);
avContentCfgDao.insertAvVoipIp(entity);
}
}
//保存avVoipAccount
if(entity.getVoipAccounts() != null && entity.getVoipAccounts().size() > 0){
for (AvVoipAccountCfg voipAccount : entity.getVoipAccounts()) {
entity.setVoipAccount(voipAccount);
avContentCfgDao.insertAvVoipAccount(entity);
}
}
//保存区域IP信息
if(entity.getAreaCfg()!=null&&entity.getAreaCfg().size()>0){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType"});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
//保存cfgIndexInfo
avContentCfgDao.insertCfgIndexInfo(entity);
}else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
//修改
}else{
Date editTime=new Date();
entity.setIsValid(0);
entity.setIsAudit(0);
voipIpIds=!StringUtil.isEmpty(voipIpIds)? voipIpIds+",":"";
voipAccountIds=!StringUtil.isEmpty(voipAccountIds)? voipAccountIds+",":"";
areaCfgIds=!StringUtil.isEmpty(areaCfgIds)? ","+areaCfgIds:"";
//判断voip信息为新增还是修改清楚voipIpIds修改的voipId记录剩下即为需要删除的voipId
if(!StringUtil.isEmpty(entity.getVoipIps())){
for (AvVoipIpCfg voipIp : entity.getVoipIps()) {
if(!StringUtil.isEmpty(voipIp.getCfgId())){
if(voipIpIds.contains(","+voipIp.getCfgId()+",")){
voipIpIds=voipIpIds.replace(voipIp.getCfgId()+",", "");
}
//修改
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
entity.setVoipIp(voipIp);
avContentCfgDao.updateAvVoipIp(entity);
}else{
//新增
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
entity.setVoipIp(voipIp);
avContentCfgDao.insertAvVoipIp(entity);
}
}
}
if(!StringUtil.isEmpty(entity.getVoipAccounts())){
for (AvVoipAccountCfg voipAccount : entity.getVoipAccounts()) {
if(!StringUtil.isEmpty(voipAccount.getCfgId())){
if(voipAccountIds.contains(","+voipAccount.getCfgId()+",")){
voipAccountIds=voipAccountIds.replace(voipAccount.getCfgId()+",", "");
}
//修改
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
entity.setVoipAccount(voipAccount);
avContentCfgDao.updateAvVoipAccount(entity);
}else{
//新增
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
entity.setVoipAccount(voipAccount);
avContentCfgDao.insertAvVoipAccount(entity);
}
}
}
if(!StringUtil.isEmpty(entity.getAreaCfg())){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
if(!StringUtil.isEmpty(areaIpCfg.getCfgId())){
if(areaCfgIds.contains(","+areaIpCfg.getCfgId()+",")){
areaCfgIds=areaCfgIds.replace(areaIpCfg.getCfgId()+",", "");
}
//修改
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType","cfgId"});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
}else{
//新增
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"ipType"
,"ipPattern"
,"srcIpAddress"
,"portPattern"
,"srcPort"
,"destPort"
,"protocol"
,"direction"
,"protocolId"
});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
}
//delete 真是删除voipAccount信息
if(!StringUtil.isEmpty(voipAccountIds.replaceAll(",", ""))){
voipAccountIds=voipAccountIds.substring(1,voipAccountIds.length());
for (String cfgId : voipAccountIds.split(",")) {
CfgIndexInfo cfg=new CfgIndexInfo();
AvVoipAccountCfg voipAccountCfg=new AvVoipAccountCfg();
voipAccountCfg.setCfgId(Long.parseLong(cfgId));
cfg.setVoipAccount(voipAccountCfg);
avContentCfgDao.deleteAvVoipAccount(cfg);
}
}
//delete 真是删除voipAccount信息
if(!StringUtil.isEmpty(voipIpIds.replaceAll(",", ""))){
voipIpIds=voipIpIds.substring(1,voipIpIds.length());
for (String cfgId : voipIpIds.split(",")) {
CfgIndexInfo cfg=new CfgIndexInfo();
AvVoipIpCfg voipIpCfg=new AvVoipIpCfg();
voipIpCfg.setCfgId(Long.parseLong(cfgId));
cfg.setVoipIp(voipIpCfg);
avContentCfgDao.deleteAvVoipIp(cfg);
}
}
//delete 真是删除areaIpCfg信息
if(!StringUtil.isEmpty(areaCfgIds.replaceAll(",", ""))){
areaCfgIds=areaCfgIds.substring(1,areaCfgIds.length());
for (String cfgId : areaCfgIds.split(",")) {
CfgIndexInfo cfg=new CfgIndexInfo();
AreaIpCfg areaIpCfg=new AreaIpCfg();
areaIpCfg.setCfgId(Long.parseLong(cfgId));
areaIpCfgDao.deleteAreaIpCfgByCfgId(areaIpCfg);
}
}
//修改
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
avContentCfgDao.updateCfgIndexInfo(entity);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids compileIds
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void updateAvVoipValid(Integer isAudit,Integer isValid,String ids,Integer functionId){
CfgIndexInfo entity = new CfgIndexInfo();
String[] idArray = ids.split(",");
for(String id :idArray){
entity.setCompileId(Integer.parseInt(id));
entity.setFunctionId(functionId);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
avContentCfgDao.updateAvVoipIp(entity);
avContentCfgDao.updateAvVoipAccount(entity);
avContentCfgDao.updateCfgIndexInfo(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg);
areaIpCfgDao.updateAreaIpCfgValid(areaIpCfg);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids 编译Id
* @param functionId
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void auditAvVoip(Integer isAudit,Integer isValid,Integer functionId,String compileId,Date auditTime){
CfgIndexInfo entity = new CfgIndexInfo();
List<CfgIndexInfo> list = new ArrayList();
List<AvVoipIpCfg> voipIpList = new ArrayList();
List<AvVoipAccountCfg> voipAccountList = new ArrayList();
List<AreaIpCfg> areaIpCfgList = new ArrayList();
CfgIndexInfo searchCfg=new CfgIndexInfo();
searchCfg.setCompileId(Integer.parseInt(compileId));
entity = avContentCfgDao.getCfgIndexInfo(searchCfg);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(auditTime);
avContentCfgDao.updateAvVoipIp(entity);
avContentCfgDao.updateAvVoipAccount(entity);
avContentCfgDao.updateCfgIndexInfo(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType","cfgId"});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
voipIpList=avContentCfgDao.findVoipIpCfgList(entity);
voipAccountList=avContentCfgDao.findVoipAccountCfgList(entity);
areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
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();
if(isAudit==1){
if(!StringUtil.isEmpty(voipIpList)){
//TODO DELETE后期删除
for (AvVoipIpCfg ipCfg : voipIpList) {
ipCfg.setCfgType("MM_VOIP_IP");
}
Map<String,List> ipMap = cfgConvert(ipRegionList,voipIpList,1,entity,groupRelationList);
groupRelationList=ipMap.get("groupList");
ipRegionList=ipMap.get("dstList");
}
if(!StringUtil.isEmpty(voipAccountList)){
//TODO DELETE后期删除
for (AvVoipAccountCfg accountCfg : voipAccountList) {
accountCfg.setCfgType("MM_VOIP_ACCOUNT");
}
Map<String,List> accountMap = cfgConvert(strRegionList,voipAccountList,2,entity,groupRelationList);
groupRelationList=accountMap.get("groupList");
strRegionList=accountMap.get("dstList");
}
if(!StringUtil.isEmpty(areaIpCfgList)){
//TODO DELETE后期删除
for (AreaIpCfg areaIpCfga : areaIpCfgList) {
areaIpCfga.setCfgType("NTC_IP_RANGE");
}
Map<String,List> areaMap = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList);
groupRelationList=areaMap.get("groupList");
areaIpRegionList=areaMap.get("dstList");
}
}
//构造提交综合服务参数格式,一条配置提交一次综合服务
if(isAudit==1){
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(auditTime);
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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("voip配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("voip配置下发响应信息"+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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("voip配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("voip配置取消配置响应信息"+result.getMsg());
}
}
/********************************voip业务*********************************/
/********************************contIp业务*********************************/
/**
* contIp查询分页数据
* @param page 分页对象
* @param entity
* @return
*/
public Page<BaseIpCfg> findContIpPage(Page page, BaseIpCfg entity) {
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
entity.setPage(page);
entity.setTableName("av_cont_ip_cfg");
List<BaseIpCfg> list=avContentCfgDao.findIpList(entity);
page.setList(list);
return page;
}
/**
* contUp根据id查询contIpCfg信息
* @param entity
* @return
*/
public BaseIpCfg getContIpCfgById(BaseIpCfg entity) {
entity.setTableName("av_cont_ip_cfg");
return avContentCfgDao.findIpCfgById(entity);
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdateContIp(BaseIpCfg entity,String areaCfgIds){
Date createTime=new Date();
entity.setTableName("av_cont_ip_cfg");
//设置区域运营商信息
setAreaEffectiveIds(entity);
//新增
if(entity.getCfgId()==null){
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
entity.setIsValid(0);
entity.setIsAudit(0);
//调用服务接口获取compileId
List<Integer> compileIds = new ArrayList<Integer>();
try {
compileIds = ConfigServiceUtil.getId(1,1);
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
if(compileIds != null && compileIds.size() >0 && compileIds.get(0) != 0){
entity.setCompileId(compileIds.get(0));
//保存区域IP信息
if(entity.getAreaCfg()!=null&&entity.getAreaCfg().size()>0){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"ipType"
,"ipPattern"
,"srcIpAddress"
,"portPattern"
,"srcPort"
,"destPort"
,"protocol"
,"direction"
,"protocolId"
});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
//保存cfgIndexInfo
avContentCfgDao.insertIp(entity);
}else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
//修改
}else{
Date editTime=new Date();
entity.setIsValid(0);
entity.setIsAudit(0);
areaCfgIds=!StringUtil.isEmpty(areaCfgIds)? ","+areaCfgIds:"";
if(!StringUtil.isEmpty(entity.getAreaCfg())){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
if(!StringUtil.isEmpty(areaIpCfg.getCfgId())){
if(areaCfgIds.contains(","+areaIpCfg.getCfgId()+",")){
areaCfgIds=areaCfgIds.replace(areaIpCfg.getCfgId()+",", "");
}
//修改
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"cfgId"
,"ipType"
,"ipPattern"
,"srcIpAddress"
,"portPattern"
,"srcPort"
,"destPort"
,"protocol"
,"direction"
,"protocolId"
});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
}else{
//新增
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"ipType"
,"ipPattern"
,"srcIpAddress"
,"portPattern"
,"srcPort"
,"destPort"
,"protocol"
,"direction"
,"protocolId"
});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
}
//delete 真是删除areaIpCfg信息
if(!StringUtil.isEmpty(areaCfgIds.replaceAll(",", ""))){
areaCfgIds=areaCfgIds.substring(1,areaCfgIds.length());
for (String cfgId : areaCfgIds.split(",")) {
AreaIpCfg areaIpCfg=new AreaIpCfg();
areaIpCfg.setCfgId(Long.parseLong(cfgId));
areaIpCfgDao.deleteAreaIpCfgByCfgId(areaIpCfg);
}
}
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
avContentCfgDao.updateIp(entity);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids compileIds
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void updateContIpValid(Integer isAudit,Integer isValid,String ids,Integer functionId){
BaseIpCfg entity = new BaseIpCfg();
entity.setTableName("av_cont_ip_cfg");
String[] idArray = ids.split(",");
for(String id :idArray){
entity.setCompileId(Integer.parseInt(id));
entity.setFunctionId(functionId);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
avContentCfgDao.updateIp(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg);
areaIpCfgDao.updateAreaIpCfgValid(areaIpCfg);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids cfgId
* @param functionId
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void auditContIp(Integer isAudit,Integer isValid,Integer functionId,String id,Date auditTime){
BaseIpCfg entity = new BaseIpCfg();
entity.setTableName("av_cont_ip_cfg");
List<BaseIpCfg> list = new ArrayList();
List<AreaIpCfg> areaIpCfgList = new ArrayList();
entity.setCompileId(Integer.parseInt(id));
entity = avContentCfgDao.findIpCfgById(entity);
entity.setTableName("av_cont_ip_cfg");
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(auditTime);
avContentCfgDao.updateIp(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"cfgId"
,"ipType"
,"ipPattern"
,"srcIpAddress"
,"portPattern"
,"srcPort"
,"destPort"
,"protocol"
,"direction"
,"protocolId"
});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
list=avContentCfgDao.getIpList(entity);
areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
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();
if(isAudit==1){
if(!StringUtil.isEmpty(list)){
//TODO DELETE后期删除
for (BaseIpCfg ipCfg : list) {
ipCfg.setCfgType("MM_AV_IP");
}
Map<String,List> ipMap = cfgConvert(ipRegionList,list,1,entity,groupRelationList);
groupRelationList=ipMap.get("groupList");
ipRegionList=ipMap.get("dstList");
}
if(!StringUtil.isEmpty(areaIpCfgList)){
//TODO DELETE后期删除
for (AreaIpCfg areaIpCfga : areaIpCfgList) {
areaIpCfga.setCfgType("NTC_IP_RANGE");
}
Map<String,List> areaMap = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList);
groupRelationList=areaMap.get("groupList");
areaIpRegionList=areaMap.get("dstList");
}
}
//构造提交综合服务参数格式,一条配置提交一次综合服务
if(isAudit==1){
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(auditTime);
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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("contIp配置下发配置参数"+json);
// 调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("contIp配置下发响应信息"+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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("contIp配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("contIp配置取消配置响应信息"+result.getMsg());
}
}
/********************************contIp业务*********************************/
/********************************picIp业务*********************************/
/**
* picIp查询分页数据
* @param page 分页对象
* @param entity
* @return
*/
public Page<BaseIpCfg> findPicIpPage(Page page, BaseIpCfg entity) {
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
entity.setPage(page);
entity.setTableName("av_pic_ip_cfg");
List<BaseIpCfg> list=avContentCfgDao.findIpList(entity);
page.setList(list);
return page;
}
/**
* picIp根据id查询contIpCfg信息
* @param entity
* @return
*/
public BaseIpCfg getPicIpCfgById(BaseIpCfg entity) {
entity.setTableName("av_pic_ip_cfg");
return avContentCfgDao.findIpCfgById(entity);
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdatePicIp(BaseIpCfg entity,String areaCfgIds){
Date createTime=new Date();
entity.setTableName("av_pic_ip_cfg");
//设置区域运营商信息
setAreaEffectiveIds(entity);
//新增
if(entity.getCfgId()==null){
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
entity.setIsValid(0);
entity.setIsAudit(0);
//调用服务接口获取compileId
List<Integer> compileIds = new ArrayList<Integer>();
try {
compileIds = ConfigServiceUtil.getId(1,1);
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
if(compileIds != null && compileIds.size() >0 && compileIds.get(0) != 0){
entity.setCompileId(compileIds.get(0));
//保存区域IP信息
if(entity.getAreaCfg()!=null&&entity.getAreaCfg().size()>0){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"ipType"
,"ipPattern"
,"srcIpAddress"
,"portPattern"
,"srcPort"
,"destPort"
,"protocol"
,"direction"
,"protocolId"
});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
//保存cfgIndexInfo
avContentCfgDao.insertIp(entity);
}else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
//修改
}else{
Date editTime=new Date();
entity.setIsValid(0);
entity.setIsAudit(0);
areaCfgIds=!StringUtil.isEmpty(areaCfgIds)? ","+areaCfgIds:"";
if(!StringUtil.isEmpty(entity.getAreaCfg())){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
if(!StringUtil.isEmpty(areaIpCfg.getCfgId())){
if(areaCfgIds.contains(","+areaIpCfg.getCfgId()+",")){
areaCfgIds=areaCfgIds.replace(areaIpCfg.getCfgId()+",", "");
}
//修改
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"cfgId"
,"ipType"
,"ipPattern"
,"srcIpAddress"
,"portPattern"
,"srcPort"
,"destPort"
,"protocol"
,"direction"
,"protocolId"
});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
}else{
//新增
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"ipType"
,"ipPattern"
,"srcIpAddress"
,"portPattern"
,"srcPort"
,"destPort"
,"protocol"
,"direction"
,"protocolId"
});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
}
//delete 真是删除areaIpCfg信息
if(!StringUtil.isEmpty(areaCfgIds.replaceAll(",", ""))){
areaCfgIds=areaCfgIds.substring(1,areaCfgIds.length());
for (String cfgId : areaCfgIds.split(",")) {
AreaIpCfg areaIpCfg=new AreaIpCfg();
areaIpCfg.setCfgId(Long.parseLong(cfgId));
areaIpCfgDao.deleteAreaIpCfgByCfgId(areaIpCfg);
}
}
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
avContentCfgDao.updateIp(entity);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids compileIds
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void updatePicIpValid(Integer isAudit,Integer isValid,String ids,Integer functionId){
BaseIpCfg entity = new BaseIpCfg();
entity.setTableName("av_pic_ip_cfg");
String[] idArray = ids.split(",");
for(String id :idArray){
entity.setCompileId(Integer.parseInt(id));
entity.setFunctionId(functionId);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
avContentCfgDao.updateIp(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg);
areaIpCfgDao.updateAreaIpCfgValid(areaIpCfg);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids cfgId
* @param functionId
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void auditPicIp(Integer isAudit,Integer isValid,Integer functionId,String id,Date auditTime){
BaseIpCfg entity = new BaseIpCfg();
entity.setTableName("av_pic_ip_cfg");
List<BaseIpCfg> list = new ArrayList();
List<AreaIpCfg> areaIpCfgList = new ArrayList();
entity.setCompileId(Integer.parseInt(id));
entity = avContentCfgDao.findIpCfgById(entity);
entity.setTableName("av_pic_ip_cfg");
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(auditTime);
avContentCfgDao.updateIp(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"cfgId"
,"ipType"
,"ipPattern"
,"srcIpAddress"
,"portPattern"
,"srcPort"
,"destPort"
,"protocol"
,"direction"
,"protocolId"
});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
list=avContentCfgDao.getIpList(entity);
areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
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();
if(isAudit==1){
if(!StringUtil.isEmpty(list)){
//TODO DELETE后期删除
for (BaseIpCfg ipCfg : list) {
ipCfg.setCfgType("MM_PIC_IP");
}
Map<String,List> ipMap = cfgConvert(ipRegionList,list,1,entity,groupRelationList);
groupRelationList=ipMap.get("groupList");
ipRegionList=ipMap.get("dstList");
}
if(!StringUtil.isEmpty(areaIpCfgList)){
//TODO DELETE后期删除
for (AreaIpCfg areaIpCfga : areaIpCfgList) {
areaIpCfga.setCfgType("NTC_IP_RANGE");
}
Map<String,List> areaMap = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList);
groupRelationList=areaMap.get("groupList");
areaIpRegionList=areaMap.get("dstList");
}
}
//构造提交综合服务参数格式,一条配置提交一次综合服务
if(isAudit==1){
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(auditTime);
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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("picIp配置下发配置参数"+json);
//TODO 调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("picIp配置下发响应信息"+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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("picIp配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("picIp配置取消配置响应信息"+result.getMsg());
}
}
/********************************picIp业务*********************************/
/********************************contUrl业务*********************************/
/**
* picIp查询分页数据
* @param page 分页对象
* @param entity
* @return
*/
public Page<BaseStringCfg> findContUrlPage(Page page, BaseStringCfg entity) {
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
entity.setPage(page);
entity.setTableName("av_cont_url_cfg");
List<BaseStringCfg> list=avContentCfgDao.findStringList(entity);
page.setList(list);
return page;
}
/**
* ContUrl根据id查询contIpCfg信息
* @param entity
* @return
*/
public BaseStringCfg getContUrlCfgById(BaseStringCfg entity) {
entity.setTableName("av_cont_url_cfg");
return avContentCfgDao.findStringCfgById(entity);
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdateContUrl(BaseStringCfg entity,String areaCfgIds){
Date createTime=new Date();
entity.setTableName("av_cont_url_cfg");
//设置区域运营商信息
setAreaEffectiveIds(entity);
//新增
if(entity.getCfgId()==null){
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
entity.setIsValid(0);
entity.setIsAudit(0);
//调用服务接口获取compileId
List<Integer> compileIds = new ArrayList<Integer>();
try {
compileIds = ConfigServiceUtil.getId(1,1);
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
if(compileIds != null && compileIds.size() >0 && compileIds.get(0) != 0){
entity.setCompileId(compileIds.get(0));
//保存区域IP信息
if(entity.getAreaCfg()!=null&&entity.getAreaCfg().size()>0){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
//保存cfgIndexInfo
avContentCfgDao.insertString(entity);
}else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
//修改
}else{
Date editTime=new Date();
entity.setIsValid(0);
entity.setIsAudit(0);
areaCfgIds=!StringUtil.isEmpty(areaCfgIds)? ","+areaCfgIds:"";
if(!StringUtil.isEmpty(entity.getAreaCfg())){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
if(!StringUtil.isEmpty(areaIpCfg.getCfgId())){
if(areaCfgIds.contains(","+areaIpCfg.getCfgId()+",")){
areaCfgIds=areaCfgIds.replace(areaIpCfg.getCfgId()+",", "");
}
//修改
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"cfgId"
});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
}else{
//新增
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
}
//delete 真是删除areaIpCfg信息
if(!StringUtil.isEmpty(areaCfgIds.replaceAll(",", ""))){
areaCfgIds=areaCfgIds.substring(1,areaCfgIds.length());
for (String cfgId : areaCfgIds.split(",")) {
AreaIpCfg areaIpCfg=new AreaIpCfg();
areaIpCfg.setCfgId(Long.parseLong(cfgId));
areaIpCfgDao.deleteAreaIpCfgByCfgId(areaIpCfg);
}
}
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
entity.setTableName("av_cont_url_cfg");
avContentCfgDao.updateString(entity);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids compileIds
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void updateContUrlValid(Integer isAudit,Integer isValid,String ids,Integer functionId){
BaseStringCfg entity = new BaseStringCfg();
entity.setTableName("av_cont_url_cfg");
String[] idArray = ids.split(",");
for(String id :idArray){
entity.setCompileId(Integer.parseInt(id));
entity.setFunctionId(functionId);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
avContentCfgDao.updateString(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg);
areaIpCfgDao.updateAreaIpCfgValid(areaIpCfg);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids cfgId
* @param functionId
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void auditContUrl(Integer isAudit,Integer isValid,Integer functionId,String id,Date auditTime){
BaseStringCfg entity = new BaseStringCfg();
entity.setTableName("av_cont_url_cfg");
List<BaseStringCfg> list = new ArrayList();
List<AreaIpCfg> areaIpCfgList = new ArrayList();
entity.setCompileId(Integer.parseInt(id));
entity = avContentCfgDao.findStringCfgById(entity);
entity.setTableName("av_cont_url_cfg");
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(auditTime);
avContentCfgDao.updateString(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"cfgId"
});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
list=avContentCfgDao.getStringList(entity);
areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
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();
if(isAudit==1){
if(!StringUtil.isEmpty(list)){
//TODO DELETE后期删除
for (BaseStringCfg strCfg : list) {
strCfg.setCfgType("MM_AV_URL");
}
Map<String,List> strMap = cfgConvert(strRegionList,list,2,entity,groupRelationList);
groupRelationList=strMap.get("groupList");
strRegionList=strMap.get("dstList");
}
if(!StringUtil.isEmpty(areaIpCfgList)){
//TODO DELETE后期删除
for (AreaIpCfg areaIpCfga : areaIpCfgList) {
areaIpCfga.setCfgType("NTC_IP_RANGE");
}
Map<String,List> areaMap = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList);
groupRelationList=areaMap.get("groupList");
areaIpRegionList=areaMap.get("dstList");
}
}
//构造提交综合服务参数格式,一条配置提交一次综合服务
if(isAudit==1){
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(auditTime);
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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("contUrl配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("contUrl配置下发响应信息"+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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("contUrl配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("contUrl配置取消配置响应信息"+result.getMsg());
}
}
/********************************contUrl业务*********************************/
/********************************picUrl业务*********************************/
/**
* picIp查询分页数据
* @param page 分页对象
* @param entity
* @return
*/
public Page<BaseStringCfg> findPicUrlPage(Page page, BaseStringCfg entity) {
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
entity.setPage(page);
entity.setTableName("av_pic_url_cfg");
List<BaseStringCfg> list=avContentCfgDao.findStringList(entity);
page.setList(list);
return page;
}
/**
* PicUrl根据id查询picIpCfg信息
* @param entity
* @return
*/
public BaseStringCfg getPicUrlCfgById(BaseStringCfg entity) {
entity.setTableName("av_pic_url_cfg");
return avContentCfgDao.findStringCfgById(entity);
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdatePicUrl(BaseStringCfg entity,String areaCfgIds){
Date createTime=new Date();
entity.setTableName("av_pic_url_cfg");
//设置区域运营商信息
setAreaEffectiveIds(entity);
//新增
if(entity.getCfgId()==null){
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
entity.setIsValid(0);
entity.setIsAudit(0);
//调用服务接口获取compileId
List<Integer> compileIds = new ArrayList<Integer>();
try {
compileIds = ConfigServiceUtil.getId(1,1);
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
if(compileIds != null && compileIds.size() >0 && compileIds.get(0) != 0){
entity.setCompileId(compileIds.get(0));
//保存区域IP信息
if(entity.getAreaCfg()!=null&&entity.getAreaCfg().size()>0){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
//保存cfgIndexInfo
avContentCfgDao.insertString(entity);
}else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
//修改
}else{
Date editTime=new Date();
entity.setIsValid(0);
entity.setIsAudit(0);
areaCfgIds=!StringUtil.isEmpty(areaCfgIds)? ","+areaCfgIds:"";
if(!StringUtil.isEmpty(entity.getAreaCfg())){
for (AreaIpCfg areaIpCfg : entity.getAreaCfg()) {
if(!StringUtil.isEmpty(areaIpCfg.getCfgId())){
if(areaCfgIds.contains(","+areaIpCfg.getCfgId()+",")){
areaCfgIds=areaCfgIds.replace(areaIpCfg.getCfgId()+",", "");
}
//修改
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"cfgId"
});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
}else{
//新增
entity.setCreatorId(UserUtils.getUser().getId());
entity.setCreateTime(createTime);
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
});
areaIpCfgDao.saveAreaIpCfg(areaIpCfg);
}
}
}
//delete 真是删除areaIpCfg信息
if(!StringUtil.isEmpty(areaCfgIds.replaceAll(",", ""))){
areaCfgIds=areaCfgIds.substring(1,areaCfgIds.length());
for (String cfgId : areaCfgIds.split(",")) {
AreaIpCfg areaIpCfg=new AreaIpCfg();
areaIpCfg.setCfgId(Long.parseLong(cfgId));
areaIpCfgDao.deleteAreaIpCfgByCfgId(areaIpCfg);
}
}
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(editTime);
entity.setTableName("av_pic_url_cfg");
avContentCfgDao.updateString(entity);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids compileIds
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void updatePicUrlValid(Integer isAudit,Integer isValid,String ids,Integer functionId){
BaseStringCfg entity = new BaseStringCfg();
entity.setTableName("av_pic_url_cfg");
String[] idArray = ids.split(",");
for(String id :idArray){
entity.setCompileId(Integer.parseInt(id));
entity.setFunctionId(functionId);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
avContentCfgDao.updateString(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg);
areaIpCfgDao.updateAreaIpCfgValid(areaIpCfg);
}
}
/**
*
* @param isAudit
* @param isValid
* @param ids cfgId
* @param functionId
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void auditPicUrl(Integer isAudit,Integer isValid,Integer functionId,String id,Date auditTime){
BaseStringCfg entity = new BaseStringCfg();
entity.setTableName("av_pic_url_cfg");
List<BaseStringCfg> list = new ArrayList();
List<AreaIpCfg> areaIpCfgList = new ArrayList();
entity.setCompileId(Integer.parseInt(id));
entity = avContentCfgDao.findStringCfgById(entity);
entity.setTableName("av_pic_url_cfg");
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(auditTime);
avContentCfgDao.updateString(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"cfgId"
});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
list=avContentCfgDao.getStringList(entity);
areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
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();
if(isAudit==1){
if(!StringUtil.isEmpty(list)){
//TODO DELETE后期删除
for (BaseStringCfg strCfg : list) {
strCfg.setCfgType("MM_PIC_URL");
}
Map<String,List> strMap = cfgConvert(strRegionList,list,2,entity,groupRelationList);
groupRelationList=strMap.get("groupList");
strRegionList=strMap.get("dstList");
}
if(!StringUtil.isEmpty(areaIpCfgList)){
//TODO DELETE后期删除
for (AreaIpCfg areaIpCfga : areaIpCfgList) {
areaIpCfga.setCfgType("NTC_IP_RANGE");
}
Map<String,List> areaMap = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList);
groupRelationList=areaMap.get("groupList");
areaIpRegionList=areaMap.get("dstList");
}
}
//构造提交综合服务参数格式,一条配置提交一次综合服务
if(isAudit==1){
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(auditTime);
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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("picUrl配置下发配置参数"+json);
// 调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("picUrl配置下发响应信息"+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(auditTime);
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("picUrl配置下发配置参数"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("picUrl配置取消配置响应信息"+result.getMsg());
}
}
/********************************picUrl业务*********************************/
}