2018-05-22 17:30:52 +08:00
|
|
|
package com.nis.web.service.configuration;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
2018-05-23 17:34:40 +08:00
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
2018-05-22 17:30:52 +08:00
|
|
|
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.GsonBuilder;
|
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
import com.nis.domain.configuration.AvFileSampleCfg;
|
|
|
|
|
import com.nis.domain.configuration.AvVoipAccountCfg;
|
|
|
|
|
import com.nis.domain.configuration.AvVoipIpCfg;
|
|
|
|
|
import com.nis.domain.configuration.CfgIndexInfo;
|
|
|
|
|
import com.nis.exceptions.MaatConvertException;
|
|
|
|
|
import com.nis.util.ConfigServiceUtil;
|
|
|
|
|
import com.nis.util.FileUtils;
|
|
|
|
|
import com.nis.web.dao.FunctionRegionDictDao;
|
|
|
|
|
import com.nis.web.dao.FunctionServiceDictDao;
|
|
|
|
|
import com.nis.web.dao.configuration.AvCfgDao;
|
|
|
|
|
import com.nis.web.dao.configuration.AvContentCfgDao;
|
|
|
|
|
import com.nis.web.security.UserUtils;
|
|
|
|
|
import com.nis.web.service.BaseService;
|
|
|
|
|
import com.nis.web.service.CrudService;
|
|
|
|
|
|
|
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 音视频文本
|
|
|
|
|
* @author dell
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class AvContentCfgService extends BaseService{
|
|
|
|
|
@Autowired
|
|
|
|
|
protected AvContentCfgDao avContentCfgDao;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询分页数据
|
|
|
|
|
* @param page 分页对象
|
|
|
|
|
* @param entity
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public Page<CfgIndexInfo> findPage(Page<CfgIndexInfo> page, CfgIndexInfo entity) {
|
|
|
|
|
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
|
|
|
|
|
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);
|
2018-05-23 17:34:40 +08:00
|
|
|
List<AvVoipAccountCfg> voipAccounts=getVoipAccountCfgList(entity);
|
|
|
|
|
List<AvVoipIpCfg> voipIps=getVoipIpCfgList(entity);
|
|
|
|
|
getVoipIpCfgList(entity);
|
|
|
|
|
cfg.setVoipAccounts(voipAccounts);
|
|
|
|
|
cfg.setVoipIps(voipIps);
|
2018-05-22 17:30:52 +08:00
|
|
|
|
|
|
|
|
return cfg;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 审核
|
|
|
|
|
* @param isAudit
|
|
|
|
|
* @param isValid
|
|
|
|
|
* @param ids **编译Id
|
|
|
|
|
* @param functionId 业务id
|
|
|
|
|
*/
|
|
|
|
|
public void auditAvVoip(Integer isAudit,Integer isValid,String ids){
|
|
|
|
|
CfgIndexInfo entity = new CfgIndexInfo();
|
|
|
|
|
String[] idArray = ids.split(",");
|
|
|
|
|
List<CfgIndexInfo> list = new ArrayList();
|
|
|
|
|
Gson gson=new GsonBuilder().disableHtmlEscaping()
|
|
|
|
|
.excludeFieldsWithoutExposeAnnotation()
|
|
|
|
|
.create();
|
|
|
|
|
//多域配置审核时间为同一个时间
|
|
|
|
|
Date auditTime=new Date();
|
|
|
|
|
|
|
|
|
|
for(String id :idArray){
|
|
|
|
|
CfgIndexInfo cfgSearch=new CfgIndexInfo();
|
|
|
|
|
cfgSearch.setCfgId(Long.parseLong(id));
|
|
|
|
|
entity = avContentCfgDao.getCfgIndexInfo(cfgSearch);
|
|
|
|
|
entity.setIsAudit(isAudit);
|
|
|
|
|
entity.setIsValid(isValid);
|
|
|
|
|
entity.setAuditorId(UserUtils.getUser().getId());
|
|
|
|
|
entity.setAuditTime(auditTime);
|
|
|
|
|
|
|
|
|
|
/*avCfgDao.auditAvFileSample(entity);
|
|
|
|
|
list.add(entity);*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/*if(isAudit==1){
|
|
|
|
|
//调用服务接口下发配置数据
|
|
|
|
|
String json=gson.toJson(list);
|
|
|
|
|
logger.info("音视频文件样例下发配置参数:"+json);
|
|
|
|
|
//调用服务接口下发配置
|
|
|
|
|
try {
|
|
|
|
|
String result = ConfigServiceUtil.postCallbackCfg(json);
|
|
|
|
|
logger.info("音视频文件样例配置下发响应信息:"+result);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
logger.info("音视频文件样例配置下发失败");
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}else if(isAudit==3){
|
|
|
|
|
//调用服务接口取消配置
|
|
|
|
|
String json=gson.toJson(list);
|
|
|
|
|
logger.info("音视频文件样例下发配置参数:"+json);
|
|
|
|
|
//调用服务接口下发配置
|
|
|
|
|
try {
|
|
|
|
|
String result = ConfigServiceUtil.put(json,2);
|
|
|
|
|
logger.info("音视频文件样例取消配置响应信息:"+result);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
logger.info("音视频文件样取消配置失败");
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-23 17:34:40 +08:00
|
|
|
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
|
|
|
|
public void saveOrUpdateAvVoip(CfgIndexInfo entity){
|
|
|
|
|
Date createTime=new Date();
|
|
|
|
|
//新增
|
|
|
|
|
if(entity.getCfgId()==null){
|
|
|
|
|
entity.setCreatorId(UserUtils.getUser().getId());
|
|
|
|
|
entity.setCreateTime(createTime);
|
|
|
|
|
//调用服务接口获取compileId
|
|
|
|
|
List<Integer> compileIds = new ArrayList<Integer>();
|
|
|
|
|
try {
|
|
|
|
|
//TODO 后期修改为动态获取
|
|
|
|
|
//compileIds = ConfigServiceUtil.getId(1,1);
|
|
|
|
|
compileIds.add((int)Math.floor(Math.random()*1000000+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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//保存cfgIndexInfo
|
|
|
|
|
avContentCfgDao.insertCfgIndexInfo(entity);
|
|
|
|
|
}else{
|
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改
|
|
|
|
|
}else{
|
|
|
|
|
//entity.setEditorId(UserUtils.getUser().getId());
|
|
|
|
|
//entity.setEditTime(new Date());
|
|
|
|
|
//entity.setIsValid(0);
|
|
|
|
|
//entity.setIsAudit(0);
|
|
|
|
|
//avCfgDao.updateAvFileSample(entity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-22 17:30:52 +08:00
|
|
|
}
|