瀏覽代碼

修改头条视频数据实体类

syh 4 年之前
父節點
當前提交
f95080a5da

+ 2 - 2
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -126,8 +126,8 @@ mybatis-plus:
       id-type: 4
       # 默认数据库表下划线命名
       table-underline: true
-  configuration:
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+#  configuration:
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 #jeecg专用配置
 jeecg:
   elasticsearch:

+ 2 - 0
jeecg-boot-module-system/src/main/resources/application.yml

@@ -1,6 +1,8 @@
 spring:
   profiles:
+#    active: wps
     active: @activatedProperties@
+
 swagger:
   production: false
   basic:

+ 79 - 34
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,7 +5,6 @@ import cn.com.ctop.check.entity.CtopCheckTaskList;
 import cn.com.ctop.check.service.ICtopCheckTaskListService;
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.UReportSubscriber;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
 import cn.com.ctop.common.module.service.*;
@@ -18,8 +17,11 @@ import cn.com.ctop.oa.modules.service.IWechatDepartmentService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
 import cn.com.ctop.oa.modules.service.IWechatUserListService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
+import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxl.job.core.log.XxlJobLogger;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
@@ -29,7 +31,6 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import java.io.File;
 import java.text.ParseException;
 import java.util.Date;
 import java.util.HashMap;
