Ver código fonte

Merge branch 'master' of http://git.tjyourong.com.cn/ctop/adsp-boot

xuzuoyun 4 anos atrás
pai
commit
b7379c5a48
71 arquivos alterados com 2705 adições e 172 exclusões
  1. 31 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/UserAllocationController.java
  2. 3 3
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/MaterialTopMapper.xml
  3. 15 0
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  4. 246 0
      jeecg-boot-module-system/src/main/resources/application-jiaoyang.yml
  5. 15 0
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  6. 15 0
      jeecg-boot-module-system/src/main/resources/application-prod2.yml
  7. 16 1
      jeecg-boot-module-system/src/main/resources/application-test.yml
  8. 15 0
      jeecg-boot-module-system/src/main/resources/application-wps.yml
  9. 16 3
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  10. 27 16
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java
  11. 39 9
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java
  12. 5 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java
  13. 0 2
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccount.java
  14. 45 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccountKuaishou.java
  15. 42 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java
  16. 27 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDatePlanKuaishou.java
  17. 50 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDateUnitKuaishou.java
  18. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/UserAllocation.java
  19. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDataAccountKuaishouMapper.java
  20. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDataTargetKuaishouMapper.java
  21. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDatePlanKuaishouMapper.java
  22. 12 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDateUnitKuaishouMapper.java
  23. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  24. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataAccountKuaishouMapper.xml
  25. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataTargetKuaishouMapper.xml
  26. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDatePlanKuaishouMapper.xml
  27. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  28. 13 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataAccountKuaishouService.java
  29. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataTargetKuaishouService.java
  30. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataUnitKuaishouService.java
  31. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDatePlanKuaishouService.java
  32. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  33. 57 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataAccountKuaishouServiceImpl.java
  34. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataTargetKuaishouServiceImpl.java
  35. 18 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataUnitKuaishouServiceImpl.java
  36. 18 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDatePlanKuaishouServiceImpl.java
  37. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  38. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/utils/CloudVideoProcessUtil.java
  39. 0 5
      module-common/src/main/java/cn/com/ctop/common/module/utils/CosUtils.java
  40. 7 0
      module-common/src/main/java/cn/com/ctop/common/module/utils/RandomUtil.java
  41. 6 0
      module-job-bytedance/pom.xml
  42. 15 0
      module-job-bytedance/src/main/resources/application-dev.yml
  43. 15 0
      module-job-bytedance/src/main/resources/application-jiaoyang.yml
  44. 15 0
      module-job-bytedance/src/main/resources/application-prod.yml
  45. 16 1
      module-job-bytedance/src/main/resources/application-test.yml
  46. 6 0
      module-job-kuaishou/pom.xml
  47. 53 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouDeleteCommentJob.java
  48. 32 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataAccountCleanJob.java
  49. 31 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataPlanCleanJob.java
  50. 34 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataTargetCleanJob.java
  51. 32 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataUnitCleanJob.java
  52. 15 0
      module-job-kuaishou/src/main/resources/application-dev.yml
  53. 231 0
      module-job-kuaishou/src/main/resources/application-jiaoyang.yml
  54. 17 2
      module-job-kuaishou/src/main/resources/application-prod.yml
  55. 16 1
      module-job-kuaishou/src/main/resources/application-test.yml
  56. 67 82
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CrossAccountBatchController.java
  57. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java
  58. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml
  59. 55 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/ICrossAccountBatchService.java
  60. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouUpdateService.java
  61. 732 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java
  62. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  63. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaiShouGetAccountFundService.java
  64. 7 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouAccountService.java
  65. 23 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouPlanService.java
  66. 62 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouGetAccountFundServiceImpl.java
  67. 6 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java
  68. 43 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouAccountServiceImpl.java
  69. 258 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java
  70. 24 30
      module-kuaishou/src/main/resources/kuaishou_config.properties
  71. 5 13
      module-toutiao/src/main/resources/bytedance_config.properties

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

@@ -16,6 +16,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
@@ -476,4 +477,34 @@ public class UserAllocationController {
         return result;
     }
 
+    /**
+     *  账户绑定是否开启删评论开关
+     */
+    @PostMapping(value = "/onOrOffDeleteComment")
+    public Result<Object> onOrOffMonitoringLink(@RequestParam Long accountId, @RequestParam Integer switchType){
+        Result<Object> result=new Result<>();
+        UserAllocation userAllocation=new UserAllocation();
+        userAllocation.setAccountId(accountId);
+        UpdateWrapper<UserAllocation> wrapper=new UpdateWrapper<>();
+        //开启删评论
+        if(switchType==0){
+            wrapper.set("delete_comment",0);
+            wrapper.setEntity(userAllocation);
+            boolean update = userAllocationService.update(wrapper);
+            if(update){
+                result.success("删评论开启成功");
+            }
+        }else if(switchType==1){
+            wrapper.set("delete_comment",1);
+            wrapper.setEntity(userAllocation);
+            boolean update = userAllocationService.update(wrapper);
+            if(update){
+                result.success("删评论关闭成功");
+            }
+        }else {
+            result.error500("未知操作");
+        }
+        return result;
+    }
+
 }

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

@@ -155,7 +155,7 @@
                       FROM
                           ctop_material_info info
                       WHERE
-                          info.CODE = t2.signature
+                          info.CODE = t1.signature
                       ORDER BY
                           create_time DESC
                       LIMIT 1),'') AS url,
@@ -164,7 +164,7 @@
                       FROM
                           ctop_material_info info
                       WHERE
-                          info.CODE = t2.signature
+                          info.CODE = t1.signature
                       ORDER BY
                           create_time DESC
                       LIMIT 1),'') AS cover_url,
@@ -174,7 +174,7 @@
                          FROM
                              ctop_material_info info
                          WHERE
-                             info.CODE = t2.signature
+                             info.CODE = t1.signature
                          ORDER BY
                              create_time DESC
                          LIMIT 1

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

@@ -215,6 +215,21 @@ jeecg:
     report-history: D://report//history//
     report-daily: D://report//daily//
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
     path: http://39.106.184.70
     port: 4723

+ 246 - 0
jeecg-boot-module-system/src/main/resources/application-jiaoyang.yml

@@ -0,0 +1,246 @@
+server:
+  port: 8804
+  ip: 39.97.120.42
+  servlet:
+    context-path: /jeecg-boot
+    compression:
+      enabled: true
+      mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
+management:
+  endpoints:
+    web:
+      exposure:
+        include: metrics,httptrace
+spring:
+  servlet:
+    multipart:
+      max-file-size: -1
+      max-request-size: -1
+  mail:
+    host: smtp.exmail.qq.com
+    username: notice@c-top.com.cn
+    password: Hcst@2019
+    properties:
+      mail:
+        smtp:
+          ssl.enable: enable
+          auth: true
+          starttls:
+            enable: true
+            required: true
+  ## quartz定时任务,采用数据库方式
+  #quartz:
+    #job-store-type: jdbc
+  #json 时间戳统一转换
+  jackson:
+    date-format:   yyyy-MM-dd HH:mm:ss
+    time-zone:   GMT+8
+  jpa:
+    open-in-view: false
+  activiti:
+    check-process-definitions: false
+    #启用作业执行器
+    async-executor-activate: false
+    #启用异步执行器
+    job-executor-activate: false
+  aop:
+    proxy-target-class: true
+  #配置freemarker
+  freemarker:
+    # 设置模板后缀名
+    suffix: .ftl
+    # 设置文档类型
+    content-type: text/html
+    # 设置页面编码格式
+    charset: UTF-8
+    # 设置页面缓存
+    cache: false
+    prefer-file-system-access: false
+    # 设置ftl文件路径
+    template-loader-path:
+      - classpath:/templates
+  # 设置静态文件路径,js,css等
+  mvc:
+    static-path-pattern: /**
+  resource:
+    static-locations: classpath:/static/,classpath:/public/
+  autoconfigure:
+    exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+  datasource:
+    url: jdbc:mysql://172.30.0.4:4000/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    username: hcst
+    password: hcst@2020
+    driver-class-name: com.mysql.jdbc.Driver
+    druid:
+      stat-view-servlet:
+        loginUsername: admin
+        loginPassword: hcst20161
+        enabled: true
+      web-stat-filter:
+        enabled: true
+    #      remove-abandoned: false
+    dynamic:
+      druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
+        # 连接池的配置信息
+        # 初始化大小,最小,最大
+        connection-init-sql: set names utf8mb4
+        initial-size: 5
+        min-idle: 5
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        # 打开PSCache,并且指定每个连接上PSCache的大小
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+        filters: stat,wall,slf4j
+        # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+        connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
+      datasource:
+        master:
+          url: jdbc:mysql://172.30.0.4:4000/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          username: hcst
+          password: hcst@2020
+          driver-class-name: com.mysql.jdbc.Driver
+  #redis 配置
+  redis:
+    database: 0
+    host: 172.30.0.17
+    lettuce:
+      pool:
+        max-active: 8   #最大连接数据库连接数,设 0 为没有限制
+        max-idle: 8     #最大等待连接中的数量,设 0 为没有限制
+        max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
+        min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
+      shutdown-timeout: 100ms
+    password: foobared
+    port: 6379
+#mybatis plus 设置
+mybatis-plus:
+  mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml,classpath*:cn/com/ctop/**/xml/*Mapper.xml
+  global-config:
+    # 关闭MP3.0自带的banner
+    banner: false
+    db-config:
+      #主键类型  0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
+      id-type: 4
+      # 默认数据库表下划线命名
+      table-underline: true
+#  configuration:
+#    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+#jeecg专用配置
+jeecg:
+  elasticsearch:
+    cluster-nodes:
+    check-enabled: false
+  uploadType:
+  oss:
+    endpoint:
+    accessKey:
+    secretKey:
+    bucketName:
+    staticDomain:
+  sms:
+    accessKeyId:
+    accessKeySecret:
+  minio:
+    minio_url:
+    minio_name:
+    minio_pass:
+    bucketName:
+  ffmpeg:
+    bin: ffmpeg
+  path:
+    #文件上传根目录 设置
+    upload: /data/upload
+    #webapp文件路径
+    webapp: /data/webapp
+    video-upload: /data/upload/video/
+    image-upload: /data/upload/image/
+    kuaishou-agent-image: /data/upload/image/temp.png
+    kuaishou-account-captcha-image: /data/upload/image/captcha.png
+    chrome-driver: /usr/bin/chromedriver
+    csv-upload: /data/upload/csv/
+    bak-database-file: /data/data/bak/
+    report-history: /data/upload/report/history/
+    report-daily: /data/upload/report/daily/
+kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 328
+  third-appid: 328
+  oauth-type: agent
+  secret: 1iFTBiMdohkyEQQs
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://callback.shyouteng.com.cn/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
+  group-control:
+    path: http://39.106.184.70
+    port: 4723
+logging:
+  level:
+    root: info
+  config: classpath:logback-prod.xml
+chrome:
+  script:
+    clean: sh /data/webapp/cleanProcess.sh
+cas:
+  prefixUrl:
+oss:
+  replace:
+    replace-value: oss-cn-beijing
+    replace-old-value: oss-cn-beijing
+    download: /data/file/video/
+
+zip:
+  local:
+    download-path: /data/unzip/
+bytedance:
+  appId: 1635316529903624
+  secret: 0c51523e90d6166418fc8421a4896808e90e26f4
+  url:
+    auth-prefix: https://ad.oceanengine.com/openapi
+    api-prefix: https://ad.oceanengine.com/open_api
+    callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/bytedance
+    refresh-token: /oauth2/refresh_token
+    advertiser-info: /2/advertiser/public_info/
+    ad-get: /2/ad/get/
+    ad-create: /2/ad/create/
+    ad-update: /2/ad/update/
+    ad-update-status: /2/ad/update/status/
+    ad-update-bid: /2/ad/update/bid/
+    ad-update-budget: /2/ad/update/budget/
+    ad-update-reject-reason: 2/ad/reject_reason/
+    campaign-get: /2/campaign/get/
+    campaign-create: /2/campaign/create/
+    campaign-update-status: /2/campaign/update/status/
+    campaign-update: /2/campaign/update/
+    dmp-custom-audience-select: /2/dmp/custom_audience/select/
+    file-video-ad: /2/file/video/ad/
+    file-image-ad: /2/file/image/ad/
+    creative-update-status: /2/creative/update/status/
+    creative-material-get: /2/creative/material/read/
+    creative-create-v2: /2/creative/create_v2/
+    creative-get: /2/creative/get/
+    creative-read: /2/creative/read_v2/
+    creative-update: /2/creative/update_v2/
+    creative-reject-reason: /2/creative/reject_reason/
+    advertiser-report-get: /2/report/advertiser/get/
+    campaign-report-get: /2/report/campaign/get/
+    ad-report-get: /2/report/ad/get/
+    ad-creative-get: /2/report/creative/get/
+    advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/

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

@@ -186,6 +186,21 @@ jeecg:
     report-history: /data/upload/report/history/
     report-daily: /data/upload/report/daily/
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
     path: http://39.106.184.70
     port: 4723

+ 15 - 0
jeecg-boot-module-system/src/main/resources/application-prod2.yml

@@ -178,6 +178,21 @@ jeecg:
     report-history: /data/upload/report/history/
     report-daily: /data/upload/report/daily/
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
     path: http://39.106.184.70
     port: 4723

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

@@ -170,8 +170,23 @@ jeecg:
     report-history: /data/report/history/
     report-daily: /data/report/daily/
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
-    path: http://127.0.0.1
+    path: http://39.106.184.70
     port: 4723
 logging:
   level:

+ 15 - 0
jeecg-boot-module-system/src/main/resources/application-wps.yml

@@ -164,6 +164,21 @@ jeecg:
     report-history: D://mnt//reportKs//
     report-daily: D://mnt//reportKs//
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
     path: http://39.106.184.70
     port: 4723

+ 16 - 3
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -14,6 +14,7 @@ import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouCostGroupService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
 import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
 import cn.com.ctop.oa.modules.service.IWechatDepartmentService;
 import cn.com.ctop.oa.modules.service.IWechatNoListService;
@@ -250,17 +251,17 @@ public class SampleTest {
     }
 
     @Test
-    public void loadKuaishouData(){
+    public void loadKuaishouData() {
         Date getDate = DateUtils.addDay(new Date(), -1);
         //1:查询当日数据
         List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
-        for (CtopOauthToken token:tokens){
+        for (CtopOauthToken token : tokens) {
             kuaishouInterfaceService.getAdvertiserCampaignReportDaily(token, getDate, getDate);
         }
     }
 
     @Test
-    public void loadKuaishouHourlyReportData(){
+    public void loadKuaishouHourlyReportData() {
         Date getDate = new Date();
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH");
         String hour = simpleDateFormat.format(getDate);
@@ -272,6 +273,7 @@ public class SampleTest {
         Date finalGetDate = getDate;
         tokens.forEach(token -> kuaishouInterfaceService.getAdvertiserReportHourly(token, finalGetDate, finalGetDate));
     }
+
     @Autowired
     private IKuaishouInterfaceService kuaishouInterfaceService;
 
@@ -339,5 +341,16 @@ public class SampleTest {
         wechatNoListService.getNoDateByNo("2020-11-01 00:00:00", "2020-12-01 23:59:59", "1");
     }
 
+    @Autowired
+    IRuleKuaiShouPlanService kuaiShouPlanService;
+
+    @Test
+    public void kuaishouRuleData() {
+        //kuaiShouPlanService.cleanRuleDataPlan(3429620L,"2020-12-07","2020-12-07",1);
+        kuaiShouPlanService.cleanRuleDataUnit(3429620L, "2020-12-07", "2020-12-07", 1);
+        // kuaiShouPlanService.cleanRuleDataTarget(3429620L,"2020-12-07","2020-12-07",1);
+
+    }
+
 
 }

+ 27 - 16
module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java

@@ -183,7 +183,9 @@ public class MatchLogic {
                 append("预警账户:").append(accountId).append(",授权名称:").append(accountName).append("<br/>");
         if ("plan".equals(type)) {
             buf.append("预警计划:").append(codes).append("<br/>");
-        } else if ("creative".equals(type)) {
+        } else if ("unit".equals(type)) {
+            buf.append("预警组:").append(codes).append("<br/>");
+        }else if ("creative".equals(type)) {
             buf.append("预警创意:").append(codes).append("<br/>");
         }
         if (isNull) {
@@ -279,29 +281,38 @@ public class MatchLogic {
      * @throws
      * @author ZHAOXA
      */
