Forráskód Böngészése

Merge branch 'test'

syh 5 éve
szülő
commit
55efa604ff
27 módosított fájl, 660 hozzáadás és 307 törlés
  1. 20 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  2. 4 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/AdvertiserMapper.java
  3. 28 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/AdvertiserMapper.xml
  4. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IAdvertiserService.java
  5. 4 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IFfmpegService.java
  6. 71 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/AdvertiserServiceImpl.java
  7. 140 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/FfmpegServiceImpl.java
  8. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/PerformanceSaleServiceImpl.java
  9. 4 6
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/SheetInfoVo.java
  10. 0 141
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/opencv/FFmpegUtils.java
  11. 67 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/YdMaterialWeekEntity.java
  12. 95 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/YdPlanAggregateEntity.java
  13. 64 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/YdWeekAggregateEntity.java
  14. 4 0
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  15. 2 0
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  16. 2 1
      jeecg-boot-module-system/src/main/resources/application.yml
  17. 36 0
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  18. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  19. 4 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  20. 4 2
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  21. 19 3
      module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java
  22. 0 31
      module-report/src/main/java/cn/com/ctop/bytedance/controller/ReportController.java
  23. 1 1
      module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCampaignDailyReport.java
  24. 2 6
      module-report/src/main/java/cn/com/ctop/bytedance/service/IReportService.java
  25. 43 105
      module-report/src/main/java/cn/com/ctop/bytedance/service/impl/ReportServiceImpl.java
  26. 40 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertisePlan.java
  27. 1 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

+ 20 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java

@@ -401,7 +401,26 @@ public class AdvertiserController {
     }
 
     /**
-     * 导出报表
+     * 导出伊对报表
+     *
+     * @return
+     */
+    @RequestMapping(value = "/ydWeekReportList")
+    @ResponseBody
+    public Map<String, Object> ydReportList(HttpServletRequest request, HttpServletResponse response, @RequestBody JSONObject data) throws Exception {
+        Map<String, Object> result = new HashMap<>();
+        //查询总的消耗信息
+        Long projectId = data.getLong("projectId");
+        String startDate = data.getString("startDate");
+        String endDate = data.getString("endDate");
+        List<SheetInfoVo> vos = advertiserService.getYdStatisticInfo(projectId, startDate, endDate);
+        result.put("data", vos);
+        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
+        return result;
+    }
+
+    /**
+     * 导出消消乐报表
      *
      * @return
      */

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/AdvertiserMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.ctop.entity.Advertiser;
 import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
+import org.jeecg.modules.excelutil.entity.YdWeekAggregateEntity;
 
 import java.util.List;
 
@@ -17,4 +18,7 @@ public interface AdvertiserMapper extends BaseMapper<Advertiser> {
 
     List<KuaishouXxlEntity> getXXlStatisticInfo(@Param(value = "projectId") Long projectId, @Param(value = "systemType") String systemType, @Param(value = "accountId") Long accountId, @Param(value = "groupBy") String groupBy);
 
+    YdWeekAggregateEntity getYdWeekStatisticInfo(@Param(value = "projectId") Long projecgId, @Param(value = "start") String lastWeekStart, @Param(value = "end") String lastWeekEnd);
+
+    List<YdWeekAggregateEntity> getYdWeekPlanStatisticInfoBtTen(@Param(value = "projectId") Long projectId, @Param(value = "start") String startDate, @Param(value = "end") String endDate, @Param(value = "accountId") Long accountId);
 }

+ 28 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/AdvertiserMapper.xml

@@ -66,4 +66,32 @@
         </if>
 
     </select>
