Jelajahi Sumber

修改头条计划时报数据清洗渠道号逻辑

syh 5 tahun lalu
induk
melakukan
6d99d5a939

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

@@ -1,14 +1,11 @@
 package org.jeecg.modules.ctop.job;
 
-import cn.com.ctop.bytedance.entity.BytedancePlanHourlyReport;
 import cn.com.ctop.bytedance.service.IBytedancePlanHourlyReportService;
 import cn.com.ctop.bytedance.service.IReportService;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.UserAllocation;
 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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
@@ -73,39 +70,7 @@ public class BytedancePlanHourlyReportLoadJob implements Job {
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
-        //清洗关于缘多多数据
-        formatData(113,finalGetDate);
-        //清洗关于交友数据
-        formatData(112,finalGetDate);
-        //清洗关于附近约会数据
-        formatData(222,finalGetDate);
         log.info("头条计划时报数据获取完成");
         executorService.shutdown();
     }
-
-    private void formatData(Integer projectId, Date finalGetDate){
-        QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("project_id", projectId);
-        List<UserAllocation> fjyhAllocations = userAllocationService.list(queryWrapper);
-        if (null != fjyhAllocations && fjyhAllocations.size() > 0) {
-            fjyhAllocations.forEach(allocation -> {
-                //根据accountId和时间,查询相关的时报报表信息
-                QueryWrapper<BytedancePlanHourlyReport> accountWrapper = new QueryWrapper<>();
-                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-                String dateString = dateFormat.format(finalGetDate);
-                accountWrapper.eq("advertiser_id", allocation.getAccountId())
-                        .eq("stat_datetime",dateString)
-                ;
-                List<BytedancePlanHourlyReport> bytedancePlanHourlyReports = planHourlyReportService.list(accountWrapper);
-                if (null != bytedancePlanHourlyReports && bytedancePlanHourlyReports.size() > 0) {
-                    bytedancePlanHourlyReports.forEach(report -> {
-                        String adName = report.getAdName();
-                        String[] tags = adName.split("-");
-                        report.setChannelCode(tags[0]);
-                        planHourlyReportService.updateById(report);
-                    });
-                }
-            });
-        }
-    }
 }

+ 4 - 2
module-report/src/main/java/cn/com/ctop/bytedance/mapper/xml/BytedancePlanHourlyReportMapper.xml

@@ -64,7 +64,8 @@
         ad_name ,
         campaign_id,
         create_time,
-        update_time)
+        update_time,
+        channel_code)
         values
         <foreach collection="reports" item="report" separator=",">
             (
@@ -129,7 +130,8 @@
             #{report.adName},
             #{report.campaignId},
             #{report.createTime},
-            #{report.updateTime}
+            #{report.updateTime},
+            #{report.channelCode}
             )
         </foreach>
     </insert>

+ 3 - 0
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ReportServiceImpl.java

@@ -241,6 +241,9 @@ public class ReportServiceImpl implements IReportService {
             var data = dataArray.getJSONObject(i);
             if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
                 var hourlyReport = new BytedancePlanHourlyReport(data, token.getAccountId());
+                String adName = hourlyReport.getAdName();
+                String[] tags = adName.split("-");
+                hourlyReport.setChannelCode(tags[0]);
                 hourlyReports.add(hourlyReport);
             } else {
                 var dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());