Просмотр исходного кода

异步批量复制+人群报表视图数据

zhaoxian 4 лет назад
Родитель
Сommit
4443a24654
22 измененных файлов с 477 добавлено и 653 удалено
  1. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouCampaignCopyDataService.java
  2. 0 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java
  3. 259 232
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouCampaignCopyDataServiceImpl.java
  4. 8 4
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouAudienceReportDailyController.java
  5. 6 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyAccountMapper.java
  6. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyAgeMapper.java
  7. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyBusinessMapper.java
  8. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyCityMapper.java
  9. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyClientMapper.java
  10. 0 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyGenderMapper.java
  11. 0 7
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/KuaishouAudienceReportDailyProvinceMapper.java
  12. 108 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyAccountMapper.xml
  13. 0 47
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyAgeMapper.xml
  14. 0 46
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyBusinessMapper.xml
  15. 2 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyCityMapper.xml
  16. 0 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyClientMapper.xml
  17. 0 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyGenderMapper.xml
  18. 0 45
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouAudienceReportDailyProvinceMapper.xml
  19. 20 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyAccountService.java
  20. 0 21
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouAudienceReportDailyService.java
  21. 73 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyAccountServiceImpl.java
  22. 0 77
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java

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

@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaishouCampaignCopyDataService extends IService<KuaishouCampaignCopyData> {
 
+    void batchCopyCampaign();
 }

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

@@ -354,7 +354,6 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
                         }
                     }
 
-
                     KuaiShouGroup group = new KuaiShouGroup();
                     group.setId("" + advertiserId + unitId);
                     group.setAccountId(advertiserId);

+ 259 - 232
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouCampaignCopyDataServiceImpl.java

@@ -66,6 +66,7 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
      * @throws
      * @author ZHAOXA
      */
