1、修改APP配置,appCode根据特定服务ID从后台查询;2、ip复用地址池下发参数修正;3、修改配置文件参数

Signed-off-by: zhangwei <zhangwei@intranet.com>
This commit is contained in:
zhangwei
2018-07-12 19:29:36 +08:00
parent 65eba098e2
commit ac11f8d462
8 changed files with 128 additions and 85 deletions

View File

@@ -20,7 +20,7 @@ public class IpMultiplexPoolCfg extends BaseCfg<IpMultiplexPoolCfg> {
@SerializedName("cfgId")
private Integer compileId;
@Expose
@SerializedName("addType")
@SerializedName("addrType")
private String ipType;
@Expose
private Integer protocol;

View File

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.Page;
import com.nis.domain.ServiceConfigInfo;
import com.nis.domain.configuration.AppByteCfg;
import com.nis.domain.configuration.AppDomainCfg;
import com.nis.domain.configuration.AppHttpCfg;
@@ -115,6 +116,10 @@ public class AppCfgController extends BaseController {
public String saveAppPolicyCfg(Model model,HttpServletRequest request,HttpServletResponse response,
AppPolicyCfg entity,RedirectAttributes redirectAttributes) {
try {
SpecificServiceCfg specificService = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(specificService!=null){
entity.setAppCode(specificService.getSpecServiceCode());
}
appCfgService.saveOrUpdateAppPolicyCfg(entity);
} catch (Exception e) {
e.printStackTrace();
@@ -221,6 +226,10 @@ public class AppCfgController extends BaseController {
public String saveAppIpCfg(Model model,HttpServletRequest request,HttpServletResponse response,
AppIpCfg entity,RedirectAttributes redirectAttributes) {
try {
SpecificServiceCfg specificService = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(specificService!=null){
entity.setAppCode(specificService.getSpecServiceCode());
}
appCfgService.saveOrUpdateAppIpCfg(entity);
} catch (Exception e) {
e.printStackTrace();
@@ -327,6 +336,10 @@ public class AppCfgController extends BaseController {
public String saveAppHttpCfg(Model model,HttpServletRequest request,HttpServletResponse response,
AppHttpCfg entity,RedirectAttributes redirectAttributes) {
try {
SpecificServiceCfg specificService = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(specificService!=null){
entity.setAppCode(specificService.getSpecServiceCode());
}
appCfgService.saveOrUpdateAppHttpCfg(entity);
} catch (Exception e) {
e.printStackTrace();
@@ -432,6 +445,10 @@ public class AppCfgController extends BaseController {
public String saveAppDomainCfg(Model model,HttpServletRequest request,HttpServletResponse response,
AppDomainCfg entity,RedirectAttributes redirectAttributes) {
try {
SpecificServiceCfg specificService = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(specificService!=null){
entity.setAppCode(specificService.getSpecServiceCode());
}
appCfgService.saveOrUpdateAppDomainCfg(entity);
} catch (Exception e) {
e.printStackTrace();
@@ -537,6 +554,10 @@ public class AppCfgController extends BaseController {
public String saveAppByteCfg(Model model,HttpServletRequest request,HttpServletResponse response,
AppByteCfg entity,RedirectAttributes redirectAttributes) {
try {
SpecificServiceCfg specificService = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(specificService!=null){
entity.setAppCode(specificService.getSpecServiceCode());
}
appCfgService.saveOrUpdateAppByteCfg(entity);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -118,7 +118,7 @@ public class AppCfgService extends BaseService {
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
entity.setIsValid(0);
entity.setIsAudit(0);
entity.setIsAudit(0);
appCfgDao.insertAppPolicyCfg(entity);
//保存策略IP配置
if(entity.getIpPortList()!=null){

View File

@@ -99,81 +99,100 @@ public class AvCfgService extends BaseService{
avCfgDao.insertAvFileSample(entity);
//调用外部脚本,生成样例文件
List list = new ArrayList();
Map<String,Object> map = new HashMap();
map.put("srcFile", entity.getSrcPath());
map.put("dstFile", entity.getSamplePath());
map.put("resultFile", entity.getResultPath());
map.put("fileId", entity.getCfgId());
list.add(map);
String param = gsonToJson(list);
String sampleCreatelProc = "";
if(entity.getCfgType().equals(Constants.AV_SAMPLE_AUDIO_REGION)||
entity.getCfgType().equals(Constants.AV_SAMPLE_VOIP_REGION)){//音频样例配置或VOIP样例配置
sampleCreatelProc = Constants.AUDIO_SAMPLE_CREATE_PROC;
if(Constants.AUDIO_SAMPLE_PROC_PARAM_IS_TRANSLATION){
param = StringEscapeUtils.escapeJava(param);
}
if(Constants.AUDIO_SAMPLE_PROC_PARAM_IS_QUOTATION){//json参数是否需要前后单引号处理
param = "'"+param+"'";
}
}else if(entity.getCfgType().equals(Constants.AV_SAMPLE_VEDIO_REGION)){//视频样例配置
sampleCreatelProc = Constants.VEDIO_SAMPLE_CREATE_PROC;
if(Constants.VEDIO_SAMPLE_PROC_PARAM_IS_TRANSLATION){
param = StringEscapeUtils.escapeJava(param);
}
if(Constants.VEDIO_SAMPLE_PROC_PARAM_IS_QUOTATION){//json参数是否需要前后单引号处理
param = "'"+param+"'";
}
}else if(entity.getCfgType().equals(Constants.AV_SAMPLE_PICTURE_REGION)){//图片样例配置
sampleCreatelProc = Constants.PICTURE_SAMPLE_CREATE_PROC;
if(Constants.PICTURE_SAMPLE_PROC_PARAM_IS_TRANSLATION){
param = StringEscapeUtils.escapeJava(param);
}
if(Constants.PICTURE_SAMPLE_PROC_PARAM_IS_QUOTATION){//json参数是否需要前后单引号处理
param = "'"+param+"'";
}
}
entity = createSampleFileParam(entity);
avCfgDao.updateAvFileSample(entity);
logger.info("调用外部程序输入参数:"+param);
Map resultMap = execShell(sampleCreatelProc,param);
logger.info("调用外部程序结果:"+resultMap);
if(resultMap.get("exitStatus").equals(0)){//调用外部程序成功
String out = resultMap.get("out").toString();//输出参数
JSONArray resArray =JSONArray.fromObject(out);
JSONObject resObject = resArray.getJSONObject(0);
logger.info("调用外部程序输出参数:"+resObject);
int state = resObject.getInt("state");
int fileSize = resObject.getInt("fileSize");
Integer fileId = resObject.getInt("fileId");
if(state==1 && fileSize>0){//成功
entity.setIsSampleCreated(1);//样例文件创建成功
}else{
entity.setIsSampleCreated(-1);//样例文件创建失败
}
if(fileId.equals(entity.getCfgId().intValue())){
File uploadSampleFile = new File(entity.getSamplePath());
String sampleMd5 = FileUtils.getFileMD5(uploadSampleFile);
entity.setSampleMd5(sampleMd5);
avCfgDao.updateAvFileSample(entity);
}else{
logger.info("调用外部程序返回fileId错误,输入的fileId为"+entity.getCfgId()+",输出的fileId为"+fileId);
}
}else{
throw new MaatConvertException(resultMap.get("error")!=null?resultMap.get("error").toString():resultMap.get("message").toString());
}
}else{
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
}
}else{
AvFileSampleCfg oldEntity = this.getAvFileSampleById(entity.getCfgId());
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
entity.setIsValid(0);
entity.setIsAudit(0);
if(!oldEntity.getSrcMd5().equals(entity.getSrcMd5())){
//删除旧的文件
FileUtils.deleteFile(oldEntity.getSrcPath());
FileUtils.deleteFile(oldEntity.getSamplePath());
//调用外部脚本,生成样例文件
entity = createSampleFileParam(entity);
}
avCfgDao.updateAvFileSample(entity);
}
}
/**
* 处理创建样例文件所需输入输出参数
* @param entity
* @return
*/
public AvFileSampleCfg createSampleFileParam(AvFileSampleCfg entity){
List list = new ArrayList();
Map<String,Object> map = new HashMap();
map.put("srcFile", entity.getSrcPath());
map.put("dstFile", entity.getSamplePath());
map.put("resultFile", entity.getResultPath());
map.put("fileId", entity.getCfgId());
list.add(map);
String param = gsonToJson(list);
String sampleCreatelProc = "";
if(entity.getCfgType().equals(Constants.AV_SAMPLE_AUDIO_REGION)||
entity.getCfgType().equals(Constants.AV_SAMPLE_VOIP_REGION)){//音频样例配置或VOIP样例配置
sampleCreatelProc = Constants.AUDIO_SAMPLE_CREATE_PROC;
if(Constants.AUDIO_SAMPLE_PROC_PARAM_IS_TRANSLATION){
param = StringEscapeUtils.escapeJava(param);
}
if(Constants.AUDIO_SAMPLE_PROC_PARAM_IS_QUOTATION){//json参数是否需要前后单引号处理
param = "'"+param+"'";
}
}else if(entity.getCfgType().equals(Constants.AV_SAMPLE_VEDIO_REGION)){//视频样例配置
sampleCreatelProc = Constants.VEDIO_SAMPLE_CREATE_PROC;
if(Constants.VEDIO_SAMPLE_PROC_PARAM_IS_TRANSLATION){
param = StringEscapeUtils.escapeJava(param);
}
if(Constants.VEDIO_SAMPLE_PROC_PARAM_IS_QUOTATION){//json参数是否需要前后单引号处理
param = "'"+param+"'";
}
}else if(entity.getCfgType().equals(Constants.AV_SAMPLE_PICTURE_REGION)){//图片样例配置
sampleCreatelProc = Constants.PICTURE_SAMPLE_CREATE_PROC;
if(Constants.PICTURE_SAMPLE_PROC_PARAM_IS_TRANSLATION){
param = StringEscapeUtils.escapeJava(param);
}
if(Constants.PICTURE_SAMPLE_PROC_PARAM_IS_QUOTATION){//json参数是否需要前后单引号处理
param = "'"+param+"'";
}
}
logger.info("调用外部程序输入参数:"+param);
Map resultMap = execShell(sampleCreatelProc,param);
logger.info("调用外部程序结果:"+resultMap);
if(resultMap.get("exitStatus").equals(0)){//调用外部程序成功
String out = resultMap.get("out").toString();//输出参数
JSONArray resArray =JSONArray.fromObject(out);
JSONObject resObject = resArray.getJSONObject(0);
logger.info("调用外部程序输出参数:"+resObject);
int state = resObject.getInt("state");
int fileSize = resObject.getInt("fileSize");
Integer fileId = resObject.getInt("fileId");
if(state==1 && fileSize>0){//成功
entity.setIsSampleCreated(1);//样例文件创建成功
}else{
entity.setIsSampleCreated(-1);//样例文件创建失败
}
if(fileId.equals(entity.getCfgId().intValue())){
File uploadSampleFile = new File(entity.getSamplePath());
String sampleMd5 = FileUtils.getFileMD5(uploadSampleFile);
entity.setSampleMd5(sampleMd5);
}else{
logger.info("调用外部程序返回fileId错误,输入的fileId为"+entity.getCfgId()+",输出的fileId为"+fileId);
}
}else{
throw new MaatConvertException(resultMap.get("error")!=null?resultMap.get("error").toString():resultMap.get("message").toString());
}
return entity;
}
public void saveOrUpdateAvSignSample(AvSignSampleCfg entity){
//设置区域运营商信息
setAreaEffectiveIds(entity);