-    public static JSONArray getKuaiShouSendData(JSONArray accountDatas, JSONArray groupDatas, JSONArray planDatas, JSONArray creativeDatas, JSONArray targetDatas) {
+    public static JSONArray getKuaiShouSendData(JSONArray accountDatas, JSONArray planDatas, JSONArray groupDatas, JSONArray creativeDatas, JSONArray targetDatas) {
         JSONArray sendData = new JSONArray();
         if (!Check.isNull(accountDatas) && Check.isNull(groupDatas) && Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
             sendData = accountDatas;
         } else {
-            if (Check.isNull(groupDatas)) {
-                if (!Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
-                    sendData = planDatas;
-                } else if (Check.isNull(planDatas) && !Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
+            if (Check.isNull(planDatas)) {
+                if (!Check.isNull(groupDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
+                    sendData = groupDatas;
+                } else if (Check.isNull(groupDatas) && !Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
                     sendData = creativeDatas;
-                } else if (Check.isNull(planDatas) && Check.isNull(creativeDatas) && !Check.isNull(targetDatas)) {
+                } else if (Check.isNull(groupDatas) && Check.isNull(creativeDatas) && !Check.isNull(targetDatas)) {
                     sendData = targetDatas;
                 }
             } else {
-                if (Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
-                    sendData = groupDatas;
-                } else if (!Check.isNull(targetDatas)) {
-                    for (int i = 0; i < groupDatas.size(); i++) {
-                        Long gGroupId = groupDatas.getJSONObject(i).getLong("groupId");
-                        for (int k = 0; k < targetDatas.size(); k++) {
-                            Long tgGroupId = targetDatas.getJSONObject(k).getLong("groupId");
-                            if (tgGroupId == gGroupId) {
-                                sendData.add(creativeDatas.getJSONObject(k));
+                if (Check.isNull(groupDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
+                    sendData = planDatas;
+                } else {
+                    for (int i = 0; i < planDatas.size(); i++) {
+                        Long planId = planDatas.getJSONObject(i).getLong("planId");
+                        if (!Check.isNull(targetDatas) && Check.isNull(groupDatas)) {
+                            for (int k = 0; k < targetDatas.size(); k++) {
+                                Long tgPlanId = targetDatas.getJSONObject(k).getLong("planId");
+                                if (tgPlanId == planId) {
+                                    sendData.add(creativeDatas.getJSONObject(k));
+                                }
+                            }
+                        } else if (Check.isNull(targetDatas) && !Check.isNull(groupDatas)) {
+                            for (int k = 0; k < groupDatas.size(); k++) {
+                                Long tgPlanId = groupDatas.getJSONObject(k).getLong("planId");
+                                if (tgPlanId == planId) {
+                                    sendData.add(creativeDatas.getJSONObject(k));
+                                }
                             }
                         }
                     }

+ 39 - 9
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -22,6 +22,7 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.SysUserMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
 import cn.com.ctop.common.module.service.IRuleDataAccountService;
 import cn.com.ctop.common.module.service.ISendMessageService;
 import cn.com.ctop.common.module.utils.Check;
@@ -82,6 +83,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
     @Autowired
     private IRuleDataAccountService ruleDataAccountService;
     @Autowired
+    private IRuleDataAccountKuaishouService ruleDataAccountKuaishouService;
+    @Autowired
     private AlarmEventSendMapper alarmEventSendMapper;
     @Autowired
     private UserAllocationMapper userAllocationMapper;
@@ -94,6 +97,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 
     private JSONObject userObj = null;
     private final static String ACCOUNT = "account";
+    private final static String UNIT = "unit";
     private final static String PLAN = "plan";
     private final static String CREATIVE = "creative";
 
@@ -142,12 +146,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
         Map<Long, Object> map = (Map<Long, Object>) ruleGroupMap.get(templates.getTemplateId());
         Integer type = (Integer) map.get("type");
         JSONObject matchData = null;
-        //媒体类型 1:头条2:快手
+        //媒体类型 1,3:头条2:快手
         if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
             //查询抖音匹配数据
-            matchData = getRuleData(templates.getAccountId());
+            matchData = getRuleData(templates.getAccountId(), "TT");
         } else {
-            //TODO 获取快手数据
+            matchData = getRuleData(templates.getAccountId(), "KS");
         }
         if (Check.isNull(matchData)) {
             log.warn("获取匹配数据失败");
@@ -398,9 +402,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     }
                     break;
                 }
-            } else if ("group".equals(ruleBase.getRuleDimension())) {
+            } else if (UNIT.equals(ruleBase.getRuleDimension())) {
                 groupDatas = getOKData(groupDatas, dimensionData, ruleBase, indicator, threshold);
-                if (Check.isNull(targetDatas)) {
+                if (Check.isNull(groupDatas)) {
                     if (!Check.isNull(accountDatas)) {
                         accountDatas = null;
                     }
@@ -471,6 +475,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
         }
         JSONObject user = getUserByAccountId(accountId);
         StringJoiner creativeJoiner = new StringJoiner(",");
+        StringJoiner unitJoiner = new StringJoiner(",");
         StringJoiner planJoiner = new StringJoiner(",");
         StringJoiner isNullCreativeJoiner = new StringJoiner(",");
         StringJoiner isNullPlanJoiner = new StringJoiner(",");
@@ -512,6 +517,15 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                         creativeJoiner = new StringJoiner(",");
                         creativeJoiner.add(obj.getString("creativeId"));
                     }
+                } else if (!Check.isNull(obj.getLong("unitId"))) {
+                    if (unitJoiner.toString().getBytes().length <= 1800) {
+                        unitJoiner.add(obj.getString("unitId"));
+                    } else {
+                        String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), isNull);
+                        sendMsg(msg, ruleGroup, user, UNIT, unitJoiner.toString(), accountId, mediaType);
+                        unitJoiner = new StringJoiner(",");
+                        unitJoiner.add(obj.getString("unitId"));
+                    }
                 } else if (!Check.isNull(obj.getLong("planId"))) {
                     if (planJoiner.toString().getBytes().length <= 1800) {
                         planJoiner.add(obj.getString("planId"));
@@ -531,6 +545,10 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), false);
             sendMsg(creativeMsg, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId, mediaType);
         }
+        if (!Check.isNull(unitJoiner.toString())) {
+            String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), false);
+            sendMsg(creativeMsg, ruleGroup, user, UNIT, unitJoiner.toString(), accountId, mediaType);
+        }
         if (!Check.isNull(planJoiner.toString())) {
             String planMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), false);
             sendMsg(planMsg, ruleGroup, user, PLAN, planJoiner.toString(), accountId, mediaType);
@@ -597,9 +615,11 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 send.setGroupId(ruleGroup.getId());
                 send.setGroupName(ruleGroup.getGroupName());
                 if (CREATIVE.equals(type)) {
-                    send.setRuleDimension(CREATIVE);
+                    send.setRuleDimension(type);
                 } else if (PLAN.equals(type)) {
-                    send.setRuleDimension(PLAN);
+                    send.setRuleDimension(type);
+                } else if (UNIT.equals(type)) {
+                    send.setRuleDimension(type);
                 } else {
                     send.setRuleDimension(ACCOUNT);
                 }
@@ -648,6 +668,11 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                     if (!(boolean) updateMap.get("success")) {
                         msg = msg.replace(id, id + "(F)");
                     }
+                } else if (UNIT.equals(type)) {
+                    updateMap = kuaiShouUpdateService.updateUnitStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
+                    if (!(boolean) updateMap.get("success")) {
+                        msg = msg.replace(id, id + "(F)");
+                    }
                 } else if (PLAN.equals(type)) {
                     updateMap = kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
                     if (!(boolean) updateMap.get("success")) {
@@ -818,9 +843,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
      * @throws
      * @author ZHAOXA
      */
-    private JSONObject getRuleData(Long accountId) {
+    private JSONObject getRuleData(Long accountId, String type) {
         try {
-            return ruleDataAccountService.getRuleDataByAccountId(accountId);
+            if ("TT".equals(type)) {
+                return ruleDataAccountService.getRuleDataByAccountId(accountId);
+            }
+            if ("KS".equals(type)) {
+                return ruleDataAccountKuaishouService.getKuaiShouRuleDataByAccountId(accountId);
+            }
         } catch (Exception e) {
             log.error("获取匹配数据集异常", e);
         }

+ 5 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java

@@ -226,6 +226,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                 QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                 indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
                 indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
+                indicatorQueryWrapper.eq("media_type", template.getMediaType());
                 indicatorQueryWrapper.last("limit 1");
                 RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);
                 if (!Check.isNull(ruleIndicator)) {
@@ -334,6 +335,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                     QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                     indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
                     indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
+                    indicatorQueryWrapper.eq("media_type", template.getMediaType());
                     indicatorQueryWrapper.last("limit 1");
                     RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);  // 查询指标的详情信息
                     if (!Check.isNull(ruleIndicator)) {
@@ -396,6 +398,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                          */
                         QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                         indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
+                        indicatorQueryWrapper.eq("media_type", template.getMediaType());
                         indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
                         indicatorQueryWrapper.last("limit 1");
                         RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper); // 查询基础规则的指标信息
@@ -478,6 +481,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                     QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                     indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
                     indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
+                    indicatorQueryWrapper.eq("media_type", template.getMediaType());
                     indicatorQueryWrapper.last("limit 1");
                     RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);
                     if (!Check.isNull(ruleIndicator)) {
@@ -515,6 +519,7 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                     QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
                     indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
                     indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
+                    indicatorQueryWrapper.eq("media_type", template.getMediaType());
                     indicatorQueryWrapper.last("limit 1");
                     RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);
                     if (!Check.isNull(ruleIndicator)) {

+ 0 - 2
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccount.java

@@ -1,7 +1,5 @@
 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;

+ 45 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccountKuaishou.java

@@ -0,0 +1,45 @@
+package cn.com.ctop.common.module.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+/**
+ * 快手预警数据账户维度
+ */
+@Data
+@TableName("ctop_rule_data_account_kuaishou")
+public class RuleDataAccountKuaishou {
+    
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**账户id*/
+	private Long accountId;
+	/**accountName*/
+	private String accountName;
+	/**消耗*/
+	private BigDecimal cost;
+	/**validBalance*/
+	private BigDecimal validBalance;
+	/**转化数*/
+	private Long convertNum;
+	/**转化成本*/
+	private BigDecimal convertCost;
+	/**次留数*/
+	private Long nextDayOpenNum;
+	/**nextDayOpenCost*/
+	private BigDecimal nextDayOpenCost;
+	/**次留率*/
+	private BigDecimal nextDayOpenRate;
+	/**status*/
+	private Integer status;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+}

+ 42 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTargetKuaishou.java

@@ -0,0 +1,42 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+/**
+ * 快手预警指标数据
+ */
+@Data
+@TableName("ctop_rule_data_target_kuaishou")
+public class RuleDataTargetKuaishou {
+    
+	/**id*/
+	private Long id;
+	/**accountId*/
+	private Long accountId;
+	/**planId*/
+	private Long planId;
+	/**unitId*/
+	private Long unitId;
+	/**广告位*/
+	private String sceneId;
+	/**地域定向*/
+	private String region;
+	/**gender*/
+	private Integer gender;
+	/**操作系统*/
+	private Integer platformOs;
+	/**手机品牌*/
+	private String deviceBrand;
+	/**手机价格*/
+	private String devicePrice;
+	/**智能扩量*/
+	private Integer isOpen;
+	/**过滤已转化人群*/
+	private Integer filterConvertedLevel;
+	/**投放时段*/
+	private String scheduleTime;
+
+	private Integer status;
+}

+ 27 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDatePlanKuaishou.java

@@ -0,0 +1,27 @@
+package cn.com.ctop.common.module.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import lombok.Data;
+
+/**
+ * 预警快手计划数据清洗
+ */
+@Data
+@TableName("ctop_rule_date_plan_kuaishou")
+public class RuleDatePlanKuaishou {
+    
+	/**id*/
+	private Long id;
+	/**accountId*/
+	private Long accountId;
+	/**accountName*/
+	private String accountName;
+	/**planId*/
+	private Long planId;
+	/**planName*/
+	private String planName;
+
+	private Integer status;
+
+}

+ 50 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDateUnitKuaishou.java

@@ -0,0 +1,50 @@
+package cn.com.ctop.common.module.entity;
+
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 快手预警组数据
+ */
+@Data
+@TableName("ctop_rule_data_unit_kuaishou")
+public class RuleDateUnitKuaishou {
+    
+	/**id*/
+	private Long id;
+	/**accountId*/
+	private Long accountId;
+    /**planId*/
+    private Long planId;
+	/**unitId*/
+	private Long unitId;
+	/**unitName*/
+	private String unitName;
+	/**消耗*/
+	private BigDecimal charge;
+
+	private Long convertNum;
+
+	private BigDecimal convertCost;
+
+	/**activation*/
+	private Long activation;
+	/**激活单价*/
+	private BigDecimal activationCost;
+	/**注册数*/
+	private Long eventRegister;
+	/**表单*/
+	private BigDecimal registerCost;
+	/**表单*/
+	private Long formCount;
+	/**表单提交单价*/
+	private BigDecimal formCost;
+	/**付费*/
+	private Long eventPay;
+	/**付费单价*/
+	private BigDecimal payCost;
+
+    private Integer status;
+
+}

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

@@ -126,6 +126,13 @@ public class UserAllocation implements Serializable {
     private Integer landingPage;
 
     /**
+     * 是否开启删评论
+     * 0 启动
+     * 1 禁用
+     */
+    private Integer deleteComment;
+
+    /**
      * 修改时间
      */
     @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手预警数据账户维度
+ */
+public interface RuleDataAccountKuaishouMapper extends BaseMapper<RuleDataAccountKuaishou> {
+
+}

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手预警指标数据
+ */
+public interface RuleDataTargetKuaishouMapper extends BaseMapper<RuleDataTargetKuaishou> {
+
+}

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 预警快手计划数据清洗
+ */
+public interface RuleDatePlanKuaishouMapper extends BaseMapper<RuleDatePlanKuaishou> {
+
+}

+ 12 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/RuleDateUnitKuaishouMapper.java

@@ -0,0 +1,12 @@
+package cn.com.ctop.common.module.mapper;
+
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 预警快手计划数据清洗
+ */
+public interface RuleDateUnitKuaishouMapper extends BaseMapper<RuleDateUnitKuaishou> {
+
+}

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

@@ -31,4 +31,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     UserAllocation getUserAllocation(@Param("accountId") Long accountId);
 
     JSONObject getSwitchStatusByAccount(@Param("accountId") Long accountId);
+
+    List<Long>  queryAccountsByDeleteComment();
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataAccountKuaishouMapper.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.RuleDataAccountKuaishouMapper">
+
+</mapper>

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDataTargetKuaishouMapper.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.RuleDataTargetKuaishouMapper">
+
+</mapper>

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/RuleDatePlanKuaishouMapper.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.RuleDatePlanKuaishouMapper">
+
+</mapper>

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

@@ -85,5 +85,16 @@
             account_id = #{accountId}
     </select>
 
+    <select id="queryAccountsByDeleteComment" resultType="java.lang.Long">
+        SELECT
+            account_id
+        FROM
+            ctop_user_allocation
+        WHERE
+            media_id = 2
+          AND account_status = 0
+          AND delete_comment = 0
+    </select>
+
 
 </mapper>

+ 13 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataAccountKuaishouService.java

@@ -0,0 +1,13 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *  快手预警数据账户维度
+ */
+public interface IRuleDataAccountKuaishouService extends IService<RuleDataAccountKuaishou> {
+
+    JSONObject getKuaiShouRuleDataByAccountId(Long accountId);
+}

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 快手预警指标数据
+ */
+public interface IRuleDataTargetKuaishouService extends IService<RuleDataTargetKuaishou> {
+
+}

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ *  组维度数据清洗
+ */
+public interface IRuleDataUnitKuaishouService extends IService<RuleDateUnitKuaishou> {
+
+}

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

@@ -0,0 +1,11 @@
+package cn.com.ctop.common.module.service;
+
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 预警快手计划数据清洗
+ */
+public interface IRuleDatePlanKuaishouService extends IService<RuleDatePlanKuaishou> {
+
+}

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

@@ -36,4 +36,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     List<UserAllocation> getUserAllocations(String mediaId ,int switchType);
 
     JSONObject getSwitchStatusByAccount(Long accountId);
+
+    List<Long> getAccountsByDeleteComment();
 }

+ 57 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataAccountKuaishouServiceImpl.java

@@ -0,0 +1,57 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDataAccountKuaishouMapper;
+import cn.com.ctop.common.module.mapper.RuleDataTargetKuaishouMapper;
+import cn.com.ctop.common.module.mapper.RuleDatePlanKuaishouMapper;
+import cn.com.ctop.common.module.mapper.RuleDateUnitKuaishouMapper;
+import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.enums.NoEn;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 快手预警数据账户维度
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Service
+public class RuleDataAccountKuaishouServiceImpl extends ServiceImpl<RuleDataAccountKuaishouMapper, RuleDataAccountKuaishou> implements IRuleDataAccountKuaishouService {
+
+    @Autowired
+    private RuleDataAccountKuaishouMapper ruleDataAccountKuaishouMapper;
+    @Autowired
+    private RuleDataTargetKuaishouMapper ruleDataTargetKuaishouMapper;
+    @Autowired
+    private RuleDateUnitKuaishouMapper ruleDateUnitKuaishouMapper;
+    @Autowired
+    private RuleDatePlanKuaishouMapper ruleDatePlanKuaishouMapper;
+
+    @Override
+    public JSONObject getKuaiShouRuleDataByAccountId(Long accountId) {
+        JSONObject obj = new JSONObject();
+        Map<String, Object> map = new HashMap<>();
+        map.put("account_id", accountId);
+        map.put("status", NoEn.NO1.valueInt());
+        List<RuleDataAccountKuaishou> accountList = ruleDataAccountKuaishouMapper.selectByMap(map);
+        obj.put("account", accountList);
+        List<RuleDateUnitKuaishou> unitKuaishous = ruleDateUnitKuaishouMapper.selectByMap(map);
+        obj.put("unit", unitKuaishous);
+        List<RuleDataTargetKuaishou> targetKuaishous = ruleDataTargetKuaishouMapper.selectByMap(map);
+        obj.put("target", targetKuaishous);
+        List<RuleDatePlanKuaishou> planKuaishous = ruleDatePlanKuaishouMapper.selectByMap(map);
+        obj.put("plan", planKuaishous);
+        return obj;
+    }
+}

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDataTargetKuaishouMapper;
+import cn.com.ctop.common.module.service.IRuleDataTargetKuaishouService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手预警指标数据
+ */
+@Service
+public class RuleDataTargetKuaishouServiceImpl extends ServiceImpl<RuleDataTargetKuaishouMapper, RuleDataTargetKuaishou> implements IRuleDataTargetKuaishouService {
+
+}

+ 18 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataUnitKuaishouServiceImpl.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDateUnitKuaishouMapper;
+import cn.com.ctop.common.module.service.IRuleDataUnitKuaishouService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 组维度数据清洗
+ * @author jeecg-boot
+ * @date   2020-12-04
+ * @version V1.0
+ */
+@Service
+public class RuleDataUnitKuaishouServiceImpl extends ServiceImpl<RuleDateUnitKuaishouMapper, RuleDateUnitKuaishou> implements IRuleDataUnitKuaishouService {
+
+}

+ 18 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDatePlanKuaishouServiceImpl.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.common.module.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import cn.com.ctop.common.module.mapper.RuleDatePlanKuaishouMapper;
+import cn.com.ctop.common.module.service.IRuleDatePlanKuaishouService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 预警快手计划数据清洗
+ * @author jeecg-boot
+ * @date   2020-12-04
+ * @version V1.0
+ */
+@Service
+public class RuleDatePlanKuaishouServiceImpl extends ServiceImpl<RuleDatePlanKuaishouMapper, RuleDatePlanKuaishou> implements IRuleDatePlanKuaishouService {
+
+}

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

@@ -134,4 +134,9 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     public JSONObject getSwitchStatusByAccount(Long accountId) {
         return userAllocationMapper.getSwitchStatusByAccount(accountId);
     }
+
+    @Override
+    public List<Long> getAccountsByDeleteComment() {
+        return userAllocationMapper.queryAccountsByDeleteComment();
+    }
 }

+ 0 - 1
module-common/src/main/java/cn/com/ctop/common/module/utils/CloudVideoProcessUtil.java

@@ -1,7 +1,6 @@
 package cn.com.ctop.common.module.utils;
 
 import cn.com.ctop.common.module.constant.CosConstant;
-import cn.com.ctop.common.module.vo.StatisticCampaignVo;
 import cn.hutool.core.map.MapUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.qcloud.cos.auth.BasicCOSCredentials;

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

@@ -306,9 +306,4 @@ public class CosUtils {
         }
         return null;
     }
-
-
-
-
-
 }

+ 7 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/RandomUtil.java

@@ -41,4 +41,11 @@ public class RandomUtil {
         return c;
     }
 
+    public static void main(String[] args) {
+        for (int i = 0; i < 1000; i++) {
+            System.err.println(verifyCodeV2());
+        }
+
+    }
+
 }

+ 6 - 0
module-job-bytedance/pom.xml

@@ -231,5 +231,11 @@
                 <activatedProperties>prod</activatedProperties>
             </properties>
         </profile>
+        <profile>
+            <id>jiaoyang</id>
+            <properties>
+                <activatedProperties>jiaoyang</activatedProperties>
+            </properties>
+        </profile>
     </profiles>
 </project>

+ 15 - 0
module-job-bytedance/src/main/resources/application-dev.yml

@@ -136,6 +136,21 @@ jeecg:
     report-history: D://report//history//
     report-daily: D://report//daily//
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
     path: http://39.106.184.70
     port: 4723

+ 15 - 0
module-job-bytedance/src/main/resources/application-jiaoyang.yml

@@ -151,6 +151,21 @@ jeecg:
     kuaishou-agent-image: /data/upload/image/temp.png
     kuaishou-account-captcha-image: /data/upload/image/captcha.png
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
     path: http://39.106.184.70
     port: 4723

+ 15 - 0
module-job-bytedance/src/main/resources/application-prod.yml

@@ -151,6 +151,21 @@ jeecg:
     kuaishou-agent-image: /data/upload/image/temp.png
     kuaishou-account-captcha-image: /data/upload/image/captcha.png
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
     path: http://39.106.184.70
     port: 4723

+ 16 - 1
module-job-bytedance/src/main/resources/application-test.yml

@@ -160,8 +160,23 @@ jeecg:
     report-history: /data/report/history/
     report-daily: /data/report/daily/
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
-    path: http://127.0.0.1
+    path: http://39.106.184.70
     port: 4723
 logging:
   level:

+ 6 - 0
module-job-kuaishou/pom.xml

@@ -215,5 +215,11 @@
                 <activatedProperties>prod</activatedProperties>
             </properties>
         </profile>
+        <profile>
+            <id>jiaoyang</id>
+            <properties>
+                <activatedProperties>jiaoyang</activatedProperties>
+            </properties>
+        </profile>
     </profiles>
 </project>

+ 53 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouDeleteCommentJob.java

@@ -0,0 +1,53 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCommentService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class KuaiShouDeleteCommentJob {
+
+    @Autowired
+    private IUserAllocationService allocationService;
+
+    @Autowired
+    private IKuaiShouCommentService kuaiShouCommentService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    static CountDownLatch countDownLatch = null;
+
+    @XxlJob("kuaiShouDeleteCommentJob")
+    public void kuaiShouDeleteComment(){
+        Long start = System.currentTimeMillis();
+        //查询需要删除的账户
+        List<Long> accountIds = allocationService.getAccountsByDeleteComment();
+        if (!accountIds.isEmpty()) {
+            countDownLatch = new CountDownLatch(accountIds.size());
+            accountIds.forEach(accountId -> executorService.submit(() -> {
+                try {
+                    kuaiShouCommentService.shieldComment(accountId);
+                } catch (Exception e) {
+                    XxlJobHelper.log(e.getMessage(), e);
+                } finally {
+                    countDownLatch.countDown();
+                }
+            }));
+            try {
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            Long end = System.currentTimeMillis();
+            XxlJobHelper.log("快手删评论所用时长:{}毫秒", end - start);
+        }
+    }
+}

+ 32 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataAccountCleanJob.java

@@ -0,0 +1,32 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouAccountService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class RuleKuaiShouDataAccountCleanJob {
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    private IRuleKuaiShouAccountService ruleKuaiShouAccountService;
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    @XxlJob("ruleKuaiShouDataAccountCleanJob")
+    public void execute() throws Exception {
+        XxlJobHelper.log("规则预警账户维度数据开始清洗");
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(()->ruleKuaiShouAccountService.cleanRuleDataAccount(token.getAccountId())));
+    }
+}

+ 31 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataPlanCleanJob.java

@@ -0,0 +1,31 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class RuleKuaiShouDataPlanCleanJob {
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    @XxlJob("ruleKuaiShouDataPlanCleanJob")
+    public void execute() throws Exception {
+        XxlJobHelper.log("规则预警计划维度数据开始清洗");
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(()->ruleKuaiShouPlanService.cleanRuleDataPlan(token.getAccountId(),1)));
+    }
+}

+ 34 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataTargetCleanJob.java

@@ -0,0 +1,34 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+@Component
+public class RuleKuaiShouDataTargetCleanJob {
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    @XxlJob("ruleKuaiShouDataTargetCleanJob")
+    public void execute() throws Exception {
+        XxlJobHelper.log("规则预警定向维度数据开始清洗");
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(() -> ruleKuaiShouPlanService.cleanRuleDataTarget(token.getAccountId(), 1)));
+    }
+
+}

