Browse Source

添加清洗报表关联md5值逻辑

syh 5 years ago
parent
commit
618da65b37

+ 19 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyLoadFileJob.java

@@ -12,6 +12,7 @@ import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 
 
 import java.util.List;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Executors;
 
 
@@ -27,8 +28,11 @@ public class KuaishouDailyLoadFileJob implements Job {
     @Autowired
     @Autowired
     private ICtopOauthTokenService tokenService;
     private ICtopOauthTokenService tokenService;
     static ExecutorService executorService = null;
     static ExecutorService executorService = null;
+    static CountDownLatch countDownLatch = null;
     @Autowired
     @Autowired
     private IKuaiShouDailyReportTaskService dailyReportTaskService;
     private IKuaiShouDailyReportTaskService dailyReportTaskService;
+    @Autowired
+    private IKuaiShouDailyReportTaskService kuaiShouDailyReportTaskService;
 
 
     @Override
     @Override
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
@@ -44,14 +48,28 @@ public class KuaishouDailyLoadFileJob implements Job {
                     return;
                     return;
                 }
                 }
                 executorService = Executors.newFixedThreadPool(3);
                 executorService = Executors.newFixedThreadPool(3);
+                countDownLatch = new CountDownLatch(tokens.size());
                 for (CtopOauthToken token : tokens) {
                 for (CtopOauthToken token : tokens) {
                     executorService.submit(new Runnable() {
                     executorService.submit(new Runnable() {
                         @Override
                         @Override
                         public void run() {
                         public void run() {
-                            dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate);
+                            try {
+                                dailyReportTaskService.getTaskList(token.getAccountId(), token.getAccessToken(), statDate);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                countDownLatch.countDown();
+                            }
                         }
                         }
                     });
                     });
                 }
                 }
+                try {
+                    countDownLatch.await();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                kuaiShouDailyReportTaskService.formatCreativeDailyReportData(null, nowDate);
+                executorService.shutdown();
             }
             }
         };
         };
         thread.start();
         thread.start();

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouDailyReportTaskService.java

@@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @date 2020-03-12
  * @date 2020-03-12
  */
  */
 public interface IKuaiShouDailyReportTaskService extends IService<KuaiShouDailyReportTask> {
 public interface IKuaiShouDailyReportTaskService extends IService<KuaiShouDailyReportTask> {
+    void formatCreativeDailyReportData(Long accountId, String statDate);
+
     void getTaskList(Long accountId, String token, String statDate);
     void getTaskList(Long accountId, String token, String statDate);
 
 
 }
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouDailyReportTaskServiceImpl.java

@@ -47,6 +47,11 @@ public class KuaiShouDailyReportTaskServiceImpl extends ServiceImpl<KuaiShouDail
     @Autowired
     @Autowired
     private KuaishouReportDailyCreativeMapper reportDailyCreativeMapper;
     private KuaishouReportDailyCreativeMapper reportDailyCreativeMapper;
 
 
+    @Override
+    public void formatCreativeDailyReportData(Long accountId, String statDate) {
+        reportDailyCreativeMapper.formatCreativeDailyReportData(accountId, statDate);
+    }
+
     /**
     /**
      * 获取任务列表
      * 获取任务列表
      */
      */

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java

@@ -222,7 +222,7 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
 
 
                 } else if (task.getViewType() == 4) {
                 } else if (task.getViewType() == 4) {
                     reportDailyCreativeMapper.loadCreativeDailyReport(task.getAccountId(), localPath);
                     reportDailyCreativeMapper.loadCreativeDailyReport(task.getAccountId(), localPath);
-
+                    reportDailyCreativeMapper.formatCreativeDailyReportData(task.getAccountId(), null);
                 }
                 }
             }
             }
             task.setTaskStatus(4);
             task.setTaskStatus(4);

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouReportDailyCreativeMapper.java

@@ -6,4 +6,6 @@ import org.apache.ibatis.annotations.Param;
 
 
 public interface KuaishouReportDailyCreativeMapper extends BaseMapper<KuaishouReportDailyCreative> {
 public interface KuaishouReportDailyCreativeMapper extends BaseMapper<KuaishouReportDailyCreative> {
     void loadCreativeDailyReport(@Param("accountId") Long accountId, @Param("localPath") String localPath);
     void loadCreativeDailyReport(@Param("accountId") Long accountId, @Param("localPath") String localPath);
+
+    void formatCreativeDailyReportData(@Param("accountId") Long accountId, @Param("statDate") String statDate);
 }
 }

+ 24 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyCreativeMapper.xml

@@ -73,5 +73,28 @@
         )
         )
           set account_id = #{accountId}
           set account_id = #{accountId}
     </insert>
     </insert>
+    <update id="formatCreativeDailyReportData">
+        UPDATE
+        ctop_kuaishou_report_daily_creative_new t1
+        SET
+        t1.signature = (
+        SELECT
+        DISTINCT t3.signature
+        FROM
+        ctop_kuaishou_creative t2
+        LEFT JOIN
+        ctop_kuaishou_video_get t3 ON t2.photo_id = t3.photo_id
+        WHERE
+        t2.creative_id = t1.creative_id
+        )
+        WHERE
+        1=1
+        <if test="accountId != null">
+            and t1.account_id = #{accountId}
+        </if>
+        <if test="statDate != null">
+            and t1.stat_date = #{statDate}
+        </if>
+    </update>
 
 
-</mapper>
+</mapper>