Browse Source

添加头条素材推送结果日志

songyh 4 years ago
parent
commit
5d9f77ec2e

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

@@ -94,6 +94,42 @@ public class MaterialUploadServiceImpl implements IMaterialUploadService {
         for (int j = 0; j < materialArray.size(); j++) {
         for (int j = 0; j < materialArray.size(); j++) {
             String materialId = materialArray.getString(j);
             String materialId = materialArray.getString(j);
             MaterialInfo materialInfo = materialInfoMapper.selectById(materialId);
             MaterialInfo materialInfo = materialInfoMapper.selectById(materialId);
+            if (null == materialInfo||materialInfo.getStatus()!=1) {
+                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();
+                            }
+                        }
+                    });
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    private void touTiaoUploadV2(String mediaId, JSONArray materialArray, JSONArray accountArray, String userId) {
+        for (int j = 0; j < materialArray.size(); j++) {
+            String materialId = materialArray.getString(j);
+            MaterialInfo materialInfo = materialInfoMapper.selectById(materialId);
             MaterialImageInfo materialImageInfo = materialImageInfoMapper.selectById(materialId);
             MaterialImageInfo materialImageInfo = materialImageInfoMapper.selectById(materialId);
             if (Check.isNull(materialInfo) && Check.isNull(materialImageInfo)) {
             if (Check.isNull(materialInfo) && Check.isNull(materialImageInfo)) {
                 continue;
                 continue;

+ 5 - 7
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -57,7 +57,8 @@ public class ProjectMemberController {
     private IAdvertiserService advertiserService;
     private IAdvertiserService advertiserService;
     @Autowired
     @Autowired
     private IUserAllocationService userAllocationService;
     private IUserAllocationService userAllocationService;
-
+    @Autowired
+    private IProductService productService;
 
 
     /**
     /**
      * 查看项目成员
      * 查看项目成员
@@ -91,9 +92,6 @@ public class ProjectMemberController {
      * @param userId
      * @param userId
      * @return
      * @return
      */
      */
-    @Autowired
-    private IProductService productService;
-
     @GetMapping(value = "/participateList")
     @GetMapping(value = "/participateList")
     public Map<String, Object> participateList(String userId) {
     public Map<String, Object> participateList(String userId) {
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
@@ -512,11 +510,11 @@ public class ProjectMemberController {
      * @return
      * @return
      */
      */
     @GetMapping("/getProjectAccountByUserId")
     @GetMapping("/getProjectAccountByUserId")
-    public Result<List<Map<String, Object>>> getProjectAccountBy(String mediaType,String userId) {
+    public Result<List<Map<String, Object>>> getProjectAccountBy(String mediaType) {
         Result<List<Map<String, Object>>> resultBody = new Result<>();
         Result<List<Map<String, Object>>> resultBody = new Result<>();
         try {
         try {
-
-            List<Map<String, Object>> result = projectMemberService.getProjectAccountByUserId(userId, mediaType);
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            List<Map<String, Object>> result = projectMemberService.getProjectAccountByUserId(user.getId(), mediaType);
             resultBody.setSuccess(true);
             resultBody.setSuccess(true);
             resultBody.setResult(result);
             resultBody.setResult(result);
         } catch (Exception e) {
         } catch (Exception e) {