Browse Source

Merge branch 'test'

syh 4 năm trước cách đây
mục cha
commit
a2e35da054
53 tập tin đã thay đổi với 2819 bổ sung202 xóa
  1. 7 11
      jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/ActivitiProcessController.java
  2. 115 8
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MediaReportCtrl.java
  3. 321 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProductController.java
  4. 8 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/MediaReportMapper.java
  5. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialTopMapper.xml
  6. 234 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MediaReportMapper.xml
  7. 9 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IMediaReportService.java
  8. 78 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/MediaReportServiceImpl.java
  9. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/MaterialTopVO.java
  10. 0 5
      jeecg-boot-module-system/src/main/resources/application-test.yml
  11. 6 6
      module-check/src/main/java/cn/com/ctop/check/component/execute/GroovyScriptExecutor.java
  12. 16 0
      module-check/src/main/java/cn/com/ctop/notice/handler/SendWeChatHandle.java
  13. 126 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/Advertiser.java
  14. 44 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/Product.java
  15. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopOauthTokenMapper.java
  16. 47 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/ProductMapper.java
  17. 9 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  18. 222 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProductMapper.xml
  19. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  20. 45 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IProductService.java
  21. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  22. 148 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/ProductServiceImpl.java
  23. 120 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java
  24. 25 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/ProductDto.java
  25. 28 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/ProductInfoDto.java
  26. 52 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/ProductVO.java
  27. 16 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/ProjectVO.java
  28. 18 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/SaleVO.java
  29. 69 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceDailyPlayableReportJob.java
  30. 68 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceDailyPlayableReportRetryJob.java
  31. 4 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceOperationRecordJob.java
  32. 1 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/CheckDataStateJob.java
  33. 1 1
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/CheckExecuteStateJob.java
  34. 123 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouNewAccountOperationRecordJob.java
  35. 9 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/ByteDanceBatchController.java
  36. 1 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/BytedanceImageInfo.java
  37. 2 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/ByteDanceVideoInfoMapper.java
  38. 4 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/BytedanceImageInfoMapper.java
  39. 12 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/ByteDanceVideoInfoMapper.xml
  40. 14 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/BytedanceImageInfoMapper.xml
  41. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceVideoInfoService.java
  42. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceImageInfoService.java
  43. 2 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  44. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java
  45. 3 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceVideoInfoServiceImpl.java
  46. 8 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceImageInfoServiceImpl.java
  47. 108 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceInterfaceController.java
  48. 175 99
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceReportPlayableDaily.java
  49. 62 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceReportPlayableRetry.java
  50. 26 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportPlayableDailyMapper.java
  51. 298 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportPlayableMapper.xml
  52. 7 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceInterfaceService.java
  53. 109 55
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceInterfaceServiceImpl.java

+ 7 - 11
jeecg-boot-module-activiti/src/main/java/org/jeecg/modules/activiti/web/ActivitiProcessController.java

@@ -27,16 +27,16 @@ import org.jeecg.modules.activiti.service.Impl.ActNodeServiceImpl;
 import org.jeecg.modules.activiti.service.Impl.ActZprocessServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.net.URLEncoder;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -130,7 +130,9 @@ public class ActivitiProcessController {
             }
             ActZprocess actProcess = actZprocessService.getById(id);
             // 当删除最后一个版本时 删除关联数据
-            if (actProcess==null) return Result.error("该数据已删除!");
+            if (actProcess==null){
+                return Result.error("该数据已删除!");
+            }
             if(actProcess.getVersion()==1){
                 deleteNodeUsers(id);
             }
