浏览代码

Merge branch 'test'

yumeng 5 年之前
父节点
当前提交
671ca1ac75
共有 80 个文件被更改,包括 1475 次插入611 次删除
  1. 4 6
      jeecg-boot-base-common/src/main/java/org/jeecg/common/system/vo/LoginUser.java
  2. 26 3
      jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java
  3. 3 9
      jeecg-boot-module-system/pom.xml
  4. 0 67
      jeecg-boot-module-system/src/main/java/org/jeecg/config/RabbitConfig.java
  5. 0 3
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  6. 19 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  7. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialCutFrameController.java
  8. 10 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java
  9. 13 21
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/PangolinController.java
  10. 3 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  11. 2 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  12. 24 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  13. 58 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/CutFrameJob.java
  14. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCrawlerJob.java
  15. 1 14
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/PangolinDataJob.java
  16. 22 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/CreateInternalServiceImpl.java
  17. 2 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  18. 0 20
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Receiver.java
  19. 0 27
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Sender.java
  20. 2 7
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  21. 0 5
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  22. 12 18
      jeecg-boot-module-system/src/main/resources/application-test.yml
  23. 98 66
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  24. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/constant/CtopRoleCodeConstant.java
  25. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/constant/OssConstant.java
  26. 3 3
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialCutFrame.java
  27. 63 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialCutFrameTask.java
  28. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java
  29. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/CtopOauthTokenMapper.java
  30. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialCutFrameTaskMapper.java
  31. 4 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  32. 9 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  33. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialCutFrameTaskMapper.xml
  34. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  35. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  36. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialCutFrameService.java
  37. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialCutFrameTaskService.java
  38. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  39. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  40. 117 59
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameServiceImpl.java
  41. 19 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameTaskServiceImpl.java
  42. 18 16
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  43. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  44. 12 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java
  45. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java
  46. 5 6
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/service/IKuaishouCrawlerService.java
  47. 2 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinCrawlerService.java
  48. 1 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinLoginService.java
  49. 13 0
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinCrawlerServiceImpl.java
  50. 33 33
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinLoginServiceImpl.java
  51. 16 1
      module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportAppHourServiceImpl.java
  52. 1 1
      module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java
  53. 3 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/service/IKuaishouAppService.java
  54. 25 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  55. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java
  56. 36 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/ConvertVo.java
  57. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouImageGetMapper.java
  58. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  59. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouImageGetMapper.xml
  60. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  61. 32 20
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  62. 9 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouImageGetServiceImpl.java
  63. 43 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  64. 19 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/AccountReportDTO.java
  65. 38 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/ByteDanceVideoReportDailyController.java
  66. 34 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceAdvertiserDailyReportController.java
  67. 17 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceHomepageReportCtrl.java
  68. 70 12
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java
  69. 3 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/ByteDanceVideoReportDailyMapper.java
  70. 7 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceHomepageMapper.java
  71. 24 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/ByteDanceVideoReportDailyMapper.xml
  72. 143 25
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml
  73. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IByteDanceVideoReportDailyService.java
  74. 4 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceHomepageReportService.java
  75. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceReportService.java
  76. 51 78
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ByteDanceVideoReportDailyServiceImpl.java
  77. 44 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAdvertiserDailyReportServiceImpl.java
  78. 100 41
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceHomepageReportServiceImpl.java
  79. 4 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportServiceImpl.java
  80. 26 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

+ 4 - 6
jeecg-boot-base-common/src/main/java/org/jeecg/common/system/vo/LoginUser.java

@@ -1,14 +1,12 @@
 package org.jeecg.common.system.vo;
 
-import java.util.Date;
-
-import org.springframework.format.annotation.DateTimeFormat;
-
 import com.fasterxml.jackson.annotation.JsonFormat;
-
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 /**
  * <p>
@@ -73,7 +71,7 @@ public class LoginUser {
 	 * 状态(1:正常 2:冻结 )
 	 */
 	private Integer status;
-	
+
 	private String delFlag;
 	/**
      * 同步工作流引擎1同步0不同步

+ 26 - 3
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -20,7 +20,7 @@ import java.util.*;
  */
 public class DateUtils extends PropertyEditorSupport {
 
-    private static Logger logger= LoggerFactory.getLogger(DateUtils.class);
+    private static Logger logger = LoggerFactory.getLogger(DateUtils.class);
 
     /**
      * 以毫秒表示的时间
@@ -1227,7 +1227,7 @@ public class DateUtils extends PropertyEditorSupport {
             e.printStackTrace();
         }
         //得到相差的天数 betweenDate
-        return  (endDate.getTime() - startDate.getTime())/(60*60*24*1000);
+        return (endDate.getTime() - startDate.getTime()) / (60 * 60 * 24 * 1000);
     }
 
     /***
@@ -1313,8 +1313,31 @@ public class DateUtils extends PropertyEditorSupport {
         return calendar.getTime();
     }
 
+
+    public static List<Date> findDates(Date dBegin, Date dEnd) {
+        List<Date> lDate = new ArrayList<Date>();
+        lDate.add(dBegin);
+        Calendar calBegin = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calBegin.setTime(dBegin);
+        Calendar calEnd = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calEnd.setTime(dEnd);
+        // 测试此日期是否在指定日期之后
+        while (dEnd.after(calBegin.getTime())) {
+            // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
+            calBegin.add(Calendar.DAY_OF_MONTH, 1);
+            lDate.add(calBegin.getTime());
+        }
+        return lDate;
+    }
+
+
     public static void main(String[] args) throws ParseException {
-        System.out.println(calDiffMonth(DateUtils.parseDate("2019-04-01", "yyyy-MM-dd"), new Date()));
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String s = DateUtils.addDay(nowDate, -180);
+        System.err.println(nowDate);
+        System.err.println(s);
     }
 
 }

+ 3 - 9
jeecg-boot-module-system/pom.xml

@@ -41,12 +41,6 @@
     </repositories>
 
     <dependencies>
-        <!-- rabbitmq 依赖jar包-->
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-amqp</artifactId>
-            <version>1.5.2.RELEASE</version>
-        </dependency>
         <dependency>
             <groupId>org.jeecgframework.boot</groupId>
             <artifactId>jeecg-boot-base-common</artifactId>
@@ -130,9 +124,9 @@
             <version>3.17</version>
         </dependency>
         <dependency>
-        <groupId>org.apache.poi</groupId>
-        <artifactId>poi-ooxml-schemas</artifactId>
-        <version>3.17</version>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml-schemas</artifactId>
+            <version>3.17</version>
         </dependency>
 
         <dependency>

+ 0 - 67
jeecg-boot-module-system/src/main/java/org/jeecg/config/RabbitConfig.java

@@ -1,67 +0,0 @@
-package org.jeecg.config;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.Queue;
-import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
-import org.springframework.amqp.rabbit.connection.ConnectionFactory;
-import org.springframework.amqp.rabbit.core.RabbitTemplate;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Scope;
-
-@Configuration
-@Slf4j
-public class RabbitConfig {
-    @Value("${spring.rabbitmq.host}")
-    private String host;
-
-    @Value("${spring.rabbitmq.port}")
-    private int port;
-
-    @Value("${spring.rabbitmq.username}")
-    private String username;
-
-    @Value("${spring.rabbitmq.password}")
-    private String password;
-
-
-    public static final String EXCHANGE_A = "my-mq-exchange_A";
-    public static final String EXCHANGE_B = "my-mq-exchange_B";
-    public static final String EXCHANGE_C = "my-mq-exchange_C";
-
-
-    public static final String QUEUE_A = "QUEUE_A";
-    public static final String QUEUE_B = "QUEUE_B";
-    public static final String QUEUE_C = "QUEUE_C";
-
-    public static final String ROUTINGKEY_A = "spring-boot-routingKey_A";
-    public static final String ROUTINGKEY_B = "spring-boot-routingKey_B";
-    public static final String ROUTINGKEY_C = "spring-boot-routingKey_C";
-
-    @Bean
-    public ConnectionFactory connectionFactory() {
-        CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host, port);
-        connectionFactory.setUsername(username);
-        connectionFactory.setPassword(password);
-        connectionFactory.setVirtualHost("/");
-        connectionFactory.setPublisherConfirms(true);
-        return connectionFactory;
-    }
-
-    /**
-     * 必须是prototype类型
-     */
-    @Bean
-    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-    public RabbitTemplate rabbitTemplate() {
-        RabbitTemplate template = new RabbitTemplate(connectionFactory());
-        return template;
-    }
-
-    @Bean
-    public Queue helloQueue() {
-        return new Queue("hello");
-    }
-}

+ 0 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -81,8 +81,6 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ctop/byteDance/homePage/report/*", "anon");
         filterChainDefinitionMap.put("/ctop/material/top/cost", "anon");
 
-        filterChainDefinitionMap.put("/pangolin/**", "anon");
-
         filterChainDefinitionMap.put("/generic/**", "anon");
         filterChainDefinitionMap.put("/", "anon");
         filterChainDefinitionMap.put("/doc.html", "anon");
@@ -144,7 +142,6 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/ks/web/test", "anon");
         filterChainDefinitionMap.put("/ureport/**", "anon");
         filterChainDefinitionMap.put("/ctop/advertiser/**", "anon");
-        filterChainDefinitionMap.put("/pangolin/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
@@ -78,7 +79,7 @@ public class AdvertiserController {
         try {
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
             QueryWrapper<Advertiser> queryWrapper = new QueryWrapper<>();
-            if (!"admin".equals(roleCode)) {
+            if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
                 QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
                 userCompanyQueryWrapper.eq("user_id", userId);
                 userCompanyQueryWrapper.orderByDesc("create_time");
@@ -115,7 +116,7 @@ public class AdvertiserController {
         Result<IPage<Advertiser>> result = new Result<>();
         String roleCode = sysRoleService.getRoleCodeByUserId(advertiser.getUserId());
         String userId = advertiser.getUserId();
-        if ("admin".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
+        if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
             advertiser.setUserId(null);
         }
         String industryId = advertiser.getIndustryId();
@@ -384,6 +385,14 @@ public class AdvertiserController {
                 }
             }
         }
+
+        List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, systemType);
+        if (null != allocations && !allocations.isEmpty()) {
+            for (UserAllocation allocation : allocations) {
+                SheetInfoVo vo = advertiserService.getXxlStatisticInfo(projectId, systemType, allocation.getAccountId(), allocation.getAuthName());
+                sheets.add(vo);
+            }
+        }
         result.put("data", sheets);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);
         return result;
@@ -413,6 +422,14 @@ public class AdvertiserController {
             }
         }
 
+        List<UserAllocation> allocations = userAllocationService.getByProjectId(projectId, systemType);
+        if (null != allocations && !allocations.isEmpty()) {
+            for (UserAllocation allocation : allocations) {
+                SheetInfoVo vo = advertiserService.getXxlStatisticInfo(projectId, systemType, allocation.getAccountId(), allocation.getAuthName());
+                sheets.add(vo);
+            }
+        }
+
         OutputStream outputStream = response.getOutputStream();
         String date = DateUtils.formatDate(new Date());
         HttpUtils.setResponseHeader(response, "爱上消消消日报" + date + ".xls");

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

@@ -51,6 +51,7 @@ public class MaterialCutFrameController {
                                                          HttpServletRequest req) {
         Result<IPage<MaterialCutFrame>> result = new Result<IPage<MaterialCutFrame>>();
         QueryWrapper<MaterialCutFrame> queryWrapper = QueryGenerator.initQueryWrapper(materialCutFrame, req.getParameterMap());
+        queryWrapper.orderByAsc("image_index");
         Page<MaterialCutFrame> page = new Page<MaterialCutFrame>(pageNo, pageSize);
         IPage<MaterialCutFrame> pageList = materialCutFrameService.page(page, queryWrapper);
         result.setSuccess(true);
@@ -58,6 +59,7 @@ public class MaterialCutFrameController {
         return result;
     }
 
+
     /**
      * 添加
      *

+ 10 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MaterialInfoController.java

@@ -1,6 +1,7 @@
 package org.jeecg.modules.ctop.controller;
 
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.*;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.Check;
@@ -24,6 +25,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
+import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.service.IKuaiShouUploadService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.ctop.service.IProjectService;
@@ -168,7 +170,7 @@ public class MaterialInfoController {
         materialInfo.setCreateTime(null);
         if (!Check.isNull(materialInfo.getUserId())) {
             String roleCode = materialInfoService.getRoleCodeByUserId(materialInfo.getUserId());
-            if ("admin".equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
+            if (CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "operator".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "operationAssistant".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
                 materialInfo.setUserId(null);
                 queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
             } else if ("designTeamLeader".equals(roleCode) || "planeLeader".equals(roleCode) || "plane".equals(roleCode) || "plan".equals(roleCode) || "shot".equals(roleCode)) {
@@ -232,12 +234,17 @@ public class MaterialInfoController {
                     material.setKuaiShou(JSONObject.parseObject(kuaiShouString));
                 }
 
+
+                Project project = projectService.getById(material.getProjectId());
+                if (!Check.isNull(project)) {
+                    material.setMediaId(project.getMediaId());
+                    material.setProjectName(project.getProjectName());
+                }
                 /*JSONObject generalizationJson = materialInfoService.getGeneralizationInfo(material.getCode());
                 if (!Check.isNull(generalizationJson)) {
-                    material.setGeneralization(generalizationJson);
+                    material.setGeneralization(generaliz  ationJson);
                 }*/
 
-
                 QueryWrapper<MaterialImageInfo> imageInfoQueryWrapper = new QueryWrapper<>();
                 imageInfoQueryWrapper.eq("video_id", material.getCode());
                 imageInfoQueryWrapper.eq("status", 0);

+ 13 - 21
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/PangolinController.java

@@ -1,6 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
-import cn.com.ctop.common.module.service.IBindAccountLoginService;
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.ResultMapUtils;
 import cn.com.ctop.common.module.utils.StatusCode;
