Przeglądaj źródła

头条视频报表url清洗异常-bug修改

yangzian 4 lat temu
rodzic
commit
aac9e364c2

+ 12 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceEtlVideoJob.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.job.bytedance.handler;
 
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
+import cn.com.ctop.toutiao.modules.report.service.IEtlBytedanceReportVideoDailyService;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -13,6 +14,10 @@ public class BytedanceEtlVideoJob {
 
     @Autowired
     private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
+
+    @Autowired
+    private IEtlBytedanceReportVideoDailyService etlBytedanceReportVideoDailyService;
+
     @XxlJob("bytedanceEtlVideoJob")
     public void execute() throws Exception {
         Date startDate = DateUtils.addDay(new Date(),-2);
@@ -30,4 +35,11 @@ public class BytedanceEtlVideoJob {
             bytedanceVideoEtlInfoService.etlBytedanceVideoInfoByProjectId(getDate);
         }
     }
+
+
+    @XxlJob("updBytedanceVideoJob")
+    public void updBytedanceVideoJob() throws Exception {
+        etlBytedanceReportVideoDailyService.updBytedanceVideo();
+
+    }
 }

+ 10 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/EtlBytedanceReportVideoDailyMapper.java

@@ -3,6 +3,9 @@ package cn.com.ctop.toutiao.modules.report.mapper;
 import cn.com.ctop.toutiao.modules.report.entity.EtlBytedanceReportVideoDaily;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+import java.util.Map;
+
 /**
  * 头条视频分日报表信息
  * @author: jeecg-boot
@@ -11,4 +14,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface EtlBytedanceReportVideoDailyMapper extends BaseMapper<EtlBytedanceReportVideoDaily> {
 
+    List<Map<String,Object>> getBytedanceVideoInfo();
+
+    void updBytedanceVideoByMd5(String md5,String coverUrl,String url);
+
+
+
+
 }

+ 34 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/EtlBytedanceReportVideoDailyMapper.xml

@@ -2,4 +2,38 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.EtlBytedanceReportVideoDailyMapper">
 
+
+    <select id="getBytedanceVideoInfo" resultType="java.util.Map">
+        SELECT
+            IF
+                ( poster_url = '素材所属主体与开发者主体不一致无法获取URL', '', poster_url ) AS posterUrl,
+            poster_url,
+            video_url AS videoUrl,
+            a.md5,
+            count( 1 ) AS total
+        FROM
+            etl_report_bytedance_video a
+                LEFT JOIN ( SELECT DISTINCT signature, poster_url, video_url FROM ctop_bytedance_video_info ) b ON b.signature = a.md5
+                LEFT JOIN ( SELECT DISTINCT CODE, url FROM ctop_material_info ) c ON c.CODE = a.md5
+        WHERE
+            a.url = ''
+          AND a.toutiao_url = ''
+          AND a.md5 != ''
+        GROUP BY
+            a.md5
+        ORDER BY
+            total DESC;
+    </select>
+
+
+    <update id="updBytedanceVideoByMd5">
+        UPDATE etl_report_bytedance_video
+        SET cover_url = #{coverUrl},
+            url = #{url}
+        WHERE
+            md5 = #{md5};
+    </update>
+
+
+
 </mapper>

+ 5 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IEtlBytedanceReportVideoDailyService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.toutiao.modules.report.entity.EtlBytedanceReportVideoDaily;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
 
 /**
  * @Description: 头条视频分日报表信息
@@ -11,4 +12,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IEtlBytedanceReportVideoDailyService extends IService<EtlBytedanceReportVideoDaily> {
 
+
+    Result updBytedanceVideo() throws Exception;
+
+
 }

+ 46 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/EtlBytedanceReportVideoDailyServiceImpl.java

@@ -4,15 +4,60 @@ import cn.com.ctop.toutiao.modules.report.entity.EtlBytedanceReportVideoDaily;
 import cn.com.ctop.toutiao.modules.report.mapper.EtlBytedanceReportVideoDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.IEtlBytedanceReportVideoDailyService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.api.client.util.Data;
+import com.google.common.base.Function;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.BiFunction;
+
 /**
  * 头条视频分日报表信息
+ *
  * @author jeecg-boot
- * @date   2021-02-20
  * @version V1.0
+ * @date 2021-02-20
  */
 @Service
 public class EtlBytedanceReportVideoDailyServiceImpl extends ServiceImpl<EtlBytedanceReportVideoDailyMapper, EtlBytedanceReportVideoDaily> implements IEtlBytedanceReportVideoDailyService {
 
+
+    @Resource
+    private EtlBytedanceReportVideoDailyMapper etlBytedanceReportVideoDailyMapper;
+
+    @Override
+    public Result updBytedanceVideo() throws Exception{
+        CompletableFuture future = CompletableFuture.supplyAsync(()->{
+           return etlBytedanceReportVideoDailyMapper.getBytedanceVideoInfo();
+        }).handle(new BiFunction<List<Map<String, Object>>, Throwable, Object>() {
+            @Override
+            public Object apply(List<Map<String, Object>> list, Throwable throwable) {
+                if (throwable != null){
+                    return Result.error(throwable.getMessage());
+                }
+                list.forEach(map ->{
+                    String coverUrl = map.get("posterUrl")+"";
+                    String url = map.get("videoUrl")+"";
+                    String md5 = map.get("md5")+"";
+                    etlBytedanceReportVideoDailyMapper.updBytedanceVideoByMd5(md5,coverUrl,url);
+                });
+                return Result.ok("修改成功。");
+            }
+        });
+        return Result.ok(future.get());
+    }
+
+
+
+
+
+
 }