yumeng 4 vuotta sitten
vanhempi
commit
c4f5af9706

+ 29 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouMaterialSyncMd5Job.java

@@ -0,0 +1,29 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import static org.jeecg.common.util.DateUtils.getAnotherDay;
+
+/**
+ * 检查前一天md5为空的数据
+ *
+ * @author yumeng
+ */
+@Component
+public class KuaishouMaterialSyncMd5Job {
+    @Autowired
+    private IKuaiShouHistoryReportTaskService historyReportTaskService;
+
+    @XxlJob("kuaishouMaterialSyncMd5Job")
+    public ReturnT<String> execute(String param) throws Exception {
+        String nowDate = DateUtils.getDate("yyyy-MM-dd");
+        String statDate = getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        historyReportTaskService.getMd5V2(statDate);
+        return ReturnT.SUCCESS;
+    }
+}

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

@@ -20,5 +20,7 @@ public interface KuaiShouReportDailyMaterialMapper extends BaseMapper<KuaiShouRe
 
     List<KuaiShouReportDailyMaterialVo> getPhotoList(@Param("accountId") Long accountId, @Param("statDate") String statDate);
 
-    VideoGetvo getVideoGetByPhotoId(Long photoId);
+    VideoGetvo getVideoGetByPhotoId(@Param("photoId") Long photoId);
+
+    List<KuaiShouReportDailyMaterialVo> getPhotoListByDate(@Param("statDate") String statDate);
 }

+ 18 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouReportDailyMaterialMapper.xml

@@ -108,15 +108,28 @@
     </insert>
 
     <select id="getPhotoList" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterialVo">
+           select
+           id as id,
+           photo_id as photoId
+           from
+           ctop_kuaishou_report_daily_material
+           where account_id = #{accountId}
+           <if test="statDate != null and statDate != '' ">
+               and stat_date = #{statDate}
+           </if>
+           group by photo_id
+
+    </select>
+
+    <select id="getPhotoListByDate"
+            resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterialVo">
         select
         id as id,
         photo_id as photoId
         from
         ctop_kuaishou_report_daily_material
-        where account_id = #{accountId}
-        <if test="statDate != null and statDate != '' ">
-            and stat_date = #{statDate}
-        </if>
+        WHERE stat_data = #{statDate}
+        and signature is null
         group by photo_id
     </select>
 
@@ -126,6 +139,7 @@
       channel_type as 'channelType'
       from ctop_kuaishou_video_get
       where photo_id = #{photoId}
+      and signature is not null
       limit 1
     </select>
 

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

@@ -16,4 +16,6 @@ public interface IKuaiShouHistoryReportTaskService extends IService<KuaiShouHist
     void getTaskList();
 
     void getMd5(String statDate, Long accountId);
+
+    void getMd5V2(String statDate);
 }

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

@@ -289,54 +289,23 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
     }
 
 
-
-    static ExecutorService executorService = Executors.newFixedThreadPool(30);
+    static ExecutorService executorService = Executors.newFixedThreadPool(20);
 
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
 
     @Override
     public void getMd5(String statDate, Long accountId) {
-
-        executorService.submit(new Runnable() {
-            @Override
-            public void run() {
-                List<KuaiShouReportDailyMaterialVo> photoList = kuaishouReportDailyMaterialMapper.getPhotoList(accountId, statDate);
-                if (!Check.isNull(photoList)) {
-                    for (KuaiShouReportDailyMaterialVo materialVo : photoList) {
-                        Long photoId = materialVo.getPhotoId();
-                        VideoGetvo videoGetvo = kuaishouReportDailyMaterialMapper.getVideoGetByPhotoId(photoId);
-                        if (!Check.isNull(videoGetvo)) {
-                            QueryWrapper<KuaiShouReportDailyMaterial> updateQueryWrapper = new QueryWrapper<>();
-                            updateQueryWrapper.eq("photo_id", photoId);
-                            if (!Check.isNull(statDate)) {
-                                updateQueryWrapper.eq("stat_date", statDate);
-                            }
-
-                            KuaiShouReportDailyMaterial material = new KuaiShouReportDailyMaterial();
-                            material.setSignature(videoGetvo.getSignature());
-                            material.setChannelType(videoGetvo.getChannelType());
-                            kuaishouReportDailyMaterialMapper.update(material, updateQueryWrapper);
-                            XxlJobLogger.log("修改成功:photoId:{},accountId:{}", photoId, accountId);
-
-                        }
-
-                    }
-                }
-            }
-        });
-
-       /* QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
+        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("media_id", 2);
         List<CtopOauthToken> list = oauthTokenService.list(queryWrapper);
         for (CtopOauthToken token : list) {
-            List<KuaiShouReportDailyMaterialVo> photoList = kuaishouReportDailyMaterialMapper.getPhotoList(token.getAccountId(), null);
+            List<KuaiShouReportDailyMaterialVo> photoList = kuaishouReportDailyMaterialMapper.getPhotoList(token.getAccountId(), statDate);
             if (!Check.isNull(photoList)) {
                 for (KuaiShouReportDailyMaterialVo materialVo : photoList) {
                     executorService.submit(new Runnable() {
                         @Override
                         public void run() {
-                            //        Long id = materialVo.getId();
                             Long photoId = materialVo.getPhotoId();
                             VideoGetvo videoGetvo = kuaishouReportDailyMaterialMapper.getVideoGetByPhotoId(photoId);
                             if (!Check.isNull(videoGetvo)) {
@@ -348,7 +317,6 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
                                 material.setChannelType(videoGetvo.getChannelType());
                                 kuaishouReportDailyMaterialMapper.update(material, updateQueryWrapper);
                                 log.info("修改成功:photoId:{},accountId", photoId, token.getAccountId());
-                                // kuaishouReportDailyMaterialMapper.updateById(material);
                             }
                         }
                     });
@@ -357,9 +325,45 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
             }
 
 
-        }*/
+        }
+
+
+    }
+
+    @Override
+    public void getMd5V2(String statDate) {
+        List<KuaiShouReportDailyMaterialVo> photoList = kuaishouReportDailyMaterialMapper.getPhotoListByDate(statDate);
+        if (!Check.isNull(photoList)) {
+            for (KuaiShouReportDailyMaterialVo materialVo : photoList) {
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        Long photoId = materialVo.getPhotoId();
+                        VideoGetvo videoGetvo = kuaishouReportDailyMaterialMapper.getVideoGetByPhotoId(photoId);
+                        if (!Check.isNull(videoGetvo)) {
+                            QueryWrapper<KuaiShouReportDailyMaterial> updateQueryWrapper = new QueryWrapper<>();
+                            updateQueryWrapper.eq("photo_id", photoId);
+                            if (!Check.isNull(statDate)) {
+                                updateQueryWrapper.eq("stat_date", statDate);
+                            }
+
+                            KuaiShouReportDailyMaterial material = new KuaiShouReportDailyMaterial();
+                            material.setSignature(videoGetvo.getSignature());
+                            material.setChannelType(videoGetvo.getChannelType());
+                            kuaishouReportDailyMaterialMapper.update(material, updateQueryWrapper);
+                            XxlJobLogger.log("修改成功:photoId:{}", photoId);
+
+                        }
+
+
+                    }
+                });
+
+            }
+        }
 
 
     }
 
+
 }