Parcourir la source

修改头条视频推送逻辑

songyh il y a 3 ans
Parent
commit
c6800bb494

+ 4 - 6
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/FileInfoServiceImpl.java

@@ -51,8 +51,6 @@ import java.util.Map;
 public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> implements IFileInfoService {
     @Value("${jeecg.path.image-upload}")
     private String imageUploadPath;
-    @Value("${jeecg.path.video-upload}")
-    private String videoUploadPath;
     @Resource
     FileInfoMapper fileInfoMapper;
     @Resource
@@ -74,23 +72,23 @@ public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> i
             CtopOauthToken token = ctopOauthTokenService.getOauthTokenByAccountId(accountId);
             JSONObject jsonObject = videoUpload(token, videoUrl,materialName);
             if (Check.isNull(jsonObject)) {
-                log.info("头条上传素材返回结果为空,返回信息:{},accountId:{}", jsonObject, accountId);
+                log.info("头条视频素材推送信息==>返回结果为空,返回信息:{},accountId:{}", jsonObject, accountId);
                 String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, "头条上传素材返回结果为空");
                 sendMessageService.sendMessage(userId, message);
                 return ;
             }
             Integer code = jsonObject.getInteger("code");
             if (code == 0) {
-                log.info("头条上传素材成功,返回信息:{},accountId:{}", jsonObject, accountId);
+                log.info("头条视频素材推送信息==>上传素材成功,返回信息:{},accountId:{}", jsonObject, accountId);
                 String message = messageTemplate.getMaterialSyncSucessTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, jsonObject.getString("message"));
                 sendMessageService.sendMessage(userId, message);
                 return ;
             }
-            log.error("头条上传素材失败,返回信息:{},accountId:{}", jsonObject, accountId);
+            log.error("头条视频素材推送信息==>上传素材失败,返回信息:{},accountId:{}", jsonObject, accountId);
             String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, jsonObject.getString("message"));
             sendMessageService.sendMessage(userId, message);
         } catch (Exception e) {
-            log.error("头条上传视频文件失败,accountId:{}", accountId);
+            log.error("头条视频素材推送信息==>上传视频文件异常,accountId:{}", accountId);
             e.printStackTrace();
             String message = messageTemplate.getMaterialSyncTemplate(project.getProjectName(), accountId, userAllocation.getAuthName(), materialName, "头条api上传素材返回结果异常:系统异常,联系研发人员");
             sendMessageService.sendMessage(userId, message);

+ 11 - 23
jeecg-boot-module-system/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java

@@ -98,30 +98,18 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
                 log.info("头条视频素材推送异常=>id:{};message:{}",materialId,"素材不存在或者未审核通过");
                 continue;
             }
-            try {
-                String url = materialInfo.getUrl();
-                String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
-                for (int i = 0; i < accountArray.size(); i++) {
-                    Long accountId = accountArray.getLong(i);
-                    if (Check.isNull(accountId)) {
-                        continue;
-                    }
-                    touTiaoExecutorService.submit(new Runnable() {
-                        @Override
-                        public void run() {
-                            try {
-                                log.info("头条文件多线程上传:{},accountId:{}", Thread.currentThread().getName(), accountId);
-                                if ("VIDEO".equals(materialInfo.getType())) {
-                                    fileInfoService.uploadVideoToBytedance(String.valueOf(accountId), localUrl, userId, materialInfo.getMaterialName());
-                                }
-                            } catch (Exception e) {
-                                e.printStackTrace();
-                            }
-                        }
-                    });
+
+            String url = materialInfo.getUrl();
+            String localUrl = LoadFileUtil.downLoadFromUrl(url, downloadUrl);
+            for (int i = 0; i < accountArray.size(); i++) {
+                Long accountId = accountArray.getLong(i);
+                if (null == accountId||accountId == 0) {
+                    continue;
                 }
-            } catch (Exception e) {
-                e.printStackTrace();
+                touTiaoExecutorService.submit(()->{
+                    log.info("头条视频素材推送信息==>头条文件多线程上传:{},accountId:{}", Thread.currentThread().getName(), accountId);
+                    fileInfoService.uploadVideoToBytedance(String.valueOf(accountId), localUrl, userId, materialInfo.getMaterialName());
+                });
             }
         }
     }

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialUploadController.java

@@ -36,6 +36,7 @@ public class MaterialUploadController {
     @PostMapping(value = "/uploadAccount")
     public Map<String, Object> uploadAccount(@RequestBody JSONObject json) {
         Map<String, Object> returnMap = new HashMap<>();
+        log.info("头条视频素材推送信息=={}",json);
         String mediaId = json.getString("mediaId");
         Boolean shieldBackwardSwitch = json.getBoolean("shieldBackwardSwitch");
         JSONArray materialArray = json.getJSONArray("materialArray");