@@ -34,16 +34,13 @@ public class PangolinController {
     private PangolinChannelService pangolinChannelService;
     @Autowired
     private ISysRoleService sysRoleService;
-    @Autowired
-    private IBindAccountLoginService bindAccountLoginService;
 
     @PostMapping("api/channel/list")
     public Map<String, Object> channelList(@RequestBody JSONObject data) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = user.getId();
-//        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         return pangolinChannelService.getListByUserId(userId);
@@ -52,10 +49,9 @@ public class PangolinController {
     @PostMapping("api/app/list")
     public Map<String, Object> appList(@RequestBody JSONObject data) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        String userId = user.getId();
-        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
+        String userId = user.getId();
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         return pangolinAppService.getListByUserId(userId,data);
@@ -66,11 +62,10 @@ public class PangolinController {
     public Map<String,Object> memberList(){
         Map<String, Object> resultMap = new HashMap<>();
         try {
-//            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//            String userId = user.getId();
-            String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
+            LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            String userId = user.getId();
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-            if (null!=roleCode&&"admin".equals(roleCode)) {
+            if (null!=roleCode&&CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
                 userId = null;
             }
             resultMap = pangolinAppService.getMemberList(userId);
@@ -88,10 +83,9 @@ public class PangolinController {
     @PostMapping("api/realtime")
     public Map<String, Object> realTime(@RequestBody JSONObject data) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        String userId = user.getId();
-        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
+        String userId = user.getId();
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         return pangolinReportAppHourService.getRealTimeData(userId,data);
@@ -103,10 +97,9 @@ public class PangolinController {
     @PostMapping("api/activation/list")
     public Map<String, Object> activationList(@RequestBody JSONObject data) {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        String userId = user.getId();
-        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
+        String userId = user.getId();
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         return pangolinReportChannelDailyService.getActivationList(userId, data);
@@ -119,10 +112,9 @@ public class PangolinController {
     public Map<String,Object> checkAppList(@RequestBody JSONObject data) {
         Map<String,Object> result = new HashMap<>();
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-//        String userId = user.getId();
-        String userId = "6b4c821adc414dc8b7718ab63ccbfcaf";
+        String userId = user.getId();
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-        if(null!=roleCode&&(roleCode.equals("admin"))){
+        if(null!=roleCode&&(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN))){
             userId = null;
         }
         PageInfo<PangolinReportAppMonthVO> pageInfo = pangolinReportBillMonthService.checkAppList(userId, data);

+ 3 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
@@ -100,7 +101,7 @@ public class ProjectController {
         String roleCode = sysRoleService.getRoleCodeByUserId(userId);
         QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
         List<Project> projects = new ArrayList<>();
-        if (!"admin".equals(roleCode) && !"sale".equals(roleCode) && !"saleDirector".equals(roleCode)) {
+        if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) && !"sale".equals(roleCode) && !"saleDirector".equals(roleCode)) {
             if ("designTeamLeader".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "planeLeader".equals(roleCode)) {
                 QueryWrapper<ProjectMember> memberQueryWrapper = new QueryWrapper<>();
                 memberQueryWrapper.eq("user_id", userId);
@@ -178,7 +179,7 @@ public class ProjectController {
         Page<Project> page = new Page<>(pageNo, pageSize);
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String roleCode = sysRoleService.getRoleCodeByUserId(sysUser.getId());
-        if (!("admin".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode))) {
+        if (!(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode))) {
             queryWrapper.eq("user_id", sysUser.getId());
             queryWrapper.orderByDesc("create_time");
         }

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONArray;
@@ -91,7 +92,7 @@ public class ProjectMemberController {
         try {
             QueryWrapper<ProjectMember> queryWrapper = new QueryWrapper<>();
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-            if (!"admin".equals(roleCode) && !"sale".equals(roleCode) && !"saleDirector".equals(roleCode)) {
+            if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) && !"sale".equals(roleCode) && !"saleDirector".equals(roleCode)) {
                 queryWrapper.eq("user_id", userId);
             }
             queryWrapper.groupBy("project_id");

+ 24 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ISysRoleService;
@@ -54,7 +55,6 @@ public class UserAllocationController {
     @Autowired
     private IProjectMemberService projectMemberService;
 
-
     @GetMapping(value = "/accountTurnProject")
     public Result<Object> getAccountList(Long accountId, Long projectId) {
         Result<Object> result = new Result<>();
@@ -155,7 +155,7 @@ public class UserAllocationController {
             }*/
 
             String roleCode = sysRoleService.getRoleCodeByUserId(userId);
-            if (!"admin".equals(roleCode) && !"kuaishouOperationManager".equals(roleCode) && !"designTeamLeader".equals(roleCode) && !"touTiaoOperationManager".equals(roleCode)) {
+            if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode) && !"kuaishouOperationManager".equals(roleCode) && !"designTeamLeader".equals(roleCode) && !"touTiaoOperationManager".equals(roleCode)) {
                 queryWrapper.eq("user_id", userId);
             }
             queryWrapper.orderByDesc("create_time");
@@ -224,7 +224,7 @@ public class UserAllocationController {
         LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         QueryWrapper<UserAllocation> queryWrapper = QueryGenerator.initQueryWrapper(userAllocation, req.getParameterMap());
         String roleCode = sysRoleService.getRoleCodeByUserId(user.getId());
-        if (!"admin".equals(roleCode)) {
+        if (!CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN.equals(roleCode)) {
             queryWrapper.eq("user_id", user.getId());
             queryWrapper.orderByDesc("id");
         }
@@ -357,4 +357,25 @@ public class UserAllocationController {
         }
         return result;
     }
+
+    /**
+     * 统计报表 查看所有账号
+     *
+     * @param projectId
+     * @return
+     */
+    @GetMapping(value = "/selectAccountListByProjectId")
+    public Result<List<UserAllocation>> selectAccountListByProjectId(Long projectId) {
+        Result<List<UserAllocation>> result = new Result<>();
+        try {
+            List<UserAllocation> userAllocations = userAllocationService.selectAccountListByProjectId(projectId);
+            result.setSuccess(true);
+            result.setResult(userAllocations);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.success("查询失败");
+        }
+        return result;
+    }
+
 }

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

@@ -0,0 +1,58 @@
+package org.jeecg.modules.ctop.job;
+
+import cn.com.ctop.common.module.entity.MaterialCutFrameTask;
+import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.service.IMaterialCutFrameTaskService;
+import cn.com.ctop.common.module.utils.Check;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.concurrent.Executors;
+
+import static org.jeecg.modules.ctop.job.KuaishouDailyGroupReportLoadJob.executorService;
+
+/**
+ * 获取抽帧视频
+ */
+@Slf4j
+public class CutFrameJob implements Job {
+    @Autowired
+    private IMaterialCutFrameService materialCutFrameService;
+    @Autowired
+    private IMaterialCutFrameTaskService taskService;
+
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
+        Thread thread = new Thread() {
+            @Override
+            public void run() {
+
+                QueryWrapper<MaterialCutFrameTask> taskQueryWrapper = new QueryWrapper<>();
+                taskQueryWrapper.eq("job_status", 0);
+                List<MaterialCutFrameTask> list = taskService.list(taskQueryWrapper);
+
+                if (Check.isNull(list)) {
+                    return;
+                }
+                executorService = Executors.newFixedThreadPool(5);
+                list.forEach(cutFrameTask -> {
+                    executorService.submit(new Runnable() {
+                        @Override
+                        public void run() {
+                            //获取广告计划信息数据
+                            materialCutFrameService.loadCutFrame(cutFrameTask.getJobId(), cutFrameTask.getVideoSignature());
+                        }
+                    });
+                });
+            }
+        };
+        thread.start();
+
+
+    }
+}

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouCrawlerJob.java

@@ -24,7 +24,7 @@ public class KuaishouCrawlerJob implements Job {
     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
         try {
             Integer page = 1;
-            QueryWrapper<KuaishouAppAccount> queryWrapper = new QueryWrapper<KuaishouAppAccount>();
+            QueryWrapper<KuaishouAppAccount> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("path","/rest/n/feed/hot");
             List<KuaishouAppAccount> list = kuaishouAppAccountService.list(queryWrapper);
             if (list != null) {
@@ -37,7 +37,7 @@ public class KuaishouCrawlerJob implements Job {
                 }
             }
 
-            QueryWrapper<KuaishouIosAccount> queryWrapper2 = new QueryWrapper<KuaishouIosAccount>();
+            QueryWrapper<KuaishouIosAccount> queryWrapper2 = new QueryWrapper<>();
             queryWrapper2.eq("path","/rest/n/feed/hot");
             List<KuaishouIosAccount> list2 = kuaishouIosAccountService.list(queryWrapper2);
             if (list2 != null) {

+ 1 - 14
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/PangolinDataJob.java

@@ -2,11 +2,8 @@ package org.jeecg.modules.ctop.job;
 
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
-import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
-import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import org.jeecg.common.util.DateUtils;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -18,8 +15,6 @@ public class PangolinDataJob implements Job {
     @Autowired
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
-    private PangolinAppService pangolinAppService;
-    @Autowired
     private PangolinCrawlerService pangolinCrawlerService;
 
     @Override
@@ -31,15 +26,7 @@ public class PangolinDataJob implements Job {
         List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
         if (list != null && !list.isEmpty()) {
             for (BindAccountLogin bindAccountLogin : list) {
-                pangolinCrawlerService.getChannelList(bindAccountLogin);
-                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
-                pangolinCrawlerService.getCheckList(bindAccountLogin);
-                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
-                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
-                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
-                if (appList != null && !appList.isEmpty()) {
-                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getId()));
-                }
+                pangolinCrawlerService.getNowData(bindAccountLogin);
             }
         }
     }

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

@@ -5,6 +5,8 @@ import cn.com.ctop.common.module.mapper.BindAccountLoginMapper;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.crawler.modules.core.util.FateadmHttpUtil;
 import cn.com.ctop.crawler.modules.core.util.FateadmUtil;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
 import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -33,6 +35,10 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
     private String chromeDriver;
     @Autowired
     private BindAccountLoginMapper bindAccountLoginMapper;
+    @Autowired
+    private PangolinLoginService pangolinLoginService;
+    @Autowired
+    private PangolinCrawlerService pangolinCrawlerService;
 
     @Override
     public Map<String, Object> bindLogin(Long projectId,String advertiserId, String accountName, String password, String loginType, String userId, String advertiserName) {
@@ -49,7 +55,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         if (null != loginType && loginType.equals(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_PY)) {
             Map<String, Object> result = this.checkAccountPassword(accountName, password);
             Boolean checkSuccess = (Boolean) result.get("success");
-            if (!checkSuccess) {
+            if (Boolean.FALSE.equals(checkSuccess)) {
                 returnMap.put("success", false);
                 returnMap.put("message", "账号验证失败");
                 return returnMap;
@@ -67,6 +73,20 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
         int i = bindAccountLoginMapper.insert(bindAccountLogin);
         if (i > 0) {
             log.info("登录账号绑定成功,广告主id:{}", bindAccountLogin.getAdvertiserId());
+            if(null!=loginType&&loginType.equals(CtopAdConstant.PLATFORM_TYPE_PANGOLIN_PY)){
+                //穿山甲账户绑定
+                Thread thread = new Thread(){
+                    @Override
+                    public void run() {
+                        //1:登录
+                        pangolinLoginService.pangolinLogin(bindAccountLogin.getAccountName(), bindAccountLogin.getPassword());
+                        //2:拉取数据
+                        pangolinCrawlerService.getNowData(bindAccountLogin);
+                    }
+                };
+                thread.start();
+            }
+
             returnMap.put("success", true);
             returnMap.put("accountUd", password);
         }
@@ -164,7 +184,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 }
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage(),e);
             ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SERVER_ERROR.getCode());
         } finally {
             //清除所有的缓存

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.ctop.service.impl;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.Check;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -13,7 +14,6 @@ import org.jeecg.modules.system.entity.SysUser;
 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;
@@ -78,7 +78,7 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
             projectMemberList = memberMapper.designProjects(userId, mediaIds);
         }else if( roleCode.equals("designTeamLeader")){
             projectMemberList = memberMapper.designLeaderProjects(companyId, mediaIds);
-        }else if(roleCode.equals("admin")){
+        }else if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             projectMemberList = memberMapper.adminProjects(mediaIds);
         }else if(roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")){
             projectMemberList = memberMapper.operationProjects(userId, mediaIds);

+ 0 - 20
jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Receiver.java

@@ -1,20 +0,0 @@
-package org.jeecg.modules.mq;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.rabbit.annotation.Queue;
-import org.springframework.amqp.rabbit.annotation.RabbitHandler;
-import org.springframework.amqp.rabbit.annotation.RabbitListener;
-import org.springframework.stereotype.Component;
-
-@Slf4j
-@Component
-@RabbitListener(queuesToDeclare = @Queue("hello"))
-public class Receiver {
-    /**
-     * 通过@RabbitHandler声明的方法,对hello队列中的消息进行处理
-     */
-    @RabbitHandler
-    public void receiver(String str) {
-        log.info("Receiver says:[" + str + "]");
-    }
-}

+ 0 - 27
jeecg-boot-module-system/src/main/java/org/jeecg/modules/mq/Sender.java

@@ -1,27 +0,0 @@
-package org.jeecg.modules.mq;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.amqp.core.AmqpTemplate;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author jeecg-boot
- * 2019年12月5日19:57:58
- */
-@Component
-@Slf4j
-public class Sender {
-
-    @Autowired
-    AmqpTemplate rabbitmqTemplate;
-
-    /**
-     * 发送消息
-     */
-    public void send() {
-        String content = "Sender says:" + "'hello, I'm sender'";
-        log.info(content);
-        rabbitmqTemplate.convertAndSend("hello", content);
-    }
-}

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

@@ -14,11 +14,6 @@ management:
         include: metrics,httptrace
 
 spring:
-  rabbitmq:
-    host: 39.106.184.70
-    port: 5672
-    username: guest
-    password: guest
   servlet:
     multipart:
       max-file-size: -1
@@ -99,7 +94,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          url: jdbc:mysql://39.97.120.42:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
           password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver
@@ -135,7 +130,7 @@ mybatis-plus:
       table-underline: true
     configuration:
       # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
-      log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+      #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 #jeecg专用配置
 jeecg:
   ffmpeg:

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

@@ -12,11 +12,6 @@ management:
       exposure:
         include: metrics,httptrace
 spring:
-  rabbitmq:
-    host: 39.106.184.70
-    port: 5672
-    username: guest
-    password: guest
   servlet:
     multipart:
       max-file-size: -1

+ 12 - 18
jeecg-boot-module-system/src/main/resources/application-test.yml

@@ -14,11 +14,6 @@ management:
         include: metrics,httptrace
 
 spring:
-  rabbitmq:
-    host: 39.106.184.70
-    port: 5672
-    username: guest
-    password: guest
   servlet:
     multipart:
       max-file-size: -1
@@ -34,6 +29,9 @@ spring:
           starttls:
             enable: true
             required: true
+  ## quartz定时任务,采用数据库方式
+  quartz:
+    job-store-type: jdbc
   #json 时间戳统一转换
   jackson:
     date-format:   yyyy-MM-dd HH:mm:ss
@@ -41,6 +39,7 @@ spring:
   aop:
     proxy-target-class: true
   #配置freemarker
+  #配置freemarker
   freemarker:
     # 设置模板后缀名
     suffix: .ftl
@@ -95,11 +94,11 @@ spring:
         filters: stat,slf4j
         # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
-#      datasource:
-#        master:
-#          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-#          username: hcst
-#          password: test@20190531
+      #      datasource:
+      #        master:
+      #          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+      #          username: hcst
+      #          password: test@20190531
       datasource:
         master:
           url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
@@ -130,11 +129,8 @@ mybatis-plus:
       id-type: 4
       # 默认数据库表下划线命名
       table-underline: true
-  configuration:
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
-
-    # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
-      #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+  # configuration:
+  #  map-underscore-to-camel-case: false
   #分页pageHelper
 pagehelper:
   helper-dialect: mysql
@@ -167,10 +163,8 @@ logging:
 chrome:
   script:
     clean: sh /mnt/webapp/cleanProcess.sh
-
-
 oss:
   replace:
-    replace-value: oss-cn-beijing-internal
+    replace-value: oss-cn-beijing
     replace-old-value: oss-cn-beijing
     download: /mnt/file/video/

+ 98 - 66
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,12 +5,15 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
-import cn.com.ctop.crawler.modules.oceanengine.entity.HotMaterial;
-import cn.com.ctop.crawler.modules.oceanengine.service.IHotMaterialService;
-import cn.com.ctop.crawler.modules.oceanengine.service.IOceanEngineService;
+import cn.com.ctop.crawler.modules.pangolin.entity.PangolinApp;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinAppService;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinCrawlerService;
+import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
-import cn.com.ctop.toutiao.modules.report.service.IBytedanceFundDailyService;
-import com.xxl.job.core.log.XxlJobLogger;
+import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
+import cn.com.ctop.toutiao.modules.report.service.IReportService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.DateUtils;
 import org.junit.Test;
@@ -19,6 +22,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -30,26 +35,40 @@ import java.util.concurrent.Executors;
 @Slf4j
 public class SampleTest {
     @Autowired
-    private IOceanEngineService oceanEngineService;
+    private IBytedanceReportService bytedanceReportService;
     @Autowired
-    private IHotMaterialService hotMaterialService;
+    private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private IReportService reportService;
+
     @Test
-    public void initImageUrl(){
-        List<HotMaterial> hotMaterials =  hotMaterialService.getId();
-        if(null!=hotMaterials&&!hotMaterials.isEmpty()){
-            hotMaterials.forEach(douyinHot -> {
-                HotMaterial getHot = hotMaterialService.getById(douyinHot.getId());
-//                String image = getHot.getCoverImage().replace("data:image/jpg;base64,", "");
-                String destPath = "D:\\data\\effectCase\\";
-                String fileName = getHot.getId()+".jpg";
-//                EffectCase.base64ToFile(destPath,image,fileName);
-            });
+    public void testOceanEngineJob() {
+        try {
+            CtopOauthToken byId = oauthTokenService.getById(1654059015242756L);
+
+          /*  SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date start = simpleDateFormat.parse("2020-01-01");
+            Date end = simpleDateFormat.parse("2020-06-03");*/
+
+
+            String nowDate = "2020-06-03";
+            String endDate = "2020-01-01";
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date start = simpleDateFormat.parse(nowDate);
+            Date end = simpleDateFormat.parse(endDate);
+            List<Date> dates = DateUtils.findDates(end, start);
+            for (int i = 0; i < dates.size(); i++) {
+                String formatDate = simpleDateFormat.format(dates.get(i));
+                Date parse = simpleDateFormat.parse(formatDate);
+                reportService.getAdvertiserReport(byId, parse, parse, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
-    }
-    @Test
-    public void testOceanEngineJob(){
-        String account="3248395570@qq.com";
-        String password = "Ydxq-704127411";
+        String account = "3248395570@qq.com";
+       /* String password = "Ydxq-704127411";
         oceanEngineService.login(account,password);
         oceanEngineService.douyinHotHandler(1,1);
         oceanEngineService.effectCaseHandler(1);
@@ -58,45 +77,48 @@ public class SampleTest {
         oceanEngineService.hotMaterialHandler(1,1,"西瓜");
         oceanEngineService.hotMaterialHandler(1,3,"火山");
         oceanEngineService.hotMaterialHandler(1,9,"穿山甲");
-        log.info("巨量创意抓取完成");
+        log.info("巨量创意抓取完成");*/
     }
 
     @Autowired
     private IBindAccountLoginService bindAccountLoginService;
     @Autowired
     private IKuaishouWebInterfaceService kuaishouWebInterfaceService;
+
     @Test
-    public void kuaishouLogin(){
-        Long start =System.currentTimeMillis();
-        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
-        if(list!=null&&!list.isEmpty()){
-            for (BindAccountLogin login:list) {
-                if(null==login.getCookie()||"".equals(login.getCookie().trim())){
+    public void kuaishouLogin() {
+        Long start = System.currentTimeMillis();
+        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
+        if (list != null && !list.isEmpty()) {
+            for (BindAccountLogin login : list) {
+                if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
                     kuaishouWebInterfaceService.getkuaishouWebLoginCookie(login);
                 }
             }
         }
         Long end = System.currentTimeMillis();
-        log.info("总用时:{}毫秒",end-start);
+        log.info("总用时:{}毫秒", end - start);
     }
+
     static ExecutorService executorService = null;
     static CountDownLatch countDownLatch = null;
+
     @Test
-    public void kuaishouCommentDelete(){
-        Long start =System.currentTimeMillis();
-        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY,1);
-        if(list!=null&&!list.isEmpty()){
+    public void kuaishouCommentDelete() {
+        Long start = System.currentTimeMillis();
+        List<BindAccountLogin> list = bindAccountLoginService.getListByParams(CtopAdConstant.PLATFORM_TYPE_KUAISHOU_PY, 1);
+        if (list != null && !list.isEmpty()) {
             executorService = Executors.newFixedThreadPool(10);
             countDownLatch = new CountDownLatch(list.size());
             list.forEach(login -> {
-                executorService.submit(()->{
+                executorService.submit(() -> {
                     try {
-                        if(null!=login.getCookie()&&!"".equals(login.getCookie().trim())){
-                            kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(),login);
+                        if (null != login.getCookie() && !"".equals(login.getCookie().trim())) {
+                            kuaishouWebInterfaceService.deleteAllComment(new HashMap<>(), login);
                         }
-                    }catch (Exception e){
+                    } catch (Exception e) {
 
-                    }finally {
+                    } finally {
                         countDownLatch.countDown();
                     }
                 });
@@ -108,41 +130,51 @@ public class SampleTest {
             e.printStackTrace();
         }
         Long end = System.currentTimeMillis();
-        log.info("总用时:{}毫秒",end-start);
+        log.info("总用时:{}毫秒", end - start);
     }
+
     @Autowired
-    private ICtopOauthTokenService tokenService;
+    private PangolinLoginService pangolinLoginService;
     @Autowired
-    private IBytedanceFundDailyService bytedanceFundDailyService;
+    private PangolinCrawlerService pangolinCrawlerService;
+    @Autowired
+    private PangolinAppService pangolinAppService;
+
     @Test
-    public void testBase64(){
-        List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
-        if (null == tokens || tokens.size() <= 0) {
-            XxlJobLogger.log("头条账户流水数据异常:未获取到可用的token");
-            return ;
+    public void testPangolinLogin() {
+        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("login_type", "pangolin");
+        queryWrapper.eq("status", 1);
+        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
+        if (list != null && !list.isEmpty()) {
+            for (BindAccountLogin login : list) {
+                if (null == login.getCookie() || "".equals(login.getCookie().trim())) {
+                    pangolinLoginService.pangolinLogin(login.getAccountName(), login.getPassword());
+                }
+            }
         }
-        executorService = Executors.newFixedThreadPool(4);
-        countDownLatch = new CountDownLatch(tokens.size());
-        tokens.forEach(token -> {
-            executorService.submit(() -> {
-                try {
-                    for(int i=0;i<12;i++){
-                        String getDate = DateUtils.addDay("2020-05-28",-i);
-                        bytedanceFundDailyService.loadFundDataByPage(token, getDate, getDate,1);
-                    }
-                }catch (Exception e){
+    }
 
-                }finally {
-                    countDownLatch.countDown();
+    @Test
+    public void testPangolinData() {
+        QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("login_type", "pangolin");
+        queryWrapper.eq("status", 1);
+        queryWrapper.isNotNull("cookie");
+        List<BindAccountLogin> list = bindAccountLoginService.list(queryWrapper);
+        if (list != null && !list.isEmpty()) {
+            for (BindAccountLogin bindAccountLogin : list) {
+                pangolinCrawlerService.getChannelList(bindAccountLogin);
+                pangolinCrawlerService.getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
+                pangolinCrawlerService.getCheckList(bindAccountLogin);
+                QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
+                queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
+                List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
+                if (appList != null && !appList.isEmpty()) {
+                    appList.forEach(pangolinApp -> pangolinCrawlerService.getRealTimeList(bindAccountLogin, pangolinApp.getId()));
                 }
-
-            });
-        });
-        try {
-            countDownLatch.await();
-        } catch (InterruptedException e) {
+            }
         }
-        System.out.println("执行完成");
     }
 }
 

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/constant/CtopRoleCodeConstant.java

@@ -0,0 +1,5 @@
+package cn.com.ctop.common.module.constant;
+
+public class CtopRoleCodeConstant {
+    public static final String COMMON_ROLE_CODE_ADMIN = "admin";
+}

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/constant/OssConstant.java

@@ -0,0 +1,5 @@
+package cn.com.ctop.common.module.constant;
+
+public class OssConstant {
+    public static final String formatUrl = "https://%s.%s.aliyuncs.com/";
+}

+ 3 - 3
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialCutFrame.java

@@ -38,7 +38,7 @@ public class MaterialCutFrame {
      */
     @Excel(name = "素材库id", width = 15)
     @ApiModelProperty(value = "素材库id")
-    private String materialMd5;
+    private String videoSignature;
     /**
      * url
      */
@@ -50,13 +50,13 @@ public class MaterialCutFrame {
      */
     @Excel(name = "md5", width = 15)
     @ApiModelProperty(value = "md5")
-    private String code;
+    private String signature;
     /**
      * 素材标
      */
     @Excel(name = "素材标", width = 15)
     @ApiModelProperty(value = "素材标")
-    private Integer cutFrameIndex;
+    private Integer imageIndex;
 
     /**
      * createTime

+ 63 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialCutFrameTask.java

@@ -0,0 +1,63 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.util.Date;
+
+/**
+ * 截帧 任务表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-06-01
+ */
+@Data
+@TableName("ctop_material_cut_frame_task")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_material_cut_frame_task对象", description = "截帧 任务表")
+public class MaterialCutFrameTask {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 视频md5
+     */
+    @Excel(name = "视频md5", width = 15)
+    @ApiModelProperty(value = "视频md5")
+    private String videoSignature;
+    /**
+     * jobId
+     */
+    @Excel(name = "jobId", width = 15)
+    @ApiModelProperty(value = "jobId")
+    private String jobId;
+    /**
+     * 任务状态 0 未执行 1 已完成
+     */
+    @Excel(name = "任务状态 0 未执行 1 已完成", width = 15)
+    @ApiModelProperty(value = "任务状态 0 未执行 1 已完成")
+    private Integer jobStatus;
+    /**
+     * createTime
+     */
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/MaterialInfo.java

@@ -153,4 +153,11 @@ public class MaterialInfo {
     private Boolean whetherUnaudited;  // 是否有未审核封面
 
 
+    @TableField(exist = false)
+    private String mediaId;  // 是否有未审核封面
+
+    @TableField(exist = false)
+    private String projectName;  // 是否有未审核封面
+
+
 }

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

@@ -2,6 +2,7 @@ package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -36,4 +37,6 @@ public interface CtopOauthTokenMapper extends BaseMapper<CtopOauthToken> {
     List<CtopOauthToken> selectKuaiShouToken();
 
     List<CtopOauthToken> selectToutiaoToken();
+
+    CtopOauthToken getAccessTokenByAccountIdAndMediaId(@Param("mediaId")Integer mediaId, @Param("accountId")Long accountId);
 }

+ 15 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialCutFrameTaskMapper.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.MaterialCutFrameTask;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 截帧 任务表
+ *
+ * @author: jeecg-boot
+ * @date: 2020-06-01
+ * @cersion: V1.0
+ */
+public interface MaterialCutFrameTaskMapper extends BaseMapper<MaterialCutFrameTask> {
+
+}

+ 4 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -2,6 +2,9 @@ package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.UserAllocation;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * @Description: 用户分配
@@ -10,5 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @Version: V1.0
  */
 public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
-
+    List<UserAllocation> selectAccountListByProjectId(@Param("projectId")Long projectId);
 }

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

@@ -97,4 +97,13 @@
         group by account_id
     </select>
 
+    <select id="getAccessTokenByAccountIdAndMediaId" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
+        select
+        *
+        from
+        ctop_oauth_token
+        where media_id = #{mediaId}
+        and account_id = #{accountId}
+    </select>
+
 </mapper>

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialCutFrameTaskMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.common.module.mapper.MaterialCutFrameTaskMapper">
+
+</mapper>

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -2,4 +2,15 @@
 <!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.UserAllocationMapper">
 
+    <select id="selectAccountListByProjectId" resultType="cn.com.ctop.common.module.entity.UserAllocation">
+        select
+        a.user_id as userId,
+        a.user_name as userName,
+        a.auth_name as authName,
+        a.account_id as accountId
+        from
+        ctop_user_allocation a
+        left join ctop_project b on a.project_id = b.id
+        where b.id = #{projectId}
+    </select>
 </mapper>

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

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

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

@@ -14,6 +14,8 @@ import java.io.IOException;
  * @date 2019-12-25
  */
 public interface IMaterialCutFrameService extends IService<MaterialCutFrame> {
-    void getCutFrame(String url, String materialId, String height, String width) throws IOException;
+    void getCutFrame(String url, String materialId, Long secondDuration, String height, String width) throws IOException;
+
+    void loadCutFrame(String jobId, String videoSignature);
 
 }

+ 15 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialCutFrameTaskService.java

@@ -0,0 +1,15 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.MaterialCutFrameTask;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 截帧 任务表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-06-01
+ */
+public interface IMaterialCutFrameTaskService extends IService<MaterialCutFrameTask> {
+
+}

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

@@ -22,4 +22,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     Map<String, Object> getPangolinAccountListByParams(String userId, JSONObject data);
 
     Map<String, Object> getPangolinProjectListByParams(String userId);
+
+    List<UserAllocation> selectAccountListByProjectId(Long projectId);
 }

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

@@ -191,4 +191,10 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
     public List<CtopOauthToken> selectToutiaoToken() {
         return cTopOauthTokenMapper.selectToutiaoToken();
     }
+
+
+    @Override
+    public CtopOauthToken getAccessTokenByAccountIdAndMediaId(Integer mediaId, Long accountId) {
+        return cTopOauthTokenMapper.getAccessTokenByAccountIdAndMediaId(mediaId, accountId);
+    }
 }

+ 117 - 59
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameServiceImpl.java

@@ -1,8 +1,12 @@
 package cn.com.ctop.common.module.service.impl;
 
+import cn.com.ctop.common.module.constant.OssConstant;
 import cn.com.ctop.common.module.entity.MaterialCutFrame;
+import cn.com.ctop.common.module.entity.MaterialCutFrameTask;
 import cn.com.ctop.common.module.mapper.MaterialCutFrameMapper;
 import cn.com.ctop.common.module.service.IMaterialCutFrameService;
+import cn.com.ctop.common.module.service.IMaterialCutFrameTaskService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.LoadFileUtil;
 import cn.com.ctop.common.module.utils.MpsUtils;
 import com.alibaba.fastjson.JSON;
@@ -14,7 +18,11 @@ import com.aliyuncs.mts.model.v20140618.QuerySnapshotJobListResponse;
 import com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobRequest;
 import com.aliyuncs.mts.model.v20140618.SubmitSnapshotJobResponse;
 import com.aliyuncs.profile.DefaultProfile;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
@@ -28,6 +36,7 @@ import java.net.URLEncoder;
  * @version V1.0
  * @date 2019-12-25
  */
+@Slf4j
 @Service
 public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMapper, MaterialCutFrame> implements IMaterialCutFrameService {
 
@@ -35,26 +44,42 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
     private static String ossBucket = "ctop-media";
     private static String ossOutputObject = "output_{Count}.jpg";
 
+    @Value("${jeecg.path.image-upload}")
+    private String imageUpLoadPath;
+
+
+    @Autowired
+    private IMaterialCutFrameTaskService cutFrameTaskService;
+
     /**
      * 获取素材关键帧
      *
      * @param url
      */
     @Override
-    public void getCutFrame(String url, String materialId, String height, String width) throws IOException {
+    public void getCutFrame(String url, String materialId, Long secondDuration, String height, String width) throws IOException {
         try {
-            String zeroFrameUrl = url + "?x-oss-process=video/snapshot,t_00000,m_fast";
 
-            // String localPath = LoadFileUtil.downLoadFromUrl(zeroFrameUrl, PropertiesUtils.getValue("kuaishou_config", "video_sava_path"));
-            String localPath = LoadFileUtil.downLoadFromUrl(zeroFrameUrl, "D:\\tets1");
+            QueryWrapper<MaterialCutFrameTask> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("video_signature", materialId);
+            queryWrapper.last("limit 1");
+            MaterialCutFrameTask checkCutFrame = cutFrameTaskService.getOne(queryWrapper);
+            if (!Check.isNull(checkCutFrame)) {
+                log.info("已存推荐封面");
+                return;
+
+            }
+
+            String zeroFrameUrl = url + "?x-oss-process=video/snapshot,t_00000,m_fast";
+            String localPath = LoadFileUtil.downLoadFromUrl(zeroFrameUrl, imageUpLoadPath);
             String md5 = LoadFileUtil.getMD5(localPath);
             LoadFileUtil.delFile(localPath);
 
             MaterialCutFrame cutFrame = new MaterialCutFrame();
-            cutFrame.setCode(md5);
+            cutFrame.setSignature(md5);
             cutFrame.setUrl(zeroFrameUrl);
-            cutFrame.setMaterialMd5(materialId);
-            cutFrame.setCutFrameIndex(0);
+            cutFrame.setVideoSignature(materialId);
+            cutFrame.setImageIndex(0);
             this.save(cutFrame);
 
 
@@ -77,6 +102,8 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
             input.put("Object", replaceUrl);
 
             request.setInput(input.toJSONString());
+
+
             // SnapshotConfig
             JSONObject snapshotConfig = new JSONObject();
             // SnapshotConfig->OutputFile
@@ -89,10 +116,15 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
 
             snapshotConfig.put("OutputFile", output.toJSONString());
             // SnapshotConfig->Time
-            snapshotConfig.put("Time", "3");
+            //   Integer time = ((secondDuration.intValue() - 2) / 14) + 1; // 时长 / 14 == 间隔时间
+
+            double num = (double) (secondDuration - 2) / 15;
+            long rint = Math.round(num);
+            log.info("相隔时间数:{}", rint);
+            snapshotConfig.put("Time", 2000);
             // SnapshotConfig->Interval/Num
-            snapshotConfig.put("Interval", "2");
-            snapshotConfig.put("Num", "9");
+            snapshotConfig.put("Interval", rint);
+            snapshotConfig.put("Num", "14");
             // SnapshotConfig->Width/Height
             snapshotConfig.put("Height", height);
             snapshotConfig.put("Width", width);
@@ -101,60 +133,86 @@ public class MaterialCutFrameServiceImpl extends ServiceImpl<MaterialCutFrameMap
             // PipelineId
             String pipelineId = MpsUtils.getPipelineId(client);
             request.setPipelineId(pipelineId);
-            // call api
-            SubmitSnapshotJobResponse response;
-            response = client.getAcsResponse(request);
-            for (int i = 0; i < 100; i++) {
-                Thread.sleep(5 * 1000L);
-                QuerySnapshotJobListRequest request1 = new QuerySnapshotJobListRequest();
-                request1.setSnapshotJobIds(response.getSnapshotJob().getId());
-                QuerySnapshotJobListResponse response1 = client.getAcsResponse(request1);
-                String s = JSON.toJSONString(response1);
-                JSONObject jsonObject = JSONObject.parseObject(s);
-                if (jsonObject == null) {
-                    continue;
-                }
-                JSONObject json = (JSONObject) jsonObject.getJSONArray("snapshotJobList").get(0);
-                String state = json.getString("state");
-                if (null == state || !"Success".equals(state)) {
-                    continue;
-                }
-                Integer count = json.getInteger("count");
-                for (int j = 1; j <= count; j++) {
-                    String urlStr = "";
-                    if (j < 10) {
-                        urlStr = String.format(
-                                "https://%s.%s.aliyuncs.com/" + ossOutputObject1 + "output_0000" + j + ".jpg",
-                                ossBucket,
-                                ossLocation);
-                    } else if (j < 100) {
-                        urlStr = String.format(
-                                "https://%s.%s.aliyuncs.com/" + ossOutputObject1 + "output_000" + j + ".jpg",
-                                ossBucket,
-                                ossLocation);
-                    } else if (j > 100) {
-                        urlStr = String.format(
-                                "https://%s.%s.aliyuncs.com/" + ossOutputObject1 + "output_00" + j + ".jpg",
-                                ossBucket,
-                                ossLocation);
-                    }
-                    String cutFramePath = LoadFileUtil.downLoadFromUrl(urlStr, "D:\\tets1");
-                    String cutFrameMd5 = LoadFileUtil.getMD5(cutFramePath);
-                    LoadFileUtil.delFile(cutFramePath);
-                    cutFrame = new MaterialCutFrame();
-                    cutFrame.setCode(cutFrameMd5);
-                    cutFrame.setUrl(urlStr);
-                    cutFrame.setMaterialMd5(materialId);
-                    cutFrame.setCutFrameIndex(j);
-                    this.save(cutFrame);
+            SubmitSnapshotJobResponse response = client.getAcsResponse(request);
+            String jobId = response.getSnapshotJob().getId();
+            MaterialCutFrameTask cutFrameTask = new MaterialCutFrameTask();
+            cutFrameTask.setJobStatus(0);
+            cutFrameTask.setJobId(jobId);
+            cutFrameTask.setVideoSignature(materialId);
+            cutFrameTaskService.save(cutFrameTask);
+        } catch (Exception e) {
+            log.error(e.getMessage());
+        }
+
+
+    }
+
+
+    @Override
+    public void loadCutFrame(String jobId, String videoSignature) {
+        try {
+            DefaultProfile profile = DefaultProfile.getProfile(
+                    "cn-beijing",
+                    "LTAIbNbqWzSOklQV",
+                    "1rkPz7JNoXk8sJevPaeYHWqfkQXBGh");
+            IAcsClient client = new DefaultAcsClient(profile);
+
+            QuerySnapshotJobListRequest request = new QuerySnapshotJobListRequest();
+            request.setSnapshotJobIds(jobId);
+            QuerySnapshotJobListResponse response = client.getAcsResponse(request);
+            JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(response));
+            if (jsonObject == null) {
+                return;
+            }
+            JSONObject json = (JSONObject) jsonObject.getJSONArray("snapshotJobList").get(0);
+            String state = json.getString("state");
+            if (null == state || !"Success".equals(state)) {
+                return;
+            }
+            String loadImage = "cutFrame/" + videoSignature + "/";
+
+            Integer count = json.getInteger("count");
+            for (int j = 1; j <= count; j++) {
+                String urlStr = null;
+                if (j < 10) {
+                    urlStr = String.format(
+                            OssConstant.formatUrl + loadImage + "output_0000" + j + ".jpg",
+                            ossBucket,
+                            ossLocation);
+                } else if (j < 100) {
+                    urlStr = String.format(
+                            OssConstant.formatUrl + loadImage + "output_000" + j + ".jpg",
+                            ossBucket,
+                            ossLocation);
+                } else if (j > 100) {
+                    urlStr = String.format(
+                            OssConstant.formatUrl + loadImage + "output_00" + j + ".jpg",
+                            ossBucket,
+                            ossLocation);
                 }
-                break;
+                String cutFramePath = LoadFileUtil.downLoadFromUrl(urlStr, imageUpLoadPath);
+                String cutFrameMd5 = LoadFileUtil.getMD5(cutFramePath);
+
+                MaterialCutFrame cutFrame = new MaterialCutFrame();
+                cutFrame.setSignature(cutFrameMd5);
+                cutFrame.setUrl(urlStr);
+                cutFrame.setVideoSignature(videoSignature);
+                cutFrame.setImageIndex(j);
+                this.save(cutFrame);
+                LoadFileUtil.delFile(cutFramePath);
+
             }
+
+            QueryWrapper<MaterialCutFrameTask> updateQueryWrapper = new QueryWrapper<>();
+            updateQueryWrapper.eq("job_id", jobId);
+            updateQueryWrapper.eq("video_signature", videoSignature);
+            MaterialCutFrameTask updateTask = new MaterialCutFrameTask();
+            updateTask.setJobStatus(1);
+            cutFrameTaskService.update(updateTask, updateQueryWrapper);
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error(e.getMessage());
         }
 
-
     }
 
 

+ 19 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialCutFrameTaskServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.MaterialCutFrameTask;
+import cn.com.ctop.common.module.mapper.MaterialCutFrameTaskMapper;
+import cn.com.ctop.common.module.service.IMaterialCutFrameTaskService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 截帧 任务表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-06-01
+ */
+@Service
+public class MaterialCutFrameTaskServiceImpl extends ServiceImpl<MaterialCutFrameTaskMapper, MaterialCutFrameTask> implements IMaterialCutFrameTaskService {
+
+}

+ 18 - 16
module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -51,6 +51,9 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     private IVideoWatermarkTaskService videoWatermarkTaskService;
     @Autowired
     private MaterialInfoMapper materialInfoMapper;
+    @Autowired
+    private MaterialParameterMapper materialParameterMapper;
+
     @Value("${oss.replace.replace-value}")
     private String replaceValue;
     @Value("${oss.replace.replace-old-value}")
@@ -324,9 +327,6 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     }
 
 
-    @Autowired
-    private MaterialParameterMapper materialParameterMapper;
-
     @Override
     public void getFile(MaterialInfo materialInfo) {
         uploadExecutorService.submit(new Runnable() {
@@ -362,6 +362,8 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                         // 视频高
                         String height = String.valueOf(m.getVideo().getSize().getHeight());
                         materialParameter.setHeight(height);
+
+
                         fis = new FileInputStream(file);
                         FileChannel fc = fis.getChannel();
                         BigDecimal fileSize = new BigDecimal(fc.size());
@@ -375,8 +377,19 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                         int insert = materialParameterMapper.insert(materialParameter);
                         if (insert > 0) {
                             log.info("素材基本信息入库完成,用时:{} s", (System.currentTimeMillis() - l) / 1000);
-
                         }
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                try {
+                                    log.info("开始抽帧");
+                                    materialCutFrameService.getCutFrame(url, materialInfo.getCode(), secondDuration, height, width);
+                                } catch (Exception e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        };
+                        thread.start();
                     } catch (FileNotFoundException e) {
                         e.printStackTrace();
                     } catch (IOException e) {
@@ -394,18 +407,7 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                         }
                     }
 
-                            /*Thread thread = new Thread() {
-                                @Override
-                                public void run() {
-                                    try {
-                                        Thread.sleep(5 * 1000);
-                                        materialCutFrameService.getCutFrame(url, materialInfo.getCode(), height, width);
-                                    } catch (Exception e) {
-                                        e.printStackTrace();
-                                    }
-                                }
-                            };
-                            thread.start();*/
+                    /* */
 
                        /* } catch (Exception e) {
                             e.printStackTrace();

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.context.annotation.Primary;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.HashMap;
@@ -25,6 +26,8 @@ import java.util.Map;
 @Service
 @Primary
 public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper, UserAllocation> implements IUserAllocationService {
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
 
     @Override
     public UserAllocation getByAccountId(Long accountId) {
@@ -78,4 +81,12 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
         result.put("data",allocations);
         return result;
     }
+
+    @Override
+    public List<UserAllocation> selectAccountListByProjectId(Long projectId) {
+        List<UserAllocation> list = userAllocationMapper.selectAccountListByProjectId(projectId);
+        return list;
+    }
+
+
 }

+ 12 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/CtopAdConstant.java

@@ -6,9 +6,20 @@ import java.math.BigDecimal;
  * 广告相关常量数据
  */
 public class CtopAdConstant {
+    //头条
     public static final String PLATFORM_TYPE_BYTEDANCE = "1";
+    public static final  int PLATFORM_TYPE_BYTEDANCE_INT = 1;
+    //快手
     public static final String PLATFORM_TYPE_KUAISHOU = "2";
-    public static final String PLATFORM_TYPE_PANGOLIN = "3";
+    public static final  int PLATFORM_TYPE_KUAISHOU_INT = 2;
+    //头条内广
+    public static final String PLATFORM_TYPE_BYTEDANCE_INSIDE = "3";
+    public static final  int PLATFORM_TYPE_BYTEDANCE_INSIDE_INT = 3;
+    //头条内广
+    public static final String PLATFORM_TYPE_KUAISHOU_INSIDE = "4";
+    public static final  int PLATFORM_TYPE_KUAISHOU_INSIDE_INT = 4;
+
+    public static final String PLATFORM_TYPE_PANGOLIN = "5";
 
     public static final String PLATFORM_TYPE_BYTEDANCE_PY = "bytedance";
     public static final String PLATFORM_TYPE_KUAISHOU_PY = "kuaishou";

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -109,6 +109,11 @@ public class KuaishouInterfaceConstant {
      */
     public static final String APP_SEARCH = "/rest/openapi/v1/tool/app/search";
 
+    /**
+     * 获取可选的应用定向
+     */
+    public static final String CONVERT_LIST = "/rest/openapi/v1/tool/convert/list";
+
 
     /**
      * 获取定向标签

+ 5 - 6
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/service/IKuaishouCrawlerService.java

@@ -5,10 +5,9 @@ import cn.com.ctop.crawler.modules.account.entity.KuaishouAppAccount;
 import cn.com.ctop.crawler.modules.account.entity.KuaishouIosAccount;
 
 public interface IKuaishouCrawlerService {
-    public String getVideoFeeds(KuaishouAppAccount kuaishouAppAccount,Integer page);
-    public String getVideoFeeds(KuaishouIosAccount kuaishouIosAccount);
-    public String getAdAccountVideoFeeds(KuaishouAdAccount kuaishouAdAccount,String pcursor);
-    public String getAdFeeds();
-
-    public String getUserProfile(Long userId);
+    String getVideoFeeds(KuaishouAppAccount kuaishouAppAccount,Integer page);
+    String getVideoFeeds(KuaishouIosAccount kuaishouIosAccount);
+    String getAdAccountVideoFeeds(KuaishouAdAccount kuaishouAdAccount,String pcursor);
+    String getAdFeeds();
+    String getUserProfile(Long userId);
 }

+ 2 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinCrawlerService.java

@@ -10,4 +10,6 @@ public interface PangolinCrawlerService {
     void getActivationList(BindAccountLogin bindAccountLogin, String date, int page);
 
     void getRealTimeList(BindAccountLogin bindAccountLogin, Long appId);
+
+    void getNowData(BindAccountLogin bindAccountLogin);
 }

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/PangolinLoginService.java

@@ -1,5 +1,5 @@
 package cn.com.ctop.crawler.modules.pangolin.service;
 
 public interface PangolinLoginService {
-    public void pangolinLogin(String username,String password);
+    void pangolinLogin(String username,String password);
 }

+ 13 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinCrawlerServiceImpl.java

@@ -341,4 +341,17 @@ public class PangolinCrawlerServiceImpl implements PangolinCrawlerService {
             e.printStackTrace();
         }
     }
+
+    @Override
+    public void getNowData(BindAccountLogin bindAccountLogin) {
+        getChannelList(bindAccountLogin);
+        getActivationList(bindAccountLogin, DateUtils.getNowDate("yyyy-MM-dd"), 1);
+        getCheckList(bindAccountLogin);
+        QueryWrapper<PangolinApp> queryWrapper1 = new QueryWrapper<>();
+        queryWrapper1.eq("account_name", bindAccountLogin.getAccountName());
+        List<PangolinApp> appList = pangolinAppService.list(queryWrapper1);
+        if (appList != null && !appList.isEmpty()) {
+            appList.forEach(pangolinApp -> getRealTimeList(bindAccountLogin, pangolinApp.getId()));
+        }
+    }
 }

+ 33 - 33
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinLoginServiceImpl.java

@@ -5,9 +5,8 @@ import cn.com.ctop.common.module.service.IBindAccountLoginService;
 import cn.com.ctop.common.module.utils.ChaojiyingUtils;
 import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.crawler.modules.pangolin.service.PangolinLoginService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
 import org.apache.http.impl.client.BasicCookieStore;
 import org.apache.http.impl.cookie.BasicClientCookie;
@@ -17,6 +16,7 @@ import org.openqa.selenium.chrome.ChromeOptions;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+
 import java.util.*;
 
 
@@ -45,33 +45,38 @@ public class PangolinLoginServiceImpl implements PangolinLoginService {
             webDriver.manage().deleteAllCookies();
             //获取登录页面
             webDriver.get(url);
+            Thread.sleep(3000L);
+            WebElement accountElement = webDriver.findElement(By.xpath("//input[@id='username']"));
+            accountElement.sendKeys(username);
+            Thread.sleep(3000L);
+            WebElement passwordElement = webDriver.findElement(By.xpath("//input[@id='password']"));
+            passwordElement.sendKeys(password);
+            WebElement captchaElement = webDriver.findElement(By.xpath("//div[@class='ant-form-item-control ']/img"));
+            String outputType = captchaElement.getScreenshotAs(OutputType.BASE64);
+            String res = ChaojiyingUtils.process(outputType,1902);
+            JSONObject capachaObject = JSONObject.parseObject(res);
+            Integer code = capachaObject.getInteger("err_no");
+            String captcha = capachaObject.getString("pic_str");
+            WebElement captchaInputElement = webDriver.findElement(By.xpath("//input[@id='captcha']"));
+            captchaInputElement.sendKeys(captcha);
+            WebElement loginElement = webDriver.findElement(By.xpath("//button[@type='submit']"));
+            Thread.sleep(3000L);
+            //点击登录
+            loginElement.click();
+            Thread.sleep(3000L);
+            webDriver.get("https://pangolin.bytedance.com");
+            Thread.sleep(3000L);
             List<WebElement> list = webDriver.findElements(By.xpath("//input[@id='captcha']"));
-            do {
-                Thread.sleep(3000L);
-                WebElement accountElement = webDriver.findElement(By.xpath("//input[@id='username']"));
-                accountElement.sendKeys(username);
-                Thread.sleep(3000L);
-                WebElement passwordElement = webDriver.findElement(By.xpath("//input[@id='password']"));
-                passwordElement.sendKeys(password);
-                WebElement captchaElement = webDriver.findElement(By.xpath("//div[@class='ant-form-item-control ']/img"));
-                String outputType = captchaElement.getScreenshotAs(OutputType.BASE64);
-                String res = ChaojiyingUtils.process(outputType,1902);
-                ObjectMapper mapper = new ObjectMapper();
-                JsonNode n = mapper.readTree(res);
-                String captcha = n.get("pic_str").asText();
-                WebElement captchaInputElement = webDriver.findElement(By.xpath("//input[@id='captcha']"));
-                captchaInputElement.sendKeys(captcha);
-                WebElement loginElement = webDriver.findElement(By.xpath("//button[@type='submit']"));
-                Thread.sleep(3000L);
-                //点击登录
-                loginElement.click();
-                Thread.sleep(3000L);
-                webDriver.get("https://pangolin.bytedance.com");
-                list = webDriver.findElements(By.xpath("//input[@id='captcha']"));
-            }while (list != null && list.size() > 0);
-
-
-
+            QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("account_name",username);
+            queryWrapper.eq("login_type","pangolin");
+            BindAccountLogin bindAccountLogin = bindAccountLoginService.getOne(queryWrapper);
+            if(null != code && code == 0 && null != list && !list.isEmpty()){
+                //表示验证码正确,登录不成功
+                bindAccountLogin.setStatus("2");
+                bindAccountLoginService.updateById(bindAccountLogin);
+                return ;
+            }
             Set<Cookie> cookies = webDriver.manage().getCookies();
             List<String> cookieList = new ArrayList<>();
             Iterator iterator = cookies.iterator();
@@ -92,11 +97,6 @@ public class PangolinLoginServiceImpl implements PangolinLoginService {
                 clientCookie.setPath(cookieMap.get("path"));
                 HttpUtils2.cookieStore.addCookie(clientCookie);
             }
-
-            QueryWrapper<BindAccountLogin> queryWrapper = new QueryWrapper<>();
-            queryWrapper.eq("account_name",username);
-            queryWrapper.eq("login_type","pangolin");
-            BindAccountLogin bindAccountLogin = bindAccountLoginService.getOne(queryWrapper);
             if (bindAccountLogin != null){
                 bindAccountLogin.setCookie(new Gson().toJson(cookieList));
                 bindAccountLoginService.updateById(bindAccountLogin);

+ 16 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/pangolin/service/impl/PangolinReportAppHourServiceImpl.java

@@ -63,6 +63,21 @@ public class PangolinReportAppHourServiceImpl extends ServiceImpl<PangolinReport
     }
 
     private JSONObject getComparedDate(Integer appId,Integer hour,String userId,String type,String today, String yesterday, String sevenDaysAgo, String compareTime1, String compareTime2,List<Long>projectIds,List<String>  accountNames) {
-        return pangolinReportAppHourMapper.getComparedDate(appId,hour,userId,type,today, yesterday,sevenDaysAgo,compareTime1,compareTime2,projectIds,accountNames);
+        JSONObject data = pangolinReportAppHourMapper.getComparedDate(appId,hour,userId,type,today, yesterday,sevenDaysAgo,compareTime1,compareTime2,projectIds,accountNames);
+        System.out.println(data.toJSONString());
+        if(null==data||data.toJSONString().equals("null")){
+            data = new JSONObject();
+            data.put("today",0);
+            data.put("yesterday",0);
+            data.put("sevendaysAgo",0);
+            data.put("hour",hour);
+            if(null!=compareTime1&&!compareTime1.trim().equals("")){
+                data.put(compareTime1,0);
+            }
+            if(null!=compareTime2&&!compareTime2.trim().equals("")){
+                data.put(compareTime2,0);
+            }
+        }
+        return data;
     }
 }

+ 1 - 1
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialUploadServiceImpl.java

@@ -1,4 +1,4 @@
-package cn.com.ctop.manage.modules.edu.service.impl;
+package cn.com.ctop.manage.modules.material.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.MaterialInfo;

+ 3 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/app/service/IKuaishouAppService.java

@@ -5,7 +5,7 @@ import cn.com.ctop.crawler.modules.account.entity.KuaishouAppAccount;
 import cn.com.ctop.crawler.modules.account.entity.KuaishouIosAccount;
 
 public interface IKuaishouAppService {
-    public void adFetch(KuaishouAppAccount kuaishouAppAccount,Integer page);
-    public void adFetch(KuaishouIosAccount kuaishouIosAccount);
-    public void adAccountFetch(KuaishouAdAccount kuaishouAdAccount,String pcursor);
+     void adFetch(KuaishouAppAccount kuaishouAppAccount,Integer page);
+     void adFetch(KuaishouIosAccount kuaishouIosAccount);
+     void adAccountFetch(KuaishouAdAccount kuaishouAdAccount,String pcursor);
 }

+ 25 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java

@@ -9,6 +9,7 @@ import cn.com.ctop.common.module.utils.BigDecimalUtil;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.RandomUtil;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
 import cn.com.ctop.kuaishou.modules.batch.entity.vo.SpendVo;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupMapper;
@@ -1811,4 +1812,28 @@ public class BatchController {
     }
 
 
+    @GetMapping(value = "/getConvertList")
+    public Result<List<ConvertVo>> getConvertList(Long accountId, Integer type) {
+        Result result = new Result<>();
+        try {
+            if (Check.isNull(accountId) || Check.isNull(type)) {
+                throw new Exception("必填参数不能为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            List<ConvertVo> convertList = iKuaishouInterfaceService.getConvertList(accountId, oauthToken.getAccessToken(), type);
+            result.setResult(convertList);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
+
 }

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java

@@ -159,6 +159,7 @@ public class KuaiShouGroup {
 
 
     private Long convertId; // 转化目标
+    private Integer useAppMarket; // 转化目标
     private String groupCreateTime;
     private String groupUpdateTime;
 

+ 36 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/vo/ConvertVo.java

@@ -0,0 +1,36 @@
+package cn.com.ctop.kuaishou.modules.batch.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.sql.Date;
+
+@Data
+public class ConvertVo implements Serializable {
+    @JsonProperty("app_name")
+    private String appName;
+    @JsonProperty("convert_target")
+    private Integer convertTarget;
+    @JsonProperty("convert_name")
+    private String convertName;
+    @JsonProperty("deep_conversion_count")
+    private Long deepConversionCount;
+    @JsonProperty("deep_conversion_type")
+    private Integer deepConversionType;
+    @JsonProperty("type")
+    private Integer type;
+    @JsonProperty("app_id")
+    private Long appId;
+    @JsonProperty("convert_id")
+    private Long convertId;
+    @JsonProperty("convert_count")
+    private Long convertCount;
+    @JsonProperty("click_url")
+    private String clickUrl;
+    @JsonProperty("create_time")
+    private String createTime;
+    @JsonProperty("update_time")
+    private String updateTime;
+
+}

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouImageGetMapper.java

@@ -17,4 +17,6 @@ public interface KuaiShouImageGetMapper extends BaseMapper<KuaiShouImageGet> {
     void replaceBatch(@Param(value = "images") List<KuaiShouImageGet> imagesGets);
 
     String getUrlByCode(String signature);
+
+    String getCutFrameUrlByCode(String signature);
 }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml

@@ -31,6 +31,7 @@
         app_id,
         app_icon_url,
         convert_id,
+        use_app_market,
         group_create_time,
         group_update_time,
         create_time,
@@ -66,6 +67,7 @@
             #{getGroup.appId},
             #{getGroup.appIconUrl},
             #{getGroup.convertId},
+            #{getGroup.useAppMarket},
             #{getGroup.groupCreateTime},
             #{getGroup.groupUpdateTime},
             #{getGroup.createTime},

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouImageGetMapper.xml

@@ -40,7 +40,13 @@
         select url from ctop_material_image_info
         where  code = #{signature}
         limit 1
+    </select>
 
+    <select id="getCutFrameUrlByCode" resultType="java.lang.String">
+        select url from ctop_material_cut_frame
+        where  signature = #{signature}
+        limit 1
     </select>
 
+
 </mapper>

+ 14 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
 import cn.com.ctop.kuaishou.modules.report.entity.*;
@@ -10,6 +11,7 @@ import com.alibaba.fastjson.JSONObject;
 
 import java.text.ParseException;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -480,6 +482,18 @@ public interface IKuaishouInterfaceService {
      */
 
     void getAsyncCreativeList(Long accountId, String accessToken, Long campaignId);
+
+
+    /**
+     * 获取转化目标
+     *
+     * @param accountId
+     * @param accessToken
+     * @param type
+     * @return
+     */
+    List<ConvertVo> getConvertList(Long accountId, String accessToken, Integer type);
+
 }
 
 

+ 32 - 20
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java

@@ -58,6 +58,18 @@ public class BatchServiceImpl implements IBatchService {
     private KuaiShouGroupMapper groupMapper;
     @Autowired
     private KuaiShouCreativeMapper creativeMapper;
+    @Autowired
+    private KuaiShouGroupMapper kuaiShouGroupMapper;
+    @Autowired
+    private KuaiShouGroupTargetMapper targetMapper;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private RestTemplate rest;
 
 
     /**
@@ -133,8 +145,7 @@ public class BatchServiceImpl implements IBatchService {
      * @param unitName
      * @return
      */
-    @Autowired
-    private KuaiShouGroupMapper kuaiShouGroupMapper;
+
 
     @Override
     public Boolean checkUnitName(Long campaignId, String unitName) {
@@ -157,11 +168,6 @@ public class BatchServiceImpl implements IBatchService {
      * @param requestJson
      * @return
      */
-    @Autowired
-    private ICtopOauthTokenService oauthTokenService;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-
     @Override
     public JSONObject createUnit(JSONObject requestJson) throws Exception {
         Long accountId = requestJson.getLong("accountId");
@@ -197,6 +203,16 @@ public class BatchServiceImpl implements IBatchService {
             unitJson.put("unit_type", requestJson.getInteger("unitType"));
         }
 
+        // 转化目标id
+        if (!Check.isNull(requestJson.getInteger("convertId"))) {
+            unitJson.put("convert_id", requestJson.getInteger("convertId"));
+        }
+
+        // 优先从系统应用商店下载
+        if (!Check.isNull(requestJson.getInteger("useAppMarket"))) {
+            unitJson.put("use_app_market", requestJson.getInteger("useAppMarket"));
+        }
+
         //投放开始时间
         if (!Check.isNull(requestJson.getString("beginTime"))) {
             String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
@@ -447,9 +463,6 @@ public class BatchServiceImpl implements IBatchService {
      * @throws Exception
      */
 
-    @Autowired
-    private KuaiShouGroupTargetMapper targetMapper;
-
 
     @Override
     public JSONObject copyUnit(KuaiShouGroup group, Long copyToCampaignId) {
@@ -489,6 +502,15 @@ public class BatchServiceImpl implements IBatchService {
                     }
 
                 }
+
+                // 优先从系统应用商店下载
+                if (!Check.isNull(group.getUseAppMarket())) {
+                    unitJson.put("use_app_market", group.getUseAppMarket());
+                }
+                // 转化目标id
+                if (!Check.isNull(group.getConvertId())) {
+                    unitJson.put("convert_id", group.getConvertId());
+                }
                 // 投放结束时间
                 if (!Check.isNull(group.getEndTime())) {
                     unitJson.put("end_time", group.getEndTime());
@@ -807,10 +829,6 @@ public class BatchServiceImpl implements IBatchService {
      * @param requestJson
      * @return
      */
-    @Autowired
-    private IKuaiShouImageGetService imageGetService;
-
-
     @Override
     public JSONObject createCreative(JSONObject requestJson) throws Exception {
         if (Check.isNull(requestJson)) {
@@ -1167,9 +1185,6 @@ public class BatchServiceImpl implements IBatchService {
      * @param requestJson
      * @return
      */
-    @Autowired
-    private IKuaiShouImageGetService iKuaiShouImageGetService;
-
     @Override
     public JSONObject updateCreative(JSONObject requestJson) throws Exception {
         if (Check.isNull(requestJson)) {
@@ -1249,9 +1264,6 @@ public class BatchServiceImpl implements IBatchService {
     }
 
 
-    @Autowired
-    private RestTemplate rest;
-
     private String exceptInfoForRestTemplate(String url, Map<String, Object> paramMap, Map<String, String> headerMap) throws ParseException {
         try {
             MultiValueMap<String, Object> param = new LinkedMultiValueMap<>();

+ 9 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouImageGetServiceImpl.java

@@ -1,9 +1,8 @@
 package cn.com.ctop.kuaishou.modules.batch.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouImageGetMapper;
-import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouVideoGetMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouImageGetService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,7 +28,14 @@ public class KuaiShouImageGetServiceImpl extends ServiceImpl<KuaiShouImageGetMap
 
     @Override
     public String getUrlByCode(String signature) {
-        return imageGetMapper.getUrlByCode(signature);
+        String url = imageGetMapper.getUrlByCode(signature);
+        if (!Check.isNull(url)) {
+            return url;
+        } else {
+            return imageGetMapper.getCutFrameUrlByCode(signature);
+        }
+
+
     }
 
 }

+ 43 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -8,6 +8,7 @@ import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.vo.ConvertVo;
 import cn.com.ctop.kuaishou.modules.batch.mapper.*;
 import cn.com.ctop.kuaishou.modules.batch.service.*;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
@@ -16,7 +17,6 @@ import cn.com.ctop.kuaishou.modules.report.entity.*;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAccountMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyCampaignMapper;
 import cn.com.ctop.kuaishou.modules.report.service.*;
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -1178,7 +1178,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         }
         JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
         if (Check.isNull(details)) {
-
             return;
         }
         addGroup(token.getAccountId(), details);
@@ -1281,6 +1280,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     group.setGroupCreateTime(detail.getString("create_time"));
                     group.setGroupUpdateTime(detail.getString("update_time"));
                     group.setConvertId(detail.getLong("convert_id"));
+                    group.setUseAppMarket(detail.getInteger("use_app_market"));
                     group.setCreateTime(new Date());
                     group.setUpdateTime(new Date());
                     groups.add(group);
@@ -3163,5 +3163,46 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
     }
 
+    /**
+     * 获取转化目标
+     *
+     * @param accountId
+     * @param accessToken
+     * @param type
+     * @return
+     */
+    @Override
+    public List<ConvertVo> getConvertList(Long accountId, String accessToken, Integer type) {
+        List<ConvertVo> convertVoList = new ArrayList<>();
+        try {
+            log.info("获取转化目标:accountId:{}", accountId);
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CONVERT_LIST;
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", "application/json");
+            JSONObject requestJson = new JSONObject();
+            requestJson.put("advertiser_id", accountId);
+            requestJson.put("type", type);
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            Integer code = resultJson.getInteger("code");
+            if (code == 0) {
+                JSONObject data = resultJson.getJSONObject("data");
+                if (!Check.isNull(data)) {
+                    JSONArray details = data.getJSONArray("details");
+                    if (!Check.isNull(details)) {
+                        for (int i = 0; i < details.size(); i++) {
+                            ConvertVo convertVo = JsonUtil.jsonToObj(details.getJSONObject(i), ConvertVo.class);
+                            convertVoList.add(convertVo);
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return convertVoList;
+    }
 
 }

+ 19 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/AccountReportDTO.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.toutiao.modules.report.DTO;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+
+@Data
+public class AccountReportDTO implements Serializable {
+    private String startDate;
+    private String endDate;
+    private BigDecimal discount;  //仅头条内广可用 折扣
+    private BigDecimal point;  //仅头条可用 返点
+    private List<Long> accountIds;
+    private Integer statHour;
+    private Integer type;
+}

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

@@ -77,6 +77,42 @@ public class ByteDanceVideoReportDailyController {
 		 return result;
 	 }
 
+	@AutoLog(value = "头条视频单个账户按天汇总")
+	@ApiOperation(value = "头条视频单个账户按天汇总", notes = "头条视频单个账户按天汇总")
+	@GetMapping(value = "/videoInfoListByAccountId")
+	public Result videoInfoListByAccountId(@RequestParam(name = "startDate") String startDate,
+										 @RequestParam(name = "endDate") String endDate,
+										   @RequestParam(name = "accountId") Long accountId,
+										 HttpServletRequest req){
+		Result result = new Result();
+		int days = DateUtils.dateDiff(startDate, endDate);
+		List<String> dateList = new ArrayList<>();
+		for(int i=0; i<=days; i++){
+			String endStr = DateUtils.addDay(startDate ,i);
+			dateList.add(endStr);
+			System.out.println(endStr);
+		}
+
+		final ExecutorService executorService = Executors.newFixedThreadPool(8);
+		dateList.forEach(date -> {
+			executorService.submit(new Runnable() {
+				@Override
+				public void run() {
+					try {
+						System.out.println("头条视频按天汇总接口现在在跑的时间为:" + date + "~" + date);
+						videoReportDailyService.videoInfoListByAccountId(date, date,accountId);
+					} catch (Exception e) {
+						e.printStackTrace();
+					} finally {
+					}
+				}
+			});
+		});
+
+		result.setSuccess(true);
+		return result;
+	}
+
 	@AutoLog(value = "头条视频账户视频关联方法")
 	@ApiOperation(value = "头条视频账户视频关联方法", notes = "头条视频账户视频关联方法")
 	@PostMapping(value = "/accountVideoMap")
@@ -239,6 +275,7 @@ public class ByteDanceVideoReportDailyController {
 			 for (ByteDanceVideoReportDaily sum : list) {
 				 List<Object> ByteDanceVideoReportDaily = new ArrayList();
 				 ByteDanceVideoReportDaily.add(sum.getAdvertiserName());  //客户
+				 ByteDanceVideoReportDaily.add(sum.getProjectName());  //项目名称
 				 ByteDanceVideoReportDaily.add(sum.getVideoUrl() );  //视频链接
 				 ByteDanceVideoReportDaily.add(DateUtils.formatDate(sum.getStatDatetime()));  //时间
 				 ByteDanceVideoReportDaily.add(sum.getCost());  //消耗
@@ -247,7 +284,7 @@ public class ByteDanceVideoReportDailyController {
 			 }
 		 }
 
-		 String[] groupHeaders = {"客户","视频链接", "时间", "消耗","环比"};
+		 String[] groupHeaders = {"客户","项目名称","视频链接", "时间", "消耗","环比"};
 		 OutputStream os = response.getOutputStream();
 		 ExportExcelUtils eeu = new ExportExcelUtils();
 		 XSSFWorkbook workbook = new XSSFWorkbook();

+ 34 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceAdvertiserDailyReportController.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.report.controller;
 
 import cn.com.ctop.common.module.utils.StringUtils;
+import cn.com.ctop.toutiao.modules.report.DTO.AccountReportDTO;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceAdvertiserDailyReport;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceAdvertiserDailyReportService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -163,4 +164,37 @@ public class BytedanceAdvertiserDailyReportController {
         }
         return result;
     }
+
+
+
+
+
+
+
+
+
+    @AutoLog(value = "头条账户报表统计-指标统计")
+    @ApiOperation(value = "头条账户报表统计-指标统计", notes = "头条账户报表统计-指标统计")
+    @GetMapping(value = "/bytedanceAccountReportStatistics")
+    public Result bytedanceAccountReportStatistics(@RequestBody AccountReportDTO accountReportDTO) {
+        Result<BytedanceAdvertiserDailyReport> result = new Result<>();
+        result.setSuccess(true);
+        //判断必填字段
+
+
+        return result;
+    }
+
+
+    @AutoLog(value = "头条账户报表统计-账户列表及汇总")
+    @ApiOperation(value = "头条账户报表统计-账户列表及汇总", notes = "头条账户报表统计-账户列表及汇总")
+    @GetMapping(value = "/bytedanceAccountReportListAndCollect")
+    public Result bytedanceAccountReportListAndCollect(@RequestBody AccountReportDTO accountReportDTO) {
+        Result<BytedanceAdvertiserDailyReport> result = new Result<>();
+        result.setSuccess(true);
+
+        return result;
+    }
+
+
 }

+ 17 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceHomepageReportCtrl.java

@@ -39,14 +39,14 @@ public class BytedanceHomepageReportCtrl {
     }
 
     @PostMapping("/report/chart")
-    public Result<List<JSONObject>> getChartReport(@RequestBody JSONObject requestBody) {
-        Result<List<JSONObject>> result = new Result<>();
+    public Result<Map<String,List<JSONObject>>> getChartReport(@RequestBody JSONObject requestBody) {
+        Result<Map<String,List<JSONObject>>> result = new Result<>();
         if(requestBody.isEmpty()){
             log.error("request body is empty");
             result.setSuccess(false);
         }
         try {
-            List<JSONObject> chartReport=bytedanceHomepageReportService.getChartByDate(requestBody);
+            Map<String,List<JSONObject>> chartReport=bytedanceHomepageReportService.getChartByDate(requestBody);
             result.setResult(chartReport);
             result.setSuccess(true);
         } catch (Exception e) {
@@ -55,6 +55,20 @@ public class BytedanceHomepageReportCtrl {
         }
 
         return result;
+    }
+    @PostMapping("/report/compare")
+    public Result<Map<String,JSONObject>> getCompareReport(@RequestBody JSONObject requestBody) {
+        Result<Map<String,JSONObject>> result = new Result<>();
+        try {
+            Map<String,JSONObject> chartReport=bytedanceHomepageReportService.getCompareByDate(requestBody);
+            result.setResult(chartReport);
+            result.setSuccess(true);
+        } catch (Exception e) {
+            log.error(e.getMessage(),e);
+            result.setSuccess(false);
+        }
 
+        return result;
     }
+
 }

+ 70 - 12
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java

@@ -3,6 +3,7 @@ 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.service.IByteDanceVideoReportDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
@@ -24,6 +25,8 @@ public class BytedanceReportController {
     private IBytedanceReportService bytedanceReportService;
     @Autowired
     private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
 
     @PostMapping("/kuaiShou/accountReport")
     public Result<JSONObject> getKuaiShouAccountReport(@RequestBody JSONObject requestJson) {
@@ -185,9 +188,28 @@ public class BytedanceReportController {
                     @Override
                     public void run() {
                         try {
-                            CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(retry.getAccountId()));
+                            String startDate = retry.getStartDate();
+                            String endDate = retry.getEndDate();
+                            Long accountId = retry.getAccountId();
+                            CtopOauthToken token = tokenService.getOauthTokenByAccountId(String.valueOf(accountId));
                             log.info("头条素材报表当前accountId为:" + token.getAccountId());
-                            bytedanceReportService.bytedanceMaterialReportRetry(token, retry.getStartDate(), retry.getEndDate());
+                            //int code = bytedanceReportService.bytedanceMaterialReportRetry(token, startDate, endDate);
+
+                            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 = bytedanceReportService.bytedanceMaterialReport(token, start, end);
+                                if(code ==200 || code == 1){
+                                    //重试成功清洗数据
+                                    byteDanceVideoReportDailyService.videoInfoListByAccountId(start,end,accountId);
+                                }
+                            }
+                            byteDanceVideoReportDailyService.videoInfoListByAccountId(retry.getStartDate(), retry.getEndDate(), token.getAccountId());
+
                         } catch (Exception e) {
                             e.printStackTrace();
                         } finally {
@@ -207,18 +229,54 @@ public class BytedanceReportController {
         return result;
     }
 
+    /**
+     * 绑定头条账户之后的操作,对此账户进行素材报表数据拉取以及素材报表数据清洗
+     * @param accountId
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    @GetMapping("/bytedance/bytedanceMaterialReportAndVideoReport")
+    public Result bytedanceMaterialReportAndVideoReport(@RequestParam(name = "accountId") Long accountId,
+                                          @RequestParam(name = "startDate") String startDate,
+                                          @RequestParam(name = "endDate") String endDate) {
+        Result result = new Result<>();
+        if (StringUtils.isBlank(startDate) || StringUtils.isBlank(endDate) || null == accountId){
+            result.error500("开始时间和结束时间、accountId均不能为空");
+            return result;
+        }
 
+        try {
+            log.info("头条获取素材报表数据任务执行开始");
+            Long starttime = System.currentTimeMillis();
+            CtopOauthToken token = tokenService.getAccessTokenByAccountIdAndMediaId(1,accountId);
+            if (null == token) {
+                log.info("头条获取素材报表数据任务执行失败:未获取到可用的token,accountId:" + accountId);
+                return result;
+            }
 
+            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 = bytedanceReportService.bytedanceMaterialReport(token, start, end);
+                //如果成功的话跑视频清洗数据方法,失败会进入重试库,重试成功后再清洗数据
+                if(code ==200 || code == 1){
+                    byteDanceVideoReportDailyService.videoInfoListByAccountId(start,end,accountId);
+                }
+            }
 
-
-
-
-
-
-
-
-
-
-
+            Long endtime = System.currentTimeMillis();
+            log.info("头条获取素材报表数据任务执行结束,accountId:{},执行耗时:{}秒", accountId, (endtime - starttime) / 1000);
+        } catch (Exception e) {
+            log.error("头条获取素材报表数据任务执行结失败accountId:" + accountId);
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
 
 }

+ 3 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/ByteDanceVideoReportDailyMapper.java

@@ -17,7 +17,9 @@ import java.util.List;
  */
 public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVideoReportDaily> {
 
-    List<ByteDanceVideoReportDaily> videoInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("companyId") String companyId);
+    List<ByteDanceVideoReportDaily> videoInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("companyId") String companyId, @Param("accountId")Long accountId);
+
+    String getCompanyIdByAccountId(@Param("accountId")Long accountId);
 
     BigDecimal getVideoReportDailyByDateAndSignature(@Param("startDate") String date, @Param("endDate") String endDate, @Param("signature") String signature, @Param("accountIds")List<Long> accountIds);
 
@@ -41,8 +43,6 @@ public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVid
 
     List<ByteDanceVideoReportDaily> videoInfoListDetailOperator(@Param("companyId") String companyId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("signature") String signature, @Param("accountIds") List<Long> accountIds);
 
-    //List<ByteDanceVideoReportDaily> bytedanceVideoInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("role") String role, @Param("userId") String userId, @Param("signature") String signature, @Param("companyId") String companyId, @Param("cost") BigDecimal cost);
-
     List<AccountVideoDTO> accountVideoMap();
 
     void replaceIntoAccountVideoMapBatch(@Param("accountVideoDTOList")List<AccountVideoDTO> accountVideoDTOList);

+ 7 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceHomepageMapper.java

@@ -13,22 +13,25 @@ public interface BytedanceHomepageMapper {
     //今日汇总数据
     JSONObject queryTodaySumReportBy(@Param("statDate") String statDate);
 
+    //根据小时区间查询今日汇总数据
+    List<JSONObject> queryTodaySumByHour(@Param("hour") int hour);
+
     //今日明细数据
     List<JSONObject> queryTodayDetailReportBy(@Param("statDate") String statDate);
 
     //根据开始、结束时间 查询汇总数据
-    JSONObject querySumByStartEndDate(@Param("startDate") String anotherDay, @Param("endDate") String endDate);
+    JSONObject querySumByStartEndDate(@Param("endDate") String endDate, @Param("startDate") String startDate);
 
     //根据开始、结束时间 查询明细数据
-     List<JSONObject> queryDetailByStartEndDate(@Param("startDate") String anotherDay, @Param("endDate") String endDate);
+    List<JSONObject> queryDetailByStartEndDate(@Param("endDate") String endDate, @Param("startDate") String startDate);
 
     //按月分组查询明细数据
-    List<JSONObject> queryDetailGroupMonthByDate(@Param("startDate") String anotherDay, @Param("endDate") String endDate);
+    List<JSONObject> queryDetailGroupMonthByDate(@Param("endDate") String endDate, @Param("startDate") String startDate);
 
     //查询固定月的明细数据
     List<JSONObject> queryDetailGroupDayByMonth(@Param("month") String month);
 
     //项目消耗排行榜
-    List<JSONObject> queryTopCost(@Param("startDate") String anotherDay, @Param("endDate") String endDate, @Param("rank") int rank);
+    List<JSONObject> queryTopCost(@Param("endDate") String endDate, @Param("startDate") String startDate, @Param("rank") int rank);
 
 }

+ 24 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/ByteDanceVideoReportDailyMapper.xml

@@ -288,6 +288,8 @@
 
     <select id="videoInfoListDetail" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
                 select
+                a.project_id as projectId,
+                a.project_name as projectName,
                 a.account_id as accountId,
                 a.advertiser_id as advertiserId,
                 a.advertiser_name as advertiserName,
@@ -319,6 +321,8 @@
 
     <select id="videoInfoListDetailOperator" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
+        a.project_id as projectId,
+        a.project_name as projectName,
         a.account_id as accountId,
         a.advertiser_id as advertiserId,
         a.advertiser_name as advertiserName,
@@ -347,6 +351,8 @@
 
     <select id="videoInfoListDetailDesign" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
+        a.project_id as projectId,
+        a.project_name as projectName,
         a.account_id as accountId,
         a.advertiser_id as advertiserId,
         a.advertiser_name as advertiserName,
@@ -425,8 +431,7 @@
         and media_id = #{mediaId}
     </select>
 
-    <select id="videoInfoList" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
+    <sql id="videoInfoSql">
         a.account_id as accountId,
         b.project_id as projectId,
         b.project_name as projectName,
@@ -629,10 +634,14 @@
         when sum(a.click) != 0
         then sum(a.download_start)/sum(a.click)
         else 0 end as downloadStartRate, --  应用下载广告数据-安卓下载开始率  计算方法:安卓下载开始数/点击数
+    </sql>
 
+    <select id="videoInfoList" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+        select
+        <include refid="videoInfoSql"></include>
         #{companyId} as companyId
         from ctop_bytedance_report_material_daily a
-        left join ctop_user_allocation b on a.account_id = b.account_id
+        left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
         left join user_company c on b.user_id = c.user_id
         left join ctop_bytedance_video_info d on a.material_id = d.material_id
         left join (select code,url,material_name from ctop_material_info group by code) e on d.signature = e.code
@@ -641,9 +650,21 @@
         'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL')
         and date_format(stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
         and date_format(stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
+        <if test="accountId != null">
+            and a.account_id = #{accountId}
+        </if>
         group by `statDatetime`,`accountId`,`signature`
     </select>
 
+    <select id="getCompanyIdByAccountId" resultType="string">
+        select
+        c.company_id
+        from
+        ctop_user_allocation b
+        left join user_company c on b.user_id = c.user_id
+        where b.account_id = #{accountId}
+    </select>
+
     <select id="videoInfoListGroupOperator" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>

+ 143 - 25
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceHomepageMapper.xml

@@ -7,7 +7,7 @@
        SELECT
 	     ROUND(sum(cost),2) cost,
 	     sum(show_num) showNum,
-	     sum(stat_datetime) click,
+	     sum(click) click,
 	     max(stat_hour) maxHour
        FROM
 	      ctop_bytedance_report_advertiser_hourly
@@ -15,22 +15,59 @@
 	      stat_datetime = #{statDate}
       </select>
 
+    <select id="queryTodaySumByHour" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            ROUND(sum(cost),2) cost,
+            sum(show_num) showNum,
+            sum(click) click
+        FROM
+            ctop_bytedance_report_advertiser_hourly
+        WHERE
+            stat_hour &lt;= #{hour}
+    </select>
 
     <select id="queryTodayDetailReportBy" resultType="com.alibaba.fastjson.JSONObject">
-       SELECT
-         stat_datetime statDate,
-         stat_hour statHour,
-	     ROUND(sum(cost),2) cost,
-	     sum(show_num) showNum,
-	     sum(click) click
-	   FROM
-	      ctop_bytedance_report_advertiser_hourly
-       WHERE
-	      stat_datetime = #{statDate}
-       GROUP BY
-	      stat_hour
-       ORDER BY
-	      stat_hour ASC
+        SELECT
+            stat_datetime statDate,
+            stat_hour statHour,
+            ROUND(sum(cost), 2) cost,
+            sum(show_num) showNum,
+            sum(click) click,
+            CASE
+                WHEN (click / show_num) IS NULL THEN
+                    0
+                ELSE
+                    CONCAT(
+                            ROUND(
+                                    (click / show_num) * 100,
+                                    2
+                                ),
+                            '%'
+                        )
+                END AS 'clickRate',
+            CASE
+                WHEN (cost / show_num) IS NULL THEN
+                    0
+                ELSE
+                    ROUND(
+                            (cost / show_num) * 1000,
+                            2
+                        )
+                END AS 'cpm',
+            CASE
+                WHEN (click / cost) IS NULL THEN
+                    0
+                ELSE
+                    ROUND((cost / click), 2)
+                END AS 'cp'
+        FROM
+            ctop_bytedance_report_advertiser_hourly
+        WHERE
+            stat_datetime = #{statDate}
+        GROUP BY
+            stat_hour
+        ORDER BY
+            stat_hour ASC
 
     </select>
 
@@ -49,9 +86,36 @@
 
     <select id="queryDetailByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
        SELECT
-         ROUND(sum(cost), 2) cost,
-         sum(show_num) showNum,
-         sum(click) click,
+           ROUND(sum(cost), 2) cost,
+           sum(show_num) showNum,
+           sum(click) click,
+           CASE
+               WHEN (sum(click) / sum(show_num)) IS NULL THEN
+                   0
+               ELSE
+                   CONCAT(
+                           ROUND(
+                                   (sum(click) / sum(show_num)) * 100,
+                                   2
+                               ),
+                           '%'
+                       )
+               END AS 'clickRate',
+           CASE
+               WHEN (sum(cost) / sum(show_num)) IS NULL THEN
+                   0
+               ELSE
+                   ROUND(
+                           (sum(cost) / sum(show_num)) * 1000,
+                           2
+                       )
+               END AS 'cpm',
+           CASE
+               WHEN (sum(click) / sum(cost)) IS NULL THEN
+                   0
+               ELSE
+                   ROUND((sum(cost) / sum(click)), 2)
+               END AS 'cp',
          DATE_FORMAT(stat_datetime,'%Y-%m-%d') statDate
        FROM
          ctop_bytedance_report_advertiser_daily
@@ -64,9 +128,36 @@
 
     <select id="queryDetailGroupMonthByDate" resultType="com.alibaba.fastjson.JSONObject">
        SELECT
-         ROUND(sum(cost), 2) cost,
-         sum(show_num) showNum,
-         sum(click) click,
+           ROUND(sum(cost), 2) cost,
+           sum(show_num) showNum,
+           sum(click) click,
+           CASE
+               WHEN (sum(click) / sum(show_num)) IS NULL THEN
+                   0
+               ELSE
+                   CONCAT(
+                           ROUND(
+                                   (sum(click) / sum(show_num)) * 100,
+                                   2
+                               ),
+                           '%'
+                       )
+               END AS 'clickRate',
+           CASE
+               WHEN (sum(cost) / sum(show_num)) IS NULL THEN
+                   0
+               ELSE
+                   ROUND(
+                           (sum(cost) / sum(show_num)) * 1000,
+                           2
+                       )
+               END AS 'cpm',
+           CASE
+               WHEN (sum(click) / sum(cost)) IS NULL THEN
+                   0
+               ELSE
+                   ROUND((sum(cost) / sum(click)), 2)
+               END AS 'cp',
          DATE_FORMAT(stat_datetime,'%Y-%m') statDate
        FROM
          ctop_bytedance_report_advertiser_daily
@@ -79,10 +170,37 @@
     </select>
 
     <select id="queryDetailGroupDayByMonth" resultType="com.alibaba.fastjson.JSONObject">
-       SELECT
-         ROUND(sum(cost), 2) cost,
-         sum(show_num) showNum,
-         sum(click) click,
+        SELECT
+            ROUND(sum(cost), 2) cost,
+            sum(show_num) showNum,
+            sum(click) click,
+            CASE
+                WHEN (sum(click) / sum(show_num)) IS NULL THEN
+                    0
+                ELSE
+                    CONCAT(
+                            ROUND(
+                                    (sum(click) / sum(show_num)) * 100,
+                                    2
+                                ),
+                            '%'
+                        )
+                END AS 'clickRate',
+            CASE
+                WHEN (sum(cost) / sum(show_num)) IS NULL THEN
+                    0
+                ELSE
+                    ROUND(
+                            (sum(cost) / sum(show_num)) * 1000,
+                            2
+                        )
+                END AS 'cpm',
+            CASE
+                WHEN (sum(click) / sum(cost)) IS NULL THEN
+                    0
+                ELSE
+                    ROUND((sum(cost) / sum(click)), 2)
+                END AS 'cp',
          DATE_FORMAT(stat_datetime,'%Y-%m-%d') statDate,
          SUBSTR(DATE_FORMAT(stat_datetime,'%Y-%m-%d') FROM 9 FOR 2) day
        FROM

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

@@ -17,6 +17,8 @@ public interface IByteDanceVideoReportDailyService extends IService<ByteDanceVid
 
     void videoInfoList(String startDate, String endDate);
 
+    void videoInfoListByAccountId(String startDate, String endDate, Long accountId);
+
     PageInfo<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort);
 
     PageInfo<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort);

+ 4 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceHomepageReportService.java

@@ -7,9 +7,10 @@ import java.util.Map;
 
 public interface IBytedanceHomepageReportService {
 
-    Map<String,JSONObject> getWeekReport(JSONObject json);
+    Map<String,JSONObject> getWeekReport(JSONObject requestBody);
 
-    List<JSONObject> getChartByDate(JSONObject json);
+    Map<String,List<JSONObject>> getChartByDate(JSONObject requestBody);
+
+    Map<String,JSONObject> getCompareByDate(JSONObject requestBody);
 
-    JSONObject getTopCostByDate(JSONObject json);
 }

+ 2 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceReportService.java

@@ -37,9 +37,9 @@ public interface IBytedanceReportService {
 
     void bytedanceAsyncTaskGet();
 
-    void bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate);
+    int bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate);
 
-    void bytedanceMaterialReportRetry(CtopOauthToken token, String startDate, String endDate);
+    int bytedanceMaterialReportRetry(CtopOauthToken token, String startDate, String endDate);
 
     List<BytedanceReportMaterialRetry> getRetryList();
 }

+ 51 - 78
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ByteDanceVideoReportDailyServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
+import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
 import cn.com.ctop.toutiao.modules.report.DTO.AccountVideoDTO;
 import cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily;
 import cn.com.ctop.toutiao.modules.report.mapper.ByteDanceVideoReportDailyMapper;
@@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
@@ -16,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -28,11 +29,13 @@ import java.util.List;
  * @version V1.0
  */
 @Service
+@Slf4j
 public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceVideoReportDailyMapper, ByteDanceVideoReportDaily> implements IByteDanceVideoReportDailyService {
 
     @Autowired
     private ByteDanceVideoReportDailyMapper byteDanceVideoReportDailyMapper;
 
+    @Override
     public void videoInfoList(String startDate, String endDate){
         //华南
         videoInfoListByCompanyId(startDate, endDate, "6608ed13c0dd42de93c790dbdf124234");
@@ -49,30 +52,32 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         wrapper.eq("company_id", companyId);
         byteDanceVideoReportDailyMapper.delete(wrapper);
 
-        List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoList(startDate, endDate, companyId);
+        List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoList(startDate, endDate, companyId, null);
         for (ByteDanceVideoReportDaily m:mList){
             byteDanceVideoReportDailyMapper.insert(m);
         }
+    }
+
+    //根据accountId和时间清洗头条素材为头条视频报表数据
+    @Override
+    public void videoInfoListByAccountId(String startDate, String endDate, Long accountId){
+        QueryWrapper<ByteDanceVideoReportDaily> wrapper = new QueryWrapper<>();
+        wrapper.ge("stat_datetime",startDate);
+        wrapper.le("stat_datetime",endDate);
+        wrapper.eq("account_id", accountId);
+        byteDanceVideoReportDailyMapper.delete(wrapper);
 
-        //QueryWrapper<ByteDanceVideoReportDaily> queryWrapper = new QueryWrapper<>();
-
-        //List<ByteDanceVideoReportDaily> mList2 = byteDanceVideoReportDailyMapper.selectList(wrapper);
-        //
-        //for(ByteDanceVideoReportDaily m:mList2){
-        //    String statDate  = DateUtils.formatDate(DateUtils.addDay(m.getStatDatetime(),-1));
-        //    BigDecimal cost = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(statDate,statDate,m.getSignature(),companyId);
-        //
-        //    BigDecimal huanbi =BigDecimal.ZERO;
-        //    if(cost != null && cost.compareTo(BigDecimal.ZERO)>0){
-        //        huanbi = m.getCost().subtract(cost).divide(cost,7, BigDecimal.ROUND_HALF_UP);
-        //    }
-        //
-        //    m.setHuanbi(huanbi);
-        //    byteDanceVideoReportDailyMapper.updateById(m);
-        //}
+        String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByAccountId(accountId);
+
+        List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoList(startDate, endDate, companyId, accountId);
+        for (ByteDanceVideoReportDaily m:mList){
+            byteDanceVideoReportDailyMapper.insert(m);
+        }
+        log.info("根据accountId和时间清洗头条素材为头条视频报表数据结束,开始时间:{},结束时间:{},accountId:{}",startDate,endDate,accountId );
     }
 
     //视频按天列表
+    @Override
     public PageInfo<ByteDanceVideoReportDaily> videoInfoListDaily(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
@@ -91,11 +96,11 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             accountIdsList = Arrays.asList(accountIds);
         }
         //admin能看所有视频
-        if(roleCode.equals("admin")){
+        if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (accountIdsList != null && accountIdsList.size() != 0){
+            if (accountIdsList != null && !accountIdsList.isEmpty()){
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
@@ -136,12 +141,12 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             m.setHuanbi(huanbi);
         }
 
-        PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
-        return pageInfo;
+        return new PageInfo<>(mList);
     }
 
 
     //视频报表月列表
+    @Override
     public PageInfo<ByteDanceVideoReportDaily> videoInfoListMonth(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
@@ -160,11 +165,11 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             accountIdsList = Arrays.asList(accountIds);
         }
         //admin能看所有视频
-        if(roleCode.equals("admin")){
+        if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (accountIdsList != null && accountIdsList.size() != 0){
+            if (accountIdsList != null && !accountIdsList.isEmpty()){
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
@@ -201,16 +206,15 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
                 huanbi = m.getCost().subtract(costBefore).divide(costBefore,7, BigDecimal.ROUND_HALF_UP);
             }
-
             m.setHuanbi(huanbi);
         }
 
-        PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
-        return pageInfo;
+        return new PageInfo<>(mList);
     }
 
 
     //视频总报表列表
+    @Override
     public PageInfo<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost , Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
@@ -229,11 +233,11 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             accountIdsList = Arrays.asList(accountIds);
         }
         //admin能看所有视频
-        if(roleCode.equals("admin")){
+        if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (accountIdsList != null && accountIdsList.size() != 0){
+            if (accountIdsList != null && !accountIdsList.isEmpty()){
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
@@ -273,30 +277,16 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
 
             m.setHuanbi(huanbi);
         }
-
-        PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
-        return pageInfo;
+        return new PageInfo<>(mList);
     }
 
     //视频总报表列表导出excel
+    @Override
     public List<ByteDanceVideoReportDaily> videoInfoListTotalExcel(String startDate, String endDate, String signature, BigDecimal cost , Long[] accountIds, String sort){
-        //LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        //String userId = sysUser.getId();
-        //String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
-        //String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
-        //
-        //List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoListWeek(startDate, endDate, roleCode, userId, signature, companyId, cost);
-
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
         String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
-
-        if(StringUtils.isBlank(sort)){
-            sort = "cost-";
-        }
-        sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
-        sort = sort.substring(0, sort.length() - 1);
         List<ByteDanceVideoReportDaily> mList = new ArrayList<>();
 
         List<Long> accountIdsList = null;
@@ -304,10 +294,10 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             accountIdsList = Arrays.asList(accountIds);
         }
         //admin能看所有视频
-        if(roleCode.equals("admin")){
+        if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (accountIdsList != null && accountIdsList.size() != 0){
+            if (accountIdsList != null && !accountIdsList.isEmpty()){
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(1,userId);
@@ -324,26 +314,11 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         }else if(roleCode.equals("designTeamLeader")){
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
         }
-
-        //计算环比
-        //for(ByteDanceVideoReportDaily m:mList){
-        //    Integer datediff = DateUtils.dateDiff(startDate, endDate);
-        //    String startMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-(datediff + 1) ) );
-        //    String endMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-1));
-        //
-        //    BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(startMonthDate,endMonthDate,m.getSignature(),accountIdsList);
-        //
-        //    BigDecimal huanbi =BigDecimal.ZERO;
-        //    if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
-        //        huanbi = m.getCost().subtract(costBefore).divide(costBefore,7, BigDecimal.ROUND_HALF_UP);
-        //    }
-        //
-        //    m.setHuanbi(huanbi);
-        //}
         return mList;
     }
 
     //视频报表周列表
+    @Override
     public PageInfo<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
@@ -362,11 +337,11 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             accountIdsList = Arrays.asList(accountIds);
         }
         //admin能看所有视频
-        if(roleCode.equals("admin")){
+        if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (accountIdsList != null && accountIdsList.size() != 0){
+            if (accountIdsList != null && !accountIdsList.isEmpty()){
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
@@ -407,18 +382,16 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             m.setHuanbi(huanbi);
         }
 
-        PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
-
-        return pageInfo;
+        return new PageInfo<>(mList);
     }
 
+    @Override
     public List<ByteDanceVideoReportDaily> videoInfoListDetail(String startDate, String endDate, String signature, Long[] accountIds){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
         String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
 
-        //List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoListDetail(companyId, startDate, endDate, signature, roleCode);
         List<ByteDanceVideoReportDaily> mList =new ArrayList<>();
 
         List<Long> accountIdsList = null;
@@ -426,10 +399,10 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             accountIdsList = Arrays.asList(accountIds);
         }
         //admin能看所有视频
-        if(roleCode.equals("admin")){
+        if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             mList = byteDanceVideoReportDailyMapper.videoInfoListDetail(companyId, startDate, endDate, signature, accountIdsList);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (accountIdsList != null && accountIdsList.size() != 0){
+            if (accountIdsList != null && !accountIdsList.isEmpty()){
                 mList = byteDanceVideoReportDailyMapper.videoInfoListDetailOperator(companyId, startDate,endDate,signature, accountIdsList);
             }else{
                 accountIdsList= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(1,userId);
@@ -454,11 +427,7 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
 
         //计算环比
         for(ByteDanceVideoReportDaily m:mList){
-            //Integer datediff = DateUtils.dateDiff(startDate, endDate);
-            //String startMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-(datediff + 1) ) );
             String beforeDate = DateUtils.formatDate(DateUtils.addDay(m.getStatDatetime(),-1));
-            //List<Long> accountIdsList = new ArrayList<>();
-            //accountIdsList.add(m.getAccountId());
             BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(beforeDate,beforeDate,m.getSignature(),accountIdsList);
 
             BigDecimal huanbi =BigDecimal.ZERO;
@@ -472,12 +441,14 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         return mList;
     }
 
+    @Override
     public String getColumnJson(Integer columnType){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         return byteDanceVideoReportDailyMapper.getJsonByUserIdAndColumnType(columnType, userId);
     }
 
+    @Override
     public void saveOrUpdateColumnJson(Integer columnType, String json){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
@@ -490,21 +461,23 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         }
     }
 
+    @Override
     public int videoInfoListTotalExportExcelPermission(){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
 
-        if(roleCode.equals("admin")  || roleCode.equals("designTeamLeader") ){
+        if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)  || roleCode.equals("designTeamLeader") ){
             return 1;
         }else{
             return 0;
         }
     }
 
+    @Override
     public void accountVideoMap(){
-        List<AccountVideoDTO> accountVideoDTOList = byteDanceVideoReportDailyMapper.accountVideoMap();
-        byteDanceVideoReportDailyMapper.replaceIntoAccountVideoMapBatch(accountVideoDTOList);
+        List<AccountVideoDTO> accountVideos = byteDanceVideoReportDailyMapper.accountVideoMap();
+        byteDanceVideoReportDailyMapper.replaceIntoAccountVideoMapBatch(accountVideos);
     }
 
 }

+ 44 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAdvertiserDailyReportServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
+import cn.com.ctop.toutiao.modules.report.DTO.AccountReportDTO;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceAdvertiserDailyReport;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceAdvertiserDailyReportMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceAdvertiserDailyReportService;
@@ -7,6 +8,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.util.List;
+
 /**
  * @Description: 广告主日报表
  * @Author: jeecg-boot
@@ -18,4 +22,44 @@ import org.springframework.stereotype.Service;
 
 public class BytedanceAdvertiserDailyReportServiceImpl extends ServiceImpl<BytedanceAdvertiserDailyReportMapper, BytedanceAdvertiserDailyReport> implements IBytedanceAdvertiserDailyReportService {
 
+    public void bytedanceAccountReportStatistics(AccountReportDTO accountReportDTO){
+        String startDate = accountReportDTO.getStartDate();
+        String endDate = accountReportDTO.getEndDate();
+        BigDecimal discount = accountReportDTO.getDiscount();  //仅头条内广可用 折扣
+        BigDecimal point = accountReportDTO.getPoint();  //仅头条可用 返点
+        List<Long> accountIds = accountReportDTO.getAccountIds();
+        Integer statHour = accountReportDTO.getStatHour();
+        Integer type = accountReportDTO.getType();  //1今天  2昨天和其他单天 3近一周、15天、1月、3月按钮 4六个月、一年 5输入框输入的除了单天的时间段
+
+        //type=1分时操作
+        if(type == 1){
+
+        }else if(type == 2){
+
+        }else if(type == 3 || type == 5){
+
+        }
+
+
+
+
+
+
+
+    }
+
+
+
+
+    public void bytedanceAccountReportListAndCollect(AccountReportDTO accountReportDTO){
+
+
+
+
+
+
+
+    }
+
+
 }

+ 100 - 41
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceHomepageReportServiceImpl.java

@@ -44,23 +44,29 @@ public class BytedanceHomepageReportServiceImpl implements IBytedanceHomepageRep
         top.put("top7", costTop);
         //周明细环比数据拼接
         JSONObject costWeekData = new JSONObject();
+        JSONObject costWeekLink = new JSONObject();
         JSONObject clickWeekData = new JSONObject();
+        JSONObject clickWeekLink = new JSONObject();
         JSONObject showNumWeekData = new JSONObject();
+        JSONObject showNumWeekLink = new JSONObject();
         weekDetailData.forEach(day -> {
             costWeekData.put((String) day.get("statDate"), day.get("cost"));
             clickWeekData.put((String) day.get("statDate"), day.get("click"));
             showNumWeekData.put((String) day.get("statDate"), day.get("showNum"));
         });
-        costWeekData.put("weekCostSum", weekSumData.get("cost"));
-        costWeekData.put("weekCostSumLink", countLink(weekSumData.getBigDecimal("cost"), weekBeforeSumData.getBigDecimal("cost")));
-        clickWeekData.put("weekClickSum", weekSumData.get("click"));
-        clickWeekData.put("weekClickSumLink", countLink(BigDecimal.valueOf(weekSumData.getLongValue("click")), BigDecimal.valueOf(weekBeforeSumData.getLong("click"))));
-        showNumWeekData.put("weekCostSum", weekSumData.get("showNum"));
-        showNumWeekData.put("weekShowNumSumLink", countLink(BigDecimal.valueOf(weekSumData.getLongValue("showNum")), BigDecimal.valueOf(weekBeforeSumData.getLong("showNum"))));
+        costWeekLink.put("weekCostSum", weekSumData.get("cost"));
+        costWeekLink.put("weekCostSumLink", countLink(weekSumData.getBigDecimal("cost"), weekBeforeSumData.getBigDecimal("cost")));
+        clickWeekLink.put("weekClickSum", weekSumData.get("click"));
+        clickWeekLink.put("weekClickSumLink", countLink(BigDecimal.valueOf(weekSumData.getLongValue("click")), BigDecimal.valueOf(weekBeforeSumData.getLong("click"))));
+        showNumWeekLink.put("weekShowNumSum", weekSumData.get("showNum"));
+        showNumWeekLink.put("weekShowNumSumLink", countLink(BigDecimal.valueOf(weekSumData.getLongValue("showNum")), BigDecimal.valueOf(weekBeforeSumData.getLong("showNum"))));
 
         result.put("costWeek", costWeekData);
+        result.put("costWeekLink", costWeekLink);
         result.put("clickWeek", clickWeekData);
+        result.put("clickWeekLink", clickWeekLink);
         result.put("showNumWeek", showNumWeekData);
+        result.put("showNumWeekLink", showNumWeekLink);
         result.put("top", top);
 
         return result;
@@ -70,12 +76,14 @@ public class BytedanceHomepageReportServiceImpl implements IBytedanceHomepageRep
      * timeType :1,2,3,4,5,6,7,8,9  前端约束入参类型
      */
     @Override
-    public List<JSONObject> getChartByDate(JSONObject requestBody) {
+    public Map<String,List<JSONObject>> getChartByDate(JSONObject requestBody) {
         int timeType = requestBody.getInteger("type");
-        List<JSONObject> resultBody = new ArrayList<>();
+        Map<String,List<JSONObject>> resultBody=new HashMap<>();
         if (requestBody.isEmpty()) {
             return resultBody;
         }
+        List<JSONObject> resultChart = new ArrayList<>();
+        List<JSONObject> resultList = new ArrayList<>();
         //当天日期
         String nowDate = DateUtils.getNowDate(SystemDateConstant.yyyy_MM_dd);
         //startTime 为取什么时间段数据的开始时间,默认昨天
@@ -83,69 +91,128 @@ public class BytedanceHomepageReportServiceImpl implements IBytedanceHomepageRep
         switch (timeType) {
             //今天
             case 1:
-                resultBody = getCompareGroupByHour(nowDate, anotherDay);
+                resultChart = getCompareGroupByHour(nowDate, anotherDay);
+                resultList = getFormDetailByDate(nowDate,nowDate,"hour");
                 break;
             //昨天
             case 2:
-                resultBody = bytedanceHomepageMapper.queryTodayDetailReportBy(anotherDay);
+                resultChart = getCompareGroupByHour(anotherDay, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, anotherDay, -1));
+                resultList = getFormDetailByDate(anotherDay,anotherDay,"hour");
                 break;
             //近一周
             case 3:
-                resultBody = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
+                resultChart = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
                         DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, anotherDay, -6));
+                resultList = getFormDetailByDate(nowDate, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, anotherDay, -6),"day");
                 break;
             //近半个月(15天)
             case 4:
-                resultBody = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
+                resultChart = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
                         DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, anotherDay, -14));
+                resultList = getFormDetailByDate(nowDate, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, anotherDay, -14),"day");
                 break;
             //近一个月
             case 5:
-                resultBody = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
+                resultChart = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
                         DateUtils.getMonthBefore(SystemDateConstant.yyyy_MM_dd, anotherDay, -1));
+                resultList = getFormDetailByDate(nowDate, DateUtils.getMonthBefore(SystemDateConstant.yyyy_MM_dd, anotherDay, -1),"day");
                 break;
             //近三个月
             case 6:
-                resultBody = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
+                resultChart = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
                         DateUtils.getMonthBefore(SystemDateConstant.yyyy_MM_dd, anotherDay, -3));
+                resultList = getFormDetailByDate(nowDate, DateUtils.getMonthBefore(SystemDateConstant.yyyy_MM_dd, anotherDay, -3),"day");
                 break;
             //近半年
             case 7:
-                resultBody = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
+                resultChart = bytedanceHomepageMapper.queryDetailByStartEndDate(nowDate,
                         DateUtils.getMonthBefore(SystemDateConstant.yyyy_MM_dd, anotherDay, -6));
+                resultList = getFormDetailByDate(nowDate, DateUtils.getMonthBefore(SystemDateConstant.yyyy_MM_dd, anotherDay, -6),"day");
                 break;
-            //全部数据
+            //近一年
             case 8:
-                resultBody = bytedanceHomepageMapper.queryDetailGroupMonthByDate(SystemDateConstant.BEGIN_TIME, nowDate);
+                resultChart = bytedanceHomepageMapper.queryDetailGroupMonthByDate( nowDate, SystemDateConstant.BEGIN_TIME);
+                resultList = getFormDetailByDate(nowDate, SystemDateConstant.BEGIN_TIME,"day");
                 break;
             //自定义起始时间
             case 9:
-                resultBody = bytedanceHomepageMapper.queryDetailByStartEndDate(requestBody.getString("startDate"), requestBody.getString("endDate"));
-                break;
-            //对比
-            case 10:
-                resultBody = getChartByType_10(requestBody.getString("sign"), requestBody.getString("smallDate"), requestBody.getString("bigDate"));
+                resultChart = bytedanceHomepageMapper.queryDetailByStartEndDate(requestBody.getString("endDate"), requestBody.getString("startDate"));
+                resultList = getFormDetailByDate(requestBody.getString("endDate"), requestBody.getString("startDate"),"day");
                 break;
             default:
         }
+        resultBody.put("chart",resultChart);
+        resultBody.put("list",resultList);
         return resultBody;
     }
 
     @Override
-    public JSONObject getTopCostByDate(JSONObject requestBody) {
-        return null;
+    public Map<String, JSONObject> getCompareByDate(JSONObject requestBody) {
+        Map<String,JSONObject> resultBody=new HashMap<>();
+        if (requestBody.isEmpty()) {
+            return resultBody;
+        }
+        String sign= requestBody.getString("sign");
+        String smallDate= requestBody.getString("smallDate");
+        String bigDate= requestBody.getString("bigDate");
+        resultBody.put("chart",this.getCompareChart(sign,smallDate,bigDate));
+        resultBody.put("list",this.getCompareList(sign,smallDate,bigDate));
+
+        return resultBody;
+    }
+
+
+    //表格数据查询
+    private List<JSONObject> getFormDetailByDate(String endDate, String startDate, String group){
+        List<JSONObject> result =null;
+        if("day".equals(group)){
+            result= bytedanceHomepageMapper.queryDetailByStartEndDate(endDate,startDate);
+        }else {
+            result= bytedanceHomepageMapper.queryTodayDetailReportBy(endDate);
+        }
+        return getListLink(result);
     }
 
     //自定义日期对比(日对比,月对比)
-    private List<JSONObject> getChartByType_10(String sign, String smallDate, String bigDate) {
-        List<JSONObject> result = new ArrayList<>();
+    private JSONObject getCompareChart(String sign, String smallDate, String bigDate) {
+        JSONObject result = new JSONObject();
         if (!sign.isEmpty() && sign.equals("month")) {
-            result = this.getCompareGroupByDay(smallDate, bigDate);
+            result.put("compare",this.getCompareGroupByDay(smallDate, bigDate));
         } else if (!sign.isEmpty() && sign.equals("day")) {
-            result = this.getCompareGroupByHour(bigDate, smallDate);
+            result.put("compare",this.getCompareGroupByHour(bigDate, smallDate));
+        }
+        return result;
+    }
+    private JSONObject getCompareList(String sign, String smallDate, String bigDate){
+        JSONObject result = new JSONObject();
+        if (!sign.isEmpty() && sign.equals("month")) {
+            result.put("smallDate",getListLink(bytedanceHomepageMapper.queryDetailGroupDayByMonth(smallDate)));
+            result.put("bigDate",getListLink(bytedanceHomepageMapper.queryDetailGroupDayByMonth(bigDate)));
+        } else if (!sign.isEmpty() && sign.equals("day")) {
+            result.put("smallDate",getListLink(bytedanceHomepageMapper.queryTodayDetailReportBy(smallDate)));
+            result.put("bigDate",getListLink(bytedanceHomepageMapper.queryTodayDetailReportBy(bigDate)));
         }
         return result;
     }
+    //List环比计算
+    private List<JSONObject> getListLink(List<JSONObject> result){
+        if(result.size()>1){
+            for(int i=1;i<result.size();i++){
+                if(i==1){result.get(i).put("costProportion",BigDecimal.ZERO);}
+                result.get(i).put("costProportion",countLink((BigDecimal) result.get(i).get("cost"),(BigDecimal) result.get(i-1).get("cost")));
+            }
+        }
+        return result;
+    }
+    /*private JSONObject getCompareSum(String sign, String smallDate, String bigDate){
+        JSONObject result = new JSONObject();
+        if (!sign.isEmpty() && sign.equals("month")) {
+            bytedanceHomepageMapper.querySumByStartEndDate()
+        } else if (!sign.isEmpty() && sign.equals("day")) {
+            result = this.getCompareGroupByHour(bigDate, smallDate);
+        }
+        return result;
+    }*/
 
     //两个月份的数据对比
     private List<JSONObject> getCompareGroupByDay(String smallDate, String bigDate) {
@@ -153,15 +220,8 @@ public class BytedanceHomepageReportServiceImpl implements IBytedanceHomepageRep
         List<JSONObject> afterDetail = bytedanceHomepageMapper.queryDetailGroupDayByMonth(bigDate);
         //小月份数据
         List<JSONObject> beforeDetail = bytedanceHomepageMapper.queryDetailGroupDayByMonth(smallDate);
-        List<JSONObject> beforeData;List<JSONObject> afterData;
-        if (afterDetail.size() >= beforeDetail.size()) {
-            beforeData = afterDetail;
-            afterData = beforeData;
-        } else {
-            beforeData = beforeDetail;
-            afterData = afterDetail;
-        }
-        return this.getCompareDate(beforeData,afterData,"day");
+
+        return this.getCompareDate(beforeDetail,afterDetail,"day");
     }
 
     //今天昨天数据对比
@@ -175,9 +235,9 @@ public class BytedanceHomepageReportServiceImpl implements IBytedanceHomepageRep
     private List<JSONObject> getCompareDate(List<JSONObject> beforeData, List<JSONObject> AfterData, String standard) {
         List<JSONObject> result = new ArrayList<>();
         beforeData.forEach(before -> {
-            String yesStatHour = String.valueOf(before.get(standard));
+            String yesStat = String.valueOf(before.get(standard));
             AfterData.forEach(after -> {
-                if ((String.valueOf(after.get(standard))).equals(yesStatHour)) {
+                if ((String.valueOf(after.get(standard))).equals(yesStat)) {
                     //消耗较昨日环比
                     after.put("costProportion", countLink(after.getBigDecimal("cost"), before.getBigDecimal("cost")));
                     //展示量较昨日环比
@@ -201,5 +261,4 @@ public class BytedanceHomepageReportServiceImpl implements IBytedanceHomepageRep
         return link;
     }
 
-}
-
+}

+ 4 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportServiceImpl.java

@@ -710,7 +710,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
     /////////////////////////////////////////////////////////\
     //素材报表
     @Override
-    public void bytedanceMaterialReportRetry(CtopOauthToken token, String startDate, String endDate) {
+    public int bytedanceMaterialReportRetry(CtopOauthToken token, String startDate, String endDate) {
         Long accountId = token.getAccountId();
         // log.info("头条素材报表当前accountId为:" + accountId);
         Integer page = 1;
@@ -729,10 +729,11 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             retry.setStatus(1);
             bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
         }
+        return code;
     }
 
     @Override
-    public void bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate) {
+    public int bytedanceMaterialReport(CtopOauthToken token, String startDate, String endDate) {
         Long accountId = token.getAccountId();
         // log.info("头条素材报表当前accountId为:" + accountId);
         Integer page = 1;
@@ -747,6 +748,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
             retry.setStatusCode(code);
             bytedanceReportMaterialDailyMapper.replaceMaterialRetry(retry);
         }
+        return code;
     }
 
     private int bytedanceMaterialReportByPage(Integer page, Integer pageSize, CtopOauthToken token, Long accountId, String startDate, String endDate) {

+ 26 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -247,6 +248,11 @@ public class ReportServiceImpl implements IReportService {
 
     @Autowired
     private BytedanceReportMaterialDailyMapper materialDailyMapper;
+    @Autowired
+    private IBytedanceReportService bytedanceReportService;
+    @Autowired
+    private IByteDanceVideoReportDailyService byteDanceVideoReportDailyService;
+
     @Override
     public void loadBytedanceHistoryData(CtopOauthToken token) {
         for (int i = 1; i < 180; i++) {
@@ -255,6 +261,26 @@ public class ReportServiceImpl implements IReportService {
             this.getAdvertiserPlanReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
             this.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
         }
+
+        try {
+            log.info("获取历史素材报表:accountId:{}", token.getAccountId());
+            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+            String endDate = DateUtils.addDay(nowDate, -180);
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            Date end = simpleDateFormat.parse(nowDate);
+            Date start = simpleDateFormat.parse(endDate);
+            List<Date> dates = DateUtils.findDates(start, end);
+            for (int i = 0; i < dates.size(); i++) {
+                String formatDate = simpleDateFormat.format(dates.get(i));
+                int code = bytedanceReportService.bytedanceMaterialReport(token, formatDate, formatDate);
+                //如果成功的话跑视频清洗数据方法,失败会进入重试库,重试成功后再清洗数据
+                if (code == 200 || code == 1) {
+                    byteDanceVideoReportDailyService.videoInfoListByAccountId(formatDate, formatDate, token.getAccountId());
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
     private ByteDanceAdvertiserReportDTO getReportDTO(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {