|
@@ -55,7 +55,6 @@ import static cn.com.ctop.common.module.utils.CloudVideoProcessUtil.videoWaterma
|
|
public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, MaterialInfo> implements IMaterialInfoService {
|
|
public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, MaterialInfo> implements IMaterialInfoService {
|
|
|
|
|
|
private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(5);
|
|
private static ExecutorService uploadExecutorService = Executors.newFixedThreadPool(5);
|
|
-
|
|
|
|
@Resource
|
|
@Resource
|
|
private ITencentWatermarkTemplateService tencentWatermarkTemplateService;
|
|
private ITencentWatermarkTemplateService tencentWatermarkTemplateService;
|
|
@Resource
|
|
@Resource
|
|
@@ -72,8 +71,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
private IMaterialCutFrameService materialCutFrameService;
|
|
private IMaterialCutFrameService materialCutFrameService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISupplierWatermarkService supplierWatermarkService;
|
|
private ISupplierWatermarkService supplierWatermarkService;
|
|
- @Resource
|
|
|
|
- private IProductService productService;
|
|
|
|
@Value("${oss.replace.download}")
|
|
@Value("${oss.replace.download}")
|
|
private String downloadUrl;
|
|
private String downloadUrl;
|
|
|
|
|
|
@@ -317,9 +314,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
getFile(info);
|
|
getFile(info);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -397,73 +392,66 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
log.info("获取素材基本信息,code:{}", materialInfo.getCode());
|
|
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;
|
|
|
|
- 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() {
|
|
|
|
|
|
+
|
|
|
|
+ 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
|
|
@Override
|
|
- public void run() {
|
|
|
|
- watermarkVideoBySupplierCode(materialInfo.getCode(), materialInfo.getUrl(), templateId);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- thread.start();
|
|
|
|
|
|
+ public void run() { watermarkVideoBySupplierCode(materialInfo.getCode(), materialInfo.getUrl(), templateId); }
|
|
|
|
+ };
|
|
|
|
+ thread.start();
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ } finally {
|
|
|
|
+ try {
|
|
|
|
+ if (fis != null) {
|
|
|
|
+ fis.close();
|
|
}
|
|
}
|
|
- } catch (FileNotFoundException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
- } catch (EncoderException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- } finally {
|
|
|
|
- try {
|
|
|
|
- if (fis != null) {
|
|
|
|
- fis.close();
|
|
|
|
- }
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
+ LoadFileUtil.delFile(localUrl);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -956,7 +944,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
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<>();
|
|
List<MaterialInfo> setList = new ArrayList<>();
|
|
PageInfo<MaterialInfo> pageInfo = new PageInfo<>(dailyList);
|
|
PageInfo<MaterialInfo> pageInfo = new PageInfo<>(dailyList);
|
|
- if (null != dailyList && !dailyList.isEmpty()) {
|
|
|
|
|
|
+ if (!dailyList.isEmpty()) {
|
|
for (MaterialInfo info : dailyList) {
|
|
for (MaterialInfo info : dailyList) {
|
|
MaterialInfo materialInfo = materialInfoMapper.selectById(info.getId());
|
|
MaterialInfo materialInfo = materialInfoMapper.selectById(info.getId());
|
|
materialInfo.setSlogansCount(info.getSlogansCount());
|
|
materialInfo.setSlogansCount(info.getSlogansCount());
|
|
@@ -1001,18 +989,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
imageInfoQueryWrapper.eq("video_id", info.getCode());
|
|
imageInfoQueryWrapper.eq("video_id", info.getCode());
|
|
imageInfoQueryWrapper.eq("status", 0);
|
|
imageInfoQueryWrapper.eq("status", 0);
|
|
List<MaterialImageInfo> imageInfoList = materialImageInfoService.list(imageInfoQueryWrapper);
|
|
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);
|
|
setList.add(materialInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|