Pārlūkot izejas kodu

添加报表逻辑代码

songyinghao 5 gadi atpakaļ
vecāks
revīzija
9024b540ce

+ 30 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedancePlanDailyReportLoadJob.java

@@ -74,6 +74,10 @@ public class BytedancePlanDailyReportLoadJob implements Job {
                             report.setMaterialType("文字动画");
                         }else if(tag.contains("采访形式")){
                             report.setMaterialType("采访形式");
+                        }else if(tag.contains("剧情")){
+                            report.setMaterialType("剧情");
+                        }else if(tag.contains("口播")){
+                            report.setMaterialType("口播");
                         }else{
                             report.setMaterialType("其他");
                         }
@@ -82,6 +86,32 @@ public class BytedancePlanDailyReportLoadJob implements Job {
                 }
             });
         }
+
+        //清洗关于缘多多数据
+        //1:查询缘多多相关的用户数据
+        QueryWrapper<UserAllocation> yddWrapper = new QueryWrapper<>();
+        wrapper.eq("project_id",113);
+        List<UserAllocation> yddallocations = userAllocationService.list(wrapper);
+        if(null!=yddallocations&&yddallocations.size()>0){
+            yddallocations.forEach(allocation->{
+                //根据accountId和时间,查询相关的日报表信息
+                QueryWrapper<BytedancePlanDailyReport> queryWrapper = new QueryWrapper<>();
+                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+                String dateString = dateFormat.format(getDate)+" 00:00:00";
+                queryWrapper.eq("advertiser_id",allocation.getAccountId())
+                        .eq("stat_datetime",dateString)
+                ;
+                List<BytedancePlanDailyReport>bytedancePlanDailyReports = planDailyReportService.list(queryWrapper);
+                if(null!=bytedancePlanDailyReports&&bytedancePlanDailyReports.size()>0){
+                    bytedancePlanDailyReports.forEach(report->{
+                        String adName = report.getAdName();
+                        String[] tags = adName.split("-");
+                        report.setChannelCode(tags[1]);
+                        planDailyReportService.updateById(report);
+                    });
+                }
+            });
+        }
     }
 
     @Autowired

