音视频样例配置审核流程(配置下发,配置取消)完善
This commit is contained in:
@@ -1,20 +1,32 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
|
||||
import info.monitorenter.cpdetector.util.FileUtil;
|
||||
|
||||
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 java.util.UUID;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.AppIdCfg;
|
||||
import com.nis.domain.configuration.AvFileSampleCfg;
|
||||
import com.nis.domain.configuration.AvSignSampleCfg;
|
||||
import com.nis.web.dao.FunctionRegionDictDao;
|
||||
import com.nis.web.dao.FunctionServiceDictDao;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.web.dao.configuration.AvCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.CrudService;
|
||||
import com.nis.web.service.BaseService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -23,7 +35,7 @@ import com.nis.web.service.CrudService;
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class AvCfgService {
|
||||
public class AvCfgService extends BaseService{
|
||||
// @Autowired
|
||||
// protected FunctionRegionDictDao functionRegionDictDao;
|
||||
// @Autowired
|
||||
@@ -52,18 +64,204 @@ public class AvCfgService {
|
||||
public void saveOrUpdateAvFileSample(AvFileSampleCfg entity){
|
||||
if(entity.getCfgId()==null){
|
||||
entity.setCreatorId(UserUtils.getUser().getId());
|
||||
entity.setCompileId(0);
|
||||
avCfgDao.insertAvFileSample(entity);
|
||||
entity.setCreateTime(new Date());
|
||||
//调用服务接口获取compileId
|
||||
String result = "";
|
||||
try {
|
||||
result = ConfigServiceUtil.getId(1,1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("获取编译ID出错");
|
||||
}
|
||||
Integer compileId = Integer.parseInt(result);
|
||||
if(compileId!=0){
|
||||
entity.setCompileId(compileId);
|
||||
avCfgDao.insertAvFileSample(entity);
|
||||
}else{
|
||||
throw new MaatConvertException("获取编译ID出错");
|
||||
}
|
||||
}else{
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(new Date());
|
||||
entity.setIsValid(0);
|
||||
entity.setIsAudit(0);
|
||||
avCfgDao.updateAvFileSample(entity);
|
||||
}
|
||||
}
|
||||
public void saveOrUpdateAvSignSample(AvSignSampleCfg entity){
|
||||
if(entity.getCfgId()==null){
|
||||
avCfgDao.insertAvSignSample(entity);
|
||||
entity.setCreatorId(UserUtils.getUser().getId());
|
||||
entity.setCreateTime(new Date());
|
||||
//调用服务接口获取compileId
|
||||
String result = "";
|
||||
try {
|
||||
result = ConfigServiceUtil.getId(1,1);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取编译ID出错");
|
||||
throw new MaatConvertException("获取编译ID出错");
|
||||
}
|
||||
Integer compileId = Integer.parseInt(result);
|
||||
if(compileId!=0){
|
||||
entity.setCompileId(compileId);
|
||||
avCfgDao.insertAvSignSample(entity);
|
||||
}else{
|
||||
throw new MaatConvertException("获取编译ID出错");
|
||||
}
|
||||
|
||||
}else{
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(new Date());
|
||||
entity.setIsValid(0);
|
||||
entity.setIsAudit(0);
|
||||
avCfgDao.updateAvSignSample(entity);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void auditAvFileSample(Integer isAudit,Integer isValid,String ids){
|
||||
AvFileSampleCfg entity = new AvFileSampleCfg();
|
||||
String[] idArray = ids.split(",");
|
||||
List<AvFileSampleCfg> list = new ArrayList();
|
||||
Gson gson=new GsonBuilder().disableHtmlEscaping()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
for(String id :idArray){
|
||||
entity = getAvFileSampleById(Long.parseLong(id));
|
||||
entity.setIsAudit(isAudit);
|
||||
entity.setIsValid(isValid);
|
||||
entity.setAuditorId(UserUtils.getUser().getId());
|
||||
entity.setAuditTime(new Date());
|
||||
if(isAudit==1){
|
||||
//音视频文件上传接口调用
|
||||
try {
|
||||
File srcFile = new File(entity.getSrcPath());
|
||||
Map<String,Object> srcMap = new HashMap();
|
||||
srcMap.put("filetype", FileUtils.getSuffix(srcFile.getName(), false));
|
||||
srcMap.put("createTime", entity.getCreateTime());
|
||||
srcMap.put("key",FileUtils.getPrefix(srcFile.getName(), false));
|
||||
srcMap.put("fileName", srcFile.getName());
|
||||
srcMap.put("checksum", entity.getSrcMd5());
|
||||
String result1 = ConfigServiceUtil.postFileCfg(null, srcFile, JSONObject.fromObject(srcMap));
|
||||
logger.info("音视频源文件上传响应信息:"+result1);
|
||||
|
||||
File smapleFile = new File(entity.getSamplePath());
|
||||
Map<String,Object> sampleMap = new HashMap();
|
||||
sampleMap.put("filetype", FileUtils.getSuffix(smapleFile.getName(), false));
|
||||
sampleMap.put("createTime", entity.getCreateTime());
|
||||
sampleMap.put("key",FileUtils.getPrefix(smapleFile.getName(), false));
|
||||
sampleMap.put("fileName", smapleFile.getName());
|
||||
sampleMap.put("checksum", entity.getSampleMd5());
|
||||
String result2 = ConfigServiceUtil.postFileCfg(null, srcFile, JSONObject.fromObject(sampleMap));
|
||||
logger.info("音视频样例文件上传响应信息:"+result2);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("音视频文件样例配置下发失败");
|
||||
throw new MaatConvertException("音视频文件样例配置下发失败:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
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("音视频文件样例配置下发失败:"+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("音视频文件样例取消配置失败:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
public void auditAvSignSample(Integer isAudit,Integer isValid,String ids){
|
||||
AvSignSampleCfg entity = new AvSignSampleCfg();
|
||||
String[] idArray = ids.split(",");
|
||||
List<AvSignSampleCfg> list = new ArrayList();
|
||||
Gson gson=new GsonBuilder().disableHtmlEscaping()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
for(String id :idArray){
|
||||
entity = getAvSignSampleById(Long.parseLong(id));
|
||||
entity.setIsAudit(isAudit);
|
||||
entity.setIsValid(isValid);
|
||||
entity.setAuditorId(UserUtils.getUser().getId());
|
||||
entity.setAuditTime(new Date());
|
||||
avCfgDao.auditAvSignSample(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("音视频标识样例配置下发失败:"+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("音视频标识样例取消失败:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user