瀏覽代碼

批量本地上传素材

yumeng 5 年之前
父節點
當前提交
35cb5fad2b

+ 19 - 17
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouMaterialUploadServiceImpl.java

@@ -1,15 +1,17 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
 import cn.com.ctop.common.module.enums.MaterialEnum;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.utils.LoadFileUtil;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouMaterialUploadService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.FileSystemResource;
@@ -25,7 +27,6 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.io.File;
 import java.io.IOException;
-import java.net.URLDecoder;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -40,6 +41,8 @@ public class KuaiShouMaterialUploadServiceImpl implements IKuaiShouMaterialUploa
     private IKuaiShouImageGetService iKuaiShouImageGetService;
     @Autowired
     private IKuaiShouVideoGetService kuaiShouVideoGetService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
 
     /**
      * 上传文件
@@ -72,23 +75,22 @@ public class KuaiShouMaterialUploadServiceImpl implements IKuaiShouMaterialUploa
                     JSONObject dataJson = resultJson.getJSONObject("data");
                     if (!Check.isNull(dataJson)) {
                         String photoId = dataJson.getString("photo_id");
-                        KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
-                        videoGet.setAccountId(accountId);
-                        videoGet.setId(accountId + photoId);
-                        videoGet.setUrl(url);
-                        videoGet.setMaterialType(type);
-                        videoGet.setPhotoId(photoId);
-                        videoGet.setSignature(signature);
-                        videoGet.setStatDate(DateUtils.getNowDate());
-                        String videoUrl = URLDecoder.decode(url).replace("https://media-1301855440.cos.ap-chongqing.myqcloud.com/", "");
-                        String loadImage = "cutFrame/" + signature + "/zero.jpg";
-                        String coverUrl = CloudVideoProcessUtil.videoCutPictureHandle(videoUrl, loadImage);
-                        videoGet.setCoverUrl(coverUrl);
-                        kuaiShouVideoGetService.saveOrUpdate(videoGet);
                         returnJson.put("success", true);
                         returnJson.put("photoId", photoId);
                         returnJson.put("signature", signature);
                         returnJson.put("message", "上传成功");
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                try {
+                                    Thread.sleep(2 * 1000L);
+                                    kuaishouInterfaceService.getVideoInfo(accessToken, accountId, photoId);
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        };
+                        thread.start();
                     }
                     LoadFileUtil.delFile(localUrl);
                     log.info("快手素材上传完成,accountId:{},code:{},返回信息:{}", accountId, signature, resultJson);