+ 119 - 3
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -9,6 +9,8 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
+import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
+import cn.com.ctop.toutiao.service.IByteDanceCreativeService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
@@ -44,9 +46,96 @@ public class SampleTest {
     private IReportService reportService;
 
     @Test
-    public void getBytedancePlanReport(){
+    public void getYddData()throws Exception{
+        String dateString = "2020-01-06";
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date getDate = dateFormat.parse(dateString);
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+        tokens.forEach(token -> {
+            reportService.getAdvertiserPlanReport(token,getDate,getDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        });
 
-        Date getDate = DateUtils.addDay(new Date(), -1);
+        //清洗关于缘多多数据
+        //1:查询缘多多相关的用户数据
+        QueryWrapper<UserAllocation> yddWrapper = new QueryWrapper<>();
+        yddWrapper.eq("project_id",113);
+        List<UserAllocation> yddallocations = userAllocationService.list(yddWrapper);
+        if(null!=yddallocations&&yddallocations.size()>0){
+            yddallocations.forEach(allocation->{
+                //根据accountId和时间,查询相关的日报表信息
+                QueryWrapper<BytedancePlanDailyReport> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("advertiser_id",allocation.getAccountId())
+                        //.eq("stat_datetime",dateString)
+                ;
+                List<BytedancePlanDailyReport>bytedancePlanDailyReports = planDailyReportService.list(queryWrapper);
+                if(null!=bytedancePlanDailyReports&&bytedancePlanDailyReports.size()>0){
+                    bytedancePlanDailyReports.forEach(report->{
+                        String adName = report.getAdName();
+                        String[] tags = adName.split("-");
+                        report.setChannelCode(tags[0]);
+                        planDailyReportService.updateById(report);
+                    });
+                }
+            });
+        }
+
+        //清洗关于缘多多数据
+        //1:查询缘多多相关的用户数据
+        QueryWrapper<UserAllocation> dsjyWrapper = new QueryWrapper<>();
+        yddWrapper.eq("project_id",112);
+        List<UserAllocation> dsjyAllocations = userAllocationService.list(dsjyWrapper);
+        if(null!=dsjyAllocations&&dsjyAllocations.size()>0){
+            dsjyAllocations.forEach(allocation->{
+                //根据accountId和时间,查询相关的日报表信息
+                QueryWrapper<BytedancePlanDailyReport> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("advertiser_id",allocation.getAccountId())
+                //.eq("stat_datetime",dateString)
+                ;
+                List<BytedancePlanDailyReport>bytedancePlanDailyReports = planDailyReportService.list(queryWrapper);
+                if(null!=bytedancePlanDailyReports&&bytedancePlanDailyReports.size()>0){
+                    bytedancePlanDailyReports.forEach(report->{
+                        String adName = report.getAdName();
+                        String[] tags = adName.split("-");
+                        report.setChannelCode(tags[0]);
+                        planDailyReportService.updateById(report);
+                    });
+                }
+            });
+        }
+
+        //清洗关于缘多多数据
+        //1:查询缘多多相关的用户数据
+        QueryWrapper<UserAllocation> fjyhWrapper = new QueryWrapper<>();
+        yddWrapper.eq("project_id",222);
+        List<UserAllocation> fjyhAllocations = userAllocationService.list(fjyhWrapper);
+        if(null!=fjyhAllocations&&fjyhAllocations.size()>0){
+            fjyhAllocations.forEach(allocation->{
+                //根据accountId和时间,查询相关的日报表信息
+                QueryWrapper<BytedancePlanDailyReport> queryWrapper = new QueryWrapper<>();
+                queryWrapper.eq("advertiser_id",allocation.getAccountId())
+                //.eq("stat_datetime",dateString)
+                ;
+                List<BytedancePlanDailyReport>bytedancePlanDailyReports = planDailyReportService.list(queryWrapper);
+                if(null!=bytedancePlanDailyReports&&bytedancePlanDailyReports.size()>0){
+                    bytedancePlanDailyReports.forEach(report->{
+                        String adName = report.getAdName();
+                        String[] tags = adName.split("-");
+                        report.setChannelCode(tags[0]);
+                        planDailyReportService.updateById(report);
+                    });
+                }
+            });
+        }
+    }
+    @Test
+    public void getZybBytedancePlanReport(){
+
+//        Date getDate = DateUtils.addDay(new Date(), -1);
+        Date getDate = new Date();
         //1:查询作业帮相关的用户数据
         QueryWrapper<UserAllocation> wrapper = new QueryWrapper<>();
         wrapper.eq("project_id",215);
@@ -55,7 +144,7 @@ public class SampleTest {
             allocations.forEach(allocation->{
                 CtopOauthToken token = tokenService.getOauthTokenByAccountId(allocation.getAccountId()+"");
                 //3:获取广告计划信息数据
-                reportService.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+                reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY);
             });
         }
 
@@ -89,6 +178,10 @@ public class SampleTest {
                             report.setMaterialType("文字动画");
                         }else if(tag.contains("采访形式")){
                             report.setMaterialType("采访形式");
+                        }else if(tag.contains("剧情")){
+                            report.setMaterialType("剧情");
+                        }else if(tag.contains("口播")){
+                            report.setMaterialType("口播");
                         }else{
                             report.setMaterialType("其他");
                         }
@@ -99,6 +192,29 @@ public class SampleTest {
         }
     }
 
+    @Test
+    public void getByteDanceCreativeDate()throws Exception{
+        String dateString = "2020-01-06";
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date getDate = dateFormat.parse(dateString);
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+        tokens.forEach(token -> {
+            //3:获取广告计划信息数据
+//            creativeService.getAdvertiserCreative(token.getAccountId() + "", "", null);
+            //2:获取全量素材数据
+//            advertiserDataService.getMaterialList(token);
+            reportService.getAdvertiserPlanReport(token,getDate,getDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        });
+    }
+
+    @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
+    @Autowired
+    private IByteDanceCreativeService creativeService;
 
     @Test
     public void getBytedancePlanHourReport(){

+ 0 - 2
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -412,6 +412,4 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         info.setExcellent(excellent);
         this.updateById(info);
     }
-
-
 }

+ 4 - 0
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedancePlanDailyReport.java

@@ -410,6 +410,10 @@ public class BytedancePlanDailyReport {
      * 计划代码
      */
     private String planCode;
+    /**
+     * 渠道号
+     */
+    private String channelCode;
 
     public BytedancePlanDailyReport(JSONObject data, Long setAdvertiserId) {
         Long playFeedBreak75 = data.getLong("play_75_feed_break");

+ 4 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceCreative.java

@@ -20,7 +20,6 @@ import java.util.Date;
  */
 @Data
 @TableName("ctop_bytedance_creative")
-@EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 @ApiModel(value = "ctop_bytedance_creative对象", description = "今日头条创意信息")
 public class ByteDanceCreative {
@@ -132,6 +131,10 @@ public class ByteDanceCreative {
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
+    public ByteDanceCreative(){
+
+    }
+
     public ByteDanceCreative(JSONObject dataObject, String accountId) {
         this.id = dataObject.getLong("creative_id");
         this.planId = dataObject.getLong("ad_id");

+ 1 - 0
module-toutiao/src/main/resources/bytedance_config.properties

@@ -27,3 +27,4 @@ bytedance_v2_file_image_ad=/2/file/image/ad/
 bytedance_v2_creative_update_status=/2/creative/update/status/
 bytedance_v2_creative_material_get=/2/creative/material/read
 bytedance_v2_creative_create_v2=/2/creative/create_v2/
+bytedance_v2_creative_get=/2/creative/get/