Ver código fonte

快手素材报表效率提升 加入 etl_kuaishou_video_base_info 表

yumeng 4 anos atrás
pai
commit
067539e162

+ 18 - 7
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEtlVideoJob.java

@@ -1,7 +1,7 @@
 package cn.com.ctop.job.kuaishou.handler;
 
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
-import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,21 +13,32 @@ import java.util.Date;
 public class KuaishouEtlVideoJob {
     @Autowired
     private IKuaishouVideoEtlInfoService kuaishouVideoEtlInfoService;
+    @Autowired
+    private IKuaiShouVideoGetService videoGetService;
+
     @XxlJob("kuaishouEtlVideoJob")
     public void execute() throws Exception {
-        Date startDate = DateUtils.addDay(new Date(),-2);
-        for(int i=0;i<=2;i++){
-            Date getDate = DateUtils.addDay(startDate,i);
+        Date startDate = DateUtils.addDay(new Date(), -2);
+        for (int i = 0; i <= 2; i++) {
+            Date getDate = DateUtils.addDay(startDate, i);
             kuaishouVideoEtlInfoService.etlKuaishouVideoInfo(getDate);
         }
     }
 
     @XxlJob("kuaishouEtlProjectVideoJob")
     public void kuaishouEtlProjectVideoJob() throws Exception {
-        Date startDate = DateUtils.addDay(new Date(),-2);
-        for(int i=0;i<=2;i++){
-            Date getDate = DateUtils.addDay(startDate,i);
+        Date startDate = DateUtils.addDay(new Date(), -2);
+        for (int i = 0; i <= 2; i++) {
+            Date getDate = DateUtils.addDay(startDate, i);
             kuaishouVideoEtlInfoService.etlKuaishouVideoInfoGroupByProjectId(getDate);
         }
     }
+
+    @XxlJob("kuaishouEtlVideoBaseInfoJob")
+    public void kuaishouEtlVideoBaseInfoJob() throws Exception {
+        String statDate = DateUtils.getStartTime(DateUtils.addDay(new Date(), -1));
+        videoGetService.etlVideoBaseInfoByStaDate(statDate);
+    }
+
+
 }

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

@@ -28,4 +28,6 @@ public interface KuaiShouVideoGetMapper extends BaseMapper<KuaiShouVideoGet> {
     List<JSONObject> getVideoListByMap(Map<String, Object> requestMap);
 
     List<KuaiShouVideoGet> getPhotoIdsByParams(Long accountId, String signature);
+
+    void etlVideoBaseInfoByStaDate(@Param("statDate") String statDate);
 }

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

@@ -372,7 +372,7 @@ where
         photo_id as 'photoId',
         signature as 'signature',
         channel_type as 'channelType'
-        from ctop_kuaishou_video_get
+        from ctop_etl_kuaishou_video_base_info
         where photo_id in
         <foreach collection="photoIdList" item="item" separator=","
                  open="(" close=")">

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

@@ -125,6 +125,20 @@
         and signature = #{signature}
         and status = 0
     </select>
-
+    <insert id="etlVideoBaseInfoByStaDate">
+    replace INTO ctop_etl_kuaishou_video_base_info (
+	signature,
+	channel_type,
+	photo_id
+    ) SELECT
+	signature,
+	channel_type,
+	photo_id
+  FROM
+	ctop_kuaishou_video_get
+	where  stat_date >= #{statDate}
+   GROUP BY
+	photo_id
+ </insert>
 
 </mapper>

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

@@ -5,6 +5,7 @@ import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -35,4 +36,6 @@ public interface IKuaiShouVideoGetService extends IService<KuaiShouVideoGet> {
     List<KuaiShouVideoGet> selectPhotoIdsByAccountId(Long accountId);
 
     KuaiShouVideoGet getVideoByPhotoId(Long photo_id);
+
+    void etlVideoBaseInfoByStaDate(String statDate);
 }

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

@@ -6,7 +6,6 @@ import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouReportDailyMaterialMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportDailyMaterialService;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaiShouReportDailyMaterial;
-import cn.com.ctop.kuaishou.modules.report.entity.VideoGetvo;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -72,7 +71,7 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
             return;
         }
         List<KuaiShouReportDailyMaterial> addList = new ArrayList<>();
-     //   List<Long> photoIdList = new ArrayList<>();
+        List<Long> photoIdList = new ArrayList<>();
         for (int i = 0; i < details.size(); i++) {
             JSONObject detailJson = details.getJSONObject(i);
             detailJson.put("photo_like", detailJson.getInteger("like"));
@@ -80,16 +79,16 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
             detailJson.put("photo_comment", detailJson.getInteger("comment"));
             detailJson.put("photo_show", detailJson.getInteger("show"));
             KuaiShouReportDailyMaterial material = JSONObject.toJavaObject(detailJson, KuaiShouReportDailyMaterial.class);
-            VideoGetvo videoGetvo = dailyMaterialMapper.getVideoGetByPhotoId(material.getPhotoId());
+           /* VideoGetvo videoGetvo = dailyMaterialMapper.getVideoGetByPhotoId(material.getPhotoId());
             if (!Check.isNull(videoGetvo)) {
                 material.setChannelType(videoGetvo.getChannelType());
                 material.setSignature(videoGetvo.getSignature());
-            }
+            }*/
             material.setAccountId(accountId);
-        //    photoIdList.add(material.getPhotoId());
+            photoIdList.add(material.getPhotoId());
             addList.add(material);
         }
-     //   addList = this.getVideoInfoByList(addList, photoIdList);
+        addList = this.getVideoInfoByList(addList, photoIdList);
         dailyMaterialMapper.batchReplace(addList);
         getMaterialReportByAccountIdAndStatDate(accountId, token, startDate, endDate, page + 1);
     }

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

@@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -177,4 +178,9 @@ public class KuaiShouVideoGetServiceImpl extends ServiceImpl<KuaiShouVideoGetMap
         return videoGet;
     }
 
+    @Override
+    public void etlVideoBaseInfoByStaDate(String statDate) {
+        videoGetMapper.etlVideoBaseInfoByStaDate(statDate);
+    }
+
 }