Browse Source

Merge remote-tracking branch 'origin/master_jiaoyang' into master_jiaoyang

syh 5 years ago
parent
commit
cb61670060
44 changed files with 1768 additions and 162 deletions
  1. 0 7
      jeecg-boot-module-system/pom.xml
  2. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/KuaishouDailyCreativeReportLoadJob.java
  3. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java
  4. 3 3
      jeecg-boot-module-system/src/main/resources/application-dev.yml
  5. 3 3
      jeecg-boot-module-system/src/main/resources/application-prod.yml
  6. 1 1
      jeecg-boot-module-system/src/main/resources/application-prod2.yml
  7. 2 2
      jeecg-boot-module-system/src/main/resources/application-test.yml
  8. 1 1
      jeecg-boot-module-system/src/main/resources/application-wps.yml
  9. 16 74
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  10. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml
  11. 4 4
      module-common/src/main/java/cn/com/ctop/common/module/utils/CorpWexinUtils.java
  12. 467 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/ByteDanceReportAccountDailyDTOEntity.java
  13. 26 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceVideoReportCleanJob.java
  14. 1 1
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyCreativeReportLoadJob.java
  15. 39 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  16. 263 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/CollectionSlogansController.java
  17. 77 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/CollectionSlogans.java
  18. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouCreative.java
  19. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouProgramCreative.java
  20. 15 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/CollectionSlogansMapper.java
  21. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/CollectionSlogansMapper.xml
  22. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCreativeMapper.xml
  23. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  24. 18 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/ICollectionSlogansService.java
  25. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  26. 128 27
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  27. 69 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/CollectionSlogansServiceImpl.java
  28. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouCreativeServiceImpl.java
  29. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  30. 9 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java
  31. 24 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  32. 8 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouProgramCreativeServiceImpl.java
  33. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml
  34. 47 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java
  35. 2 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/ByteDanceVideoReportDaily.java
  36. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/ByteDanceVideoReportDailyMapper.java
  37. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceAccountReportMapper.java
  38. 401 10
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/ByteDanceVideoReportDailyMapper.xml
  39. 45 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAccountReportMapper.xml
  40. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceAccountReportService.java
  41. 15 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ByteDanceVideoReportDailyServiceImpl.java
  42. 29 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java
  43. 4 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java
  44. 5 0
      pom.xml

+ 0 - 7
jeecg-boot-module-system/pom.xml

@@ -161,13 +161,6 @@
             <artifactId>poi-ooxml-schemas</artifactId>
             <version>3.17</version>
         </dependency>
-
-        <dependency>
-            <groupId>com.alibaba</groupId>
-            <artifactId>easyexcel</artifactId>
-            <version>1.1.2-beat1</version>
-        </dependency>
-
         <dependency>
             <groupId>com.bstek.ureport</groupId>
             <artifactId>ureport2-core</artifactId>

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

@@ -61,7 +61,7 @@ public class KuaishouDailyCreativeReportLoadJob implements Job {
                                     @Override
                                     public void run() {
                                         try {
-                                            kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate, campaignIds);
+                                            kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate, campaignIds, null);
                                         } catch (Exception e) {
                                             log.info("获取创意日报失败,accountId:{}", token.getAccountId());
                                         }

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

@@ -122,7 +122,7 @@ public class SysBaseApiImpl implements ISysBaseApi {
 	}
 
 	@Override
