|
@@ -48,14 +48,15 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
private IVideoWatermarkTemplateService videoWatermarkTemplateService;
|
|
|
@Autowired
|
|
|
private IVideoWatermarkTaskService videoWatermarkTaskService;
|
|
|
+
|
|
|
@Override
|
|
|
- public void watermarkVideo(String materialId,Integer videoWatermarkTemplateId,String userId){
|
|
|
+ public void watermarkVideo(String materialId, Integer videoWatermarkTemplateId, String userId) {
|
|
|
VideoWatermarkTemplate videoWatermarkTemplate = videoWatermarkTemplateService.getById(videoWatermarkTemplateId);
|
|
|
MaterialInfo materialInfo = this.getById(materialId);
|
|
|
MpsUtils mpsUtils = new MpsUtils();
|
|
|
- String path = materialInfo.getUrl().substring(materialInfo.getUrl().indexOf("/",10)+1,materialInfo.getUrl().length());
|
|
|
+ String path = materialInfo.getUrl().substring(materialInfo.getUrl().indexOf("/", 10) + 1, materialInfo.getUrl().length());
|
|
|
System.out.println(path);
|
|
|
- String jobId = mpsUtils.videoWaterMark(path,videoWatermarkTemplate.getTemplatePath(),videoWatermarkTemplate.getTemplateId(),videoWatermarkTemplate.getHeight());
|
|
|
+ String jobId = mpsUtils.videoWaterMark(path, videoWatermarkTemplate.getTemplatePath(), videoWatermarkTemplate.getTemplateId(), videoWatermarkTemplate.getHeight());
|
|
|
QueryJobListResponse.Job job = mpsUtils.getJobStatus(jobId);
|
|
|
VideoWatermarkTask videoWatermarkTask = new VideoWatermarkTask();
|
|
|
videoWatermarkTask.setJobId(jobId);
|
|
@@ -111,62 +112,43 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
try {
|
|
|
String type = jsonObject.getString("type");
|
|
|
- MaterialInfo info = new MaterialInfo();
|
|
|
- info.setId(jsonObject.getString("code"));
|
|
|
- info.setCode(jsonObject.getString("code"));
|
|
|
+ if ("IMAGE".equals(type)) {
|
|
|
+ JSONArray imageArr = jsonObject.getJSONArray("imageArr");
|
|
|
+ if (!Check.isNull(imageArr)) {
|
|
|
+ jsonObject.remove("imageArr");
|
|
|
+ for (int i = 0; i < imageArr.size(); i++) {
|
|
|
+ String url = imageArr.getString(i);
|
|
|
+ if (!Check.isNull(url)) {
|
|
|
+ jsonObject.remove("code");
|
|
|
+ jsonObject.remove("materialName");
|
|
|
+ url = "https:" + url;
|
|
|
+ String localPath = LoadFileUtil.downLoadFromUrl(url, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));
|
|
|
+ // String localPath = LoadFileUtil.downLoadFromUrl(url, "D:\\tets1\\image");
|
|
|
+ String md5 = LoadFileUtil.getMD5(localPath);
|
|
|
+ jsonObject.put("code", md5);
|
|
|
+ LoadFileUtil.delFile(localPath);
|
|
|
+ String fileName = url.substring(url.lastIndexOf("/") + 1);
|
|
|
+ String fileNameStr = null;
|
|
|
+ if (!Check.isNull(fileName)) {
|
|
|
+ String[] split = fileName.split("-");
|
|
|
+ fileNameStr = split[0];
|
|
|
+ }
|
|
|
+ jsonObject.put("materialName", AesEncryptUtil.getUrlDecoderString(fileNameStr));
|
|
|
+
|
|
|
+ insertMaterialInfo(url, type, jsonObject);
|
|
|
+ }
|
|
|
|
|
|
- if (!Check.isNull(jsonObject.getString("watermarkUrl"))) {
|
|
|
- info.setWatermarkUrl("https:" + jsonObject.getString("watermarkUrl"));
|
|
|
- }
|
|
|
- if (!Check.isNull(jsonObject.getString("url"))) {
|
|
|
- info.setUrl("https:" + jsonObject.getString("url"));
|
|
|
- }
|
|
|
- info.setUserId(jsonObject.getString("userId"));
|
|
|
- info.setProjectId(jsonObject.getLong("projectId"));
|
|
|
- info.setWatermarkCode(jsonObject.getString("watermarkCode"));
|
|
|
- info.setStatus(0);
|
|
|
- info.setMaterialName(jsonObject.getString("materialName"));
|
|
|
- info.setWatermarkMaterialName(jsonObject.getString("watermarkMaterialName"));
|
|
|
- info.setMaterialDescribe(jsonObject.getString("materialDescribe"));
|
|
|
- info.setCreateTime(new Date());
|
|
|
- info.setUpdateTime(new Date());
|
|
|
- info.setType(type);
|
|
|
- this.save(info);
|
|
|
- Map<String, Object> deleteMap = new HashMap<>();
|
|
|
- deleteMap.put("material_id", info.getId());
|
|
|
-
|
|
|
- JSONObject ascription = jsonObject.getJSONObject("ascription");
|
|
|
- if (!Check.isNull(ascription)) {
|
|
|
- MaterialAscription materialAscription = new MaterialAscription();
|
|
|
- materialAscription.setMaterialId(info.getId());
|
|
|
- // 剪辑人
|
|
|
- materialAscription.setClipId(ascription.getString("clipId"));
|
|
|
- // 拍摄人id
|
|
|
- materialAscription.setShotId(ascription.getString("shotId"));
|
|
|
- // 策划id
|
|
|
- materialAscription.setPlanId(ascription.getString("planId"));
|
|
|
- //平面id
|
|
|
- materialAscription.setPlaneId(ascription.getString("planeId"));
|
|
|
- materialAscriptionMapper.deleteByMap(deleteMap);
|
|
|
- int i = materialAscriptionMapper.insert(materialAscription);
|
|
|
- if (i > 0) {
|
|
|
- log.info("素材归属信息入库完成,MaterialId:{}", info.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- JSONArray tag = jsonObject.getJSONArray("tag");
|
|
|
- if (!Check.isNull(tag)) {
|
|
|
- materialTagMapper.deleteByMap(deleteMap);
|
|
|
- for (int i = 0; i < tag.size(); i++) {
|
|
|
- String tagStr = tag.getString(i);
|
|
|
- if (!Check.isNull(tagStr)) {
|
|
|
- MaterialTag materialTag = new MaterialTag();
|
|
|
- materialTag.setMaterialId(info.getId());
|
|
|
- materialTag.setTag(tagStr);
|
|
|
- materialTagMapper.insert(materialTag);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ } else {
|
|
|
+ String url = "";
|
|
|
+ if (!Check.isNull(jsonObject.getString("url"))) {
|
|
|
+ url = "https:" + jsonObject.getString("url");
|
|
|
+ }
|
|
|
+ insertMaterialInfo(url, type, jsonObject);
|
|
|
}
|
|
|
- getFile(info);
|
|
|
+
|
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
|
|
|
} catch (Exception e) {
|
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.MATERIAL_UPLOAD_FAIL.getCode());
|
|
@@ -179,6 +161,68 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
|
|
|
}
|
|
|
|
|
|
|
|
|
+ private void insertMaterialInfo(String url, String type, JSONObject jsonObject) {
|
|
|
+ MaterialInfo info = new MaterialInfo();
|
|
|
+ info.setId(jsonObject.getString("code"));
|
|
|
+ info.setCode(jsonObject.getString("code"));
|
|
|
+
|
|
|
+ if (!Check.isNull(jsonObject.getString("watermarkUrl"))) {
|
|
|
+ info.setWatermarkUrl(jsonObject.getString("watermarkUrl"));
|
|
|
+ }
|
|
|
+ info.setUrl(url);
|
|
|
+ info.setUserId(jsonObject.getString("userId"));
|
|
|
+ info.setProjectId(jsonObject.getLong("projectId"));
|
|
|
+ info.setWatermarkCode(jsonObject.getString("watermarkCode"));
|
|
|
+ info.setStatus(0);
|
|
|
+ info.setMaterialName(jsonObject.getString("materialName"));
|
|
|
+ info.setWatermarkMaterialName(jsonObject.getString("watermarkMaterialName"));
|
|
|
+ info.setMaterialDescribe(jsonObject.getString("materialDescribe"));
|
|
|
+ info.setCreateTime(new Date());
|
|
|
+ info.setUpdateTime(new Date());
|
|
|
+ info.setType(type);
|
|
|
+ this.save(info);
|
|
|
+
|
|
|
+ Map<String, Object> deleteMap = new HashMap<>();
|
|
|
+ deleteMap.put("material_id", info.getId());
|
|
|
+
|
|
|
+ JSONObject ascription = jsonObject.getJSONObject("ascription");
|
|
|
+ if (!Check.isNull(ascription)) {
|
|
|
+ MaterialAscription materialAscription = new MaterialAscription();
|
|
|
+ materialAscription.setMaterialId(info.getId());
|
|
|
+ // 剪辑人
|
|
|
+ materialAscription.setClipId(ascription.getString("clipId"));
|
|
|
+ // 拍摄人id
|
|
|
+ materialAscription.setShotId(ascription.getString("shotId"));
|
|
|
+ // 策划id
|
|
|
+ materialAscription.setPlanId(ascription.getString("planId"));
|
|
|
+ //平面id
|
|
|
+ materialAscription.setPlaneId(ascription.getString("planeId"));
|
|
|
+ materialAscriptionMapper.deleteByMap(deleteMap);
|
|
|
+ int i = materialAscriptionMapper.insert(materialAscription);
|
|
|
+ if (i > 0) {
|
|
|
+ log.info("素材归属信息入库完成,MaterialId:{}", info.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray tag = jsonObject.getJSONArray("tag");
|
|
|
+ if (!Check.isNull(tag)) {
|
|
|
+ materialTagMapper.deleteByMap(deleteMap);
|
|
|
+ for (int i = 0; i < tag.size(); i++) {
|
|
|
+ String tagStr = tag.getString(i);
|
|
|
+ if (!Check.isNull(tagStr)) {
|
|
|
+ MaterialTag materialTag = new MaterialTag();
|
|
|
+ materialTag.setMaterialId(info.getId());
|
|
|
+ materialTag.setTag(tagStr);
|
|
|
+ materialTagMapper.insert(materialTag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ getFile(info);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取素材详细信息
|
|
|
*
|