Przeglądaj źródła

Merge branch 'master' of http://39.106.184.70:3000/ctop/adsp-boot

yumeng 5 lat temu
rodzic
commit
5fb789ac60
18 zmienionych plików z 1006 dodań i 16 usunięć
  1. 31 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java
  2. 52 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyAccountReportAsyncJob.java
  3. 50 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyCampaignReportAsyncJob.java
  4. 50 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyCreativeReportAsyncJob.java
  5. 60 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyMaterialReportJob.java
  6. 56 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyMaterialReportRetryJob.java
  7. 50 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyPlanReportAsyncJob.java
  8. 40 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/BytedanceDailyReportAsyncTaskGetJob.java
  9. 59 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyAccountReportNextDayStayJob.java
  10. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAccount.java
  11. 19 15
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java
  12. 258 0
      performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/controller/HuananVideoReportController.java
  13. 26 0
      performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/dto/HuananVideoReportDTO.java
  14. 93 0
      performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/entity/HuananVideoReport.java
  15. 23 0
      performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/mapper/HuananVideoReportMapper.java
  16. 57 0
      performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/mapper/xml/HuananVideoReportMapper.xml
  17. 16 0
      performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/service/IHuananVideoReportService.java
  18. 65 0
      performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/service/impl/HuananVideoReportServiceImpl.java

+ 31 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/TestController.java

@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.job.KuaishouDailyAccountReportLoadJob;
 import org.jeecg.modules.ctop.service.ICleanMaterialService;
 import org.jeecg.modules.ctop.service.ICleanMaterialService;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -851,5 +852,35 @@ public class TestController {
 
 
     }
     }
 
 
+    @GetMapping(value = "/KuaishouDailyAccountReportLoadJob")
+    public void KuaishouDailyAccountReportLoadJob(){
+        Date getDate = DateUtils.addDay(new Date(), -2);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取快手数据异常:未获取到可用的token");
+            return;
+        }
+
+        executorService = Executors.newFixedThreadPool(3);
+        tokens.forEach(token -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    //1: 获取广告主信息数据
+                    kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
+                }
+            });
+        });
+    }
+
+
+
+
+
+
+
+
+
 
 
 }
 }

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

@@ -0,0 +1,52 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 头条素材报表按天跑前一天的数据任务
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyAccountReportAsyncJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String date = DateUtils.formatDate(getDate);
+
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
+            return ;
+        }
+
+        for (CtopOauthToken token : tokens) {
+            try {
+                bytedanceReportService.bytedanceAsyncTaskCreate(date, date, token, 2);  //1.创意 2.广告主 3.广告主 4.广告计划
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+
+    }
+}

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

@@ -0,0 +1,50 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 头条素材报表按天跑前一天的数据任务
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyCampaignReportAsyncJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String date = DateUtils.formatDate(getDate);
+
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
+            return ;
+        }
+
+        for (CtopOauthToken token : tokens) {
+            try {
+                bytedanceReportService.bytedanceAsyncTaskCreate(date, date, token, 3);  //1.创意 2.广告主 3.广告组 4.广告计划
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+
+    }
+}

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

@@ -0,0 +1,50 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 头条素材报表按天跑前一天的数据任务
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyCreativeReportAsyncJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String date = DateUtils.formatDate(getDate);
+
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
+            return ;
+        }
+
+        for (CtopOauthToken token : tokens) {
+            try {
+                bytedanceReportService.bytedanceAsyncTaskCreate(date, date, token, 1);  //1.创意 2.广告主 3.广告主 4.广告计划
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+
+    }
+}

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

@@ -0,0 +1,60 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 头条素材报表按天跑前一天的数据任务
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyMaterialReportJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String date = DateUtils.formatDate(getDate);
+
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("头条获取素材报表数据任务执行失败:未获取到可用的token");
+            return;
+        }
+
+        final ExecutorService executorService = Executors.newFixedThreadPool(3);
+        tokens.forEach(token -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        //获取头条素材报表数据
+                        bytedanceReportService.bytedanceMaterialReport(token, date, date);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    } finally {
+                    }
+                }
+            });
+        });
+
+    }
+}

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