-	@Cacheable(cacheNames=CacheConstant.SYS_USERS_CACHE, key="#username")
+	// @Cacheable(cacheNames=CacheConstant.SYS_USERS_CACHE, key="#username")
 	public LoginUser getUserByName(String username) {
 		if(oConvertUtils.isEmpty(username)) {
 			return null;

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

@@ -1,5 +1,5 @@
 server:
-  port: 8080
+  port: 8805
   tomcat:
     max-swallow-size: -1
   servlet:
@@ -135,9 +135,9 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://139.186.31.213:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
+          url: jdbc:mysql://139.186.27.96:3306/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
-          password: hcst2020
+          password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver
           # 多数据源配置
           #multi-datasource1:

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

@@ -1,5 +1,5 @@
 server:
-  port: 8804
+  port: 8805
   ip: 39.97.120.42
   servlet:
     context-path: /jeecg-boot
@@ -67,7 +67,7 @@ spring:
   autoconfigure:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
-    url: jdbc:mysql://172.30.0.4:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    url: jdbc:mysql://139.186.27.96:3306/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
     username: hcst
     password: test@20190531
     driver-class-name: com.mysql.jdbc.Driver
@@ -106,7 +106,7 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://172.30.0.4:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          url: jdbc:mysql://139.186.27.96:3306/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
           username: hcst
           password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver

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

@@ -59,7 +59,7 @@ spring:
   autoconfigure:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
-    url: jdbc:mysql://172.30.0.4:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    url: jdbc:mysql://139.186.27.96:3306/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
     username: hcst
     password: test@20190531
     driver-class-name: com.mysql.jdbc.Driver

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

@@ -97,9 +97,9 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://139.186.31.213:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true
+          url: jdbc:mysql://139.186.27.96:3306/jiaoyang?characterEncoding=UTF-8&useUnicode=true
           username: hcst
-          password: hcst2020
+          password: test@20190531
           driver-class-name: com.mysql.jdbc.Driver
   #redis 配置
   redis:

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

@@ -56,7 +56,7 @@ spring:
   autoconfigure:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
-    url: jdbc:mysql://139.186.27.96:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+    url: jdbc:mysql://139.186.27.96:3306/jiaoyang?characterEncoding=UTF-8&useUnicode=true&useSSL=false
 #    url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
     username: hcst
     password: test@20190531

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

@@ -8,14 +8,11 @@ import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
 import cn.com.ctop.common.module.service.*;
+import cn.com.ctop.common.module.utils.CorpWexinUtils;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
-import cn.com.ctop.kuaishou.modules.batch.service.*;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
-import cn.com.ctop.oa.modules.service.IWechatCheckinDataService;
-import cn.com.ctop.oa.modules.service.IWechatDepartmentService;
-import cn.com.ctop.oa.modules.service.IWechatNoListService;
-import cn.com.ctop.oa.modules.service.IWechatUserListService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
@@ -31,7 +28,6 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import java.text.ParseException;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -51,65 +47,16 @@ public class SampleTest {
     @Autowired
     private IReportService reportService;
     @Autowired
-    private IUserAllocationService userAllocationService;
-    @Autowired
     private IByteDanceAdvertiserDataService advertiserDataService;
     @Autowired
     private IKuaiShouHistoryReportTaskService kuaiShouHistoryReportTaskService;
-    @Autowired
-    private IKuaiShouDailyReportTaskService dailyReportTaskService;
 
     @Autowired
-    private IWechatDepartmentService wechatDepartment;
-    @Autowired
-    private IKuaishouInterfaceService kuaishouInterfaceService;
-    @Autowired
-    private IWechatUserListService wechatUserInfoService;
-    @Autowired
-    private IWechatCheckinDataService wechatCheckinDataService;
-    @Autowired
-    private IWechatNoListService wechatNoListService;
-    @Autowired
     private ICtopOauthTokenService tokenService;
-    @Autowired
-    private IKuaishouRealTimeDataService realTimeDataService;
-
-    @Autowired
-    private IKuaiShouCreativeService creativeService;
-    @Autowired
-    private IMessageTemplate messageTemplate;
-
-    @Autowired
-    private ISendMessageService sendMessageService;
-
-    @Autowired
-    private IKuaiShouOverRunSendMessageService overRunSendMessageService;
-
-
-    @Test
-    public void getDepartment() throws ParseException {
-
-      /*  String message = messageTemplate.getCreativeOverRunMessage(23212L, 2000, "hahah");
-        //  LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        sendMessageService.sendMessage("14c3cd
-        5e5e434211a9bb5e8f9d8a335d", message);*/
-
-        overRunSendMessageService.creativeOverRunSendMessage(23212L);
-
-
-    }
-
 
     @Test
     public void loadBytedanceCreativeData() {
-        QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("media_id", 2);
-        List<CtopOauthToken> list = oauthTokenService.list(queryWrapper);
-        for (CtopOauthToken token : list) {
-            kuaiShouHistoryReportTaskService.createTask(token.getAccountId(), token.getAccessToken(), "2020-09-20", "2020-09-20", "daily");
-
-        }
-
+        CorpWexinUtils.sendMessageByWeChatId("ZhaoWang","测试企业微信发送消息");
     }
 
     @Test
@@ -238,13 +185,14 @@ public class SampleTest {
 
     @Test
     public void loadBytedanceData(){
-        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
-        for (CtopOauthToken token:tokens) {
-            for(int i=0;i<20;i++){
-                Date getDate = DateUtils.addDay(new Date(), -i);
-                String date = DateUtils.formatDate(getDate);
-                bytedanceReportService.bytedanceMaterialReport(token, date, date);
-//            videoReportDailyService.videoInfoList(date, date);
+        String strings = "1672894840372238_1674183267750990_1673076203257870_1650079154438157_1670286873337870_1648709018451972_1661556811389966_1676540488471559";
+        String[] tokens = strings.split("_");
+        for (int i=0;i<tokens.length;i++) {
+            Long accountId = Long.parseLong(tokens[i]);
+            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+            for(int j=10;j<110;j++){
+                Date getDate = DateUtils.addDay(new Date(), -j);
+                reportService.getAdvertiserReport(token, getDate, getDate,CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
             }
 
         }
@@ -252,17 +200,11 @@ public class SampleTest {
 
     @Test
     public void loaddata(){
-//        List<UserAllocation> allocations = allocationService.getByParams(643L,null,0);
-//        for (UserAllocation allocation:allocations) {
-            for(int i=0;i<50;i++){
-//                CtopOauthToken token = tokenService.getTokenByAccountId(allocation.getAccountId());
-                Date getDate = DateUtils.addDay(new Date(), -i);
-                String date = DateUtils.formatDate(getDate);
-//                bytedanceReportService.bytedanceMaterialReport(token, date, date);
-                videoReportDailyService.videoInfoList(date, date);
-            }
-
-//        }
+        for(int i=0;i<30;i++){
+            Date getDate = DateUtils.addDay(new Date(), -i);
+            String date = DateUtils.formatDate(getDate);
+            videoReportDailyService.videoInfoList(date, date);
+        }
     }
 
     @Autowired

+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml

@@ -119,7 +119,9 @@
         matInfo.project_id,
         matInfo.id
         from ctop_material_info matInfo
-        left join ctop_material_tag_info tagInfo on tagInfo.code = matInfo.code
+        <if test="tagCode!=null">
+            left join ctop_material_tag_info tagInfo on tagInfo.code = matInfo.code
+        </if>
         where 1=1
         <if test="tagCode!=null">
             and tagInfo.tag_code like concat(#{tagCode},'%')

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

@@ -20,11 +20,11 @@ public class CorpWexinUtils {
 
     public static void initService() {
         val configStorage = new WxCpDefaultConfigImpl();
-        configStorage.setCorpId("ww24b8a47826f5875f");
+        configStorage.setCorpId("wwef2e51064c0ac897");
         configStorage.setAgentId(1000002);
-        configStorage.setCorpSecret("MJIlySADGPlgvADnkFQPUpfZD4yV-4WN6066OgNnb0s");
-        configStorage.setToken("hcst2019");
-        configStorage.setAesKey("hcst2019");
+        configStorage.setCorpSecret("ieoVDAIurCOMdLrvktyQNCqWvTPqdphmXSFdk57NZ1k");
+/*        configStorage.setToken("hcst2019");
+        configStorage.setAesKey("hcst2019");*/
         wxCpService = new WxCpServiceImpl();
         wxCpService.setWxCpConfigStorage(configStorage);
     }

File diff suppressed because it is too large
+ 467 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/ByteDanceReportAccountDailyDTOEntity.java


+ 26 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceVideoReportCleanJob.java

@@ -0,0 +1,26 @@
+package cn.com.ctop.job.bytedance.handler;
+
+import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+import com.xxl.job.core.biz.model.ReturnT;
+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.Date;
+
+@Component
+public class BytedanceVideoReportCleanJob {
+    @Autowired
+    private IByteDanceVideoReportDailyService videoReportDailyService;
+
+    @XxlJob("bytedanceVideoReportCleanJob")
+    public ReturnT<String> execute(String param) throws Exception {
+        for(int i=0;i<2;i++){
+            Date getDate = DateUtils.addDay(new Date(), -i);
+            String date = DateUtils.formatDate(getDate);
+            videoReportDailyService.videoInfoList(date, date);
+        }
+        return ReturnT.SUCCESS;
+    }
+}

+ 1 - 1
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyCreativeReportLoadJob.java

@@ -52,7 +52,7 @@ public class KuaishouDailyCreativeReportLoadJob {
             }
             List<JSONArray> campaigns = campaignService.getJsonArrByAccount(token.getAccountId(), 50);
             if (null != campaigns && !campaigns.isEmpty()) {
-                campaigns.forEach(campaign -> executorService.submit(() -> kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate, campaign)));
+                campaigns.forEach(campaign -> executorService.submit(() -> kuaishouInterfaceService.getAdvertiserCreativeReportDaily(token, getDate, getDate, campaign, null)));
             }
         });
         return ReturnT.SUCCESS;

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

@@ -2325,6 +2325,11 @@ public class BatchController {
     }
 
 
+    /**
+     * 贴纸类型
+     * @param accountId
+     * @return
+     */
     @GetMapping(value = "/getCreativeWordStyles")
     public Result<JSONArray> getCreativeWordStyles(Long accountId) {
         Result<JSONArray> result = new Result<>();
@@ -2349,4 +2354,38 @@ public class BatchController {
 
         return result;
     }
+
+    /**
+     * 创意分类
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getCreativeCategory")
+    public Result<JSONArray> getCreativeCategory(Long accountId) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("入参为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+
+            JSONArray data = batchService.getCreativeCategory(accountId, oauthToken.getAccessToken());
+            result.setSuccess(true);
+            result.setResult(data);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setResult(null);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+
+
 }

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

@@ -0,0 +1,263 @@
+package cn.com.ctop.kuaishou.modules.batch.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans;
+import cn.com.ctop.kuaishou.modules.batch.service.ICollectionSlogansService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 收藏的广告语
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-12
+ */
+@Slf4j
+@Api(tags = "收藏的广告语")
+@RestController
+@RequestMapping("/kuaishou/collectionSlogans")
+public class CollectionSlogansController {
+    @Autowired
+    private ICollectionSlogansService CollectionSlogansService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param CollectionSlogans
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-分页列表查询")
+    @ApiOperation(value = "收藏的广告语-分页列表查询", notes = "收藏的广告语-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<CollectionSlogans>> queryPageList(CollectionSlogans CollectionSlogans,
+                                                          @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                          HttpServletRequest req) {
+        Result<IPage<cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans>> result = new Result<>();
+        QueryWrapper<CollectionSlogans> queryWrapper = QueryGenerator.initQueryWrapper(CollectionSlogans, req.getParameterMap());
+        Page<CollectionSlogans> page = new Page<CollectionSlogans>(pageNo, pageSize);
+        IPage<CollectionSlogans> pageList = CollectionSlogansService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
+     * 添加
+     *
+     * @param CollectionSlogans
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-添加")
+    @ApiOperation(value = "收藏的广告语-添加", notes = "收藏的广告语-添加")
+    @PostMapping(value = "/add")
+    public Result<JSONObject> add(@RequestBody JSONObject requestJson) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if(Check.isNull(requestJson.getJSONArray("coverSlogansList"))&&Check.isNull(requestJson.getJSONArray("captionsList"))){
+                result.setMessage("请输入广告语");
+                result.setSuccess(false);
+                return result;
+            }
+            CollectionSlogansService.saveCollectionSlogans(requestJson);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param CollectionSlogans
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-编辑")
+    @ApiOperation(value = "收藏的广告语-编辑", notes = "收藏的广告语-编辑")
+    @PutMapping(value = "/edit")
+    public Result<CollectionSlogans> edit(@RequestBody CollectionSlogans CollectionSlogans) {
+        Result<CollectionSlogans> result = new Result<CollectionSlogans>();
+        CollectionSlogans CollectionSlogansEntity = CollectionSlogansService.getById(CollectionSlogans.getId());
+        if (CollectionSlogansEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = CollectionSlogansService.updateById(CollectionSlogans);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-通过id删除")
+    @ApiOperation(value = "收藏的广告语-通过id删除", notes = "收藏的广告语-通过id删除")
+    @GetMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            CollectionSlogansService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-批量删除")
+    @ApiOperation(value = "收藏的广告语-批量删除", notes = "收藏的广告语-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<CollectionSlogans> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<CollectionSlogans> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.CollectionSlogansService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "收藏的广告语-通过userId查询")
+    @ApiOperation(value = "收藏的广告语-通过id查询", notes = "收藏的广告语-通过id查询")
+    @GetMapping(value = "/getByUserId")
+    public Result<JSONObject> queryById(String userId,String accountId,String type) {
+        Result<JSONObject> result = new Result<>();
+        JSONObject CollectionSlogans = CollectionSlogansService.getByUserId(userId,accountId,type);
+        if (CollectionSlogans == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(CollectionSlogans);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<CollectionSlogans> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                CollectionSlogans CollectionSlogans = JSON.parseObject(deString, CollectionSlogans.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(CollectionSlogans, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<CollectionSlogans> pageList = CollectionSlogansService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "收藏的广告语列表");
+        mv.addObject(NormalExcelConstants.CLASS, CollectionSlogans.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("收藏的广告语列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<CollectionSlogans> listCollectionSloganss = ExcelImportUtil.importExcel(file.getInputStream(), CollectionSlogans.class, params);
+                CollectionSlogansService.saveBatch(listCollectionSloganss);
+                return Result.ok("文件导入成功!数据行数:" + listCollectionSloganss.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

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

@@ -0,0 +1,77 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * 收藏的广告语
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-12
+ */
+@Data
+@TableName("ctop_kuaishou_slogans_collection")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_slogans_collection对象", description = "收藏的广告语")
+public class CollectionSlogans {
+
+    /**
+     * 主键
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "主键")
+    private Long id;
+    /**
+     * 类型1-封面广告语;2-广告语
+     */
+    @Excel(name = "类型1-封面广告语;2-广告语", width = 15)
+    @ApiModelProperty(value = "类型1-封面广告语;2-广告语")
+    private String type;
+    /**
+     * value
+     */
+    @Excel(name = "value", width = 15)
+    @ApiModelProperty(value = "value")
+    private String value;
+    /**
+     * 人员ID
+     */
+    @Excel(name = "人员ID", width = 15)
+    @ApiModelProperty(value = "人员ID")
+    private String userId;
+    /**
+     * 账户ID
+     */
+    @Excel(name = "账户ID", width = 15)
+    @ApiModelProperty(value = "账户ID")
+    private Long accountId;
+    /**
+     * createTime
+     */
+    @Excel(name = "createTime", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "createTime")
+    private Date createTime;
+    /**
+     * updateTime
+     */
+    @Excel(name = "updateTime", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "updateTime")
+    private Date updateTime;
+}

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

@@ -58,7 +58,6 @@ public class KuaiShouCreative {
     @ApiModelProperty(value = "广告创意ID")
     private Long creativeId;
 
-
     /**
      * 素材类型
      */
@@ -221,4 +220,8 @@ public class KuaiShouCreative {
 
 
     private String photoIds;
+
+    private Integer creativeCategory;
+    private String creativeTag;
+
 }

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

@@ -135,6 +135,10 @@ public class KuaishouProgramCreative {
     @Excel(name = "程序化创意状态描述", width = 15)
     @ApiModelProperty(value = "程序化创意状态描述")
     private String viewStatusReason;
+
+    private Integer creativeCategory;
+    private String creativeTag;
+
     /**
      * 创意创建时间
      */

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

@@ -0,0 +1,15 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 收藏的广告语
+ *
+ * @author: jeecg-boot
+ * @date: 2020-10-12
+ * @cersion: V1.0
+ */
+public interface CollectionSlogansMapper extends BaseMapper<CollectionSlogans> {
+
+}

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/CollectionSlogansMapper.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.cn.com.ctop.kuaishou.modules.batch.controller.mapper.CollectionSlogansMapper">
+
+</mapper>

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

@@ -37,6 +37,8 @@
         actionbar_click_url,
         creative_create_time,
         creative_update_time,
+        creative_category,
+        creative_tag,
         create_time,
         update_time)
         values
@@ -76,6 +78,8 @@
             #{creative.actionbarClickUrl},
             #{creative.creativeCreateTime},
             #{creative.creativeUpdateTime},
+            #{creative.creativeCategory},
+            #{creative.creativeTag},
             #{creative.createTime},
             #{creative.updateTime})
         </foreach>

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

@@ -158,4 +158,12 @@ public interface IBatchService {
      * @return
      */
     JSONArray getCreativeWordStyles(Long accountId, String accessToken);
+
+    /**
+     * 获取创意分类
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    JSONArray getCreativeCategory(Long accountId, String accessToken);
 }

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 收藏的广告语
+ * @Author: jeecg-boot
+ * @Date: 2020-10-12
+ * @Version: V1.0
+ */
+public interface ICollectionSlogansService extends IService<CollectionSlogans> {
+
+    void saveCollectionSlogans(JSONObject requestJson);
+
+    JSONObject getByUserId(String userId, String accountId,String type);
+}

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

@@ -340,7 +340,7 @@ public interface IKuaishouInterfaceService {
      * @param endDate
      * @param campaignIds
      */
-    void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds);
+    void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds, JSONArray creativeIds);
 
     /**
      * 获取广告主时报

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

@@ -1072,7 +1072,13 @@ public class BatchServiceImpl implements IBatchService {
                 creativeJson.put("action_bar_text", action_bar_text);
                 creativeJson.put("description", description.trim());
                 creativeJson.put("creative_name", name);
-                //  creativeJson.put("click_track_url", click_track_url);
+                String imageToken = null;
+                if (!Check.isNull(creative.getStickerTitle()) && !Check.isNull(creative.getOverlayType())) {
+                    imageToken = creative.getOverlayBgImageToken();
+                } else {
+                    imageToken = creative.getImageToken();
+                }
+
 
                 //封面广告语标题
                 if (!Check.isNull(creative.getStickerTitle())) {
@@ -1083,6 +1089,7 @@ public class BatchServiceImpl implements IBatchService {
                     creativeJson.put("overlay_type", creative.getOverlayType());
                 }
 
+
                 // 第三方有效播放监测链接
                 if (!Check.isNull(creative.getAdPhotoPlayedT3sUrl())) {
                     creativeJson.put("ad_photo_played_t3s_url", creative.getAdPhotoPlayedT3sUrl());
@@ -1092,7 +1099,13 @@ public class BatchServiceImpl implements IBatchService {
                     creativeJson.put("actionbar_click_url", creative.getActionbarClickUrl());
                 }
 
-
+                /**
+                 * 创意标签
+                 */
+                if (!Check.isNull(creative.getCreativeCategory()) && !Check.isNull(!Check.isNull(creative.getCreativeTag()))) {
+                    creativeJson.put("creative_category", creative.getCreativeCategory());
+                    creativeJson.put("creative_tag", JSONArray.parseArray(creative.getCreativeTag()));
+                }
                 if (!Check.isNull(otherJson)) {
                     Boolean isUpdate = otherJson.getBoolean("isUpdate"); // 是否修改落地页
                     if (isUpdate) {
@@ -1117,8 +1130,7 @@ public class BatchServiceImpl implements IBatchService {
                             } else {
                                 String photo_id = creative.getPhotoId();
                                 creativeJson.put("photo_id", photo_id);
-                                String image = creative.getImageToken();
-                                creativeJson.put("image_token", image);
+                                creativeJson.put("image_token", imageToken);
                                 creativeJson.put("click_track_url", clickTrackUrl);
 
                             }
@@ -1137,8 +1149,7 @@ public class BatchServiceImpl implements IBatchService {
                             } else {
                                 String photo_id = creative.getPhotoId();
                                 creativeJson.put("photo_id", photo_id);
-                                String image = creative.getImageToken();
-                                creativeJson.put("image_token", image);
+                                creativeJson.put("image_token", imageToken);
                                 if (!Check.isNull(click_track_url)) {
                                     creativeJson.put("click_track_url", click_track_url);
                                 }
@@ -1159,8 +1170,8 @@ public class BatchServiceImpl implements IBatchService {
                         } else {
                             String photo_id = creative.getPhotoId();
                             creativeJson.put("photo_id", photo_id);
-                            String image = creative.getImageToken();
-                            creativeJson.put("image_token", image);
+                            creativeJson.put("image_token", imageToken);
+
                             if (!Check.isNull(click_track_url)) {
                                 creativeJson.put("click_track_url", click_track_url);
                             }
@@ -1186,8 +1197,7 @@ public class BatchServiceImpl implements IBatchService {
                     } else {
                         String photo_id = creative.getPhotoId();
                         creativeJson.put("photo_id", photo_id);
-                        String image = creative.getImageToken();
-                        creativeJson.put("image_token", image);
+                        creativeJson.put("image_token", imageToken);
                         if (!Check.isNull(click_track_url)) {
                             creativeJson.put("click_track_url", click_track_url);
                         }
@@ -1272,6 +1282,9 @@ public class BatchServiceImpl implements IBatchService {
         String action_bar_text = requestJson.getString("actionBarText");
         String click_track_url = requestJson.getString("clickTrackUrl");
         String site_id = requestJson.getString("siteId");
+        Integer creativeCategory = requestJson.getInteger("creativeCategory");// 创意分类
+        JSONArray creativeTag = requestJson.getJSONArray("creativeTag");
+
         JSONObject returnJson = new JSONObject();
         JSONArray successArr = new JSONArray();
         JSONArray failArr = new JSONArray();
@@ -1285,8 +1298,8 @@ public class BatchServiceImpl implements IBatchService {
 
                 String creativeMaterialType = dataJson.getString("creativeMaterialType");
                 String shortSlogan = dataJson.getString("shortSlogan");
-
-
+                String overlayType = dataJson.getString("overlayType");
+                String stickerTitle = dataJson.getString("stickerTitle");
                 if (!Check.isNull(dataJsons)) {
                     String description = dataJson.getString("description");
                     String photo_id = dataJson.getString("photoId");
@@ -1309,11 +1322,22 @@ public class BatchServiceImpl implements IBatchService {
                                     creativeJson.put("creative_material_type", creativeMaterialType);
                                 }
 
+                                if (!Check.isNull(overlayType)) {
+                                    creativeJson.put("overlay_type", overlayType);
+                                }
+                                if (!Check.isNull(stickerTitle)) {
+                                    creativeJson.put("sticker_title", stickerTitle);
+                                }
+
+                                if (!Check.isNull(creativeCategory) && !Check.isNull(creativeTag)) {
+                                    creativeJson.put("creative_category", creativeCategory);
+                                    creativeJson.put("creative_tag", creativeTag);
+                                }
+
                                 if (creativeMaterialType.equals("4")) {
                                     if (!Check.isNull("shortSlogan")) {
                                         creativeJson.put("short_slogan", shortSlogan);
                                     }
-
                                 }
                                 String imageToken = null;
                                 String signature = imageJson.getString("signature");
@@ -1789,27 +1813,104 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONArray getCreativeWordStyles(Long accountId, String accessToken) {
-        String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/creative_word/styles";
-        Map<String, String> headers = new HashMap<String, String>();
-        headers.put("Content-Type", "application/json");
-        headers.put("Access-Token", accessToken);
-        Map<String, Object> param = new HashMap<String, Object>();
-        param.put("advertiser_id", accountId);
-
-        String result = HttpUtils.httpPostRequest(url, param, headers);
-        JSONObject resultJson = JSONObject.parseObject(result);
-        log.info("获取贴纸样式,accountId:{},data:{}", accountId, resultJson);
-        if (!Check.isNull(resultJson)) {
-            Integer code = resultJson.getInteger("code");
-            if (code == 0) {
-                return resultJson.getJSONArray("data");
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/tool/creative_word/styles";
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", accessToken);
+            Map<String, Object> param = new HashMap<String, Object>();
+            param.put("advertiser_id", accountId);
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    return resultJson.getJSONArray("data");
+                }
             }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+    /**
+     * 获取创意分类
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    @Override
+    public JSONArray getCreativeCategory(Long accountId, String accessToken) {
 
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/creative/creative_category/list";
+            Map<String, String> headers = new HashMap<String, String>();
+            headers.put("Content-Type", "application/json");
+            headers.put("Access-Token", accessToken);
+            Map<String, Object> param = new HashMap<String, Object>();
+            param.put("advertiser_id", accountId);
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = resultJson.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        JSONArray details = data.getJSONArray("details");
+                        if (!Check.isNull(details)) {
+                            JSONArray returnArr = new JSONArray();
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject firstJson = details.getJSONObject(i);
+
+                                Integer parent_id = firstJson.getInteger("parent_id");
+                                if (0 == parent_id) {
+                                    JSONArray LevelArr = getSecond(firstJson.getString("category_id"), details);
+                                    firstJson.put("child", LevelArr);
+                                    returnArr.add(firstJson);
+                                }
+                            }
+                            return returnArr;
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
         return null;
     }
 
 
+    private JSONArray getSecond(String categoryId, JSONArray details) {
+
+        JSONArray secondArr = new JSONArray();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject secondJson = details.getJSONObject(i);
+            if (categoryId.equals(secondJson.getString("parent_id"))) {
+                JSONArray thirdArr = getThird(secondJson.getString("category_id"), details);
+                secondJson.put("child", thirdArr);
+                secondArr.add(secondJson);
+            }
+        }
+        return secondArr;
+    }
+
+
+    private JSONArray getThird(String categoryId, JSONArray details) {
+        JSONArray thirdArr = new JSONArray();
+        for (int i = 0; i < details.size(); i++) {
+            JSONObject thirdJson = details.getJSONObject(i);
+            String parent_id = thirdJson.getString("parent_id");
+            if (categoryId.equals(parent_id)) {
+                thirdArr.add(thirdJson);
+            }
+
+        }
+        return thirdArr;
+    }
 }
 
 

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

@@ -0,0 +1,69 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.entity.CollectionSlogans;
+import cn.com.ctop.kuaishou.modules.batch.mapper.CollectionSlogansMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.ICollectionSlogansService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+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;
+
+/**
+ * 收藏的广告语
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-10-12
+ */
+@Service
+public class CollectionSlogansServiceImpl extends ServiceImpl<CollectionSlogansMapper, CollectionSlogans> implements ICollectionSlogansService {
+
+    @Autowired
+    CollectionSlogansMapper collectionSlogansMapper;
+
+    @Override
+    public void saveCollectionSlogans(JSONObject requestJson) {
+        CollectionSlogans co = new CollectionSlogans();
+        String userId = requestJson.getString("userId");
+        Long accountId = requestJson.getLong("accountId");
+        if (!Check.isNull(requestJson.getJSONArray("coverSlogansList"))) {
+            //封面广告语
+            co.setType(NoEn.NO1.valueStr());
+            co.setValue(requestJson.getJSONArray("coverSlogansList").toString());
+        }
+        if (!Check.isNull(requestJson.getJSONArray("captionsList"))) {
+            co.setType(NoEn.NO2.valueStr());
+            co.setValue(requestJson.getJSONArray("captionsList").toString());
+        }
+        co.setAccountId(accountId);
+        co.setUserId(userId);
+        JSONObject slogansJson = getByUserId(userId, accountId.toString(), co.getType());
+        if (!Check.isNull(slogansJson)) {
+            QueryWrapper<CollectionSlogans> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("id", slogansJson.getInteger("id"));
+            collectionSlogansMapper.update(co, queryWrapper);
+        } else {
+            collectionSlogansMapper.insert(co);
+        }
+    }
+
+    @Override
+    public JSONObject getByUserId(String userId, String accountId, String type) {
+        QueryWrapper<CollectionSlogans> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.eq("user_id", userId);
+        queryWrapper.eq("type", type);
+        queryWrapper.last("limit 1");
+        CollectionSlogans slogans = collectionSlogansMapper.selectOne(queryWrapper);
+        JSONObject resultJson = null;
+        if (!Check.isNull(slogans)) {
+            resultJson = (JSONObject) JSONObject.toJSON(slogans);
+            resultJson.put("value", JSONArray.parseArray(slogans.getValue()));
+        }
+        return resultJson;
+    }
+}

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

@@ -149,6 +149,10 @@ public class KuaiShouCreativeServiceImpl extends ServiceImpl<KuaiShouCreativeMap
                     creative.setDescription(displayInfoJson.getString("description"));
                     creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
                 }
+                creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                    creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                }
                 creative.setCreateTime(new java.util.Date());
                 creative.setUpdateTime(new java.util.Date());
                 creative.setSiteId(detailJson.getLong("site_id"));

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

@@ -222,6 +222,10 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                         creative.setDescription(displayInfoJson.getString("description"));
                         creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
                     }
+                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                    }
                     creative.setCreateTime(new Date());
                     creative.setUpdateTime(new Date());
                     creative.setSiteId(detailJson.getLong("site_id"));

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

@@ -273,25 +273,25 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
     private void getHistoryTypeList() {
 
         historyTypeList = new ArrayList<>();
-       /* historyTypeList.add(5);
+        historyTypeList.add(5);
         historyTypeList.add(1);
         historyTypeList.add(2);
         historyTypeList.add(3);
         historyTypeList.add(10);
-        historyTypeList.add(4);*/
-        historyTypeList.add(7);
+        historyTypeList.add(4);
+     //   historyTypeList.add(7);
 
 
     }
 
     private void getDailyTypeList() {
         dailyTypeList = new ArrayList<>();
-//        dailyTypeList.add(2);
-//        dailyTypeList.add(3);
-//        dailyTypeList.add(4);
-//        dailyTypeList.add(5);
-//        dailyTypeList.add(10);
-        historyTypeList.add(7);
+        dailyTypeList.add(2);
+        dailyTypeList.add(3);
+        dailyTypeList.add(4);
+        dailyTypeList.add(5);
+        dailyTypeList.add(10);
+//        historyTypeList.add(7);
     }
 
 

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

@@ -657,11 +657,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
-    public void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds) {
-        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, 1);
+    public void getAdvertiserCreativeReportDaily(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds, JSONArray creativeIds) {
+        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, creativeIds, 1);
     }
 
-    private void getAdvertiserCreativeReportDailyByPage(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds, int page) {
+    private void getAdvertiserCreativeReportDailyByPage(CtopOauthToken token, Date startDate, Date endDate, JSONArray campaignIds, JSONArray creativeIds, int page) {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_REPORT;
         Map<String, String> headers = new HashMap<String, String>();
         headers.put("Content-Type", "application/json");
@@ -677,7 +677,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             param.put("campaign_ids", campaignIds);
 
         }
+        if (!Check.isNull(creativeIds) && creativeIds.size() > 0) {
+            param.put("creative_ids", creativeIds);
 
+        }
         param.put("advertiser_id", token.getAccountId());
         param.put("temporal_granularity", "DAILY");
         param.put("page_size", 1000);
@@ -714,7 +717,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             dailyCreativeStatisticService.saveOrUpdate(statistic);
             dailyCreativeService.saveOrUpdate(creative);
         }
-        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, page + 1);
+        getAdvertiserCreativeReportDailyByPage(token, startDate, endDate, campaignIds, creativeIds, page + 1);
     }
 
     private KuaishouReportDailyCreativeStatistic setDailyStatistic(KuaishouReportDailyCreative creative, CtopOauthToken token) {
@@ -1336,7 +1339,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     if (!Check.isNull(detailJson.getJSONArray("material_url"))) {
                         creative.setMaterialUrl(detailJson.getJSONArray("material_url").toJSONString());
                     }
-
                     if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
                         creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
                     }
@@ -1359,6 +1361,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
                     creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
                     creative.setShortSlogan(detailJson.getString("short_slogan"));
+                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                    }
                     creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
                     if (!Check.isNull(displayInfoJson)) {
@@ -1542,6 +1548,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     creative.setShortSlogan(detailJson.getString("short_slogan"));
                                     creative.setActionbarClickUrl(detailJson.getString("actionbar_click_url"));
                                     JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
+
+                                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                                    }
+
                                     if (!Check.isNull(displayInfoJson)) {
                                         creative.setDescription(displayInfoJson.getString("description"));
                                         creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
@@ -2694,7 +2706,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
 
             String endDate = DateUtils.getNowDate("yyyy-MM-dd");
-            String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", endDate, -1);
+            String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", endDate, -2);
             json.put("start_date", startDate);
             json.put("end_date", endDate);
             String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
@@ -3066,6 +3078,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                     if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
                                         creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
                                     }
+
+                                    creative.setCreativeCategory(detailJson.getInteger("creative_category"));
+                                    if (!Check.isNull(detailJson.getJSONArray("creative_tag"))) {
+                                        creative.setCreativeTag(detailJson.getJSONArray("creative_tag").toJSONString());
+                                    }
+
                                     creative.setStatus(detailJson.getInteger("status"));
                                     creative.setPutStatus(detailJson.getInteger("put_status"));
                                     creative.setCreateChannel(detailJson.getInteger("create_channel"));

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

@@ -139,6 +139,13 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
                 pramsJson.put("cover_slogans", requestJson.getJSONArray("coverSlogans"));
             }
 
+            Integer creativeCategory = requestJson.getInteger("creativeCategory");
+            JSONArray creativeTag = requestJson.getJSONArray("creativeTag");
+
+            if (!Check.isNull(creativeCategory) && !Check.isNull(creativeTag)) {
+                pramsJson.put("creative_category", creativeCategory);
+                pramsJson.put("creative_tag", creativeTag);
+            }
             pramsJson.put("action_bar", requestJson.getString("actionBarText"));
             pramsJson.put("captions", requestJson.getJSONArray("captions"));
             if (!Check.isNull(requestJson.getString("clickUrl"))) {
@@ -151,8 +158,6 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
             headers.put("Content-Type", "application/json");
             headers.put("Access-Token", oauthToken.getAccessToken());
             String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.PROGRAM_CREATE;
-
-
             JSONArray coverImageTokens = requestJson.getJSONArray("coverImageTokens");
             JSONArray cover_image_tokens = new JSONArray();
             requestJson.remove(coverImageTokens);
@@ -197,7 +202,7 @@ public class KuaishouProgramCreativeServiceImpl extends ServiceImpl<KuaishouProg
                     returnJson.put("isTrueOrFalse", true);
                     returnJson.put("message", "创建成功");
                 } else {
-                    log.error("创建失败:入参:{}",pramsJson);
+                    log.error("创建失败:入参:{}", pramsJson);
                     returnJson.put("isTrueOrFalse", false);
                     returnJson.put("message", jsonObject.getString("message"));
                 }

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyAccountMapper.xml

@@ -702,7 +702,7 @@
                  open="(" close=")">
             #{item}
         </foreach>
-        group by b.project_id
+        group by b.project_id  order by sum(a.charge) desc
     </select>
 
     <!-- 计划汇总 -->

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

@@ -2,12 +2,18 @@ package cn.com.ctop.toutiao.modules.report.controller;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.common.module.vo.ByteDanceReportAccountDailyDTOEntity;
+import cn.com.ctop.common.module.vo.SheetInfoVo;
 import cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO;
 import cn.com.ctop.toutiao.modules.report.DTO.BytedanceInfoDTO;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceAccountReportService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
+import com.alibaba.excel.EasyExcelFactory;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.metadata.Sheet;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
@@ -17,7 +23,11 @@ import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
@@ -452,4 +462,41 @@ public class BytedanceReportController {
         return result;
     }
 
+
+    /**
+     * 导出报表
+     *
+     * @return
+     */
+    @RequestMapping(value = "/exportBytedanceSaleProjectInfo")
+    @ResponseBody
+    public void exportXxl(@RequestBody BytedanceInfoDTO dto,HttpServletResponse response) throws IOException {
+        List<SheetInfoVo> sheets = new ArrayList<>();
+        if(dto == null || dto.getStartDate() ==null || dto.getEndDate() == null){
+            Date getDate = DateUtils.addDay(new Date(), -1);
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+            String dateString = dateFormat.format(getDate);
+
+            dto = new BytedanceInfoDTO();
+            dto.setStartDate(dateString);
+            dto.setEndDate(dateString);
+        }
+
+        if(dto.getPageSize() == 0 ){
+            dto.setPageSize(1000000000);
+        }
+        //查询总的消耗信息
+        SheetInfoVo totalSheetVo = bytedanceAccountReportService.getBytedanceSaleProjectInfoSheetVO(dto.getStartDate(), dto.getEndDate(), dto.getProjectList(),dto.getPageNum(),dto.getPageSize(),dto.getSort(), dto.getYn());
+        OutputStream outputStream = response.getOutputStream();
+        String date = DateUtils.formatDate(new Date());
+        HttpUtils.setResponseHeader(response, "头条销售报表" + date + ".xlsx");
+        ExcelWriter excelWriter = EasyExcelFactory.getWriter(outputStream);
+        Sheet sheet = new Sheet(1, 0, ByteDanceReportAccountDailyDTOEntity.class);
+        sheet.setSheetName(totalSheetVo.getSheetName());
+        excelWriter.write(totalSheetVo.getDetails(), sheet);
+        excelWriter.finish();
+        outputStream.flush();
+        outputStream.close();
+    }
+
 }

+ 2 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/ByteDanceVideoReportDaily.java

@@ -29,11 +29,11 @@ public class ByteDanceVideoReportDaily {
 	/**id*/
 	@TableId(type = IdType.AUTO)
     @ApiModelProperty(value = "id")
-	private Integer id;
+	private Long id;
 	/**项目id*/
 	@Excel(name = "项目id", width = 15)
     @ApiModelProperty(value = "项目id")
-	private Integer projectId;
+	private Long projectId;
 	/**项目名称*/
 	@Excel(name = "项目名称", width = 15)
     @ApiModelProperty(value = "项目名称")

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

@@ -77,4 +77,6 @@ public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVid
     List<Long> getAccountIds(@Param("companyId") String companyId, @Param("signature") String signature);
 
     List<Long> getAccountIdsByUserIdAndMediaIds(@Param("userId") String userId, @Param("mediaIds") List<Integer> mediaIds);
+
+    void insertBatch(@Param("mlist")List<ByteDanceVideoReportDaily> mList);
 }

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.mapper;
 
+import cn.com.ctop.common.module.vo.ByteDanceReportAccountDailyDTOEntity;
 import cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -67,4 +68,5 @@ public interface BytedanceAccountReportMapper {
 
     List<Long> getUserProjectAccountIdsByAdmin();
 
+    List<ByteDanceReportAccountDailyDTOEntity> getBytedanceProjectInfoEntity(@Param("startDate")String startDate, @Param("endDate")String endDate,@Param("projectList")List<Long> projectList, @Param("yn")Integer yn);
 }

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

@@ -446,6 +446,203 @@
         )
         </foreach>
     </insert>
+    <insert id="insertBatch">
+        insert into ctop_bytedance_video_report_daily(
+        account_id,
+        project_id,
+        project_name,
+        advertiser_id,
+        advertiser_name,
+        signature,
+        video_url,
+        url,
+        huanbi,
+        material_name,
+        app_type,
+        company_id,
+        material_id,
+        stat_datetime,
+        click,
+        cost,
+        active,
+        download_finish,
+        download_start,
+        install_finish,
+        register,
+        pay_count,
+        in_app_uv,
+        in_app_detail_uv,
+        in_app_cart,
+        in_app_order,
+        in_app_pay,
+        phone,
+        form,
+        map_search,
+        view_material,
+        qq,
+        lottery,
+        vote,
+        redirect,
+        shopping,
+        consult,
+        wechat,
+        phone_confirm,
+        phone_connect,
+        consult_effective,
+        total_play,
+        valid_play,
+        wifi_play,
+        play25_feed_break_rate,
+        play25_feed_break,
+        play50_feed_break,
+        play75_feed_break,
+        play100_feed_break,
+        advanced_creative_phone_click,
+        advanced_creative_counsel_click,
+        advanced_creative_form_click,
+        share_material,
+        comment_material,
+        follow,
+        home_visited,
+        ies_challenge_click,
+        ies_music_click,
+        next_day_open,
+        next_day_open_rate,
+        next_day_open_cost,
+        active_pay_amount,
+        valid_play_cost,
+        advanced_creative_coupon_addition,
+        convert_material,
+        active_pay_cost,
+        download,
+        cpc,
+        location_click,
+        play_over_rate,
+        ctr,
+        cpm,
+        wifi_play_rate,
+        like_material,
+        active_cost,
+        game_addiction_cost,
+        game_addiction,
+        active_rate,
+        game_addiction_rate,
+        active_register_rate,
+        download_finish_cost,
+        active_register_cost,
+        convert_rate,
+        download_finish_rate,
+        install_finish_rate,
+        coupon,
+        coupon_single_page,
+        play_over,
+        download_start_cost,
+        message,
+        valid_play_rate,
+        average_play_time_per_play,
+        convert_cost,
+        install_finish_cost,
+        download_start_rate
+        )
+        values
+        <foreach collection="mlist" item="image" separator=",">
+            (#{image.accountId},
+            #{image.projectId},
+            #{image.projectName},
+            #{image.advertiserId},
+            #{image.advertiserName},
+            #{image.signature},
+            #{image.videoUrl},
+            #{image.url},
+            #{image.huanbi},
+            #{image.materialName},
+            #{image.appType},
+            #{image.companyId},
+            #{image.materialId},
+            #{image.statDatetime},
+            #{image.click},
+            #{image.cost},
+            #{image.active},
+            #{image.downloadFinish},
+            #{image.downloadStart},
+            #{image.installFinish},
+            #{image.register},
+            #{image.payCount},
+            #{image.inAppUv},
+            #{image.inAppDetailUv},
+            #{image.inAppCart},
+            #{image.inAppOrder},
+            #{image.inAppPay},
+            #{image.phone},
+            #{image.form},
+            #{image.mapSearch},
+            #{image.viewMaterial},
+            #{image.qq},
+            #{image.lottery},
+            #{image.vote},
+            #{image.redirect},
+            #{image.shopping},
+            #{image.consult},
+            #{image.wechat},
+            #{image.phoneConfirm},
+            #{image.phoneConnect},
+            #{image.consultEffective},
+            #{image.totalPlay},
+            #{image.validPlay},
+            #{image.wifiPlay},
+            #{image.play25FeedBreakRate},
+            #{image.play25FeedBreak},
+            #{image.play50FeedBreak},
+            #{image.play75FeedBreak},
+            #{image.play100FeedBreak},
+            #{image.advancedCreativePhoneClick},
+            #{image.advancedCreativeCounselClick},
+            #{image.advancedCreativeFormClick},
+            #{image.shareMaterial},
+            #{image.commentMaterial},
+            #{image.follow},
+            #{image.homeVisited},
+            #{image.iesChallengeClick},
+            #{image.iesMusicClick},
+            #{image.nextDayOpen},
+            #{image.nextDayOpenRate},
+            #{image.nextDayOpenCost},
+            #{image.activePayAmount},
+            #{image.validPlayCost},
+            #{image.advancedCreativeCouponAddition},
+            #{image.convertMaterial},
+            #{image.activePayCost},
+            #{image.download},
+            #{image.cpc},
+            #{image.locationClick},
+            #{image.playOverRate},
+            #{image.ctr},
+            #{image.cpm},
+            #{image.wifiPlayRate},
+            #{image.likeMaterial},
+            #{image.activeCost},
+            #{image.gameAddictionCost},
+            #{image.gameAddiction},
+            #{image.activeRate},
+            #{image.gameAddictionRate},
+            #{image.activeRegisterRate},
+            #{image.downloadFinishCost},
+            #{image.activeRegisterCost},
+            #{image.convertRate},
+            #{image.downloadFinishRate},
+            #{image.installFinishRate},
+            #{image.coupon},
+            #{image.couponSinglePage},
+            #{image.playOver},
+            #{image.downloadStartCost},
+            #{image.message},
+            #{image.validPlayRate},
+            #{image.averagePlayTimePerPlay},
+            #{image.convertCost},
+            #{image.installFinishCost},
+            #{image.downloadStartRate})
+        </foreach>
+    </insert>
 
     <select id="getAccountIdByprojectIds" resultType="long">
         select
@@ -678,18 +875,212 @@
 
     <select id="videoInfoList" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
-        <include refid="videoInfoSql"></include>
-        #{companyId} as companyId
+        a.account_id as accountId,
+        b.project_id as projectId,
+        b.project_name as projectName,
+        b.advertiser_id as advertiserId,
+        b.advertiser_name as advertiserName,
+        a.stat_datetime as statDatetime,
+        sum(a.cost) as cost,
+        d.signature as signature,
+        d.video_url as videoUrl,
+        (select mat.url from ctop_material_info mat where mat.code = d.signature order by id desc limit 1) as url,
+        '-' as materialDesc,
+        1 as appType,
+        sum(a.click) as click,
+        case
+        when sum(a.total_play) != 0
+        then sum(a.play25_feed_break)/sum(a.total_play)
+        else 0 end as play25FeedBreakRate,
+
+        case
+        when sum(a.total_play) != 0
+        then sum(a.play_over)/sum(a.total_play)
+        else 0 end as playOverRate,
+
+        case
+        when sum(a.click) != 0
+        then sum(a.convert_material)/sum(a.click)
+        else 0 end as convertRate,
+        sum(a.active) as active,
+        sum(a.download_finish) as downloadFinish,
+        sum(a.download_start) as downloadStart,
+        sum(a.install_finish) as installFinish,
+        sum(a.register) as register,
+        sum(a.pay_count) as payCount,
+        sum(a.in_app_uv) as inAppUv,
+        sum(a.in_app_detail_uv) as inAppDetailUv,
+        sum(a.in_app_cart) as inAppCart,
+        sum(a.in_app_order) as inAppOrder,
+        sum(a.in_app_pay) as inAppPay,
+        sum(a.phone) as phone,
+        sum(a.form) as form,
+        sum(a.map_search) as mapSearch,
+        sum(a.button) as button,
+        sum(a.view_material) as viewMaterial,
+        sum(a.qq) as qq,
+        sum(a.lottery) as lottery,
+        sum(a.vote) as vote,
+        sum(a.redirect) as redirect,
+        sum(a.shopping) as shopping,
+        sum(a.consult) as consult,
+        sum(a.wechat) as wechat,
+        sum(a.phone_confirm) as phoneConfirm,
+        sum(a.phone_connect) as phoneConnect,
+        sum(a.consult_effective) as consultEffective,
+        sum(a.total_play) as totalPlay,
+        sum(a.valid_play) as validPlay,
+        sum(a.wifi_play) as wifiPlay,
+        sum(a.play25_feed_break) as play25FeedBreak,
+        sum(a.play50_feed_break) as play50FeedBreak,
+        sum(a.play75_feed_break) as play75FeedBreak,
+        sum(a.play100_feed_break) as play100FeedBreak,
+        sum(a.advanced_creative_phone_click) as advancedCreativePhoneClick,
+        sum(a.advanced_creative_counsel_click) as advancedCreativeCounselClick,
+        sum(a.advanced_creative_form_click) as advancedCreativeFormClick,
+        sum(a.share_material) as shareMaterial,
+        sum(a.comment_material) as commentMaterial,
+        sum(a.follow) as follow,
+        sum(a.home_visited) as homeVisited,
+        sum(a.ies_challenge_click) as iesChallengeClick,
+        sum(a.ies_music_click) as iesMusicClick,
+        sum(a.next_day_open) as nextDayOpen,
+        case
+        when sum(a.active) != 0
+        then sum(a.next_day_open)/sum(a.active)
+        else 0 end as nextDayOpenRate,
+
+        case
+        when sum(a.next_day_open) != 0
+        then sum(a.cost)/sum(a.next_day_open)
+        else 0 end as nextDayOpenCost,
+
+        case when sum(a.pay_count) != 0
+        then sum(a.cost)/sum(a.pay_count)
+        else 0 end
+        as activePayCost,
+
+        sum(a.active_pay_amount) as activePayAmount,
+
+        case
+        when sum(a.valid_play) != 0
+        then sum(a.cost)/sum(a.valid_play)
+        else 0 end validPlayCost,
+        sum(a.advanced_creative_coupon_addition) as advancedCreativeCouponAddition,
+        sum(a.convert_material) as convertMaterial,
+
+        case
+        when sum(a.active_pay_amount) != 0
+        then sum(a.cost)/sum(a.active_pay_amount)
+        else 0 end as activePayCost,
+        sum(a.download) as download,
+
+        case
+        when sum(a.click) != 0
+        then sum(a.cost) / sum(a.click)
+        else 0 end                           as cpc,
+        sum(a.location_click) as locationClick,
+
+        case
+        when sum(a.show_material) != 0
+        then sum(a.click)/sum(a.show_material)
+        else 0 end as ctr,
+
+        case
+        when sum(a.show_material) != 0
+        then sum(a.cost)/sum(a.show_material)*1000
+        else 0 end cpm,
+        sum(a.wifi_play_rate) as wifiPlayRate,
+        sum(a.like_material) as likeMaterial,
+
+        case
+        when sum(a.active) != 0
+        then sum(a.cost)/sum(a.active)
+        else 0 end activeCost,
+
+        case
+        when sum(a.game_addiction) != 0
+        then sum(a.cost)/sum(a.game_addiction)
+        else 0 end as gameAddictionCost,
+        sum(a.game_addiction) as gameAddiction,
+
+        case
+        when sum(a.click) != 0
+        then sum(a.active)/sum(a.click)
+        else 0 end as activeRate,
+
+        case
+        when sum(a.active) != 0
+        then sum(a.game_addiction)/sum(a.active)
+        else 0 end gameAddictionRate,
+
+        case
+        when sum(a.active) != 0
+        then sum(a.register)/sum(a.active)
+        else 0 end as activeRegisterRate,
+
+
+        case
+        when sum(a.download_finish) != 0
+        then sum(a.cost)/sum(a.download_finish)
+        else 0 end as downloadFinishCost,
+
+
+        case
+        when sum(a.register) != 0
+        then sum(a.cost)/sum(a.register)
+        else 0 end as activeRegisterCost,
+        sum(a.show_material) as showMaterial,
+
+        case
+        when sum(a.download_start) != 0
+        then sum(a.download_finish)/sum(a.download_start)
+        else 0 end as downloadFinishRate,
+
+        case
+        when sum(a.download_finish) != 0
+        then sum(a.install_finish)/sum(a.download_finish)
+        else 0 end as installFinishRate,
+        sum(a.coupon) as coupon,
+        sum(a.coupon_single_page) as couponSinglePage,
+        sum(a.play_over) as playOver,
+
+        case
+        when sum(a.download_start) != 0
+        then sum(a.cost)/sum(a.download_start)
+        else 0 end as downloadStartCost,
+        sum(a.message) as message,
+        case
+        when sum(a.show_material) != 0
+        then sum(a.valid_play)/sum(a.show_material)
+        else 0 end as validPlayRate,
+
+        case
+        when sum(a.valid_play) != 0
+        then sum(a.average_play_time_per_play*a.valid_play)/sum(a.valid_play)
+        else 0 end as averagePlayTimePerPlay,
+
+        case
+        when sum(a.convert_material) != 0
+        then sum(a.cost)/sum(a.convert_material)
+        else 0 end as convertCost,
+        case
+        when sum(a.install_finish) != 0
+        then sum(a.cost)/sum(a.install_finish)
+        else 0 end as installFinishCost,
+
+        case
+        when sum(a.click) != 0
+        then sum(a.download_start)/sum(a.click)
+        else 0 end as downloadStartRate,
+        c.company_id as companyId
         from ctop_bytedance_report_material_daily a
-        left join (select * from ctop_user_allocation group by account_id) b on a.account_id = b.account_id
+        left join ctop_user_allocation b on a.account_id = b.account_id
         left join user_company c on b.user_id = c.user_id
-        left join (select * from ctop_bytedance_video_info group by material_id) d on a.material_id = d.material_id
-        left join (select code,url,material_name from ctop_material_info group by code) e on d.signature = e.code
-        where c.company_id = #{companyId}      -- '6608ed13c0dd42de93c790dbdf124234'
-        and a.image_mode in ('CREATIVE_IMAGE_MODE_VIDEO',
-        'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL')
-        and date_format(stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
-        and date_format(stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
+        left join (select signature,video_url,material_id from ctop_bytedance_video_info group by material_id) d on a.material_id = d.material_id
+        where c.company_id = #{companyId}
+        and stat_datetime &gt;= #{startDate}
+        and stat_datetime &lt;= #{endDate}
         <if test="accountId != null">
             and a.account_id = #{accountId}
         </if>

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

@@ -507,5 +507,50 @@
         b.media_id in (1,3)
 
     </select>
+    <select id="getBytedanceProjectInfoEntity"
+            resultType="cn.com.ctop.common.module.vo.ByteDanceReportAccountDailyDTOEntity">
+        select * from (
+        select
+        concat(#{startDate},'~',#{endDate}) as statDate,
+        a.advertiser_id as 'accountId',
+        c.advertiser_id as 'advertiserId',
+        (select name from ctop_advertiser where id = c.advertiser_id) as 'advertiserName',
+
+        (
+        select realname from sys_user where id = (
+        select responsible_id from ctop_project where id = b.project_id
+        )
+        ) as 'responsibleName',
+        (
+        select realname from sys_user where id = (
+        select design_responsible_id from ctop_project where id = b.project_id
+        )
+        ) as 'designResponsibleName',
+        b.auth_name as 'authName',
+        b.project_id as 'projectId',
+        (select project_name from ctop_project where id = b.project_id) as 'projectName',
+        c.media_id as 'mediaId',
+        <include refid="selectSql"></include>
+        from
+        ctop_bytedance_report_advertiser_daily a
+        left join ctop_user_allocation b on a.advertiser_id = b.account_id
+        left join ctop_project c on b.project_id = c.id
+        where
+        date_format(a.stat_datetime, '%Y-%m-%d') &gt;= #{startDate}
+        and
+        date_format(a.stat_datetime, '%Y-%m-%d') &lt;= #{endDate}
+        and
+        b.project_id in
+        <foreach collection="projectList" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+        group by b.project_id
+        )m
+        <if test="yn = 1">
+            where
+            m.cost != 0
+        </if>
+    </select>
 
 </mapper>

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.service;
 
+import cn.com.ctop.common.module.vo.SheetInfoVo;
 import cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -24,4 +25,5 @@ public interface IBytedanceAccountReportService {
 
     PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn);
 
+    SheetInfoVo getBytedanceSaleProjectInfoSheetVO(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn);
 }

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

@@ -54,8 +54,21 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         byteDanceVideoReportDailyMapper.delete(wrapper);
 
         List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoList(startDate, endDate, companyId, null);
-        for (ByteDanceVideoReportDaily m:mList){
-            byteDanceVideoReportDailyMapper.insert(m);
+        if(null!=mList&&!mList.isEmpty()){
+            List<ByteDanceVideoReportDaily> reports = new ArrayList<>();
+            for(ByteDanceVideoReportDaily report :mList){
+                if(null == report.getMaterialName()||report.getMaterialName().trim().equals("")){
+                    report.setMaterialName("-");
+                }
+                if(null == report.getProjectName()||report.getProjectName().trim().equals("")){
+                    report.setProjectName("-");
+                }
+                if(null == report.getAdvertiserName()||report.getAdvertiserName().trim().equals("")){
+                    report.setAdvertiserName("-");
+                }
+                reports.add(report);
+            }
+            byteDanceVideoReportDailyMapper.insertBatch(reports);
         }
     }
 

+ 29 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceAccountReportServiceImpl.java

@@ -1,6 +1,8 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
 import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.common.module.vo.ByteDanceReportAccountDailyDTOEntity;
+import cn.com.ctop.common.module.vo.SheetInfoVo;
 import cn.com.ctop.toutiao.modules.report.DTO.ByteDanceReportAccountDailyDTO;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceAccountReportMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceAccountReportService;
@@ -196,7 +198,6 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
 
     @Override
     public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn){
-        //List<ByteDanceReportAccountDailyDTO> list = new ArrayList<>();
 
         if(projectList==null || projectList.size()==0){
             LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -222,6 +223,33 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
     }
 
     @Override
+    public SheetInfoVo getBytedanceSaleProjectInfoSheetVO(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn) {
+        SheetInfoVo vo = new SheetInfoVo<ByteDanceReportAccountDailyDTOEntity>();
+        if(projectList==null || projectList.size()==0){
+            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            String userId = sysUser.getId();
+            //String userId = "388e787edd294ecfb9243fe176a3ae56";
+            String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
+
+            List<Long> mediaIds = new ArrayList<>();
+            mediaIds.add(1L);
+            mediaIds.add(3L);
+
+            if("admin".equals(roleCode)){
+                projectList = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
+            }else{
+                projectList = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
+            }
+        }
+
+        PageHelper.startPage(pageNum,pageSize);
+        List<ByteDanceReportAccountDailyDTOEntity> dtos = bytedanceAccountReportMapper.getBytedanceProjectInfoEntity(startDate, endDate, projectList, yn);
+        vo.setSheetName("头条销售报表");
+        vo.setDetails(dtos);
+        return vo;
+    }
+
+    @Override
     public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort, Integer yn){
 
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

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

@@ -82,6 +82,10 @@ public class ReportServiceImpl implements IReportService {
         config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
         JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
         JSONObject getObject = getAdvertiserStat(token, jsonObject);
+        if(null == getObject){
+            XxlJobLogger.log("头条广告主数据获取异常");
+            return;
+        }
         Integer code = getObject.getInteger("code");
         String message = getObject.getString("message");
         if (null == code || code != 0) {

+ 5 - 0
pom.xml

@@ -165,6 +165,11 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-freemarker</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>1.1.2-beat1</version>
+        </dependency>
 
         <!-- Lombok -->
         <dependency>