浏览代码

Merge branch 'master' into jiaoyang

# Conflicts:
#	jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
yumeng 4 年之前
父节点
当前提交
4af23d356d
共有 60 个文件被更改,包括 1478 次插入168 次删除
  1. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  2. 3 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  3. 1 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  4. 51 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountAudienceReportJob.java
  5. 33 11
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAudienceReportJob.java
  6. 22 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEffectVideoJob.java
  7. 31 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/BatchController.java
  8. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouStrategyMapper.java
  9. 6 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouStrategyMapper.xml
  10. 8 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IBatchService.java
  11. 11 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouStrategyService.java
  12. 28 41
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/BatchServiceImpl.java
  13. 3 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouActionBarTextServiceImpl.java
  14. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupTemplateServiceImpl.java
  15. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouStrategyServiceImpl.java
  16. 20 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouAudienceReportDailyController.java
  17. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDaily.java
  18. 26 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyAccount.java
  19. 1 9
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyBussiness.java
  20. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyAccountMapper.java
  21. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyAgeMapper.java
  22. 6 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyBusinessMapper.java
  23. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyCityMapper.java
  24. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyClientMapper.java
  25. 4 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyGenderMapper.java
  26. 3 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyProvinceMapper.java
  27. 46 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyAgeMapper.xml
  28. 46 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyBusinessMapper.xml
  29. 45 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyCityMapper.xml
  30. 45 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyClientMapper.xml
  31. 45 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyGenderMapper.xml
  32. 45 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyProvinceMapper.xml
  33. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyAccountService.java
  34. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyAgeService.java
  35. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyBusinessService.java
  36. 13 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyCityService.java
  37. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyClientService.java
  38. 17 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyGenderService.java
  39. 14 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyProvinceService.java
  40. 13 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyService.java
  41. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyAccountServiceImpl.java
  42. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyAgeServiceImpl.java
  43. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyBusinessServiceImpl.java
  44. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyCityServiceImpl.java
  45. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyClientServiceImpl.java
  46. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyGenderServiceImpl.java
  47. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyProvinceServiceImpl.java
  48. 123 50
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java
  49. 6 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyAgentServiceImpl.java
  50. 1 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouVideoEtlInfoServiceImpl.java
  51. 150 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceVideoEtlInfoController.java
  52. 74 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/BytedanceVideoEtlInfo.java
  53. 5 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceReportMaterialDailyMapper.java
  54. 16 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/BytedanceVideoEtlInfoMapper.java
  55. 34 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMaterialDailyMapper.xml
  56. 8 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceVideoEtlInfoMapper.xml
  57. 4 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceReportMaterialDailyService.java
  58. 18 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IBytedanceVideoEtlInfoService.java
  59. 11 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceReportMaterialDailyServiceImpl.java
  60. 179 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/BytedanceVideoEtlInfoServiceImpl.java

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

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

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

@@ -95,6 +95,9 @@
           AND account_status = 0
           AND delete_comment = 0
     </select>
+    <select id="getCompanyNameByUserId" resultType="java.lang.String">
+        select company_name from user_company where user_id = #{planId} limit 1
+    </select>
 
 
 </mapper>

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

@@ -134,6 +134,7 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
                 log.error("查询token信息返回结果为空,accountId:{}", accountId);
                 return;
             }
+            XxlJobHelper.log("刷新token,入參:{},token:{}", param,headers);
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject resultJson = JSONObject.parseObject(result);
             log.info("快手刷新token返回结果:{}", refreshToken);

+ 51 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAccountAudienceReportJob.java

@@ -0,0 +1,51 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 快手广告主分天数据
+ *
+ * @author syh
+ */
+@Component
+public class KuaishouDailyAccountAudienceReportJob {
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+    @Autowired
+    private IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
+
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+
+    @XxlJob("kuaishouAccountAudienceReportJob")
+    public void execute() throws Exception {
+        //查询两天前数据  策略
+        String date = DateUtils.getLastDay(DateUtils.date2Str(), 2);
+        List<CtopOauthToken> tokens = tokenService.selectKuaiShouToken();
+        if (null == tokens || tokens.isEmpty()) {
+            XxlJobHelper.log("定时获取人群分析报表数据异常:未获取到可用的token");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        int page = 1;
+        int pageSize = 2000;
+        tokens.forEach(token -> executorService.submit(() -> {
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "province", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "city", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "gender", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "ageSegment", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "clientId", null, null, page, pageSize);
+            kuaishouAudienceReportDailyService.crowdAnalysisReport(token, date, "businessInterestTags", null, null, page, pageSize);
+        }));
+    }
+}

+ 33 - 11
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouDailyAudienceReportJob.java

@@ -2,9 +2,10 @@ package cn.com.ctop.job.kuaishou.handler;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
-import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCampaignService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouStrategyService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
@@ -12,6 +13,7 @@ import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -29,6 +31,8 @@ public class KuaishouDailyAudienceReportJob {
     private IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
     @Autowired
     private IKuaiShouGroupService kuaiShouGroupService;
+    @Autowired
+    private IKuaishouStrategyService kuaishouStrategyService;
 
     static ExecutorService executorService = Executors.newFixedThreadPool(6);
 
@@ -42,16 +46,34 @@ public class KuaishouDailyAudienceReportJob {
             XxlJobHelper.handleFail();
             return;
         }
-        int page = 1;
-        int pageSize = 2000;
-        tokens.forEach(token -> executorService.submit(() -> {
-            getAudienceReportData(token, date, "province", page, pageSize);
-            getAudienceReportData(token, date, "city", page, pageSize);
-            getAudienceReportData(token, date, "gender", page, pageSize);
-            getAudienceReportData(token, date, "ageSegment", page, pageSize);
-            getAudienceReportData(token, date, "clientId", page, pageSize);
-            getAudienceReportData(token, date, "businessInterestTags", page, pageSize);
-        }));
+        //查询有效策略的账户ID
+        List<Long> accountIds = kuaishouStrategyService.queryActiveAccount();
+        if (Check.isNull(accountIds) || accountIds.size() == 0) {
+            XxlJobHelper.log("定时获取人群分析报表数据异常:为获取到有效策略账户信息");
+            XxlJobHelper.handleFail();
+            return;
+        }
+        //筛选出有效账户,获取该账户的组级人群报表数据
+        List<CtopOauthToken> activeTokens = new ArrayList<>();
+        for (Long accountId : accountIds) {
+            for (CtopOauthToken token : tokens) {
+                if (token.getAccountId() - accountId == 0) {
+                    activeTokens.add(token);
+                }
+            }
+        }
+        if (!Check.isNull(activeTokens) && activeTokens.size() > 0) {
+            int page = 1;
+            int pageSize = 2000;
+            activeTokens.forEach(token -> executorService.submit(() -> {
+                getAudienceReportData(token, date, "province", page, pageSize);
+                getAudienceReportData(token, date, "city", page, pageSize);
+                getAudienceReportData(token, date, "gender", page, pageSize);
+                getAudienceReportData(token, date, "ageSegment", page, pageSize);
+                getAudienceReportData(token, date, "clientId", page, pageSize);
+                getAudienceReportData(token, date, "businessInterestTags", page, pageSize);
+            }));
+        }
     }
 
     private void getAudienceReportData(CtopOauthToken token, String date, String type, Integer page, Integer pageSize) {

+ 22 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouEffectVideoJob.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouVideoEtlInfoService;
+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.text.ParseException;
+import java.util.Date;
+
+@Component
+public class KuaishouEffectVideoJob {
+    @Autowired
+    private IKuaishouVideoEtlInfoService etlInfoService;
+
+    @XxlJob("kuaishouGroupDailyReportJob")
+    public void execute() throws ParseException {
+        Date getDate = DateUtils.addDay(new Date(),-1);
+        etlInfoService.etlKuaishouVideoInfo(getDate);
+    }
+}

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

@@ -2409,4 +2409,35 @@ public class BatchController {
     }
 
 
+    /**
+     * 获取创意标签白名单
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping(value = "/getCategoryWhite")
+    public Result<JSONObject> getCategoryWhite(Long accountId) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("入参为空");
+            }
+            CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+            if (Check.isNull(oauthToken)) {
+                throw new Exception("未获取到账户信息");
+            }
+            JSONObject data = batchService.getCategoryWhite(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;
+    }
+
+
 }

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

@@ -16,4 +16,6 @@ import java.util.List;
 public interface KuaishouStrategyMapper extends BaseMapper<KuaishouStrategy> {
 
     List<JSONObject> queryPlanIdsByStrategyId(Long id);
+
+    List<Long> queryActiveAccount();
 }

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

@@ -10,4 +10,10 @@
           from ctop_ai_kuaishou_strategy_map_creative
          where strategy_id = #{id}
     </select>
+
+    <select id="queryActiveAccount" resultType="java.lang.Long">
+        SELECT account_id FROM ctop_kuaishou_strategy
+        WHERE strategy_state = 1
+        GROUP BY account_id
+    </select>
 </mapper>

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

@@ -172,4 +172,12 @@ public interface IBatchService {
 
     Map<String, Object> batchCreateCreative(JSONObject requestJson) throws Exception;
 
+    /**
+     * 获取创意分类白名单
+     *
+     * @param accountId
+     * @param accessToken
+     * @return
+     */
+    JSONObject getCategoryWhite(Long accountId, String accessToken);
 }

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