@@ -0,0 +1,56 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.entity.BytedanceReportMaterialRetry;
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 头条素材报表错误重试定时任务
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyMaterialReportRetryJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+        List<BytedanceReportMaterialRetry> retryList = bytedanceReportService.getRetryList();
+        //
+        //多线程
+        final ExecutorService executorService = Executors.newFixedThreadPool(3);
+        retryList.forEach(retry -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(retry.getAccountId()));
+                        log.info("头条素材报表重试定时任务,当前accountId为:" + token.getAccountId());
+                        bytedanceReportService.bytedanceMaterialReportRetry(token,retry.getStartDate(),retry.getEndDate());
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    } finally {
+                    }
+                }
+            });
+        });
+        ////
+
+    }
+}

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

@@ -0,0 +1,50 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 头条素材报表按天跑前一天的数据任务
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyPlanReportAsyncJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String date = DateUtils.formatDate(getDate);
+
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("头条获取异步报表数据任务执行失败:未获取到可用的token");
+            return ;
+        }
+
+        for (CtopOauthToken token : tokens) {
+            try {
+                bytedanceReportService.bytedanceAsyncTaskCreate(date, date, token, 4);  //1.创意 2.广告主 3.广告组 4.广告计划
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+
+    }
+}

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

@@ -0,0 +1,40 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.bytedance.service.IBytedanceReportService;
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 头条素材报表按天跑前一天的数据任务
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class BytedanceDailyReportAsyncTaskGetJob implements Job {
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        try {
+            log.info("头条获取素材报表数据定时任务执行开始");
+            Long starttime = System.currentTimeMillis();
+            bytedanceReportService.bytedanceAsyncTaskGet();
+            Long endtime = System.currentTimeMillis();
+            log.info("头条异步报表数据定时任务执行结束,执行耗时:{}秒", (endtime - starttime) / 1000);
+        } catch (Exception e) {
+            log.error("头条获取异步报表数据定时任务执行报错");
+            e.printStackTrace();
+        }
+    }
+}

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

@@ -0,0 +1,59 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 快手广告主次留数据--凌晨跑两天前的次留,统一跑起来
+ *
+ * @author sunzhen
+ */
+@Slf4j
+public class KuaishouDailyAccountReportNextDayStayJob implements Job {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    static ExecutorService executorService = null;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+                Date getDate = DateUtils.addDay(new Date(), -2);
+                //1:查询当日数据
+                List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+                if (null == tokens || tokens.size() <= 0) {
+                    log.info("定时获取快手数据异常:未获取到可用的token");
+                    return;
+                }
+
+                executorService = Executors.newFixedThreadPool(3);
+                tokens.forEach(token -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            //1: 获取广告主信息数据
+                            kuaishouInterfaceService.getAdvertiserReportDaily(token, getDate, getDate);
+                        }
+                    });
+                });
+            }
+        };
+        thread.start();
+
+    }
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportDailyAccount.java

@@ -154,7 +154,7 @@ public class KuaishouReportDailyAccount implements Serializable {
     private BigDecimal eventNextDayStayCost;
     private BigDecimal eventNextDayStayCost;
 
 
     @JsonProperty("event_next_day_stay_ratio")
     @JsonProperty("event_next_day_stay_ratio")
-    private Long eventNextDayStayRatio;
+    private BigDecimal eventNextDayStayRatio;
 
 
     @JsonProperty("form_action_ratio")
     @JsonProperty("form_action_ratio")
     private Double formActionRatio;
     private Double formActionRatio;

+ 19 - 15
module-report/src/main/java/cn/com/ctop/bytedance/service/impl/BytedanceReportServiceImpl.java

@@ -724,7 +724,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             {
             {
                 put("start_date", startDate);
                 put("start_date", startDate);
                 put("end_date", endDate);
                 put("end_date", endDate);
-                if(type == 1){//素材
+                if(type == 1){//创意
                     put("group_by", new String[]{"STAT_GROUP_BY_CREATIVE_ID","STAT_GROUP_BY_TIME_DAY","STAT_GROUP_BY_CREATIVE_MATERIAL_MODE"});   //按照创意分组、天分组、创意类型分组查询
                     put("group_by", new String[]{"STAT_GROUP_BY_CREATIVE_ID","STAT_GROUP_BY_TIME_DAY","STAT_GROUP_BY_CREATIVE_MATERIAL_MODE"});   //按照创意分组、天分组、创意类型分组查询
                 }else if(type == 2){//广告主
                 }else if(type == 2){//广告主
                     put("group_by", new String[]{"STAT_GROUP_BY_ADVERTISER_ID","STAT_GROUP_BY_TIME_DAY","STAT_GROUP_BY_PRICING_CATEGORY"});   //按照广告主分组、天分组、广告类型类型分组查询
                     put("group_by", new String[]{"STAT_GROUP_BY_ADVERTISER_ID","STAT_GROUP_BY_TIME_DAY","STAT_GROUP_BY_PRICING_CATEGORY"});   //按照广告主分组、天分组、广告类型类型分组查询
@@ -952,20 +952,24 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
         requestMap.put("advertiser_id", task.getAccountId());
         requestMap.put("advertiser_id", task.getAccountId());
         requestMap.put("task_id", task.getTaskId());
         requestMap.put("task_id", task.getTaskId());
         String localPath = DownloadUtils.downloadByUrl(requestMap, downloadPath, url, token.getAccessToken(), fileName);
         String localPath = DownloadUtils.downloadByUrl(requestMap, downloadPath, url, token.getAccessToken(), fileName);
-        if(type == 1){
-            //素材异步报表
-            bytedanceDailyReportTaskMapper.loadBytedanceDailyCreativeFileAsync(localPath);
-        }else if(type == 2){
-            //账户异步报表
-            bytedanceDailyReportTaskMapper.loadBytedanceDailyAccountFileAsync(localPath);
-        }else if(type == 3){
-            //campaign异步报表
-            bytedanceDailyReportTaskMapper.loadBytedanceDailyCampaignFileAsync(localPath);
-        }else if(type == 4){
-            //plan异步报表
-            bytedanceDailyReportTaskMapper.loadBytedanceDailyPlanFileAsync(localPath);
-        }else{
-            log.error("异步报表类型传入错误,task_id:" + task.getTaskId() + ";类型:" + type);
+        if(task.getAccountId() !=1649961222605831L && task.getAccountId() != 1643726941045772L){
+
+
+            if(type == 1){
+                //素材异步报表
+                bytedanceDailyReportTaskMapper.loadBytedanceDailyCreativeFileAsync(localPath);
+            }else if(type == 2){
+                //账户异步报表
+                bytedanceDailyReportTaskMapper.loadBytedanceDailyAccountFileAsync(localPath);
+            }else if(type == 3){
+                //campaign异步报表
+                bytedanceDailyReportTaskMapper.loadBytedanceDailyCampaignFileAsync(localPath);
+            }else if(type == 4){
+                //plan异步报表
+                bytedanceDailyReportTaskMapper.loadBytedanceDailyPlanFileAsync(localPath);
+            }else{
+                log.error("异步报表类型传入错误,task_id:" + task.getTaskId() + ";类型:" + type);
+            }
         }
         }
     }
     }
 
 

+ 258 - 0
performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/controller/HuananVideoReportController.java

@@ -0,0 +1,258 @@
+package cn.com.ctop.huananvideoreport.controller;
+
+import java.text.ParseException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import cn.com.ctop.userefficientvideomap.entity.PerformanceTimeDTO;
+import cn.com.ctop.userefficientvideomap.entity.UserDto2;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.util.oConvertUtils;
+import cn.com.ctop.huananvideoreport.entity.HuananVideoReport;
+import cn.com.ctop.huananvideoreport.service.IHuananVideoReportService;
+import java.util.Date;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * 华南视频报表类
+ * @author jeecg-boot
+ * @date   2020-04-28
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="华南视频报表类")
+@RestController
+@RequestMapping("/huananvideoreport/huananVideoReport")
+public class HuananVideoReportController {
+	@Autowired
+	private IHuananVideoReportService huananVideoReportService;
+
+	/**
+	  * 分页列表查询
+	 * @param huananVideoReport
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "华南视频报表类-分页列表查询")
+	@ApiOperation(value="华南视频报表类-分页列表查询", notes="华南视频报表类-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<HuananVideoReport>> queryPageList(HuananVideoReport huananVideoReport,
+									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+									  HttpServletRequest req) {
+		Result<IPage<HuananVideoReport>> result = new Result<IPage<HuananVideoReport>>();
+		QueryWrapper<HuananVideoReport> queryWrapper = QueryGenerator.initQueryWrapper(huananVideoReport, req.getParameterMap());
+		Page<HuananVideoReport> page = new Page<HuananVideoReport>(pageNo, pageSize);
+		IPage<HuananVideoReport> pageList = huananVideoReportService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param huananVideoReport
+	 * @return
+	 */
+	@AutoLog(value = "华南视频报表类-添加")
+	@ApiOperation(value="华南视频报表类-添加", notes="华南视频报表类-添加")
+	@PostMapping(value = "/add")
+	public Result<HuananVideoReport> add(@RequestBody HuananVideoReport huananVideoReport) {
+		Result<HuananVideoReport> result = new Result<HuananVideoReport>();
+		try {
+			huananVideoReportService.save(huananVideoReport);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param huananVideoReport
+	 * @return
+	 */
+	@AutoLog(value = "华南视频报表类-编辑")
+	@ApiOperation(value="华南视频报表类-编辑", notes="华南视频报表类-编辑")
+	@PutMapping(value = "/edit")
+	public Result<HuananVideoReport> edit(@RequestBody HuananVideoReport huananVideoReport) {
+		Result<HuananVideoReport> result = new Result<HuananVideoReport>();
+		HuananVideoReport huananVideoReportEntity = huananVideoReportService.getById(huananVideoReport.getId());
+		if(huananVideoReportEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = huananVideoReportService.updateById(huananVideoReport);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "华南视频报表类-通过id删除")
+	@ApiOperation(value="华南视频报表类-通过id删除", notes="华南视频报表类-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			huananVideoReportService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "华南视频报表类-批量删除")
+	@ApiOperation(value="华南视频报表类-批量删除", notes="华南视频报表类-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<HuananVideoReport> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<HuananVideoReport> result = new Result<HuananVideoReport>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.huananVideoReportService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "华南视频报表类-通过id查询")
+	@ApiOperation(value="华南视频报表类-通过id查询", notes="华南视频报表类-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<HuananVideoReport> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<HuananVideoReport> result = new Result<HuananVideoReport>();
+		HuananVideoReport huananVideoReport = huananVideoReportService.getById(id);
+		if(huananVideoReport==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(huananVideoReport);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+      // Step.1 组装查询条件
+      QueryWrapper<HuananVideoReport> queryWrapper = null;
+      try {
+          String paramsStr = request.getParameter("paramsStr");
+          if (oConvertUtils.isNotEmpty(paramsStr)) {
+              String deString = URLDecoder.decode(paramsStr, "UTF-8");
+              HuananVideoReport huananVideoReport = JSON.parseObject(deString, HuananVideoReport.class);
+              queryWrapper = QueryGenerator.initQueryWrapper(huananVideoReport, request.getParameterMap());
+          }
+      } catch (UnsupportedEncodingException e) {
+          e.printStackTrace();
+      }
+
+      //Step.2 AutoPoi 导出Excel
+      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+      List<HuananVideoReport> pageList = huananVideoReportService.list(queryWrapper);
+      //导出文件名称
+      mv.addObject(NormalExcelConstants.FILE_NAME, "华南视频报表类列表");
+      mv.addObject(NormalExcelConstants.CLASS, HuananVideoReport.class);
+      mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("华南视频报表类列表数据", "导出人:Jeecg", "导出信息"));
+      mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+      return mv;
+  }
+
+  /**
+      * 通过excel导入数据
+   *
+   * @param request
+   * @param response
+   * @return
+   */
+  @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+  public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+      MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+          MultipartFile file = entity.getValue();
+          ImportParams params = new ImportParams();
+          params.setTitleRows(2);
+          params.setHeadRows(1);
+          params.setNeedSave(true);
+          try {
+              List<HuananVideoReport> listHuananVideoReports = ExcelImportUtil.importExcel(file.getInputStream(), HuananVideoReport.class, params);
+              huananVideoReportService.saveBatch(listHuananVideoReports);
+              return Result.ok("文件导入成功!数据行数:" + listHuananVideoReports.size());
+          } catch (Exception e) {
+              log.error(e.getMessage(),e);
+              return Result.error("文件导入失败:"+e.getMessage());
+          } finally {
+              try {
+                  file.getInputStream().close();
+              } catch (IOException e) {
+                  e.printStackTrace();
+              }
+          }
+      }
+      return Result.ok("文件导入失败!");
+  }
+
+
+	 @AutoLog(value = "头条优化季度绩效报表")
+	 @ApiOperation(value = "头条优化季度绩效报表", notes = "头条优化季度绩效报表")
+	 @PostMapping(value = "/getHuananMaterialInfo")
+	 public Result getHuananMaterialInfo(HttpServletRequest req) throws ParseException {
+		 Result<List<UserDto2>> result = new Result<List<UserDto2>>();
+		 huananVideoReportService.getHuananMaterialInfo("2020-04-01", "2020-04-29");
+		 result.setSuccess(true);
+		 return result;
+	 }
+
+}

+ 26 - 0
performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/dto/HuananVideoReportDTO.java

@@ -0,0 +1,26 @@
+package cn.com.ctop.huananvideoreport.dto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 华南视频报表类
+ * @author jeecg-boot
+ * @date   2020-04-28
+ * @version V1.0
+ */
+@Data
+public class HuananVideoReportDTO {
+
+	private String accountId;
+	private String authName;
+}

+ 93 - 0
performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/entity/HuananVideoReport.java

@@ -0,0 +1,93 @@
+package cn.com.ctop.huananvideoreport.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 华南视频报表类
+ * @author jeecg-boot
+ * @date   2020-04-28
+ * @version V1.0
+ */
+@Data
+@TableName("bytedance_huanan_video_report")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="bytedance_huanan_video_report对象", description="华南视频报表类")
+public class HuananVideoReport {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Integer id;
+	/**accountId*/
+	@Excel(name = "accountId", width = 15)
+    @ApiModelProperty(value = "accountId")
+	private String accountId;
+	/**authName*/
+	@Excel(name = "authName", width = 15)
+    @ApiModelProperty(value = "authName")
+	private String authName;
+	/**projectId*/
+	@Excel(name = "projectId", width = 15)
+    @ApiModelProperty(value = "projectId")
+	private Integer projectId;
+	/**projectName*/
+	@Excel(name = "projectName", width = 15)
+    @ApiModelProperty(value = "projectName")
+	private String projectName;
+	/**advertiserId*/
+	@Excel(name = "advertiserId", width = 15)
+    @ApiModelProperty(value = "advertiserId")
+	private String advertiserId;
+	/**advertiserName*/
+	@Excel(name = "advertiserName", width = 15)
+    @ApiModelProperty(value = "advertiserName")
+	private String advertiserName;
+	/**cost*/
+	@Excel(name = "cost", width = 15)
+    @ApiModelProperty(value = "cost")
+	private java.math.BigDecimal cost;
+	/**signature*/
+	@Excel(name = "signature", width = 15)
+    @ApiModelProperty(value = "signature")
+	private String signature;
+	/**videoUrl*/
+	@Excel(name = "videoUrl", width = 15)
+    @ApiModelProperty(value = "videoUrl")
+	private String videoUrl;
+	/**环比*/
+	@Excel(name = "环比", width = 15)
+    @ApiModelProperty(value = "环比")
+	private java.math.BigDecimal huanbi;
+	/**素材名称*/
+	@Excel(name = "素材名称", width = 15)
+    @ApiModelProperty(value = "素材名称")
+	private String materialName;
+	/**1头条2快手*/
+	@Excel(name = "1头条2快手", width = 15)
+    @ApiModelProperty(value = "1头条2快手")
+	private Integer appType;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+
+	private Long materialId;
+
+	private String statDatetime;
+}

+ 23 - 0
performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/mapper/HuananVideoReportMapper.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.huananvideoreport.mapper;
+
+import java.util.List;
+
+import cn.com.ctop.huananvideoreport.dto.HuananVideoReportDTO;
+import org.apache.ibatis.annotations.Param;
+import cn.com.ctop.huananvideoreport.entity.HuananVideoReport;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 华南视频报表类
+ * @author: jeecg-boot
+ * @date:   2020-04-28
+ * @cersion: V1.0
+ */
+public interface HuananVideoReportMapper extends BaseMapper<HuananVideoReport> {
+
+    List<HuananVideoReport> getHuananMaterialInfo(@Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    HuananVideoReport selectByDateAndId(@Param("materialId")Long materialId, @Param("statDate")String statDate);
+
+    HuananVideoReportDTO getAccountConcatInfo(@Param("materialId")Long materialId);
+}

+ 57 - 0
performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/mapper/xml/HuananVideoReportMapper.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.huananvideoreport.mapper.HuananVideoReportMapper">
+
+
+    <select id="getHuananMaterialInfo" resultType="cn.com.ctop.huananvideoreport.entity.HuananVideoReport">
+        select
+        a.material_id as materialId,
+--         a.account_id as accountId,
+--         b.auth_name as authName,
+        b.project_id as projectId,
+        b.project_name as projectName,
+        b.advertiser_id as advertiserId,
+        b.advertiser_name as advertiserName,
+        a.stat_datetime as statDatetime,
+        sum(a.cost) as cost,
+        d.signature as signature,
+        d.video_url as video_url,
+        e.url as url,
+        e.material_name as materialName,
+        1 as appType
+        from ctop_bytedance_report_material_daily a
+        left join ctop_user_allocation b on a.account_id = b.account_id
+        left join user_company c on b.user_id = c.user_id
+        left join ctop_bytedance_video_info d on a.material_id = d.material_id
+        left join (select code,url,material_name from ctop_material_info group by code) e on d.signature = e.code
+        where c.company_id = '6608ed13c0dd42de93c790dbdf124234'
+        and a.image_mode in ('CREATIVE_IMAGE_MODE_VIDEO',
+        'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL')
+        and date_format(stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
+        and date_format(stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
+        group by `statDatetime`,`materialId`
+        order by `statDatetime`,`projectId`,`materialId`
+    </select>
+
+    <select id="selectByDateAndId" resultType="cn.com.ctop.huananvideoreport.entity.HuananVideoReport">
+        select
+        *
+        from
+        bytedance_huanan_video_report
+        where material_id = #{materialId}
+        and stat_datetime = #{statDate}
+
+    </select>
+
+    <select id="getAccountConcatInfo" resultType="cn.com.ctop.huananvideoreport.dto.HuananVideoReportDTO">
+        select
+        group_concat(distinct(b.account_id)) as accountId,
+        group_concat(distinct(b.auth_name)) as authName
+        from
+        ctop_bytedance_report_material_daily a
+        left join ctop_user_allocation b on a.account_id = b.account_id
+        where a.material_id = #{materialId}
+    </select>
+
+
+</mapper>

+ 16 - 0
performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/service/IHuananVideoReportService.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.huananvideoreport.service;
+
+import cn.com.ctop.huananvideoreport.entity.HuananVideoReport;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.text.ParseException;
+
+/**
+ * 华南视频报表类
+ * @author jeecg-boot
+ * @date   2020-04-28
+ * @version V1.0
+ */
+public interface IHuananVideoReportService extends IService<HuananVideoReport> {
+    void getHuananMaterialInfo(String startDate, String endDate) throws ParseException;
+}

+ 65 - 0
performance-appraisal/src/main/java/cn/com/ctop/huananvideoreport/service/impl/HuananVideoReportServiceImpl.java

@@ -0,0 +1,65 @@
+package cn.com.ctop.huananvideoreport.service.impl;
+
+import cn.com.ctop.common.module.entity.MaterialInfo;
+import cn.com.ctop.huananvideoreport.dto.HuananVideoReportDTO;
+import cn.com.ctop.huananvideoreport.entity.HuananVideoReport;
+import cn.com.ctop.huananvideoreport.mapper.HuananVideoReportMapper;
+import cn.com.ctop.huananvideoreport.service.IHuananVideoReportService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import org.assertj.core.util.DateUtil;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import java.math.BigDecimal;
+import java.text.ParseException;
+import java.util.List;
+
+/**
+ * 华南视频报表类
+ * @author jeecg-boot
+ * @date   2020-04-28
+ * @version V1.0
+ */
+@Service
+public class HuananVideoReportServiceImpl extends ServiceImpl<HuananVideoReportMapper, HuananVideoReport> implements IHuananVideoReportService {
+
+    @Autowired
+    private HuananVideoReportMapper huananVideoReportMapper;
+
+    public void getHuananMaterialInfo(String startDate, String endDate) throws ParseException {
+
+        List<HuananVideoReport> mList = huananVideoReportMapper.getHuananMaterialInfo(startDate, endDate);
+
+        for (HuananVideoReport m:mList){
+            huananVideoReportMapper.insert(m);
+        }
+
+
+        QueryWrapper<HuananVideoReport> queryWrapper = new QueryWrapper<>();
+        List<HuananVideoReport> mList2 = huananVideoReportMapper.selectList(queryWrapper);
+
+        for(HuananVideoReport m:mList2){
+            String statDate  = DateUtils.addDay(m.getStatDatetime(),-1);
+            HuananVideoReport mb = huananVideoReportMapper.selectByDateAndId(m.getMaterialId(),statDate);
+
+            BigDecimal huanbi =BigDecimal.ZERO;
+            if(mb != null && mb.getCost().compareTo(BigDecimal.ZERO)>0){
+                huanbi = m.getCost().subtract(mb.getCost()).divide(mb.getCost(),7, BigDecimal.ROUND_HALF_UP);
+            }
+            HuananVideoReportDTO accountConcatInfo = huananVideoReportMapper.getAccountConcatInfo(m.getMaterialId());
+
+            m.setAccountId(accountConcatInfo.getAccountId());
+            m.setAuthName(accountConcatInfo.getAuthName());
+            m.setHuanbi(huanbi);
+            huananVideoReportMapper.updateById(m);
+        }
+
+
+
+    }
+
+
+}