@@ -143,7 +145,6 @@ public class ActivitiProcessController {
         return Result.ok("删除成功");
     }
     public void deleteNodeUsers(String processId){
-
         BpmnModel bpmnModel = repositoryService.getBpmnModel(processId);
         List<Process> processes = bpmnModel.getProcesses();
         for(Process process : processes){
@@ -160,11 +161,9 @@ public class ActivitiProcessController {
      */
     @RequestMapping(value = "/convertToModel")
     public Result convertToModel( String id){
-
         ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
         InputStream bpmnStream = repositoryService.getResourceAsStream(pd.getDeploymentId(), pd.getResourceName());
         ActZprocess actProcess = actZprocessService.getById(id);
-
         try {
             XMLInputFactory xif = XMLInputFactory.newInstance();
             InputStreamReader in = new InputStreamReader(bpmnStream, "UTF-8");
@@ -209,11 +208,8 @@ public class ActivitiProcessController {
     /*通过流程定义id获取流程节点*/
     @RequestMapping(value = "/getProcessNode")
     public Result getProcessNode(String id){
-
         BpmnModel bpmnModel = repositoryService.getBpmnModel(id);
-
         List<ProcessNodeVo> list = new ArrayList<>();
-
         List<Process> processes = bpmnModel.getProcesses();
         if(processes==null||processes.size()==0){
             return Result.ok();

+ 115 - 8
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MediaReportCtrl.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.entity.Product;
 import cn.com.ctop.common.module.entity.SysCompany;
 import cn.com.ctop.common.module.service.ISysCompanyService;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
@@ -7,8 +8,10 @@ import cn.com.ctop.common.module.utils.HttpUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.service.IMediaReportService;
  import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -18,6 +21,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -40,13 +44,13 @@ public class MediaReportCtrl {
         Result<List<SysCompany>> result=new Result<>();
         //TODO 没有维护渠道的信息暂时不能再库里加,会影响到绩效等其他接口查询公司的接口
         List<SysCompany> list=sysCompanyService.list();
-        SysCompany sysCompany = new SysCompany();
-        sysCompany.setId(4L);
-        sysCompany.setCompanyId("6weq589875c040119adst08751712368");
-        sysCompany.setCompanyCode("A04");
-        sysCompany.setCompanyName("渠道");
-        sysCompany.setArea("渠道");
-        list.add(sysCompany);
+        //SysCompany sysCompany = new SysCompany();
+        //sysCompany.setId(4L);
+        //sysCompany.setCompanyId("6weq589875c040119adst08751712368");
+        //sysCompany.setCompanyCode("A04");
+        //sysCompany.setCompanyName("渠道");
+        //sysCompany.setArea("渠道");
+        //list.add(sysCompany);
         result.setSuccess(true);
         result.setResult(list);
         return result;
@@ -69,10 +73,34 @@ public class MediaReportCtrl {
         return result;
     }
 
+    //获取所有产品
+    @ResponseBody
+    @RequestMapping(value = "/getAllProductList")
+    public Result<List<Product>> getAllProductList(@RequestBody JSONObject requestBody,
+                                                   HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/getAllProductList 方法开始");
+        Result<List<Product>> result = new Result();
+
+        try {
+            List<Product> allProductList = mediaReportService.getAllProductList(requestBody.getInteger("mediaType"), requestBody.getString("advertiserId"));
+            result.setResult(allProductList);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/getAllProductList 方法结束");
+        }
+
+        return result;
+    }
+
+
     @PostMapping("/{pageNo}/{pageSize}")
     public Result<PageInfo<JSONObject>> getReport(@PathVariable int pageNo,
                                                   @PathVariable int pageSize,
-                                                  @RequestBody JSONObject requestBody){ Result<PageInfo<JSONObject>> result = new Result<>();
+                                                  @RequestBody JSONObject requestBody){
+        Result<PageInfo<JSONObject>> result = new Result<>();
         if(requestBody.isEmpty()){
             log.error("requestBody is null");
             result.setSuccess(false);
@@ -139,4 +167,83 @@ public class MediaReportCtrl {
             log.error(e.getMessage());
         }
     }
+
+    @PostMapping("/mediaReport/{pageNum}/{pageSize}")
+    public Result<PageInfo<JSONObject>> mediaReport(@PathVariable int pageNum,
+                                                  @PathVariable int pageSize,
+                                                  @RequestBody JSONObject requestBody){
+        Result<PageInfo<JSONObject>> result = new Result<>();
+        if(StringUtils.isBlank(requestBody.getString("todayDate")) || requestBody.getInteger("mediaType") ==null){
+            result.setSuccess(false);
+            result.setMessage("参数有误");
+        }
+
+        if(requestBody.isEmpty()){
+            log.error("requestBody is null");
+            result.setSuccess(false);
+            return result;
+        }
+        PageInfo<JSONObject> pageInfo = mediaReportService.mediaReport(pageNum,pageSize,requestBody);
+
+        result.setResult(pageInfo);
+        result.setSuccess(true);
+        return result;
+    }
+
+    /**
+     *  导出数据
+     * @param requestBody
+     * @param request
+     * @param response
+     */
+    @PostMapping("/exportMediaReportExcel")
+    public void exportMediaReportExcel(@RequestBody JSONObject requestBody,
+                               HttpServletRequest request,
+                               HttpServletResponse response) {
+        String today = requestBody.getString("todayDate");
+        Date todayDate = DateUtils.parseDate(today, "yyyy-MM-dd");
+        Date yesterdayDate = DateUtils.addDay(todayDate, -1);
+        String yesterday = DateUtils.formatDate(yesterdayDate);
+
+        List<JSONObject> excelData = mediaReportService.exportMediaReportExcel(requestBody);
+
+        List<List<Object>> excelList= new ArrayList<>();
+        excelData.forEach(data->{
+            List<Object> temp= new ArrayList<>();
+            temp.add(data.get("mediaType")==null?"-":(data.getInteger("mediaType")==1?"头条":"快手"));
+            temp.add(data.get("advertiserName")==null?"-":data.get("advertiserName"));
+            temp.add(data.get("productName")==null?"-":data.get("productName"));
+            temp.add(data.get("operator")==null?"-":data.get("operator"));
+            temp.add(data.get("sale")==null?"-":data.get("sale"));
+            temp.add(data.get("todayCost"));
+            temp.add(data.get("yesterdayCost"));
+            temp.add(data.get("diffCost"));
+            temp.add(data.get("companyName"));
+            excelList.add(temp);
+        });
+        try{
+            String[] headers = {"媒体类型","广告主","产品","运营","销售",requestBody.getString("todayDate"),yesterday,"消耗差","区域"};
+            OutputStream os = response.getOutputStream();
+            ExportExcelUtils eeu = new ExportExcelUtils();
+            XSSFWorkbook workbook = new XSSFWorkbook();
+            eeu.exportExcelForMediaReport(workbook, 0, "媒介报表", headers, excelList);
+            HttpUtils.setResponseHeader(response, "媒介报表.xlsx");
+            workbook.write(os);
+            os.flush();
+            os.close();
+        }catch (IOException e){
+            log.error(e.getMessage());
+        }
+
+    }
+
+
+
+
+
+
+
+
+
+
 }

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

@@ -0,0 +1,321 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.common.module.entity.Advertiser;
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.service.IProductService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
+import cn.com.ctop.common.module.vo.ProductInfoDto;
+import cn.com.ctop.common.module.vo.ProductVO;
+import cn.com.ctop.common.module.vo.ProjectVO;
+import cn.com.ctop.manage.modules.actor.entity.Actor;
+import cn.com.ctop.manage.modules.actor.entity.ActorComment;
+import cn.com.ctop.manage.modules.actor.entity.ActorPhoto;
+import cn.com.ctop.manage.modules.actor.entity.ActorVideo;
+import cn.com.ctop.manage.modules.actor.service.IActorCommentService;
+import cn.com.ctop.manage.modules.actor.service.IActorPhotoService;
+import cn.com.ctop.manage.modules.actor.service.IActorService;
+import cn.com.ctop.manage.modules.actor.service.IActorVideoService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@Slf4j
+@RequestMapping("/ctop/product")
+public class ProductController {
+    @Autowired
+    private IProductService productService;
+
+    //获取广告主列表
+    @ResponseBody
+    @RequestMapping(value = "/advertiserList")
+    public Result<List<Advertiser>> advertiserList(HttpServletRequest request,HttpServletResponse response){
+        log.info("/ctop/product/advertiserList 方法开始");
+        Result<List<Advertiser>> result = new Result();
+
+        try {
+            List<Advertiser> advertiserList = productService.advertiserList();
+            result.setResult(advertiserList);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/advertiserList 方法结束");
+        }
+
+        return result;
+    }
+
+    //根据广告主id获取项目列表
+    @ResponseBody
+    @RequestMapping(value = "/getProjectListByAdvertiserId")
+    public Result<List<Project>> getProjectListByAdvertiserId(@RequestBody ProductInfoDto dto,
+            HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/getProjectListByAdvertiserId 方法开始");
+        Result<List<Project>> result = new Result();
+        if(dto == null || dto.getAdvertiserId() ==null ){
+            result.setSuccess(false);
+            result.setMessage("advertiserId不能为空");
+            return result;
+        }
+
+        try {
+            List<Project> projectList = productService.getProjectListByAdvertiserId(dto.getAdvertiserId());
+            result.setResult(projectList);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/getProjectListByAdvertiserId 方法结束");
+        }
+
+        return result;
+    }
+
+    //根据项目列表获取运营和销售的信息
+    @ResponseBody
+    @RequestMapping(value = "/getSaleAndYunyingListByProjectIds")
+    public Result<Map<String, Object>> getSaleAndYunyingListByProjectIds(@RequestBody ProductInfoDto dto,
+                                                              HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/getSaleAndYunyingListByProjectIds 方法开始");
+        Result<Map<String, Object>> result = new Result();
+        if(dto == null || dto.getProjectIds() ==null || dto.getProjectIds().size() ==0 ){
+            result.setSuccess(false);
+            result.setMessage("projectIds不能为空");
+            return result;
+        }
+
+        try {
+            Map<String, Object> map = productService.getSaleAndYunyingListByProjectIds(dto.getProjectIds());
+            result.setResult(map);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/getSaleAndYunyingListByProjectIds 方法结束");
+        }
+
+        return result;
+    }
+
+    //逻辑删除产品
+    @ResponseBody
+    @RequestMapping(value = "/deleteProduct")
+    public Result deleteProduct(@RequestBody ProductInfoDto dto,HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/deleteProduct 方法开始");
+        Result result = new Result();
+        if(dto == null || dto.getProductId() ==null ){
+            result.setSuccess(false);
+            result.setMessage("productId不能为空");
+            return result;
+        }
+
+        try {
+            productService.deleteProduct(dto.getProductId());
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/deleteProduct 方法结束");
+        }
+
+        return result;
+    }
+
+    //产品信息入库
+    @ResponseBody
+    @RequestMapping(value = "/insertOrUpdateProduct")
+    public Result insertOrUpdateProduct(@RequestBody ProductVO vo, HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/insertOrUpdateProduct 方法开始");
+        Result result = new Result();
+
+        try {
+            productService.insertOrUpdateProduct(vo);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/insertOrUpdateProduct 方法结束");
+        }
+
+        return result;
+    }
+
+    //编辑产品反显
+    @ResponseBody
+    @RequestMapping(value = "/getProductInfo")
+    public Result<Map<String, Object>> getProductInfo(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/getProductInfo 方法开始");
+        Result<Map<String, Object>> result = new Result();
+        if(dto==null || dto.getProductId() == null){
+            result.setSuccess(false);
+            result.setMessage("productId不能为空");
+            return result;
+        }
+
+        try {
+            Map<String, Object> productInfo = productService.getProductInfo(dto.getProductId());
+            result.setResult(productInfo);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/getProductInfo 方法结束");
+        }
+
+        return result;
+    }
+
+    //单独删除产品关联项目
+    @ResponseBody
+    @RequestMapping(value = "/deleteByProjectIdAndProductId")
+    public Result deleteByProjectIdAndProductId(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/deleteByProjectIdAndProductId 方法开始");
+        Result result = new Result();
+        if(dto==null || dto.getProductId() == null || dto.getProjectId() ==null){
+            result.setSuccess(false);
+            result.setMessage("productId,projectId不能为空");
+            return result;
+        }
+
+        try {
+            productService.deleteByProjectIdAndProductId(dto.getProjectId(), dto.getProductId());
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/deleteByProjectIdAndProductId 方法结束");
+        }
+
+        return result;
+    }
+
+    //编辑产品按钮反显
+    @ResponseBody
+    @RequestMapping(value = "/getProjectListByProductId")
+    public Result<List<ProjectVO>> getProjectListByProductId(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/getProjectListByProductId 方法开始");
+        Result<List<ProjectVO>> result = new Result();
+        if(dto==null || dto.getProductId() == null){
+            result.setSuccess(false);
+            result.setMessage("productId,projectId不能为空");
+            return result;
+        }
+
+        try {
+            List<ProjectVO> projectListByProductId = productService.getProjectListByProductId(dto.getProductId());
+            result.setResult(projectListByProductId);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/getProjectListByProductId 方法结束");
+        }
+
+        return result;
+    }
+
+    //产品列表
+    @ResponseBody
+    @RequestMapping(value = "/getProductList")
+    public Result<PageInfo<ProductVO>> getProductList(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/getProductList 方法开始");
+        Result<PageInfo<ProductVO>> result = new Result();
+        if(dto==null || dto.getPageNum() == 0 || dto.getPageSize() ==0){
+            dto.setPageNum(1);
+            dto.setPageSize(10);
+        }
+
+        try {
+            PageInfo<ProductVO> productList = productService.getProductList(dto.getAdvertiserName(), dto.getProductName(), dto.getPageNum(), dto.getPageSize());
+            result.setResult(productList);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/getProductList 方法结束");
+        }
+
+        return result;
+    }
+
+    //产品列表
+    @ResponseBody
+    @RequestMapping(value = "/insertProductProjectMap")
+    public Result insertProductProjectMap(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
+        log.info("/ctop/product/insertProductProjectMap 方法开始");
+        Result result = new Result();
+        if(dto==null || dto.getProductId() == null || dto.getProjectIds() == null){
+            result.setSuccess(false);
+            result.setMessage("productId,projectIds不能为空");
+            return result;
+        }
+
+        List<Long> dtoProjectIds = dto.getProjectIds();
+        List<Long> projectIdsHas = productService.getProjectIdsByProductId(dto.getProductId());
+        List<Long> addProjectIds = new ArrayList<>();
+
+        for(Long dtoProjectId:dtoProjectIds){
+            int filter = 0;
+            for(Long projectIdHas:projectIdsHas){
+                if(projectIdHas.equals(dtoProjectId)){
+                    filter = -1;
+                    break;
+                }
+            }
+            if(filter == 0){
+                addProjectIds.add(dtoProjectId);
+            }
+        }
+
+        if(addProjectIds==null || addProjectIds.size()==0){
+            return result;
+        }
+
+        try {
+            productService.insertProductProjectMap(dto.getProductId(), addProjectIds);
+        }catch (Exception e){
+            log.error(e.getMessage());
+            result.setSuccess(false);
+            result.setMessage("error");
+        }finally{
+            log.info("/ctop/product/insertProductProjectMap 方法结束");
+        }
+
+        return result;
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+}

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.mapper;
 
+import cn.com.ctop.common.module.entity.Product;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Param;
 
@@ -17,4 +18,11 @@ public interface MediaReportMapper {
 
     List<JSONObject> queryAgentReportBy(@Param("todayDate") String todayDate ,@Param("yesterdayDate") String yesterdayDate);
 
+    //快手媒介报表
+    List<JSONObject> kuaishouMediaReport(@Param("today") String today ,@Param("yesterday") String yesterday,@Param("advertiserId") String advertiserId, @Param("companyId")String companyId, @Param("productId")Long productId);
+    //头条媒介报表
+    List<JSONObject> toutiaoMediaReport(@Param("today") String today ,@Param("yesterday") String yesterday, @Param("advertiserId") String advertiserId, @Param("companyId")String companyId, @Param("productId")Long productId);
+
+    List<Product> getAllProductList(@Param("mediaType")Integer mediaType, @Param("advertiserId")String advertiserId);
+
 }

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

@@ -3,6 +3,7 @@
 <mapper namespace="org.jeecg.modules.ctop.mapper.MaterialTopMapper">
     <select id="selectMapsPage" resultType="org.jeecg.modules.ctop.vo.MaterialTopVO">
         SELECT
+            code,
             url,
             cover_url,
             name,

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

@@ -264,4 +264,238 @@
                           GROUP by advertiserName, projectName) as r) as e
         ORDER BY sumCost desc
     </select>
+
+    <!-- 快手 -->
+    <select id="kuaishouMediaReport" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        mediaType,
+        advertiserName,
+        productName,
+        sale,
+        operator,
+        format(todayCost,3) as todayCost,
+        format(yesterdayCost,3) as yesterdayCost,
+        format(( todayCost - yesterdayCost ),3) AS diffCost,
+        companyName
+        FROM
+                (
+                    SELECT
+                    a.media_id AS mediaType,
+                    a.advertiser_name AS advertiserName,
+                    a.product_name AS productName,
+                    (
+                        SELECT
+                            GROUP_CONCAT( DISTINCT o.realname )
+                        FROM
+                            ctop_product_project_map m
+                            LEFT JOIN ctop_project n ON m.project_id = n.id
+                            LEFT JOIN sys_user o ON n.sale_id = o.id
+                        WHERE
+                            m.product_id = a.id
+                    ) AS sale,
+                    (
+                        SELECT
+                            GROUP_CONCAT( DISTINCT al.user_name )
+                        FROM
+                            ( SELECT * FROM ctop_user_allocation GROUP BY account_id ) al
+                            LEFT JOIN user_company co ON al.user_id = co.user_id
+                        WHERE
+                            al.project_id IN ( SELECT project_id FROM ctop_product_project_map map WHERE map.product_id = a.id )
+                            AND co.company_id = d.company_id
+                    ) AS operator,
+                    IFNULL(
+                            (
+                                SELECT
+                                    sum( charge )
+                                FROM
+                                    ctop_kuaishou_report_daily_account report
+                                WHERE
+                                    report.account_id IN (
+                                SELECT
+                                    account_id
+                                FROM
+                                    ( SELECT * FROM ctop_user_allocation GROUP BY account_id ) al
+                                    LEFT JOIN user_company co ON al.user_id = co.user_id
+                                WHERE
+                                    al.project_id IN ( SELECT project_id FROM ctop_product_project_map map WHERE map.product_id = a.id )
+                                    AND co.company_id = d.company_id
+                                    )
+                                    AND report.stat_date = #{today}
+                            )
+                    ,0) AS todayCost,
+                    IFNULL(
+                            (
+                                SELECT
+                                    sum( charge )
+                                FROM
+                                    ctop_kuaishou_report_daily_account report
+                                WHERE
+                                    report.account_id IN (
+                                SELECT
+                                    account_id
+                                FROM
+                                    ctop_user_allocation al
+                                    LEFT JOIN user_company co ON al.user_id = co.user_id
+                                WHERE
+                                    al.project_id IN ( SELECT project_id FROM ctop_product_project_map map WHERE map.product_id = a.id )
+                                    AND co.company_id = d.company_id
+                                    )
+                                    AND report.stat_date = #{yesterday}
+                             )
+                        ,0) AS yesterdayCost,
+                        case
+                            when d.company_id = 'd57fecdcf7a94d009736d9c850731582' then '华北'
+                            when d.company_id = '6608ed13c0dd42de93c790dbdf124234' then '华南'
+                            when d.company_id = '4b10089775c040119e139087517aed88' then '华东'
+                            else '-' end AS companyName
+                    FROM
+                        ctop_product a
+                        LEFT JOIN ctop_product_project_map b ON a.id = b.product_id
+                        LEFT JOIN ( SELECT * FROM ctop_user_allocation GROUP BY account_id ) c ON b.project_id = c.project_id
+                        LEFT JOIN user_company d ON c.user_id = d.user_id
+                    WHERE
+                        d.company_id IS NOT NULL
+                        AND a.product_status = 1
+                        AND a.media_id = 2
+                        <if test="advertiserId != null and advertiserId != ''">
+                        AND a.advertiser_id = #{advertiserId}
+                        </if>
+                        <if test="companyId != null and companyId != ''">
+                            AND d.company_id = #{companyId}
+                        </if>
+                        <if test="productId != null and productId != ''">
+                            AND a.id = #{productId}
+                        </if>
+                    GROUP BY
+                        a.id,
+                        d.company_id
+                ) t
+        ORDER BY
+        t.companyName,t.todayCost DESC
+    </select>
+
+    <select id="toutiaoMediaReport" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        mediaType,
+        advertiserName,
+        productName,
+        sale,
+        operator,
+        format(todayCost,2) as todayCost,
+        format(yesterdayCost,2) as yesterdayCost,
+        format(( todayCost - yesterdayCost ),2) AS diffCost,
+        companyName
+        FROM
+            (
+                SELECT
+                    a.media_id AS mediaType,
+                    a.advertiser_name AS advertiserName,
+                    a.product_name AS productName,
+                    (
+                SELECT
+                    GROUP_CONCAT( DISTINCT o.realname )
+                FROM
+                    ctop_product_project_map m
+                    LEFT JOIN ctop_project n ON m.project_id = n.id
+                    LEFT JOIN sys_user o ON n.sale_id = o.id
+                WHERE
+                    m.product_id = a.id
+                    ) AS sale,
+                    (
+                SELECT
+                    GROUP_CONCAT( DISTINCT al.user_name )
+                FROM
+                    ctop_user_allocation al
+                    LEFT JOIN user_company co ON al.user_id = co.user_id
+                WHERE
+                    al.project_id IN ( SELECT project_id FROM ctop_product_project_map map WHERE map.product_id = a.id )
+                    AND co.company_id = d.company_id
+                    ) AS operator,
+                    IFNULL(
+                    (
+                SELECT
+                    sum( cost )
+                FROM
+                    ctop_bytedance_report_advertiser_daily report
+                WHERE
+                    report.advertiser_id IN (
+                SELECT
+                    account_id
+                FROM
+                    ctop_user_allocation al
+                    LEFT JOIN user_company co ON al.user_id = co.user_id
+                WHERE
+                    al.project_id IN ( SELECT project_id FROM ctop_product_project_map map WHERE map.product_id = a.id )
+                    AND co.company_id = d.company_id
+                    )
+                    AND date_format( report.stat_datetime, '%Y-%m-%d' ) = #{today}
+                    ),
+                    0
+                    ) AS todayCost,
+                    IFNULL(
+                            (
+                        SELECT
+                            sum( cost )
+                        FROM
+                            ctop_bytedance_report_advertiser_daily report
+                        WHERE
+                            report.advertiser_id IN (
+                                SELECT
+                                    account_id
+                                FROM
+                                    ctop_user_allocation al
+                                    LEFT JOIN user_company co ON al.user_id = co.user_id
+                                WHERE
+                                    al.project_id IN ( SELECT project_id FROM ctop_product_project_map map WHERE map.product_id = a.id )
+                                    AND co.company_id = d.company_id
+                            )
+                            AND date_format( report.stat_datetime, '%Y-%m-%d' ) = #{yesterday}
+                            ),0) AS yesterdayCost,
+                    case when d.company_id = 'd57fecdcf7a94d009736d9c850731582' then '华北'
+                         when d.company_id = '6608ed13c0dd42de93c790dbdf124234' then '华南'
+                         when d.company_id = '4b10089775c040119e139087517aed88' then '华东'
+                         else '-' end AS companyName
+                FROM
+                    ctop_product a
+                    LEFT JOIN ctop_product_project_map b ON a.id = b.product_id
+                    LEFT JOIN ( SELECT * FROM ctop_user_allocation GROUP BY account_id ) c ON b.project_id = c.project_id
+                    LEFT JOIN user_company d ON c.user_id = d.user_id
+                WHERE
+                    d.company_id IS NOT NULL
+                    AND a.media_id = 1
+                    AND a.product_status = 1
+                    <if test="advertiserId != null and advertiserId != ''">
+                        AND a.advertiser_id = #{advertiserId}
+                    </if>
+                    <if test="companyId != null and companyId != ''">
+                        AND a.company_id = #{companyId}
+                    </if>
+                    <if test="productId != null and productId != ''">
+                        AND a.id = #{productId}
+                    </if>
+                GROUP BY
+                    a.id,
+                    d.company_id
+            ) t
+        ORDER BY t.companyName, t.todayCost DESC
+
+    </select>
+
+    <select id="getAllProductList" resultType="cn.com.ctop.common.module.entity.Product">
+        select
+        id as id,
+        product_name as productName,
+        media_id as mediaId
+        from
+        ctop_product
+        where
+        product_status = 1
+        <if test="mediaType != null">
+            and media_id = #{mediaType}
+        </if>
+        <if test="advertiserId != null">
+            and advertiser_id = #{advertiserId}
+        </if>
+    </select>
+
 </mapper>

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.service;
 
+import cn.com.ctop.common.module.entity.Product;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
 
@@ -11,6 +12,8 @@ public interface IMediaReportService {
 
     List<JSONObject> queryProjectNameByAdvertiserId(String advertiserId);
 
+    List<Product> getAllProductList(Integer mediaType, String advertiserId);
+
     PageInfo<JSONObject> queryReportByCondition(int pageNo,int pageSize,JSONObject requestBody);
 
     PageInfo<JSONObject> queryAllReportByCondition(int pageNo,int pageSize,JSONObject requestBody);
@@ -19,5 +22,11 @@ public interface IMediaReportService {
 
     List<JSONObject> queryReportByCondition(JSONObject requestBody);
 
+    PageInfo<JSONObject> mediaReport(int pageNum, int pageSize, JSONObject requestBody);
+
+    //PageInfo<JSONObject> toutiaoMediaReport(int pageNum, int pageSize, JSONObject requestBody);
+
+    List<JSONObject> exportMediaReportExcel(JSONObject requestBody);
+
 
 }

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

@@ -1,13 +1,16 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.common.module.entity.Product;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.ctop.mapper.MediaReportMapper;
 import org.jeecg.modules.ctop.service.IMediaReportService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -27,6 +30,12 @@ public class MediaReportServiceImpl implements IMediaReportService {
     }
 
     @Override
+    public List<Product> getAllProductList(Integer mediaType, String advertiserId){
+        return mediaReportMapper.getAllProductList(mediaType, advertiserId);
+    }
+
+
+    @Override
     public PageInfo<JSONObject> queryReportByCondition(int pageNO, int pageSize, JSONObject requestBody) {
         PageInfo<JSONObject> pageInfo;
         if(requestBody.getString("companyId").equals("6weq589875c040119adst08751712368")){
@@ -114,4 +123,73 @@ public class MediaReportServiceImpl implements IMediaReportService {
         }
         return result;
     }
+
+
+    //@Override
+    //public PageInfo<JSONObject> toutiaoMediaReport(int pageNum, int pageSize, JSONObject requestBody) {
+    //    String today = requestBody.getString("todayDate");
+    //    Date todayDate = DateUtils.parseDate(today, "yyyy-MM-dd");
+    //    Date yesterdayDate = DateUtils.addDay(todayDate, -1);
+    //    String yesterday = DateUtils.formatDate(yesterdayDate);
+    //
+    //    String advertiserId = requestBody.getString("advertiserId");
+    //    String companyId = requestBody.getString("companyId");
+    //
+    //    PageHelper.startPage(pageNum, pageSize);
+    //    List<JSONObject> jsonObjectList = mediaReportMapper.toutiaoMediaReport(today, yesterday, advertiserId, companyId);
+    //
+    //    return new PageInfo<JSONObject>(jsonObjectList);
+    //}
+
+
+    @Override
+    public PageInfo<JSONObject> mediaReport(int pageNum, int pageSize, JSONObject requestBody) {
+        String today = requestBody.getString("todayDate");
+        Date todayDate = DateUtils.parseDate(today, "yyyy-MM-dd");
+        Date yesterdayDate = DateUtils.addDay(todayDate, -1);
+        String yesterday = DateUtils.formatDate(yesterdayDate);
+
+        String advertiserId = requestBody.getString("advertiserId");
+        String companyId = requestBody.getString("companyId");
+        Long productId = requestBody.getLong("productId");
+
+        Integer mediaType = requestBody.getInteger("mediaType");
+
+        List<JSONObject> jsonObjectList = null;
+        if(mediaType == 1){
+            PageHelper.startPage(pageNum, pageSize);
+            jsonObjectList = mediaReportMapper.toutiaoMediaReport(today, yesterday, advertiserId, companyId, productId);
+        }else if(mediaType == 2){
+            PageHelper.startPage(pageNum, pageSize);
+            jsonObjectList = mediaReportMapper.kuaishouMediaReport(today, yesterday, advertiserId, companyId, productId);
+        }
+
+        return new PageInfo<JSONObject>(jsonObjectList);
+    }
+
+    @Override
+    public List<JSONObject> exportMediaReportExcel(JSONObject requestBody) {
+        String today = requestBody.getString("todayDate");
+        Date todayDate = DateUtils.parseDate(today, "yyyy-MM-dd");
+        Date yesterdayDate = DateUtils.addDay(todayDate, -1);
+        String yesterday = DateUtils.formatDate(yesterdayDate);
+
+        String advertiserId = requestBody.getString("advertiserId");
+        String companyId = requestBody.getString("companyId");
+        Long productId = requestBody.getLong("productId");
+
+        Integer mediaType = requestBody.getInteger("mediaType");
+
+        if(mediaType == 2){
+            return mediaReportMapper.kuaishouMediaReport(today, yesterday, advertiserId, companyId, productId);
+        }else if(mediaType == 1){
+            return mediaReportMapper.toutiaoMediaReport(today, yesterday, advertiserId, companyId, productId);
+        }
+        return null;
+    }
+
+
+
+
+
 }

+ 1 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/vo/MaterialTopVO.java

@@ -6,6 +6,7 @@ import java.math.BigDecimal;
 
 @Data
 public class MaterialTopVO {
+    private String code;
     private String url;
     private String coverUrl;
     private String name ;

+ 0 - 5
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -91,11 +91,6 @@ spring:
         filters: stat,slf4j
         # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
-#      datasource:
-#        master:
-#          url: jdbc:mysql://139.186.27.96:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-#          username: hcst
-#          password: test@20190531
       datasource:
         master:
           url: jdbc:mysql://39.106.184.70/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false

+ 6 - 6
module-check/src/main/java/cn/com/ctop/check/component/execute/GroovyScriptExecutor.java

@@ -53,7 +53,7 @@ public class GroovyScriptExecutor {
         if(script.getIsDelete()||!script.getExeState()){
             return Result.error(String.format("groovy script is invalid. api_name=%s", script.getApiName()));
         }else {
-            return executescriptScript(script);
+            return executeScript(script);
         }
     }
 
@@ -62,11 +62,11 @@ public class GroovyScriptExecutor {
         if (script == null) {
             return Result.error(String.format("groovy script not found. api_name=%s", apiName));
         }else {
-            return executescriptScript(script);
+            return executeScript(script);
         }
     }
 
-    private Result<Object> executescriptScript(CtopCheckTaskList taskList){
+    private Result<Object> executeScript(CtopCheckTaskList taskList){
         ClearCache();
         GroovyCodeSource groovyCodeSource = getGroovyCodeSource(taskList);
         Result<Object> response = null;
@@ -81,9 +81,9 @@ public class GroovyScriptExecutor {
                 scriptInstance.setCtopCheckTaskList(taskList);
                 response = scriptInstance.exec();
             } else {
-                scriptProcessLogExecutor.insertLogExecute(taskList,0L,0L,false,false);
-                log.error("script script should extends Abstractscript.");
-                response=Result.error("script script should extends Abstractscript.");
+                scriptProcessLogExecutor.insertLogExecute(taskList,start,0L,false,false);
+                log.error("script script should extends AbstractScript.");
+                response=Result.error("script script should extends AbstractScript.");
             }
             long end=System.currentTimeMillis();
             scriptProcessLogExecutor.insertLogExecute(taskList,start,end);

+ 16 - 0
module-check/src/main/java/cn/com/ctop/notice/handler/SendWeChatHandle.java

@@ -6,6 +6,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Arrays;
+import java.util.List;
+
 @Slf4j
 @Service
 public class SendWeChatHandle {
@@ -25,4 +28,17 @@ public class SendWeChatHandle {
         }
         return result;
     }
+
+    public void SendWeChatByMails(String mails,String message){
+        List<String> mail= Arrays.asList(mails.split(","));
+        mail.forEach(m->{
+            String weChatId=mailLogMapper.getWeChatByMail(m);
+            if(weChatId.isEmpty()){
+                log.error(String.format("mail's WeChat not found. mail =%s", m));
+                //TODO 通知管理员添加邮箱
+            }else{
+                CorpWexinUtils.sendMessageByWeChatId(weChatId,message);
+            }
+        });
+    }
 }

+ 126 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/Advertiser.java

@@ -0,0 +1,126 @@
+package cn.com.ctop.common.module.entity;
+
+import cn.com.ctop.common.module.annotation.Dict;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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 org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 广告主信息表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-06-11
+ */
+@Data
+@TableName("ctop_advertiser")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_advertiser对象", description = "广告主信息表")
+public class Advertiser {
+
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "主键ID")
+    private String id;
+    /**
+     * 广告主名称
+     */
+    @Excel(name = "广告主名称", width = 15)
+    @ApiModelProperty(value = "广告主名称")
+    private String name;
+    /**
+     * 行业ID
+     */
+    @Excel(name = "行业ID", width = 15)
+    @ApiModelProperty(value = "行业ID")
+    @Dict(dicCode = "id",dictTable="sys_category",dicText="name")
+    private String industryId;
+    private String industryCode;
+    /**
+     * 销售ID
+     */
+    @Excel(name = "销售ID", width = 15)
+    @ApiModelProperty(value = "销售ID")
+    @Dict(dicCode = "id",dictTable="sys_user",dicText="realname")
+    private String saleId;
+    /**
+     * 销售ID
+     */
+    @Excel(name = "广告主类别", width = 15)
+    @ApiModelProperty(value = "广告主类别")
+    private Integer advertiserType;
+
+    /**
+     * 代理商Id
+     */
+    private Long agentId;
+
+    /**
+     * 联系人姓名
+     */
+    @Excel(name = "联系人姓名", width = 15)
+    @ApiModelProperty(value = "联系人姓名")
+    private String contact;
+    /**
+     * 联系人手机
+     */
+    @Excel(name = "联系人手机", width = 15)
+    @ApiModelProperty(value = "联系人手机")
+    private String mobile;
+    /**
+     * 联系人邮箱
+     */
+    @Excel(name = "联系人邮箱", width = 15)
+    @ApiModelProperty(value = "联系人邮箱")
+    private String email;
+    /**
+     * 创建人
+     */
+    @Excel(name = "创建人", width = 15)
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改人
+     */
+    @Excel(name = "修改人", width = 15)
+    @ApiModelProperty(value = "修改人")
+    private String updateBy;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+    private String userId;
+
+    private String companyId;
+
+    @TableField(exist = false)
+    private String saleName;
+
+
+}

+ 44 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/Product.java

@@ -0,0 +1,44 @@
+package cn.com.ctop.common.module.entity;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 产品
+ */
+@Data
+public class Product {
+    /**
+     * id
+     */
+    private Long id;
+    /**
+     * 产品名称
+     */
+    private String productName;
+    /**
+     * 广告主id
+     */
+    private String advertiserId;
+
+    private String advertiserName;
+
+    /**
+     * 创建人
+     */
+    private String createUserId;
+
+    /**
+     * 媒体类型
+     */
+    private String mediaId;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    private Date updateTime;
+
+}

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopOauthTokenMapper.java

@@ -31,6 +31,8 @@ public interface CtopOauthTokenMapper extends BaseMapper<CtopOauthToken> {
 
     List<CtopOauthToken> selectKuaiShouToken();
 
+    List<CtopOauthToken> selectKuaiShouTokenBefore();
+
     List<CtopOauthToken> selectToutiaoToken();
 
     CtopOauthToken getAccessTokenByAccountIdAndMediaId(@Param("mediaId") Integer mediaId, @Param("accountId") Long accountId);

+ 47 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/ProductMapper.java

@@ -0,0 +1,47 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.Advertiser;
+import cn.com.ctop.common.module.entity.Product;
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.vo.*;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+
+public interface ProductMapper extends BaseMapper<Product> {
+
+    Long insertProduct(@Param("product") ProductVO product);
+
+    List<Advertiser> getAdvertiserList();
+
+    List<Project> getProjectListByAdvertiserId(@Param("advertiserId")String advertiserId);
+
+    List<ProductDto> getYunyingListByProjectIds(@Param("projectIds")List<Long> projectIds);
+
+    List<ProductDto> getSaleListByProjectIds(@Param("projectIds")List<Long> projectIds);
+
+    void logicDeleteProductById(@Param("id")Long id);
+
+    void deleteProductProjectMapByProductId(@Param("id")Long ProductId);
+
+    void insertProductProjectMap(@Param("projectIds")List<Long> projectIds, @Param("productId")Long productId);
+
+    void updateProduct(@Param("product")ProductVO product);
+
+    Product getProductInfo(@Param("id")Long id);
+
+    List<ProjectVO> getProjectListByProductId(@Param("productId")Long productId);
+
+    List<Long> getProjectIdsByProductId(@Param("productId")Long productId);
+
+    void deleteByProjectIdAndProductId(@Param("productId")Long productId, @Param("projectId")Long projectId);
+
+    List<ProductVO> getProductList(@Param("advertiserName")String advertiserName, @Param("productName")String productName);
+
+    List<SaleVO> getSalesListByProductId(@Param("productId")Long productId);
+
+    List<UserDto> getYunyingListByProductId(@Param("productId")Long productId);
+
+}

+ 9 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml

@@ -96,6 +96,15 @@
 
     </select>
 
+    <select id="selectKuaiShouTokenBefore" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
+        select  t1.*
+        from ctop_oauth_token t1
+        left join ctop_user_allocation t2
+        on t1.account_id = t2.account_id
+        where t1.media_id = 2
+        and date_format(t2.create_time, '%Y-%m-%d') = date_sub(curdate(),interval 1 day)
+    </select>
+
     <select id="selectToutiaoToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
         select t1.*
         from ctop_oauth_token t1

+ 222 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProductMapper.xml

@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.common.module.mapper.ProductMapper">
+
+    <insert id="insertProduct" useGeneratedKeys="true" keyProperty="id">
+        insert into
+        ctop_product
+        (
+            product_name,
+            media_id,
+            advertiser_id,
+            advertiser_name,
+            create_user_id,
+            product_status
+        )values(
+            #{product.productName},
+            #{product.mediaId},
+            #{product.advertiserId},
+            #{product.advertiserName},
+            #{product.createUserId},
+            1
+        )
+    </insert>
+
+    <select id="getAdvertiserList" resultType="cn.com.ctop.common.module.entity.Advertiser">
+        select
+        id as id,
+        name as name
+        from
+        ctop_advertiser
+    </select>
+
+    <select id="getProjectListByAdvertiserId" resultType="cn.com.ctop.common.module.entity.Project">
+        select
+        id,
+        project_name as projectName,
+        media_id as mediaId
+        from
+        ctop_project
+        where
+        advertiser_id = #{advertiserId}
+    </select>
+
+    <select id="getYunyingListByProjectIds" resultType="cn.com.ctop.common.module.vo.ProductDto">
+        select
+        distinct user_id as userId,
+        user_name as userName
+        from
+        ctop_user_allocation
+        where
+        project_id in
+        <foreach collection="projectIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+
+    </select>
+
+    <select id="getSaleListByProjectIds" resultType="cn.com.ctop.common.module.vo.ProductDto">
+        select
+        a.id as projectId,
+        a.project_name as projectName,
+        a.sale_id as saleId,
+        b.realname as saleName
+        from
+        ctop_project a
+        left join sys_user b on a.sale_id = b.id
+        where
+        a.id in
+        <foreach collection="projectIds" item="item" separator=","
+                       open="(" close=")">
+        #{item}
+        </foreach>
+    </select>
+
+    <update id="logicDeleteProductById">
+        update
+        ctop_product
+        set product_status = 0
+        where
+        id = #{id}
+    </update>
+
+    <delete id="deleteProductProjectMapByProductId">
+        delete
+        from
+        ctop_product_project_map
+        where
+        product_id  = #{id}
+    </delete>
+
+    <insert id="insertProductProjectMap">
+        insert into
+        ctop_product_project_map
+        (
+            product_id,
+            project_id
+        )
+        values
+        <foreach collection="projectIds" item="projectId" separator=",">
+            (
+             #{productId},
+             #{projectId}
+            )
+        </foreach>
+    </insert>
+
+    <update id="updateProduct">
+        update
+        ctop_product
+        set
+        product_name = #{product.productName},
+        media_id = #{product.mediaId}
+      <!--  advertiser_id = #{product.advertiserId},
+        advertiser_name = #{product.advertiserName}  -->
+        where
+        id = #{product.id}
+    </update>
+
+    <select id="getProductInfo" resultType="cn.com.ctop.common.module.entity.Product">
+        select
+        id as id,
+        product_name as productName,
+        media_id as mediaId,
+        advertiser_id as advertiserId,
+        advertiser_name as advertiserName,
+        create_user_id as createUserId,
+        product_status as productStatus
+        from
+        ctop_product
+        where
+        id = #{id}
+    </select>
+
+    <select id="getProjectListByProductId" resultType="cn.com.ctop.common.module.vo.ProjectVO">
+        select
+        a.project_id as projectId,
+        b.project_name as projectName
+        from
+        ctop_product_project_map a
+        left join ctop_project b on a.project_id = b.id
+        where
+        a.product_id = #{productId}
+    </select>
+
+    <select id="getProjectIdsByProductId" resultType="Long">
+        select
+        a.project_id as projectId
+        from
+        ctop_product_project_map a
+        left join ctop_project b on a.project_id = b.id
+        where
+        a.product_id = #{productId}
+    </select>
+
+
+
+
+    <select id="deleteByProjectIdAndProductId">
+        delete
+        from
+        ctop_product_project_map
+        where
+        project_id = #{projectId}
+        and
+        product_id = #{productId}
+    </select>
+
+    <select id="getProductList" resultType="cn.com.ctop.common.module.vo.ProductVO">
+            select
+            id as id,
+            product_name as productName,
+            media_id as mediaId,
+            advertiser_id as advertiserId,
+            advertiser_name as advertiserName,
+            create_user_id as createUserId,
+            product_status as productStatus
+        from
+        ctop_product
+        where
+        product_status = 1 and
+        <if test="advertiserName != null and advertiserName != '' ">
+            advertiser_name like concat('%', #{advertiserName},'%') and
+        </if>
+        <if test="productName != null and productName != '' ">
+            product_name like concat('%', #{productName}, '%') and
+        </if>
+        1=1
+    </select>
+
+    <select id="getSalesListByProductId" resultType="cn.com.ctop.common.module.vo.SaleVO">
+        select
+        distinct b.sale_id as saleId,
+        c.realname as saleName
+        from
+        ctop_product_project_map a
+        left join (select id,project_name,sale_id from ctop_project) b on a.project_id = b.id
+        left join sys_user c on b.sale_id = c.id
+        where
+        product_id = #{productId}
+    </select>
+
+    <select id="getYunyingListByProductId" resultType="cn.com.ctop.common.module.vo.UserDto">
+        select
+        distinct user_id as userId,
+        user_name as realname
+        from
+        ctop_user_allocation a
+        where
+        project_id in (
+        select project_id
+        from
+        ctop_product_project_map
+        where product_id = #{productId}
+        )
+
+    </select>
+
+
+
+
+</mapper>

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

@@ -26,6 +26,8 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
 
     List<CtopOauthToken> selectKuaiShouToken();
 
+    List<CtopOauthToken> selectKuaiShouTokenBefore();
+
     List<CtopOauthToken> selectToutiaoToken();
 
     CtopOauthToken getAccessTokenByAccountIdAndMediaId(Integer mediaId, Long accountId);

+ 45 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IProductService.java

@@ -0,0 +1,45 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.Advertiser;
+import cn.com.ctop.common.module.entity.Product;
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.vo.ProductVO;
+import cn.com.ctop.common.module.vo.ProjectVO;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 项目
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-11-19
+ */
+public interface IProductService extends IService<Product> {
+
+    List<Advertiser> advertiserList();
+
+    List<Project> getProjectListByAdvertiserId(String advertiserId);
+
+    Map<String,Object> getSaleAndYunyingListByProjectIds(List<Long> projectIds);
+
+    void deleteProduct(Long id);
+
+    void insertOrUpdateProduct(ProductVO product);
+
+    void insertProductProjectMap(Long productId, List<Long> projectIds);
+
+    Map<String, Object> getProductInfo(Long productId);
+
+    void deleteByProjectIdAndProductId(Long projectId, Long productId);
+
+    List<ProjectVO> getProjectListByProductId(Long productId);
+
+    PageInfo<ProductVO> getProductList(String advertiserName, String productName, Integer pageNum, Integer pageSize);
+
+    List<Long> getProjectIdsByProductId(Long productId);
+
+}

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -194,6 +194,11 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         return ctopOauthTokenMapper.selectKuaiShouToken();
     }
 
+    @Override
+    public List<CtopOauthToken> selectKuaiShouTokenBefore() {
+        return ctopOauthTokenMapper.selectKuaiShouTokenBefore();
+    }
+
 
     /**
      * 获取toutiao有效账户列表

+ 148 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/ProductServiceImpl.java

@@ -0,0 +1,148 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.Advertiser;
+import cn.com.ctop.common.module.entity.Product;
+import cn.com.ctop.common.module.entity.Project;
+import cn.com.ctop.common.module.mapper.ProductMapper;
+import cn.com.ctop.common.module.service.IProductService;
+import cn.com.ctop.common.module.vo.*;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@Service
+public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
+
+    @Autowired
+    private ProductMapper productMapper;
+
+    @Override
+    public List<Advertiser> advertiserList(){
+        return productMapper.getAdvertiserList();
+    }
+
+    @Override
+    public List<Project> getProjectListByAdvertiserId(String advertiserId){
+        return productMapper.getProjectListByAdvertiserId(advertiserId);
+    }
+
+    @Override
+    public Map<String,Object> getSaleAndYunyingListByProjectIds(List<Long> projectIds){
+        Map<String,Object> map = new HashMap<>();
+
+        List<ProductDto> saleList = productMapper.getSaleListByProjectIds(projectIds);
+        List<ProductDto> yunyingeList = productMapper.getYunyingListByProjectIds(projectIds);
+
+        map.put("saleList",saleList);
+        map.put("yunyingList",yunyingeList);
+
+        return map;
+    }
+
+    @Override
+    public void deleteProduct(Long id){
+        productMapper.logicDeleteProductById(id);
+    }
+
+    @Override
+    public void insertOrUpdateProduct(ProductVO product){
+        //更新
+        if(product.getId() != null){
+            //productMapper.deleteProductProjectMapByProductId(product.getId());
+            //if(product.getProjectIds() != null && product.getProjectIds().size() != 0 ){
+            //    productMapper.insertProductProjectMap(product.getProjectIds(), product.getId());
+            //}
+            productMapper.updateProduct(product);
+        }else { //入库
+            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            product.setCreateUserId(sysUser.getId());
+            productMapper.insertProduct(product);
+
+            if(product.getProjectIds() != null && product.getProjectIds().size() != 0 ){
+                productMapper.insertProductProjectMap(product.getProjectIds(), product.getId());
+            }
+        }
+    }
+
+    @Override
+    public void insertProductProjectMap(Long productId, List<Long> projectIds){
+        productMapper.insertProductProjectMap(projectIds, productId);
+    }
+
+  @Override
+    public Map<String, Object> getProductInfo(Long productId){
+        Map<String,Object> map = new HashMap<>();
+
+        Product product = productMapper.getProductInfo(productId);
+        List<ProjectVO> projectList = productMapper.getProjectListByProductId(productId);
+
+        List<Long> projectIds = new ArrayList<>();
+        for(ProjectVO vo:projectList){
+            projectIds.add(vo.getProjectId());
+        }
+
+        List<ProductDto> saleList = productMapper.getSaleListByProjectIds(projectIds);
+        List<ProductDto> yunyingeList = productMapper.getYunyingListByProjectIds(projectIds);
+
+        map.put("saleList",saleList);
+        map.put("yunyingList",yunyingeList);
+        map.put("product",product);
+        map.put("projectList",projectList);
+
+        return map;
+    }
+
+    @Override
+    public void deleteByProjectIdAndProductId(Long projectId, Long productId){
+        productMapper.deleteByProjectIdAndProductId(productId, projectId);
+    }
+
+    @Override
+    public List<ProjectVO> getProjectListByProductId(Long productId){
+        return productMapper.getProjectListByProductId(productId);
+    }
+
+    @Override
+    public PageInfo<ProductVO> getProductList(String advertiserName, String productName, Integer pageNum, Integer pageSize){
+        PageHelper.startPage(pageNum, pageSize);
+        List<ProductVO> productList = productMapper.getProductList(advertiserName, productName);
+
+        for(ProductVO product:productList){
+            List<ProjectVO> projectListByProductId = productMapper.getProjectListByProductId(product.getId());
+            List<SaleVO> salesListByProductId = productMapper.getSalesListByProductId(product.getId());
+            List<UserDto> yunyingListByProductId = productMapper.getYunyingListByProductId(product.getId());
+            List<Long> projectIds = productMapper.getProjectIdsByProductId(product.getId());
+
+            product.setProjectIds(projectIds);
+            product.setProjectList(projectListByProductId);
+            product.setSaleList(salesListByProductId);
+            product.setYunyingList(yunyingListByProductId);
+        }
+
+        return new PageInfo<>(productList);
+
+    }
+
+    @Override
+    public List<Long> getProjectIdsByProductId(Long productId){
+
+        return productMapper.getProjectIdsByProductId(productId);
+
+    }
+
+
+
+
+
+
+}

+ 120 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/ExportExcelUtils.java

@@ -91,4 +91,124 @@ public class ExportExcelUtils {
             }
         }
     }
+
+    public void exportExcelForMediaReport(XSSFWorkbook workbook, int sheetNum,
+                            String sheetTitle, String[] headers, List<List<Object>> result) {
+        // 生成一个表格
+        XSSFSheet sheet = workbook.createSheet();
+        workbook.setSheetName(sheetNum, sheetTitle);
+        // 设置表格默认列宽度为20个字节
+        sheet.setDefaultColumnWidth((short) 20);
+        sheet.setColumnWidth(0, 15 * 256);
+        sheet.setColumnWidth(1, 40 * 256);
+        sheet.setColumnWidth(2, 30 * 256);
+        sheet.setColumnWidth(3, 35 * 256);
+        sheet.setColumnWidth(4, 20 * 256);
+        sheet.setColumnWidth(5, 20 * 256);
+        sheet.setColumnWidth(6, 20 * 256);
+        sheet.setColumnWidth(7, 20 * 256);
+        sheet.setColumnWidth(8, 15 * 256);
+        // 生成一个样式
+        XSSFCellStyle style = workbook.createCellStyle();
+        // 设置这些样式
+        style.setFillForegroundColor(IndexedColors.PALE_BLUE.index);
+        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
+        style.setBorderBottom(BorderStyle.THIN);
+        style.setBorderLeft(BorderStyle.THIN);
+        style.setBorderRight(BorderStyle.THIN);
+        style.setBorderTop(BorderStyle.THIN);
+        // style.setAlignment(HorizontalAlignment.CENTER);
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
+        // 生成一个字体
+        XSSFFont font = workbook.createFont();
+        font.setColor(IndexedColors.BLACK.index);
+        font.setFontHeightInPoints((short) 12);
+        font.setBold(true);
+        // 把字体应用到当前的样式
+        style.setFont(font);
+
+        // 指定当单元格内容显示不下时自动换行
+        style.setWrapText(true);
+
+        //同一行第一个cell
+        XSSFCellStyle cellStyle = workbook.createCellStyle();
+        cellStyle.setAlignment(HorizontalAlignment.CENTER);
+        cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyle.setWrapText(true);
+
+        // 产生表格标题行
+        XSSFRow row = sheet.createRow(0);
+        for (int i = 0; i < headers.length; i++) {
+            XSSFCell cell = row.createCell((short) i);
+            cell.setCellStyle(style);
+            XSSFRichTextString text = new XSSFRichTextString(headers[i]);
+            cell.setCellValue(text.toString());
+        }
+        // 遍历集合数据,产生数据行
+        if (result != null) {
+            int index = 1;
+            for (List<Object> m : result) {
+                row = sheet.createRow(index);
+                int cellIndex = 0;
+
+                for (Object obj : m) {
+                    XSSFCell cell = row.createCell((short) cellIndex);
+                    if (!Check.isNull(obj)) {
+                        if (obj instanceof String) {
+                            cell.setCellValue((String) obj);
+                        } else if (obj instanceof Double) {
+                            cell.setCellValue((Double) obj);
+                        } else if (obj instanceof BigDecimal) {
+                            BigDecimal bigDecimal = (BigDecimal) obj;
+                            cell.setCellValue(bigDecimal.doubleValue());
+                        } else if (obj instanceof Long) {
+                            cell.setCellValue(String.valueOf(obj));
+                        } else {
+                            cell.setCellValue(obj.toString());
+                        }
+                    } else {
+                        cell.setCellValue(0);
+                    }
+                    cell.setCellStyle(cellStyle);
+
+                    cellIndex++;
+                }
+                index++;
+            }
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 }

+ 25 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/ProductDto.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.common.module.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class ProductDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String userId;
+
+    private String userName;
+
+    private String saleId;
+
+    private String saleName;
+
+    private Long projectId;
+
+    private String projectName;
+
+}

+ 28 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/ProductInfoDto.java

@@ -0,0 +1,28 @@
+package cn.com.ctop.common.module.vo;
+
+import com.github.pagehelper.PageInfo;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+@Data
+public class ProductInfoDto extends PageInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String advertiserId;
+
+    private List<Long> projectIds;
+
+    private Long productId;
+
+    private Long projectId;
+
+    private String advertiserName;
+
+    private String productName;
+
+    private Integer mediaId;
+
+}

+ 52 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/ProductVO.java

@@ -0,0 +1,52 @@
+package cn.com.ctop.common.module.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 产品
+ */
+@Data
+public class ProductVO {
+    /**
+     * id
+     */
+    private Long id;
+    /**
+     * 产品名称
+     */
+    private String productName;
+    /**
+     * 广告主id
+     */
+    private String advertiserId;
+    private String advertiserName;
+
+    /**
+     * 创建人
+     */
+    private String createUserId;
+
+    /**
+     * 媒体类型
+     */
+    private String mediaId;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    private Date updateTime;
+
+    private List<Long> projectIds;
+
+    private List<ProjectVO> projectList;
+
+    private List<SaleVO> saleList;
+
+    private List<UserDto> yunyingList;
+
+}

+ 16 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/ProjectVO.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.common.module.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 产品
+ */
+@Data
+public class ProjectVO {
+   private Long projectId;
+   private String projectName;
+
+}

+ 18 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/SaleVO.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.common.module.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 产品
+ */
+@Data
+public class SaleVO {
+
+    private String saleId;
+
+    private String saleName;
+
+}

+ 69 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceDailyPlayableReportJob.java

@@ -0,0 +1,69 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceInterfaceService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class BytedanceDailyPlayableReportJob {
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(4);
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceInterfaceService bytedanceInterfaceService;
+
+    @XxlJob("bytedanceDailyPlayableReportJob")
+    public ReturnT<String> execute(String param) throws Exception {
+        Date getDate2 = DateUtils.addDay(new Date(), -2);
+        String date2 = DateUtils.formatDate(getDate2);
+
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        String date = DateUtils.formatDate(getDate);
+        XxlJobLogger.log("头条获取试玩报表数据任务开始,任务时间:" + date2 + "~" + date);
+
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        if (null == tokens || tokens.size() <= 0) {
+            XxlJobLogger.log("头条获取试玩报表数据任务执行失败:未获取到可用的token");
+            return ReturnT.FAIL;
+        }
+
+        tokens.forEach(token -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        //获取头条素材报表两天前的数据
+                        XxlJobLogger.log("账户"+token.getAccountId() + "试玩报表数据任务开始,任务时间:" + date2 + "~" + date2);
+                        bytedanceInterfaceService.bytedancePlayableReport(token, date2, date2);
+                        XxlJobLogger.log("账户"+token.getAccountId() + "试玩报表数据任务完成,任务时间:" + date2 + "~" + date2);
+
+                        //获取头条素材报表数据
+                        XxlJobLogger.log("账户"+token.getAccountId() + "试玩报表数据任务开始,任务时间:" + date + "~" + date);
+                        bytedanceInterfaceService.bytedancePlayableReport(token, date, date);
+                        XxlJobLogger.log("账户"+token.getAccountId() + "试玩报表数据任务完成,任务时间:" + date + "~" + date);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    } finally {
+                    }
+                }
+            });
+        });
+        return ReturnT.SUCCESS;
+    }
+
+
+
+}

+ 68 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceDailyPlayableReportRetryJob.java

@@ -0,0 +1,68 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportPlayableRetry;
+import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceInterfaceService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class BytedanceDailyPlayableReportRetryJob {
+    static ExecutorService executorService = Executors.newFixedThreadPool(4);
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IBytedanceInterfaceService bytedanceInterfaceService;
+
+
+    @XxlJob("bytedanceDailyPlayableReportRetryJob")
+    public ReturnT<String> execute(String param) throws Exception {
+        XxlJobLogger.log("头条试玩报表重试定时任务开始");
+
+        List<BytedanceReportPlayableRetry> retryList = bytedanceInterfaceService.getRetryList();
+        retryList.forEach(retry -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        String startDate = retry.getStartDate();
+                        String endDate = retry.getEndDate();
+                        Long accountId = retry.getAccountId();
+                        Integer type = retry.getType();
+                        CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
+                        XxlJobLogger.log("头条试玩报表重试定时任务开始,当前accountId为:" + token.getAccountId());
+                        Long days = DateUtils.getDiscrepantDays(startDate, endDate); //间隔天数
+                        String start = null;
+                        String end = null;
+                        for (int i = 0; i <= days; i++) {
+                            start = DateUtils.addDay(startDate, i);
+                            end = start;
+                            //获取头条素材报表数据
+                            int code = bytedanceInterfaceService.bytedancePlayableReportRetry(type, token, start, end);
+                            XxlJobLogger.log("头条试玩报表重试定时任务完成,当前accountId为:" + token.getAccountId() + "code:" + code);
+
+                        }
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    } finally {
+                    }
+                }
+            });
+        });
+        return ReturnT.SUCCESS;
+    }
+
+
+}

+ 4 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceOperationRecordJob.java

@@ -44,6 +44,10 @@ public class BytedanceOperationRecordJob {
                     XxlJobLogger.log("定时获取头条操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 2 + "时间:" + startDate + "~" + endDate);
                     bytedanceInterfaceService.searchLog(token.getAccountId(), token, 2, startDate, endDate);
                     XxlJobLogger.log("定时获取头条操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 2 + "时间:" + startDate + "~" + endDate);
+
+                    XxlJobLogger.log("定时获取头条操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 3 + "时间:" + startDate + "~" + endDate);
+                    bytedanceInterfaceService.searchLog(token.getAccountId(), token, 3, startDate, endDate);
+                    XxlJobLogger.log("定时获取头条操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 3 + "时间:" + startDate + "~" + endDate);
                 }
             });
         });

+ 1 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/CheckDataStateJob.java

@@ -28,7 +28,7 @@ public class CheckDataStateJob {
     public ReturnT<String> execute(String param) throws Exception {
         //查询需要检查的任务列表
         List<CtopCheckTaskList> ctopCheckTaskList= checkTaskListService.queryExecuteList(jobName);
-        if(!ctopCheckTaskList.isEmpty()){
+        if(ctopCheckTaskList!=null){
             ctopCheckTaskList.forEach(it-> groovyScriptExecutor.execute(it));
         }
         return ReturnT.SUCCESS;

+ 1 - 1
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/CheckExecuteStateJob.java

@@ -28,7 +28,7 @@ public class CheckExecuteStateJob {
     public ReturnT<String> execute(String param) throws Exception {
         //查询需要检查的任务列表
         List<CtopCheckTaskList> ctopCheckTaskList= checkTaskListService.queryExecuteList(jobName);
-        if(!ctopCheckTaskList.isEmpty()){
+        if(ctopCheckTaskList!=null){
             ctopCheckTaskList.forEach(it-> groovyScriptExecutor.execute(it));
         }
         return ReturnT.SUCCESS;

+ 123 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouNewAccountOperationRecordJob.java

@@ -0,0 +1,123 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService2;
+import com.xxl.job.core.biz.model.ReturnT;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import com.xxl.job.core.log.XxlJobLogger;
+import org.apache.commons.lang.StringUtils;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ *  快手操作记录,将前一天绑定的账户的近6个月的数据统一跑出来
+ */
+@Component
+public class KuaishouNewAccountOperationRecordJob {
+    @Autowired
+    private IKuaishouInterfaceService2 kuaishouInterfaceService2;
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(4);
+
+    @XxlJob("kuaishouNewAccountOperationRecord")
+    public ReturnT<String> execute(String param) throws Exception {
+        Date getDate = DateUtils.addDay(new Date(), -1);
+        if(StringUtils.isNotBlank(param)){
+            getDate =  DateUtils.addDay(new Date(), Integer.parseInt(param));
+        }
+
+        String date = DateUtils.formatDate(getDate);
+        String startDate = DateUtils.getMonthBefore("yyyy-MM-dd", date, -6);
+
+        //1:查询当日数据
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouTokenBefore();
+        if (null == tokens || tokens.size() <= 0) {
+            XxlJobLogger.log("定时获取快手操作记录数据异常:未获取到可用的token");
+            return ReturnT.FAIL;
+        }
+        tokens.forEach(token -> {
+            executorService.submit(new Runnable() {
+                @Override
+                public void run() {
+                    XxlJobLogger.log("定时获取快手操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 1 + "时间:" + date + "~" + date);
+                    //kuaishouInterfaceService2.getOperationRecord(token.getAccountId(), token.getAccessToken(), 1, date, date);
+                    month(token.getAccountId(), token.getAccessToken(), 1, startDate, date);
+                    XxlJobLogger.log("定时获取快手操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 1 + "时间:" + date + "~" + date);
+
+                    XxlJobLogger.log("定时获取快手操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 2+ "时间:" + date + "~" + date);
+                    //kuaishouInterfaceService2.getOperationRecord(token.getAccountId(),token.getAccessToken(),2, date, date);
+                    month(token.getAccountId(), token.getAccessToken(), 2, startDate, date);
+                    XxlJobLogger.log("定时获取快手操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 2+ "时间:" + date + "~" + date);
+
+                    XxlJobLogger.log("定时获取快手操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 3+ "时间:" + date + "~" + date);
+                    //kuaishouInterfaceService2.getOperationRecord(token.getAccountId(),token.getAccessToken(),3, date, date);
+                    month(token.getAccountId(), token.getAccessToken(), 3, startDate, date);
+                    XxlJobLogger.log("定时获取快手操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 3+ "时间:" + date + "~" + date);
+
+                    XxlJobLogger.log("定时获取快手操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 4+ "时间:" + date + "~" + date);
+                    //kuaishouInterfaceService2.getOperationRecord(token.getAccountId(),token.getAccessToken(),4, date, date);
+                    month(token.getAccountId(), token.getAccessToken(), 4, startDate, date);
+                    XxlJobLogger.log("定时获取快手操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 4+ "时间:" + date + "~" + date);
+
+                    XxlJobLogger.log("定时获取快手操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 5+ "时间:" + date + "~" + date);
+                    //kuaishouInterfaceService2.getOperationRecord(token.getAccountId(),token.getAccessToken(),5, date, date);
+                    month(token.getAccountId(), token.getAccessToken(), 5, startDate, date);
+                    XxlJobLogger.log("定时获取快手操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 5+ "时间:" + date + "~" + date);
+
+                    XxlJobLogger.log("定时获取快手操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 6+ "时间:" + date + "~" + date);
+                    //kuaishouInterfaceService2.getOperationRecord(token.getAccountId(),token.getAccessToken(),6, date, date);
+                    month(token.getAccountId(), token.getAccessToken(), 6, startDate, date);
+                    XxlJobLogger.log("定时获取快手操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 6+ "时间:" + date + "~" + date);
+
+                    XxlJobLogger.log("定时获取快手操作记录数据开始,accountId:" + token.getAccountId() + "操作目标为:" + 7+ "时间:" + date + "~" + date);
+                    //kuaishouInterfaceService2.getOperationRecord(token.getAccountId(),token.getAccessToken(),7, date, date);
+                    month(token.getAccountId(), token.getAccessToken(), 7, startDate, date);
+                    XxlJobLogger.log("定时获取快手操作记录数据结束,accountId:" + token.getAccountId() + "操作目标为:" + 7+ "时间:" + date + "~" + date);
+                }
+            });
+        });
+
+        return ReturnT.SUCCESS;
+    }
+
+
+    private void month(Long token, String accessToken, Integer operationTarget, String startDate, String endDate){
+        int diffMonths = DateUtils.calDiffMonth(DateUtils.parseDate(startDate, "yyyy-MM-dd"), DateUtils.parseDate(endDate, "yyyy-MM-dd"));
+        if (diffMonths == 0) {
+            kuaishouInterfaceService2.getOperationRecord(token, accessToken, operationTarget, startDate, endDate);
+        } else {
+            for (int i = 0; i <= diffMonths; i++) {
+                if (i == 0) {
+                    Map<String, String> dateMap = DateUtils.getMaxMinDaysOfAddMonth(startDate, "yyyy-MM-dd", i);
+                    String end = dateMap.get("endDate");
+                    kuaishouInterfaceService2.getOperationRecord(token, accessToken, operationTarget, startDate, end);
+                    //ytedanceAsyncTaskCreateByMonth(startDate, end, token, type);
+                } else if (i == diffMonths) {
+                    Map<String, String> dateMap = DateUtils.getMaxMinDaysOfAddMonth(startDate, "yyyy-MM-dd", i);
+                    String start = dateMap.get("startDate");
+                    kuaishouInterfaceService2.getOperationRecord(token, accessToken, operationTarget, start, endDate);
+                    //bytedanceAsyncTaskCreateByMonth(start, endDate, token, type);
+                } else {
+                    Map<String, String> dateMap = DateUtils.getMaxMinDaysOfAddMonth(startDate, "yyyy-MM-dd", i);
+                    String start = dateMap.get("startDate");
+                    String end = dateMap.get("endDate");
+                    kuaishouInterfaceService2.getOperationRecord(token, accessToken, operationTarget, start, end);
+                    //bytedanceAsyncTaskCreateByMonth(start, end, token, type);
+                }
+            }
+        }
+    }
+
+
+
+}

+ 9 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/ByteDanceBatchController.java

@@ -106,16 +106,21 @@ public class ByteDanceBatchController {
     private IBytedanceImageInfoService imageInfoService;
 
     @GetMapping(value = "/getImageList")
-    public Result<IPage<BytedanceImageInfo>> getBytedqanceVideoList(@RequestParam(name = "accountId")Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
-                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
-                                                                    @RequestParam(name = "startDate", defaultValue = "") String startDate,
-                                                                    @RequestParam(name = "endDate", defaultValue = "") String endDate, HttpServletRequest req) {
+    public Result<IPage<BytedanceImageInfo>> getBytedqanceVideoList(
+            @RequestParam(name = "type") Integer type,
+            @RequestParam(name = "accountId")Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            @RequestParam(name = "startDate", defaultValue = "") String startDate,
+            @RequestParam(name = "endDate", defaultValue = "") String endDate, HttpServletRequest req) {
         Result<IPage<BytedanceImageInfo>> result = new Result<>();
         try {
             if (Check.isNull(accountId)) {
                 throw new Exception("账户id不能为空");
             }
             QueryWrapper<BytedanceImageInfo> queryWrapper = new QueryWrapper<>();
+            if(null!=type&&type!=0){
+                queryWrapper.eq("type",type);
+            }
             if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
                 queryWrapper.between("image_create_time", startDate+" 00:00:00", endDate+" 23:59:59");
             }

+ 1 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/BytedanceImageInfo.java

@@ -67,6 +67,7 @@ public class BytedanceImageInfo {
 	/**updateTime*/
     @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
+    private Integer type;
 
 	public BytedanceImageInfo(JSONObject dataObject, CtopOauthToken token) {
 		String id = dataObject.getString("id");

+ 2 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/ByteDanceVideoInfoMapper.java

@@ -16,5 +16,6 @@ public interface ByteDanceVideoInfoMapper extends BaseMapper<ByteDanceVideoInfo>
 
     void replaceBatch(@Param(value = "videoList") List<ByteDanceVideoInfo> videoInfoList);
 
-    void updateVideoType();
+    void updateVideoVerticalType();
+    void updateVideoHorizonType();
 }

+ 4 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/BytedanceImageInfoMapper.java

@@ -15,4 +15,8 @@ import java.util.List;
 public interface BytedanceImageInfoMapper extends BaseMapper<BytedanceImageInfo> {
 
     void replaceBatch(@Param(value = "imageInfos")List<BytedanceImageInfo> imageInfos);
+
+    void updateImageVerticalType();
+
+    void updateImageHorizonType();
 }

+ 12 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/ByteDanceVideoInfoMapper.xml

@@ -51,7 +51,17 @@
             )
         </foreach>
     </insert>
-    <update id="updateVideoType">
-        update ctop_bytedance_video_info set type = 2 where height&gt;width
+    <update id="updateVideoVerticalType">
+        update
+            ctop_bytedance_video_info
+        set type = 2
+        where height &gt; width
+        and (height between 1280 and 2560)  and (width between 720 and 1440);
+    </update>
+    <update id="updateVideoHorizonType">
+        update ctop_bytedance_video_info
+            set type = 1
+        where height &lt; width
+        and (width between 1280 and 2560)  and (height between 720 and 1440)
     </update>
 </mapper>

+ 14 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/BytedanceImageInfoMapper.xml

@@ -32,4 +32,18 @@
             #{imageInfo.updateTime},#{imageInfo.imageUrl})
         </foreach>
     </insert>
+
+    <update id="updateImageVerticalType">
+        update
+            ctop_bytedance_image_info
+        set type = 2
+        where height &gt; width
+        and (height between 1280 and 2560)  and (width between 720 and 1440);
+    </update>
+    <update id="updateImageHorizonType">
+        update ctop_bytedance_image_info
+            set type = 1
+        where height &lt; width
+        and (width between 1280 and 2560)  and (height between 720 and 1440)
+    </update>
 </mapper>

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceVideoInfoService.java

@@ -17,5 +17,5 @@ public interface IByteDanceVideoInfoService extends IService<ByteDanceVideoInfo>
 
     ByteDanceVideoInfo getOneByParams(Long materialId);
 
-    void updateVideoType();
+    void updateMaterialType();
 }

+ 2 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceImageInfoService.java

@@ -13,4 +13,6 @@ import java.util.List;
  */
 public interface IBytedanceImageInfoService extends IService<BytedanceImageInfo> {
     void replaceBatch(List<BytedanceImageInfo> videoInfoList);
+
+    void updateType();
 }

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

@@ -32,8 +32,6 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     @Autowired
     private ByteDanceCreativeMapper creativeMapper;
     @Autowired
-    private IByteDanceCampaignService campaignService;
-    @Autowired
     private IByteDanceVideoInfoService videoInfoService;
 
     @Override
@@ -577,7 +575,8 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     public void getMaterialList(CtopOauthToken token) {
         getVideoByPage(token, "", 1);
         getImageByPage(token, "", 1);
-        videoInfoService.updateVideoType();
+        videoInfoService.updateMaterialType();
+        imageInfoService.updateType();
     }
 
     @Autowired

+ 5 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java

@@ -438,6 +438,11 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
                 String imageId = getImage.getString("image_id");
                 if(null!=imageId&&!imageId.trim().equals("")){
                     setImage.put("imageId",imageId);
+                    if(null!=imageId&&imageId.contains("web")){
+                        setImage.put("imageUrl","https://sf6-ttcdn-tos.pstatp.com/obj/"+imageId);
+                    }else{
+                        setImage.put("imageUrl","https://sf6-ttcdn-tos.pstatp.com/obj/mosaic-legacy/"+imageId);
+                    }
                     setImage.put("imageUrl","https://sf6-ttcdn-tos.pstatp.com/obj/mosaic-legacy/"+imageId);
                 }
                 String videoId = getImage.getString("video_id");

+ 3 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceVideoInfoServiceImpl.java

@@ -37,7 +37,8 @@ public class ByteDanceVideoInfoServiceImpl extends ServiceImpl<ByteDanceVideoInf
     }
 
     @Override
-    public void updateVideoType() {
-        videoInfoMapper.updateVideoType();
+    public void updateMaterialType() {
+        videoInfoMapper.updateVideoVerticalType();
+        videoInfoMapper.updateVideoHorizonType();
     }
 }

+ 8 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceImageInfoServiceImpl.java

@@ -18,9 +18,15 @@ import java.util.List;
 @Service
 public class BytedanceImageInfoServiceImpl extends ServiceImpl<BytedanceImageInfoMapper, BytedanceImageInfo> implements IBytedanceImageInfoService {
     @Autowired
-    private BytedanceImageInfoMapper bytedanceImageInfoMapper;
+    private BytedanceImageInfoMapper imageInfoMapper;
     @Override
     public void replaceBatch(List<BytedanceImageInfo> videoInfoList) {
-        bytedanceImageInfoMapper.replaceBatch(videoInfoList);
+        imageInfoMapper.replaceBatch(videoInfoList);
+    }
+
+    @Override
+    public void updateType() {
+        imageInfoMapper.updateImageVerticalType();
+        imageInfoMapper.updateImageHorizonType();
     }
 }

+ 108 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceInterfaceController.java

@@ -2,6 +2,8 @@ package cn.com.ctop.toutiao.modules.report.controller;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportPlayableRetry;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceAccountReportService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceInterfaceService;
@@ -16,6 +18,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
 /**
  * Created by JQ.bi on 2020.6.5
  */
@@ -35,7 +41,7 @@ public class BytedanceInterfaceController {
 
 
     /**
-     * 头条视频素材报表--此接口仅有视频素材,单个accountId拉取数据
+     * 头条试玩报表--单个accountId拉取数据
      * @param startDate
      * @param endDate
      * @return
@@ -79,4 +85,105 @@ public class BytedanceInterfaceController {
         return result;
     }
 
+    //头条试玩报表
+    @GetMapping("/bytedancePlayableReport")
+    public Result bytedancePlayableReport(@RequestParam(name = "startDate") String startDate,
+                                          @RequestParam(name = "endDate") String endDate) {
+        Result result = new Result<>();
+        if (StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate)){
+            result.error500("开始时间和结束时间不能为空");
+            return result;
+        }
+        try {
+            log.info("头条获取试玩报表数据任务执行开始");
+            Long starttime = System.currentTimeMillis();
+            List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+            if (null == tokens || tokens.size() <= 0) {
+                log.info("头条获取试玩报表数据任务执行失败:未获取到可用的token");
+                return result;
+            }
+
+            final ExecutorService executorService = Executors.newFixedThreadPool(8);
+            tokens.forEach(token -> {
+                        executorService.submit(new Runnable() {
+                            @Override
+                            public void run() {
+                                try {
+                                    //间隔天数
+                                    Long days = DateUtils.getDiscrepantDays(startDate, endDate);
+                                    String start = null;
+                                    String end = null;
+                                    for (int i = 0; i <= days; i++) {
+                                        start = DateUtils.addDay(startDate, i);
+                                        end = start;
+                                        //获取头条试玩报表数据
+                                        bytedanceInterfaceService.bytedancePlayableReport(token, start, end);
+                                    }
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                } finally {
+                                }
+                            }
+                        });
+                    }
+            );
+            ////
+            Long endtime = System.currentTimeMillis();
+            log.info("头条获取素材报表数据任务执行结束,执行耗时:{}秒", (endtime - starttime) / 1000);
+        } catch (Exception e) {
+            log.error("头条获取素材报表数据任务执行结失败");
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
+    @GetMapping("/bytedancePlayableReporRetry")
+    public Result bytedancePlayableReporRetry() {
+        log.info("头条获取试玩报表失败数据任务重试开始");
+        Result result = new Result<>();
+        try {
+            List<BytedanceReportPlayableRetry> retryList = bytedanceInterfaceService.getRetryList();
+            final ExecutorService executorService = Executors.newFixedThreadPool(3);
+            retryList.forEach(retry -> {
+                executorService.submit(new Runnable() {
+                    @Override
+                    public void run() {
+                        try {
+                            Integer type = retry.getType();
+                            String startDate = retry.getStartDate();
+                            String endDate = retry.getEndDate();
+                            Long accountId = retry.getAccountId();
+                            CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
+
+                            Long days = DateUtils.getDiscrepantDays(startDate, endDate); //间隔天数
+                            String start = null;
+                            String end = null;
+                            for (int i = 0; i <= days; i++) {
+                                start = DateUtils.addDay(startDate, i);
+                                end = start;
+                                //获取头条素材报表数据
+                                bytedanceInterfaceService.bytedancePlayableReportRetry(type, token, start, end);
+                            }
+
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                });
+            });
+            ////
+
+        } catch (Exception e) {
+            log.error("头条获取试玩报表失败数据任务重试失败");
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+
+        return result;
+    }
+
+
+
+
 }

+ 175 - 99
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceReportPlayableDaily.java

@@ -13,7 +13,6 @@ import org.jeecg.common.util.DateUtils;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.math.BigDecimal;
-import java.util.Date;
 
 /**
  * 头条视频素材日报表--仅包含视频素材
@@ -159,14 +158,14 @@ public class BytedanceReportPlayableDaily {
 	@Excel(name = "视频-有效播放1", width = 15)
 	@ApiModelProperty(value = "视频-有效播放1")
 	private Integer validPlay;
-	/**视频-wifi播放1*/
-	@Excel(name = "视频-wifi播放1", width = 15)
-	@ApiModelProperty(value = "视频-wifi播放1")
-	private Integer wifiPlay;
-	/**视频-播放时长,单位ms1*/
-	@Excel(name = "视频-播放时长,单位ms1", width = 15)
-	@ApiModelProperty(value = "视频-播放时长,单位ms1")
-	private Integer playDurationSum;
+	///**视频-wifi播放1*/
+	//@Excel(name = "视频-wifi播放1", width = 15)
+	//@ApiModelProperty(value = "视频-wifi播放1")
+	//private Integer wifiPlay;
+	///**视频-播放时长,单位ms1*/
+	//@Excel(name = "视频-播放时长,单位ms1", width = 15)
+	//@ApiModelProperty(value = "视频-播放时长,单位ms1")
+	//private Integer playDurationSum;
 	/**视频-播放25%进度总数1*/
 	@Excel(name = "视频-播放25%进度总数1", width = 15)
 	@ApiModelProperty(value = "视频-播放25%进度总数1")
@@ -223,30 +222,30 @@ public class BytedanceReportPlayableDaily {
 	@Excel(name = "次留数1", width = 15)
 	@ApiModelProperty(value = "次留数1")
 	private Integer nextDayOpen;
-	/**次留率1*/
-	@Excel(name = "次留率1", width = 15)
-	@ApiModelProperty(value = "次留率1")
-	private BigDecimal nextDayOpenRate;
-	/**次留成本*/
-	@Excel(name = "次留成本", width = 15)
-	@ApiModelProperty(value = "次留成本")
-	private BigDecimal nextDayOpenCost;
-	/**素材类型*/
-	@Excel(name = "素材类型", width = 15)
-	@ApiModelProperty(value = "素材类型")
-	private String imageMode;
-	/**素材id*/
-	@Excel(name = "素材id", width = 15)
-	@ApiModelProperty(value = "素材id")
-	private Long materialId;
-	/**投放位置*/
-	@Excel(name = "投放位置", width = 15)
-	@ApiModelProperty(value = "投放位置")
-	private String inventory;
-	/**activePayAmount*/
-	@Excel(name = "activePayAmount", width = 15)
-	@ApiModelProperty(value = "activePayAmount")
-	private Integer activePayAmount;
+	///**次留率1*/
+	//@Excel(name = "次留率1", width = 15)
+	//@ApiModelProperty(value = "次留率1")
+	//private BigDecimal nextDayOpenRate;
+	///**次留成本*/
+	//@Excel(name = "次留成本", width = 15)
+	//@ApiModelProperty(value = "次留成本")
+	//private BigDecimal nextDayOpenCost;
+	///**素材类型*/
+	//@Excel(name = "素材类型", width = 15)
+	//@ApiModelProperty(value = "素材类型")
+	//private String imageMode;
+	///**素材id*/
+	//@Excel(name = "素材id", width = 15)
+	//@ApiModelProperty(value = "素材id")
+	//private Long materialId;
+	///**投放位置*/
+	//@Excel(name = "投放位置", width = 15)
+	//@ApiModelProperty(value = "投放位置")
+	//private String inventory;
+	///**activePayAmount*/
+	//@Excel(name = "activePayAmount", width = 15)
+	//@ApiModelProperty(value = "activePayAmount")
+	//private Integer activePayAmount;
 	/**validPlayCost*/
 	@Excel(name = "validPlayCost", width = 15)
 	@ApiModelProperty(value = "validPlayCost")
@@ -267,14 +266,14 @@ public class BytedanceReportPlayableDaily {
 	@Excel(name = "download", width = 15)
 	@ApiModelProperty(value = "download")
 	private Integer download;
-	/**cpa*/
-	@Excel(name = "cpa", width = 15)
-	@ApiModelProperty(value = "cpa")
-	private BigDecimal cpa;
-	/**cpc*/
-	@Excel(name = "cpc", width = 15)
-	@ApiModelProperty(value = "cpc")
-	private BigDecimal cpc;
+	///**cpa*/
+	//@Excel(name = "cpa", width = 15)
+	//@ApiModelProperty(value = "cpa")
+	//private BigDecimal cpa;
+	///**cpc*/
+	//@Excel(name = "cpc", width = 15)
+	//@ApiModelProperty(value = "cpc")
+	//private BigDecimal cpc;
 	/**locationClick*/
 	@Excel(name = "locationClick", width = 15)
 	@ApiModelProperty(value = "locationClick")
@@ -287,10 +286,10 @@ public class BytedanceReportPlayableDaily {
 	@Excel(name = "ctr", width = 15)
 	@ApiModelProperty(value = "ctr")
 	private BigDecimal ctr;
-	/**cpm*/
-	@Excel(name = "cpm", width = 15)
-	@ApiModelProperty(value = "cpm")
-	private BigDecimal cpm;
+	///**cpm*/
+	//@Excel(name = "cpm", width = 15)
+	//@ApiModelProperty(value = "cpm")
+	//private BigDecimal cpm;
 	/**wifiPlayRate*/
 	@Excel(name = "wifiPlayRate", width = 15)
 	@ApiModelProperty(value = "wifiPlayRate")
@@ -319,14 +318,14 @@ public class BytedanceReportPlayableDaily {
 	@Excel(name = "activeRate", width = 15)
 	@ApiModelProperty(value = "activeRate")
 	private BigDecimal activeRate;
-	/**playDuration10s*/
-	@Excel(name = "playDuration10s", width = 15)
-	@ApiModelProperty(value = "playDuration10s")
-	private Integer playDuration_10s;
-	/**phoneEffective*/
-	@Excel(name = "phoneEffective", width = 15)
-	@ApiModelProperty(value = "phoneEffective")
-	private Integer phoneEffective;
+	///**playDuration10s*/
+	//@Excel(name = "playDuration10s", width = 15)
+	//@ApiModelProperty(value = "playDuration10s")
+	//private Integer playDuration_10s;
+	///**phoneEffective*/
+	//@Excel(name = "phoneEffective", width = 15)
+	//@ApiModelProperty(value = "phoneEffective")
+	//private Integer phoneEffective;
 	/**gameAddictionRate*/
 	@Excel(name = "gameAddictionRate", width = 15)
 	@ApiModelProperty(value = "gameAddictionRate")
@@ -335,18 +334,18 @@ public class BytedanceReportPlayableDaily {
 	@Excel(name = "activeRegisterRate", width = 15)
 	@ApiModelProperty(value = "activeRegisterRate")
 	private BigDecimal activeRegisterRate;
-	/**averageVideoPlay*/
-	@Excel(name = "averageVideoPlay", width = 15)
-	@ApiModelProperty(value = "averageVideoPlay")
-	private BigDecimal averageVideoPlay;
+	///**averageVideoPlay*/
+	//@Excel(name = "averageVideoPlay", width = 15)
+	//@ApiModelProperty(value = "averageVideoPlay")
+	//private BigDecimal averageVideoPlay;
 	/**downloadFinishCost*/
 	@Excel(name = "downloadFinishCost", width = 15)
 	@ApiModelProperty(value = "downloadFinishCost")
 	private BigDecimal downloadFinishCost;
-	/**playDuration3s*/
-	@Excel(name = "playDuration3s", width = 15)
-	@ApiModelProperty(value = "playDuration3s")
-	private Integer playDuration_3s;
+	///**playDuration3s*/
+	//@Excel(name = "playDuration3s", width = 15)
+	//@ApiModelProperty(value = "playDuration3s")
+	//private Integer playDuration_3s;
 	/**activeRegisterCost*/
 	@Excel(name = "activeRegisterCost", width = 15)
 	@ApiModelProperty(value = "activeRegisterCost")
@@ -375,10 +374,10 @@ public class BytedanceReportPlayableDaily {
 	@Excel(name = "couponSinglePage", width = 15)
 	@ApiModelProperty(value = "couponSinglePage")
 	private Integer couponSinglePage;
-	/**playOver*/
-	@Excel(name = "playOver", width = 15)
-	@ApiModelProperty(value = "playOver")
-	private Integer playOver;
+	///**playOver*/
+	//@Excel(name = "playOver", width = 15)
+	//@ApiModelProperty(value = "playOver")
+	//private Integer playOver;
 	/**downloadStartCost*/
 	@Excel(name = "downloadStartCost", width = 15)
 	@ApiModelProperty(value = "downloadStartCost")
@@ -387,10 +386,10 @@ public class BytedanceReportPlayableDaily {
 	@Excel(name = "message", width = 15)
 	@ApiModelProperty(value = "message")
 	private Integer message;
-	/**playDuration*/
-	@Excel(name = "playDuration", width = 15)
-	@ApiModelProperty(value = "playDuration")
-	private Integer playDuration;
+	///**playDuration*/
+	//@Excel(name = "playDuration", width = 15)
+	//@ApiModelProperty(value = "playDuration")
+	//private Integer playDuration;
 	/**validPlayRate*/
 	@Excel(name = "validPlayRate", width = 15)
 	@ApiModelProperty(value = "validPlayRate")
@@ -403,18 +402,58 @@ public class BytedanceReportPlayableDaily {
 	@Excel(name = "convertCost", width = 15)
 	@ApiModelProperty(value = "convertCost")
 	private BigDecimal convertCost;
-	/**convertShowRate*/
-	@Excel(name = "convertShowRate", width = 15)
-	@ApiModelProperty(value = "convertShowRate")
-	private BigDecimal convertShowRate;
+	///**convertShowRate*/
+	//@Excel(name = "convertShowRate", width = 15)
+	//@ApiModelProperty(value = "convertShowRate")
+	//private BigDecimal convertShowRate;
 	/**installFinishCost*/
 	@Excel(name = "installFinishCost", width = 15)
 	@ApiModelProperty(value = "installFinishCost")
 	private BigDecimal installFinishCost;
-
 	private BigDecimal downloadStartRate;
 
+	private String playableName;  //试玩素材名称
+	private String playableUrl;  //试玩素材链接
+	private Long playableId;  //试玩素材ID
+	private String playablePreviewUrl; //试玩素材预览链接
+	private String playableOrientation; //试玩素材展示方向
+	private Long poiAddressClick;  //落地页及门店数据-查看店铺地址
+	private BigDecimal attributionConvertCost;  //转化数据(计费时间)-转化成本(计费时间)
 
+	private Long clickWebsite;  //互动数据-主页内落地页访问量(主页官网访问量)
+	private Long messageAction;  //互动数据-私信数
+	private Long advancedCreativeFormSubmit;  //附加创意-附加创意表单提交
+	private Long lubanLiveSlidecartClickCnt;  //落地页及门店数据-直播间查看购物车数
+	private Long poiCollect;  //落地页及门店数据-店铺收藏
+	private Long lubanOrderCnt;  //落地页及门店数据-鲁班订单量
+	private BigDecimal attributionNextDayOpenRate;  //应用下载广告数据-次留率
+	private Long attributionNextDayOpenCnt;  //应用下载广告数据-次留数
+	private BigDecimal loanCreditRate;  //应用下载广告数据-授信率
+	private BigDecimal loanCreditCost;  //应用下载广告数据-授信成本
+	private BigDecimal lubanOrderStatAmount;  //落地页及门店数据-鲁班订单金额
+	private Long lubanLiveEnterCnt;  //落地页及门店数据-直播间观看数
+	private Long clickLandingPage;  //互动数据-推广页访问量
+	private Long lubanLiveFollowCnt;  //落地页及门店数据-直播间关注数
+	private Long clickShopwindow;  //互动数据-主页商品橱窗访问量
+	private Long attributionDeepConvert;  //转化数据(计费时间)-深度转化数(计费时间)
+	private Long lubanLivePayOrderCount ; //落地页及门店数据-直播间订单量
+	private BigDecimal lubanLivePayOrderStatCost;  //落地页及门店数据-直播间订单金额
+	private Long cardShow;  //视频数据3秒卡片展现
+	private Long preLoanCredit;  //应用下载广告数据-预授信数
+	private Long redirectToShop; //落地页及门店数据-调起店铺
+	private BigDecimal attributionDeepConvertCost;  //转化数据(计费时间)-深度转化成本(计费时间)
+	private BigDecimal preLoanCreditCost;  //应用下载广告数据-预授信成本
+	private BigDecimal avgClickCost;  //展现数据-平均点击单价
+	private Long attributionConvert;  //转化数据(计费时间)-转化数(计费时间)
+	private BigDecimal attributionNextDayOpenCost;  //应用下载广告数据-次留成本
+	private BigDecimal loanCompletionRate;  //应用下载广告数据-完件率
+	private Long clickDownload;  //互动数据-主页下载链接点击量
+	private BigDecimal loanCompletionCost;  //应用下载广告数据-完件成本
+	private BigDecimal lubanOrderRoi;  //落地页及门店数据-鲁班ROI
+	private Long loanCompletion;  //应用下载广告数据-完件数
+	private Long loanCredit; //应用下载广告数据-授信数
+	private BigDecimal avgShowCost;  //展现数据-平均千次展现费用
+	private Long clickCallDy;  //互动数据-主页内电话拨打点击量
 
 
 	public BytedanceReportPlayableDaily() {
@@ -423,37 +462,37 @@ public class BytedanceReportPlayableDaily {
 	public BytedanceReportPlayableDaily(JSONObject detailJson, Long accountId) {
 		JSONObject dimensions = detailJson.getJSONObject("dimensions");
 		this.accountId = accountId;
-		//this.setPlayableName(dimensions.getString("playable_name"));
-		//this.setPlayableUrl(dimensions.getString("playable_url"));
-		//this.setPlayableId(dimensions.getLong("playable_id"));
-		//this.setPlayablePreviewUrl(dimensions.getString("playable_preview_url"));
-		//this.setPlayableOrientation(dimensions.getString("playable_orientation"));
+		this.setPlayableName(dimensions.getString("playable_name"));
+		this.setPlayableUrl(dimensions.getString("playable_url"));
+		this.setPlayableId(dimensions.getLong("playable_id"));
+		this.setPlayablePreviewUrl(dimensions.getString("playable_preview_url"));
+		this.setPlayableOrientation(dimensions.getString("playable_orientation"));
 		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.setActivePayAmount(metrics.getInteger("active_pay_amount"));
 		this.setValidPlayCost(metrics.getBigDecimal("valid_play_cost"));
-		this.setPlay75FeedBreak(metrics.getInteger("play_75_feed_break"));
+		this.setPlay75FeedBreak(metrics.getInteger("play_75_feed_break"));  //1
 		this.setNextDayOpen(metrics.getInteger("next_day_open"));
-		this.setAdvancedCreativeCouponAddition(metrics.getInteger("advanced_creative_coupon_addition"));
-		this.setConvertMaterial(metrics.getInteger("convert"));
+		this.setAdvancedCreativeCouponAddition(metrics.getInteger("advanced_creative_coupon_addition")); //1
+		this.setConvertMaterial(metrics.getInteger("convert")); //1
 		this.setActivePayCost(metrics.getBigDecimal("active_pay_cost"));
-		this.setInAppCart(metrics.getInteger("in_app_cart"));
+		this.setInAppCart(metrics.getInteger("in_app_cart")); //1
 		this.setPlay25FeedBreak(metrics.getInteger("play_25_feed_break"));
-		this.setConsultEffective(metrics.getInteger("consult_effective"));
+		this.setConsultEffective(metrics.getInteger("consult_effective")); //1
 		this.setViewMaterial(metrics.getInteger("view"));
 		this.setDownload(metrics.getInteger("download"));
-		this.setCpa(metrics.getBigDecimal("cpa"));
-		this.setCpc(metrics.getBigDecimal("cpc"));
+		//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.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.setCpm(metrics.getBigDecimal("cpm"));
 		this.setWifiPlayRate(metrics.getBigDecimal("wifi_play_rate"));
 		this.setLikeMaterial(metrics.getInteger("like"));
 		this.setPlay50FeedBreak(metrics.getInteger("play_50_feed_break"));
@@ -464,27 +503,27 @@ public class BytedanceReportPlayableDaily {
 		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.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.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.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.setAverageVideoPlay(metrics.getBigDecimal("average_video_play"));
 		this.setDownloadFinishCost(metrics.getBigDecimal("download_finish_cost"));
-		this.setPlayDuration_3s(metrics.getInteger("play_duration_3s"));
+		//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.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.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"));
@@ -506,22 +545,59 @@ public class BytedanceReportPlayableDaily {
 		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.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.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.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"));
+
+		this.setPoiAddressClick(metrics.getLong("poi_address_click"));
+		this.setAttributionConvertCost(metrics.getBigDecimal("attribution_convert_cost"));
+		this.setClickWebsite(metrics.getLong("click_website"));
+		this.setMessageAction(metrics.getLong("message_action"));
+		this.setAdvancedCreativeFormSubmit(metrics.getLong("advanced_creative_form_submit"));
+	    this.setLubanLiveSlidecartClickCnt(metrics.getLong("luban_live_slidecart_click_cnt"));
+	    this.setPoiCollect(metrics.getLong("poi_collect"));
+		this.setLubanOrderCnt(metrics.getLong("luban_order_cnt"));
+		this.setAttributionNextDayOpenRate(metrics.getBigDecimal("attribution_next_day_open_rate"));
+		this.setAttributionNextDayOpenCnt(metrics.getLong("attribution_next_day_open_cnt"));
+		this.setLoanCreditRate(metrics.getBigDecimal("loan_credit_rate"));
+		this.setLoanCreditCost(metrics.getBigDecimal("loan_credit_cost"));
+		this.setLubanOrderStatAmount(metrics.getBigDecimal("luban_order_stat_amount"));
+		this.setLubanLiveEnterCnt(metrics.getLong("luban_live_enter_cnt"));
+		this.setClickLandingPage(metrics.getLong("click_landing_page"));
+		this.setLubanLiveFollowCnt(metrics.getLong("luban_live_follow_cnt"));
+		this.setClickShopwindow(metrics.getLong("click_shopwindow"));
+		this.setAttributionDeepConvert(metrics.getLong("attribution_deep_convert"));
+		this.setLubanLivePayOrderCount(metrics.getLong("luban_live_pay_order_count"));
+		this.setLubanLivePayOrderStatCost(metrics.getBigDecimal("luban_live_pay_order_stat_cost"));
+		this.setCardShow(metrics.getLong("card_show"));
+		this.setPreLoanCredit(metrics.getLong("pre_loan_credit"));
+		this.setRedirectToShop(metrics.getLong("redirect_to_shop"));
+		this.setAttributionDeepConvertCost(metrics.getBigDecimal("attribution_deep_convert_cost"));
+		this.setPreLoanCreditCost(metrics.getBigDecimal("pre_loan_credit_cost"));
+		this.setAvgClickCost(metrics.getBigDecimal("avg_click_cost"));
+		this.setAttributionConvert(metrics.getLong("attribution_convert"));
+		this.setAttributionNextDayOpenCost(metrics.getBigDecimal("attribution_next_day_open_cost"));
+		this.setLoanCompletionRate(metrics.getBigDecimal("loan_completion_rate"));
+		this.setClickDownload(metrics.getLong("click_download"));
+		this.setLoanCompletionCost(metrics.getBigDecimal("loan_completion_cost"));
+		this.setLubanOrderRoi(metrics.getBigDecimal("luban_order_roi"));
+		this.setLoanCompletion(metrics.getLong("loan_completion"));
+		this.setLoanCredit(metrics.getLong("loan_credit"));
+		this.setAvgShowCost(metrics.getBigDecimal("avg_show_cost"));
+		this.setClickCallDy(metrics.getLong("click_call_dy"));
 	}
 
 }

+ 62 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceReportPlayableRetry.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.toutiao.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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 org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 头条试玩报表连接出错数据记录表
+ * @author jeecg-boot
+ * @date   2020-04-21
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_report_playable_retry")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_bytedance_report_playable_retry对象", description="头条试玩报表连接出错数据记录表")
+public class BytedanceReportPlayableRetry {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+	private Integer id;
+	/**账户id*/
+	@Excel(name = "账户id", width = 15)
+    @ApiModelProperty(value = "账户id")
+	private Long accountId;
+	/**开始时间*/
+	@Excel(name = "开始时间", width = 15, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "开始时间")
+	private String startDate;
+	/**结束时间*/
+	@Excel(name = "结束时间", width = 15, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    @ApiModelProperty(value = "结束时间")
+	private String endDate;
+	/**状态 0同步失败 1同步成功*/
+	@Excel(name = "状态 0同步失败 1同步成功", width = 15)
+    @ApiModelProperty(value = "状态 0同步失败 1同步成功")
+	private Integer status;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+    private Integer statusCode;
+    private Integer type;
+}

+ 26 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportPlayableDailyMapper.java

@@ -0,0 +1,26 @@
+package cn.com.ctop.toutiao.modules.report.mapper;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportPlayableDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportPlayableRetry;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+
+public interface BytedanceReportPlayableDailyMapper extends BaseMapper<BytedanceReportPlayableDaily> {
+
+    void replaceIntoBatch(@Param("infos") List<BytedanceReportPlayableDaily> infos);
+    //
+    //void replaceIntoVideoMaterialBatch(@Param("infos") List<BytedanceReportVideoMaterialDaily> infos);
+    //
+    void replaceMaterialRetry(@Param("retry") BytedanceReportPlayableRetry retry);
+
+    List<BytedanceReportPlayableRetry> getRetryList();
+
+    void updateRetry(@Param("retry") BytedanceReportPlayableRetry retry);
+    //
+    //List<BytedanceVideoVo> getVideoVoByDate(@Param("date") String date);
+}

+ 298 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportPlayableMapper.xml

@@ -0,0 +1,298 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportPlayableDailyMapper">
+
+    <insert id="replaceIntoBatch">
+        REPLACE INTO ctop_bytedance_report_playable_daily
+        (
+        account_id,
+        playable_id,
+        playable_url,
+        playable_name,
+        playable_preview_url,
+        playable_orientation,
+        stat_datetime,
+        click,
+        cost,
+        active,
+        download_finish,
+        download_start,
+        install_finish,
+        register,
+        pay_count,
+        in_app_uv,
+        in_app_detail_uv,
+        in_app_cart,
+        in_app_order,
+        in_app_pay,
+        phone,
+        form,
+        map_search,
+        button,
+        view_material,
+        qq,
+        lottery,
+        vote,
+        redirect,
+        shopping,
+        consult,
+        wechat,
+        phone_confirm,
+        phone_connect,
+        consult_effective,
+        total_play,
+        valid_play,
+        play25_feed_break,
+        play50_feed_break,
+        play75_feed_break,
+        play100_feed_break,
+        advanced_creative_phone_click,
+        advanced_creative_counsel_click,
+        advanced_creative_form_click,
+        share_material,
+        comment_material,
+        follow,
+        home_visited,
+        ies_challenge_click,
+        ies_music_click,
+        next_day_open,
+        valid_play_cost,
+        advanced_creative_coupon_addition,
+        convert_material,
+        active_pay_cost,
+        download,
+        location_click,
+        play_over_rate,
+        ctr,
+        wifi_play_rate,
+        like_material,
+        active_pay_rate,
+        active_cost,
+        game_addiction_cost,
+        game_addiction,
+        active_rate,
+        game_addiction_rate,
+        download_finish_cost,
+        active_register_cost,
+        show_material,
+        convert_rate,
+        download_finish_rate,
+        install_finish_rate,
+        coupon,
+        coupon_single_page,
+        download_start_cost,
+        message,
+        valid_play_rate,
+        average_play_time_per_play,
+        convert_cost,
+        install_finish_cost,
+        download_start_rate,
+        poi_address_click,
+        attribution_convert_cost,
+        click_website,
+        message_action,
+        advanced_creative_form_submit,
+        luban_live_slidecart_click_cnt,
+        poi_collect,
+        luban_order_cnt,
+        attribution_next_day_open_rate,
+        attribution_next_day_open_cnt,
+        loan_credit_rate,
+        loan_credit_cost,
+        luban_order_stat_amount,
+        luban_live_enter_cnt,
+        click_landing_page,
+        luban_live_follow_cnt,
+        click_shopwindow,
+        attribution_deep_convert,
+        luban_live_pay_order_count,
+        luban_live_pay_order_stat_cost,
+        card_show,
+        pre_loan_credit,
+        redirect_to_shop,
+        attribution_deep_convert_cost,
+        pre_loan_credit_cost,
+        avg_click_cost,
+        attribution_convert,
+        attribution_next_day_open_cost,
+        loan_completion_rate,
+        click_download,
+        loan_completion_cost,
+        luban_order_roi,
+        loan_completion,
+        loan_credit,
+        avg_show_cost,
+        click_call_dy
+        )
+        VALUES
+        <foreach collection="infos" item="info" separator=",">
+      (
+        #{info.accountId},
+        #{info.playableId},
+        #{info.playableUrl},
+        #{info.playableName},
+        #{info.playablePreviewUrl},
+        #{info.playableOrientation},
+        #{info.statDatetime},
+        #{info.click},
+        #{info.cost},
+        #{info.active},
+        #{info.downloadFinish},
+        #{info.downloadStart},
+        #{info.installFinish},
+        #{info.register},
+        #{info.payCount},
+        #{info.inAppUv},
+        #{info.inAppDetailUv},
+        #{info.inAppCart},
+        #{info.inAppOrder},
+        #{info.inAppPay},
+        #{info.phone},
+        #{info.form},
+        #{info.mapSearch},
+        #{info.button},
+        #{info.viewMaterial},
+        #{info.qq},
+        #{info.lottery},
+        #{info.vote},
+        #{info.redirect},
+        #{info.shopping},
+        #{info.consult},
+        #{info.wechat},
+        #{info.phoneConfirm},
+        #{info.phoneConnect},
+        #{info.consultEffective},
+        #{info.totalPlay},
+        #{info.validPlay},
+        #{info.play25FeedBreak},
+        #{info.play50FeedBreak},
+        #{info.play75FeedBreak},
+        #{info.play100FeedBreak},
+        #{info.advancedCreativePhoneClick},
+        #{info.advancedCreativeCounselClick},
+        #{info.advancedCreativeFormClick},
+        #{info.shareMaterial},
+        #{info.commentMaterial},
+        #{info.follow},
+        #{info.homeVisited},
+        #{info.iesChallengeClick},
+        #{info.iesMusicClick},
+        #{info.validPlayCost},
+        #{info.advancedCreativeCouponAddition},
+        #{info.convertMaterial},
+        #{info.activePayCost},
+        #{info.download},
+        #{info.locationClick},
+        #{info.playOverRate},
+        #{info.ctr},
+        #{info.wifiPlayRate},
+        #{info.likeMaterial},
+        #{info.activePayRate},
+        #{info.activeCost},
+        #{info.gameAddictionCost},
+        #{info.gameAddiction},
+        #{info.activeRate},
+        #{info.gameAddictionRate},
+        #{info.activeRegisterRate},
+        #{info.downloadFinishCost},
+        #{info.activeRegisterCost},
+        #{info.showMaterial},
+        #{info.convertRate},
+        #{info.downloadFinishRate},
+        #{info.installFinishRate},
+        #{info.coupon},
+        #{info.couponSinglePage},
+        #{info.downloadStartCost},
+        #{info.message},
+        #{info.validPlayRate},
+        #{info.averagePlayTimePerPlay},
+        #{info.convertCost},
+        #{info.installFinishCost},
+        #{info.downloadStartRate},
+        #{info.poiAddressClick},
+        #{info.attributionConvertCost},
+        #{info.clickWebsite},
+        #{info.messageAction},
+        #{info.advancedCreativeFormSubmit},
+        #{info.lubanLiveSlidecartClickCnt},
+        #{info.poiCollect},
+        #{info.lubanOrderCnt},
+        #{info.attributionNextDayOpenRate},
+        #{info.attributionNextDayOpenCnt},
+        #{info.loanCreditRate},
+        #{info.loanCreditCost},
+        #{info.lubanOrderStatAmount},
+        #{info.lubanLiveEnterCnt},
+        #{info.clickLandingPage},
+        #{info.lubanLiveFollowCnt},
+        #{info.clickShopwindow},
+        #{info.attributionDeepConvert},
+        #{info.lubanLivePayOrderCount},
+        #{info.lubanLivePayOrderStatCost},
+        #{info.cardShow},
+        #{info.preLoanCredit},
+        #{info.redirectToShop},
+        #{info.attributionDeepConvertCost},
+        #{info.preLoanCreditCost},
+        #{info.avgClickCost},
+        #{info.attributionConvert},
+        #{info.attributionNextDayOpenCost},
+        #{info.loanCompletionRate},
+        #{info.clickDownload},
+        #{info.loanCompletionCost},
+        #{info.lubanOrderRoi},
+        #{info.loanCompletion},
+        #{info.loanCredit},
+        #{info.avgShowCost},
+        #{info.clickCallDy}
+         )
+        </foreach>
+    </insert>
+
+    <insert id="replaceMaterialRetry">
+        REPLACE INTO ctop_bytedance_report_playable_retry
+        (
+            account_id,
+            start_date,
+            end_date,
+            status,
+            status_code,
+            type
+        )
+        VALUES
+        (
+            #{retry.accountId},
+            #{retry.startDate},
+            #{retry.endDate},
+            #{retry.status},
+            #{retry.statusCode},
+            #{retry.type}
+        )
+
+    </insert>
+
+    <select id="getRetryList" resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceReportPlayableRetry">
+            select
+            account_id,
+            start_date,
+            end_date,
+            status,
+            type
+        from
+        ctop_bytedance_report_playable_retry
+        where status = 0
+    </select>
+
+    <update id="updateRetry">
+        update
+        ctop_bytedance_report_playable_retry
+        set
+        status = 1
+        where
+        account_id = #{retry.accountId}
+        and start_date = #{retry.startDate}
+        and end_date = #{retry.endDate}
+    </update>
+
+</mapper>
+

+ 7 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceInterfaceService.java

@@ -1,6 +1,9 @@
 package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportPlayableRetry;
+
+import java.util.List;
 
 public interface IBytedanceInterfaceService {
 
@@ -9,4 +12,8 @@ public interface IBytedanceInterfaceService {
     //头条试玩报表
     int bytedancePlayableReport(CtopOauthToken token, String startDate, String endDate);
 
+    List<BytedanceReportPlayableRetry> getRetryList();
+
+    int bytedancePlayableReportRetry(Integer type, CtopOauthToken token, String startDate, String endDate);
+
 }

+ 109 - 55
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceInterfaceServiceImpl.java

@@ -9,10 +9,9 @@ import cn.com.ctop.toutiao.modules.material.entity.ByteDanceCreative;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCampaignService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
-import cn.com.ctop.toutiao.modules.report.entity.ByteDanceOperationRecord;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
-import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportVideoMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.*;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceOperationRecordMapper;
+import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportPlayableDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -40,6 +39,8 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
     private BytedanceOperationRecordMapper bytedanceOperationRecordMapper;
     @Autowired
     private IByteDanceCreativeService byteDanceCreativeService;
+    @Autowired
+    private BytedanceReportPlayableDailyMapper bytedanceReportPlayableDailyMapper;
 
     @Override
     public void searchLog(Long accountId, CtopOauthToken token, Integer operationTarget, String startDate, String endDate){
@@ -68,7 +69,7 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
                 parameterQueryWrapper.select("id");
                 List<ByteDanceCampaign> list = byteDanceCampaignService.list(parameterQueryWrapper);
                 for (ByteDanceCampaign campaign:list){
-                    logSearchByPage(pageNum, pageSize, token, accountId, campaign.getId(), 2, startTime, endTime);  //组
+                    int code = logSearchByPage(pageNum, pageSize, token, accountId, campaign.getId(), 2, startTime, endTime);  //组
                 }
             }else if(operationTarget == 3){
                 QueryWrapper<ByteDanceAdvertisePlan> parameterQueryWrapper = new QueryWrapper<>();
@@ -76,7 +77,7 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
                 parameterQueryWrapper.select("id");
                 List<ByteDanceAdvertisePlan> list = byteDanceAdvertisePlanService.list(parameterQueryWrapper);
                 for (ByteDanceAdvertisePlan plan:list){
-                    logSearchByPage(pageNum, pageSize, token, accountId, plan.getId(), 3, startTime, endTime);  //计划
+                    int code = logSearchByPage(pageNum, pageSize, token, accountId, plan.getId(), 3, startTime, endTime);  //计划
                 }
             }else if(operationTarget == 4){
                 QueryWrapper<ByteDanceCreative> parameterQueryWrapper = new QueryWrapper<>();
@@ -84,7 +85,7 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
                 parameterQueryWrapper.select("id");
                 List<ByteDanceCreative> list = byteDanceCreativeService.list(parameterQueryWrapper);
                 for(ByteDanceCreative creative:list){
-                    logSearchByPage(pageNum, pageSize, token, accountId, creative.getId(), 4, startTime, endTime);  //创意
+                    int code = logSearchByPage(pageNum, pageSize, token, accountId, creative.getId(), 4, startTime, endTime);  //创意
                 }
             }
         }catch (Exception e){
@@ -93,7 +94,7 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
         }
     }
 
-    private void logSearchByPage(Integer pageNum, Integer pageSize, CtopOauthToken token, Long accountId, Long objectId, Integer operationType, String startTime, String endTime) {
+    private int logSearchByPage(Integer pageNum, Integer pageSize, CtopOauthToken token, Long accountId, Long objectId, Integer operationType, String startTime, String endTime) {
         log.info("当前页数:" + pageNum);
         String access_token = token.getAccessToken();
 
@@ -116,51 +117,71 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
         JSONObject json = HttpUtils.bytedanceGetRequest(access_token, open_api_domain + path, JSONObject.parseObject(JSONObject.toJSONString(data)));
         if (json == null) {
             log.error("头条日志查询返回为空,请求有误:" + JSONObject.toJSONString(data) + ";;;返回值为:"+ json);
-            return ;
+            return -2;
         }
 
-        int code =  json.getInteger("code");
-        if(code == 0){
-            List<ByteDanceOperationRecord>  records = new ArrayList<>();
-
-            JSONObject dataResultJson = json.getJSONObject("data");
-            JSONObject pageInfoJson = dataResultJson.getJSONObject("page_info");
-            int totalPage = pageInfoJson.getInteger("total_number");
-            int page = pageInfoJson.getInteger("page");
-
-            JSONArray logsArray = dataResultJson.getJSONArray("logs");
-            int logsSize = logsArray.size();
-            for (int i=0; i<logsSize ;i++){
-                JSONObject logJson =  logsArray.getJSONObject(i);
-                ByteDanceOperationRecord record = new ByteDanceOperationRecord();
-                record.setAccountId(accountId);
-                record.setContentTitle(logJson.getString("content_title"));
-                record.setContentLog(logJson.getString("content_log"));
-                record.setObjectId(logJson.getLong("object_id"));
-                record.setObjectName(logJson.getString("object_name"));
-                record.setObjectType(logJson.getString("object_type"));
-                record.setOperationCreateTime(logJson.getDate("create_time"));
-                record.setStatDate(DateUtils.formatDate(logJson.getDate("create_time")));
-                record.setOperator(logJson.getString("operator"));
-                record.setOptIp(logJson.getString("opt_ip"));
-                record.setOperationTarget(operationType);
-
-                records.add(record);
-            }
+        Integer returnCode = 200;
+        try {
+            int code = json.getInteger("code");
+            if (code == 0) {
+                List<ByteDanceOperationRecord> records = new ArrayList<>();
 
-            //按类型入库
-            if(records !=null && records.size()!=0){
-                insertLog(operationType, records);
-            }
+                JSONObject dataResultJson = json.getJSONObject("data");
+                JSONArray logsArray = dataResultJson.getJSONArray("logs");
+                JSONObject pageInfoJson = dataResultJson.getJSONObject("page_info");
 
-            if(page < totalPage){
-                logSearchByPage(page+1, pageSize, token, accountId, objectId, operationType, startTime, endTime);
+                if (Check.isNull(logsArray) || Check.isNull(pageInfoJson)) {
+                    log.error("获取任务列表返回信息data内容为空,头条accountId:" + accountId + ";返回json为:" + json + "请求为:" + JSONObject.toJSONString(data));
+                    return -1;
+                }
+
+                int totalPage = pageInfoJson.getInteger("total_number");
+                int page = pageInfoJson.getInteger("page");
+
+                if (totalPage == 0) {
+                    log.info("头条日志查询返回页数为0,请求:" + JSONObject.toJSONString(data) + ";;;返回值为:"+ json);
+                    return 1;
+                }
+
+                int logsSize = logsArray.size();
+                for (int i = 0; i < logsSize; i++) {
+                    JSONObject logJson = logsArray.getJSONObject(i);
+                    ByteDanceOperationRecord record = new ByteDanceOperationRecord();
+                    record.setAccountId(accountId);
+                    record.setContentTitle(logJson.getString("content_title"));
+                    record.setContentLog(logJson.getString("content_log"));
+                    record.setObjectId(logJson.getLong("object_id"));
+                    record.setObjectName(logJson.getString("object_name"));
+                    record.setObjectType(logJson.getString("object_type"));
+                    record.setOperationCreateTime(logJson.getDate("create_time"));
+                    record.setStatDate(DateUtils.formatDate(logJson.getDate("create_time")));
+                    record.setOperator(logJson.getString("operator"));
+                    record.setOptIp(logJson.getString("opt_ip"));
+                    record.setOperationTarget(operationType);
+
+                    records.add(record);
+                }
+
+                //按类型入库
+                if (records != null && records.size() != 0) {
+                    insertLog(operationType, records);
+                }
+
+                if (page < totalPage) {
+                    logSearchByPage(page + 1, pageSize, token, accountId, objectId, operationType, startTime, endTime);
+                }else{
+                    return 1;
+                }
+            } else {
+                log.error("头条日志查询返回为空,请求有误:" + JSONObject.toJSONString(data) + ";;;返回值为:" + json);
+                return -1;
             }
-        }else{
-            log.error("头条日志查询返回为空,请求有误:" + JSONObject.toJSONString(data)+";;;返回值为:"+ json);
-            return ;
+        }catch(Exception e){
+            e.printStackTrace();
+            log.error("头条视频素材报表其他错误,accountId:" + accountId + ",json:" + json + "请求为:" + JSONObject.toJSONString(data));
+            returnCode = -3;
         }
-        //return 200;
+        return returnCode;
     }
 
     private void insertLog(Integer operationTarget, List<ByteDanceOperationRecord> records){
@@ -175,6 +196,39 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
 
     //////////////////////////////////////////////////
 
+    @Override
+    public List<BytedanceReportPlayableRetry> getRetryList() {
+        return bytedanceReportPlayableDailyMapper.getRetryList();
+    }
+
+    @Override
+    public int bytedancePlayableReportRetry(Integer type, CtopOauthToken token, String startDate, String endDate) {
+        Long accountId = token.getAccountId();
+        log.info("头条试玩报表重试开始 当前accountId:{}  {}~{},type:{}" , accountId, startDate,endDate,type);
+        Integer page = 1;
+        Integer pageSize = 100;
+        Integer code = null;
+        code = bytedancePlayableReportByPage(page, pageSize, token, accountId, startDate, endDate);
+
+
+        BytedanceReportPlayableRetry retry = new BytedanceReportPlayableRetry();
+        retry.setAccountId(accountId);
+        retry.setStartDate(startDate);
+        retry.setEndDate(endDate);
+        retry.setStatusCode(code);
+        retry.setType(type);
+        if (code != 200 && code != 1) {
+            retry.setStatus(0);
+            bytedanceReportPlayableDailyMapper.replaceMaterialRetry(retry);
+        } else {
+            retry.setStatus(1);
+            bytedanceReportPlayableDailyMapper.replaceMaterialRetry(retry);
+        }
+        log.info("头条试玩报表重试结束 当前accountId:{}  {}~{},type:{},code:{}" , accountId, startDate,endDate,type,code);
+        return code;
+    }
+
+
 
     /**
      * 头条视频素材报表
@@ -186,21 +240,21 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
     @Override
     public int bytedancePlayableReport(CtopOauthToken token, String startDate, String endDate) {
         Long accountId = token.getAccountId();
-        log.info("头条素材报表当前accountId为:{}  {}~{},开始" , accountId, startDate,endDate);
+        log.info("头条试玩报表当前accountId为:{}  {}~{},开始" , accountId, startDate,endDate);
         Integer page = 1;
         Integer pageSize = 100;
         int code = bytedancePlayableReportByPage(page, pageSize, token, accountId, startDate, endDate);
         if (code != 200 && code != 1) {
-            BytedanceReportMaterialRetry retry = new BytedanceReportMaterialRetry();
+            BytedanceReportPlayableRetry retry = new BytedanceReportPlayableRetry();
             retry.setAccountId(accountId);
             retry.setStatus(0);
             retry.setStartDate(startDate);
             retry.setEndDate(endDate);
             retry.setStatusCode(code);
-            retry.setType(2);  //1素材报表重试,2视频素材报表重试
-            //bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
+            retry.setType(1);  //1试玩报表
+            bytedanceReportPlayableDailyMapper.replaceMaterialRetry(retry);
         }
-        log.info("头条素材报表当前accountId为:{}  {}~{},结束" , accountId, startDate,endDate);
+        log.info("头条试玩报表当前accountId为:{}  {}~{},结束" , accountId, startDate,endDate);
         return code;
     }
 
@@ -251,15 +305,15 @@ public class BytedanceInterfaceServiceImpl implements IBytedanceInterfaceService
                     return 1;
                 }
 
-                List<BytedanceReportVideoMaterialDaily> bytedanceReportVideoMaterialDailyList = new ArrayList<>();
+                List<BytedanceReportPlayableDaily> bytedanceReportPlayableDailyList = new ArrayList<>();
                 for (int i = 0; i < jsonArrayay.size(); i++) {
                     JSONObject detailJson = jsonArrayay.getJSONObject(i);
                     if (!Check.isNull(detailJson)) {
-                        BytedanceReportVideoMaterialDaily daily = new BytedanceReportVideoMaterialDaily(detailJson, accountId);
-                        bytedanceReportVideoMaterialDailyList.add(daily);
+                        BytedanceReportPlayableDaily daily = new BytedanceReportPlayableDaily(detailJson, accountId);
+                        bytedanceReportPlayableDailyList.add(daily);
                     }
                 }
-                //bytedanceReportMaterialDailyMapper.replaceIntoVideoMaterialBatch(bytedanceReportVideoMaterialDailyList);
+                bytedanceReportPlayableDailyMapper.replaceIntoBatch(bytedanceReportPlayableDailyList);
                 if (currentPage >= totalPage) {
                     log.info("头条视频素材报表当前accountId为:{}  {}~{},接口数据拉取成功" , accountId, startDate,endDate);
                     return 1;