@@ -8,6 +8,7 @@ import java.util.HashMap;
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 ;
@@ -23,6 +24,19 @@ import com.nis.domain.configuration.AvSignSampleCfg;
import com.nis.domain.configuration.AvVoipAccountCfg ;
import com.nis.domain.configuration.AvVoipIpCfg ;
import com.nis.domain.configuration.CfgIndexInfo ;
import com.nis.domain.configuration.HttpBodyCfg ;
import com.nis.domain.configuration.HttpReqHeadCfg ;
import com.nis.domain.configuration.HttpResHeadCfg ;
import com.nis.domain.configuration.HttpUrlCfg ;
import com.nis.domain.configuration.IpPortCfg ;
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 ;
@@ -137,9 +151,8 @@ public class AvContentCfgService extends BaseService{
//调用服务接口获取compileId
List < Integer > compileIds = new ArrayList < Integer > ( ) ;
try {
//TODO
//compileIds = ConfigServiceUtil.getId(1,1 );
compileIds . add ( ( int ) Math . floor ( Math . random ( ) * 1000000 + 1 ) ) ;
compileIds = ConfigServiceUtil . getId ( 1 , 1 ) ;
//compileIds.add((int)Math.floor(Math.random()*1000000+1) );
} catch ( Exception e ) {
e . printStackTrace ( ) ;
logger . info ( " 获取编译ID出错 " ) ;
@@ -316,63 +329,108 @@ public class AvContentCfgService extends BaseService{
* @param ids 编译Id
* @param functionId
*/
public void auditAvVoip ( Integer isAudit , Integer isValid , String ids , Integer f unctionId ) {
@Transactional ( readOnly = false , rollbackFor = R untimeException . class )
public void auditAvVoip ( Integer isAudit , Integer isValid , Integer functionId , String compileId , Date auditTime ) {
CfgIndexInfo entity = new CfgIndexInfo ( ) ;
String [ ] idArray = ids . split ( " , " ) ;
List < CfgIndexInfo > list = new ArrayList ( ) ;
List < AvVoipIpCfg > voipIpList = new ArrayList ( ) ;
List < AvVoipAccountCfg > voipAccountList = new ArrayList ( ) ;
List < AreaIpCfg > areaIpCfgList = new ArrayList ( ) ;
Map < String , Object > childMap = new HashMap < > ( ) ;
CfgIndexInfo searchCfg = new CfgIndexInfo ( ) ;
Date auditTime = new Date ( ) ;
for ( String id : idArray ) {
searchCfg . setCompileId ( Integer . parseInt ( id ) ) ;
entity = avContentCfgDao . g etCfgIndexInfo ( searchCfg ) ;
entity . setIsAudit ( isAudit ) ;
entity . setIsValid ( isValid ) ;
entity . setAuditorId ( UserUtils . getUser ( ) . getId ( ) ) ;
entity . setAuditTime ( auditTime ) ;
voipIpList = avContentCfgDao . findVoipIpCfgList ( entity ) ;
voipAccountList = avContentCfgDao . findVoipAccountCfgList ( entity ) ;
areaIpCfgList = areaIpCfgDao . findAreaIpCfgLis t ( entity ) ;
searchCfg . setCompileId ( Integer . parseInt ( compileId ) ) ;
entity = avContentCfgDao . getCfgIndexInfo ( searchCfg ) ;
entity . s etIsAudit ( isAudit ) ;
entity . setIsValid ( isValid ) ;
entity . setAuditorId ( UserUtils . getUser ( ) . getId ( ) ) ;
entity . setAuditTime ( auditTime ) ;
avContentCfgDao . updateAvVoipIp ( entity ) ;
avContentCfgDao . updateAvVoipAccoun t ( entity ) ;
avContentCfgDao . updateCfgIndexInfo ( entity ) ;
areaIpCfgDao . updateAreaIpCfgFromCfgIndexInfo ( entity ) ;
voipIpList = avContentCfgDao . findVoipIpCfgList ( entity ) ;
voipAccountList = avContentCfgDao . findVoipAccountCfgList ( entity ) ;
areaIpCfgList = areaIpCfgDao . findAreaIpCfgList ( entity ) ;
ToMaatBean maatBean = new ToMaatBean ( ) ;
MaatCfg maatCfg = new MaatCfg ( ) ;
List < MaatCfg > configCompileList = new ArrayList ( ) ;
List < GroupCfg > groupRelationList = new ArrayList ( ) ;
List < IpCfg > ipRegionList = new ArrayList ( ) ;
List < StringCfg > strRegionList = new ArrayList ( ) ;
List < NumBoundaryCfg > numRegionList = new ArrayList ( ) ;
List < DigestCfg > digestRegionList = new ArrayList ( ) ;
List < IpCfg > areaIpRegionList = new ArrayList ( ) ;
if ( isAudit = = 1 ) {
if ( ! StringUtil . isEmpty ( voipIpList ) ) {
Map < String , List > ipMap = cfgConvert ( ipRegionList , voipIpList , 1 , entity , groupRelationList ) ;
groupRelationList = ipMap . get ( " groupList " ) ;
ipRegionList = ipMap . get ( " dstList " ) ;
}
avContentCfgDao . updateAvVoipIp ( entity ) ;
avContentCfgDao . updateAvVoipAccount ( entity ) ;
avContentCfgDao . updateCfgIndexInfo ( entity ) ;
areaIpCfgDao . updateAreaIpCfgFromCfgIndexInfo ( entity ) ;
childMap . put ( " voipIps " , voipIpList ) ;
childMap . put ( " voipAccounts " , voipAccount List) ;
childMap . pu t( " areaIpCfgs " , areaIpCfg List) ;
list . add ( entity ) ;
if ( ! StringUtil . isEmpty ( voipAccountList ) ) {
Map < String , List > accountMap = cfgConvert ( strRegionList , voipAccountList , 2 , entity , groupRelationList ) ;
groupRelationList = accountMap . get ( " groupList " ) ;
strRegionList = accountMap . get ( " dstList " ) ;
}
if ( ! StringUtil . isEmpty ( areaIpCfg List) ) {
Map < String , List > areaMap = cfgConver t( areaIpRegionList , areaIpCfgList , 1 , entity , groupRelation List) ;
groupRelationList = areaMap . get ( " groupList " ) ;
areaIpRegionList = areaMap . get ( " dstList " ) ;
}
}
/*if(isAudit==1){
//构造提交综合服务参数格式,一条配置提交一次综合服务
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 ( ) ) ;
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(list);
logger.info("文件样例下发配置参数:"+json);
String json = gsonToJson ( maatBean ) ;
logger. info ( " voip配置下发配置参数: " + json ) ;
//调用服务接口下发配置
try {
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
logger.info("音视频VOIP配置下发响应信息: "+result.getMsg());
} catch (Exception e) {
e.printStackTrace();
logger.info("音视频VOIP配置下发失败");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
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 ( entity . getAuditTime ( ) ) ;
maatBean . setCreatorName ( entity . getCurrentUser ( ) . getName ( ) ) ;
maatBean . setVersion ( Constants . MAAT_VERSION ) ;
maatBean . setOpAction ( Constants . UPDATE_ACTION ) ;
//调用服务接口取消配置
String json=gsonToJson(list);
logger.info("音视频VOIP配置参数: "+json);
//调用服务接口取消配置
try {
ToMaatResult result = ConfigServiceUtil.put(json, 2);
logger.info("音视频VOIP取消配置响应信息: "+result.getMsg());
} catch (Exception e) {
e.printStackTrace();
logger.info("音视频VOIP消配置失败");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
}*/
String json = gsonToJson ( maatBean ) ;
logger. info ( " http配置下发配置参数: " + json ) ;
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil . put ( json , 1 ) ;
logger . info ( " http配置取消配置响应信息: " + result . getMsg ( ) ) ;
}
}
@@ -411,9 +469,8 @@ public class AvContentCfgService extends BaseService{
//调用服务接口获取compileId
List < Integer > compileIds = new ArrayList < Integer > ( ) ;
try {
//TODO
//compileIds = ConfigServiceUtil.getId(1,1 );
compileIds . add ( ( int ) Math . floor ( Math . random ( ) * 1000000 + 1 ) ) ;
compileIds = ConfigServiceUtil . getId ( 1 , 1 ) ;
//compileIds.add((int)Math.floor(Math.random()*1000000+1) );
} catch ( Exception e ) {
e . printStackTrace ( ) ;
logger . info ( " 获取编译ID出错 " ) ;