2018-05-17 15:33:30 +08:00
|
|
|
|
package com.nis.web.service.configuration;
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-05-21 11:22:51 +08:00
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
import java.util.HashMap;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import java.util.List;
|
2018-05-21 11:22:51 +08:00
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
import net.sf.json.JSONObject;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
|
2018-05-17 15:33:30 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
2018-05-21 11:22:51 +08:00
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
|
import com.google.gson.GsonBuilder;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.domain.Page;
|
|
|
|
|
|
import com.nis.domain.configuration.AvFileSampleCfg;
|
|
|
|
|
|
import com.nis.domain.configuration.AvSignSampleCfg;
|
2018-05-24 10:01:24 +08:00
|
|
|
|
import com.nis.domain.maat.ToMaatResult;
|
|
|
|
|
|
import com.nis.domain.maat.ToMaatResult.ResponseData;
|
2018-05-21 11:22:51 +08:00
|
|
|
|
import com.nis.exceptions.MaatConvertException;
|
|
|
|
|
|
import com.nis.util.ConfigServiceUtil;
|
|
|
|
|
|
import com.nis.util.FileUtils;
|
2018-05-22 13:47:49 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
2018-05-17 15:33:30 +08:00
|
|
|
|
import com.nis.web.dao.configuration.AvCfgDao;
|
2018-05-18 16:46:46 +08:00
|
|
|
|
import com.nis.web.security.UserUtils;
|
2018-05-21 11:22:51 +08:00
|
|
|
|
import com.nis.web.service.BaseService;
|
2018-05-17 15:33:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-05-18 16:46:46 +08:00
|
|
|
|
* 音视频配置相关事务类
|
2018-05-17 15:33:30 +08:00
|
|
|
|
* @author dell
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Service
|
2018-05-21 11:22:51 +08:00
|
|
|
|
public class AvCfgService extends BaseService{
|
2018-05-18 16:46:46 +08:00
|
|
|
|
// @Autowired
|
|
|
|
|
|
// protected FunctionRegionDictDao functionRegionDictDao;
|
|
|
|
|
|
// @Autowired
|
|
|
|
|
|
// protected FunctionServiceDictDao functionServiceDictDao;
|
2018-05-17 15:33:30 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
protected AvCfgDao avCfgDao;
|
|
|
|
|
|
|
2018-05-18 16:46:46 +08:00
|
|
|
|
public AvFileSampleCfg getAvFileSampleById(Long cfgId){
|
|
|
|
|
|
return avCfgDao.getAvFileSampleById(cfgId);
|
|
|
|
|
|
}
|
|
|
|
|
|
public AvSignSampleCfg getAvSignSampleById(Long cfgId){
|
|
|
|
|
|
return avCfgDao.getAvSignSampleById(cfgId);
|
|
|
|
|
|
}
|
|
|
|
|
|
public Page<AvFileSampleCfg> getAvFileSampleList(Page<AvFileSampleCfg> page, AvFileSampleCfg entity){
|
2018-05-21 17:21:21 +08:00
|
|
|
|
// 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL)
|
|
|
|
|
|
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
|
2018-05-18 16:46:46 +08:00
|
|
|
|
entity.setPage(page);
|
|
|
|
|
|
List<AvFileSampleCfg> list = avCfgDao.getAvFileSampleList(entity);
|
|
|
|
|
|
page.setList(list);
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
|
|
|
|
|
public Page<AvSignSampleCfg> getAvSignSampleList(Page<AvSignSampleCfg> page, AvSignSampleCfg entity){
|
2018-05-21 17:21:21 +08:00
|
|
|
|
// 生成数据权限过滤条件(dsf为dataScopeFilter的简写,在xml中使用 ${sqlMap.dsf}调用权限SQL)
|
|
|
|
|
|
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
|
2018-05-18 16:46:46 +08:00
|
|
|
|
entity.setPage(page);
|
|
|
|
|
|
List<AvSignSampleCfg> list = avCfgDao.getAvSignSampleList(entity);
|
|
|
|
|
|
page.setList(list);
|
|
|
|
|
|
return page;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void saveOrUpdateAvFileSample(AvFileSampleCfg entity){
|
|
|
|
|
|
if(entity.getCfgId()==null){
|
|
|
|
|
|
entity.setCreatorId(UserUtils.getUser().getId());
|
2018-05-21 11:22:51 +08:00
|
|
|
|
entity.setCreateTime(new Date());
|
|
|
|
|
|
//调用服务接口获取compileId
|
2018-05-24 10:01:24 +08:00
|
|
|
|
Integer compileId = 0;
|
2018-05-21 11:22:51 +08:00
|
|
|
|
try {
|
2018-05-24 10:01:24 +08:00
|
|
|
|
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
|
|
|
|
|
if(!StringUtil.isEmpty(compileIds)){
|
|
|
|
|
|
compileId = compileIds.get(0);
|
|
|
|
|
|
}
|
2018-05-21 11:22:51 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("获取编译ID出错");
|
2018-05-21 14:10:11 +08:00
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
2018-05-21 11:22:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(compileId!=0){
|
|
|
|
|
|
entity.setCompileId(compileId);
|
|
|
|
|
|
avCfgDao.insertAvFileSample(entity);
|
|
|
|
|
|
}else{
|
2018-05-21 14:10:11 +08:00
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
2018-05-21 11:22:51 +08:00
|
|
|
|
}
|
2018-05-18 16:46:46 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
entity.setEditorId(UserUtils.getUser().getId());
|
2018-05-21 11:22:51 +08:00
|
|
|
|
entity.setEditTime(new Date());
|
|
|
|
|
|
entity.setIsValid(0);
|
|
|
|
|
|
entity.setIsAudit(0);
|
2018-05-18 16:46:46 +08:00
|
|
|
|
avCfgDao.updateAvFileSample(entity);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void saveOrUpdateAvSignSample(AvSignSampleCfg entity){
|
|
|
|
|
|
if(entity.getCfgId()==null){
|
2018-05-21 11:22:51 +08:00
|
|
|
|
entity.setCreatorId(UserUtils.getUser().getId());
|
|
|
|
|
|
entity.setCreateTime(new Date());
|
|
|
|
|
|
//调用服务接口获取compileId
|
2018-05-24 10:01:24 +08:00
|
|
|
|
Integer compileId = 0;
|
2018-05-21 11:22:51 +08:00
|
|
|
|
try {
|
2018-05-24 10:01:24 +08:00
|
|
|
|
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
|
|
|
|
|
|
if(!StringUtil.isEmpty(compileIds)){
|
|
|
|
|
|
compileId = compileIds.get(0);
|
|
|
|
|
|
}
|
2018-05-21 11:22:51 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.info("获取编译ID出错");
|
2018-05-21 14:10:11 +08:00
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
2018-05-21 11:22:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(compileId!=0){
|
|
|
|
|
|
entity.setCompileId(compileId);
|
|
|
|
|
|
avCfgDao.insertAvSignSample(entity);
|
|
|
|
|
|
}else{
|
2018-05-21 14:10:11 +08:00
|
|
|
|
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>");
|
2018-05-21 11:22:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-18 16:46:46 +08:00
|
|
|
|
}else{
|
2018-05-21 11:22:51 +08:00
|
|
|
|
entity.setEditorId(UserUtils.getUser().getId());
|
|
|
|
|
|
entity.setEditTime(new Date());
|
|
|
|
|
|
entity.setIsValid(0);
|
|
|
|
|
|
entity.setIsAudit(0);
|
2018-05-18 16:46:46 +08:00
|
|
|
|
avCfgDao.updateAvSignSample(entity);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-05-21 11:22:51 +08:00
|
|
|
|
public void updateAvFileSampleValid(Integer isAudit,Integer isValid,String ids){
|
|
|
|
|
|
AvFileSampleCfg entity = new AvFileSampleCfg();
|
|
|
|
|
|
String[] idArray = ids.split(",");
|
|
|
|
|
|
for(String id :idArray){
|
|
|
|
|
|
entity.setCfgId(Long.parseLong(id));
|
|
|
|
|
|
entity.setIsAudit(isAudit);
|
|
|
|
|
|
entity.setIsValid(isValid);
|
|
|
|
|
|
entity.setEditorId(UserUtils.getUser().getId());
|
|
|
|
|
|
entity.setEditTime(new Date());
|
|
|
|
|
|
avCfgDao.updateAvFileSampleValid(entity);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-05-28 11:40:58 +08:00
|
|
|
|
public void auditAvFileSample(AvFileSampleCfg entity,Integer isAudit) throws MaatConvertException{
|
2018-05-28 10:10:37 +08:00
|
|
|
|
//修改数据库审核状态信息
|
|
|
|
|
|
avCfgDao.auditAvFileSample(entity);
|
|
|
|
|
|
List<AvFileSampleCfg> list = new ArrayList<AvFileSampleCfg>();
|
|
|
|
|
|
//一条配置提交一次综合服务
|
|
|
|
|
|
if(isAudit==1){
|
2018-05-29 17:55:07 +08:00
|
|
|
|
list.add(entity);
|
2018-05-21 11:22:51 +08:00
|
|
|
|
//调用服务接口下发配置数据
|
2018-05-24 10:01:24 +08:00
|
|
|
|
String json=gsonToJson(list);
|
2018-05-21 11:22:51 +08:00
|
|
|
|
logger.info("音视频文件样例下发配置参数:"+json);
|
|
|
|
|
|
//调用服务接口下发配置
|
2018-05-28 11:40:58 +08:00
|
|
|
|
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
|
|
|
|
|
logger.info("音视频文件样例配置下发响应信息:"+result.getMsg());
|
|
|
|
|
|
|
2018-05-21 11:22:51 +08:00
|
|
|
|
}else if(isAudit==3){
|
2018-05-29 17:55:07 +08:00
|
|
|
|
AvFileSampleCfg cfg = new AvFileSampleCfg();
|
|
|
|
|
|
cfg.setIsValid(0);
|
|
|
|
|
|
cfg.setCompileId(entity.getCompileId());
|
|
|
|
|
|
cfg.setServiceId(entity.getServiceId());
|
|
|
|
|
|
list.add(cfg);
|
2018-05-21 11:22:51 +08:00
|
|
|
|
//调用服务接口取消配置
|
2018-05-24 10:01:24 +08:00
|
|
|
|
String json=gsonToJson(list);
|
2018-05-21 11:22:51 +08:00
|
|
|
|
logger.info("音视频文件样例下发配置参数:"+json);
|
|
|
|
|
|
//调用服务接口下发配置
|
2018-05-28 11:40:58 +08:00
|
|
|
|
ToMaatResult result = ConfigServiceUtil.put(json,2);
|
|
|
|
|
|
logger.info("音视频文件样例取消配置响应信息:"+result.getMsg());
|
2018-05-21 11:22:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void updateAvSignSampleValid(Integer isAudit,Integer isValid,String ids){
|
|
|
|
|
|
AvSignSampleCfg entity = new AvSignSampleCfg();
|
|
|
|
|
|
String[] idArray = ids.split(",");
|
|
|
|
|
|
for(String id :idArray){
|
|
|
|
|
|
entity.setCfgId(Long.parseLong(id));
|
|
|
|
|
|
entity.setIsAudit(isAudit);
|
|
|
|
|
|
entity.setIsValid(isValid);
|
|
|
|
|
|
entity.setEditorId(UserUtils.getUser().getId());
|
|
|
|
|
|
entity.setEditTime(new Date());
|
|
|
|
|
|
avCfgDao.updateAvSignSampleValid(entity);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-05-28 11:40:58 +08:00
|
|
|
|
public void auditAvSignSample(AvSignSampleCfg entity,Integer isAudit) throws MaatConvertException{
|
2018-05-28 10:10:37 +08:00
|
|
|
|
avCfgDao.auditAvSignSample(entity);
|
|
|
|
|
|
List<AvSignSampleCfg> list = new ArrayList<AvSignSampleCfg>();
|
2018-05-29 17:55:07 +08:00
|
|
|
|
if(isAudit==1){
|
|
|
|
|
|
list.add(entity);
|
2018-05-21 11:22:51 +08:00
|
|
|
|
//调用服务接口下发配置数据
|
2018-05-24 10:01:24 +08:00
|
|
|
|
String json=gsonToJson(list);
|
2018-05-21 11:22:51 +08:00
|
|
|
|
logger.info("文件样例下发配置参数:"+json);
|
|
|
|
|
|
//调用服务接口下发配置
|
2018-05-28 11:45:03 +08:00
|
|
|
|
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
|
|
|
|
|
|
logger.info("音视频标志样例配置下发响应信息:"+result.getMsg());
|
|
|
|
|
|
|
2018-05-21 11:22:51 +08:00
|
|
|
|
}else if(isAudit==3){
|
2018-05-29 17:55:07 +08:00
|
|
|
|
AvSignSampleCfg cfg = new AvSignSampleCfg();
|
|
|
|
|
|
cfg.setIsValid(0);
|
|
|
|
|
|
cfg.setCompileId(entity.getCompileId());
|
|
|
|
|
|
cfg.setServiceId(entity.getServiceId());
|
|
|
|
|
|
list.add(cfg);
|
2018-05-21 11:22:51 +08:00
|
|
|
|
//调用服务接口取消配置
|
2018-05-24 10:01:24 +08:00
|
|
|
|
String json=gsonToJson(list);
|
2018-05-21 11:22:51 +08:00
|
|
|
|
logger.info("标志样例下发配置参数:"+json);
|
|
|
|
|
|
//调用服务接口取消配置
|
2018-05-28 11:40:58 +08:00
|
|
|
|
ToMaatResult result = ConfigServiceUtil.put(json, 2);
|
|
|
|
|
|
logger.info("音视频标志样例配置取消配置响应信息:"+result.getMsg());
|
2018-05-21 11:22:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-05-17 15:33:30 +08:00
|
|
|
|
}
|