Stream Media 域配置

NTC_STREAM_MEDIA_URL
NTC_ SUBSCRIBE_ID
NTC_UNIVERSAL_IP[protocol_id=23]
NTC_UNIVERSAL_PROTO_TYPE
This commit is contained in:
leijun
2018-10-12 19:31:16 +08:00
parent c5130454f1
commit cb2ce6f8ba
10 changed files with 1102 additions and 512 deletions

View File

@@ -15,11 +15,13 @@ 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.AvContUrlCfg;
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.configuration.HttpUrlCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.domain.maat.MaatCfg;
@@ -117,15 +119,26 @@ public class AvContentCfgService extends BaseService{
public CfgIndexInfo getCfgIndexInfo(CfgIndexInfo entity) {
CfgIndexInfo cfg=avContentCfgDao.getCfgIndexInfo(entity);
List<NtcSubscribeIdCfg> ntcSubscribeList=getSubscribeIdCfgList(cfg);
//List<AvVoipIpCfg> voipIps=getVoipIpCfgList(cfg);
List<IpPortCfg> ipPortList = avContentCfgDao.getIpPortList(cfg);
List<AvVoipAccountCfg> voipAccounts=getVoipAccountCfgList(cfg);
cfg.setNtcSubscribeIdCfgList(ntcSubscribeList);
//cfg.setVoipIps(voipIps);
cfg.setVoipAccounts(voipAccounts);
cfg.setIpPortList(ipPortList);
return cfg;
}
public CfgIndexInfo getUrlCfgIndexInfo(CfgIndexInfo entity) {
CfgIndexInfo cfg=avContentCfgDao.getCfgIndexInfo(entity);
List<NtcSubscribeIdCfg> ntcSubscribeList=getSubscribeIdCfgList(cfg);
List<AvContUrlCfg> avContUrlList=avContentCfgDao.getAvContUrlList(cfg);
List<IpPortCfg> ipPortList = avContentCfgDao.getIpPortList(cfg);
cfg.setNtcSubscribeIdCfgList(ntcSubscribeList);
cfg.setIpPortList(ipPortList);
cfg.setAvContUrlCfgList(avContUrlList);
return cfg;
}
/* public CfgIndexInfo getCfgIndexInfo2(CfgIndexInfo entity) {
CfgIndexInfo cfg=avContentCfgDao.getCfgIndexInfo(entity);
List<AvVoipAccountCfg> voipAccounts=new ArrayList<>();
@@ -348,13 +361,15 @@ public class AvContentCfgService extends BaseService{
String[] idArray = compileIds.split(",");
for(String id :idArray){
CfgIndexInfo entity = new CfgIndexInfo();
entity.setCompileId(Integer.parseInt(id));
entity.setCfgId(Long.parseLong(id));
entity.setFunctionId(functionId);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
//avContentCfgDao.updateAvVoipIp(entity);
entity.setTableName(CfgIndexInfo.getTablename());
avContentCfgDao.updateCfgValid(entity);
entity = getCfgIndexInfo(entity);
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
IpPortCfg cfg = new IpPortCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
@@ -1344,129 +1359,108 @@ public class AvContentCfgService extends BaseService{
NtcSubscribeIdCfg subscribeIdCfg = new NtcSubscribeIdCfg();
BeanUtils.copyProperties(cfg, subscribeIdCfg, new String[] {"cfgId","isValid"});
List<NtcSubscribeIdCfg> list = stringCfgDao.findSubscribeIdCfgList(subscribeIdCfg);
CfgIndexInfo cfgInfo=new CfgIndexInfo();
cfgInfo.setCompileId(cfg.getCompileId());
List<IpPortCfg> ipPortList=avContentCfgDao.getIpPortList(cfgInfo);
cfg.setNtcSubscribeIdCfgList(list);
return cfg;
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdateContUrl(BaseStringCfg<BaseStringCfg> entity,String areaCfgIds){
Date createTime=new Date();
entity.setTableName("av_cont_url_cfg");
public void saveOrUpdateContUrl(CfgIndexInfo entity){
//设置区域运营商信息
setAreaEffectiveIds(entity);
//新增
entity.setIsValid(0);//无效
entity.setIsAudit(0);//未审核
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>();
Integer compileId = 0;
try {
compileIds = ConfigServiceUtil.getId(1,1);
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());
avContentCfgDao.insertCfgIndexInfo(entity);
if(entity.getIpPortList()!=null){
for(IpPortCfg cfg:entity.getIpPortList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
avContentCfgDao.saveIpPortCfg(cfg);
}
}
if(entity.getNtcSubscribeIdCfgList()!=null){
for(NtcSubscribeIdCfg cfg:entity.getNtcSubscribeIdCfgList()){
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
entity.setNtcSubscribeIdCfg(cfg);
avContentCfgDao.insertAvVoipKeywordCfg(entity);
}
}
}
if(entity.getAvContUrlCfgList()!=null&&entity.getAvContUrlCfgList().size()>0){
for(AvContUrlCfg avContUrlCfg : entity.getAvContUrlCfgList()){
entity.setAvContUrlCfg(avContUrlCfg);
avContentCfgDao.saveAvContUrlCfg(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("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
// 添加subscribeId
if(entity.getNtcSubscribeIdCfgList()!=null){
for(NtcSubscribeIdCfg cfg:entity.getNtcSubscribeIdCfgList()){
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
entity.setCompileId(compileIds.get(0));
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType",
"cfgKeywords","exprType",
"matchMethod","isHexbin"});
stringCfgDao.saveSubscribeIdCfg(cfg);
}
}
}
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);
entity.setEditTime(new Date());
entity.setEditorId(entity.getCurrentUser().getId());
avContentCfgDao.updateCfgIndexInfo(entity);
//无效子配置后,再新增子配置
avContentCfgDao.deleteIpCfg(entity);
stringCfgDao.deleteSubscribeIdCfgByCfgIndexInfo(entity);
avContentCfgDao.deleteAvContUrlCfg(entity);
AreaIpCfg area = new AreaIpCfg();
area.setCompileId(entity.getCompileId());
area.setFunctionId(entity.getFunctionId());
areaIpCfgDao.deleteAreaIpCfg(area);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
// 删除SubscribeId配置再进行添加
NtcSubscribeIdCfg subscribeIdCfg = new NtcSubscribeIdCfg();
BeanUtils.copyProperties(entity, subscribeIdCfg,new String[]{"cfgId","cfgType"});
stringCfgDao.deleteSubscribeIdCfg(subscribeIdCfg);
if(entity.getIpPortList()!=null){
for(IpPortCfg cfg:entity.getIpPortList()){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
avContentCfgDao.saveIpPortCfg(cfg);
}
}
if(entity.getNtcSubscribeIdCfgList()!=null){
for(NtcSubscribeIdCfg cfg:entity.getNtcSubscribeIdCfgList()){
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType",
"cfgKeywords","exprType",
"matchMethod","isHexbin"});
stringCfgDao.saveSubscribeIdCfg(cfg);
entity.setNtcSubscribeIdCfg(cfg);
avContentCfgDao.insertAvVoipKeywordCfg(entity);
}
}
}
if(entity.getAvContUrlCfgList()!=null&&entity.getAvContUrlCfgList().size()>0){
for(AvContUrlCfg avContUrlCfg : entity.getAvContUrlCfgList()){
entity.setAvContUrlCfg(avContUrlCfg);
avContentCfgDao.saveAvContUrlCfg(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);
}
}
}
}
}
/**
*
@@ -1478,24 +1472,30 @@ public class AvContentCfgService extends BaseService{
public void updateContUrlValid(Integer isAudit,Integer isValid,String ids,Integer functionId){
String[] idArray = ids.split(",");
for(String id :idArray){
BaseStringCfg entity = new BaseStringCfg();
CfgIndexInfo entity = new CfgIndexInfo();
entity.setCfgId(Long.parseLong(id));
BaseStringCfg urlCfg = this.getContUrlCfgById(entity);// 获取CompileId
entity.setCompileId(urlCfg.getCompileId());
entity.setTableName("av_cont_url_cfg");
entity.setFunctionId(functionId);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
avContentCfgDao.updateString(entity);
// 查询域配置信息
BaseStringCfg cfg = this.getContUrlCfgById(entity);
if(cfg.getNtcSubscribeIdCfgList() != null && cfg.getNtcSubscribeIdCfgList().size()>0) {
NtcSubscribeIdCfg subscribeIdCfg = new NtcSubscribeIdCfg();
BeanUtils.copyProperties(cfg, subscribeIdCfg, new String[] {"cfgId","cfgType","tableName"});
stringCfgDao.updateSubscribeIdCfg(subscribeIdCfg);
entity.setTableName(CfgIndexInfo.getTablename());
avContentCfgDao.updateCfgValid(entity);
entity = getUrlCfgIndexInfo(entity);
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
IpPortCfg cfg = new IpPortCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(IpPortCfg.getTablename());
avContentCfgDao.updateCfgValid(cfg);
}
if(entity.getAvContUrlCfgList()!=null && entity.getAvContUrlCfgList().size()>0){
AvContUrlCfg cfg = new AvContUrlCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(AvContUrlCfg.getTablename());
avContentCfgDao.updateCfgValid(cfg);
}
avContentCfgDao.updateAvVoipKeywordCfgt(entity);
avContentCfgDao.updateCfgIndexInfo(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg);
areaIpCfgDao.updateAreaIpCfgValid(areaIpCfg);
@@ -1510,31 +1510,30 @@ public class AvContentCfgService extends BaseService{
*/
@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();
CfgIndexInfo entity = new CfgIndexInfo();
List<CfgIndexInfo> list = new ArrayList();
List<IpPortCfg> ipPortList =new ArrayList();
List <NtcSubscribeIdCfg> ntcList = new ArrayList();
List<AreaIpCfg> areaIpCfgList = new ArrayList();
List<AvContUrlCfg> avContUrlCfgList = new ArrayList();
CfgIndexInfo searchCfg=new CfgIndexInfo();
searchCfg.setCfgId(Long.parseLong(id));
entity.setCompileId(Integer.parseInt(id));
entity = avContentCfgDao.findStringCfgById(entity);
entity.setTableName("av_cont_url_cfg");
entity = avContentCfgDao.getCfgIndexInfo(searchCfg);
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(auditTime);
avContentCfgDao.updateString(entity);
avContentCfgDao.updateAvVoipKeywordCfgt(entity);
avContentCfgDao.updateCfgIndexInfo(entity);
AreaIpCfg areaIpCfg=new AreaIpCfg();
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode"
,"cfgType"
,"cfgId"
});
BeanUtils.copyProperties(entity, areaIpCfg,new String[]{"cfgRegionCode","cfgType","cfgId"});
areaIpCfgDao.updateAreaIpCfg(areaIpCfg);
list=avContentCfgDao.getStringList(entity);
ipPortList = avContentCfgDao.getIpPortList(entity);
ntcList=stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity);
areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
avContUrlCfgList=avContentCfgDao.getAvContUrlList(entity);
ToMaatBean maatBean = new ToMaatBean();
MaatCfg maatCfg = new MaatCfg();
List<MaatCfg> configCompileList = new ArrayList();
@@ -1545,13 +1544,36 @@ public class AvContentCfgService extends BaseService{
List<DigestCfg> digestRegionList = new ArrayList();
List<IpCfg> areaIpRegionList = new ArrayList();
if(avContUrlCfgList!=null && avContUrlCfgList.size()>0){
entity.setAvContUrlCfgList(avContUrlCfgList);
AvContUrlCfg cfg = new AvContUrlCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(AvContUrlCfg.getTablename());
avContentCfgDao.updateCfgValid(cfg);
}
if(isAudit==1){
if(!StringUtil.isEmpty(list)){
Map<String,List> strMap = cfgConvert(strRegionList,list,2,entity,groupRelationList);
groupRelationList=strMap.get("groupList");
strRegionList=strMap.get("dstList");
if(!StringUtil.isEmpty(ipPortList)){
Map<String,List> ipMap = cfgConvert(ipRegionList,ipPortList,1,entity,groupRelationList);
groupRelationList=ipMap.get("groupList");
ipRegionList=ipMap.get("dstList");
if(ipMap.get("numRegionList")!=null){
numRegionList.addAll(ipMap.get("numRegionList"));
}
}
if(!StringUtil.isEmpty(avContUrlCfgList)){
Map<String,List> urlMap = cfgConvert(strRegionList,avContUrlCfgList,2,entity,groupRelationList);
groupRelationList=urlMap.get("groupList");
strRegionList=urlMap.get("dstList");
}
if(!StringUtil.isEmpty(ntcList)){
Map<String,List> ntcMap = cfgConvert(strRegionList,ntcList,2,entity,groupRelationList);
groupRelationList=ntcMap.get("groupList");
strRegionList=ntcMap.get("dstList");
}
if(!StringUtil.isEmpty(areaIpCfgList)){
Map<String,List> areaMap = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList);
groupRelationList=areaMap.get("groupList");
@@ -1559,20 +1581,6 @@ public class AvContentCfgService extends BaseService{
}
}
// 修改审核状态
BaseStringCfg baseStrCfg = this.getContUrlCfgById(entity);
if(!StringUtil.isEmpty(baseStrCfg.getNtcSubscribeIdCfgList())) {
NtcSubscribeIdCfg cfg = new NtcSubscribeIdCfg();
BeanUtils.copyProperties(entity, cfg, new String[] {"cfgId","cfgType","cfgKeywords",
"exprType","matchMethod","isHexbin"});
stringCfgDao.updateSubscribeIdCfg(cfg);
if(isAudit==1) {
Map<String,List> map = cfgConvert(strRegionList,baseStrCfg.getNtcSubscribeIdCfgList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
}
//构造提交综合服务参数格式,一条配置提交一次综合服务
if(isAudit==1){
maatCfg.initDefaultValue();
@@ -1595,11 +1603,11 @@ public class AvContentCfgService extends BaseService{
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("contUrl配置下发配置参数"+json);
logger.info("contUrl 配置下发配置参数:"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("contUrl配置下发响应信息"+result.getMsg());
logger.info("contUrl 配置下发响应信息:"+result.getMsg());
}else if(isAudit==3){
maatCfg.setCompileId(entity.getCompileId());
maatCfg.setServiceId(entity.getServiceId());
@@ -1612,12 +1620,12 @@ public class AvContentCfgService extends BaseService{
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("contUrl配置下发配置参数"+json);
logger.info("contUrl 配置下发配置参数:"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("contUrl配置取消配置响应信息"+result.getMsg());
logger.info("contUrl 配置取消配置响应信息:"+result.getMsg());
}
}
}
/********************************contUrl业务*********************************/