Jelajahi Sumber

清洗项目素材

zhaoxian 4 tahun lalu
induk
melakukan
5b04b78332

+ 46 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouProjectVideoGetJob.java

@@ -1,10 +1,16 @@
 package cn.com.ctop.job.kuaishou.handler;
 
+import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IProjectService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouProjectVideoGetService;
+import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -20,21 +26,60 @@ import java.util.concurrent.Executors;
  * @return
  * @throws
  */
+@Slf4j
 @Component
 public class KuaishouProjectVideoGetJob {
     @Autowired
     private IKuaishouProjectVideoGetService projectVideoGetService;
     @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+    @Autowired
     private IProjectService projectService;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
     static ExecutorService executorService = Executors.newFixedThreadPool(5);
 
     @XxlJob("kuaishouProjectVideoGetJob")
     public void execute() throws Exception {
+        log.info("同步素造素材供应商-------start");
+        kuaishouSupplierVideoGet();
+        Thread.sleep(60000);
+        log.info("清洗项目素材-------start");
+        kuaishouProjectVideoGet();
+    }
+
+
+    /**
+     * 获取供应商信息
+     */
+    private void kuaishouSupplierVideoGet() {
+        List<JSONObject> datas = videoGetService.getAccountIds();
+        for (JSONObject data : datas) {
+            CtopOauthToken token = tokenService.getTokenByAccountId(data.getLong("accountId"));
+            if (Check.isNull(token)) {
+                continue;
+            }
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    videoGetService.getSuZaoList(token.getAccessToken(), data.getLong("accountId"), 1, data.getString("startDate"));
+                }
+            });
+        }
+        XxlJobHelper.log("同步素造素材供应商完成");
+    }
+
+    /**
+     * 素材清洗
+     */
+    private void kuaishouProjectVideoGet() {
         //2快手,1开启的项目
         List<Project> projects = projectService.listByMediaType(2, 0);
         projects.forEach(project -> executorService.submit(() -> {
-            projectVideoGetService.clearProjectVideo(project.getId(),1,null);
+            projectVideoGetService.clearProjectVideo(project.getId(), 1, null);
         }));
         XxlJobHelper.log("清洗项目素材完成");
     }
+
 }

+ 0 - 50
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouSupplierVideoGetJob.java

@@ -1,50 +0,0 @@
-package cn.com.ctop.job.kuaishou.handler;
-
-import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
-import com.alibaba.fastjson.JSONObject;
-import com.xxl.job.core.context.XxlJobHelper;
-import com.xxl.job.core.handler.annotation.XxlJob;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * 同步素造素材供应商
- *
- * @param
- * @author ZHAOXA
- * @return
- * @throws
- */
-@Component
-public class KuaishouSupplierVideoGetJob {
-    @Autowired
-    private IKuaiShouVideoGetService videoGetService;
-    @Autowired
-    private ICtopOauthTokenService tokenService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(5);
-
-    @XxlJob("kuaishouSupplierVideoGetJob")
-    public void execute() throws Exception {
-        List<JSONObject> datas = videoGetService.getAccountIds();
-        for (JSONObject data : datas) {
-            CtopOauthToken token = tokenService.getTokenByAccountId(data.getLong("accountId"));
-            if (Check.isNull(token)) {
-                continue;
-            }
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    videoGetService.getSuZaoList(token.getAccessToken(), data.getLong("accountId"), 1, data.getString("startDate"));
-                }
-            });
-        }
-        XxlJobHelper.log("同步素造素材供应商完成");
-    }
-}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouVideoGetMapper.xml

@@ -313,7 +313,7 @@
     </select>
 
     <select id="getAccountIds" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT account_id 'accountId',DATE_FORMAT(MAX(create_time), '%Y-%m-%d %H:%i:%s') 'startDate'
+        SELECT account_id 'accountId',DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 65 MINUTE), '%Y-%m-%d %H:%i:%s') 'startDate'
         FROM ctop_kuaishou_video_get
         where channel_type = 1
           and status = 0