@@ -2,11 +2,11 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouStrategy;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -36,4 +36,14 @@ public interface IKuaishouStrategyService extends IService<KuaishouStrategy> {
      * @author ZHAOXA
      */
     Map<String, Object> createPlanLevelStrategy(CtopOauthToken oauthToken, JSONObject data);
+
+    /**
+     * 查询有效策略的账户
+     *
+     * @param
+     * @return java.util.List<java.lang.Long>
+     * @throws
+     * @author ZHAOXA
+     */
+    List<Long> queryActiveAccount();
 }

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

@@ -788,9 +788,7 @@ public class BatchServiceImpl implements IBatchService {
                     } else {
                         unitJson.put("begin_time", group.getBeginTime());
                     }
-
                 }
-
                 // 优先从系统应用商店下载
                 if (!Check.isNull(group.getUseAppMarket())) {
                     unitJson.put("use_app_market", group.getUseAppMarket());
@@ -836,8 +834,6 @@ public class BatchServiceImpl implements IBatchService {
                 if (!Check.isNull(group.getSpeed())) {
                     unitJson.put("speed", group.getSpeed());
                 }
-
-
                 QueryWrapper<KuaiShouGroupTarget> targetQueryWrapper = new QueryWrapper<>();
                 targetQueryWrapper.eq("account_id", group.getAccountId());
                 targetQueryWrapper.eq("unit_id", group.getUnitId());
@@ -966,8 +962,6 @@ public class BatchServiceImpl implements IBatchService {
 
                     unitJson.put("target", targetJson);
                 }
-
-
                 // 出价
                 if (!Check.isNull(group.getBid())) {
                     unitJson.put("bid", group.getBid());
@@ -1194,7 +1188,6 @@ public class BatchServiceImpl implements IBatchService {
                         creativeJson.put("site_id", creative.getSiteId());
                     }
 
-
                     if (creativeMaterialType == 4) {
                         creativeJson.put("image_tokens", JSONArray.parseArray(creative.getImageTokens()));
                         creativeJson.put("short_slogan", creative.getShortSlogan());
@@ -1214,8 +1207,6 @@ public class BatchServiceImpl implements IBatchService {
                             creativeJson.put("click_track_url", click_track_url);
                         }
                     }
-
-
                 }
                 // 安卓下载中间页
                 Map<String, Object> returnCreativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), accountId, creativeJson, 1);