+ 32 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/RuleKuaiShouDataUnitCleanJob.java

@@ -0,0 +1,32 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class RuleKuaiShouDataUnitCleanJob {
+
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    private IRuleKuaiShouPlanService ruleKuaiShouPlanService;
+
+    private ExecutorService executorService = Executors.newFixedThreadPool(10);
+
+    @XxlJob("ruleKuaiShouDataUnitCleanJob")
+    public void execute() throws Exception {
+        XxlJobHelper.log("规则预警组维度数据开始清洗");
+        List<CtopOauthToken> tokens = oauthTokenService.selectKuaiShouToken();
+        tokens.forEach(token -> executorService.submit(() -> ruleKuaiShouPlanService.cleanRuleDataUnit(token.getAccountId(), DateUtils.date2Str(), DateUtils.date2Str(), 1)));
+    }
+
+}

+ 15 - 0
module-job-kuaishou/src/main/resources/application-dev.yml

@@ -118,6 +118,21 @@ jeecg:
     report-history: D://report//history//
     report-daily: D://report//daily//
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
     path: http://39.106.184.70
     port: 4723

+ 231 - 0
module-job-kuaishou/src/main/resources/application-jiaoyang.yml

@@ -0,0 +1,231 @@
+management:
+  endpoints:
+    web:
+      exposure:
+        include: metrics,httptrace
+spring:
+  servlet:
+    multipart:
+      max-file-size: -1
+      max-request-size: -1
+  mail:
+    host: smtp.163.com
+    username: jeecgos@163.com
+    password: ??
+    properties:
+      mail:
+        smtp:
+          auth: true
+          starttls:
+            enable: true
+            required: true
+  #json 时间戳统一转换
+  jackson:
+    date-format:   yyyy-MM-dd HH:mm:ss
+    time-zone:   GMT+8
+  aop:
+    proxy-target-class: true
+  #配置freemarker
+  freemarker:
+    # 设置模板后缀名
+    suffix: .ftl
+    # 设置文档类型
+    content-type: text/html
+    # 设置页面编码格式
+    charset: UTF-8
+    # 设置页面缓存
+    cache: false
+    prefer-file-system-access: false
+    # 设置ftl文件路径
+    template-loader-path:
+      - classpath:/templates
+  # 设置静态文件路径,js,css等
+  mvc:
+    static-path-pattern: /**
+  resource:
+    static-locations: classpath:/static/,classpath:/public/
+  autoconfigure:
+    exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
+  datasource:
+    url: jdbc:mysql://172.30.0.4:4000/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    username: hcst
+    password: hcst@2020
+    driver-class-name: com.mysql.jdbc.Driver
+    druid:
+      stat-view-servlet:
+        loginUsername: admin
+        loginPassword: hcst2016
+        enabled: true
+      web-stat-filter:
+        enabled: true
+    #      remove-abandoned: false
+    dynamic:
+      druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
+        # 连接池的配置信息
+        # 初始化大小,最小,最大
+        connection-init-sql: set names utf8mb4
+        initial-size: 5
+        min-idle: 5
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        # 打开PSCache,并且指定每个连接上PSCache的大小
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+        filters: stat,slf4j
+        # 通过connectProperties属性来打开mergeSql功能;慢SQL记录
+        connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
+      datasource:
+        master:
+          url: jdbc:mysql://172.30.0.4:4000/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          username: hcst
+          password: hcst@2020
+          driver-class-name: com.mysql.jdbc.Driver
+  #redis 配置
+  redis:
+    database: 0
+    host: 172.30.0.17
+#    host: 127.0.0.1
+    lettuce:
+      pool:
+        max-active: 8   #最大连接数据库连接数,设 0 为没有限制
+        max-idle: 8     #最大等待连接中的数量,设 0 为没有限制
+        max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
+        min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
+      shutdown-timeout: 100ms
+    password: foobared
+    port: 6379
+#mybatis plus 设置
+mybatis-plus:
+  mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml,classpath*:cn/com/ctop/**/xml/*Mapper.xml
+  global-config:
+    # 关闭MP3.0自带的banner
+    banner: false
+    db-config:
+      #主键类型  0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
+      id-type: 4
+      # 默认数据库表下划线命名
+      table-underline: true
+#jeecg专用配置
+jeecg:
+  elasticsearch:
+    cluster-nodes:
+    check-enabled: false
+  uploadType:
+  oss:
+    endpoint:
+    accessKey:
+    secretKey:
+    bucketName:
+    staticDomain:
+  sms:
+    accessKeyId:
+    accessKeySecret:
+  minio:
+    minio_url:
+    minio_name:
+    minio_pass:
+    bucketName:
+  ffmpeg:
+    bin: ffmpeg
+  path:
+    #文件上传根目录 设置
+    upload: /data/upload
+    #webapp文件路径
+    webapp: /data/webapp
+    video-upload: /data/upload/video/
+    image-upload: /data/upload/image/
+    chrome-driver: /usr/bin/chromedriver
+    csv-upload: /data/upload/csv/
+    bak-database-file: /data/data/bak/
+    report-history: /data/upload/report/history/
+    report-daily: /data/upload/report/daily/
+    kuaishou-agent-image: /data/upload/image/temp.png
+    kuaishou-account-captcha-image: /data/upload/image/captcha.png
+kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 328
+  third-appid: 328
+  oauth-type: agent
+  secret: 1iFTBiMdohkyEQQs
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://callback.shyouteng.com.cn/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
+  group-control:
+    path: http://39.106.184.70
+    port: 4723
+logging:
+  level:
+    root: info
+  config: classpath:logback-prod.xml
+chrome:
+  script:
+    clean: sh /data/webapp/cleanProcess.sh
+oss:
+  replace:
+    replace-value: oss-cn-beijing-internal
+    replace-old-value: oss-cn-beijing
+    download: /data/file/video/
+bytedance:
+  appId: 1635316529903624
+  secret: 0c51523e90d6166418fc8421a4896808e90e26f4
+  url:
+    auth-prefix: https://ad.oceanengine.com/openapi
+    api-prefix: https://ad.oceanengine.com/open_api
+    callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/bytedance
+    refresh-token: /oauth2/refresh_token
+    advertiser-info: /2/advertiser/public_info/
+    ad-get: /2/ad/get/
+    ad-create: /2/ad/create/
+    ad-update: /2/ad/update/
+    ad-update-status: /2/ad/update/status/
+    ad-update-bid: /2/ad/update/bid/
+    ad-update-budget: /2/ad/update/budget/
+    ad-update-reject-reason: 2/ad/reject_reason/
+    campaign-get: /2/campaign/get/
+    campaign-create: /2/campaign/create/
+    campaign-update-status: /2/campaign/update/status/
+    campaign-update: /2/campaign/update/
+    dmp-custom-audience-select: /2/dmp/custom_audience/select/
+    file-video-ad: /2/file/video/ad/
+    file-image-ad: /2/file/image/ad/
+    creative-update-status: /2/creative/update/status/
+    creative-material-get: /2/creative/material/read/
+    creative-create-v2: /2/creative/create_v2/
+    creative-get: /2/creative/get/
+    creative-read: /2/creative/read_v2/
+    creative-update: /2/creative/update_v2/
+    creative-reject-reason: /2/creative/reject_reason/
+    advertiser-report-get: /2/report/advertiser/get/
+    campaign-report-get: /2/report/campaign/get/
+    ad-report-get: /2/report/ad/get/
+    ad-creative-get: /2/report/creative/get/
+    advertiser-fund-daily-stat: /2/advertiser/fund/daily_stat/
+xxl:
+  job:
+    accessToken:
+    executor:
+      appname: module-job-kuaishou-v2
+      port: 9998
+      ip:
+      logpath: /data/applogs/xxl-job/jobhandler
+      logretentiondays: 30
+    admin:
+      addresses: http://129.28.150.229:8090/xxl-job-admin
+#      addresses: http://139.186.29.76:8090/xxl-job-admin

+ 17 - 2
module-job-kuaishou/src/main/resources/application-prod.yml

@@ -47,7 +47,7 @@ spring:
   autoconfigure:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
-    url: jdbc:mysql://172.30.0.4:4000/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    url: jdbc:mysql://172.30.0.4:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
     username: hcst
     password: hcst@2020
     driver-class-name: com.mysql.jdbc.Driver
@@ -86,7 +86,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://172.30.0.4:4000/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          url: jdbc:mysql://172.30.0.4:4000/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
           password: hcst@2020
           driver-class-name: com.mysql.jdbc.Driver
@@ -152,6 +152,21 @@ jeecg:
     kuaishou-agent-image: /data/upload/image/temp.png
     kuaishou-account-captcha-image: /data/upload/image/captcha.png
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
     path: http://39.106.184.70
     port: 4723

+ 16 - 1
module-job-kuaishou/src/main/resources/application-test.yml

@@ -136,8 +136,23 @@ jeecg:
     report-history: /data/report/history/
     report-daily: /data/report/daily/
 kuaishou:
+  api-url: https://ad.e.kuaishou.com
+  auth-url: https://ad.e.kuaishou.com
+  appid: 27
+  third-appid: 328
+  oauth-type: agent
+  secret: QovprB1tNhXptgDc
+  third-secret: 1iFTBiMdohkyEQQs
+  callback-url: http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+  third-callback-url: http://callback.shyouteng.com.cn/kuaishou
+  apk-sava-path: /mnt/file/apk
+  image-sava-path: /mnt/file/image
+  video-sava-path: /mnt/file/video
+  model-video-src-path: /mnt/data/src/
+  model-video-fill-path: /mnt/data/fill/
+  model-video-final-path: /mnt/data/final/
   group-control:
-    path: http://127.0.0.1
+    path: http://39.106.184.70
     port: 4723
 logging:
   level:

+ 67 - 82
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CrossAccountBatchController.java

@@ -8,6 +8,7 @@ import cn.com.ctop.common.module.service.IProjectService;
 import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.Enums.CampaignTypeEnum;
+import cn.com.ctop.kuaishou.modules.batch.service.ICrossAccountBatchService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -43,7 +44,8 @@ public class CrossAccountBatchController {
     private IKuaishouInterfaceService kuaishouInterfaceService;
     @Autowired
     private IUserAllocationService userAllocationService;
-
+    @Autowired
+    private ICrossAccountBatchService crossAccountBatchService;
 
     /**
      * 批量创建广告计划
@@ -55,7 +57,6 @@ public class CrossAccountBatchController {
     public Result<JSONArray> campaignCreate(@RequestBody JSONObject requestJson) {
         Result<JSONArray> result = new Result<>();
         try {
-            System.err.println(requestJson);
             JSONArray accountArr = requestJson.getJSONArray("accountArr");
             if (Check.isNull(accountArr)) {
                 throw new Exception("请选择需要创建的账户");
@@ -190,122 +191,106 @@ public class CrossAccountBatchController {
     }
 
 
-
-
-
     /**
      * 批量创建广告组
      *
      * @param requestJson
      * @return
      */
-    @PostMapping(value = "/batchUnitCreate")
+    @PostMapping(value = "/crossAccountUnitCreate")
     public Result<JSONArray> batchUnitCreate(@RequestBody JSONObject requestJson) {
+        System.err.println(requestJson);
         Result<JSONArray> result = new Result<>();
         try {
-            System.err.println(requestJson);
+
+            if (Check.isNull(requestJson)) {
+                throw new Exception("参数不能为空");
+            }
             JSONArray accountArr = requestJson.getJSONArray("accountArr");
             if (Check.isNull(accountArr)) {
-                throw new Exception("请选择需要创建的账户");
+                throw new Exception("accountArr节点不能为空");
             }
-            JSONArray returnArr = new JSONArray();
 
+            JSONArray createUnitArr = new JSONArray();
             for (int i = 0; i < accountArr.size(); i++) {
-                Long accountId = accountArr.getLong(i);
-                CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
-                if (Check.isNull(oauthToken)) {
-                    throw new Exception("未获取到账户信息");
+                JSONObject accountJson = accountArr.getJSONObject(i);
+                if (Check.isNull(accountJson)) {
+                    continue;
                 }
-
-                JSONObject returnJson = new JSONObject();
-                returnJson.put("accountId", accountId);
-                JSONObject campaignJson = new JSONObject();
-                campaignJson.put("day_budget", requestJson.getLong("dayBudget"));
-                Integer nameType = requestJson.getInteger("nameType");
-                Integer type = requestJson.getInteger("type");
-                campaignJson.put("type", type);
-                if (!Check.isNull(requestJson.getLong("dayBudget"))) {
-                    campaignJson.put("day_budget", requestJson.getLong("dayBudget"));
+                Long accountId = accountJson.getLong("accountId");
+                if (Check.isNull(accountId)) {
+                    log.error("账户id不能为空");
+                    continue;
                 }
-
-                if (!Check.isNull(requestJson.getJSONArray("dayBudgetSchedule"))) {
-                    campaignJson.put("day_budget_schedule", requestJson.getJSONArray("dayBudgetSchedule"));
+                CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+                if (Check.isNull(oauthToken)) {
+                    log.error("未获取到授权信息");
+                    continue;
                 }
-
-                JSONArray campaignNames = new JSONArray();
-                if (nameType == 0) { // 0 为统一命名  1 为分别命名
-                    //    Integer startNum = requestJson.getInteger("startNum");
-                    Integer createTotal = requestJson.getInteger("createTotal");
-                    String campaignName = requestJson.getString("campaignName");
-                    for (int j = 0; j < createTotal; j++) {
-                        if (campaignName.contains("{{数值}}")) {
-                            String name = getName(campaignName, accountId, j, type);
-                            campaignNames.add(name);
-                        } else {
-                            String name = null;
-                            if (createTotal == 1) {
-                                name = getName(campaignName, accountId, null, type);
-                            } else {
-                                name = getName(campaignName + "_" + j, accountId, null, type);
-                            }
-                            campaignNames.add(name);
-                        }
-                    }
-                } else if (nameType == 1) { // "分别命名"
-                    JSONArray nameArr = requestJson.getJSONArray("nameArr");
-                    for (int j = 0; j < nameArr.size(); j++) {
-                        JSONObject nameJson = nameArr.getJSONObject(j);
-                        if (nameJson.getLong("accountId").equals(accountId)) {
-                            campaignNames = nameJson.getJSONArray("campaignNames");
-                        }
+                Integer campaignAgreement = accountJson.getInteger("campaignAgreement");  //判断是否计划相同   0为相同取值campaignOne   1不同取值campaignList
+                if (campaignAgreement == 0) { // 计划下组相同
+                    JSONObject campaignOne = accountJson.getJSONObject("campaignOne");
+                    if (Check.isNull(campaignOne)) {
+                        continue;
                     }
-                }
-                if (!Check.isNull(campaignNames)) {
-                    JSONArray returnCampaigns = new JSONArray();
-                    for (int j = 0; j < campaignNames.size(); j++) {
-                        JSONObject returnCampaignJson = new JSONObject();
-                        String campaignName = (String) campaignNames.get(j);
-                        campaignJson.put("campaign_name", campaignName);
-                        Map<String, Object> campaignMap = kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), accountId, campaignJson);
-                        if ((Integer) campaignMap.get("code") == 0) {
-                            returnCampaignJson.put("code", 0);
-                            returnCampaignJson.put("campaignId", campaignMap.get("campaignId"));
-                            returnCampaignJson.put("campaignName", campaignName);
-                            returnCampaignJson.put("type", type);
-                            returnCampaignJson.put("message", campaignMap.get("message"));
-                        } else {
-                            returnCampaignJson.put("code", -1);
-                            returnCampaignJson.put("campaignName", campaignName);
-                            returnCampaignJson.put("message", campaignMap.get("message"));
-                        }
-                        returnCampaigns.add(returnCampaignJson);
+                    createUnitArr = crossAccountBatchService.assembleUnitJson(oauthToken, createUnitArr, campaignOne);
 
+                } else if (campaignAgreement == 1) { // 计划下组不同
+                    JSONArray campaignList = accountJson.getJSONArray("campaignList");
+                    if (Check.isNull(campaignList)) {
+                        continue;
                     }
-                    returnJson.put("createDetail", returnCampaigns);
-
+                    createUnitArr = crossAccountBatchService.assembleUnitArray(oauthToken, createUnitArr, campaignList);
                 }
-                returnArr.add(returnJson);
             }
+            System.err.println("组装数据:"+createUnitArr);
+            JSONArray returnArray = crossAccountBatchService.createUnit(createUnitArr);
+            System.err.println(returnArray);
             result.setSuccess(true);
-            System.err.println(returnArr);
-            result.setResult(returnArr);
+            result.setResult(returnArray);
         } catch (Exception e) {
             e.printStackTrace();
-            result.setSuccess(false);
+            result.setSuccess(true);
             result.setMessage(e.getMessage());
-
         }
         return result;
 
     }
 
 
+    @PostMapping(value = "/crossAccountCreativeCreate")
+    public Result<JSONArray> crossAccountCreativeCreate(@RequestBody JSONObject requestJson) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            System.err.println(requestJson);
 
+            if (Check.isNull(requestJson)) {
+                throw new Exception("参数不能为空");
+            }
+            JSONArray accountArr = requestJson.getJSONArray("accountArr");
+            if (Check.isNull(accountArr)) {
+                throw new Exception("accountArr节点不能为空");
+            }
+            JSONArray creativeArray = new JSONArray();
+            for (int i = 0; i < accountArr.size(); i++) {
+                JSONObject accountJson = accountArr.getJSONObject(i);
+                creativeArray = crossAccountBatchService.assembleCreativeJson(creativeArray, accountJson);
+            }
+            System.err.println("组装数据:"+creativeArray);
+            JSONArray returnArray = crossAccountBatchService.createCreative(creativeArray);
+            System.err.println(returnArray);
+            result.setSuccess(true);
+            result.setResult(returnArray);
 
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(true);
+            result.setMessage(e.getMessage());
+        }
 
 
-
-
+        return result;
+    }
 
 
     /**

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -17,4 +18,6 @@ public interface KuaiShouCampaignMapper extends BaseMapper<KuaiShouCampaign> {
     void replaceBatch(@Param(value = "campaigns") List<KuaiShouCampaign> campaigns);
 
     List<Long> queryIdsByPutStatus(Long accountId,String putStatus);
+
+    JSONArray queryCampaignIdByAccountId(Long accountId);
 }

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

@@ -41,4 +41,10 @@
         WHERE account_id = #{accountId}
         AND put_status = #{putStatus}
     </select>
+    <select id="queryCampaignIdByAccountId" resultType="java.lang.Long">
+        SELECT campaign_id
+        FROM
+        ctop_kuaishou_campaign
+        WHERE account_id = #{accountId}
+    </select>
 </mapper>

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

@@ -0,0 +1,55 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+public interface ICrossAccountBatchService {
+    /**
+     * \
+     * 组装数据 JSON
+     *
+     * @param oauthToken
+     * @param createUnitArr
+     * @param campaignOne
+     * @return
+     */
+    JSONArray assembleUnitJson(CtopOauthToken oauthToken, JSONArray createUnitArr, JSONObject campaignOne);
+
+    /**
+     * 组装数据 JSONArray
+     *
+     * @param oauthToken
+     * @param createUnitArr
+     * @param campaignList
+     * @return
+     */
+    JSONArray assembleUnitArray(CtopOauthToken oauthToken, JSONArray createUnitArr, JSONArray campaignList);
+
+    /**
+     * 跨账户批量创建组
+     *
+     * @param createUnitArr
+     * @return
+     */
+
+    JSONArray createUnit(JSONArray createUnitArr);
+
+    /**
+     * 组装批量创建创意数据
+     *
+     * @param creativeArray
+     * @param accountJson
+     * @return
+     */
+    JSONArray assembleCreativeJson(JSONArray creativeArray, JSONObject accountJson);
+
+
+    /**
+     * 跨账户批量创建计划
+     *
+     * @param creativeArray
+     * @return
+     */
+    JSONArray createCreative(JSONArray creativeArray);
+}

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouUpdateService.java

@@ -58,7 +58,7 @@ public interface IKuaiShouUpdateService {
      * @param token
      * @param advertiserId
      * @param unitId
-     * @param putStatus
+     * @param putStatus 1-投放、2-暂停、3-删除,传其他数字非法
      * @return
      */
     Map<String, Object> updateUnitStatus(String token, Long advertiserId, Long unitId, int putStatus, String loginId);

+ 732 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CrossAccountBatchServiceImpl.java

@@ -0,0 +1,732 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.*;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouImageGet;
+import cn.com.ctop.kuaishou.modules.batch.service.*;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class CrossAccountBatchServiceImpl implements ICrossAccountBatchService {
+
+
+    @Autowired
+    private IKuaiShouGroupService getKuaiShouGroupService;
+    @Autowired
+    private ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    private IKuaiShouImageGetService imageGetService;
+    @Autowired
+    private IKuaiShouMaterialUploadService uploadService;
+    @Autowired
+    private IKuaiShouOverRunSendMessageService overRunSendMessageService;
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
+
+
+    /**
+     * 组装数据  jason
+     *
+     * @param oauthToken
+     * @param createUnitArr
+     * @param campaignOne
+     * @return
+     */
+    @Override
+    public JSONArray assembleUnitJson(CtopOauthToken oauthToken, JSONArray createUnitArr, JSONObject campaignOne) {
+        if (Check.isNull(campaignOne)) {
+            return createUnitArr;
+        }
+        JSONArray campaignIds = campaignOne.getJSONArray("campaignIds"); // 计划ids
+        if (Check.isNull(campaignIds)) {
+            return createUnitArr;
+
+        }
+        JSONObject createUnitJson = this.getCreateUnitJson(campaignOne);// 通用参数组装
+        JSONArray unitNames = campaignOne.getJSONArray("unitNames"); // 组名称集合
+        if (Check.isNull(unitNames)) {
+            return createUnitArr;
+        }
+        createUnitJson.put("advertiser_id", oauthToken.getAccountId());
+        createUnitJson.put("access_token", oauthToken.getAccessToken());
+        for (int i = 0; i < campaignIds.size(); i++) {
+            Long campaignId = campaignIds.getLong(i);
+            if (Check.isNull(campaignId)) {
+                continue;
+            }
+            for (int j = 0; j < unitNames.size(); j++) {
+                String unitName = unitNames.getString(j);
+                if (!Check.isNull(unitName)) {
+                    String s = JSON.toJSONString(createUnitJson, SerializerFeature.DisableCircularReferenceDetect);
+                    createUnitJson = JSON.parseObject(s);
+                    createUnitJson.remove("campaign_id");
+                    createUnitJson.remove("unit_name");
+                    createUnitJson.put("campaign_id", campaignId);
+                    createUnitJson.put("unit_name", unitName);
+                    createUnitArr.add(createUnitJson);
+                }
+            }
+        }
+        return createUnitArr;
+    }
+
+    /**
+     * 组装数据 array
+     *
+     * @param oauthToken
+     * @param createUnitArr
+     * @param campaignList
+     * @return
+     */
+    @Override
+    public JSONArray assembleUnitArray(CtopOauthToken oauthToken, JSONArray createUnitArr, JSONArray campaignList) {
+        for (int i = 0; i < campaignList.size(); i++) {
+            JSONObject campaignJson = campaignList.getJSONObject(i);
+            if (Check.isNull(campaignJson)) {
+                continue;
+            }
+            Long campaignId = campaignJson.getLong("campaignId");
+            Integer check = campaignJson.getInteger("check");
+            if (check == 1) { // 计划下组相同
+                JSONObject unitIdenticalJson = campaignJson.getJSONObject("unitIdentical");
+                if (Check.isNull(unitIdenticalJson)) {
+                    continue;
+                }
+                JSONArray unitNames = unitIdenticalJson.getJSONArray("unitName");
+                if (Check.isNull(unitNames)) {
+                    continue;
+                }
+
+                JSONObject createUnitJson = this.getCreateUnitJson(unitIdenticalJson);// 通用参数组装
+                for (int j = 0; j < unitNames.size(); j++) {
+                    String s = JSON.toJSONString(createUnitJson, SerializerFeature.DisableCircularReferenceDetect);
+                    createUnitJson = JSON.parseObject(s);
+
+                    String unitName = unitNames.getString(j);
+                    createUnitJson.put("advertiser_id", oauthToken.getAccountId());
+                    createUnitJson.put("access_token", oauthToken.getAccessToken());
+                    createUnitJson.remove("campaign_id");
+                    createUnitJson.remove("unit_name");
+                    createUnitJson.put("campaign_id", campaignId);
+                    createUnitJson.put("unit_name", unitName);
+                    createUnitArr.add(createUnitJson);
+                }
+            } else if (check == 2) {// 计划下组不同
+                JSONArray unitArray = campaignJson.getJSONArray("unit");
+                if (Check.isNull(unitArray)) {
+                    continue;
+                }
+                for (int j = 0; j < unitArray.size(); j++) {
+                    JSONObject unitJson = unitArray.getJSONObject(j);
+                    if (Check.isNull(unitJson)) {
+                        continue;
+                    }
+                    JSONObject createUnitJson = this.getCreateUnitJson(unitJson);// 通用参数组装
+                    createUnitJson.put("advertiser_id", oauthToken.getAccountId());
+                    createUnitJson.put("access_token", oauthToken.getAccessToken());
+                    createUnitJson.remove("campaign_id");
+                    createUnitJson.remove("unit_name");
+                    createUnitJson.put("campaign_id", campaignId);
+                    createUnitJson.put("unit_name", unitJson.getString("name"));
+                    createUnitArr.add(createUnitJson);
+                }
+            }
+        }
+        return createUnitArr;
+    }
+
+    /**
+     * 批量创建广告组
+     *
+     * @param createUnitArr
+     * @return
+     */
+    @Override
+    public JSONArray createUnit(JSONArray createUnitArr) {
+        JSONArray returnArr = new JSONArray();
+        for (int i = 0; i < createUnitArr.size(); i++) {
+            JSONObject createUnitJson = createUnitArr.getJSONObject(i);
+            if (Check.isNull(createUnitJson)) {
+                continue;
+            }
+            JSONObject resultJson = adUnitCreate(createUnitJson, 1);
+            returnArr.add(resultJson);
+
+        }
+        return returnArr;
+    }
+
+    /**
+     * 组装创建创意数据
+     *
+     * @param creativeArray
+     * @param accountJson
+     * @return
+     */
+    @Override
+    public JSONArray assembleCreativeJson(JSONArray creativeArray, JSONObject accountJson) {
+        if (Check.isNull(accountJson)) {
+            return creativeArray;
+        }
+        Long accountId = accountJson.getLong("accountId");
+        if (Check.isNull(accountId)) {
+            return creativeArray;
+        }
+        CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+        if (Check.isNull(oauthToken)) {
+            return creativeArray;
+        }
+        Long unitId = accountJson.getLong("unitId");
+        if (Check.isNull(unitId)) {
+            return creativeArray;
+        }
+
+        JSONArray photoArr = accountJson.getJSONArray("photoArr");
+        if (Check.isNull(photoArr)) {
+            return creativeArray;
+        }
+
+
+        String clickTrackUrl = accountJson.getString("clickTrackUrl");
+        String impressionUrl = accountJson.getString("impressionUrl");
+        String adPhotoPlayedT3sUrl = accountJson.getString("adPhotoPlayedT3sUrl");
+        Integer creativeCategory = accountJson.getInteger("creativeCategory");
+        JSONArray creativeTag = accountJson.getJSONArray("creativeTag");
+        String actionBarText = accountJson.getString("actionBarText");
+        String siteId = accountJson.getString("siteId");
+
+
+        for (int i = 0; i < photoArr.size(); i++) {
+            JSONObject photoJson = photoArr.getJSONObject(i);
+            if (Check.isNull(photoJson)) {
+                continue;
+            }
+            JSONObject creativeJson = new JSONObject();
+            creativeJson.put("advertiser_id", oauthToken.getAccountId());
+            creativeJson.put("access_token", oauthToken.getAccessToken());
+            creativeJson.put("unit_id", unitId);
+            creativeJson.put("unit_name", accountJson.getString("unitName"));
+            if (!Check.isNull(clickTrackUrl)) {
+                creativeJson.put("click_track_url", clickTrackUrl); //第三方点击检测链接
+            }
+            if (!Check.isNull(impressionUrl)) {
+                creativeJson.put("impression_url", impressionUrl); //第三方开始播放监测链接
+            }
+            if (!Check.isNull(adPhotoPlayedT3sUrl)) {
+                creativeJson.put("ad_photo_played_t3s_url", adPhotoPlayedT3sUrl); //第三方有效播放监测链接
+            }
+            if (!Check.isNull(photoJson.getString("actionbarClickUrl"))) {
+                creativeJson.put("actionbar_click_url", photoJson.getString("actionbarClickUrl")); //第三方点击按钮监测链接
+            }
+            if (!Check.isNull(creativeCategory)) {
+                creativeJson.put("creative_category", creativeCategory); // 创意分类
+            }
+            if (!Check.isNull((creativeTag))) {
+                creativeJson.put("creative_tag", creativeTag); //创意标签
+            }
+
+            Long creativeMaterialType = photoJson.getLong("creativeMaterialType");
+
+            JSONArray creatives = new JSONArray();
+            String creativeName = photoJson.getString("creativeName");// 创意名称
+            if (4 == creativeMaterialType) { // 便利贴组装数据
+
+                JSONArray imageTokens = photoJson.getJSONArray("imageTokens");
+                for (int j = 0; j < imageTokens.size(); j++) {
+                    String imageToken = imageTokens.getString(j);
+                    if (!Check.isNull(imageToken)) {
+                        JSONObject createJson = new JSONObject();
+                        if (!Check.isNull(photoJson.getString("shortSlogan"))) {
+                            createJson.put("short_slogan", photoJson.getString("shortSlogan")); // 便利贴创意短广告语
+                        }
+                        if (!Check.isNull(creativeMaterialType)) {
+                            createJson.put("creative_material_type", creativeMaterialType); // 素材类型
+                        }
+                        if (!Check.isNull(actionBarText)) {
+                            createJson.put("action_bar_text", actionBarText); // 行动号召按钮文案
+                        }
+                        if (!Check.isNull(photoJson.getString("description"))) {
+                            createJson.put("description", photoJson.getString("description")); // 广告语
+                        }
+                        if (!Check.isNull(photoJson.getString("stickerTitle"))) {
+                            createJson.put("sticker_title", photoJson.getString("stickerTitle")); //封面广告语标题
+                        }
+                        if (!Check.isNull(photoJson.getString("overlayType"))) {
+                            createJson.put("overlay_type", photoJson.getString("overlayType")); // 贴纸样式类型
+                        }
+                        if (!Check.isNull(photoJson.getString("exposeTag"))) {
+                            createJson.put("expose_tag", photoJson.getString("exposeTag")); //广告标签
+                        }
+                        if (!Check.isNull(photoJson.getString("newExposeTag"))) {
+                            createJson.put("new_expose_tag", photoJson.getString("newExposeTag")); // 广告标签2期
+                        }
+                        if (!Check.isNull(siteId)) {
+                            createJson.put("site_id", siteId); //安卓下载中间页ID
+                        }
+                        JSONArray imageTokenArr = new JSONArray();
+                        imageTokenArr.add(imageToken);
+                        createJson.put("image_tokens", imageTokenArr); // 便利贴创意短广告语
+                        if (!Check.isNull(creativeName)) {
+                            createJson.put("creative_name", creativeName + "_" + RandomUtil.verifyCodeV2()); // 便利贴创意短广告语
+                        }
+                        creatives.add(createJson);
+                    }
+                }
+                creativeJson.put("creatives", creatives);
+            } else { //  非便利贴组装数据
+                JSONArray imageTokenArr = photoJson.getJSONArray("imageTokenArr");
+                if (Check.isNull(imageTokenArr)) { // 如果图片为空 说明是首帧创建
+                    JSONObject createJson = new JSONObject();
+                    if (!Check.isNull(photoJson.getLong("photoId"))) {
+                        createJson.put("photo_id", photoJson.getLong("photoId")); // 视频id
+                    }
+                    createJson.put("creative_name", creativeName); // 创意名称
+                    if (!Check.isNull(creativeMaterialType)) {
+                        createJson.put("creative_material_type", creativeMaterialType); // 素材类型
+                    }
+                    if (!Check.isNull(actionBarText)) {
+                        createJson.put("action_bar_text", actionBarText); // 行动号召按钮文案
+                    }
+                    if (!Check.isNull(photoJson.getString("description"))) {
+                        createJson.put("description", photoJson.getString("description")); // 广告语
+                    }
+                    if (!Check.isNull(photoJson.getString("stickerTitle"))) {
+                        createJson.put("sticker_title", photoJson.getString("stickerTitle")); //封面广告语标题
+                    }
+                    if (!Check.isNull(photoJson.getString("overlayType"))) {
+                        createJson.put("overlay_type", photoJson.getString("overlayType")); // 贴纸样式类型
+                    }
+                    if (!Check.isNull(photoJson.getString("exposeTag"))) {
+                        createJson.put("expose_tag", photoJson.getString("exposeTag")); //广告标签
+                    }
+                    if (!Check.isNull(photoJson.getString("newExposeTag"))) {
+                        createJson.put("new_expose_tag", photoJson.getString("newExposeTag")); // 广告标签2期
+                    }
+                    if (!Check.isNull(siteId)) {
+                        createJson.put("site_id", siteId); //安卓下载中间页ID
+                    }
+
+                    if (!Check.isNull(photoJson.getString("stickerTitle"))) {
+                        createJson.put("sticker_title", photoJson.getString("stickerTitle")); //封面广告语标题
+                    }
+
+                    creatives.add(createJson);
+                } else { // 选择多张图片进行创建
+                    for (int j = 0; j < imageTokenArr.size(); j++) {
+                        String signature = imageTokenArr.getString(j);
+                        if (Check.isNull(signature)) {
+                            continue;
+                        }
+                        JSONObject createJson = new JSONObject();
+                        if (!Check.isNull(photoJson.getLong("photoId"))) {
+                            createJson.put("photo_id", photoJson.getLong("photoId")); // 视频id
+                        }
+                        QueryWrapper<KuaiShouImageGet> queryWrapper = new QueryWrapper<>();
+                        queryWrapper.eq("account_id", accountId);
+                        queryWrapper.eq("signature", signature);
+                        queryWrapper.last("limit 1");
+                        String imageToken = null;
+                        KuaiShouImageGet imageGet = imageGetService.getOne(queryWrapper);
+                        if (!Check.isNull(imageGet)) {
+                            imageToken = imageGet.getImageToken();
+                        } else {
+                            String url = imageGetService.getUrlByCode(signature);
+                            imageToken = uploadService.kuauiShouImageUpload(url, signature, accountId, oauthToken.getAccessToken());
+                        }
+                        if (!Check.isNull(imageToken)) {
+                            createJson.put("image_token", imageToken); // 封面图片 token
+                        }
+                        String name = creativeName + "_" + RandomUtil.verifyCodeV2();
+                        createJson.put("creative_name", name); // 创意名称
+                        if (!Check.isNull(creativeMaterialType)) {
+                            createJson.put("creative_material_type", creativeMaterialType); // 素材类型
+                        }
+                        if (!Check.isNull(actionBarText)) {
+                            createJson.put("action_bar_text", actionBarText); // 行动号召按钮文案
+                        }
+                        if (!Check.isNull(photoJson.getString("description"))) {
+                            createJson.put("description", photoJson.getString("description")); // 广告语
+                        }
+
+                        if (!Check.isNull(photoJson.getString("stickerTitle"))) {
+                            createJson.put("sticker_title", photoJson.getString("stickerTitle")); //封面广告语标题
+                        }
+                        if (!Check.isNull(photoJson.getString("overlayType"))) {
+                            createJson.put("overlay_type", photoJson.getString("overlayType")); // 贴纸样式类型
+                        }
+                        if (!Check.isNull(photoJson.getString("exposeTag"))) {
+                            createJson.put("expose_tag", photoJson.getString("exposeTag")); //广告标签
+                        }
+                        if (!Check.isNull(photoJson.getString("newExposeTag"))) {
+                            createJson.put("new_expose_tag", photoJson.getString("newExposeTag")); // 广告标签2期
+                        }
+                        if (!Check.isNull(siteId)) {
+                            createJson.put("site_id", siteId); //安卓下载中间页ID
+                        }
+                        creatives.add(createJson);
+                    }
+
+                }
+
+
+            }
+            creativeJson.put("creatives", creatives);
+            creativeArray.add(creativeJson);
+        }
+
+        return creativeArray;
+    }
+
+    /**
+     * 跨账户批量创建计划
+     *
+     * @param creativeArray
+     * @return
+     */
+    @Override
+    public JSONArray createCreative(JSONArray creativeArray) {
+        JSONArray returnArr = new JSONArray();
+        for (int i = 0; i < creativeArray.size(); i++) {
+            JSONObject createUnitJson = creativeArray.getJSONObject(i);
+            if (Check.isNull(createUnitJson)) {
+                continue;
+            }
+            JSONObject resultJson = aCreativeCreate(createUnitJson, 1);
+            returnArr.add(resultJson);
+        }
+        return returnArr;
+    }
+
+    /**
+     * 调用快手创建接口
+     *
+     * @param requestJson
+     * @param count
+     * @return
+     */
+
+    private JSONObject adUnitCreate(JSONObject requestJson, Integer count) {
+        JSONObject returnJson = new JSONObject();
+        try {
+            if (Check.isNull(requestJson)) {
+                throw new Exception("参数不能为空");
+            }
+            String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.AD_UNIT_CREATE;
+            Long advertiserId = requestJson.getLong("advertiser_id");
+            String accessToken = requestJson.getString("access_token");
+            Map<String, String> headers = new HashMap<>();
+            headers.put("Access-Token", accessToken);
+            headers.put("Content-Type", " application/json");
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            log.info("快手创建广告组返回,accountId:{},返回结果:{}", requestJson.getString("advertiser_id"), resultJson);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject dataJson = resultJson.getJSONObject("data");
+                    if (!Check.isNull(dataJson)) {
+                        Long unitId = dataJson.getLong("unit_id");
+
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                getKuaiShouGroupService.getGroupByUnitId(accessToken, advertiserId, unitId);
+                            }
+
+                        };
+                        thread.start();
+                        returnJson.put("code", 0);
+                        returnJson.put("accountId", requestJson.getLong("advertiser_id"));
+                        returnJson.put("campaignId", requestJson.getLong("campaign_id"));
+                        returnJson.put("unitId", unitId);
+                        returnJson.put("accountName", requestJson.getString("account_name"));
+                        returnJson.put("unitName", requestJson.getString("unit_name"));
+                        returnJson.put("sceneId", requestJson.getJSONArray("scene_id").toJSONString());
+                        returnJson.put("ocpxActionType", requestJson.getLong("ocpx_action_type"));
+                        returnJson.put("bidType", requestJson.getLong("bid_type"));
+                        returnJson.put("unitType", requestJson.getInteger("unit_type"));
+                    }
+
+                } else {
+
+                    if (code == 500000 && count <= 4) {
+                        adUnitCreate(requestJson, count + 1);
+                    }
+                    log.error("创建广告信息失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson);
+                    returnJson.put("code", -1);
+                    returnJson.put("message", resultJson.getString("message"));
+                    returnJson.put("accountId", requestJson.getLong("advertiser_id"));
+                    returnJson.put("accountName", requestJson.getString("account_name"));
+                    returnJson.put("unitName", requestJson.getString("unit_name"));
+                }
+            } else {
+                if (count <= 4) {
+                    log.info("创建组失败,重试,入参:{}", requestJson);
+                    adUnitCreate(requestJson, count + 1);
+                }
+                log.error("快手创建广告计划返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
+                returnJson.put("code", -1);
+                returnJson.put("message", "创建广告组异常,返回结果为空");
+                returnJson.put("accountName", requestJson.getString("account_name"));
+                returnJson.put("accountId", requestJson.getLong("advertiser_id"));
+                returnJson.put("unitName", requestJson.getString("unit_name"));
+
+            }
+        } catch (Exception e) {
+            log.error("创建广告计划失败,advertiser_id:{}", requestJson.getLong("advertiser_id"));
+            returnJson.put("code", -1);
+            returnJson.put("message", "创建广告组错误,系统异常");
+            returnJson.put("accountId", requestJson.getLong("advertiser_id"));
+            returnJson.put("accountName", requestJson.getString("account_name"));
+            returnJson.put("unitName", requestJson.getString("unit_name"));
+            returnJson.put("desc", "Interface exception");
+
+            e.printStackTrace();
+        }
+        return returnJson;
+    }
+
+    /**
+     * 创建创意
+     *
+     * @param
+     * @param
+     * @param requestJson
+     * @param count
+     * @return
+     */
+    private JSONObject aCreativeCreate(JSONObject requestJson, Integer count) {
+        JSONObject retuenJson = new JSONObject();
+        try {
+            Long advertiserId = requestJson.getLong("advertiser_id");
+            String accessToken = requestJson.getString("access_token");
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v2/creative/batch/update";
+            requestJson.put("advertiser_id", advertiserId);
+            Map<String, String> header = new HashMap<String, String>();
+            header.put("Content-Type", " application/json");
+            header.put("Access-Token", accessToken);
+
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), header);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            log.info("快手创建创意返回:accountId:{},返回结果{}", requestJson.getLong("advertiser_id"), resultJson);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject dataJson = resultJson.getJSONObject("data");
+                    if (!Check.isNull(dataJson)) {
+                        JSONArray add_creative_ids = dataJson.getJSONArray("add_creative_ids");
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                try {
+                                    Thread.sleep(100);
+                                    kuaishouInterfaceService.getCreativeByCreativeIds(accessToken, advertiserId, add_creative_ids);
+
+                                } catch (InterruptedException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        };
+                        thread.start();
+                        retuenJson.put("code", 0);
+                        retuenJson.put("accountId", requestJson.getLong("advertiser_id"));
+                        retuenJson.put("unitId", requestJson.getString("unit_id"));
+                        retuenJson.put("unitName", requestJson.getString("unit_name"));
+                    }
+                } else {
+                    if (code == 500000 && count <= 4) {
+                        aCreativeCreate(requestJson, count + 1);
+                    }
+                    if (code == 400001 && "/rest/openapi/v2/creative/create已超日限".equals(resultJson.getString("message"))) {
+                        overRunSendMessageService.creativeOverRunSendMessage(advertiserId);
+                    }
+                    log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson, count + 1);
+                    retuenJson.put("code", -1);
+                    retuenJson.put("message", resultJson.getString("message"));
+                    retuenJson.put("accountId", requestJson.getLong("advertiser_id"));
+                    retuenJson.put("unitId", requestJson.getString("unit_id"));
+                    retuenJson.put("unitName", requestJson.getString("unit_name"));
+                }
+            } else {
+                if (count <= 4) {
+                    aCreativeCreate(requestJson, count + 1);
+                }
+                log.error("快手创建广告创意返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
+                retuenJson.put("code", -1);
+                retuenJson.put("message", "创建创意失败,返回信息为空");
+                retuenJson.put("accountId", requestJson.getLong("advertiser_id"));
+                retuenJson.put("unitId", requestJson.getString("unit_id"));
+                retuenJson.put("unitName", requestJson.getString("unit_name"));
+            }
+
+        } catch (Exception e) {
+            log.error("创建广告创意失败,advertiser_id:{}", requestJson.getLong("advertiser_id"));
+            retuenJson.put("code", -1);
+            retuenJson.put("message", e.getMessage());
+            retuenJson.put("accountId", requestJson.getLong("advertiser_id"));
+            retuenJson.put("unitId", requestJson.getString("unit_id"));
+            retuenJson.put("unitName", requestJson.getString("unit_name"));
+            e.printStackTrace();
+        }
+        return retuenJson;
+
+    }
+
+    /**
+     * 通用组创建数据组装
+     *
+     * @param campaignOne
+     * @return
+     */
+    private JSONObject getCreateUnitJson(JSONObject campaignOne) {
+        JSONObject createUnitJson = new JSONObject();
+
+
+        if (!Check.isNull(campaignOne.getString("accountName"))) {
+            createUnitJson.put("account_name", campaignOne.getString("accountName")); // 优化目标类型
+        }
+
+        if (!Check.isNull(campaignOne.getInteger("bidType"))) {
+            createUnitJson.put("bid_type", campaignOne.getInteger("bidType")); // 优化目标类型
+        }
+
+        if (!Check.isNull(campaignOne.getInteger("useAppMarket"))) {
+            createUnitJson.put("use_app_market", campaignOne.getInteger("useAppMarket")); //优先从系统应用商店下载
+        }
+        if (!Check.isNull(campaignOne.getJSONArray("appStore"))) {
+            createUnitJson.put("app_store", campaignOne.getJSONArray("appStore")); //应用商店列表
+        }
+        if (!Check.isNull(campaignOne.getLong("bid"))) {
+            createUnitJson.put("bid", campaignOne.getLong("bid")); //出价
+
+        }
+        if (!Check.isNull(campaignOne.getLong("cpaBid"))) {
+            createUnitJson.put("cpa_bid", campaignOne.getLong("cpaBid")); //出价
+
+        }
+        if (!Check.isNull(campaignOne.getInteger("smartBid"))) {
+            createUnitJson.put("smart_bid", campaignOne.getInteger("smartBid")); //优先低成本出价(设置条件)
+
+        }
+        if (!Check.isNull(campaignOne.getInteger("ocpxActionType"))) {
+            createUnitJson.put("ocpx_action_type", campaignOne.getInteger("ocpxActionType")); //优化目标
+
+        }
+        if (!Check.isNull(campaignOne.getInteger("deepConversionType"))) {
+            createUnitJson.put("deep_conversion_type", campaignOne.getInteger("deepConversionType")); //深度转化目标
+
+        }
+        if (!Check.isNull(campaignOne.getDouble("roiRatio"))) {
+            createUnitJson.put("roi_ratio", campaignOne.getDouble("roiRatio")); //付费ROI系数
+
+        }
+        if (!Check.isNull(campaignOne.getLong("deepConversionBid"))) {
+            createUnitJson.put("deep_conversion_bid", campaignOne.getLong("deepConversionBid")); //深度转化目标出价
+
+        }
+        if (!Check.isNull(campaignOne.getJSONArray("sceneId"))) {
+            createUnitJson.put("scene_id", campaignOne.getJSONArray("sceneId")); //资源位置
+
+        }
+        if (!Check.isNull(campaignOne.getInteger("unitType"))) {
+            createUnitJson.put("unit_type", campaignOne.getInteger("unitType")); //创意制作方式
+
+        }
+        if (!Check.isNull(campaignOne.getString("beginTime"))) {
+            createUnitJson.put("begin_time", campaignOne.getString("beginTime")); //投放开始时间
+
+        }
+        if (!Check.isNull(campaignOne.getString("endTime"))) {
+            createUnitJson.put("end_time", campaignOne.getString("endTime")); //投放结束时间
+
+        }
+        if (!Check.isNull(campaignOne.getString("scheduleTime"))) {
+            createUnitJson.put("schedule_time", campaignOne.getString("scheduleTime")); //投放时间段
+
+        }
+        if (!Check.isNull(campaignOne.getLong("dayBudget"))) {
+            createUnitJson.put("day_budget", campaignOne.getLong("dayBudget")); //单日预算金额
+
+        }
+        if (!Check.isNull(campaignOne.getJSONArray("dayBudgetSchedule"))) {
+            createUnitJson.put("day_budget_schedule", campaignOne.getJSONArray("dayBudgetSchedule")); //分日预算
+
+        }
+        if (!Check.isNull(campaignOne.getInteger("convert_id"))) {
+            createUnitJson.put("convert_id", campaignOne.getInteger("convert_id")); //转化目标ID
+
+        }
+        if (!Check.isNull(campaignOne.getString("url_type"))) {
+            createUnitJson.put("url_type", campaignOne.getString("url_type")); //url类型
+
+        }
+        if (!Check.isNull(campaignOne.getString("webUriType"))) {
+            createUnitJson.put("web_uri_type", campaignOne.getString("webUriType")); //url类型
+
+        }
+        if (!Check.isNull(campaignOne.getString("url"))) {
+            createUnitJson.put("url", campaignOne.getString("url")); // 投放链接
+
+        }
+        if (!Check.isNull(campaignOne.getString("schemaUri"))) {
+            createUnitJson.put("schema_uri", campaignOne.getString("schemaUri")); // 调起链接
+
+        }
+        if (!Check.isNull(campaignOne.getString("appId"))) {
+            createUnitJson.put("app_id", campaignOne.getString("appId")); // 应用ID
+
+        }
+        if (!Check.isNull(campaignOne.getInteger("showMode"))) {
+            createUnitJson.put("show_mode", campaignOne.getInteger("showMode")); // 创意展现方式
+
+        }
+        if (!Check.isNull(campaignOne.getInteger("speed"))) {
+            createUnitJson.put("speed", campaignOne.getInteger("speed")); // 投放方式
+
+        }
+        if (!Check.isNull(campaignOne.getInteger("siteType"))) {
+            createUnitJson.put("site_type", campaignOne.getInteger("siteType")); //预约广告
+
+        }
+        if (!Check.isNull(campaignOne.getInteger("giftData"))) {
+            createUnitJson.put("gift_data", campaignOne.getInteger("giftData")); //游戏礼包码
+
+        }
+        if (!Check.isNull(campaignOne.getBoolean("videoLandingPage"))) {
+            createUnitJson.put("video_landing_page", campaignOne.getBoolean("videoLandingPage")); //游戏礼包码
+
+        }
+        if (!Check.isNull(campaignOne.getBoolean("autoTarget"))) {
+            createUnitJson.put("auto_target", campaignOne.getBoolean("autoTarget")); //智能定向
+
+        }
+        if (!Check.isNull(campaignOne.getBoolean("smartCover"))) {
+            createUnitJson.put("smart_cover", campaignOne.getBoolean("smartCover")); //是否开启智能抽帧
+
+        }
+        if (!Check.isNull(campaignOne.getBoolean("assetMining"))) {
+            createUnitJson.put("asset_mining", campaignOne.getBoolean("assetMining")); //是否开启历史素材挖掘
+
+        }
+
+        if (!Check.isNull(campaignOne.getLong("templateId"))) {
+            createUnitJson.put("template_id", campaignOne.getLong("templateId")); //定向模板id
+        }
+
+        return createUnitJson;
+    }
+
+
+}

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

@@ -893,6 +893,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             Date getStartDate = DateUtils.addDay(endDate, -i);
             //1: 获取广告主信息数据
             getAdvertiserReportHourly(token, getStartDate, getStartDate);
+            getAdvertiserReportDaily(token, getStartDate, getStartDate);
             //2:获取广告计划信息数据
             // getAdvertiserCampaignReportHourly(token, getStartDate, getStartDate);
             //3:获取广告组信息数据

+ 23 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaiShouGetAccountFundService.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import com.alibaba.fastjson.JSONObject;
+
+/**
+ *  Created by JQ.bi on 2020.11.15
+ *
+ *  拉取账户余额
+ */
+public interface IKuaiShouGetAccountFundService {
+
+    /**
+     * 获取账号余额信息
+     */
+    JSONObject getAccountFundBy(CtopOauthToken token, Long advertiserId);
+
+    /**
+     * 获取账号余额信息
+     */
+    JSONObject getAccountReportBy(CtopOauthToken token, Long advertiserId);
+
+}

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

@@ -0,0 +1,7 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+public interface IRuleKuaiShouAccountService {
+
+    void cleanRuleDataAccount(Long accountId);
+
+}

+ 23 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IRuleKuaiShouPlanService.java

@@ -0,0 +1,23 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+/**
+ *  快手规则引擎数据清洗;计划、组、定向
+ */
+public interface IRuleKuaiShouPlanService {
+
+    /**
+     *  计划
+     */
+    void cleanRuleDataPlan(Long accountId,int page);
+
+    /**
+     *  组
+     */
+    void cleanRuleDataUnit(Long accountId,String startDate, String endDate,int page);
+
+    /**
+     *  定向
+     */
+    void cleanRuleDataTarget(Long accountId,int page);
+
+}

+ 62 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouGetAccountFundServiceImpl.java

@@ -0,0 +1,62 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouGetAccountFundService;
+
+import com.alibaba.fastjson.JSONObject;
+import com.xxl.job.core.context.XxlJobHelper;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.constant.SystemDateConstant;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class KuaiShouGetAccountFundServiceImpl implements IKuaiShouGetAccountFundService {
+
+    @Override
+    public JSONObject getAccountFundBy(CtopOauthToken token, Long advertiserId) {
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+
+        JSONObject params=new JSONObject();
+        params.put("advertiser_id",advertiserId);
+
+        JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpGetRequest("https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/fund/get", headers,params));
+        if(jsonObject.getInteger("code")!=0){
+            XxlJobHelper.log("查询账户余额失败==》accountId:{},message:{}", token.getAccountId(), jsonObject.getString("message"));
+            return null;
+        }
+        return jsonObject.getJSONObject("data");
+    }
+
+    @Override
+    public JSONObject getAccountReportBy(CtopOauthToken token, Long advertiserId) {
+
+        JSONObject result= new JSONObject();
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+
+        String now = DateUtils.getNowDate(SystemDateConstant.yyyy_MM_dd);
+        JSONObject params=new JSONObject();
+        params.put("advertiser_id",advertiserId);
+        params.put("start_date",now);
+        params.put("end_date",now);
+        JSONObject jsonObject = JSONObject.parseObject(HttpUtils.httpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/report/account_report", params, headers));
+        if(jsonObject.getInteger("code")!=0){
+            XxlJobHelper.log("账户{}获取实时数据失败---{}",advertiserId,jsonObject.getString("message"));
+        }else {
+            if(!jsonObject.getJSONObject("data").getJSONArray("details").isEmpty()){
+                result= (JSONObject) jsonObject.getJSONObject("data").getJSONArray("details").get(0);
+            }
+        }
+        return result;
+    }
+}