+    <select id="getYdWeekStatisticInfo" resultType="org.jeecg.modules.excelutil.entity.YdWeekAggregateEntity">
+        select
+            concat(#{start},'至',#{end}) as date,
+            round(sum(cost),2) as cost,
+            sum(active) as active,
+            (
+                case
+                    when sum(cost)!=0 and sum(active)!=0
+                    then round(sum(cost)/sum(active),2)
+                    else 0
+                end)    as activeAvg
+        from
+            ctop_bytedance_report_advertiser_daily daily
+        left join ctop_user_allocation allocation on allocation.account_id = daily.advertiser_id
+        where
+            allocation.project_id = #{projectId}
+        and
+            allocation.account_status = 0
+        and
+            daily.stat_datetime &gt;= #{start}
+        and
+            daily.stat_datetime &lt;= #{end}
+
+    </select>
+    <select id="getYdWeekPlanStatisticInfoBtTen"
+            resultType="org.jeecg.modules.excelutil.entity.YdWeekAggregateEntity">
+
+    </select>
 </mapper>

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IAdvertiserService.java

@@ -19,4 +19,6 @@ public interface IAdvertiserService extends IService<Advertiser> {
     SheetInfoVo getXxlStatisticInfo(Long projectId, String systemType, Long accountId, String sheetName);
 
     List<SheetInfoVo> getSystemTypeXxlStatisticInfo(Long projectId);
+
+    List<SheetInfoVo> getYdStatisticInfo(Long projectId, String startDate, String endDate);
 }

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IFfmpegService.java

@@ -0,0 +1,4 @@
+package org.jeecg.modules.ctop.service;
+
+public interface IFfmpegService {
+}

+ 71 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/AdvertiserServiceImpl.java

@@ -1,16 +1,25 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.service.IUserAllocationService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.entity.Advertiser;
 import org.jeecg.modules.ctop.mapper.AdvertiserMapper;
 import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.vo.SheetInfoVo;
 import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
+import org.jeecg.modules.excelutil.entity.YdPlanAggregateEntity;
+import org.jeecg.modules.excelutil.entity.YdWeekAggregateEntity;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.ParseException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -33,7 +42,7 @@ public class AdvertiserServiceImpl extends ServiceImpl<AdvertiserMapper, Adverti
 
     @Override
     public SheetInfoVo getXxlStatisticInfo(Long projectId, String systemType, Long accountId, String sheetName) {
-        SheetInfoVo vo = new SheetInfoVo();
+        SheetInfoVo vo = new SheetInfoVo<KuaishouXxlEntity>();
         List<KuaishouXxlEntity> details = new ArrayList<>();
         vo.setSheetName(sheetName);
         List<KuaishouXxlEntity> totalList = advertiserMapper.getXXlStatisticInfo(projectId, systemType, accountId, null);
@@ -54,4 +63,65 @@ public class AdvertiserServiceImpl extends ServiceImpl<AdvertiserMapper, Adverti
         vos.add(ios);
         return vos;
     }
+
+    @Override
+    public List<SheetInfoVo> getYdStatisticInfo(Long projectId, String startDate, String endDate) {
+        List<SheetInfoVo> sheetInfoVos = new ArrayList<>();
+        try {
+            Date start = DateUtils.parseDate(startDate, "yyyy-MM-dd");
+            Date end = DateUtils.parseDate(endDate, "yyyy-MM-dd");
+            String lastWeekStart = DateUtils.formatDate(DateUtils.addDay(start, -7));
+            String lastWeekEnd = DateUtils.formatDate(DateUtils.addDay(end, -7));
+            //1:获取周报汇总数据
+            SheetInfoVo voFirst = new SheetInfoVo();
+            List<YdWeekAggregateEntity> weekEntities = new ArrayList<>();
+            YdWeekAggregateEntity lastWeek = advertiserMapper.getYdWeekStatisticInfo(projectId, lastWeekStart + " 00:00:00", lastWeekEnd + " 00:00:00");
+            weekEntities.add(lastWeek);
+            YdWeekAggregateEntity thWeek = advertiserMapper.getYdWeekStatisticInfo(projectId, startDate + " 00:00:00", endDate + " 00:00:00");
+            weekEntities.add(thWeek);
+            YdWeekAggregateEntity qoq = new YdWeekAggregateEntity();
+            qoq.setDate("环比数据");
+            BigDecimal qoqActive = (new BigDecimal(thWeek.getActive()).subtract(new BigDecimal(lastWeek.getActive()))).divide(
+                    new BigDecimal(lastWeek.getActive()), 5, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
+            qoq.setActive(qoqActive.toString() + "%");
+            BigDecimal qoqCost = (new BigDecimal(thWeek.getCost()).subtract(new BigDecimal(lastWeek.getCost()))).divide(
+                    new BigDecimal(lastWeek.getCost()), 5, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
+            qoq.setCost(qoqCost.toString() + "%");
+            BigDecimal qoqActiveAvg = (new BigDecimal(thWeek.getActiveAvg()).subtract(new BigDecimal(lastWeek.getActiveAvg()))).divide(
+                    new BigDecimal(lastWeek.getActiveAvg()), 5, RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP);
+            qoq.setActiveAvg(qoqActiveAvg.toString() + "%");
+            weekEntities.add(qoq);
+            voFirst.setSheetName("周数据");
+            voFirst.setDetails(weekEntities);
+            sheetInfoVos.add(voFirst);
+            //2:获取主力计划汇总
+            SheetInfoVo secondVo = new SheetInfoVo();
+            secondVo.setSheetName("主力计划汇总");
+            List<YdPlanAggregateEntity> planAggregateEntities = getYdPlanStatisticInfo(projectId, startDate, endDate);
+            //3:获取每周素材统计
+            return null;
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private List<YdPlanAggregateEntity> getYdPlanStatisticInfo(Long projectId, String startDate, String endDate) {
+        List<YdPlanAggregateEntity> result = new ArrayList<>();
+        List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, null);
+        if (null != allocations && allocations.size() > 0) {
+            allocations.forEach(allocation -> {
+                List<YdWeekAggregateEntity> plans = statisticWeekInfoByAccount(allocation, startDate, endDate, projectId);
+            });
+        }
+        return result;
+    }
+
+    private List<YdWeekAggregateEntity> statisticWeekInfoByAccount(UserAllocation allocation, String startDate, String endDate, Long projectId) {
+        List<YdWeekAggregateEntity> entitiesBtTens = advertiserMapper.getYdWeekPlanStatisticInfoBtTen(projectId, startDate, endDate, allocation.getAccountId());
+        return null;
+    }
+
+    @Autowired
+    private IUserAllocationService userAllocationService;
 }

+ 140 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/FfmpegServiceImpl.java

@@ -0,0 +1,140 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.ctop.service.IFfmpegService;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+@Slf4j
+public class FfmpegServiceImpl implements IFfmpegService {
+    /**
+     * FFmpeg全路径
+     */
+    @Value("${jeecg.ffmpeg.bin}")
+    private String FFMPEG_PATH;
+
+    /**
+     * 从视频中抽取音频文件
+     */
+    public void getM4aFromMp4(String videoPath, String m4apath) {
+        /**
+         * D:\java\ffmpeg\bin\ffmpeg.exe -i D:\data\test\\video.mp4 -vn -y -acodec copy D:\data\test\\video.m4a
+         */
+        List<String> command = new ArrayList<>();
+        command.add(FFMPEG_PATH);
+        command.add("-i");
+        command.add(videoPath);
+        command.add("-vn");
+        command.add("-y");
+        command.add("-acodec");
+        command.add("copy");
+        command.add(m4apath);
+        runCommand(command);
+    }
+
+    /**
+     * 截取音频文件
+     */
+    public void cutM4a(String srcPath, String targetPath, String startSecond, String endSecond) {
+        /**
+         *D:\java\ffmpeg\bin\ffmpeg.exe -i D:\data\test\\video.m4a -vn -acodec copy -ss 00:00:00.000 -t 00:00:08.000 D:\data\test\\cut.m4a
+         */
+        List<String> command = new ArrayList<>();
+        command.add(FFMPEG_PATH);
+        command.add("-i");
+        command.add(srcPath);
+        command.add("-vn");
+        command.add("-acodec");
+        command.add("copy");
+        command.add("-ss");
+        command.add(startSecond);
+        command.add("-t");
+        command.add(endSecond);
+        command.add(targetPath);
+        runCommand(command);
+    }
+
+    /**
+     * 音频拼接
+     * D:\java\ffmpeg\bin\ffmpeg.exe -i D:\data\test\\cut.m4a -i D:\data\test\\fill.m4a -filter_complex "[0:0] [1:0] concat=n=2:v=0:a=1 [a]" -map [a] D:\data\test\\final.m4a
+     */
+    public void audioMosaic(String audioPart1, String audioPart2, String finalAudio) {
+        List<String> command = new ArrayList<>();
+        command.add(FFMPEG_PATH);
+        command.add("-i");
+        command.add(audioPart1);
+        command.add("-i");
+        command.add(audioPart2);
+        command.add("-filter_complex");
+        command.add("\"[0:0] [1:0] concat=n=2:v=0:a=1 [a]\"");
+        command.add("-map");
+        command.add("[a]");
+        command.add(finalAudio);
+        runCommand(command);
+    }
+
+    /**
+     * 音频+视频合成视频
+     *
+     * @param srcVideoPath
+     * @param srcAudioPath
+     * @param finalVideoPath D:\java\ffmpeg\bin\ffmpeg.exe -i D:\data\test\\merge.mp4 -i D:\data\test\\final.m4a -c:v copy -c:a aac -strict experimental D:\data\test\\final.mp4
+     */
+    public void mergeAudioAndVideo(String srcVideoPath, String srcAudioPath, String finalVideoPath) {
+        List<String> command = new ArrayList<>();
+        command.add(FFMPEG_PATH);
+        command.add("-i");
+        command.add(srcVideoPath);
+        command.add("-i");
+        command.add(srcAudioPath);
+        command.add("-c:v");
+        command.add("copy");
+        command.add("-c:a");
+        command.add("aac");
+        command.add("-strict");
+        command.add("experimental");
+        command.add(finalVideoPath);
+        runCommand(command);
+    }
+
+    /**
+     * D:\java\ffmpeg\bin\ffmpeg.exe -f image2 -i D:\\data\\video\\%d.jpg  -vcodec libx264 -r 25  D:\\data\\merge.mp4
+     *
+     * @param imagePath
+     * @param frameNumber
+     * @param videoFilePath
+     */
+    public void MergeImageToVideo(String imagePath, Integer frameNumber, String videoFilePath) {
+        List<String> command = new ArrayList<>();
+        command.add(FFMPEG_PATH);
+        command.add("-i");
+        command.add("image2");
+        command.add("-i");
+        command.add(imagePath + "%d.jpg");
+        command.add("-vcodec");
+        command.add("copy");
+        command.add("libx264");
+        command.add("-r");
+        command.add(frameNumber + "");
+        command.add(videoFilePath);
+        runCommand(command);
+    }
+
+    private void runCommand(List<String> command) {
+        try {
+            ProcessBuilder builder = new ProcessBuilder();
+            builder.command(command);
+            builder.redirectErrorStream(true);
+            Process process = builder.start();
+            // 等待进程执行结束
+            process.waitFor();
+            log.info("ffmpeg命令执行完成");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/PerformanceSaleServiceImpl.java

@@ -55,7 +55,7 @@ public class PerformanceSaleServiceImpl implements IPerformanceSaleService {
 
     public void countPerformance(SysUser user) {
 //        Date getDate = DateUtils.addDay(new Date(), -1)
-        Date getDate = DateUtils.addDay(new Date(), -5);
+        Date getDate = DateUtils.addDay(new Date(), -15);
         String startDateStr = DateUtils.getQuarterStartDate(getDate);
         String endDateStr = DateUtils.getQuarterEndDate(getDate);
         //获取用户角色信息
@@ -153,7 +153,7 @@ public class PerformanceSaleServiceImpl implements IPerformanceSaleService {
     }
 
     private BigDecimal getPercentagePercent(SalePerformanceDetail detail) {
-        BigDecimal percent = detail.getDoMediaTask().divide(detail.getMediaTask()).multiply(new BigDecimal("100"));
+        BigDecimal percent = detail.getDoMediaTask().divide(detail.getMediaTask(), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
         //AM非自拓客户
         if (detail.getRoleId().equals(CtopAdConstant.SYSTEM_SALE_AM_CODE) && detail.getExtensionSelf() != 1) {
             return new BigDecimal("0.0005");

+ 4 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/SheetInfoVo.java

@@ -1,21 +1,19 @@
 package org.jeecg.modules.ctop.vo;
 
-import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
-
 import java.util.List;
 
 /**
  * @author 宋英豪
  */
-public class SheetInfoVo {
+public class SheetInfoVo<T> {
     private String sheetName;
-    List<KuaishouXxlEntity> details;
+    List<T> details;
 
-    public List<KuaishouXxlEntity> getDetails() {
+    public List<T> getDetails() {
         return details;
     }
 
-    public void setDetails(List<KuaishouXxlEntity> details) {
+    public void setDetails(List<T> details) {
         this.details = details;
     }
 

+ 0 - 141
jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/opencv/FFmpegUtils.java

@@ -1,141 +0,0 @@
-//package org.jeecg.modules.demo.opencv;
-//
-//import java.io.BufferedReader;
-//import java.io.IOException;
-//import java.io.InputStream;
-//import java.io.InputStreamReader;
-//import java.text.SimpleDateFormat;
-//import java.util.ArrayList;
-//import java.util.Date;
-//import java.util.List;
-//import java.util.UUID;
-//
-//public class FFmpegUtils {
-//    public static void videoToPcm(String vedioUrl,String m4aUrl,String ffmpegUrl) throws InterruptedException, IOException {
-//        List<String> commend = new ArrayList<String>();
-//        commend.add(ffmpegUrl);
-//        commend.add("-i");
-//        commend.add(vedioUrl);
-//        commend.add("-vn");
-//        commend.add("y");
-//        commend.add("-acodec");
-//        commend.add("copy");
-//        commend.add(m4aUrl);
-//        ProcessBuilder builder = new ProcessBuilder();
-//        builder.command(commend);
-//        builder.redirectErrorStream(true);
-//        Process process = builder.start();
-//        process.waitFor();// 等待进程执行结束
-//    }
-//
-//    public static void mergeVideodioAndPcm(String videoInputPath, String audioInputPath, String videoOutPath,String ffmpegUrl) throws InterruptedException, IOException {
-//        /**
-//         *  String command = FFMPEG_PATH + " -i " + videoInputPath + " -i " + audioInputPath
-//         *   + " -c:v copy -c:a aac -strict experimental " +
-//         *   " -map 0:v:0 -map 1:a:0 "
-//         *   + " -y " + videoOutPath;
-//         */
-//        List<String> commend = new ArrayList<String>();
-//        commend.add(ffmpegUrl);
-//        commend.add("-i");
-//        commend.add(videoInputPath);
-//        commend.add("-i");
-//        commend.add(audioInputPath);
-//        commend.add(" -c:v");
-//        commend.add("copy");
-//        commend.add("-c:a");
-//        commend.add("acc");
-//        commend.add("-strict");
-//        commend.add("experimental");
-//        commend.add(videoOutPath);
-//        ProcessBuilder builder = new ProcessBuilder();
-//        builder.command(commend);
-//        builder.redirectErrorStream(true);
-//        Process process = builder.start();
-//        process.waitFor();// 等待进程执行结束
-//    }
-//
-//    public static void main(String[] args) throws InterruptedException, IOException {
-////        videoToPcm("D:\\data\\fill.mp4","D:\\data\\fill.m4a","D:\\java\\ffmpeg\\bin\\ffmpeg.exe");
-////        mergeVideodioAndPcm("D:\\data\\merge.mp4","D:\\data\\fill.m4a","D:\\data\\fill2.mp4","D:\\java\\ffmpeg\\bin\\ffmpeg.exe");
-//        try {
-//			videoToAudio("D:\\data\\test\\fill.mp4","D:\\data\\test\\123.mp3");
-//            String videoInputPath = "D:\\data\\test\\merge.mp4";
-//            String audioInputPath = "D:\\data\\test\\123.mp3";
-//            String videoOutPath = "D:\\data\\test\\fill.mp4";
-//            convetor(videoInputPath,audioInputPath,videoOutPath);
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        System.out.println("---------获取音频文件成功!-----------");
-//    }
-//
-//    /**
-//     * @param videoInputPath 原视频的全路径
-//     * @param audioInputPath 音频的全路径
-//     * @param videoOutPath   视频与音频结合之后的视频的路径
-//     * @throws Exception
-//     */
-//    public static void convetor(String videoInputPath, String audioInputPath, String videoOutPath)
-//            throws Exception {
-//        Process process = null;
-//        try {
-//            String command =FFMPEG_PATH + " -i " + videoInputPath + " -i " + audioInputPath + " -c:v copy -c:a aac -strict experimental " +
-//                    " -map 0:v:0 -map 1:a:0 "
-//                    + " -y " + videoOutPath;
-//            System.out.println(command);
-//            process = Runtime.getRuntime().exec(command);
-//            process.waitFor();
-//        } catch (IOException e) {
-//            // TODO Auto-generated catch block
-//            e.printStackTrace();
-//        }
-//        // 使用这种方式会在瞬间大量消耗CPU和内存等系统资源,所以这里我们需要对流进行处理
-//        InputStream errorStream = process.getErrorStream();
-//        InputStreamReader inputStreamReader = new InputStreamReader(errorStream);
-//        BufferedReader br = new BufferedReader(inputStreamReader);
-//
-//        String line = "";
-//        while ((line = br.readLine()) != null) {
-//        }
-//        if (br != null) {
-//            br.close();
-//        }
-//        if (inputStreamReader != null) {
-//            inputStreamReader.close();
-//        }
-//        if (errorStream != null) {
-//            errorStream.close();
-//        }
-//
-//    }
-//
-//    /**
-//     * 从视频中提取音频信息
-//     * @param videoUrl
-//     * @return
-//     */
-//    public static String videoToAudio(String videoUrl,String accFile){
-//        String aacFile = "";
-//        try {
-//            aacFile = TMP_PATH + "/" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())
-//                    + UUID.randomUUID().toString().replaceAll("-", "") + ".mp3";
-//            String command =   FFMPEG_PATH + " -i "+ videoUrl + " -vn -acodec copy "+ aacFile;
-//            System.out.println("video to audio command : " + command);
-//            Process process = Runtime.getRuntime().exec(command);
-//            process.waitFor();
-//        } catch (Exception e) {
-//            e.printStackTrace();
-//        }
-//        return "";
-//    }
-//
-//    /**
-//     * FFmpeg全路径
-//     */
-//    private static final String FFMPEG_PATH = "D:\\java\\ffmpeg\\bin\\ffmpeg.exe";
-//    /**
-//     * 音频保存路径
-//     */
-//    private static final String TMP_PATH = "D:\\data\\test";
-//}

+ 67 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/YdMaterialWeekEntity.java

@@ -0,0 +1,67 @@
+package org.jeecg.modules.excelutil.entity;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+/**
+ * 伊对每周素材统计
+ *
+ * @author 宋英豪
+ */
+public class YdMaterialWeekEntity extends BaseRowModel {
+    /**
+     * 日期
+     */
+    @ExcelProperty(index = 1, value = "日期")
+    private String date;
+
+    /**
+     * 创意类型
+     */
+    @ExcelProperty(index = 1, value = "创意类型")
+    private String type;
+
+    /**
+     * 视频链接/图片数量
+     */
+    @ExcelProperty(index = 1, value = "视频链接/图片数量")
+    private String imageUrl;
+
+    /**
+     * 创意类型
+     */
+    @ExcelProperty(index = 1, value = "创意名称")
+    private String name;
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public String getImageUrl() {
+        return imageUrl;
+    }
+
+    public void setImageUrl(String imageUrl) {
+        this.imageUrl = imageUrl;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 95 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/YdPlanAggregateEntity.java

@@ -0,0 +1,95 @@
+package org.jeecg.modules.excelutil.entity;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+/**
+ * 伊对计划汇总报表信息
+ *
+ * @author 宋英豪
+ */
+public class YdPlanAggregateEntity extends BaseRowModel {
+    /**
+     * 账号名称
+     */
+    @ExcelProperty(index = 1, value = "账号名称")
+    private String accountName;
+
+    /**
+     * 投放时间
+     */
+    @ExcelProperty(index = 1, value = "投放时间")
+    private String date;
+
+    /**
+     * 计划名称
+     */
+    @ExcelProperty(index = 1, value = "计划名称")
+    private String planName;
+
+    /**
+     * 总花费(元)
+     */
+    @ExcelProperty(index = 1, value = "总花费(元)")
+    private String totalCost;
+
+    /**
+     * 展示
+     */
+    @ExcelProperty(index = 1, value = "展示")
+    private String show;
+
+    /**
+     * 点击
+     */
+    @ExcelProperty(index = 1, value = "点击")
+    private String click;
+
+    /**
+     * 点击率(%)
+     */
+    @ExcelProperty(index = 1, value = "点击率(%)")
+    private String clickRate;
+
+    /**
+     * 平均点击单价(元)
+     */
+    @ExcelProperty(index = 1, value = "平均点击单价(元)")
+    private String priceAvg;
+
+    /**
+     * 平均千次展现费用(元)
+     */
+    @ExcelProperty(index = 1, value = "平均千次展现费用(元)")
+    private String ctr;
+
+    /**
+     * 转化数
+     */
+    @ExcelProperty(index = 1, value = "转化数")
+    private String convert;
+
+    /**
+     * 转化成本
+     */
+    @ExcelProperty(index = 1, value = "转化成本")
+    private String convertPrice;
+
+    /**
+     * 转化率(%)
+     */
+    @ExcelProperty(index = 1, value = "转化率(%)")
+    private String convertRate;
+
+    /**
+     * 投放平台
+     */
+    @ExcelProperty(index = 1, value = "投放平台")
+    private String platform;
+
+    /**
+     * 投放性别
+     */
+    @ExcelProperty(index = 1, value = "投放性别")
+    private String sex;
+}

+ 64 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/excelutil/entity/YdWeekAggregateEntity.java

@@ -0,0 +1,64 @@
+package org.jeecg.modules.excelutil.entity;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.metadata.BaseRowModel;
+
+/**
+ * 伊对周报汇总
+ *
+ * @author 宋英豪
+ */
+public class YdWeekAggregateEntity extends BaseRowModel {
+    /**
+     * 时间
+     */
+    @ExcelProperty(index = 1, value = "时间")
+    private String date;
+    /**
+     * 时间
+     */
+    @ExcelProperty(index = 2, value = "总消费")
+    private String cost;
+    /**
+     * 时间
+     */
+    @ExcelProperty(index = 3, value = "激活数(头条)")
+    private String active;
+    /**
+     * 时间
+     */
+    @ExcelProperty(index = 4, value = "激活成本(头条)")
+    private String activeAvg;
+
+    public String getDate() {
+        return date;
+    }
+
+    public void setDate(String date) {
+        this.date = date;
+    }
+
+    public String getCost() {
+        return cost;
+    }
+
+    public void setCost(String cost) {
+        this.cost = cost;
+    }
+
+    public String getActive() {
+        return active;
+    }
+
+    public void setActive(String active) {
+        this.active = active;
+    }
+
+    public String getActiveAvg() {
+        return activeAvg;
+    }
+
+    public void setActiveAvg(String activeAvg) {
+        this.activeAvg = activeAvg;
+    }
+}

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

@@ -79,6 +79,8 @@ spring:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
     druid:
+      removeAbandoned: true
+      removeAbandonedTimeout: 300
       stat-view-servlet:
         enabled: true
         loginUsername: admin
@@ -152,6 +154,8 @@ mybatis-plus:
       log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 #jeecg专用配置
 jeecg:
+  ffmpeg:
+    bin: D:\java\ffmpeg\bin\ffmpeg.exe
   path:
     #文件上传根目录 设置
     upload: D://upFiles

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

@@ -141,6 +141,8 @@ mybatis-plus:
       table-underline: true
 #jeecg专用配置
 jeecg:
+  ffmpeg:
+    bin: /mnt/ffmpeg/bin
   path:
     #文件上传根目录 设置
     upload: /mnt/upload

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

@@ -1,6 +1,7 @@
 spring:
   profiles:
-    active: @activatedProperties@
+    active: prod
+  #      active: @activatedProperties@
   application:
     name: system-web
 eureka:

+ 36 - 0
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,14 +5,17 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 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.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
+import cn.com.ctop.toutiao.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.IBytedanceFundDailyService;
 import org.jeecg.modules.ctop.service.IPerformanceSaleService;
 import org.junit.Test;
@@ -168,6 +171,28 @@ public class SampleTest {
         }
     }
 
+    @Test
+    public void loadCampaignDate() {
+        Date endDate = DateUtils.addDay(new Date(), -1);
+        Date startDate = DateUtils.addDay(new Date(), -10);
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        if (null == tokens || tokens.size() <= 0) {
+            log.info("定时获取头条数据异常:为获取到可用的token");
+            return;
+        }
+//        executorService = Executors.newFixedThreadPool(10);
+        tokens.forEach(token -> {
+//            executorService.submit(new Runnable() {
+//                @Override
+//                public void run() {
+            //获取广告主信息数据
+            reportService.getCampaignReportByPage(token, startDate, endDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY, 1);
+//                }
+//            });
+        });
+    }
+
     @Autowired
     private IReportService reportService;
     @Autowired
@@ -239,6 +264,17 @@ public class SampleTest {
         performanceSaleService.loadSalsePerformance();
     }
 
+    @Test
+    public void loadBtPlanData() {
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
+        tokens.forEach(token -> {
+            advertiserDataService.getAdvertiserPlan(token, "", null, null);
+        });
+    }
+
+    @Autowired
+    private IByteDanceAdvertiserDataService advertiserDataService;
+
     @Autowired
     private IPerformanceSaleService performanceSaleService;
 

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -15,5 +15,5 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     UserAllocation getByAccountId(Long accountId);
 
-    List<UserAllocation> getByProjectId(long projectId, String systemType);
+    List<UserAllocation> getByProjectId(Long projectId, String systemType);
 }

+ 4 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -154,7 +154,10 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
     @Override
     public List<CtopOauthToken> getTokenListByType(String platformType) {
         QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("media_id", platformType).orderByDesc("account_id");
+        if (null != platformType && !platformType.trim().equals("")) {
+            queryWrapper.eq("media_id", platformType);
+        }
+        queryWrapper.orderByDesc("account_id");
         return this.list(queryWrapper);
     }
 

+ 4 - 2
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -26,9 +26,11 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     }
 
     @Override
-    public List<UserAllocation> getByProjectId(long projectId, String systemType) {
+    public List<UserAllocation> getByProjectId(Long projectId, String systemType) {
         QueryWrapper<UserAllocation> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("project_id", projectId);
+        if (null != projectId && projectId != 0) {
+            queryWrapper.eq("project_id", projectId);
+        }
         if (null != systemType && !systemType.trim().equals("")) {
             queryWrapper.eq("system_type", systemType);
         }

+ 19 - 3
module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java

@@ -34,10 +34,21 @@ public class CtopAdConstant {
      */
     public static final String SYSTEM_SALE_AM_CODE = "f5a68aa2acf86e842100f0fa4b050d28";
 
-
-    public static final BigDecimal BYTEDANCE_MEDIA_TASK_COST = new BigDecimal("200000000");
-    public static final BigDecimal KUAISHOU_MEDIA_TASK_COST = new BigDecimal("200000000");
+    /**
+     * 头条销售媒体季度任务
+     */
+    public static final BigDecimal BYTEDANCE_MEDIA_TASK_COST = new BigDecimal("150000000");
+    /**
+     * 快手销售媒体季度任务
+     */
+    public static final BigDecimal KUAISHOU_MEDIA_TASK_COST = new BigDecimal("147000000");
+    /**
+     * 头条销售季度个人任务
+     */
     public static final BigDecimal BYTEDANCE_PERSONAL_TASK_COST = new BigDecimal("2400000");
+    /**
+     * 快手销售季度个人任务
+     */
     public static final BigDecimal KUAISHOU_PERSONAL_TASK_COST = new BigDecimal("2400000");
 
     /**
@@ -48,4 +59,9 @@ public class CtopAdConstant {
      * 华北头条销售机构号
      */
     public static final String HB_BYTEDANCE_SALE_ORG_CODE = "A01A11A02";
+
+    public static final String BYTEDANCE_GENDER_TYPE_NONE = "NONE";
+    public static final String BYTEDANCE_GENDER_TYPE_GENDER_MALE = "GENDER_MALE";
+    public static final String BYTEDANCE_GENDER_TYPE_GENDER_FEMALE = "GENDER_FEMALE";
+
 }

+ 0 - 31
module-report/src/main/java/cn/com/ctop/bytedance/controller/ReportController.java

@@ -38,37 +38,6 @@ public class ReportController {
     }
 
     /**
-     * 头条广告计划报表信息
-     * 只支持查询2016-10-26及以后的日期
-     * 单次获取最大条数1000
-     * @return 广告组报表数据
-     */
-    @GetMapping("bytedance/campaign")
-    public Map<String, Object> campaignReport(@RequestBody ByteDanceAdvertiserReportDTO conditions) {
-        return reportService.getCampaignReport(conditions);
-    }
-
-    /**
-     * 头条广告计划报表信息
-     * @param conditions 查询条件
-     * @return 广告计划报表数据
-     */
-    @GetMapping("bytedance/ad")
-    public Map<String, Object> adReport(@RequestBody ByteDanceAdvertiserReportDTO conditions) {
-        return reportService.getAdReport(conditions);
-    }
-
-    /**
-     * 头条广告创意报表信息
-     * @param conditions
-     * @return
-     */
-    @GetMapping("bytedance/creative")
-    public Map<String, Object> creativeReport(@RequestBody ByteDanceAdvertiserReportDTO conditions) {
-        return reportService.getCreativeReport(conditions);
-    }
-
-    /**
      * 代理商数据
      * @param conditions
      * @return

+ 1 - 1
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceCampaignDailyReport.java

@@ -429,7 +429,7 @@ public class BytedanceCampaignDailyReport {
         }
         String statDatetime = data.getString("stat_datetime");
         if (null != statDatetime && !"".equals(statDatetime.trim())) {
-            this.statDatetime = statDatetime;
+            this.statDatetime = statDatetime.substring(0, 10);
         }
         Long shopping = data.getLong("shopping");
         if (null != shopping) {

+ 2 - 6
module-report/src/main/java/cn/com/ctop/bytedance/service/IReportService.java

@@ -10,12 +10,6 @@ import java.util.Map;
 public interface IReportService {
     Map<String, Object> getAdvertiserReport(ByteDanceAdvertiserReportDTO conditions);
 
-    Map<String, Object> getCampaignReport(ByteDanceAdvertiserReportDTO conditions);
-
-    Map<String, Object> getAdReport(ByteDanceAdvertiserReportDTO conditions);
-
-    Map<String, Object> getCreativeReport(ByteDanceAdvertiserReportDTO conditions);
-
     Map<String, Object> getAgentReport(JSONObject conditions);
 
     void insertCustomerInfo(String csvPath, String charset);
@@ -28,6 +22,8 @@ public interface IReportService {
 
     void getAdvertiserCampaignReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
 
+    void getCampaignReportByPage(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl, Integer pageNum);
+
     void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
 
     void getAdvertiserCreativeReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);

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

@@ -146,12 +146,10 @@ public class ReportServiceImpl implements IReportService {
         getCampaignReportByPage(token, conditions, 1);
     }
 
-    private void getCampaignReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
-        conditions.setPage(page);
-        SerializeConfig config = new SerializeConfig();
-        config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
-        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
-        JSONObject getObject = getCampaignStat(token, jsonObject);
+    @Override
+    public void getCampaignReportByPage(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl, Integer pageNum) {
+        JSONObject getObject = getCampaignStat(token, startDate, endDate, bytedanceReportTypePl, pageNum);
+        System.out.println("返回数据:" + getObject.toJSONString());
         Integer code = getObject.getInteger("code");
         String message = getObject.getString("message");
         if (null == code || code != 0) {
@@ -165,51 +163,63 @@ public class ReportServiceImpl implements IReportService {
         }
         for (var i = 0; i < dataArray.size(); i++) {
             var data = dataArray.getJSONObject(i);
-            if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
+            if (CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(bytedanceReportTypePl)) {
                 var hourlyReport = new BytedanceCampaignHourlyReport(data, token.getAccountId());
                 campaignHourlyReportService.saveOrUpdate(hourlyReport);
             } else {
+                System.out.println(data.toJSONString());
                 var dailyReport = new BytedanceCampaignDailyReport(data, token.getAccountId());
                 campaignDailyReportService.saveOrUpdate(dailyReport);
             }
         }
-        getCampaignReportByPage(token, conditions, page + 1);
+        getCampaignReportByPage(token, startDate, endDate, bytedanceReportTypePl, pageNum + 1);
     }
 
-    @Override
-    public Map<String, Object> getCampaignReport(ByteDanceAdvertiserReportDTO conditions) {
-        conditions.setAdvertiserId(111463131228L);
-        conditions.setStartDate("2019-06-01");
-        conditions.setEndDate("2019-06-10");
-        conditions.setPageSize(1000);
-        conditions.setPage(1);
-        conditions.setTimeGranularity(CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+    private JSONObject getCampaignStat(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl, Integer pageNum) {
+        // 请求地址
+        String url = "https://ad.oceanengine.com/open_api/2/report/campaign/get/";
+        // 请求参数
+        JSONObject params = new JSONObject();
+        params.put("page", pageNum);
+        params.put("page_size", 100);
+        params.put("advertiser_id", token.getAccountId());
+        params.put("start_date", DateUtils.formatDate(startDate));
+        params.put("end_date", DateUtils.formatDate(endDate));
+        params.put("time_granularity", bytedanceReportTypePl);
+        params.put("group_by", new String[]{"STAT_GROUP_BY_FIELD_ID", "STAT_GROUP_BY_FIELD_STAT_TIME"});
+        return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
+    }
+
+    private void getCampaignReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
+        conditions.setPage(page);
         SerializeConfig config = new SerializeConfig();
         config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
         JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
-        Long accountId = conditions.getAdvertiserId();
-        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
-        JSONObject getObject = getAdStat(token, jsonObject);
+        System.out.println(jsonObject.toJSONString());
+        JSONObject getObject = getCampaignStat(token, jsonObject);
+        System.out.println(getObject.toJSONString());
         Integer code = getObject.getInteger("code");
         String message = getObject.getString("message");
         if (null == code || code != 0) {
             log.error("广告组报表数据获取异常:{}", message);
-        } else {
-            JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
-            if (null != dataArray && dataArray.size() > 0) {
-                for (int i = 0; i < dataArray.size(); i++) {
-                    JSONObject data = dataArray.getJSONObject(i);
-                    if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
-                        BytedanceCampaignHourlyReport hourlyReport = new BytedanceCampaignHourlyReport(data, token.getAccountId());
-                        campaignHourlyReportService.saveOrUpdate(hourlyReport);
-                    } else {
-                        BytedanceCampaignDailyReport dailyReport = new BytedanceCampaignDailyReport(data, token.getAccountId());
-                        campaignDailyReportService.saveOrUpdate(dailyReport);
-                    }
-                }
+            return;
+        }
+        JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
+        if (null == dataArray || dataArray.size() <= 0) {
+            log.info("广告组报表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+        for (var i = 0; i < dataArray.size(); i++) {
+            var data = dataArray.getJSONObject(i);
+            if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
+                var hourlyReport = new BytedanceCampaignHourlyReport(data, token.getAccountId());
+                campaignHourlyReportService.saveOrUpdate(hourlyReport);
+            } else {
+                var dailyReport = new BytedanceCampaignDailyReport(data, token.getAccountId());
+                campaignDailyReportService.saveOrUpdate(dailyReport);
             }
         }
-        return getObject;
+        getCampaignReportByPage(token, conditions, page + 1);
     }
 
     @Override
@@ -266,42 +276,6 @@ public class ReportServiceImpl implements IReportService {
     }
 
     @Override
-    public Map<String, Object> getAdReport(ByteDanceAdvertiserReportDTO conditions) {
-        conditions.setAdvertiserId(111463131228L);
-        conditions.setStartDate("2019-06-01");
-        conditions.setEndDate("2019-06-10");
-        conditions.setPageSize(1000);
-        conditions.setPage(1);
-        conditions.setTimeGranularity(CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-        SerializeConfig config = new SerializeConfig();
-        config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
-        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
-        Long accountId = conditions.getAdvertiserId();
-        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
-        JSONObject getObject = getAdStat(token, jsonObject);
-        Integer code = getObject.getInteger("code");
-        String message = getObject.getString("message");
-        if (null == code || code != 0) {
-            log.error("广告计划报表数据获取异常:{}", message);
-        } else {
-            JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
-            if (null != dataArray && dataArray.size() > 0) {
-                for (int i = 0; i < dataArray.size(); i++) {
-                    JSONObject data = dataArray.getJSONObject(i);
-                    if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
-                        BytedancePlanHourlyReport hourlyReport = new BytedancePlanHourlyReport(data, token.getAccountId());
-                        planHourlyReportService.saveOrUpdate(hourlyReport);
-                    } else {
-                        BytedancePlanDailyReport dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());
-                        planDailyReportService.saveOrUpdate(dailyReport);
-                    }
-                }
-            }
-        }
-        return getObject;
-    }
-
-    @Override
     public void getAdvertiserCreativeReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
         var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
         getCreativeReportByPage(token, conditions, 1);
@@ -373,42 +347,6 @@ public class ReportServiceImpl implements IReportService {
     }
 
     @Override
-    public Map<String, Object> getCreativeReport(ByteDanceAdvertiserReportDTO conditions) {
-        conditions.setAdvertiserId(111463131228L);
-        conditions.setStartDate("2019-06-01");
-        conditions.setEndDate("2019-06-10");
-        conditions.setPageSize(1000);
-        conditions.setPage(1);
-        conditions.setTimeGranularity(CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-        SerializeConfig config = new SerializeConfig();
-        config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
-        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
-        Long accountId = conditions.getAdvertiserId();
-        CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
-        JSONObject getObject = getCreativeStat(token, jsonObject);
-        Integer code = getObject.getInteger("code");
-        String message = getObject.getString("message");
-        if (null == code || code != 0) {
-            log.error("广告创意报表数据获取异常:{}", message);
-        } else {
-            JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
-            if (null != dataArray && dataArray.size() > 0) {
-                for (int i = 0; i < dataArray.size(); i++) {
-                    JSONObject data = dataArray.getJSONObject(i);
-                    if (null != conditions.getTimeGranularity() && CtopAdConstant.BYTEDANCE_REPORT_TYPE_HOURLY.equals(conditions.getTimeGranularity())) {
-                        BytedanceCreativeHourlyReport hourlyReport = new BytedanceCreativeHourlyReport(data, token.getAccountId());
-                        creativeHourlyReportService.saveOrUpdate(hourlyReport);
-                    } else {
-                        BytedanceCreativeDailyReport dailyReport = new BytedanceCreativeDailyReport(data, token.getAccountId());
-                        creativeDailyReportService.saveOrUpdate(dailyReport);
-                    }
-                }
-            }
-        }
-        return getObject;
-    }
-
-    @Override
     public Map<String, Object> getAgentReport(JSONObject conditions) {
         Long accountId = conditions.getLong("accountId");
         CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");

+ 40 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertisePlan.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.entity;
 
-import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -12,6 +13,7 @@ import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * 今日头条广告计划信息
@@ -219,10 +221,22 @@ public class ByteDanceAdvertisePlan {
      */
     @Excel(name = "audience", width = 15)
     @ApiModelProperty(value = "audience")
-    private Object audience;
+    private String audience;
     @Excel(name = "上次修改时间", width = 15)
     @ApiModelProperty(value = "上次修改时间")
     private String modifyTime;
+    /**
+     * 受众性别
+     */
+    private String gender;
+    /**
+     * 受众平台
+     */
+    private String platform;
+
+    private Date createTime;
+
+    private Date updateTime;
 
     public ByteDanceAdvertisePlan(JSONObject dataObject, String accountId) {
         Long id = dataObject.getLong("id");
@@ -232,7 +246,30 @@ public class ByteDanceAdvertisePlan {
         if (null != name && !"".equals(name.trim())) {
             this.name = name;
         }
-
+        JSONObject audience = dataObject.getJSONObject("audience");
+        if (null != audience) {
+            this.audience = audience.toJSONString();
+            JSONArray platform = audience.getJSONArray("platform");
+            if (null != platform && platform.size() > 0) {
+                String plat = "";
+                for (int i = 0; i < platform.size(); i++) {
+                    plat += platform.getString(i) + ",";
+                }
+                this.platform = plat.substring(0, plat.length() - 1);
+            }
+            String gender = audience.getString("gender");
+            if (null != gender) {
+                if (CtopAdConstant.BYTEDANCE_GENDER_TYPE_NONE.equals(gender)) {
+                    this.gender = "不限";
+                } else if (CtopAdConstant.BYTEDANCE_GENDER_TYPE_GENDER_MALE.equals(gender)) {
+                    this.gender = "男";
+                } else {
+                    this.gender = "女";
+                }
+            }
+        }
+        this.createTime = new Date();
+        this.updateTime = new Date();
         Long advertiserId = dataObject.getLong("advertiser_id");
         if (null != advertiserId) {
             this.toutiaoId = advertiserId;

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

@@ -111,6 +111,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         param.put("page_size", 100);
         param.put("filtering", filtering);
         JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
+        System.out.println(resultObject.toJSONString());
         Integer code = resultObject.getInteger("code");
         if (null == code || !code.equals(0)) {
             log.error("获取广告计划信息接口异常==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
@@ -128,8 +129,6 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
             if (null != deepCpabid) {
                 advertisePlan.setDeepCpabid(deepCpabid);
             }
-
-
             advertisePlanService.saveOrUpdate(advertisePlan);
         }
         getAd(token, pageNum + 1, ids, date, updateDate);