Selaa lähdekoodia

素材报表接口提交

syh 5 vuotta sitten
vanhempi
commit
5ed48dc6a9

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

@@ -0,0 +1,250 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.ctop.entity.EduLessonNew;
+import org.jeecg.modules.ctop.service.IEduLessonNewService;
+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 javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 内部培训视频信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-22
+ */
+@Slf4j
+@Api(tags = "内部培训视频信息")
+@RestController
+@RequestMapping("/ctop/eduLessonNew")
+public class EduLessonNewController {
+    @Autowired
+    private IEduLessonNewService eduLessonNewService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param eduLessonNew
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "内部培训视频信息-分页列表查询")
+    @ApiOperation(value = "内部培训视频信息-分页列表查询", notes = "内部培训视频信息-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<EduLessonNew>> queryPageList(EduLessonNew eduLessonNew,
+                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                     @RequestParam(name = "pageSize", defaultValue = "1000") Integer pageSize,
+                                                     HttpServletRequest req) {
+        Result<IPage<EduLessonNew>> result = new Result<>();
+        eduLessonNew.setEnabled(CtopAdConstant.COMMON_STATUS_ENABLED);
+        QueryWrapper<EduLessonNew> queryWrapper = QueryGenerator.initQueryWrapper(eduLessonNew, req.getParameterMap());
+        Page<EduLessonNew> page = new Page<>(pageNo, pageSize);
+        IPage<EduLessonNew> pageList = eduLessonNewService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param eduLessonNew
+     * @return
+     */
+    @AutoLog(value = "内部培训视频信息-添加")
+    @ApiOperation(value = "内部培训视频信息-添加", notes = "内部培训视频信息-添加")
+    @PostMapping(value = "/add")
+    public Result<EduLessonNew> add(@RequestBody EduLessonNew eduLessonNew) {
+        Result<EduLessonNew> result = new Result<EduLessonNew>();
+        try {
+            eduLessonNewService.save(eduLessonNew);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param eduLessonNew
+     * @return
+     */
+    @AutoLog(value = "内部培训视频信息-编辑")
+    @ApiOperation(value = "内部培训视频信息-编辑", notes = "内部培训视频信息-编辑")
+    @PutMapping(value = "/edit")
+    public Result<EduLessonNew> edit(@RequestBody EduLessonNew eduLessonNew) {
+        Result<EduLessonNew> result = new Result<EduLessonNew>();
+        EduLessonNew eduLessonNewEntity = eduLessonNewService.getById(eduLessonNew.getId());
+        if (eduLessonNewEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = eduLessonNewService.updateById(eduLessonNew);
+            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 {
+            eduLessonNewService.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<EduLessonNew> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<EduLessonNew> result = new Result<EduLessonNew>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.eduLessonNewService.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<EduLessonNew> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<EduLessonNew> result = new Result<EduLessonNew>();
+        EduLessonNew eduLessonNew = eduLessonNewService.getById(id);
+        if (eduLessonNew == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(eduLessonNew);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<EduLessonNew> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                EduLessonNew eduLessonNew = JSON.parseObject(deString, EduLessonNew.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(eduLessonNew, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<EduLessonNew> pageList = eduLessonNewService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "内部培训视频信息列表");
+        mv.addObject(NormalExcelConstants.CLASS, EduLessonNew.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<EduLessonNew> listEduLessonNews = ExcelImportUtil.importExcel(file.getInputStream(), EduLessonNew.class, params);
+                eduLessonNewService.saveBatch(listEduLessonNews);
+                return Result.ok("文件导入成功!数据行数:" + listEduLessonNews.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("文件导入失败!");
+    }
+
+}

+ 100 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/EduLessonNew.java

@@ -0,0 +1,100 @@
+package org.jeecg.modules.ctop.entity;
+
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+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
+ * @version V1.0
+ * @date 2020-04-22
+ */
+@Data
+@TableName("ctop_edu_lesson_new")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_edu_lesson_new对象", description = "内部培训视频信息")
+public class EduLessonNew {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+    private Integer id;
+    /**
+     * name
+     */
+    @Excel(name = "name", width = 15)
+    @ApiModelProperty(value = "name")
+    private String name;
+    /**
+     * 文件类型
+     */
+    @Excel(name = "文件类型", width = 15)
+    @ApiModelProperty(value = "文件类型")
+    private Integer fileType;
+    /**
+     * 节点类型
+     */
+    @Excel(name = "节点类型", width = 15)
+    @ApiModelProperty(value = "节点类型")
+    private Integer nodeType;
+    /**
+     * 父id
+     */
+    @Excel(name = "父id", width = 15)
+    @ApiModelProperty(value = "父id")
+    private Integer parentId;
+    /**
+     * author
+     */
+    @Excel(name = "author", width = 15)
+    @ApiModelProperty(value = "author")
+    private String author;
+    /**
+     * desc
+     */
+    @Excel(name = "desc", width = 15)
+    @ApiModelProperty(value = "desc")
+    private String desc;
+    /**
+     * fileId
+     */
+    @Excel(name = "fileId", width = 15)
+    @ApiModelProperty(value = "fileId")
+    private String fileId;
+    /**
+     * enabled
+     */
+    @Excel(name = "enabled", width = 15)
+    @ApiModelProperty(value = "enabled")
+    private Integer enabled;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+
+    public EduLessonNew() {
+        this.enabled = CtopAdConstant.COMMON_STATUS_ENABLED;
+        this.createTime = new Date();
+        this.updateTime = new Date();
+    }
+}

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

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.ctop.entity.EduLessonNew;
+
+/**
+ * 内部培训视频信息
+ *
+ * @author: jeecg-boot
+ * @date: 2020-04-22
+ * @cersion: V1.0
+ */
+public interface EduLessonNewMapper extends BaseMapper<EduLessonNew> {
+
+}

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

@@ -0,0 +1,5 @@
+<?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="org.jeecg.modules.ctop.mapper.EduLessonNewMapper">
+
+</mapper>

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

@@ -0,0 +1,15 @@
+package org.jeecg.modules.ctop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.ctop.entity.EduLessonNew;
+
+/**
+ * 内部培训视频信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-22
+ */
+public interface IEduLessonNewService extends IService<EduLessonNew> {
+
+}

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

@@ -0,0 +1,19 @@
+package org.jeecg.modules.ctop.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.ctop.entity.EduLessonNew;
+import org.jeecg.modules.ctop.mapper.EduLessonNewMapper;
+import org.jeecg.modules.ctop.service.IEduLessonNewService;
+import org.springframework.stereotype.Service;
+
+/**
+ * 内部培训视频信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-04-22
+ */
+@Service
+public class EduLessonNewServiceImpl extends ServiceImpl<EduLessonNewMapper, EduLessonNew> implements IEduLessonNewService {
+
+}

+ 18 - 113
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -1,20 +1,18 @@
 package org.jeecg;
 
-import cn.com.ctop.bytedance.service.IBytedanceReportService;
 import cn.com.ctop.bytedance.service.IReportService;
 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 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.modules.ctop.service.IBytedanceFundDailyService;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.IPerformanceSaleService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -23,7 +21,6 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -55,74 +52,6 @@ public class SampleTest {
             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
             Date parse = simpleDateFormat.parse("2020-03-12");
             kuaishouInterfaceService.getAdvertiserReportDaily(token, parse, parse);
-
-
-//            reportTaskService.createTask(3727345L, "871fc2c248782a94ad2962c941555abc", "");
-//            reportTaskService.getTaskList();
-
-/*
-            reportTaskService.createTask(3727345L, "871fc2c248782a94ad2962c941555abc");
-            reportTaskService.getTaskList();*/
-
-
-
-         /*   String url = "https://ad.e.kuaishou.com/rest/openapi/v1/async_task/list";
-            Map<String, String> headers = new HashMap<>();
-            headers.put("Content-Type", " application/json");
-            headers.put("Access-Token", "eb9a0d18072eabc339ee26ad010ecd6b");
-            JSONObject param = new JSONObject();
-            param.put("advertiser_id", 142402);
-            JSONArray taskIds = new JSONArray();
-            taskIds.add(1229917);
-
-            param.put("task_ids", taskIds);
-            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
-            JSONObject resultJson = JSONObject.parseObject(result);
-
-
-          /*  String url = "https://ad.e.kuaishou.com/rest/openapi/v1/async_task/download";
-
-            Map<String, String> headers = new HashMap<>();
-            headers.put("Access-Token", "eb9a0d18072eabc339ee26ad010ecd6b");
-
-            Map<String,Object> param = new HashMap<>();
-            param.put("advertiser_id", 142402);
-            param.put("task_id", "1229917");
-            String result = HttpUtils.KuaiShouttpGetRequest(url, param,headers);*/
-
-
-            /*URL url = new URL("https://ad.e.kuaishou.com/rest/openapi/v1/async_task/download?task_id=1229917&advertiser_id=142402");
-            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-            //设置超时间为3秒
-            conn.setConnectTimeout(10 * 1000);
-            //防止屏蔽程序抓取而返回403错误
-            conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
-            conn.setRequestProperty("Access-Token", "6a1fbe20e49fe519ec8120aac5c9e55a");
-            //得到输入流
-            InputStream inputStream = conn.getInputStream();
-            //获取自己数组
-            byte[] getData = readInputStream(inputStream);
-
-            //文件保存位置
-            File saveDir = new File("D:\\file");
-            if (!saveDir.exists()) {
-                saveDir.mkdirs();
-            }
-            String fileName = "123.csv";
-            File file = new File(saveDir + File.separator + fileName);
-            FileOutputStream fos = new FileOutputStream(file);
-            fos.write(getData);
-            if (fos != null) {
-                fos.close();
-            }
-            if (inputStream != null) {
-                inputStream.close();
-            }*/
-         /*   String localPath = "D:\\file\\123.csv";
-
-            reportDailyAccountMapper.loadAccountDailyReport(142402L,localPath);*/
-
-
         } catch (Exception e) {
             e.printStackTrace();
 
@@ -134,28 +63,26 @@ public class SampleTest {
     private static ExecutorService executorService = Executors.newFixedThreadPool(10);
     private static CountDownLatch countDownLatch = null;
 
-    @Autowired
-    private IBytedanceFundDailyService fundDailyService;
     @Test
     public void testLoadJob() {
-        String endDate = "2020-04-07";
-        String startDate = "2019-09-01";
-        CtopOauthToken token = tokenService.getTokenByAccountId(1654676647522317L);
-//        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
-        List<CtopOauthToken> tokens = new ArrayList<>();
-        tokens.add(token);
+        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
         if (null != tokens && tokens.size() > 0) {
             countDownLatch = new CountDownLatch(tokens.size());
-            tokens.forEach(getToken -> {
+            tokens.forEach(token -> {
                 //拉取往期数据
                 executorService.submit(new Runnable() {
                     @Override
                     public void run() {
                         try {
-                            fundDailyService.loadFundDataByPage(getToken, startDate, endDate, 1);
-                            countDownLatch.countDown();
+                            Date date = new Date();
+                            for (int i = 0; i < 180; i++) {
+                                Date startDate = DateUtils.addDay(date, -i);
+                                reportService.getMaterialReportByPage(token, DateUtils.formatDate(startDate), DateUtils.formatDate(startDate), 1);
+                            }
                         } catch (Exception e) {
                             e.printStackTrace();
+                        } finally {
+                            countDownLatch.countDown();
                         }
                     }
                 });
@@ -171,17 +98,12 @@ public class SampleTest {
 
     @Autowired
     private IReportService reportService;
-    @Autowired
-    private IUserAllocationService userAllocationService;
 
     @Test
     public void wanHuaTong() {
         String url = "https://ad.oceanengine.com/open_api/2/kaleidoscope/job/smart_cut/submit/";
 
         JSONObject conditions = new JSONObject();
-
-        // 1629785592929294
-
         conditions.put("advertiser_id", "1659671533108238");
         JSONObject job = new JSONObject();
         job.put("job_conf_id", 10);
@@ -231,10 +153,6 @@ public class SampleTest {
 
     }
 
-
-    @Autowired
-    private IKuaiShouCreativeService creativeService;
-
     @Test
     public void testSalePerformance() {
         performanceSaleService.loadSalsePerformance();
@@ -251,32 +169,19 @@ public class SampleTest {
         Long accountId = 3917130L;
         String token = "0a42e23921e486108105263e75561404";
         kuaishouInterfaceService.getVideoList("e91c778d7de1bd0e9d8f3213d1e0e57c",3820093L, null,null,1);
-
-      /*  String url = "https://ad.e.kuaishou.com/rest/openapi/v1/file/ad/video/su_zao/list";
-
-
-        Map<String, String> headers = new HashMap<String, String>();
-        headers.put("Content-Type", "application/json");
-        headers.put("Access-Token", token);
-        Map<String, Object> param = new HashMap<String, Object>();
-
-        param.put("advertiser_id", accountId);
-        param.put("temporal_granularity", "HOURLY");
-        param.put("page", 1);
-        String result = HttpUtils.httpPostRequest(url, param, headers);
-        System.err.println(result);*/
-
-
     }
 
     @Test
     public void testLoadMatData() {
         CtopOauthToken token = tokenService.getTokenByAccountId(1660215200335886L);
-        bytedanceReportService.bytedanceMaterialReport(token, "2020-01-06", "2020-01-06");
+        Date date = new Date();
+        //2020-03-20
+        for (int i = 0; i < 180; i++) {
+            Date startDate = DateUtils.addDay(date, -i);
+            reportService.getMaterialReportByPage(token, DateUtils.formatDate(startDate), DateUtils.formatDate(startDate), 1);
+        }
+//        reportService.getMaterialReportByPage(token, "2020-03-20", "2020-03-20",1);
     }
-
-    @Autowired
-    private IBytedanceReportService bytedanceReportService;
 }
 
 

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java

@@ -51,4 +51,8 @@ public class CtopAdConstant {
      * 华北头条销售机构号
      */
     public static final String HB_BYTEDANCE_SALE_ORG_CODE = "A01A11A02";
+
+    public static final Integer COMMON_STATUS_ENABLED = 1;
+
+    public static final Integer COMMON_STATUS_NOT_ENABLED = 0;
 }

+ 4 - 51
module-report/src/main/java/cn/com/ctop/bytedance/controller/ReportController.java

@@ -4,13 +4,14 @@ import cn.com.ctop.bytedance.service.IReportService;
 import cn.com.ctop.bytedance.vo.ByteDanceAdvertiserReportDTO;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.ResultMapUtils;
-import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONObject;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
@@ -49,26 +50,6 @@ public class ReportController {
     }
 
     /**
-     * 头条广告计划报表信息
-     * @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
@@ -97,34 +78,6 @@ public class ReportController {
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
 
-    /**
-     * 360借条报表客户后台数据
-     */
-    @GetMapping("jietiao/customer/insert")
-    public Map<String, Object> jietiaoCustomerInsert() {
-        Map<String, Object> result = new HashMap<>();
-        String csvPath = "D:\\工作文件\\360借条\\测试数据\\客户后台数据.csv";
-        reportService.insertCustomerInfo(csvPath, "utf8");
-        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
-        return result;
-    }
-
-    /**
-     * 360借条报表平台数据
-     */
-    @GetMapping("jietiao/plateform/insert")
-    public Map<String, Object> jietiaoPlatformInsert() {
-        Map<String, Object> result = new HashMap<>();
-        String csvPath = "D:\\工作文件\\360借条\\测试数据\\快手后台数据.csv";
-        reportService.insertPlatformInfo(csvPath, "gb2312", 4L);
-        ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS.getCode());
-        return result;
-    }
-
-    @PostMapping("debitAuto")
-    Map<String, Object> debitAuto(@RequestBody JSONObject data) {
-        return reportService.debitAuto(data);
-    }
 
     @GetMapping("download/file")
     public void downLoadFile(String path, HttpServletResponse response) {

+ 109 - 6
module-report/src/main/java/cn/com/ctop/bytedance/entity/BytedanceReportMaterialDaily.java

@@ -1,21 +1,19 @@
 package cn.com.ctop.bytedance.entity;
 
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.Date;
+import com.alibaba.fastjson.JSONObject;
 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.jeecg.common.util.DateUtils;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
+import java.math.BigDecimal;
+
 /**
  * 素材报表
  * @author jeecg-boot
@@ -445,4 +443,109 @@ public class BytedanceReportMaterialDaily {
 	private java.math.BigDecimal installFinishCost;
 
 	private BigDecimal downloadStartRate;
+
+	public BytedanceReportMaterialDaily() {
+	}
+
+	public BytedanceReportMaterialDaily(JSONObject detailJson, Long accountId) {
+		JSONObject dimensions = detailJson.getJSONObject("dimensions");
+		this.accountId = accountId;
+		this.setImageMode(dimensions.getString("image_mode"));
+		this.setMaterialId(dimensions.getLong("material_id"));
+		this.setInventory(dimensions.getString("inventory"));
+		this.setStatDatetime(dimensions.getDate("stat_datetime") == null ? null : DateUtils.formatDate(dimensions.getDate("stat_datetime"), "yyyy-MM-dd"));
+
+		JSONObject metrics = detailJson.getJSONObject("metrics");
+		this.setActivePayAmount(metrics.getInteger("active_pay_amount"));
+		this.setValidPlayCost(metrics.getBigDecimal("valid_play_cost"));
+		this.setPlay75FeedBreak(metrics.getInteger("play_75_feed_break"));
+		this.setNextDayOpen(metrics.getInteger("next_day_open"));
+		this.setAdvancedCreativeCouponAddition(metrics.getInteger("advanced_creative_coupon_addition"));
+		this.setConvertMaterial(metrics.getInteger("convert"));
+		this.setActivePayCost(metrics.getBigDecimal("active_pay_cost"));
+		this.setInAppCart(metrics.getInteger("in_app_cart"));
+		this.setPlay25FeedBreak(metrics.getInteger("play_25_feed_break"));
+		this.setConsultEffective(metrics.getInteger("consult_effective"));
+		this.setViewMaterial(metrics.getInteger("view"));
+		this.setDownload(metrics.getInteger("download"));
+		this.setCpa(metrics.getBigDecimal("cpa"));
+		this.setCpc(metrics.getBigDecimal("cpc"));
+		this.setLocationClick(metrics.getInteger("location_click"));
+		this.setPhoneConfirm(metrics.getInteger("phone_confirm"));
+		this.setIesMusicClick(metrics.getInteger("ies_music_click"));
+		this.setPlayOverRate(metrics.getBigDecimal("play_over_rate"));
+		this.setWifiPlay(metrics.getInteger("wifi_play"));
+		this.setShopping(metrics.getInteger("shopping"));
+		this.setQq(metrics.getInteger("qq"));
+		this.setCtr(metrics.getBigDecimal("ctr"));
+		this.setCpm(metrics.getBigDecimal("cpm"));
+		this.setWifiPlayRate(metrics.getBigDecimal("wifi_play_rate"));
+		this.setLikeMaterial(metrics.getInteger("like"));
+		this.setPlay50FeedBreak(metrics.getInteger("play_50_feed_break"));
+		this.setActivePayRate(metrics.getBigDecimal("active_pay_rate"));
+		this.setActiveCost(metrics.getBigDecimal("active_cost"));
+		this.setActive(metrics.getInteger("active"));
+		this.setGameAddictionCost(metrics.getBigDecimal("game_addiction_cost"));
+		this.setGameAddiction(metrics.getInteger("game_addiction"));
+		this.setActiveRate(metrics.getBigDecimal("active_rate"));
+		this.setClick(metrics.getInteger("click"));
+		this.setPlayDuration_10s(metrics.getInteger("play_duration_10s"));
+		this.setAdvancedCreativePhoneClick(metrics.getInteger("advanced_creative_phone_click"));
+		this.setDownloadStart(metrics.getInteger("download_start"));
+		this.setHomeVisited(metrics.getInteger("home_visited"));
+		this.setPhone(metrics.getInteger("phone"));
+		this.setPhoneEffective(metrics.getInteger("phone_effective"));
+		this.setInAppPay(metrics.getInteger("in_app_pay"));
+		this.setGameAddictionRate(metrics.getBigDecimal("game_addiction_rate"));
+		this.setNextDayOpenCost(metrics.getBigDecimal("next_day_open_cost"));
+		this.setIesChallengeClick(metrics.getInteger("ies_challenge_click"));
+		this.setTotalPlay(metrics.getInteger("total_play"));
+		this.setActiveRegisterRate(metrics.getBigDecimal("active_register_rate"));
+		this.setAverageVideoPlay(metrics.getBigDecimal("average_video_play"));
+		this.setDownloadFinishCost(metrics.getBigDecimal("download_finish_cost"));
+		this.setPlayDuration_3s(metrics.getInteger("play_duration_3s"));
+		this.setActiveRegisterCost(metrics.getBigDecimal("active_register_cost"));
+		this.setShowMaterial(metrics.getInteger("show"));
+		this.setNextDayOpenRate(metrics.getBigDecimal("next_day_open_rate"));
+		this.setMapSearch(metrics.getInteger("map_search"));
+		this.setButton(metrics.getInteger("button"));
+		this.setPlayDurationSum(metrics.getInteger("play_duration_sum"));
+		this.setPlay100FeedBreak(metrics.getInteger("play_100_feed_break"));
+		this.setAdvancedCreativeCounselClick(metrics.getInteger("advanced_creative_counsel_click"));
+		this.setConvertRate(metrics.getBigDecimal("convert_rate"));
+		this.setDownloadFinishRate(metrics.getBigDecimal("download_finish_rate"));
+		this.setConsult(metrics.getInteger("consult"));
+		this.setShareMaterial(metrics.getInteger("share"));
+		this.setVote(metrics.getInteger("vote"));
+		this.setValidPlay(metrics.getInteger("valid_play"));
+		this.setInstallFinishRate(metrics.getBigDecimal("install_finish_rate"));
+		this.setRedirect(metrics.getInteger("redirect"));
+		this.setPayCount(metrics.getInteger("pay_count"));
+		this.setAdvancedCreativeFormClick(metrics.getInteger("advanced_creative_form_click"));
+		this.setCost(metrics.getBigDecimal("cost"));
+		this.setPhoneConnect(metrics.getInteger("phone_connect"));
+		this.setCoupon(metrics.getInteger("coupon"));
+		this.setDownloadStartRate(metrics.getBigDecimal("download_start_rate"));
+		this.setDownloadFinish(metrics.getInteger("download_finish"));
+		this.setWechat(metrics.getInteger("wechat"));
+		this.setCouponSinglePage(metrics.getInteger("coupon_single_page"));
+		this.setInstallFinish(metrics.getInteger("install_finish"));
+		this.setLottery(metrics.getInteger("lottery"));
+		this.setPlayOver(metrics.getInteger("play_over"));
+		this.setInAppOrder(metrics.getInteger("in_app_order"));
+		this.setDownloadStartCost(metrics.getBigDecimal("download_start_cost"));
+		this.setFollow(metrics.getInteger("follow"));
+		this.setMessage(metrics.getInteger("message"));
+		this.setInAppDetailUv(metrics.getInteger("in_app_detail_uv"));
+		this.setPlayDuration(metrics.getInteger("play_duration"));
+		this.setForm(metrics.getInteger("form"));
+		this.setValidPlayRate(metrics.getBigDecimal("valid_play_rate"));
+		this.setAveragePlayTimePerPlay(metrics.getBigDecimal("average_play_time_per_play"));
+		this.setConvertShowRate(metrics.getBigDecimal("convert_show_rate"));
+		this.setInstallFinishCost(metrics.getBigDecimal("install_finish_cost"));
+		this.setCommentMaterial(metrics.getInteger("comment"));
+		this.setInAppUv(metrics.getInteger("in_app_uv"));
+		this.setRegister(metrics.getInteger("register"));
+		this.setConvertCost(metrics.getBigDecimal("convert_cost"));
+	}
 }

+ 4 - 12
module-report/src/main/java/cn/com/ctop/bytedance/service/IReportService.java

@@ -10,27 +10,19 @@ 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);
+    void getAdvertiserCampaignReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl);
 
-    Map<String, Object> getCreativeReport(ByteDanceAdvertiserReportDTO conditions);
+    Map<String, Object> getCampaignReport(ByteDanceAdvertiserReportDTO conditions);
 
     Map<String, Object> getAgentReport(JSONObject conditions);
 
-    void insertCustomerInfo(String csvPath, String charset);
-
-    void insertPlatformInfo(String excelPath, String charset, Long accountId);
-
-    Map<String, Object> debitAuto(JSONObject data);
-
     void getAdvertiserReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl);
 
-    void getAdvertiserCampaignReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
-
     void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
 
     void getAdvertiserCreativeReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
 
+    void getMaterialReportByPage(CtopOauthToken token, String startDate, String endDate, Integer pageNum);
+
     void loadBytedanceHistoryData(CtopOauthToken token);
 }

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

@@ -1,39 +1,32 @@
 package cn.com.ctop.bytedance.service.impl;
 
 import cn.com.ctop.bytedance.entity.*;
+import cn.com.ctop.bytedance.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.bytedance.mapper.CustomerPlanStatisticInfoMapper;
 import cn.com.ctop.bytedance.mapper.PlatformCampaignStatisticInfoMapper;
 import cn.com.ctop.bytedance.service.*;
 import cn.com.ctop.bytedance.vo.ByteDanceAdvertiserReportDTO;
-import cn.com.ctop.bytedance.vo.StatisticCampaignVo;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
-import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.utils.PropertiesUtils;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.PropertyNamingStrategy;
 import com.alibaba.fastjson.serializer.SerializeConfig;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import lombok.var;
-import org.apache.poi.hssf.usermodel.HSSFDataFormat;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.xssf.usermodel.XSSFSheet;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
-import java.io.*;
-import java.math.BigDecimal;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author 宋英豪
@@ -41,14 +34,7 @@ import java.util.*;
 @Slf4j
 @Service
 public class ReportServiceImpl implements IReportService {
-    @Value("${jeecg.path.csv-upload}")
-    private String csvUploadPath;
-    @Autowired
-    private IPlatformCampaignStatisticInfoService platformCampaignStatisticInfoService;
-    @Autowired
-    private ICustomerPlanStatisticInfoService customerPlanStatisticInfoService;
-    @Autowired
-    private PlatformCampaignStatisticInfoMapper statisticInfoMapper;
+
     @Autowired
     private CustomerPlanStatisticInfoMapper customerPlanStatisticInfoMapper;
     @Autowired
@@ -266,47 +252,73 @@ 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);
+    public void getAdvertiserCreativeReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
+        var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
+        getCreativeReportByPage(token, conditions, 1);
+    }
+
+
+    public JSONObject getMaterialReport(CtopOauthToken token, String startDate, String endDate, Integer pageNum) {
+        // 请求地址
+        String url = "https://ad.oceanengine.com/open_api/2/report/integrated/get/";
+        // 请求参数
+        JSONObject params = new JSONObject();
+        params.put("advertiser_id", token.getAccountId());
+        params.put("start_date", startDate);
+        params.put("end_date", endDate);
+        params.put("page", pageNum);
+        params.put("page_size", 100);
+        JSONArray groupBy = new JSONArray();
+        groupBy.add("STAT_GROUP_BY_MATERIAL_ID");
+        groupBy.add("STAT_GROUP_BY_TIME_DAY");
+        groupBy.add("STAT_GROUP_BY_INVENTORY");
+        groupBy.add("STAT_GROUP_BY_IMAGE_MODE");
+        params.put("group_by", groupBy);
+        return HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, params);
+    }
+
+    @Autowired
+    private IBytedanceReportMaterialRetryService retryService;
+
+    @Override
+    public void getMaterialReportByPage(CtopOauthToken token, String startDate, String endDate, Integer pageNum) {
+        JSONObject getObject = getMaterialReport(token, startDate, endDate, pageNum);
+        if (null == getObject) {
+            BytedanceReportMaterialRetry reportMaterialRetry = new BytedanceReportMaterialRetry();
+            reportMaterialRetry.setAccountId(token.getAccountId());
+            reportMaterialRetry.setStartDate(startDate);
+            reportMaterialRetry.setStartDate(endDate);
+            reportMaterialRetry.setStatus(0);
+            retryService.save(reportMaterialRetry);
+            log.error("素材报表请求数据null=>accountId:{};startDate:{};endDate:{}", token.getAccountId(), startDate, endDate);
+            return;
+        }
         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);
-                    }
-                }
-            }
+            log.error("素材报表数据获取异常:{}", message);
+            return;
+        }
+        System.out.println(getObject.toJSONString());
+        JSONArray dataArray = getObject.getJSONObject("data").getJSONArray("list");
+        if (null == dataArray || dataArray.size() <= 0) {
+            return;
+        }
+        List<BytedanceReportMaterialDaily> dailyReports = new ArrayList<>();
+        for (var i = 0; i < dataArray.size(); i++) {
+            var data = dataArray.getJSONObject(i);
+            var dailyReport = new BytedanceReportMaterialDaily(data, token.getAccountId());
+            dailyReports.add(dailyReport);
+        }
+        materialDailyMapper.replaceIntoBatch(dailyReports);
+        Integer totalNum = getObject.getJSONObject("data").getJSONObject("page_info").getInteger("total_page");
+        if (null != totalNum && totalNum > pageNum) {
+            getMaterialReportByPage(token, startDate, endDate, pageNum + 1);
         }
-        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);
     }
 
+    @Autowired
+    private BytedanceReportMaterialDailyMapper materialDailyMapper;
     @Override
     public void loadBytedanceHistoryData(CtopOauthToken token) {
         for (int i = 1; i < 180; i++) {
@@ -373,42 +385,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 + "");
@@ -416,437 +392,6 @@ public class ReportServiceImpl implements IReportService {
         return getObject;
     }
 
-    @Override
-    public void insertCustomerInfo(String csvPath, String charset) {
-        try {
-            List<String[]> data = CsvUtils.readCsv(csvPath, charset);
-            if (null != data && data.size() > 1) {
-                for (int i = 1; i < data.size(); i++) {
-                    String[] record = data.get(i);
-                    CustomerPlanStatisticInfo statisticInfo = new CustomerPlanStatisticInfo(record);
-                    customerPlanStatisticInfoMapper.insert(statisticInfo);
-                }
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public void insertPlatformInfo(String csvPath, String charset, Long accountId) {
-        try {
-            List<String[]> data = CsvUtils.readCsv(csvPath, charset);
-            if (null != data && data.size() > 1) {
-                for (int i = 1; i < data.size(); i++) {
-                    String[] record = data.get(i);
-                    PlatformCampaignStatisticInfo statisticInfo = new PlatformCampaignStatisticInfo(record, accountId);
-                    platformCampaignStatisticInfoMapper.insert(statisticInfo);
-                }
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    @Override
-    public Map<String, Object> debitAuto(JSONObject data) {
-        Map<String, Object> resultMap = new HashMap<>();
-        String accountOneKsDataUrl = data.getString("accountOneKsDataUrl");
-        String accountFourKsDataUrl = data.getString("accountFourKsDataUrl");
-        String debitDataUrl = data.getString("debitDataUrl");
-        //1:文件下载入库
-        String accountOneKsDataPath = downLoadByUrl(accountOneKsDataUrl);
-        String accountFourKsDataPath = downLoadByUrl(accountFourKsDataUrl);
-        String debitDataPath = downLoadByUrl(debitDataUrl);
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/M/dd");
-        //2:文件入库
-        //2.1 清除数据库原始数据
-        QueryWrapper<CustomerPlanStatisticInfo> planWrapper = new QueryWrapper<>();
-        planWrapper.isNotNull("id");
-        customerPlanStatisticInfoService.remove(planWrapper);
-
-        QueryWrapper<PlatformCampaignStatisticInfo> campaignWrapper = new QueryWrapper<>();
-        campaignWrapper.isNotNull("id");
-        platformCampaignStatisticInfoService.remove(campaignWrapper);
-
-        this.insertPlatformInfo(accountOneKsDataPath, "gb2312", 1L);
-        QueryWrapper<PlatformCampaignStatisticInfo> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("campaign_code", "biaodan").orderByDesc("id").last("limit 1");
-        PlatformCampaignStatisticInfo statisticInfo = platformCampaignStatisticInfoMapper.selectOne(queryWrapper);
-        if (null != statisticInfo) {
-            PlatformCampaignStatisticInfo updateInfo = new PlatformCampaignStatisticInfo();
-            updateInfo.setCampaignCode("biaodan2");
-            QueryWrapper<PlatformCampaignStatisticInfo> updateWrapper = new QueryWrapper<>();
-            updateWrapper.ne("campaign_info", statisticInfo.getCampaignInfo()).eq("campaign_code", statisticInfo.getCampaignCode());
-            platformCampaignStatisticInfoMapper.update(updateInfo, updateWrapper);
-        }
-        this.insertPlatformInfo(accountFourKsDataPath, "gb2312", 4L);
-        this.insertCustomerInfo(debitDataPath, "utf8");
-        //3:根据模板生成相应的excel模板文件
-        try {
-            String platformReportPath = getExcelDataPath(simpleDateFormat.format(new Date()), 1L, 4L);
-//            //4:同步上传到oss文件服务器
-//            String ossPath = OSSUtils.uploadFile2Oss(new File(platformReportPath));
-//            //5: 返回文件服务器访问链接
-            ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
-            resultMap.put("path", platformReportPath);
-            return resultMap;
-        } catch (Exception e) {
-            e.printStackTrace();
-            ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SERVER_ERROR.getCode());
-            return resultMap;
-        }
-    }
-
-    public String getExcelDataPath(String date, Long accountId1, Long accountId4) throws Exception {
-        List<StatisticCampaignVo> statisticCampaign1Vos = statisticInfoMapper.getVoByParams(accountId1);
-        List<StatisticCampaignVo> statisticCampaign4Vos = statisticInfoMapper.getVoByParams(accountId4);
-        File f = new File(csvUploadPath + "template.xlsx");
-        InputStream inputStream = new FileInputStream(f);
-        XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
-//        //获取第一个sheet
-        XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0);
-        CellStyle numbericCellStyle = xssfWorkbook.createCellStyle();
-        numbericCellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("0.00"));
-        int index;
-        for (index = 1; index < statisticCampaign1Vos.size() + 1; index++) {
-            StatisticCampaignVo vo = statisticCampaign1Vos.get(index - 1);
-            String content = vo.getContent();
-            String[] contents = content.split("-");
-            Row row = xssfSheet.getRow(index);
-            setExcelRow(numbericCellStyle, vo, contents, row, "single");
-        }
-        List<StatisticCampaignVo> zero1Vos = statisticInfoMapper.sumZeroVoByParams(accountId1);
-        List<StatisticCampaignVo> zaodianVos = statisticInfoMapper.sumZaodianVoByParams(accountId1);
-        if (null != zero1Vos && zero1Vos.size() > 0) {
-            for (int z = 0; z < zero1Vos.size(); z++) {
-                StatisticCampaignVo vo = zero1Vos.get(z);
-                Row row = xssfSheet.getRow(index);
-                String content = vo.getContent();
-                String[] contents = content.split("-");
-                setExcelRow(numbericCellStyle, vo, contents, row, "single");
-                index++;
-            }
-        }
-        if (null != zaodianVos && zaodianVos.size() > 0) {
-            for (int z = 0; z < zaodianVos.size(); z++) {
-                StatisticCampaignVo vo = zaodianVos.get(z);
-                Row row = xssfSheet.getRow(index);
-                String content = vo.getContent();
-                String[] contents = content.split("-");
-                setExcelRow(numbericCellStyle, vo, contents, row, "single");
-                index++;
-            }
-        }
-        Row totalRow1 = xssfSheet.getRow(index);
-        StatisticCampaignVo total = statisticInfoMapper.getTotalStatisticVoByparams(accountId1);
-        if (null != total) {
-            setExcelRow(numbericCellStyle, total, new String[]{}, totalRow1, "total1");
-        }
-        index++;
-        for (int j = 0; j < statisticCampaign4Vos.size(); j++) {
-            index++;
-            StatisticCampaignVo vo = statisticCampaign4Vos.get(j);
-            String content = vo.getContent();
-            String[] contents = content.split("-");
-            Row row = xssfSheet.getRow(index);
-            setExcelRow(numbericCellStyle, vo, contents, row, "single");
-        }
-        List<StatisticCampaignVo> zero4Vos = statisticInfoMapper.sumZeroVoByParams(accountId4);
-        if (null != zero4Vos && zero4Vos.size() > 0) {
-            for (int z = 0; z < zero4Vos.size(); z++) {
-                index++;
-                StatisticCampaignVo vo = zero4Vos.get(z);
-                Row row = xssfSheet.getRow(index);
-                String content = vo.getContent();
-                String[] contents = content.split("-");
-                setExcelRow(numbericCellStyle, vo, contents, row, "single");
-            }
-        }
-        index++;
-        Row totalRow4 = xssfSheet.getRow(index);
-        StatisticCampaignVo total1 = statisticInfoMapper.getTotalStatisticVoByparams(accountId4);
-        if (null != total1) {
-            setExcelRow(numbericCellStyle, total1, new String[]{}, totalRow4, "total4");
-        }
-        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-m-dd");
-        String path = csvUploadPath + "report_" + dateFormat.format(new Date()) + ".xlsx";
-        FileOutputStream fileOutputStream = new FileOutputStream(path);
-        xssfWorkbook.write(fileOutputStream);
-        fileOutputStream.close();
-        return path;
-
-    }
-
-    private void setExcelRow(CellStyle numbericCellStyle, StatisticCampaignVo vo, String[] contents, Row row, String type) {
-        for (int j = 0; j < 38; j++) {
-            Cell cell = row.createCell(j);
-            if (j == 0) {
-                //日期
-                if (null != type && "single".equals(type)) {
-                    cell.setCellValue(vo.getStatisticDate());
-                } else if (null != type && "total1".equals(type)) {
-                    cell.setCellValue("户一总计");
-                } else {
-                    cell.setCellValue("户四总计");
-                }
-            } else if (j == 1) {
-                //代理
-                cell.setCellValue(vo.getProxy());
-            } else if (j == 2) {
-                //投放系统
-                if (null != contents && contents.length > 3) {
-                    cell.setCellValue(contents[2]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 3) {
-                //渠道号
-                if (null != contents && contents.length > 2) {
-                    cell.setCellValue(contents[1]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 4) {
-                //content
-                if (null != contents && contents.length > 0) {
-                    cell.setCellValue(contents[0]);
-                } else {
-                    cell.setCellValue("");
-                }
-//                cell.setCellValue(vo.getContent());
-            } else if (j == 5) {
-                if (null != contents && contents.length > 5) {
-                    cell.setCellValue(contents[4]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 6) {
-                //出价方式
-                if (null != contents && contents.length > 6) {
-                    cell.setCellValue(contents[5]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 7) {
-                //定向条件
-                if (null != contents && contents.length > 4) {
-                    cell.setCellValue(contents[3]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 8) {
-                //定向条件
-                if (null != contents && contents.length > 7) {
-                    cell.setCellValue(contents[6]);
-                } else {
-                    cell.setCellValue("");
-                }
-            } else if (j == 9) {
-                //花费
-                if (null != vo.getCost() && !"".equals(vo.getCost())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCost()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 10) {
-                //封面曝光数
-                if (null != vo.getCoverViews() && !"".equals(vo.getCoverViews())) {
-                    cell.setCellValue(Integer.parseInt(vo.getCoverViews()));
-                }
-            } else if (j == 11) {
-                //封面点击数
-                if (null != vo.getCoverClick() && !"".equals(vo.getCoverClick())) {
-                    cell.setCellValue(Integer.parseInt(vo.getCoverClick()));
-                }
-            } else if (j == 12) {
-                //素材曝光数
-                if (null != vo.getMaterialViews() && !"".equals(vo.getMaterialViews())) {
-                    cell.setCellValue(Integer.parseInt(vo.getMaterialViews()));
-                }
-            } else if (j == 13) {
-                //行为数
-                if (null != vo.getActions() && !"".equals(vo.getActions())) {
-                    cell.setCellValue(Integer.parseInt(vo.getActions()));
-                }
-            } else if (j == 14) {
-                //点击率
-                if (null != vo.getClickRate() && !"".equals(vo.getClickRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getClickRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 15) {
-                //行为点击率
-                if (null != vo.getActionClickRate() && !"".equals(vo.getActionClickRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getActionClickRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 16) {
-                //ACTR*BCTR
-                if (null != vo.getAbctr() && !"".equals(vo.getAbctr())) {
-                    cell.setCellValue(Float.parseFloat(vo.getAbctr()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 17) {
-                //点击成本
-                if (null != vo.getClickPrice() && !"".equals(vo.getClickPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getClickPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 18) {
-                //行为成本
-                if (null != vo.getActionPrice() && !"".equals(vo.getActionPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getActionPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 19) {
-                //注册用户
-                if (null != vo.getRegistUserNum() && !"".equals(vo.getRegistUserNum())) {
-                    BigDecimal decimal = new BigDecimal(vo.getRegistUserNum());
-                    cell.setCellValue(decimal.intValue());
-                }
-            } else if (j == 20) {
-                //完件用户
-                if (null != vo.getComplateUserNum() && !"".equals(vo.getComplateUserNum())) {
-                    BigDecimal decimal = new BigDecimal(vo.getComplateUserNum());
-                    cell.setCellValue(decimal.intValue());
-                }
-            } else if (j == 21) {
-                //授信用户
-                if (null != vo.getCreditUserNum() && !"".equals(vo.getCreditUserNum())) {
-                    BigDecimal decimal = new BigDecimal(vo.getCreditUserNum());
-                    cell.setCellValue(decimal.intValue());
-                }
-            } else if (j == 22) {
-                //当日注册且完件数
-                if (null != vo.getRegistCompleteNum() && !"".equals(vo.getRegistCompleteNum())) {
-                    BigDecimal decimal = new BigDecimal(vo.getRegistCompleteNum());
-                    cell.setCellValue(decimal.intValue());
-                }
-            } else if (j == 23) {
-                //当日注册且授信数
-                if (null != vo.getRegistCreditNum() && !"".equals(vo.getRegistCreditNum())) {
-                    BigDecimal decimal = new BigDecimal(vo.getRegistCreditNum());
-                    cell.setCellValue(decimal.intValue());
-                }
-            } else if (j == 24) {
-                //注册成本
-                if (null != vo.getRegistPrice() && !"".equals(vo.getRegistPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 25) {
-                //完件成本
-                if (null != vo.getCompletePrice() && !"".equals(vo.getCompletePrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCompletePrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 26) {
-                //授信成本
-                if (null != vo.getCreditPrice() && !"".equals(vo.getCreditPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCreditPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 27) {
-                //当日注册且完件成本
-                if (null != vo.getRegistCompletePrice() && !"".equals(vo.getRegistCompletePrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistCompletePrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 28) {
-                //当日注册且授信成本
-                if (null != vo.getRegistCreditPrice() && !"".equals(vo.getRegistCreditPrice())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistCreditPrice()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 29) {
-                //点击注册率
-                if (null != vo.getClickRegistRate() && !"".equals(vo.getClickRegistRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getClickRegistRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 30) {
-                //行为注册率
-                if (null != vo.getActionRegistRate() && !"".equals(vo.getActionRegistRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getActionRegistRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 31) {
-                //完件率
-                if (null != vo.getCompleteRate() && !"".equals(vo.getCompleteRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCompleteRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 32) {
-                //授信率
-                if (null != vo.getCreditRate() && !"".equals(vo.getCreditRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCreditRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 33) {
-                //当日完件率
-                if (null != vo.getRegistCompleteRate() && !"".equals(vo.getRegistCompleteRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistCompleteRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 34) {
-                //当日授信率
-                if (null != vo.getRegistCreditRate() && !"".equals(vo.getRegistCreditRate())) {
-                    cell.setCellValue(Float.parseFloat(vo.getRegistCreditRate()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 35) {
-                //当日完件/完件
-                if (null != vo.getCompleteRateDay() && !"".equals(vo.getCompleteRateDay())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCompleteRateDay()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 36) {
-                //当日授信/授信
-                if (null != vo.getCreditRateDay() && !"".equals(vo.getCreditRateDay())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCreditRateDay()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            } else if (j == 37) {
-                //当日授信/注册
-                if (null != vo.getCreditRegistRateDay() && !"".equals(vo.getCreditRegistRateDay())) {
-                    cell.setCellValue(Float.parseFloat(vo.getCreditRegistRateDay()));
-                    cell.setCellStyle(numbericCellStyle);
-                }
-            }
-        }
-    }
-
-    public String downLoadByUrl(String fileUrl) {
-        //获取文件名,文件名实际上在URL中可以找到
-        String fileName = fileUrl.substring(fileUrl.lastIndexOf("/") + 1);
-        //这里服务器上要将此图保存的路径
-        String savePath = this.csvUploadPath + fileName;
-        try {
-            //将网络资源地址传给,即赋值给url
-            URL url = new URL("https:" + fileUrl);
-            //此为联系获得网络资源的固定格式用法,以便后面的in变量获得url截取网络资源的输入流
-            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
-            DataInputStream in = new DataInputStream(connection.getInputStream());
-            //此处也可用BufferedInputStream与BufferedOutputStream
-            DataOutputStream out = new DataOutputStream(new FileOutputStream(savePath));
-            //将参数savePath,即将截取的图片的存储在本地地址赋值给out输出流所指定的地址
-            byte[] buffer = new byte[4096];
-            int count = 0;
-            //将输入流以字节的形式读取并写入buffer中
-            while ((count = in.read(buffer)) > 0) {
-                out.write(buffer, 0, count);
-            }
-            out.close();
-            in.close();
-            connection.disconnect();
-            //返回内容是保存后的完整的URL
-            return savePath;
-
-        } catch (Exception e) {
-            return null;
-        }
-    }
-
     /**
      * 获取广告创意报表信息
      *