+ 6 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBussiness;
@@ -43,6 +44,8 @@ import java.util.Map;
 public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyMapper, KuaishouAudienceReportDaily> implements IKuaishouAudienceReportDailyService {
 
     @Autowired
+    private KuaiShouCampaignMapper kuaiShouCampaignMapper;
+    @Autowired
     private KuaishouAudienceReportDailyProvinceMapper provinceMapper;
     @Autowired
     private KuaishouAudienceReportDailyAgeMapper ageMapper;
@@ -70,6 +73,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
     public void crowdAnalysisReport(CtopOauthToken token, String date, String type, Integer page, Integer pageSize) {
         long start = System.currentTimeMillis();
         try {
+            JSONArray campaignIdList = kuaiShouCampaignMapper.queryCampaignIdByAccountId(token.getAccountId());
             String url = urlPath + KuaishouInterfaceConstant.AUDIENCE_REPORT;
             JSONArray reportDims = new JSONArray();
             reportDims.add(type);
@@ -78,6 +82,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
             headers.put("Content-Type", "application/json");
             JSONObject requestJson = new JSONObject();
             requestJson.put("advertiser_id", token.getAccountId());
+            requestJson.put("campaign_ids", campaignIdList);
             requestJson.put("start_date", date);
             requestJson.put("end_date", date);
             requestJson.put("report_dims", reportDims);
@@ -91,7 +96,6 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                     JSONObject datas = resultJson.getJSONObject("data");
                     JSONArray details = datas.getJSONArray("details");
                     if (!Check.isNull(details)) {
-                        System.out.println(type + ",size:" + details.size());
                         for (int i = 0; i < details.size(); i++) {
                             JSONObject obj = details.getJSONObject(i);
                             if ("province".equals(type)) {
@@ -145,7 +149,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                             }
                         }
                     }
-                }else{
+                } else {
                     log.error("查询人群分析报表数据返回信息错误:accountId:{},返回信息:{}", token.getAccountId(), resultJson);
                 }
             }

+ 43 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouAccountServiceImpl.java

@@ -0,0 +1,43 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouGetAccountFundService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouAccountService;
+import com.alibaba.fastjson.JSONObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class RuleKuaiShouAccountServiceImpl implements IRuleKuaiShouAccountService {
+
+    @Autowired
+    IKuaiShouGetAccountFundService kuaiShouGetAccountFundService;
+    @Autowired
+    ICtopOauthTokenService oauthTokenService;
+    @Autowired
+    IRuleDataAccountKuaishouService ruleDataAccountKuaishouService;
+    @Autowired
+    IUserAllocationService userAllocationService;
+
+    @Override
+    public void cleanRuleDataAccount(Long accountId) {
+        CtopOauthToken oauthToken=oauthTokenService.getTokenByAccountId(accountId);
+        //查询账户实时数据
+        JSONObject dataAccount=kuaiShouGetAccountFundService.getAccountReportBy(oauthToken,accountId);
+        if(!dataAccount.isEmpty()){
+            JSONObject fundData=kuaiShouGetAccountFundService.getAccountFundBy(oauthToken,accountId);
+            RuleDataAccountKuaishou ruleDataAccount=new RuleDataAccountKuaishou();
+            ruleDataAccount.setId(accountId);
+            ruleDataAccount.setAccountName(userAllocationService.getByAccountId(accountId).getAuthName());
+            ruleDataAccount.setAccountId(accountId);
+            ruleDataAccount.setCost(dataAccount.getBigDecimal("charge"));
+            ruleDataAccount.setValidBalance(fundData.getBigDecimal("balance"));
+
+            ruleDataAccountKuaishouService.saveOrUpdate(ruleDataAccount);
+        }
+    }
+}

+ 258 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java

@@ -0,0 +1,258 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataTargetKuaishouService;
+import cn.com.ctop.common.module.service.IRuleDataUnitKuaishouService;
+import cn.com.ctop.common.module.service.IRuleDatePlanKuaishouService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.report.service.IRuleKuaiShouPlanService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxl.job.core.context.XxlJobHelper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class RuleKuaiShouPlanServiceImpl implements IRuleKuaiShouPlanService {
+
+    @Autowired
+    ICtopOauthTokenService oauthTokenService;
+
+    @Autowired
+    IRuleDataTargetKuaishouService targetKuaishouService;
+
+    @Autowired
+    IRuleDatePlanKuaishouService planKuaishouService;
+
+    @Autowired
+    IRuleDataUnitKuaishouService unitKuaishouService;
+
+    @Autowired
+    IKuaiShouGroupService kuaiShouGroupService;
+
+    @Override
+    public void cleanRuleDataPlan(Long accountId, int page) {
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", oauthTokenService.getTokenByAccountId(accountId).getAccessToken());
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/campaign/list", param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            XxlJobHelper.log("获取广告计划接口异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            XxlJobHelper.log("获取广告计划返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        this.insertPlan(accountId, details);
+        cleanRuleDataPlan(accountId, page + 1);
+    }
+
+    @Override
+    public void cleanRuleDataUnit(Long accountId, String startDate, String endDate, int page) {
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page_size", 500);
+        param.put("page", page);
+        param.put("start_date",startDate);
+        param.put("end_date",endDate);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", oauthTokenService.getTokenByAccountId(accountId).getAccessToken());
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/report/unit_report", param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            XxlJobHelper.log("获取广告组报表接口异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            XxlJobHelper.log("获取广告组报表返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        this.insertUnit(accountId, details);
+        cleanRuleDataUnit(accountId, startDate, endDate, page + 1);
+    }
+
+    @Override
+    public void cleanRuleDataTarget(Long accountId, int page) {
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", accountId);
+        param.put("page_size", 500);
+        param.put("page", page);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", oauthTokenService.getTokenByAccountId(accountId).getAccessToken());
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/ad_unit/list", param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            XxlJobHelper.log("获取广告组接口异常,advertiserId:{}", accountId);
+            return;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            XxlJobHelper.log("获取广告组返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return;
+        }
+        this.insertTarget(accountId, details);
+        cleanRuleDataTarget(accountId, page + 1);
+    }
+
+    private void insertPlan(Long accountId, JSONArray details) {
+        List<RuleDatePlanKuaishou> batch = new ArrayList<>();
+        details.forEach(detail -> {
+            JSONObject planDetail = (JSONObject) detail;
+            RuleDatePlanKuaishou plan = new RuleDatePlanKuaishou();
+            if (planDetail.getInteger("status") == 4 && planDetail.getInteger("put_status") == 1) {
+                plan.setId(planDetail.getLong("campaign_id"));
+                plan.setAccountId(accountId);
+                plan.setPlanId(planDetail.getLong("campaign_id"));
+                plan.setPlanName(planDetail.getString("campaign_name"));
+                batch.add(plan);
+            }
+        });
+        if(!batch.isEmpty()) {
+            planKuaishouService.saveOrUpdateBatch(batch);
+        }
+    }
+
+    private void insertUnit(Long accountId, JSONArray details) {
+        List<RuleDateUnitKuaishou> batch = new ArrayList<>();
+        details.forEach(detail -> {
+            JSONObject unitDetail = (JSONObject) detail;
+            RuleDateUnitKuaishou unit = new RuleDateUnitKuaishou();
+            QueryWrapper<KuaiShouGroup> wrapper=new QueryWrapper<>();
+            wrapper.eq("unit_id",unitDetail.getLong("unit_id"));
+            KuaiShouGroup group = kuaiShouGroupService.getOne(wrapper);
+            if(group!=null){
+                unit.setId(unitDetail.getLong("unit_id"));
+                unit.setAccountId(accountId);
+                unit.setPlanId(unitDetail.getLong("campaign_id"));
+                unit.setUnitId(unitDetail.getLong("unit_id"));
+                unit.setUnitName(unitDetail.getString("unit_name"));
+                unit.setCharge(unitDetail.getBigDecimal("charge"));
+                //未知优化目标数据存空
+                if(group.getOcpxActionType()!=0){
+                    unit.setConvertNum(handleConvertNum(group.getOcpxActionType(),unitDetail));
+                    if(unit.getConvertNum()!=0){
+                        unit.setConvertCost(unitDetail.getBigDecimal("charge").divide(BigDecimal.valueOf(unit.getConvertNum()), 2, RoundingMode.HALF_UP));
+                    }
+                }
+                batch.add(unit);
+            }
+
+        });
+        if(!batch.isEmpty()){
+            unitKuaishouService.saveOrUpdateBatch(batch);
+        }
+    }
+
+    private void insertTarget(Long accountId, JSONArray details) {
+        List<RuleDataTargetKuaishou> batch = new ArrayList<>();
+        details.forEach(detail -> {
+            JSONObject unitDetail = (JSONObject) detail;
+            RuleDataTargetKuaishou target = new RuleDataTargetKuaishou();
+            if ((unitDetail.getInteger("status") == 20 || unitDetail.getInteger("status") == 19) &&
+                    unitDetail.getInteger("put_status") == 1) {
+                target.setId(unitDetail.getLong("unit_id"));
+                target.setAccountId(accountId);
+                target.setPlanId(unitDetail.getLong("campaign_id"));
+                target.setUnitId(unitDetail.getLong("unit_id"));
+                target.setSceneId(unitDetail.getJSONArray("scene_id")==null?"":unitDetail.getJSONArray("scene_id").toString());
+                target.setRegion(unitDetail.getJSONArray("region")==null?"":unitDetail.getJSONArray("region").toString());
+                target.setGender(unitDetail.getInteger("gender")==null?0:unitDetail.getInteger("gender"));
+                target.setPlatformOs(unitDetail.getInteger("platform_os")==null?0:unitDetail.getInteger("platform_os"));
+                target.setDeviceBrand(unitDetail.getJSONArray("device_brand")==null?"":unitDetail.getJSONArray("device_brand").toString());
+                target.setDevicePrice(unitDetail.getJSONArray("device_price")==null?"":unitDetail.getJSONArray("device_price").toString());
+                target.setFilterConvertedLevel(unitDetail.getInteger("filter_converted_level")==null?0:unitDetail.getInteger("filter_converted_level"));
+                target.setIsOpen(unitDetail.getInteger("is_open")==null?0:unitDetail.getInteger("is_open"));
+                target.setScheduleTime(unitDetail.getString("schedule_time")==null?"":unitDetail.getString("schedule_time"));
+                batch.add(target);
+            }
+        });
+        if (!batch.isEmpty()) {
+            targetKuaishouService.saveOrUpdateBatch(batch);
+        }
+    }
+
+    private Long handleConvertNum(int ocpxActionType,JSONObject detail){
+        Long convertNum=null;
+        switch (ocpxActionType){
+            case 2:
+                convertNum=detail.getLong("submit");
+                break;
+            case 10:
+                convertNum=detail.getLong("show");
+                break;
+            case 11:
+                convertNum=detail.getLong("photo_click");
+                break;
+            case 31:
+                convertNum=detail.getLong("download_completed");
+                break;
+            case 53:
+                convertNum=detail.getLong("event_valid_clues");
+                break;
+            case 180:
+                convertNum=detail.getLong("activation");
+                break;
+            case 190:
+                convertNum=detail.getLong("event_pay");
+                break;
+            case 191:
+                convertNum=detail.getDouble("event_pay_first_day_roi").longValue();
+                break;
+            case 348:
+                convertNum=detail.getLong("event_valid_clues");
+                break;
+            case 383:
+                convertNum=detail.getLong("event_credit_grant_landing_page");
+                break;
+            case 384:
+                convertNum=detail.getLong("event_jin_jian_landing_page");
+                break;
+            case 715:
+                convertNum=detail.getLong("event_add_wechat");
+                break;
+        }
+        return convertNum;
+    }
+}

+ 24 - 30
module-kuaishou/src/main/resources/kuaishou_config.properties

@@ -1,30 +1,12 @@
-#kuaishou_api_url=https://ad.e.kuaishou.com
-#kuaishou_auth_url=https://ad.e.kuaishou.com
-#kuaishou_appid=27
-#kuaishou_third_appid=328
-#oauth_type=agent
-#kuaishou_secret=QovprB1tNhXptgDc
-#kuaishou_third_secret=1iFTBiMdohkyEQQs
-#kuaishou_callback_url=http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
-#kuaishou_third_callback_url=http://callback.shyouteng.com.cn/kuaishou
-#apk_sava_path=/mnt/file/apk
-#image_sava_path=/mnt/file/image
-#video_sava_path=/mnt/file/video
-### 模板视频存放路径
-#model_video_src_path=/mnt/data/src/
-### 片段合成视频存放路径
-#model_video_fill_path=/mnt/data/fill/
-###
-#model_video_final_path=/mnt/data/final/
-
-
-## jiaoyang
 kuaishou_api_url=https://ad.e.kuaishou.com
 kuaishou_auth_url=https://ad.e.kuaishou.com
-kuaishou_appid=328
+kuaishou_appid=27
+kuaishou_third_appid=328
 oauth_type=agent
-kuaishou_secret=1iFTBiMdohkyEQQs
-kuaishou_callback_url=http://callback.shyouteng.com.cn/kuaishou
+kuaishou_secret=QovprB1tNhXptgDc
+kuaishou_third_secret=1iFTBiMdohkyEQQs
+kuaishou_callback_url=http://adsp.c-top.com.cn:8080/jeecg-boot/kuaishou
+kuaishou_third_callback_url=http://callback.shyouteng.com.cn/kuaishou
 apk_sava_path=/mnt/file/apk
 image_sava_path=/mnt/file/image
 video_sava_path=/mnt/file/video
@@ -34,9 +16,21 @@ model_video_src_path=/mnt/data/src/
 model_video_fill_path=/mnt/data/fill/
 ##
 model_video_final_path=/mnt/data/final/
-## 模板视频存放路径
-model_video_src_path_test=D:\\data\\model\\src\\
-## 片段合成视频存放路径
-model_video_fill_path_test=D:\\data\\model\\fill\\
-##
-model_video_final_path_test=D:\\data\\model\\final\\
+
+
+## jiaoyang
+#kuaishou_api_url=https://ad.e.kuaishou.com
+#kuaishou_auth_url=https://ad.e.kuaishou.com
+#kuaishou_appid=328
+#oauth_type=agent
+#kuaishou_secret=1iFTBiMdohkyEQQs
+#kuaishou_callback_url=http://callback.shyouteng.com.cn/kuaishou
+#apk_sava_path=/mnt/file/apk
+#image_sava_path=/mnt/file/image
+#video_sava_path=/mnt/file/video
+### 模板视频存放路径
+#model_video_src_path=/mnt/data/src/
+### 片段合成视频存放路径
+#model_video_fill_path=/mnt/data/fill/
+###
+#model_video_final_path=/mnt/data/final/

+ 5 - 13
module-toutiao/src/main/resources/bytedance_config.properties

@@ -1,26 +1,22 @@
 #release
-#bytedance_appid=1635316529903624
+bytedance_appid=1635316529903624
 # bytedance_appid=1634953881401358
-#bytedance_secret=0c51523e90d6166418fc8421a4896808e90e26f4
+bytedance_secret=0c51523e90d6166418fc8421a4896808e90e26f4
 # bytedance_secret=34bc59f53955c66871ce111a1f15a6051cfa3f12
 #release
-#bytedance_api_url=https://ad.oceanengine.com/open_api
-#bytedance_auth_url=https://ad.oceanengine.com/openapi
-
+bytedance_api_url=https://ad.oceanengine.com/open_api
+bytedance_auth_url=https://ad.oceanengine.com/openapi
 #sandbox
 #bytedance_api_url=https://test-ad.toutiao.com/open_api
 #bytedance_auth_url=https://test-ad.toutiao.com/open_api
 #bytedance_callback_url=http://callback.c-top.com.cn/bytedance
-#bytedance_callback_url=http://adsp.c-top.com.cn:8080/jeecg-boot/bytedance
+bytedance_callback_url=http://adsp.c-top.com.cn:8080/jeecg-boot/bytedance
 bytedance_v2_advertiser_info=/2/advertiser/public_info/
 bytedance_v2_ad_get=/2/ad/get/
-bytedance_v2_advertiser_fund_daily_stat=/2/advertiser/fund/daily_stat/
 bytedance_v2_ad_create=/2/ad/create/
-bytedance_v2_ad_update=/2/ad/update/
 bytedance_v2_ad_update_status=/2/ad/update/status/
 bytedance_v2_ad_update_bid=/2/ad/update/bid/
 bytedance_v2_ad_update_budget=/2/ad/update/budget/
-bytedance_v2_ad_update_reject_reason=2/ad/reject_reason/
 bytedance_v2_campaign_get=/2/campaign/get/
 bytedance_v2_campaign_create=/2/campaign/create/
 bytedance_v2_campaign_update_status=/2/campaign/update/status/
@@ -32,10 +28,6 @@ bytedance_v2_creative_update_status=/2/creative/update/status/
 bytedance_v2_creative_material_get=/2/creative/material/read/
 bytedance_v2_creative_create_v2=/2/creative/create_v2/
 bytedance_v2_creative_get=/2/creative/get/
-bytedance_v2_creative_read=/2/creative/read_v2/
-bytedance_v2_creative_update=/2/creative/update_v2/
-bytedance_v2_creative_reject_reason=/2/creative/reject_reason/
-
 bytedance_v2_advertiser_report_get=/2/report/advertiser/get/
 bytedance_v2_campaign_report_get=/2/report/campaign/get/
 bytedance_v2_ad_report_get=/2/report/ad/get/