+    @Override
     public void batchCopyCampaign() {
         Map<String, Object> map = new HashMap<>();
         //'状态:1待复制,2成功,3失败'
@@ -75,17 +76,20 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
             try {
                 CtopOauthToken token = tokenService.getTokenByAccountId(copyData.getAccountId());
                 //执行删除被复制的计划组+创意
-                delOldCampaigns(copyData.getAccountId(), copyData.getNewCampaignId());
+                delOldCampaigns(copyData.getAccountId(), copyData.getOldCampaignId());
                 //获取当前最新广告计划组、创意数据并入库
                 JSONObject data = getNewCampaigns(token.getAccessToken(), copyData);
                 data.put("copyData", copyData);
                 //根据被复制的组数据和模板、预算和排期数据调用快手创建组接口
                 createCopyUnits(token, data);
+                //更新成功,修改状态并发送通知
+                updateState(copyData.getId(), NoEn.NO2.valueStr(), "复制成功");
+                sendNotification(copyData.getOldCampaignName(), copyData.getCreaterId(), NoEn.NO2.valueStr());
             } catch (Exception e) {
                 log.error("复制广告计划异常", e);
-                //复制过程中失败,更新状态并发送通知
+                //复制过程中失败,更新状态并发送预警
                 updateState(copyData.getId(), NoEn.NO3.valueStr(), e.getMessage());
-                sendNotification(copyData, NoEn.NO3.valueStr());
+                sendNotification(copyData.getOldCampaignName(), copyData.getCreaterId(), NoEn.NO3.valueStr());
             }
 
 
@@ -130,7 +134,7 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
             if (Check.isNull(kuaiShouGroups)) {
                 //获取广告组失败,更新状态并发送通知
                 updateState(copyData.getId(), NoEn.NO3.valueStr(), "被复制的计划更新广告组失败");
-                sendNotification(copyData, NoEn.NO3.valueStr());
+                sendNotification(copyData.getOldCampaignName(), copyData.getCreaterId(), NoEn.NO3.valueStr());
             }
             for (KuaiShouGroup kuaiShouGroup : kuaiShouGroups) {
                 kuaiShouGroup.setTarget(kuaiShouGroupTargetService.queryTargetInfoByunitId(copyData.getAccountId(), kuaiShouGroup.getUnitId()));
@@ -155,264 +159,286 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
      * @author ZHAOXA
      */
     private void createCopyUnits(CtopOauthToken token, JSONObject data) throws Exception {
-        JSONArray groups = data.getJSONArray("groups");
-        JSONObject copyData = data.getJSONObject("copyData");
-        for (int i = 0; i < groups.size(); i++) {
-            JSONObject group = groups.getJSONObject(i);
-            JSONObject unitJson = new JSONObject();
-            unitJson.put("campaign_id", group.getLong("campaignId"));
-            // 资源位置
-            JSONArray scene_id = copyData.getJSONArray("sceneId");
-            if (Check.isNull(scene_id) || scene_id.size() == 0) {
-                scene_id = group.getJSONArray("sceneId");
-            }
-            unitJson.put("scene_id", scene_id);
-            // 资源创作方式
-            unitJson.put("unit_type", group.getInteger("unitType"));
-            // 转化目标id
-            unitJson.put("convert_id", group.getInteger("convertId"));
-
-            // 优先从系统应用商店下载
-            unitJson.put("use_app_market", group.getInteger("useAppMarket"));
-
-            // 应用商店列表
-            unitJson.put("app_store", group.getJSONArray("appStore"));
-
-            //投放开始时间
-            String beginTime = copyData.getString("beginTime");
-            if (Check.isNull(beginTime)) {
-                beginTime = group.getString("beginTime");
-            }
-            String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-            boolean beginTimeBoolean = DateUtils.compare(beginTime, nowDate);
-            if (beginTimeBoolean) {
-                unitJson.put("begin_time", nowDate);
-            } else {
-                unitJson.put("begin_time", beginTime);
-            }
-            // 投放结束时间
-            String endTime = copyData.getString("endTime");
-            if (Check.isNull(endTime)) {
-                endTime = group.getString("endTime");
-            }
-            unitJson.put("end_time", endTime);
-            // 投放时间段
-            String scheduleTime = copyData.getString("scheduleTime");
-            if (Check.isNull(scheduleTime)) {
-                scheduleTime = group.getString("scheduleTime");
-            }
-            unitJson.put("schedule_time", scheduleTime);
-            // 广告组单日预算
-            Long dayBudget = copyData.getLong("dayBudget");
-            if (Check.isNull(dayBudget)) {
-                dayBudget = group.getLong("dayBudget");
-            }
-            unitJson.put("day_budget", dayBudget);
-            // url类型
-            unitJson.put("url_type", group.getInteger("urlType"));
-            // url
-            unitJson.put("url", group.getString("url"));
-            // appId
-            unitJson.put("app_id", group.getLong("appId"));
-            // 创意展现方式
-            unitJson.put("show_mode", group.getInteger("showMode"));
-            //投放方式
-            Integer speed = copyData.getInteger("speed");
-            if (Check.isNull(speed)) {
-                speed = group.getInteger("speed");
-            }
-            unitJson.put("speed", speed);
+        try {
+            JSONArray groups = data.getJSONArray("groups");
+            JSONObject copyData = data.getJSONObject("copyData");
+            for (int i = 0; i < groups.size(); i++) {
+                JSONObject group = groups.getJSONObject(i);
+                JSONObject unitJson = new JSONObject();
+                unitJson.put("campaign_id", copyData.getLong("newCampaignId"));
+                // 资源位置
+                JSONArray scene_id = copyData.getJSONArray("sceneId");
+                if (Check.isNull(scene_id) || scene_id.size() == 0) {
+                    scene_id = group.getJSONArray("sceneId");
+                }
+                unitJson.put("scene_id", scene_id);
+                // 资源创作方式
+                unitJson.put("unit_type", group.getInteger("unitType"));
+                // 转化目标id
+                unitJson.put("convert_id", group.getInteger("convertId"));
 
-            String templateId = copyData.getString("templateId");
-            if (!Check.isNull(templateId)) {
-                unitJson.put("template_id", templateId);
-            } else {
-                /*----------------用户定向-----------*/
-                JSONObject target = group.getJSONObject("target");
-                JSONObject targetJson = new JSONObject();
-                // 地域
-                targetJson.put("region", target.getJSONArray("region"));
+                // 优先从系统应用商店下载
+                unitJson.put("use_app_market", group.getInteger("useAppMarket"));
 
-                // 自定义年龄段
+                // 应用商店列表
+                unitJson.put("app_store", group.getJSONArray("appStore"));
 
-                if (!Check.isNull(target.getInteger("ageMax")) && !Check.isNull(target.getInteger("ageMin"))) {
-                    JSONObject ageJson = new JSONObject();
-                    ageJson.put("min", target.getInteger("ageMin"));
-                    ageJson.put("max", target.getInteger("ageMax"));
-                    targetJson.put("age", ageJson);
+                //投放开始时间
+                String beginTime = copyData.getString("beginTime");
+                if (Check.isNull(beginTime)) {
+                    beginTime = group.getString("beginTime");
                 }
-                // 固定年龄段
-                if (!Check.isNull(target.getJSONArray("agesRange"))) {
-                    targetJson.put("ages_range", target.getJSONArray("agesRange"));
+                String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+                boolean beginTimeBoolean = DateUtils.compare(beginTime, nowDate);
+                if (beginTimeBoolean) {
+                    unitJson.put("begin_time", nowDate);
+                } else {
+                    unitJson.put("begin_time", beginTime);
                 }
-                // 性别
-                if (!Check.isNull(target.getInteger("gender"))) {
-                    targetJson.put("gender", target.getInteger("gender"));
+                // 投放结束时间
+                String endTime = copyData.getString("endTime");
+                if (Check.isNull(endTime)) {
+                    endTime = group.getString("endTime");
                 }
-                //操作系统
-                if (!Check.isNull(target.getInteger("platformOs"))) {
-                    targetJson.put("platform_os", target.getInteger("platformOs"));
+                if (!Check.isNull(endTime)) {
+                    unitJson.put("end_time", endTime);
                 }
-                //Android版本
-                if (!Check.isNull(target.getInteger("androidOsv"))) {
-                    targetJson.put("android_osv", target.getInteger("androidOsv"));
+                // 投放时间段
+                String scheduleTime = copyData.getString("scheduleTime");
+                if (Check.isNull(scheduleTime)) {
+                    scheduleTime = group.getString("scheduleTime");
                 }
-                // iOS版本
-                if (!Check.isNull(target.getInteger("iosOsv"))) {
-                    targetJson.put("ios_osv", target.getInteger("iosOsv"));
+                if (!Check.isNull(scheduleTime)) {
+                    unitJson.put("schedule_time", scheduleTime);
                 }
-                //网络环境
-                if (!Check.isNull(target.getInteger("network"))) {
-                    targetJson.put("network", target.getInteger("network"));
+                // 广告组单日预算
+                Long dayBudget = copyData.getLong("dayBudget");
+                if (Check.isNull(dayBudget)) {
+                    dayBudget = group.getLong("dayBudget");
                 }
-                //设备品牌
-                if (!Check.isNull(target.getJSONArray("deviceBrand"))) {
-                    targetJson.put("device_brand", target.getJSONArray("deviceBrand"));
+                if (!Check.isNull(dayBudget)) {
+                    unitJson.put("day_budget", dayBudget);
                 }
-                //设备价格
-                if (!Check.isNull(target.getJSONArray("devicePrice"))) {
-                    targetJson.put("device_price", target.getJSONArray("devicePrice"));
+                // url类型
+                if (!Check.isNull(group.getInteger("urlType"))) {
+                    unitJson.put("url_type", group.getInteger("urlType"));
                 }
-                // APP行为-按分类
-                if (!Check.isNull(target.getJSONArray("appInterest"))) {
-                    targetJson.put("app_interest", target.getJSONArray("appInterest"));
+                // url
+                if (!Check.isNull(group.getString("url"))) {
+                    unitJson.put("url", group.getString("url"));
                 }
-                // APP行为-按APP名称
-                if (!Check.isNull(target.getJSONArray("appIds"))) {
-                    targetJson.put("app_ids", target.getJSONArray("appIds"));
+                // appId
+                if (!Check.isNull(group.getLong("appId"))) {
+                    unitJson.put("app_id", group.getLong("appId"));
                 }
-                // 人群包定向
-                if (!Check.isNull(target.getJSONArray("population"))) {
-                    targetJson.put("population", target.getJSONArray("population"));
+                // 创意展现方式
+                if (!Check.isNull(group.getInteger("showMode"))) {
+                    unitJson.put("show_mode", group.getInteger("showMode"));
                 }
-                // 人群包排除
-                if (!Check.isNull(target.getJSONArray("excludePopulation"))) {
-                    targetJson.put("exclude_population", target.getJSONArray("excludePopulation"));
+                //投放方式
+                Integer speed = copyData.getInteger("speed");
+                if (Check.isNull(speed)) {
+                    speed = group.getInteger("speed");
                 }
-                //三方付费人群
-                if (!Check.isNull(target.getJSONArray("thirdPlatformCode"))) {
-                    targetJson.put("third_platform_code", target.getJSONArray("thirdPlatformCode"));
+                if (!Check.isNull(speed)) {
+                    unitJson.put("speed", speed);
                 }
-                Integer sceneId = valueOf(scene_id.get(0).toString());
-                if (sceneId != 5) {
-                    //过滤已转化人群纬度
-                    if (!Check.isNull(target.getInteger("filterConvertedLevel"))) {
-                        targetJson.put("filter_converted_level", target.getInteger("filterConvertedLevel"));
+
+                String templateId = copyData.getString("templateId");
+                if (!Check.isNull(templateId)) {
+                    unitJson.put("template_id", templateId);
+                } else {
+                    /*----------------用户定向-----------*/
+                    JSONObject target = group.getJSONObject("target");
+                    JSONObject targetJson = new JSONObject();
+                    // 地域
+                    if (!Check.isNull(target.getJSONArray("region"))) {
+                        targetJson.put("region", target.getJSONArray("region"));
+                    }
+                    // 自定义年龄段
+                    if (!Check.isNull(target.getInteger("ageMax")) && !Check.isNull(target.getInteger("ageMin"))) {
+                        JSONObject ageJson = new JSONObject();
+                        ageJson.put("min", target.getInteger("ageMin"));
+                        ageJson.put("max", target.getInteger("ageMax"));
+                        targetJson.put("age", ageJson);
+                    }
+                    // 固定年龄段
+                    if (!Check.isNull(target.getJSONArray("agesRange"))) {
+                        targetJson.put("ages_range", target.getJSONArray("agesRange"));
+                    }
+                    // 性别
+                    if (!Check.isNull(target.getInteger("gender"))) {
+                        targetJson.put("gender", target.getInteger("gender"));
+                    }
+                    //操作系统
+                    if (!Check.isNull(target.getInteger("platformOs"))) {
+                        targetJson.put("platform_os", target.getInteger("platformOs"));
+                    }
+                    //Android版本
+                    if (!Check.isNull(target.getInteger("androidOsv"))) {
+                        targetJson.put("android_osv", target.getInteger("androidOsv"));
                     }
-                    //商业兴趣类型
-                    if (!Check.isNull(target.getInteger("businessInterestType"))) {
-                        targetJson.put("business_interest_type", target.getInteger("businessInterestType"));
+                    // iOS版本
+                    if (!Check.isNull(target.getInteger("iosOsv"))) {
+                        targetJson.put("ios_osv", target.getInteger("iosOsv"));
                     }
-                    // 商业兴趣
-                    if (!Check.isNull(target.getJSONArray("businessInterest"))) {
-                        targetJson.put("business_interest", target.getJSONArray("businessInterest"));
+                    //网络环境
+                    if (!Check.isNull(target.getInteger("network"))) {
+                        targetJson.put("network", target.getInteger("network"));
                     }
-                    //网红粉丝
-                    if (!Check.isNull(target.getJSONArray("fansStar"))) {
-                        targetJson.put("fans_star", target.getJSONArray("fansStar"));
+                    //设备品牌
+                    if (!Check.isNull(target.getJSONArray("deviceBrand"))) {
+                        targetJson.put("device_brand", target.getJSONArray("deviceBrand"));
                     }
-                    //兴趣视频用户
-                    if (!Check.isNull(target.getJSONArray("interestVideo"))) {
-                        targetJson.put("interest_video", target.getJSONArray("interestVideo"));
+                    //设备价格
+                    if (!Check.isNull(target.getJSONArray("devicePrice"))) {
+                        targetJson.put("device_price", target.getJSONArray("devicePrice"));
                     }
-                    /*----------------智能扩量----------------*/
-                    JSONObject intelliExtendJson = new JSONObject();
-                    // 开启智能扩量
-                    if (!Check.isNull(target.getInteger("isOpen"))) {
-                        intelliExtendJson.put("is_open", target.getInteger("isOpen"));
+                    // APP行为-按分类
+                    if (!Check.isNull(target.getJSONArray("appInterest"))) {
+                        targetJson.put("app_interest", target.getJSONArray("appInterest"));
                     }
-                    //不可突破年龄
-                    if (!Check.isNull(target.getInteger("noAgeBreak"))) {
-                        intelliExtendJson.put("no_age_break", target.getInteger("noAgeBreak"));
+                    // APP行为-按APP名称
+                    if (!Check.isNull(target.getJSONArray("appIds"))) {
+                        targetJson.put("app_ids", target.getJSONArray("appIds"));
                     }
-                    //不可突破性别
-                    if (!Check.isNull(target.getInteger("noGenderBreak"))) {
-                        intelliExtendJson.put("no_gender_break", target.getInteger("noGenderBreak"));
+                    // 人群包定向
+                    if (!Check.isNull(target.getJSONArray("population"))) {
+                        targetJson.put("population", target.getJSONArray("population"));
                     }
-                    // 不可突破地域
-                    if (!Check.isNull(target.getInteger("noAreaBreak"))) {
-                        intelliExtendJson.put("no_area_break", target.getInteger("noAreaBreak"));
+                    // 人群包排除
+                    if (!Check.isNull(target.getJSONArray("excludePopulation"))) {
+                        targetJson.put("exclude_population", target.getJSONArray("excludePopulation"));
                     }
-                    if (!Check.isNull(intelliExtendJson)) {
-                        targetJson.put("intelli_extend", intelliExtendJson);
+                    //三方付费人群
+                    if (!Check.isNull(target.getJSONArray("thirdPlatformCode"))) {
+                        targetJson.put("third_platform_code", target.getJSONArray("thirdPlatformCode"));
+                    }
+                    Integer sceneId = valueOf(scene_id.get(0).toString());
+                    if (sceneId != 5) {
+                        //过滤已转化人群纬度
+                        if (!Check.isNull(target.getInteger("filterConvertedLevel"))) {
+                            targetJson.put("filter_converted_level", target.getInteger("filterConvertedLevel"));
+                        }
+                        //商业兴趣类型
+                        if (!Check.isNull(target.getInteger("businessInterestType"))) {
+                            targetJson.put("business_interest_type", target.getInteger("businessInterestType"));
+                        }
+                        // 商业兴趣
+                        if (!Check.isNull(target.getJSONArray("businessInterest"))) {
+                            targetJson.put("business_interest", target.getJSONArray("businessInterest"));
+                        }
+                        //网红粉丝
+                        if (!Check.isNull(target.getJSONArray("fansStar"))) {
+                            targetJson.put("fans_star", target.getJSONArray("fansStar"));
+                        }
+                        //兴趣视频用户
+                        if (!Check.isNull(target.getJSONArray("interestVideo"))) {
+                            targetJson.put("interest_video", target.getJSONArray("interestVideo"));
+                        }
+                        /*----------------智能扩量----------------*/
+                        JSONObject intelliExtendJson = new JSONObject();
+                        // 开启智能扩量
+                        if (!Check.isNull(target.getInteger("isOpen"))) {
+                            intelliExtendJson.put("is_open", target.getInteger("isOpen"));
+                        }
+                        //不可突破年龄
+                        if (!Check.isNull(target.getInteger("noAgeBreak"))) {
+                            intelliExtendJson.put("no_age_break", target.getInteger("noAgeBreak"));
+                        }
+                        //不可突破性别
+                        if (!Check.isNull(target.getInteger("noGenderBreak"))) {
+                            intelliExtendJson.put("no_gender_break", target.getInteger("noGenderBreak"));
+                        }
+                        // 不可突破地域
+                        if (!Check.isNull(target.getInteger("noAreaBreak"))) {
+                            intelliExtendJson.put("no_area_break", target.getInteger("noAreaBreak"));
+                        }
+                        if (!Check.isNull(intelliExtendJson)) {
+                            targetJson.put("intelli_extend", intelliExtendJson);
+                        }
                     }
+                    unitJson.put("target", targetJson);
                 }
-                unitJson.put("target", targetJson);
-            }
-            // 出价
-            String bid = copyData.getString("bid");
-            if (Check.isNull(bid)) {
-                bid = group.getString("bid");
-            }
-            unitJson.put("bid", bid);
-            // 出价类型
-            String bidType = copyData.getString("bidType");
-            if (Check.isNull(bidType)) {
-                bidType = group.getString("bidType");
-            }
-            unitJson.put("bid_type", bidType);
-            // 深度转化出价
-            String cpaBid = copyData.getString("cpaBid");
-            if (Check.isNull(cpaBid)) {
-                cpaBid = group.getString("cpaBid");
-            }
-            unitJson.put("cpa_bid", cpaBid);
-            // 深度转化目标出价
-            String deepConversionBid = copyData.getString("deepConversionBid");
-            if (Check.isNull(deepConversionBid)) {
-                deepConversionBid = group.getString("deepConversionBid");
-            }
-            if (!Check.isNull(deepConversionBid)) {
-                unitJson.put("deep_conversion_bid", deepConversionBid);
-            }
-            // 深度转化目标
-            String deepConversionType = copyData.getString("deepConversionType");
-            if (Check.isNull(deepConversionType)) {
-                deepConversionType = group.getString("deepConversionType");
-            }
-            unitJson.put("deep_conversion_type", deepConversionType);
-            // 优化目标
-            String ocpxActionType = copyData.getString("ocpxActionType");
-            if (Check.isNull(ocpxActionType)) {
-                ocpxActionType = group.getString("ocpxActionType");
-            }
-            unitJson.put("ocpx_action_type", ocpxActionType);
+                // 出价
+                String bid = copyData.getString("bid");
+                if (Check.isNull(bid)) {
+                    bid = group.getString("bid");
+                }
+                unitJson.put("bid", bid);
+                // 出价类型
+                String bidType = copyData.getString("bidType");
+                if (Check.isNull(bidType)) {
+                    bidType = group.getString("bidType");
+                }
+                unitJson.put("bid_type", bidType);
+                // 深度转化出价
+                String cpaBid = copyData.getString("cpaBid");
+                if (Check.isNull(cpaBid)) {
+                    cpaBid = group.getString("cpaBid");
+                }
+                unitJson.put("cpa_bid", cpaBid);
+                // 深度转化目标出价
+                String deepConversionBid = copyData.getString("deepConversionBid");
+                if (Check.isNull(deepConversionBid)) {
+                    deepConversionBid = group.getString("deepConversionBid");
+                }
+                if (!Check.isNull(deepConversionBid)) {
+                    unitJson.put("deep_conversion_bid", deepConversionBid);
+                }
+                // 深度转化目标
+                String deepConversionType = copyData.getString("deepConversionType");
+                if (Check.isNull(deepConversionType)) {
+                    deepConversionType = group.getString("deepConversionType");
+                }
+                unitJson.put("deep_conversion_type", deepConversionType);
+                // 优化目标
+                String ocpxActionType = copyData.getString("ocpxActionType");
+                if (Check.isNull(ocpxActionType)) {
+                    ocpxActionType = group.getString("ocpxActionType");
+                }
+                unitJson.put("ocpx_action_type", ocpxActionType);
 
-            //快手广告组名
-            String unitName = group.getString("unitName");
-            if (unitName.contains("CopyFrom")) {
-                String format = "-".concat(DateUtils.yyyymmddhhmmss.get().format(new Date()));
-                if (unitName.contains("(update)")) {
-                    int lastIndx = unitName.lastIndexOf("-");
-                    group.put("unit_name", unitName.substring(0, lastIndx).concat(format).concat("(update)"));
+                //快手广告组名
+                String unitName = group.getString("unitName");
+                if (unitName.contains("CopyFrom")) {
+                    String format = "-".concat(DateUtils.yyyymmddhhmmss.get().format(new Date()));
+                    if (unitName.contains("(update)")) {
+                        int lastIndx = unitName.lastIndexOf("-");
+                        group.put("unit_name", unitName.substring(0, lastIndx).concat(format).concat("(update)"));
+                    } else {
+                        unitJson.put("unit_name", unitName.concat(format).concat("(update)"));
+                    }
                 } else {
-                    unitJson.put("unit_name", unitName.concat(format).concat("(update)"));
+                    unitJson.put("unit_name", "CopyFrom-".concat(unitName));
                 }
-            } else {
-                unitJson.put("unit_name", "CopyFrom-".concat(unitName));
-            }
-            Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitJson, 1);
-            if (!Check.isNullMap(returnUnitMap)) {
-                Integer code = (Integer) returnUnitMap.get("code");
-                if (code == 0) {
-                    Long unitId = (Long) returnUnitMap.get("unitId");
-                    Thread thread = new Thread() {
-                        @Override
-                        public void run() {
-                            try {
-                                batchService.copyCreative(token.getAccountId(), unitId, group.getLong("unitId"), new JSONObject());
-                            } catch (Exception e) {
-                                e.printStackTrace();
+                Map<String, Object> returnUnitMap = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitJson, 1);
+                if (!Check.isNullMap(returnUnitMap)) {
+                    Integer code = (Integer) returnUnitMap.get("code");
+                    if (code == 0) {
+                        Long unitId = (Long) returnUnitMap.get("unitId");
+                        Thread thread = new Thread() {
+                            @Override
+                            public void run() {
+                                try {
+                                    batchService.copyCreative(token.getAccountId(), unitId, group.getLong("unitId"), null);
+                                } catch (Exception e) {
+                                    log.error("复制创建广告创意异常", e);
+                                    updateState(copyData.getLong("id"), NoEn.NO3.valueStr(), "复制创建广告创意异常");
+                                    sendNotification(copyData.getString("oldCampaignName"), copyData.getString("createrId"), NoEn.NO3.valueStr());
+                                }
                             }
-                        }
-                    };
-                    thread.start();
+                        };
+                        thread.start();
+                    }
+                } else {
+                    updateState(copyData.getLong("id"), NoEn.NO3.valueStr(), (String) returnUnitMap.get("message"));
+                    sendNotification(copyData.getString("oldCampaignName"), copyData.getString("createrId"), NoEn.NO3.valueStr());
                 }
-            } else {
-                JSONObject failJson = new JSONObject();
-                failJson.put("unitName", unitName);
-                failJson.put("failMessage", returnUnitMap.get("message"));
             }
+        } catch (Exception e) {
+            log.error("复制过程调用快手接口异常", e);
+            throw new Exception("复制过程调用快手接口异常");
         }
 
     }
@@ -425,7 +451,8 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
      * @throws
      * @author ZHAOXA
      */
-    private void createCopyCreatives(CtopOauthToken token, JSONObject data, KuaishouCampaignCopyData copyData) throws Exception {
+    private void createCopyCreatives(CtopOauthToken token, JSONObject data, KuaishouCampaignCopyData
+            copyData) throws Exception {
 
     }
 
@@ -437,9 +464,9 @@ public class KuaishouCampaignCopyDataServiceImpl extends ServiceImpl<KuaishouCam
      * @throws
      * @author ZHAOXA
      */
-    private void sendNotification(KuaishouCampaignCopyData copyData, String state) {
-        String msg = messageTemplate.getCopyCampaignMessage(copyData.getOldCampaignName(), state);
-        sendMessageService.sendMessage(copyData.getCreaterId(), msg);
+    private void sendNotification(String name, String userId, String state) {
+        String msg = messageTemplate.getCopyCampaignMessage(name, state);
+        sendMessageService.sendMessage(userId, msg);
     }
 
     /**

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

@@ -2,6 +2,8 @@ package cn.com.ctop.kuaishou.modules.report.controller;
 
 import cn.com.ctop.common.module.annotation.AutoLog;
 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.service.IKuaishouAudienceReportDailyAccountService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouAudienceReportDailyService;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -55,6 +57,8 @@ import java.util.Map;
 public class KuaishouAudienceReportDailyController {
     @Autowired
     private IKuaishouAudienceReportDailyService kuaishouAudienceReportDailyService;
+    @Autowired
+    private IKuaishouAudienceReportDailyAccountService kuaishouAudienceReportDailyAccountService;
 
     /**
      * 分页列表查询
@@ -93,9 +97,9 @@ public class KuaishouAudienceReportDailyController {
     @AutoLog(value = "人群分析报表-分页列表查询")
     @ApiOperation(value = "人群分析报表-分页列表查询", notes = "人群分析报表-分页列表查询")
     @GetMapping(value = "/queryPageList")
-    public Result<Object> queryPageLists(KuaishouAudienceReportDaily audienceReport, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, String type) {
+    public Result<Object> queryPageLists(KuaishouAudienceReportDailyAccount audienceReport, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
-            return kuaishouAudienceReportDailyService.queryPageLists(audienceReport, pageNo, pageSize, type);
+            return kuaishouAudienceReportDailyAccountService.queryPageLists(audienceReport, pageNo, pageSize);
         } catch (Exception e) {
             log.error("人群分析报表-分页列表查询异常", e);
         }
@@ -113,9 +117,9 @@ public class KuaishouAudienceReportDailyController {
     @AutoLog(value = "首页报表数据接口")
     @ApiOperation(value = "首页报表数据接口", notes = "首页报表数据接口")
     @GetMapping(value = "/queryAllReportForm")
-    public Result<Object> queryAllReportForm(KuaishouAudienceReportDaily audienceReport) {
+    public Result<Object> queryAllReportForm(KuaishouAudienceReportDailyAccount audienceReport) {
         try {
-            return kuaishouAudienceReportDailyService.queryAllReportForm(audienceReport);
+            return kuaishouAudienceReportDailyAccountService.queryAllReportForm(audienceReport);
         } catch (Exception e) {
             log.error("首页报表数据接口", e);
         }

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

@@ -1,9 +1,11 @@
 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.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
+import java.util.List;
+
 /**
  * 人群分析报表
  *
@@ -13,4 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface KuaishouAudienceReportDailyAccountMapper extends BaseMapper<KuaishouAudienceReportDailyAccount> {
 
+    List<JSONObject> queryPageLists(KuaishouAudienceReportDailyAccount audienceReport);
+
+    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDailyAccount audienceReport);
 }

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

@@ -1,12 +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.KuaishouAudienceReportDailyAge;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyAgeMapper extends BaseMapper<KuaishouAudienceReportDailyAge> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +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.KuaishouAudienceReportDailyBusiness;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyBusinessMapper extends BaseMapper<KuaishouAudienceReportDailyBusiness> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +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.KuaishouAudienceReportDailyCity;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyCityMapper extends BaseMapper<KuaishouAudienceReportDailyCity> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +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.KuaishouAudienceReportDailyClient;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyClientMapper extends BaseMapper<KuaishouAudienceReportDailyClient> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +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.KuaishouAudienceReportDailyGender;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -15,8 +11,4 @@ import java.util.List;
  * @cersion: V1.0
  */
 public interface KuaishouAudienceReportDailyGenderMapper extends BaseMapper<KuaishouAudienceReportDailyGender> {
-
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -1,12 +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.KuaishouAudienceReportDailyProvince;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
-import java.util.List;
-
 /**
  * 人群分析报表
  *
@@ -16,7 +12,4 @@ import java.util.List;
  */
 public interface KuaishouAudienceReportDailyProvinceMapper extends BaseMapper<KuaishouAudienceReportDailyProvince> {
 
-    List<JSONObject> queryPageLists(KuaishouAudienceReportDaily audienceReport);
-
-    List<JSONObject> queryAllReportForm(KuaishouAudienceReportDaily audienceReport);
 }

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

@@ -0,0 +1,108 @@
+<?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.KuaishouAudienceReportDailyAccountMapper">
+
+    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        account_id,
+        province,
+        age_segment,
+        business_interest_tags,
+        city,
+        client,
+        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_account
+        where account_id = #{accountId}
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        <if test="audienceType == 'province' ">
+            AND audience_type = #{audienceType}
+            GROUP BY province
+        </if>
+        <if test="audienceType == 'city' ">
+            AND audience_type = #{audienceType}
+            GROUP BY city
+        </if>
+        <if test="audienceType == 'gender' ">
+            AND audience_type = #{audienceType}
+            GROUP BY gender
+        </if>
+        <if test="audienceType == 'ageSegment' ">
+            AND audience_type = #{audienceType}
+            GROUP BY age_segment
+        </if>
+        <if test="audienceType == 'clientId' ">
+            AND audience_type = #{audienceType}
+            GROUP BY client
+        </if>
+        <if test="audienceType == 'businessInterestTags' ">
+            AND audience_type = #{audienceType}
+            GROUP BY business_interest_tags
+        </if>
+        <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,
+        age_segment,
+        business_interest_tags,
+        city,
+        client,
+        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_account
+        where account_id = #{accountId}
+        <if test="startTime != null">
+            AND stat_date &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            AND stat_date &lt;= #{endTime}
+        </if>
+        <if test="audienceType == 'province' ">
+            AND audience_type = #{audienceType}
+            GROUP BY province
+        </if>
+        <if test="audienceType == 'city' ">
+            AND audience_type = #{audienceType}
+            GROUP BY city
+        </if>
+        <if test="audienceType == 'gender' ">
+            AND audience_type = #{audienceType}
+            GROUP BY gender
+        </if>
+        <if test="audienceType == 'ageSegment' ">
+            AND audience_type = #{audienceType}
+            GROUP BY age_segment
+        </if>
+        <if test="audienceType == 'clientId' ">
+            AND audience_type = #{audienceType}
+            GROUP BY client
+        </if>
+        <if test="audienceType == 'businessInterestTags' ">
+            AND audience_type = #{audienceType}
+            GROUP BY business_interest_tags
+        </if>
+    </select>
+</mapper>

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

@@ -1,52 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyAgeMapper">
-    <select id="queryPageLists" resultType="com.alibaba.fastjson.JSONObject">
-        select
-        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}
-        <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>

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

@@ -1,51 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyBusinessMapper">
-    <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}
-        <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>

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

@@ -1,50 +1,7 @@
 <?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="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}
-        <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>

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

@@ -1,50 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyClientMapper">
-    <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}
-        <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>

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

@@ -1,50 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAudienceReportDailyGenderMapper">
-    <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}
-        <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>

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

@@ -2,50 +2,5 @@
 <!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="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}
-        <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>

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

@@ -1,6 +1,5 @@
 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;
@@ -14,4 +13,24 @@ import org.jeecg.common.api.vo.Result;
  */
 public interface IKuaishouAudienceReportDailyAccountService extends IService<KuaishouAudienceReportDailyAccount> {
 
+
+    /**
+     * 人群报表接口:
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    Result<Object> queryPageLists(KuaishouAudienceReportDailyAccount audienceReport, Integer pageNo, Integer pageSize);
+
+    /**
+     * 首页报表数据
+     *
+     * @param
+     * @return org.jeecg.common.api.vo.Result<java.lang.Object>
+     * @throws
+     * @author ZHAOXA
+     */
+    Result<Object> queryAllReportForm(KuaishouAudienceReportDailyAccount audienceReport);
 }

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

@@ -22,25 +22,4 @@ 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);
 }

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

@@ -1,12 +1,19 @@
 package cn.com.ctop.kuaishou.modules.report.service.impl;
 
+import cn.com.ctop.common.module.utils.Check;
 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.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.pagehelper.PageHelper;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 人群分析报表
  *
@@ -18,4 +25,70 @@ import org.springframework.stereotype.Service;
 @Service
 public class KuaishouAudienceReportDailyAccountServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyAccountMapper, KuaishouAudienceReportDailyAccount> implements IKuaishouAudienceReportDailyAccountService {
 
+    @Autowired
+    private KuaishouAudienceReportDailyAccountMapper accountMapper;
+
+
+    @Override
+    public Result<Object> queryPageLists(KuaishouAudienceReportDailyAccount audienceReport, Integer pageNo, Integer pageSize) {
+        if (null == pageNo || pageNo == 0) {
+            pageNo = 1;
+        }
+        if (null == pageSize || pageSize == 0) {
+            pageSize = 10;
+        }
+        List<JSONObject> list = null;
+        PageHelper.startPage(pageNo, pageSize);
+        List<JSONObject> jsonObjects = null;
+        try {
+            jsonObjects = accountMapper.queryPageLists(audienceReport);
+        } catch (Exception e) {
+            return Result.error("查询失败");
+        }
+        return Result.ok(jsonObjects);
+    }
+
+    /**
+     * 首页报表数据
+     *
+     * @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(KuaishouAudienceReportDailyAccount audienceReport) {
+        JSONObject data = new JSONObject();
+        audienceReport.setAudienceType("province");
+        List<JSONObject> provinces = accountMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(provinces)) {
+            data.put("province", provinces);
+        }
+        audienceReport.setAudienceType("gender");
+        List<JSONObject> genders = accountMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(genders)) {
+            data.put("gender", genders);
+        }
+        audienceReport.setAudienceType("ageSegment");
+        List<JSONObject> ages = accountMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(ages)) {
+            data.put("ageSegment", ages);
+        }
+        audienceReport.setAudienceType("clientId");
+        List<JSONObject> clients = accountMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(clients)) {
+            data.put("client", clients);
+        }
+        audienceReport.setAudienceType("businessInterestTags");
+        List<JSONObject> bussiness = accountMapper.queryAllReportForm(audienceReport);
+        if (!Check.isNull(bussiness)) {
+            data.put("businessInterestTags", bussiness);
+        }
+        if (data.size() == 0) {
+            return Result.error("只能获取到两天前的数据,请正确选择时间");
+        }
+        return Result.ok(data);
+    }
+
+
 }

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

@@ -89,83 +89,6 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
     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>
-     * @throws
-     * @author ZHAOXA
-     */
-    @Override
-    public Result<Object> queryPageLists(KuaishouAudienceReportDaily audienceReport, Integer pageNo, Integer pageSize, String type) {
-        if (null == pageNo || pageNo == 0) {
-            pageNo = 1;
-        }
-        if (null == pageSize || pageSize == 0) {
-            pageSize = 10;
-        }
-        List<JSONObject> list = null;
-        PageHelper.startPage(pageNo, pageSize);
-        if ("province".equals(type)) {
-            list = provinceMapper.queryPageLists(audienceReport);
-        } else if ("city".equals(type)) {
-            list = cityMapper.queryPageLists(audienceReport);
-        } else if ("gender".equals(type)) {
-            list = genderMapper.queryPageLists(audienceReport);
-        } else if ("ageSegment".equals(type)) {
-            list = ageMapper.queryPageLists(audienceReport);
-        } else if ("client".equals(type)) {
-            list = clientMapper.queryPageLists(audienceReport);
-        } else if ("businessInterestTags".equals(type)) {
-            list = bussinessMapper.queryPageLists(audienceReport);
-        } else {
-            return Result.error("请选择人群报表类型");
-        }
-        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: 商业兴趣分布