@@ -187,18 +188,18 @@ public class SampleTest {
     @Test
     public void loadKuaishouAgentData() {
         kuaishouReportDailyAgentService.loginAgent();
-        for (int i = 0; i < 20; i++) {
-            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
-            kuaishouReportDailyAgentService.getReport(currentDate, DateUtils.getNowDate("yyyy-MM-dd"));
-        }
-//
-//        try {
-//            for (int i = 1; i < 30; i++) {
-//                kuaishouReportDailyAgentService.getAccount(i);
-//            }
-//        } catch (Exception e) {
-//            e.printStackTrace();
+//        for (int i = 0; i < 20; i++) {
+//            String currentDate = DateUtils.formatDate(DateUtils.addDay(new Date(), -i));
+//            kuaishouReportDailyAgentService.getReport(currentDate, DateUtils.getNowDate("yyyy-MM-dd"));
 //        }
+//
+        try {
+            for (int i = 1; i < 30; i++) {
+                kuaishouReportDailyAgentService.getAccount(i);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     @Autowired
@@ -218,8 +219,14 @@ public class SampleTest {
 
     @Test
     public void loadAccountData() {
-        CtopOauthToken token = oauthTokenService.getTokenByAccountId(1665922219192387L);
-        reportService.getAdvertiserReport(token, DateUtils.parseDate("2020-09-01", "yy-MM-dd"), DateUtils.parseDate("2020-09-01", "yy-MM-dd"), CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
+//        List<UserAllocation> allocations = allocationService.getByParams(776L,null,0);
+//        for (UserAllocation allocation:allocations) {
+            CtopOauthToken token = tokenService.getTokenByAccountId(93238965516L);
+            for(int i=92;i<100;i++){
+                Date getDate = DateUtils.addDay(new Date(),-i);
+                reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            }
+//        }
     }
 
     @Autowired
@@ -230,27 +237,65 @@ public class SampleTest {
     IUReportService uReportService;
 
     @Test
-    public void sendUReport() {
-        uReportService.uReportList().forEach(uReport -> {
-            List<UReportSubscriber> uReportSubscriber = uReportService.getUReportSubscriberByFileId(uReport.getString("id"));
-            if (!uReportSubscriber.isEmpty()) {
-                String title = uReport.getString("name").replace(".ureport.xml", "");
-                String content = "您订阅的日报在附件中请注意查收》》》";
-                //下载文件到本地
-                uReportExportService.exportExcel(uReport.getString("name"));
-                uReportSubscriber.forEach(sender -> {
-                    emailSendMsgHandle.SendAttachment("bijiequan@c-top.com.cn", title, content,
-                            new File(System.getProperty("user.dir") + File.separator + "uReport" + File.separator + uReport.getString("name").replace("ureport.xml", "") + "xlsx"));
-                });
+    public void loadBytedanceData(){
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        for (CtopOauthToken token:tokens) {
+            for(int i=0;i<20;i++){
+                Date getDate = DateUtils.addDay(new Date(), -i);
+                String date = DateUtils.formatDate(getDate);
+                bytedanceReportService.bytedanceMaterialReport(token, date, date);
+//            videoReportDailyService.videoInfoList(date, date);
             }
-        });
-        //发完全部订阅,删除文件
-        File file = new File(System.getProperty("user.dir") + File.separator + "uReport");
-        File[] files = file.listFiles();
-        if (files != null && files.length > 0) {
-            for (File f : files) {
-                f.delete();
+
+        }
+    }
+
+    @Test
+    public void loaddata(){
+//        List<UserAllocation> allocations = allocationService.getByParams(643L,null,0);
+//        for (UserAllocation allocation:allocations) {
+            for(int i=0;i<50;i++){
+//                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
+                Date getDate = DateUtils.addDay(new Date(), -i);
+                String date = DateUtils.formatDate(getDate);
+//                bytedanceReportService.bytedanceMaterialReport(token, date, date);
+                videoReportDailyService.videoInfoList(date, date);
             }
+
+//        }
+    }
+
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Autowired
+    private IByteDanceVideoReportDailyService videoReportDailyService;
+    @Test
+    public void loadMatData(){
+        List<UserAllocation> allocations = allocationService.getByParams(320L,null,0);
+        countDownLatch = new CountDownLatch(allocations.size());
+        executorService = Executors.newFixedThreadPool(2);
+        allocations.forEach(allocation -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
+                        //获取全量视频素材数据
+                        advertiserDataService.getMaterialList(token);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    } finally {
+                        countDownLatch.countDown();
+                    }
+                }
+            });
+        });
+        try {
+            countDownLatch.await();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
         }
+        XxlJobLogger.log("物料数据同步完成");
     }
 }

+ 18 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceVideoDailyReportLoadJob.java

@@ -1,8 +1,26 @@
 package cn.com.ctop.job.bytedance.handler;
 
+import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+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 java.util.Date;
+
 @Component
 public class BytedanceVideoDailyReportLoadJob {
+    @XxlJob("bytedanceVideoDailyReportLoadJob")
+    public ReturnT<String> execute(String params) throws Exception {
+        for(int i=0;i<3;i++){
+            Date getDate = DateUtils.addDay(new Date(), -i);
+            String date = DateUtils.formatDate(getDate);
+            videoReportDailyService.videoInfoList(date, date);
+        }
+        return ReturnT.SUCCESS;
+    }
 
+    @Autowired
+    private IByteDanceVideoReportDailyService videoReportDailyService;
 }

+ 4 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceVideoInfo.java

@@ -29,9 +29,10 @@ public class ByteDanceVideoInfo {
     /**
      * id
      */
-    @TableId()
+    @TableId
     @ApiModelProperty(value = "id")
     private String id;
+    private String vid;
     /**
      * 对应本文件id
      */
@@ -87,7 +88,8 @@ public class ByteDanceVideoInfo {
     private Integer type;
 
     public ByteDanceVideoInfo(JSONObject data, CtopOauthToken token) {
-        this.id = data.getString("id");
+        this.id = data.getString("id")+token.getAccountId();
+        this.vid = data.getString("id");
         this.fileId = data.getString("video_id");
         this.accountId = token.getAccountId();
         this.advertiserId = token.getAdvertiserId();

+ 2 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/ByteDanceVideoInfoMapper.xml

@@ -4,6 +4,7 @@
     <insert id="replaceBatch">
         replace into ctop_bytedance_video_info(
         id,
+        vid,
         advertiser_id,
         account_id,
         material_id,
@@ -28,6 +29,7 @@
         <foreach collection="videoList" item="video" separator=",">
             (
             #{video.id},
+            #{video.vid},
             #{video.advertiserId},
             #{video.accountId},
             #{video.materialId},

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -608,7 +608,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     @Override
     public void getMaterialList(CtopOauthToken token) {
         getVideoByPage(token, "", 1);
-        getImageByPage(token, "", 1);
+//        getImageByPage(token, "", 1);
         videoInfoService.updateMaterialType();
         imageInfoService.updateType();
     }

文件差異過大導致無法顯示
+ 3 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportServiceImpl.java