@@ -1279,12 +1270,10 @@ public class BatchServiceImpl implements IBatchService {
         if (Check.isNull(oauthToken)) {
             throw new Exception("未获取到账户信息");
         }
-
         Long unitId = requestJson.getLong("unitId");
         if (Check.isNull(unitId)) {
             throw new Exception("请选择广告组");
         }
-
         JSONObject creativeJson = new JSONObject();
         creativeJson.put("advertiser_id", accountId);
         creativeJson.put("unit_id", unitId);
@@ -1296,18 +1285,14 @@ public class BatchServiceImpl implements IBatchService {
         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();
         JSONArray dataJsons = requestJson.getJSONArray("dataJson");
-
         Integer content = requestJson.getInteger("content");
-
         if (!Check.isNull(dataJsons)) {
             for (int i = 0; i < dataJsons.size(); i++) {
                 JSONObject dataJson = dataJsons.getJSONObject(i);
-
                 String creativeMaterialType = dataJson.getString("creativeMaterialType");
                 String shortSlogan = dataJson.getString("shortSlogan");
                 String overlayType = dataJson.getString("overlayType");
@@ -1436,19 +1421,13 @@ public class BatchServiceImpl implements IBatchService {
         creativeJson.put("unit_id", unitId);
         String click_track_url = requestJson.getString("clickTrackUrl");
         String actionbar_click_url = requestJson.getString("actionbarClickUrl");
-
-
         // 素材类型
-
         String action_bar_text = requestJson.getString("actionBarText");
         String site_id = requestJson.getString("siteId");
         Integer creativeCategory = requestJson.getInteger("creativeCategory");// 创意分类
         JSONArray creativeTag = requestJson.getJSONArray("creativeTag");
-
-
         JSONArray dataJsons = requestJson.getJSONArray("dataJson");
         Integer content = requestJson.getInteger("content");
-
         if (!Check.isNull(dataJsons)) {
             JSONArray creatives = new JSONArray();
             for (int i = 0; i < dataJsons.size(); i++) {
@@ -1539,6 +1518,34 @@ public class BatchServiceImpl implements IBatchService {
         return returnUnitMap;
     }
 
+    @Override
+    public JSONObject getCategoryWhite(Long accountId, String accessToken) {
+        try {
+            String url = "https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/white_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)) {
+                        return data;
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+
+
+    }
+
 
     /**
      * 获取创意信息
@@ -1853,39 +1860,29 @@ public class BatchServiceImpl implements IBatchService {
         if (Check.isNull(requestJson)) {
             throw new Exception("入参为空");
         }
-
-
         JSONObject creativeJson = new JSONObject();
         creativeJson.put("advertiser_id", token.getAccountId());
-
         Long creativeId = requestJson.getLong("creativeId");
         if (Check.isNull(creativeId)) {
             throw new Exception("请选择广告创意");
         }
         creativeJson.put("creative_id", creativeId);
-
-
         // 创意名称
         if (!Check.isNull(requestJson.get("creativeName"))) {
             creativeJson.put("creative_name", requestJson.get("creativeName"));
         }
-
         //封面
         if (!Check.isNull(requestJson.get("photoId"))) {
             creativeJson.put("photo_id", requestJson.get("photoId"));
         }
-
         // 视频id
         if (!Check.isNull(requestJson.get("imageToken"))) {
             creativeJson.put("image_token", requestJson.get("imageToken"));
         }
-
         // 行动号召按钮
         if (!Check.isNull(requestJson.get("actionBarText"))) {
             creativeJson.put("action_bar_text", requestJson.get("actionBarText"));
         }
-
-
         // 广告语
         if (!Check.isNull(requestJson.get("description"))) {
             creativeJson.put("description", requestJson.getString("description").trim());
@@ -1894,7 +1891,6 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(requestJson.get("stickerTitle"))) {
             creativeJson.put("sticker_title", requestJson.get("stickerTitle"));
         }
-
         // 贴纸样式
         if (!Check.isNull(requestJson.get("overlayType"))) {
             creativeJson.put("overlay_type", requestJson.get("overlayType"));
@@ -1903,18 +1899,15 @@ public class BatchServiceImpl implements IBatchService {
         if (!Check.isNull(requestJson.get("clickTrackUrl"))) {
             creativeJson.put("click_track_url", requestJson.get("clickTrackUrl"));
         }
-
         // 后贴片 第三方检测链接
         if (!Check.isNull(requestJson.get("adPhotoPlayedT3sUrl"))) {
             creativeJson.put("ad_photo_played_t3s_url", requestJson.get("adPhotoPlayedT3sUrl"));
         }
-
         // 后贴片 第三方检测链接
         if (!Check.isNull(requestJson.get("impressionUrl"))) {
             creativeJson.put("impression_url", requestJson.get("impressionUrl"));
         }
         JSONObject returnJson = updateService.updateCreative(token.getAccessToken(), creativeJson);
-
         return returnJson;
     }
 
@@ -1928,14 +1921,12 @@ public class BatchServiceImpl implements IBatchService {
      */
     @Override
     public JSONObject getWhiteList(Long accountId, String accessToken) {
-
         String url = "https://ad.e.kuaishou.com/rest/openapi/v1/advertiser/white_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);
         log.info("获取联盟白名单,accountId:{},data:{}", accountId, resultJson);
@@ -1944,7 +1935,6 @@ public class BatchServiceImpl implements IBatchService {
             if (code == 0) {
                 return resultJson.getJSONObject("data");
             }
-
         }
         return null;
     }
@@ -1990,7 +1980,6 @@ public class BatchServiceImpl implements IBatchService {
      */
     @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>();
@@ -2031,7 +2020,6 @@ public class BatchServiceImpl implements IBatchService {
 
 
     private JSONArray getSecond(String categoryId, JSONArray details) {
-
         JSONArray secondArr = new JSONArray();
         for (int i = 0; i < details.size(); i++) {
             JSONObject secondJson = details.getJSONObject(i);
@@ -2053,7 +2041,6 @@ public class BatchServiceImpl implements IBatchService {
             if (categoryId.equals(parent_id)) {
                 thirdArr.add(thirdJson);
             }
-
         }
         return thirdArr;
     }

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

@@ -67,6 +67,9 @@ public class KuaiShouActionBarTextServiceImpl extends ServiceImpl<KuaiShouAction
                     Integer campaign_type = data.getInteger("campaign_type");
                     JSONArray action_bar_text = data.getJSONArray("action_bar_text");
                     if (!Check.isNull(action_bar_text)) {
+                        Map<String, Object> deleteMap = new HashMap<>();
+                        deleteMap.put("type", campaign_type);
+                        actionBarTextMapper.deleteByMap(deleteMap);
                         for (int j = 0; j < action_bar_text.size(); j++) {
                             String actionBarText = action_bar_text.getString(j);
                             KuaiShouActionBarText kuaiShouActionBarText = new KuaiShouActionBarText();

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

@@ -235,7 +235,7 @@ public class KuaiShouGroupTemplateServiceImpl extends ServiceImpl<KuaiShouGroupT
         QueryWrapper<KuaiShouGroupTemplate> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("task_status", 0);
         queryWrapper.orderByAsc("create_time");
-        queryWrapper.last("limit 30");
+        queryWrapper.last("limit 45");
         List<KuaiShouGroupTemplate> list = this.list(queryWrapper);
         if (Check.isNull(list)) {
             log.error("暂未未创建的组");

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

@@ -146,6 +146,11 @@ public class KuaishouStrategyServiceImpl extends ServiceImpl<KuaishouStrategyMap
         return kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), planJson);
     }
 
+    @Override
+    public List<Long> queryActiveAccount() {
+        return kuaishouStrategyMapper.queryActiveAccount();
+    }
+
     public JSONArray createGroupLevelStrategy(CtopOauthToken oauthToken, JSONObject data) {
         JSONArray resultArr = new JSONArray();
         JSONArray groupInfo = data.getJSONArray("groupInfo");

+ 20 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouAudienceReportDailyController.java

@@ -4,7 +4,6 @@ import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
 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;
@@ -104,6 +103,26 @@ public class KuaishouAudienceReportDailyController {
     }
 
     /**
+     * 首页报表数据接口
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @AutoLog(value = "首页报表数据接口")
+    @ApiOperation(value = "首页报表数据接口", notes = "首页报表数据接口")
+    @GetMapping(value = "/queryAllReportForm")
+    public Result<Object> queryAllReportForm(KuaishouAudienceReportDaily audienceReport) {
+        try {
+            return kuaishouAudienceReportDailyService.queryAllReportForm(audienceReport);
+        } catch (Exception e) {
+            log.error("首页报表数据接口", e);
+        }
+        return Result.error("首页报表数据接口失败");
+    }
+
+    /**
      * 添加
      *
      * @param kuaishouAudienceReportDaily

+ 13 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDaily.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
@@ -724,6 +725,18 @@ public class KuaishouAudienceReportDaily {
     @Excel(name = "eventAdWatchTimes", width = 15)
     @ApiModelProperty(value = "eventAdWatchTimes")
     private java.lang.String eventAdWatchTimes;
+
+    @TableField(exist = false)
+    private java.lang.String startTime;
+
+    @TableField(exist = false)
+    private java.lang.String endTime;
+
+    @TableField(exist = false)
+    private java.lang.String orderType;
+
+    @TableField(exist = false)
+    private java.lang.String upOrDown;
     /**
      * 评论数
      */

+ 26 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyAccount.java

@@ -0,0 +1,26 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Data
+@TableName("ctop_kuaishou_audience_report_daily_account")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_kuaishou_audience_report_daily_account对象", description = "年龄人群分析报表")
+public class KuaishouAudienceReportDailyAccount extends KuaishouAudienceReportDaily {
+    /**
+     * province: 省级地域分布,city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布,clientId: 系统分布,businessInterestTags: 商业兴趣分布
+     */
+    private java.lang.String audienceType;
+}

+ 1 - 9
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAudienceReportDailyBussiness.java

@@ -1,18 +1,10 @@
 package cn.com.ctop.kuaishou.modules.report.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.jeecgframework.poi.excel.annotation.Excel;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import java.util.Date;
 
 /**
  * 商业兴趣人群分析报表
@@ -26,5 +18,5 @@ import java.util.Date;
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 @ApiModel(value = "ctop_kuaishou_audience_report_daily_business对象", description = "商业兴趣人群分析报表")
-public class KuaishouAudienceReportDailyBussiness extends KuaishouAudienceReportDaily {
+public class KuaishouAudienceReportDailyBusiness extends KuaishouAudienceReportDaily {
 }

+ 16 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyAccountMapper.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 人群分析报表
+ *
+ * @author: jeecg-boot
+ * @date: 2020-12-03
+ * @cersion: V1.0
+ */
+public interface KuaishouAudienceReportDailyAccountMapper extends BaseMapper<KuaishouAudienceReportDailyAccount> {
+
+}

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

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 import java.util.List;
@@ -15,5 +16,7 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyAgeMapper extends BaseMapper<KuaishouAudienceReportDailyAge> {
 
-    List<KuaishouAudienceReportDaily> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+
+    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

+ 6 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyBusinessMapper.java

@@ -1,7 +1,8 @@
 package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBussiness;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBusiness;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 import java.util.List;
@@ -13,7 +14,9 @@ import java.util.List;
  * @date: 2020-12-03
  * @cersion: V1.0
  */
-public interface KuaishouAudienceReportDailyBusinessMapper extends BaseMapper<KuaishouAudienceReportDailyBussiness> {
+public interface KuaishouAudienceReportDailyBusinessMapper extends BaseMapper<KuaishouAudienceReportDailyBusiness> {
 
-    List<KuaishouAudienceReportDaily> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+
+    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyCity;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 import java.util.List;
@@ -15,5 +16,7 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyCityMapper extends BaseMapper<KuaishouAudienceReportDailyCity> {
 
-    List<KuaishouAudienceReportDaily> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+
+    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyClient;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 import java.util.List;
@@ -15,5 +16,7 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyClientMapper extends BaseMapper<KuaishouAudienceReportDailyClient> {
 
-    List<KuaishouAudienceReportDaily> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+
+    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -2,6 +2,7 @@ package cn.com.ctop.kuaishou.modules.report.mapper;
 
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
 import java.util.List;
@@ -15,5 +16,7 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyGenderMapper extends BaseMapper<KuaishouAudienceReportDailyGender> {
 
-    List<KuaishouAudienceReportDaily> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+
+    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -16,5 +16,7 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyProvinceMapper extends BaseMapper<KuaishouAudienceReportDailyProvince> {
 
-    List<KuaishouAudienceReportDaily> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
+
+    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

+ 46 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyAgeMapper.xml

@@ -1,11 +1,52 @@
 <?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.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAgeMapper">
-    <select id="queryPageLists" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily">
+    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
         select
-        *
-       from
-        ctop_kuaishou_audience_report_daily_province
+        SELECT
+        account_id,
+        age_segment,
+        SUM(charge) as charge,
+        SUM(activation) as activation,
+        SUM(event_next_day_stay) as eventNextDayStay,
+        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
+        FROM ctop_kuaishou_audience_report_daily_age t1
         where account_id = #{accountId}
-      </select>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY age_segment
+        <if test="orderType!= null">
+            ORDER BY #{orderType}
+        </if>
+        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
+            DESC
+        </if>
+    </select>
+
+
+    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        stat_date,
+        account_id,
+        age_segment,
+        SUM(photo_show) as photoShow,
+        SUM(photo_click) as photoClick,
+        SUM(aclick) as aclick,
+        SUM(bclick) as bclick,
+        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
+        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
+        FROM ctop_kuaishou_audience_report_daily_age t1
+        where account_id = #{accountId}
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY age_segment
+    </select>
 </mapper>

+ 46 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyBusinessMapper.xml

@@ -1,11 +1,51 @@
 <?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.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyBusinessMapper">
-    <select id="queryPageLists" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily">
-        select
-        *
-       from
-        ctop_kuaishou_audience_report_daily_province
+    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        account_id,
+        business_interest_tags,
+        SUM(charge) as charge,
+        SUM(activation) as activation,
+        SUM(event_next_day_stay) as eventNextDayStay,
+        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
+        FROM ctop_kuaishou_audience_report_daily_business t1
         where account_id = #{accountId}
-      </select>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY business_interest_tags
+        <if test="orderType!= null">
+            ORDER BY #{orderType}
+        </if>
+        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
+            DESC
+        </if>
+    </select>
+
+
+    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        stat_date,
+        account_id,
+        business_interest_tags,
+        SUM(photo_show) as photoShow,
+        SUM(photo_click) as photoClick,
+        SUM(aclick) as aclick,
+        SUM(bclick) as bclick,
+        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
+        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
+        FROM ctop_kuaishou_audience_report_daily_business t1
+        where account_id = #{accountId}
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY business_interest_tags
+    </select>
 </mapper>

+ 45 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyCityMapper.xml

@@ -1,11 +1,50 @@
 <?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.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyCityMapper">
-    <select id="queryPageLists" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily">
-        select
-        *
-       from
-        ctop_kuaishou_audience_report_daily_province
+    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        account_id,
+        city,
+        SUM(charge) as charge,
+        SUM(activation) as activation,
+        SUM(event_next_day_stay) as eventNextDayStay,
+        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
+        FROM ctop_kuaishou_audience_report_daily_city t1
         where account_id = #{accountId}
-      </select>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY city
+        <if test="orderType!= null">
+            ORDER BY #{orderType}
+        </if>
+        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
+            DESC
+        </if>
+    </select>
+
+    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        stat_date,
+        account_id,
+        city,
+        SUM(photo_show) as photoShow,
+        SUM(photo_click) as photoClick,
+        SUM(aclick) as aclick,
+        SUM(bclick) as bclick,
+        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
+        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
+        FROM ctop_kuaishou_audience_report_daily_city t1
+        where account_id = #{accountId}
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY city
+    </select>
 </mapper>

+ 45 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyClientMapper.xml

@@ -1,11 +1,50 @@
 <?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.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyClientMapper">
-    <select id="queryPageLists" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily">
-        select
-        *
-       from
-        ctop_kuaishou_audience_report_daily_province
+    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        account_id,
+        client,
+        SUM(charge) as charge,
+        SUM(activation) as activation,
+        SUM(event_next_day_stay) as eventNextDayStay,
+        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
+        FROM ctop_kuaishou_audience_report_daily_client t1
         where account_id = #{accountId}
-      </select>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY client
+        <if test="orderType!= null">
+            ORDER BY #{orderType}
+        </if>
+        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
+            DESC
+        </if>
+    </select>
+
+    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        stat_date,
+        account_id,
+        client,
+        SUM(photo_show) as photoShow,
+        SUM(photo_click) as photoClick,
+        SUM(aclick) as aclick,
+        SUM(bclick) as bclick,
+        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
+        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
+        FROM ctop_kuaishou_audience_report_daily_client t1
+        where account_id = #{accountId}
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY client
+    </select>
 </mapper>

+ 45 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyGenderMapper.xml

@@ -1,11 +1,50 @@
 <?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.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyGenderMapper">
-    <select id="queryPageLists" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily">
-        select
-        *
-       from
-        ctop_kuaishou_audience_report_daily_province
+    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        account_id,
+        gender,
+        SUM(charge) as charge,
+        SUM(activation) as activation,
+        SUM(event_next_day_stay) as eventNextDayStay,
+        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
+        FROM ctop_kuaishou_audience_report_daily_gender t1
         where account_id = #{accountId}
-      </select>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY gender
+        <if test="orderType!= null">
+            ORDER BY #{orderType}
+        </if>
+        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
+            DESC
+        </if>
+    </select>
+
+    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        stat_date,
+        account_id,
+        gender,
+        SUM(photo_show) as photoShow,
+        SUM(photo_click) as photoClick,
+        SUM(aclick) as aclick,
+        SUM(bclick) as bclick,
+        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
+        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
+        FROM ctop_kuaishou_audience_report_daily_gender t1
+        where account_id = #{accountId}
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY gender
+    </select>
 </mapper>

+ 45 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyProvinceMapper.xml

@@ -2,11 +2,50 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyProvinceMapper">
 
-    <select id="queryPageLists" resultType="cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily">
-        select
-        *
-       from
-        ctop_kuaishou_audience_report_daily_province
+    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        account_id,
+        province,
+        SUM(charge) as charge,
+        SUM(activation) as activation,
+        SUM(event_next_day_stay) as eventNextDayStay,
+        ROUND(SUM(event_next_day_stay)/SUM(activation)*100,2)as eventNextDayStayRatio
+        FROM ctop_kuaishou_audience_report_daily_province t1
         where account_id = #{accountId}
-      </select>
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY province
+        <if test="orderType!= null">
+            ORDER BY #{orderType}
+        </if>
+        <if test="upOrDown == 'desc' || upOrDown == 'DESC'">
+            DESC
+        </if>
+    </select>
+
+    <select id="queryAllReportForm" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        stat_date,
+        account_id,
+        province,
+        SUM(photo_show) as photoShow,
+        SUM(photo_click) as photoClick,
+        SUM(aclick) as aclick,
+        SUM(bclick) as bclick,
+        ROUND(SUM(photo_click)/SUM(photo_show)*100,2) as photoClickRatio,
+        ROUND(SUM(bclick)/SUM(aclick)*100,2) as actionRatio
+        FROM ctop_kuaishou_audience_report_daily_province t1
+        where account_id = #{accountId}
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        GROUP BY province
+    </select>
 </mapper>

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyAccountService extends IService<KuaishouAudienceReportDailyAccount> {
+
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyAgeService extends IService<KuaishouAudienceReportDailyAge> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBusiness;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyBusinessService extends IService<KuaishouAudienceReportDailyBusiness> {
+
+}

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

@@ -0,0 +1,13 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyCity;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyCityService extends IService<KuaishouAudienceReportDailyCity> {
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyClient;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyClientService extends IService<KuaishouAudienceReportDailyClient> {
+
+}

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

@@ -0,0 +1,17 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyGenderService extends IService<KuaishouAudienceReportDailyGender> {
+
+}

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

@@ -0,0 +1,14 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyProvince;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 人群分析报表
+ * @Author: jeecg-boot
+ * @Date: 2020-12-03
+ * @Version: V1.0
+ */
+public interface IKuaishouAudienceReportDailyProvinceService extends IService<KuaishouAudienceReportDailyProvince> {
+
+}

+ 13 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyService.java

@@ -2,7 +2,6 @@ package cn.com.ctop.kuaishou.modules.report.service;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 
@@ -24,12 +23,24 @@ public interface IKuaishouAudienceReportDailyService extends IService<KuaishouAu
     void crowdAnalysisReport(CtopOauthToken token, String date, String type, Long plan, Long unit, Integer page, Integer pageSize);
 
     /**
-     * 人群分析报表
+     * 查询人群分析报表
      *
      * @param
+     * @param no
+     * @param type
      * @return java.lang.Long
      * @throws
      * @author ZHAOXA
      */
     Result<Object> queryPageLists(KuaishouAudienceReportDaily audienceReport, Integer pageNo, Integer pageSize, String type);
+
+    /**
+     * 首页报表数据
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    Result<Object> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAccountMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAccountService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyAccountServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyAccountMapper, KuaishouAudienceReportDailyAccount> implements IKuaishouAudienceReportDailyAccountService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAgeMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAgeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyAgeServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyAgeMapper, KuaishouAudienceReportDailyAge> implements IKuaishouAudienceReportDailyAgeService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBusiness;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyBusinessMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyBusinessService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyBusinessServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyBusinessMapper, KuaishouAudienceReportDailyBusiness> implements IKuaishouAudienceReportDailyBusinessService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyCity;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyCityMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyCityService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyCityServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyCityMapper, KuaishouAudienceReportDailyCity> implements IKuaishouAudienceReportDailyCityService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyClient;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyClientMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyClientService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyClientServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyClientMapper, KuaishouAudienceReportDailyClient> implements IKuaishouAudienceReportDailyClientService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyGenderMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyGenderService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyGenderServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyGenderMapper, KuaishouAudienceReportDailyGender> implements IKuaishouAudienceReportDailyGenderService {
+
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyProvince;
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyProvinceMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyProvinceService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+/**
+ * 人群分析报表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-12-03
+ */
+@Slf4j
+@Service
+public class KuaishouAudienceReportDailyProvinceServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyProvinceMapper, KuaishouAudienceReportDailyProvince> implements IKuaishouAudienceReportDailyProvinceService {
+
+}

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

@@ -7,8 +7,9 @@ import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAccount;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
-import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBussiness;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBusiness;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyCity;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyClient;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyGender;
@@ -20,6 +21,13 @@ import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyCli
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyGenderMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyMapper;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyProvinceMapper;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAccountService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyAgeService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyBusinessService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyCityService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyClientService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyGenderService;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyProvinceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -28,9 +36,11 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -61,11 +71,25 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
     @Autowired
     private KuaishouAudienceReportDailyGenderMapper genderMapper;
     @Autowired
+    private IKuaishouAudienceReportDailyAccountService dailyAccountService;
+    @Autowired
+    private IKuaishouAudienceReportDailyProvinceService dailyProvinceService;
+    @Autowired
+    private IKuaishouAudienceReportDailyGenderService dailyGenderService;
+    @Autowired
+    private IKuaishouAudienceReportDailyClientService dailyClientService;
+    @Autowired
+    private IKuaishouAudienceReportDailyCityService dailyCityService;
+    @Autowired
+    private IKuaishouAudienceReportDailyBusinessService dailyBusinessService;
+    @Autowired
+    private IKuaishouAudienceReportDailyAgeService dailyAgeService;
+    @Autowired
     private ICtopOauthTokenService tokenService;
     private String urlPath = PropertiesUtils.getConfig("kuaishou_api_url");
 
     /**
-     * 报表分页查询
+     * 报表分页分页查询
      *
      * @param type province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
      * @return org.jeecg.common.api.vo.Result<java.lang.Object>
@@ -80,7 +104,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
         if (null == pageSize || pageSize == 0) {
             pageSize = 10;
         }
-        List<KuaishouAudienceReportDaily> list = null;
+        List<JSONObject> list = null;
         PageHelper.startPage(pageNo, pageSize);
         if ("province".equals(type)) {
             list = provinceMapper.queryPageLists(audienceReport);
@@ -97,11 +121,51 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
         } else {
             return Result.error("请选择人群报表类型");
         }
-        PageInfo<KuaishouAudienceReportDaily> pageInfo = new PageInfo<>(list);
+        if (Check.isNull(list)) {
+            return Result.error("只能获取到两天前的数据,请正确选择时间");
+        }
+        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
         return Result.ok(pageInfo);
     }
 
     /**
+     * 首页报表数据
+     *
+     * @param type province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    @Override
+    public Result<Object> queryAllReportForm(KuaishouAudienceReportDaily audienceReport) {
+        JSONObject data = new JSONObject();
+        List<JSONObject> provinces = provinceMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(provinces)) {
+            data.put("province", provinces);
+        }
+        List<JSONObject> genders = genderMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(genders)) {
+            data.put("gender", genders);
+        }
+        List<JSONObject> ages = ageMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(ages)) {
+            data.put("ageSegment", ages);
+        }
+        List<JSONObject> clients = clientMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(clients)) {
+            data.put("client", clients);
+        }
+        List<JSONObject> bussiness = bussinessMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(bussiness)) {
+            data.put("businessInterestTags", bussiness);
+        }
+        if (data.size() == 0) {
+            return Result.error("只能获取到两天前的数据,请正确选择时间");
+        }
+        return Result.ok(data);
+    }
+
+    /**
      * 人群分析报表入库
      *
      * @param type      province: 省级地域分布, city: 地级地域分布,gender: 性别分布,ageSegment: 年龄分布clientId: 系统分布 businessInterestTags: 商业兴趣分布
@@ -143,20 +207,32 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                     JSONObject datas = resultJson.getJSONObject("data");
                     JSONArray details = datas.getJSONArray("details");
                     if (!Check.isNull(details)) {
-                        for (int i = 0; i < details.size(); i++) {
-                            JSONObject obj = details.getJSONObject(i);
-                            if ("province".equals(type)) {
-                                KuaishouAudienceReportDailyProvince entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyProvince.class);
+                        //账户级数据
+                        if (Check.isNull(plan) && Check.isNull(unit)) {
+                            List<KuaishouAudienceReportDailyAccount> list = new ArrayList<>();
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject obj = details.getJSONObject(i);
+                                KuaishouAudienceReportDailyAccount entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyAccount.class);
                                 entity.setPhotoLike(obj.getLong("like"));
                                 entity.setComments(obj.getLong("comment"));
                                 entity.setPhotoShow(obj.getLong("show"));
                                 entity.setShares(obj.getString("share"));
                                 entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                provinceMapper.insert(entity);
-                            } else if ("city".equals(type)) {
-                                KuaishouAudienceReportDailyCity entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyCity.class);
+                                entity.setAudienceType(type);
+                                list.add(entity);
+                            }
+                            dailyAccountService.saveBatch(list);
+                        } else {
+                            List<KuaishouAudienceReportDailyProvince> provinceList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyCity> cityList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyGender> genderList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyAge> ageList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyClient> clientList = new ArrayList<>();
+                            List<KuaishouAudienceReportDailyBusiness> businessList = new ArrayList<>();
+                            //组级
+                            for (int i = 0; i < details.size(); i++) {
+                                JSONObject obj = details.getJSONObject(i);
+                                KuaishouAudienceReportDaily entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDaily.class);
                                 entity.setPhotoLike(obj.getLong("like"));
                                 entity.setComments(obj.getLong("comment"));
                                 entity.setPhotoShow(obj.getLong("show"));
@@ -164,47 +240,44 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                                 entity.setAccountId(Long.valueOf(token.getAccountId()));
                                 entity.setPlanId(plan);
                                 entity.setUnitId(unit);
-                                cityMapper.insert(entity);
+                                if ("province".equals(type)) {
+                                    KuaishouAudienceReportDailyProvince provinceEntity = new KuaishouAudienceReportDailyProvince();
+                                    BeanUtils.copyProperties(entity, provinceEntity);
+                                    provinceList.add(provinceEntity);
+                                } else if ("city".equals(type)) {
+                                    KuaishouAudienceReportDailyCity cityEntity = new KuaishouAudienceReportDailyCity();
+                                    BeanUtils.copyProperties(entity, cityEntity);
+                                    cityList.add(cityEntity);
+                                } else if ("gender".equals(type)) {
+                                    KuaishouAudienceReportDailyGender genderEntity = new KuaishouAudienceReportDailyGender();
+                                    BeanUtils.copyProperties(entity, genderEntity);
+                                    genderList.add(genderEntity);
+                                } else if ("ageSegment".equals(type)) {
+                                    KuaishouAudienceReportDailyAge ageEntity = new KuaishouAudienceReportDailyAge();
+                                    BeanUtils.copyProperties(entity, ageEntity);
+                                    ageList.add(ageEntity);
+                                } else if ("clientId".equals(type)) {
+                                    KuaishouAudienceReportDailyClient clientEntity = new KuaishouAudienceReportDailyClient();
+                                    BeanUtils.copyProperties(entity, clientEntity);
+                                    clientList.add(clientEntity);
+                                } else if ("businessInterestTags".equals(type)) {
+                                    KuaishouAudienceReportDailyBusiness bussinessEntity = new KuaishouAudienceReportDailyBusiness();
+                                    BeanUtils.copyProperties(entity, bussinessEntity);
+                                    businessList.add(bussinessEntity);
+                                }
+                            }
+                            if ("province".equals(type)) {
+                                dailyProvinceService.saveBatch(provinceList);
+                            } else if ("city".equals(type)) {
+                                dailyCityService.saveBatch(cityList);
                             } else if ("gender".equals(type)) {
-                                KuaishouAudienceReportDailyGender entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyGender.class);
-                                entity.setPhotoLike(obj.getLong("like"));
-                                entity.setComments(obj.getLong("comment"));
-                                entity.setPhotoShow(obj.getLong("show"));
-                                entity.setShares(obj.getString("share"));
-                                entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                genderMapper.insert(entity);
+                                dailyGenderService.saveBatch(genderList);
                             } else if ("ageSegment".equals(type)) {
-                                KuaishouAudienceReportDailyAge entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyAge.class);
-                                entity.setPhotoLike(obj.getLong("like"));
-                                entity.setComments(obj.getLong("comment"));
-                                entity.setPhotoShow(obj.getLong("show"));
-                                entity.setShares(obj.getString("share"));
-                                entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                ageMapper.insert(entity);
+                                dailyAgeService.saveBatch(ageList);
                             } else if ("clientId".equals(type)) {
-                                KuaishouAudienceReportDailyClient entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyClient.class);
-                                entity.setPhotoLike(obj.getLong("like"));
-                                entity.setComments(obj.getLong("comment"));
-                                entity.setPhotoShow(obj.getLong("show"));
-                                entity.setShares(obj.getString("share"));
-                                entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                clientMapper.insert(entity);
+                                dailyClientService.saveBatch(clientList);
                             } else if ("businessInterestTags".equals(type)) {
-                                KuaishouAudienceReportDailyBussiness entity = JSONObject.toJavaObject(obj, KuaishouAudienceReportDailyBussiness.class);
-                                entity.setPhotoLike(obj.getLong("like"));
-                                entity.setComments(obj.getLong("comment"));
-                                entity.setPhotoShow(obj.getLong("show"));
-                                entity.setShares(obj.getString("share"));
-                                entity.setAccountId(Long.valueOf(token.getAccountId()));
-                                entity.setPlanId(plan);
-                                entity.setUnitId(unit);
-                                bussinessMapper.insert(entity);
+                                dailyBusinessService.saveBatch(businessList);
                             }
                         }
                     }

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

@@ -88,9 +88,9 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
         ChromeOptions chromeOptions = new ChromeOptions();
 //        chromeOptions.addArguments("--headless");
 //        chromeOptions.addArguments("--no-sandbox");
-//        chromeOptions.addArguments("--disable-dev-shm-usage");
-//        chromeOptions.addArguments("--incognito");
-//        chromeOptions.addArguments("--disable-gpu");
+        chromeOptions.addArguments("--disable-dev-shm-usage");
+        chromeOptions.addArguments("--incognito");
+        chromeOptions.addArguments("--disable-gpu");
         chromeOptions.addArguments("--window-size=1920,1080");
         chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
         chromeOptions.setAcceptInsecureCerts(true);
@@ -102,12 +102,12 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
             //获取登录页面
             webDriver.get(url);
             Thread.sleep(3000L);
-            WebElement accountElement = webDriver.findElement(By.xpath("//div[@class='phone ']/input[@type='text']"));
+            WebElement accountElement = webDriver.findElement(By.xpath("//div[contains(@class,'component-input-container')]/input[@type='text']"));
             accountElement.sendKeys("17718376864");
             Thread.sleep(3000L);
-            WebElement passwordElement = webDriver.findElement(By.xpath("//div[@class='password ']/input[@type='password']"));
+            WebElement passwordElement = webDriver.findElement(By.xpath("//div[contains(@class,'component-input-container')]/input[@type='password']"));
             passwordElement.sendKeys("yehcbost85567");
-            WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='foot']"));
+            WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='btn-container']/button[contains(@class,'submit')]"));
             Thread.sleep(3000L);
             //点击登录
             loginElement.click();

+ 1 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouVideoEtlInfoServiceImpl.java

@@ -122,7 +122,6 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
                             etlInfo.setUpdateTime(new Date());
                             this.save(etlInfo);
                         }else{
-                            BigDecimal totalCost = etlInfo.getTotalCost();
                             //只需要更新汇总数据
                             etlInfo.setTotalCost(nowData.getCharge());
                             etlInfo.setAclick(nowData.getAclick());
@@ -130,6 +129,7 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
                             etlInfo.setPhotoClick(nowData.getPhotoClick());
                             etlInfo.setPhotoShow(nowData.getPhotoShow());
                             etlInfo.setUpdateTime(new Date());
+                            BigDecimal totalCost = etlInfo.getTotalCost();
                             //计算投放总天数
                             if(days == 7){
                                 etlInfo.setSingleWeekCost(nowData.getCharge());
@@ -175,8 +175,6 @@ public class KuaishouVideoEtlInfoServiceImpl extends ServiceImpl<KuaishouVideoEt
 
     @Autowired
     private IMaterialAscriptionService materialAscriptionService;
-    @Autowired
-    private IMaterialInfoService materialInfoService;
     @Override
     public KuaishouVideoEtlInfo getBySignature(String signature) {
         QueryWrapper<KuaishouVideoEtlInfo> queryWrapper = new QueryWrapper<>();

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

@@ -0,0 +1,150 @@
+package cn.com.ctop.toutiao.modules.report.controller;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
+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.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+ /**
+ * 头条视频数据清洗信息
+ * @author jeecg-boot
+ * @date   2020-12-21
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="头条视频数据清洗信息")
+@RestController
+@RequestMapping("/ctop/bytedanceVideoEtlInfo")
+public class BytedanceVideoEtlInfoController {
+	@Autowired
+	private IBytedanceVideoEtlInfoService bytedanceVideoEtlInfoService;
+
+	/**
+	  * 分页列表查询
+	 * @param bytedanceVideoEtlInfo
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-分页列表查询", notes="头条视频数据清洗信息-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<BytedanceVideoEtlInfo>> queryPageList(BytedanceVideoEtlInfo bytedanceVideoEtlInfo,
+															  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+															  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+															  HttpServletRequest req) {
+		Result<IPage<BytedanceVideoEtlInfo>> result = new Result<>();
+		QueryWrapper<BytedanceVideoEtlInfo> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceVideoEtlInfo, req.getParameterMap());
+		Page<BytedanceVideoEtlInfo> page = new Page<BytedanceVideoEtlInfo>(pageNo, pageSize);
+		IPage<BytedanceVideoEtlInfo> pageList = bytedanceVideoEtlInfoService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param bytedanceVideoEtlInfo
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-添加", notes="头条视频数据清洗信息-添加")
+	@PostMapping(value = "/add")
+	public Result<BytedanceVideoEtlInfo> add(@RequestBody BytedanceVideoEtlInfo bytedanceVideoEtlInfo) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		try {
+			bytedanceVideoEtlInfoService.save(bytedanceVideoEtlInfo);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param bytedanceVideoEtlInfo
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-编辑", notes="头条视频数据清洗信息-编辑")
+	@PutMapping(value = "/edit")
+	public Result<BytedanceVideoEtlInfo> edit(@RequestBody BytedanceVideoEtlInfo bytedanceVideoEtlInfo) {
+		Result<BytedanceVideoEtlInfo> result = new Result<BytedanceVideoEtlInfo>();
+		BytedanceVideoEtlInfo bytedanceVideoEtlInfoEntity = bytedanceVideoEtlInfoService.getById(bytedanceVideoEtlInfo.getId());
+		if(bytedanceVideoEtlInfoEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = bytedanceVideoEtlInfoService.updateById(bytedanceVideoEtlInfo);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-通过id删除", notes="头条视频数据清洗信息-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			bytedanceVideoEtlInfoService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-批量删除", notes="头条视频数据清洗信息-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<BytedanceVideoEtlInfo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.bytedanceVideoEtlInfoService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@ApiOperation(value="头条视频数据清洗信息-通过id查询", notes="头条视频数据清洗信息-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<BytedanceVideoEtlInfo> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<BytedanceVideoEtlInfo> result = new Result<>();
+		BytedanceVideoEtlInfo bytedanceVideoEtlInfo = bytedanceVideoEtlInfoService.getById(id);
+		if(bytedanceVideoEtlInfo==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(bytedanceVideoEtlInfo);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

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

@@ -0,0 +1,74 @@
+package cn.com.ctop.toutiao.modules.report.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 头条视频数据清洗信息
+ * @author jeecg-boot
+ * @date   2020-12-21
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_bytedance_video_etl_info")
+public class BytedanceVideoEtlInfo {
+
+	/**id*/
+	@TableId(type = IdType.AUTO)
+	private Long id;
+	/**视频唯一标识*/
+	private String videoCode;
+	/**初次产生消耗时间*/
+	private String stateDate;
+	/**url*/
+	private String url;
+	/**coverUrl*/
+	private String coverUrl;
+	/**companyName*/
+	private String companyName;
+	/**planId*/
+	private String planId;
+	/**planName*/
+	private String planName;
+	/**clipId*/
+	private String clipId;
+	/**clipName*/
+	private String clipName;
+	/**shotId*/
+	private String shotId;
+	/**shotName*/
+	private String shotName;
+	/**singleWeekCost*/
+	private BigDecimal singleWeekCost;
+	/**twoWeekCost*/
+	private BigDecimal twoWeekCost;
+	/**fourWeekCost*/
+	private BigDecimal fourWeekCost;
+	/**总消耗*/
+	private BigDecimal totalCost;
+	/**clickNum*/
+	private Long clickNum;
+	/**showNum*/
+	private Long showNum;
+	/**activeNum*/
+	private Long activeNum;
+	/**convertNum*/
+	private Long convertNum;
+	/**createTime*/
+	private Date createTime;
+	/**updateTime*/
+	private Date updateTime;
+	/**effectDate*/
+	private String effectDate;
+	/**faddishDate*/
+	private String faddishDate;
+	/**effectDayNum*/
+	private Integer effectDayNum;
+	/**faddishDayNum*/
+	private Integer faddishDayNum;
+}

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

@@ -6,6 +6,7 @@ import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialRetry;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportVideoMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -58,4 +59,8 @@ public interface BytedanceReportMaterialDailyMapper extends BaseMapper<Bytedance
                                                               @Param("code")String code,
                                                               @Param("order")String order,
                                                               @Param("target")String target);
+
+    List<BytedanceVideoEtlInfo> getSignatureByDate(@Param(value = "date") String date);
+
+    BytedanceVideoEtlInfo getEtlDataByParams(@Param("signature")String signature, @Param("date")String date);
 }

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

@@ -0,0 +1,16 @@
+package cn.com.ctop.toutiao.modules.report.mapper;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 头条视频数据清洗信息
+ * @author: jeecg-boot
+ * @date:   2020-12-21
+ * @cersion: V1.0
+ */
+public interface BytedanceVideoEtlInfoMapper extends BaseMapper<BytedanceVideoEtlInfo> {
+
+    BytedanceVideoEtlInfo getBySignature(@Param(value = "signature") String signature);
+}

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

@@ -416,6 +416,40 @@ where a.plane_id is not null and a.plane_name is null
         </if>
         group by report.material_id)a order by a.${target} ${order}
     </select>
+    <select id="getSignatureByDate"
+            resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo">
+        select
+            distinct signature as 'video_code'
+        from
+        ctop_bytedance_report_material_daily report
+        left join ctop_bytedance_video_info video on video.material_id = report.material_id and video.account_id = report.account_id
+        where
+            video.signature is not null
+        and
+            video.signature != ''
+        and
+            report.stat_datetime = #{date}
+    </select>
+    <select id="getEtlDataByParams"
+            resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo">
+        select
+        video.signature as 'video_code',
+        '' as cover_url,
+        video.video_url as url,
+        min(report.stat_datetime)as 'state_date',
+        sum(report.cost)as 'total_cost',
+        sum(report.click)as 'click_num',
+        sum(report.active)as 'active_num',
+        sum(report.show_material)as 'show_num',
+        sum(report.convert_material)as 'convert_num'
+        from ctop_bytedance_report_material_daily report
+        left join ctop_bytedance_video_info video on report.account_id = video.account_id and video.material_id = report.material_id
+        where
+            video.signature = #{signature}
+        and
+            report.stat_datetime&lt;= #{date}
+        group by video.signature;
+    </select>
 
     <insert id="replaceIntoVideoMaterialBatch">
         REPLACE INTO ctop_bytedance_report_video_material_daily

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

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.BytedanceVideoEtlInfoMapper">
+
+    <select id="getBySignature" resultType="cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo">
+
+    </select>
+</mapper>

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

@@ -2,6 +2,7 @@ package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -15,4 +16,7 @@ import java.util.List;
 public interface IBytedanceReportMaterialDailyService extends IService<BytedanceReportMaterialDaily> {
     List<BytedanceReportMaterialDaily> getListByParams(String date);
     List<BytedanceVideoVo> getVideoVoByDate(String date);
+    List<BytedanceVideoEtlInfo> getSignatureByDate(String date);
+
+    BytedanceVideoEtlInfo getEtlDataByParams(String signature, String date);
 }

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

@@ -0,0 +1,18 @@
+package cn.com.ctop.toutiao.modules.report.service;
+
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.Date;
+
+/**
+ * @Description: 头条视频数据清洗信息
+ * @Author: jeecg-boot
+ * @Date:   2020-12-21
+ * @Version: V1.0
+ */
+public interface IBytedanceVideoEtlInfoService extends IService<BytedanceVideoEtlInfo> {
+    void etlBytedanceVideoInfo(Date date);
+
+    BytedanceVideoEtlInfo getBySignature(String signature);
+}

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

@@ -2,6 +2,7 @@ package cn.com.ctop.toutiao.modules.report.service.impl;
 
 import cn.com.ctop.toutiao.modules.material.vo.BytedanceVideoVo;
 import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportMaterialDailyService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -39,5 +40,15 @@ public class BytedanceReportMaterialDailyServiceImpl extends ServiceImpl<Bytedan
         return bytedanceReportMaterialDailyMapper.getVideoVoByDate(date);
     }
 
+    @Override
+    public List<BytedanceVideoEtlInfo> getSignatureByDate(String date) {
+        return bytedanceReportMaterialDailyMapper.getSignatureByDate(date);
+    }
+
+    @Override
+    public BytedanceVideoEtlInfo getEtlDataByParams(String signature, String date) {
+        return bytedanceReportMaterialDailyMapper.getEtlDataByParams(signature,date);
+    }
+
 
 }

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

@@ -0,0 +1,179 @@
+package cn.com.ctop.toutiao.modules.report.service.impl;
+
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
+import cn.com.ctop.common.module.service.IMaterialAscriptionService;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceReportMaterialDaily;
+import cn.com.ctop.toutiao.modules.report.entity.BytedanceVideoEtlInfo;
+import cn.com.ctop.toutiao.modules.report.mapper.BytedanceVideoEtlInfoMapper;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportMaterialDailyService;
+import cn.com.ctop.toutiao.modules.report.service.IBytedanceVideoEtlInfoService;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * 头条视频数据清洗信息
+ * @author jeecg-boot
+ * @date   2020-12-21
+ * @version V1.0
+ */
+@Slf4j
+@Service
+public class BytedanceVideoEtlInfoServiceImpl extends ServiceImpl<BytedanceVideoEtlInfoMapper, BytedanceVideoEtlInfo> implements IBytedanceVideoEtlInfoService {
+    @Autowired
+    private IBytedanceReportMaterialDailyService materialDailyService;
+    @Autowired
+    private UserAllocationMapper userAllocationMapper;
+    static ExecutorService executorService = Executors.newFixedThreadPool(50);
+    @Autowired
+    private IMaterialAscriptionService materialAscriptionService;
+    @Override
+    public void etlBytedanceVideoInfo(Date getDate) {
+        String date = DateUtils.formatDate(getDate);
+        //1:查询单当日视频信息
+        List<BytedanceVideoEtlInfo> materials = materialDailyService.getSignatureByDate(date);
+        if(null!=materials&&!materials.isEmpty()){
+            CountDownLatch countDownLatch= new CountDownLatch(materials.size());
+            materials.forEach(material->{
+                executorService.submit(()->{
+                    try {
+                        if(null == material.getVideoCode()||material.getVideoCode().trim().equals("")){
+                            return;
+                        }
+                        String signature = material.getVideoCode();
+                        BytedanceVideoEtlInfo etlInfo = this.getBySignature(signature);
+                        BytedanceVideoEtlInfo nowData = materialDailyService.getEtlDataByParams(signature,date);
+                        String minDate = nowData.getStateDate();
+                        Integer days = DateUtils.getdaysOfTwoDate(minDate,date);
+                        if(null == etlInfo){
+                            //第一次查询的数据
+                            etlInfo = nowData;
+                            BigDecimal totalCost = etlInfo.getTotalCost();
+                            JSONObject ascription =  materialAscriptionService.getDetailByCode(signature);
+                            String planId = null;
+                            if(null!=ascription){
+                                planId = ascription.getString("planId");
+                                if(null!=planId&&!planId.trim().equals("")){
+                                    etlInfo.setPlanId(planId);
+                                }
+                                String planName =  ascription.getString("planName");
+                                if(null!=planName&&!planName.trim().equals("")){
+                                    etlInfo.setPlanName(planName);
+                                }
+                                String clipId = ascription.getString("clipId");
+                                if(null!=clipId&&!clipId.trim().equals("")){
+                                    etlInfo.setClipId(clipId);
+                                }
+                                String clipName = ascription.getString("clipName");
+                                if(null!=clipName&&!clipName.trim().equals("")){
+                                    etlInfo.setClipName(clipName);
+                                }
+                                String shotId = ascription.getString("shotId");
+                                if(null!=shotId&&!shotId.trim().equals("")){
+                                    etlInfo.setShotId(shotId);
+                                }
+                                String shotName = ascription.getString("shotName");
+                                if(null!=shotName&&!shotName.trim().equals("")){
+                                    etlInfo.setShotName(shotName);
+                                }
+                            }
+                            if(null!=planId){
+                                String companyName = userAllocationMapper.getCompanyNameByUserId(planId);
+                                if (null!=companyName&&!companyName.trim().equals("")){
+                                    etlInfo.setCompanyName(companyName);
+                                }
+                            }
+                            //计算投放总天数
+                            if(days == 7){
+                                etlInfo.setSingleWeekCost(nowData.getTotalCost());
+                            }
+                            if(days == 14){
+                                etlInfo.setTwoWeekCost(nowData.getTotalCost());
+                            }
+                            if(days == 28){
+                                etlInfo.setFourWeekCost(nowData.getTotalCost());
+                            }
+                            //计算是否有效,爆款
+                            if(totalCost.compareTo(new BigDecimal("5000"))>0){
+                                //此刻成为有效
+                                etlInfo.setEffectDate(date);
+                                etlInfo.setEffectDayNum(days);
+                            }
+                            if(totalCost.compareTo(new BigDecimal("100000"))>0){
+                                //此刻成为爆款
+                                etlInfo.setEffectDate(date);
+                                etlInfo.setEffectDayNum(days);
+                            }
+                            etlInfo.setCreateTime(new Date());
+                            etlInfo.setUpdateTime(new Date());
+                            this.save(etlInfo);
+                        }else{
+                            //只需要更新汇总数据
+                            etlInfo.setTotalCost(nowData.getTotalCost());
+                            BigDecimal totalCost = etlInfo.getTotalCost();
+                            etlInfo.setClickNum(nowData.getClickNum());
+                            etlInfo.setShowNum(nowData.getShowNum());
+                            etlInfo.setActiveNum(nowData.getActiveNum());
+                            etlInfo.setConvertNum(nowData.getConvertNum());
+                            etlInfo.setUpdateTime(new Date());
+                            //计算投放总天数
+                            if(days == 7){
+                                etlInfo.setSingleWeekCost(nowData.getTotalCost());
+                            }
+                            if(days == 14){
+                                etlInfo.setTwoWeekCost(nowData.getTotalCost());
+                            }
+                            if(days == 28){
+                                etlInfo.setFourWeekCost(nowData.getTotalCost());
+                            }
+                            if(null == etlInfo.getEffectDayNum()){
+                                if(totalCost.compareTo(new BigDecimal("5000"))>0){
+                                    //此刻成为有效
+                                    etlInfo.setEffectDate(date);
+                                    etlInfo.setEffectDayNum(days);
+                                }
+                            }
+                            if(null == etlInfo.getFaddishDayNum()){
+                                if(totalCost.compareTo(new BigDecimal("100000"))>0){
+                                    //此刻成为爆款
+                                    etlInfo.setEffectDate(date);
+                                    etlInfo.setEffectDayNum(days);
+                                }
+                            }
+                            this.updateById(etlInfo);
+                        }
+                    }catch (Exception e){
+
+                    }finally {
+                        countDownLatch.countDown();
+                    }
+                });
+            });
+
+            try {
+                countDownLatch.await();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+            log.info("{}数据获取完成",date);
+        }
+    }
+
+    @Override
+    public BytedanceVideoEtlInfo getBySignature(String signature) {
+        QueryWrapper<BytedanceVideoEtlInfo> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("video_code",signature).last("limit 1");
+        return this.getOne(queryWrapper);
+    }
+}