|
@@ -18,7 +18,6 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.tencentcloudapi.mps.v20190612.models.DescribeTaskDetailResponse;
|
|
|
import it.sauronsoftware.jave.Encoder;
|
|
|
-import it.sauronsoftware.jave.EncoderException;
|
|
|
import it.sauronsoftware.jave.MultimediaInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
@@ -31,7 +30,10 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.io.*;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.net.URLDecoder;
|
|
@@ -55,7 +57,6 @@ import static cn.com.ctop.common.module.utils.CloudVideoProcessUtil.videoWaterma
|
|
|
public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, MaterialInfo> implements IMaterialInfoService {
|
|
|
|
|
|
private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(5);
|
|
|
-
|
|
|
@Resource
|
|
|
private ITencentWatermarkTemplateService tencentWatermarkTemplateService;
|
|
|
@Resource
|
|
@@ -72,8 +73,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
private IMaterialCutFrameService materialCutFrameService;
|
|
|
@Autowired
|
|
|
private ISupplierWatermarkService supplierWatermarkService;
|
|
|
- @Resource
|
|
|
- private IProductService productService;
|
|
|
@Value("${oss.replace.download}")
|
|
|
private String downloadUrl;
|
|
|
|
|
@@ -317,9 +316,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
getFile(info);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
@@ -397,73 +394,68 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
@Override
|
|
|
public void run() {
|
|
|
log.info("获取素材基本信息,code:{}", materialInfo.getCode());
|
|
|
- if (!Check.isNull(materialInfo)) {
|
|
|
- long l = System.currentTimeMillis();
|
|
|
- String url = materialInfo.getUrl();
|
|
|
- log.info("replaceUrl:{}", url);
|
|
|
- String localUrl = null;
|
|
|
- MultimediaInfo m = null;
|
|
|
- FileInputStream fis = null;
|
|
|
+
|
|
|
+ long l = System.currentTimeMillis();
|
|
|
+ String url = materialInfo.getUrl();
|
|
|
+ log.info("replaceUrl:{}", url);
|
|
|
+ String localUrl = null;
|
|
|
+ MultimediaInfo m = null;
|
|
|
+ FileInputStream fis = null;
|
|
|
+ try {
|
|
|
+ localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
|
|
|
+ File file = new File(localUrl);
|
|
|
+ it.sauronsoftware.jave.Encoder encoder = new Encoder();
|
|
|
+ m = encoder.getInfo(file);
|
|
|
+ long duration = m.getDuration();
|
|
|
+ long secondDuration = duration / 1000;
|
|
|
+ MaterialParameter materialParameter = new MaterialParameter();
|
|
|
+ materialParameter.setMaterialId(materialInfo.getCode());
|
|
|
+ // 视频秒数
|
|
|
+ materialParameter.setSecond(secondDuration);
|
|
|
+ // 视频格式
|
|
|
+ materialParameter.setFormat(m.getFormat());
|
|
|
+ // 视频宽
|
|
|
+ String width = String.valueOf(m.getVideo().getSize().getWidth());
|
|
|
+ materialParameter.setWidth(width);
|
|
|
+ // 视频高
|
|
|
+ String height = String.valueOf(m.getVideo().getSize().getHeight());
|
|
|
+ materialParameter.setHeight(height);
|
|
|
+ fis = new FileInputStream(file);
|
|
|
+ FileChannel fc = fis.getChannel();
|
|
|
+ BigDecimal fileSize = new BigDecimal(fc.size());
|
|
|
+ String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
|
|
|
+ materialParameter.setSize(size);
|
|
|
+ materialParameter.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ Map<String, Object> deleteMap = new HashMap<>();
|
|
|
+ deleteMap.put("material_id", materialInfo.getId());
|
|
|
+ materialParameterMapper.deleteByMap(deleteMap);
|
|
|
+ int insert = materialParameterMapper.insert(materialParameter);
|
|
|
+ if (insert > 0) {
|
|
|
+ log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
|
|
|
+ }
|
|
|
+ // 默认抽帧 素造供应商
|
|
|
+ Long templateId = MaterialSupplierEnum.getTemplateIdBySize(Integer.valueOf(width), Integer.valueOf(height));
|
|
|
+ if (!Check.isNull(templateId)) {
|
|
|
+ Thread thread = new Thread() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ watermarkVideoBySupplierCode(materialInfo.getCode(), materialInfo.getUrl(), templateId);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ thread.start();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
try {
|
|
|
- localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
|
|
|
- File file = new File(localUrl);
|
|
|
- it.sauronsoftware.jave.Encoder encoder = new Encoder();
|
|
|
- m = encoder.getInfo(file);
|
|
|
- long duration = m.getDuration();
|
|
|
- long secondDuration = duration / 1000;
|
|
|
- MaterialParameter materialParameter = new MaterialParameter();
|
|
|
- materialParameter.setMaterialId(materialInfo.getCode());
|
|
|
- // 视频秒数
|
|
|
- materialParameter.setSecond(secondDuration);
|
|
|
- // 视频格式
|
|
|
- materialParameter.setFormat(m.getFormat());
|
|
|
- // 视频宽
|
|
|
- String width = String.valueOf(m.getVideo().getSize().getWidth());
|
|
|
- materialParameter.setWidth(width);
|
|
|
- // 视频高
|
|
|
- String height = String.valueOf(m.getVideo().getSize().getHeight());
|
|
|
- materialParameter.setHeight(height);
|
|
|
-
|
|
|
- fis = new FileInputStream(file);
|
|
|
- FileChannel fc = fis.getChannel();
|
|
|
- BigDecimal fileSize = new BigDecimal(fc.size());
|
|
|
- String size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
|
|
|
- materialParameter.setSize(size);
|
|
|
- materialParameter.setUpdateTime(new Date());
|
|
|
-
|
|
|
- Map<String, Object> deleteMap = new HashMap<>();
|
|
|
- deleteMap.put("material_id", materialInfo.getId());
|
|
|
- materialParameterMapper.deleteByMap(deleteMap);
|
|
|
- int insert = materialParameterMapper.insert(materialParameter);
|
|
|
- if (insert > 0) {
|
|
|
- log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
|
|
|
+ if (fis != null) {
|
|
|
+ fis.close();
|
|
|
}
|
|
|
- // 默认抽帧 素造供应商
|
|
|
- Long templateId = MaterialSupplierEnum.getTemplateIdBySize(Integer.valueOf(width), Integer.valueOf(height));
|
|
|
- if (!Check.isNull(templateId)) {
|
|
|
- Thread thread = new Thread() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- watermarkVideoBySupplierCode(materialInfo.getCode(), materialInfo.getUrl(), templateId);
|
|
|
- }
|
|
|
- };
|
|
|
- thread.start();
|
|
|
- }
|
|
|
- } catch (FileNotFoundException e) {
|
|
|
- e.printStackTrace();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
- } catch (EncoderException e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- if (fis != null) {
|
|
|
- fis.close();
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
}
|
|
|
+ LoadFileUtil.delFile(localUrl);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -522,7 +514,13 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
info.setProductId(productId);
|
|
|
info.setWatermarkCode(json.getString("watermarkCode"));
|
|
|
info.setStatus(0);
|
|
|
- info.setMaterialName(StringUtils.getFileNameNoEx(json.getString("materialName")));
|
|
|
+ String fileName = AesEncryptUtil.getUrlDecoderString(url.substring(url.lastIndexOf("/") + 1));
|
|
|
+ String fileNameNoEx = StringUtils.getFileNameNoEx(fileName);
|
|
|
+ if (fileNameNoEx.contains("-")) {
|
|
|
+ fileNameNoEx = fileNameNoEx.substring(0, fileNameNoEx.lastIndexOf("-"));
|
|
|
+ }
|
|
|
+
|
|
|
+ info.setMaterialName(fileNameNoEx);
|
|
|
info.setWatermarkMaterialName(json.getString("watermarkMaterialName"));
|
|
|
info.setMaterialDescribe(json.getString("materialDescribe"));
|
|
|
info.setCreateTime(new Date());
|
|
@@ -580,17 +578,17 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
//TODO 需要添加获取设计负责人代码
|
|
|
SysUser clip = userService.getById(clipId);
|
|
|
String roleCode = userService.getRoleCodeByUserId(clipId);
|
|
|
- log.info("剪辑人员名称:"+clip.getRealname()+";ID:"+clipId);
|
|
|
+ log.info("剪辑人员名称:" + clip.getRealname() + ";ID:" + clipId);
|
|
|
String leaderName = "";
|
|
|
String leaderId = "";
|
|
|
- if("designTeamLeader".equals(roleCode)){
|
|
|
+ if ("designTeamLeader".equals(roleCode)) {
|
|
|
leaderId = clipId;
|
|
|
leaderName = clip.getRealname();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
leaderId = clip.getLeaderId();
|
|
|
leaderName = clip.getLeaderName();
|
|
|
}
|
|
|
- log.info("负责人名称:"+leaderName+";ID:"+leaderId);
|
|
|
+ log.info("负责人名称:" + leaderName + ";ID:" + leaderId);
|
|
|
materialAscription.setLeaderName(leaderName);
|
|
|
materialAscription.setLeaderId(leaderId);
|
|
|
int result = materialAscriptionMapper.insert(materialAscription);
|
|
@@ -617,21 +615,21 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
|
|
|
@Override
|
|
|
public JSONArray checkArrayCode(JSONArray array) {
|
|
|
- if(null == array||array.isEmpty()){
|
|
|
+ if (null == array || array.isEmpty()) {
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
- Map<String,String> codeMap = new HashMap<>();
|
|
|
+ Map<String, String> codeMap = new HashMap<>();
|
|
|
JSONArray resultArray = new JSONArray();
|
|
|
- for(int i=0;i<array.size();i++){
|
|
|
+ for (int i = 0; i < array.size(); i++) {
|
|
|
JSONObject data = array.getJSONObject(i);
|
|
|
- String url = "https:"+data.getString("url");
|
|
|
- data.put("url",url);
|
|
|
+ String url = "https:" + data.getString("url");
|
|
|
+ data.put("url", url);
|
|
|
String code = MD5Util.md5ByUrl(url);
|
|
|
- if(codeMap.containsKey(code)){
|
|
|
+ if (codeMap.containsKey(code)) {
|
|
|
continue;
|
|
|
}
|
|
|
- codeMap.put(code,code);
|
|
|
- data.put("code",code);
|
|
|
+ codeMap.put(code, code);
|
|
|
+ data.put("code", code);
|
|
|
resultArray.add(data);
|
|
|
}
|
|
|
return resultArray;
|
|
@@ -728,17 +726,17 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
//TODO 需要添加获取设计负责人代码
|
|
|
SysUser clip = userService.getById(clipId);
|
|
|
String roleCode = userService.getRoleCodeByUserId(clipId);
|
|
|
- log.info("剪辑人员名称:"+clip.getRealname()+";ID:"+clipId);
|
|
|
+ log.info("剪辑人员名称:" + clip.getRealname() + ";ID:" + clipId);
|
|
|
String leaderName = "";
|
|
|
String leaderId = "";
|
|
|
- if("designTeamLeader".equals(roleCode)){
|
|
|
+ if ("designTeamLeader".equals(roleCode)) {
|
|
|
leaderId = clipId;
|
|
|
leaderName = clip.getRealname();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
leaderId = clip.getLeaderId();
|
|
|
leaderName = clip.getLeaderName();
|
|
|
}
|
|
|
- log.info("负责人名称:"+leaderName+";ID:"+leaderId);
|
|
|
+ log.info("负责人名称:" + leaderName + ";ID:" + leaderId);
|
|
|
materialAscription.setLeaderName(leaderName);
|
|
|
materialAscription.setLeaderId(leaderId);
|
|
|
int result = materialAscriptionMapper.insert(materialAscription);
|
|
@@ -763,6 +761,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
}
|
|
|
return resultMap;
|
|
|
}
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
|
|
|
@@ -935,7 +934,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Map<String, Object> getListByParams(String tagCode, String type, Integer status, String materialName, List<Long> projectIds, String code, String startDate, String endDate, String userId, String clipId, String shotId, String planId, String leaderName,Integer offlineFlag, Integer pageNo, Integer pageSize) {
|
|
|
+ public Map<String, Object> getListByParams(String tagCode, String type, Integer status, String materialName, List<Long> projectIds, String code, String startDate, String endDate, String userId, String clipId, String shotId, String planId, String leaderName, Integer offlineFlag, Integer pageNo, Integer pageSize) {
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
PageHelper.startPage(pageNo, pageSize);
|
|
|
|
|
@@ -953,10 +952,10 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
endDate = endDate + " 23:59:59";
|
|
|
}
|
|
|
|
|
|
- List<MaterialInfo> dailyList = materialInfoMapper.getListByParams(tagCode, type, status, materialName, code, startDate, endDate, userId, projectIds, ascription, clipId, shotId, planId,leaderName, offlineFlag);
|
|
|
+ List<MaterialInfo> dailyList = materialInfoMapper.getListByParams(tagCode, type, status, materialName, code, startDate, endDate, userId, projectIds, ascription, clipId, shotId, planId, leaderName, offlineFlag);
|
|
|
List<MaterialInfo> setList = new ArrayList<>();
|
|
|
PageInfo<MaterialInfo> pageInfo = new PageInfo<>(dailyList);
|
|
|
- if (null != dailyList && !dailyList.isEmpty()) {
|
|
|
+ if (!dailyList.isEmpty()) {
|
|
|
for (MaterialInfo info : dailyList) {
|
|
|
MaterialInfo materialInfo = materialInfoMapper.selectById(info.getId());
|
|
|
materialInfo.setSlogansCount(info.getSlogansCount());
|
|
@@ -1001,18 +1000,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
imageInfoQueryWrapper.eq("video_id", info.getCode());
|
|
|
imageInfoQueryWrapper.eq("status", 0);
|
|
|
List<MaterialImageInfo> imageInfoList = materialImageInfoService.list(imageInfoQueryWrapper);
|
|
|
- if (Check.isNull(imageInfoList)) {
|
|
|
- materialInfo.setWhetherUnaudited(false);
|
|
|
- } else {
|
|
|
- materialInfo.setWhetherUnaudited(true);
|
|
|
- }
|
|
|
- //统计广告语数量
|
|
|
-// List<BytedanceVideoSlogenInfo> slogenInfos = slogenInfoService.listByParams(materialInfo.getCode(), 1);
|
|
|
-// JSONArray slogenArray = new JSONArray();
|
|
|
-// if (null != slogenInfos && !slogenInfos.isEmpty()) {
|
|
|
-// slogenArray.addAll(slogenInfos);
|
|
|
-// }
|
|
|
-// materialInfo.setSlogans(slogenArray);
|
|
|
+ materialInfo.setWhetherUnaudited(!Check.isNull(imageInfoList));
|
|
|
setList.add(materialInfo);
|
|
|
}
|
|
|
}
|