瀏覽代碼

Merge branch 'master' into V1.1.8

zhaoxian 3 年之前
父節點
當前提交
ac81fc4a53
共有 26 個文件被更改,包括 787 次插入220 次删除
  1. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 183 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/ByteDanceAdvertiserReportDTO.java
  3. 0 2
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceMaterialsLoadJob.java
  4. 3 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePlanLoadJob.java
  5. 35 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/ExternalMaterialCollectionJob.java
  6. 60 142
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoCreativeJob.java
  7. 0 45
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoVideoJob.java
  8. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAdvertiserStrategyMapper.java
  9. 9 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAdvertiserStrategyMapper.xml
  10. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAdvertiserStrategyService.java
  11. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAdvertiserStrategyServiceImpl.java
  12. 205 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouRealTimeController.java
  13. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  14. 4 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouRealTimeDataService.java
  15. 38 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
  16. 44 3
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouRealTimeDataServiceImpl.java
  17. 27 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java
  18. 7 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java
  19. 120 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/utils/LinkUtils.java
  20. 11 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceAdvertisePlan.java
  21. 3 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/BytedanceImageInfoMapper.java
  22. 12 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/BytedanceImageInfoMapper.xml
  23. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceImageInfoService.java
  24. 5 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  25. 7 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceImageInfoServiceImpl.java
  26. 1 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

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

@@ -202,6 +202,8 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/kuaishou/batch/*", "anon");
         filterChainDefinitionMap.put("/dimension/kuaiShouDimensionAccount/*", "anon");
         filterChainDefinitionMap.put("/ai/projectCreate/*", "anon");
+        //获取快手实时组数据信息
+        filterChainDefinitionMap.put("/kuaishou/realTime/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 183 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/ByteDanceAdvertiserReportDTO.java

@@ -3,6 +3,8 @@ package cn.com.ctop.common.module.vo;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 
 @Data
 public class ByteDanceAdvertiserReportDTO implements Serializable {
@@ -12,4 +14,185 @@ public class ByteDanceAdvertiserReportDTO implements Serializable {
     private Integer pageSize;
     private Integer page;
     private String timeGranularity;
+
+
+
+    private List<String> fields;
+
+
+
+    public List<String> getFieldsList(){
+        List<String> fields = new ArrayList<>();
+        fields.add("cost");
+        fields.add("show");
+        fields.add("avg_show_cost");
+        fields.add("avg_click_cost");
+        fields.add("click");
+        fields.add("ctr");
+        fields.add("convert");
+        fields.add("convert_cost");
+        fields.add("convert_rate");
+        fields.add("deep_convert");
+        fields.add("deep_convert_cost");
+        fields.add("deep_convert_rate");
+        fields.add("attribution_convert");
+        fields.add("attribution_convert_cost");
+        fields.add("attribution_deep_convert");
+        fields.add("attribution_deep_convert_cost");
+        fields.add("download_start");
+        fields.add("download_start_cost");
+        fields.add("download_start_rate");
+        fields.add("download_finish");
+        fields.add("download_finish_cost");
+        fields.add("download_finish_rate");
+        fields.add("install_finish");
+        fields.add("install_finish_cost");
+        fields.add("install_finish_rate");
+        fields.add("active");
+        fields.add("active_cost");
+        fields.add("active_rate");
+        fields.add("register");
+        fields.add("active_register_cost");
+        fields.add("active_register_rate");
+        fields.add("attribution_next_day_open_cnt");
+        fields.add("attribution_next_day_open_cost");
+        fields.add("attribution_next_day_open_rate");
+        fields.add("next_day_open");
+        fields.add("game_addiction");
+        fields.add("game_addiction_cost");
+        fields.add("game_addiction_rate");
+        fields.add("pay_count");
+        fields.add("active_pay_cost");
+        fields.add("active_pay_rate");
+        fields.add("game_pay_count");
+        fields.add("game_pay_cost");
+        fields.add("attribution_game_pay_7d_count");
+        fields.add("attribution_game_pay_7d_cost");
+        fields.add("attribution_active_pay_7d_per_count");
+        fields.add("loan_completion");
+        fields.add("loan_completion_cost");
+        fields.add("loan_completion_rate");
+        fields.add("pre_loan_credit");
+        fields.add("pre_loan_credit_cost");
+        fields.add("loan_credit");
+        fields.add("loan_credit_cost");
+        fields.add("loan_credit_rate");
+        fields.add("in_app_uv");
+        fields.add("in_app_detail_uv");
+        fields.add("in_app_cart");
+        fields.add("in_app_pay");
+        fields.add("in_app_order");
+        fields.add("phone");
+        fields.add("form");
+        fields.add("map_search");
+        fields.add("button");
+        fields.add("view");
+        fields.add("download");
+        fields.add("qq");
+        fields.add("lottery");
+        fields.add("vote");
+        fields.add("message");
+        fields.add("redirect");
+        fields.add("shopping");
+        fields.add("consult");
+        fields.add("wechat");
+        fields.add("wechat_login_count");
+        fields.add("attribution_wechat_login_30d_count");
+        fields.add("wechat_login_cost");
+        fields.add("attribution_wechat_login_30d_cost");
+        fields.add("wechat_first_pay_count");
+        fields.add("attribution_wechat_first_pay_30d_count");
+        fields.add("wechat_first_pay_cost");
+        fields.add("attribution_wechat_first_pay_30d_cost");
+        fields.add("wechat_first_pay_rate");
+        fields.add("attribution_wechat_first_pay_30d_rate");
+        fields.add("wechat_pay_amount");
+        fields.add("attribution_wechat_pay_30d_amount");
+        fields.add("attribution_wechat_pay_30d_roi");
+        fields.add("phone_connect");
+        fields.add("phone_confirm");
+        fields.add("phone_effective");
+        fields.add("consult_effective");
+        fields.add("coupon");
+        fields.add("coupon_single_page");
+        fields.add("redirect_to_shop");
+        fields.add("poi_address_click");
+        fields.add("poi_collect");
+        fields.add("luban_order_cnt");
+        fields.add("luban_order_stat_amount");
+        fields.add("luban_order_roi");
+        fields.add("luban_live_enter_cnt");
+        fields.add("live_watch_one_minute_count");
+        fields.add("luban_live_follow_cnt");
+        fields.add("live_fans_club_join_cnt");
+        fields.add("luban_live_comment_cnt");
+        fields.add("luban_live_share_cnt");
+        fields.add("luban_live_gift_cnt");
+        fields.add("luban_live_gift_amount");
+        fields.add("luban_live_slidecart_click_cnt");
+        fields.add("luban_live_click_product_cnt");
+        fields.add("luban_live_pay_order_count");
+        fields.add("luban_live_pay_order_stat_cost");
+        //fields.add("live_pay_order_cost_per_order");
+        fields.add("total_play");
+        fields.add("valid_play");
+        fields.add("valid_play_cost");
+        fields.add("valid_play_rate");
+        fields.add("play_25_feed_break");
+        fields.add("play_50_feed_break");
+        fields.add("play_100_feed_break");
+        //fields.add("play_25_feed_break_rate");
+        //fields.add("play_50_feed_break_rate");
+        //fields.add("play_100_feed_break_rate");
+        //fields.add("play_75_feed_break_rate");
+        fields.add("average_play_time_per_play");
+        //fields.add("play_over");
+        fields.add("play_over_rate");
+        fields.add("wifi_play_rate");
+        fields.add("wifi_play");
+        fields.add("card_show");
+        //fields.add("play_duration_2s_rate");
+        //fields.add("play_duration_3s_rate");
+        //fields.add("play_duration_5s_rate");
+        //fields.add("play_duration_10s_rate");
+        fields.add("advanced_creative_phone_click");
+        fields.add("advanced_creative_counsel_click");
+        fields.add("advanced_creative_form_click");
+        fields.add("advanced_creative_coupon_addition");
+        fields.add("advanced_creative_form_submit");
+        fields.add("share");
+        fields.add("comment");
+        fields.add("like");
+        fields.add("follow");
+        //fields.add("dislike");
+        //fields.add("report");
+        fields.add("message_action");
+        fields.add("home_visited");
+        fields.add("ies_challenge_click");
+        fields.add("ies_music_click");
+        fields.add("location_click");
+        fields.add("click_download");
+        fields.add("click_call_dy");
+        fields.add("click_shopwindow");
+        fields.add("click_website");
+        fields.add("click_landing_page");
+        //fields.add("interact_per_cost");
+        //fields.add("convert_show_rate");
+        //fields.add("cpc");
+        //fields.add("cpm");
+        //fields.add("cpa");
+        fields.add("submit_certification_count");
+        fields.add("approval_count");
+        fields.add("first_order_count");
+        fields.add("first_rental_order_count");
+        fields.add("commute_first_pay_count");
+        fields.add("live_component_click_count");
+        fields.add("live_component_click_cost");
+        fields.add("live_component_click_rate");
+        return fields;
+
+    }
+
+
+
 }

+ 0 - 2
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceMaterialsLoadJob.java

@@ -57,8 +57,6 @@ public class BytedanceMaterialsLoadJob {
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
-        //修改图片类型
-        imageInfoService.updateType();
         XxlJobHelper.log("物料数据同步完成");
     }
 }

+ 3 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePlanLoadJob.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -13,6 +14,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Component
+@Slf4j
 public class BytedancePlanLoadJob {
     @Autowired
     private ICtopOauthTokenService tokenService;
@@ -27,6 +29,7 @@ public class BytedancePlanLoadJob {
     @XxlJob("bytedancePlanLoadJob")
     public void execute() throws Exception {
         //1:查询当日数据
+        log.info("============获取头条全量计划=================");
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         tokens.forEach(token -> executorService.submit(() -> advertiserDataService.getAdvertiserPlan(token, "", null, null)));
         XxlJobHelper.log("头条全量计划数据获取完成");

+ 35 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/ExternalMaterialCollectionJob.java

@@ -0,0 +1,35 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.utils.HttpUtils2;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * 清洗外部素材集信息表
+ */
+@Component
+@Slf4j
+public class ExternalMaterialCollectionJob {
+
+    @Value("${xxl-job.requestUrl}")
+    private String jobUrl;
+
+    /**
+     * 快手自动创建组
+     */
+    @XxlJob("externalMaterialCollectionJob")
+    public void execute() {
+        String url = jobUrl + "/jeecg-boot/external/materialCollection/createInternalMaterial";
+        log.info("请求地址:{}", url);
+        try {
+            HttpUtils2.httpGet(url, null, null);
+        } catch (Exception e) {
+            XxlJobHelper.log(e.getMessage());
+        }
+    }
+}

+ 60 - 142
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoCreativeJob.java

@@ -1,28 +1,15 @@
-/*
 package cn.com.ctop.job.kuaishou.handler;
 
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.HttpUtils2;
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
-import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
-import java.text.ParseException;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
-*/
-/**
- * @author syh
- * 自动投放定时任务
- *//*
 
 @Component
 @Slf4j
@@ -34,151 +21,82 @@ public class KuaishouAccountAutoCreativeJob {
     @Autowired
     private IAiKuaishouAdvertiserStrategyService strategyService;
 
-    */
-/**
-     * 自定义上新创意
-     *//*
 
-    @XxlJob("kuaishouCustomCreativeAuto")
-    public void kuaishouCustomCreativeAuto() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 自动投放账户_素材清洗
+     */
+    @XxlJob("kuaishouAccountAutoVideos")
+    public void kuaishouAccountAutoVideos() {
+        List<Long> accountIds = strategyService.getKuaishouAccountAutoStrategy();
+        if (null == accountIds || accountIds.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/create/customCreativeLimit";
-        for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
-                Map<String, Object> requestMap = new HashMap<>();
-                requestMap.put("id", strategy.getId());
-                String result = HttpUtils2.httpGet(url, requestMap, null);
-                JSONObject jsonObject = JSONObject.parseObject(result);
-                if (!Check.isNull(jsonObject)) {
-                    Integer code = jsonObject.getInteger("code");
-                    if (code == 0) {
-                        log.info("快手自动上新异步执行中,accountId:{}", strategy.getAccountId());
-                    } else {
-                        log.error("快手自动上新异执行失败,accountId:{}", strategy.getAccountId());
-                    }
-                } else {
-                    log.error("快手自动上新返回结果为空,accountId:{}", strategy.getAccountId());
-                }
-            }
-        }
-
-
+        log.info("自动投放账户_开始清洗素材");
+        accountIds.forEach(accountId -> {
+            String url = jobUrl + "/jeecg-boot/auto/aiKuaishouAccountAutoVideo/insertAutoVideo?accountId=" + accountId;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
 
-    */
-/**
-     * 补充创意
-     *//*
+    /**
+     * 创建自定义上新广告创意 、频率 20分钟/次
+     */
 
-    @XxlJob("kuaishouCustomCreativeSupplement")
-    public void kuaishouCustomCreativeSupplement() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    @XxlJob("autoCreateCustomUpNewCreative")
+    public void createCustomUpNewCreative() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        try {
-            String url = jobUrl + "/jeecg-boot/ai/create/kuaishouCustomCreativeSupplement";
-            int hour = DateUtils.getNowHour();
-            for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-                if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
-                    Map<String, Object> requestMap = new HashMap<>();
-                    requestMap.put("id", strategy.getId());
-                    requestMap.put("hour", hour);
-                    String result = HttpUtils2.httpGet(url, requestMap, null);
-                    JSONObject jsonObject = JSONObject.parseObject(result);
-                    if (!Check.isNull(jsonObject)) {
-                        Integer code = jsonObject.getInteger("code");
-                        if (code == 0) {
-                            log.info("快手创意补充异步执行中,accountId:{}", strategy.getAccountId());
-                        } else {
-                            log.error("快手创意补充异步执行失败,accountId:{}", strategy.getAccountId());
-                        }
-                    } else {
-                        log.error("快手创意补充返回结果为空,accountId:{}", strategy.getAccountId());
-                    }
-                }
-            }
-
-
-        } catch (ParseException e) {
-            e.printStackTrace();
-        }
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/createCustomUpNewCreative?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
 
-    */
-/**
-     * 程序化上新创意
-     *//*
-
-    @XxlJob("kuaishouProgramCreativeAuto")
-    public void kuaishouProgramCreativeAuto() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 创建自定义非上新广告创意 、频率 60分钟/次
+     */
+    @XxlJob("autoCreateCustomCreative")
+    public void createCustomCreative() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/create/kuaishouProgramCreativeAuto";
-        for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
-                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
-                Map<String, Object> requestMap = new HashMap<>();
-                requestMap.put("id", strategy.getId());
-                requestMap.put("videoCnt", videoCnt);
-                String result = HttpUtils2.httpGet(url, requestMap, null);
-                JSONObject jsonObject = JSONObject.parseObject(result);
-                if (!Check.isNull(jsonObject)) {
-                    Integer code = jsonObject.getInteger("code");
-                    if (code == 0) {
-                        log.info("快手上新程序化创意补充异步执行中,accountId:{}", strategy.getAccountId());
-                    } else {
-                        log.error("快手上新程序化异步执行失败,accountId:{}", strategy.getAccountId());
-                    }
-                } else {
-                    log.error("快手上新程序化充返回结果为空,accountId:{}", strategy.getAccountId());
-                }
-
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/createCustomCreative?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
+    }
 
-            }
+    /**
+     * 创建程序化广告创意 频率 60分钟/次
+     */
+    @XxlJob("autoCreateProgramCreative")
+    public void createProgramCreative() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
+            return;
         }
-
-
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/createProgramCreative?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
 
-    */
-/**
-     * 程序化高质量创意
-     *//*
-
-    @XxlJob("kuaishouProgramCreativeTop")
-    public void kuaishouProgramCreativeTop() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 每日补充创建创意 、频率 每天22点05分钟执行1次
+     */
+    @XxlJob("aotoSupplementCreatives")
+    public void aotoSupplementCreatives() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/create/autoCreateProgramHistoryTopCreative";
-        for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
-                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
-                Map<String, Object> requestMap = new HashMap<>();
-                requestMap.put("id", strategy.getId());
-                requestMap.put("videoCnt", videoCnt);
-                String result = HttpUtils2.httpGet(url, requestMap, null);
-                JSONObject jsonObject = JSONObject.parseObject(result);
-                if (!Check.isNull(jsonObject)) {
-                    Integer code = jsonObject.getInteger("code");
-                    if (code == 0) {
-                        log.info("快手历史高质量程序化创意补充异步执行中,accountId:{}", strategy.getAccountId());
-                    } else {
-                        log.error("快手历史高质量程序化异步执行失败,accountId:{}", strategy.getAccountId());
-                    }
-                } else {
-                    log.error("快手历史高质量程序化充返回结果为空,accountId:{}", strategy.getAccountId());
-                }
-            }
-        }
-
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/supplementTodayCreatives?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
+
 }
-*/

+ 0 - 45
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoVideoJob.java

@@ -1,45 +0,0 @@
-/*
-package cn.com.ctop.job.kuaishou.handler;
-
-import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.HttpUtils;
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
-import com.xxl.job.core.handler.annotation.XxlJob;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-*/
-/**
- * 自动投放账户_素材
- *//*
-
-@Component
-@Slf4j
-public class KuaishouAccountAutoVideoJob {
-
-    @Value("${xxl-job.requestUrl}")
-    private String jobUrl;
-
-    @Autowired
-    private IAiKuaishouAdvertiserStrategyService strategyService;
-
-    @XxlJob("kuaishouAccountAutoVideo")
-    public void kuaishouCustomCreativeAuto() {
-        List<Long> accountIds = strategyService.getKuaishouAccountAutoStrategy();
-        if (null == accountIds || accountIds.isEmpty()) {
-            return;
-        }
-        accountIds.forEach(accountId -> {
-            String url = jobUrl + "/jeecg-boot/auto/aiKuaishouAccountAutoVideo/insertAutoVideo?accountId=" + accountId;
-            HttpUtils.httpGet(url, null, null);
-        });
-    }
-}
-*/

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

@@ -14,4 +14,6 @@ import java.util.List;
 public interface AiKuaishouAdvertiserStrategyMapper extends BaseMapper<AiKuaishouAdvertiserStrategy> {
 
     List<Long> getKuaishouAccountAutoStrategy();
+
+    List<Long> getKuaishouAccountAutoStrategyIds();
 }

+ 9 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAdvertiserStrategyMapper.xml

@@ -3,12 +3,15 @@
 <mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouAdvertiserStrategyMapper">
 
     <select id="getKuaishouAccountAutoStrategy" resultType="java.lang.Long">
-        SELECT
-            account_id
-        FROM
-            ctop_ai_kuaishou_account_auto_strategy
-        WHERE
-            status = 1
+        SELECT account_id
+        FROM ctop_ai_kuaishou_account_auto_strategy
+        GROUP BY account_id
+    </select>
+
+    <select id="getKuaishouAccountAutoStrategyIds" resultType="java.lang.Long">
+        SELECT id
+        FROM ctop_ai_kuaishou_account_auto_strategy
+        WHERE status = 1
     </select>
 
 </mapper>

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAdvertiserStrategyService.java

@@ -28,4 +28,6 @@ public interface IAiKuaishouAdvertiserStrategyService extends IService<AiKuaisho
     List<AiKuaishouAdvertiserStrategy> getAllEffectStrategy();
 
     List<Long> getKuaishouAccountAutoStrategy();
+
+    List<Long> getKuaishouAccountAutoStrategyIds();
 }

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

@@ -116,6 +116,11 @@ public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuais
         return kuaishouAdvertiserStrategyMapper.getKuaishouAccountAutoStrategy();
     }
 
+    @Override
+    public List<Long> getKuaishouAccountAutoStrategyIds() {
+        return kuaishouAdvertiserStrategyMapper.getKuaishouAccountAutoStrategyIds();
+    }
+
     private Map<String,Object> historicalMissingMaterialCreateCreative(AiKuaishouAdvertiserStrategy strategy) {
         Map<String,Object>result =new HashMap<>();
         //判定是否单一应用

+ 205 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouRealTimeController.java

@@ -1,19 +1,34 @@
 package cn.com.ctop.kuaishou.modules.batch.controller;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.material.entity.MaterialVideoAuthor;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouRealTimeDataService;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
+import cn.com.ctop.kuaishou.modules.utils.LinkUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.gson.JsonObject;
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.A;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 广告组-app信息
@@ -30,7 +45,24 @@ public class KuaiShouRealTimeController {
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
 
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+    @Autowired
+    IKuaishouReportHourlyGroupService kuaishouReportHourlyGroupService;
+
+
+    @Autowired
+    IKuaishouInterfaceService kuaishouInterfaceService;
+
 
+
+
+    /**
+     *  快手- 获取实时数据 计划
+     * @param requestJson
+     * @return
+     */
     @PostMapping(value = "/getCampaignDate")
     public Result<JSONArray> getCampaignDate(@RequestBody JSONObject requestJson) {
         Result<JSONArray> result = new Result<>();
@@ -64,6 +96,13 @@ public class KuaiShouRealTimeController {
     }
 
 
+
+
+    /**
+     *  快手- 获取实时数据 组
+     * @param requestJson
+     * @return
+     */
     @PostMapping(value = "/getUnitDate")
     public Result<JSONArray> getUnitDate(@RequestBody JSONObject requestJson) {
         Result<JSONArray> result = new Result<>();
@@ -77,9 +116,9 @@ public class KuaiShouRealTimeController {
                 throw new Exception("未获取到账户信息");
             }
             Long unitId = requestJson.getLong("unitId");
-            if (Check.isNull(unitId)) {
+            /*if (Check.isNull(unitId)) {
                 throw new Exception("请传入组id");
-            }
+            }*/
             String startDate = requestJson.getString("startDate");
             String endDate = requestJson.getString("endDate");
             if (Check.isNull(startDate) || Check.isNull(endDate)) {
@@ -96,4 +135,164 @@ public class KuaiShouRealTimeController {
         return result;
     }
 
+
+    /**
+     * 盯盘-快手 组实时数据信息
+     * @param accountId
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @GetMapping(value = "/getUnitDateInfo")
+    public Result getUnitDate(@RequestParam("accountId") Long accountId,
+                                         @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
+                                         @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize) {
+
+        DecimalFormat df = new DecimalFormat("#.000");
+
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+        //广告主 当天 实时 组 数据信息
+        Map unitData = realTimeDataService.getUnitDatePage(accountId, token.getAccessToken(),  nowDate, nowDate,pageNum,pageSize);
+        //kuaishouReportHourlyGroupService.getAdvertiserGroupReportHourly(accountId,token.getAccessToken(), nowDate,nowDate);
+
+        List<KuaishouReportHourlyGroup> unitList = JSONArray.parseArray(unitData.get("details").toString(),KuaishouReportHourlyGroup.class);
+
+        for (KuaishouReportHourlyGroup unitInfo : unitList) {
+            unitInfo.setTotalCount(Integer.valueOf(unitData.get("totalCount").toString()));
+
+            //激活成本 = 花费  / 激活数
+            String activationCost = "0";
+
+
+            if (unitInfo.getCharge().doubleValue() != new Double(0) && unitInfo.getActivation() != 0l){
+                Double activation_cost = unitInfo.getCharge().doubleValue() / unitInfo.getActivation();
+                activationCost = df.format(activation_cost);
+            }
+            unitInfo.setActivationCost(activationCost);
+
+
+            //获取广告组的出价
+            JSONArray unitPrice = kuaishouInterfaceService.getKuaishouUnitList(token, unitInfo.getUnitId(),null, null , 1);
+            //优化目标
+            Integer conver = 0;
+            if(!Check.isNull(unitPrice)){
+                JSONObject unitVo = JSONObject.parseObject(unitPrice.get(0).toString());
+                //出价
+                unitInfo.setBid(Double.valueOf(unitVo.getLong("bid")));
+                unitInfo.setBidType(unitVo.getInteger("bid_type"));
+                 //优化目标
+                conver = unitVo.getInteger("ocpx_action_type");
+                unitInfo.setConverType(conver);
+            }
+
+            //优化目标: 激活,  付费,  行为,  表单提交,  注册,  唤起应用,  关键行为
+            //对应转化数 激活数,付费数,行为数,表单提交数,注册数,唤起应用次数,关键行为数
+            //优化目标id 来源---ctop_kuaishou_ocpx_action_type_config
+            //激活
+            if (conver == 180){
+                unitInfo.setConverNum(unitInfo.getActivation().intValue());
+            }
+            //付费
+            if (conver == 190){
+                unitInfo.setConverNum(unitInfo.getEventPay().intValue());
+            }
+            //行为
+            if (conver == 2){
+                unitInfo.setConverNum(unitInfo.getBclick().intValue());
+            }
+            //表单提交
+            if (conver == 53){
+                unitInfo.setConverNum(unitInfo.getFormCount().intValue());
+            }
+            //注册
+            if (conver == 396 ){
+                unitInfo.setConverNum(unitInfo.getEventRegister().intValue());
+            }
+           //唤起应用
+            if (conver == 324){
+                unitInfo.setConverNum(unitInfo.getEventAppInvoked().intValue());
+            }
+           //关键行为
+            if (conver == 773){
+                unitInfo.setConverNum(unitInfo.getKeyAction().intValue());
+            }
+            //转化成本 = 花费 / 转化数
+            unitInfo.setConverCost(Check.isNull(unitInfo.getCharge()) || Check.isNull(unitInfo.getConverNum())  ? 0 : unitInfo.getCharge().doubleValue() /  unitInfo.getConverNum().doubleValue());
+            if (unitInfo.getConverCost().isNaN() || unitInfo.getConverCost().isInfinite()){
+                unitInfo.setConverCost(new Double(0));
+            }
+
+            //操作建议
+            //消耗
+            Double charge = unitInfo.getCharge().doubleValue();
+            //出价
+            Double bid = unitInfo.getBid();
+            //转化数量
+            Integer converNum = unitInfo.getConverNum();
+            //转化成本
+            Double converCost = unitInfo.getConverCost();
+
+
+
+            //1. 转化成本大于出价×120%,消耗大于500元:
+            if ((converCost > bid * 1.2) && (charge > 500)){
+                unitInfo.setOperationAgree("高成本 | 有消耗");
+                unitInfo.setOperationAgreeContent("建议限制预算");
+                unitInfo.setOperationAgreeInfo("当前广告组转化成本偏高且消耗大于500,建议限制预算;");
+            }
+            //2.  转化成本大于出价×120%,转化数大于10小于等于50:
+            if (converCost > bid * 1.2 && LinkUtils.isInTheInterval(String.valueOf(converNum), "(10,50)")){
+                unitInfo.setOperationAgree("高成本 | 有转化");
+                unitInfo.setOperationAgreeContent("建议限制预算");
+                unitInfo.setOperationAgreeInfo("当前广告组成本大于出价×120%且转化数介于10-50之间;");
+            }
+            //3. 转化成本大于出价×120%,转化数大于50
+            if (converCost > bid * 1.2 && LinkUtils.isInTheInterval(String.valueOf(converNum), "(50,∞)")){
+                unitInfo.setOperationAgree("高成本 | 有转化");
+                unitInfo.setOperationAgreeContent("建议降低出价;");
+                unitInfo.setOperationAgreeInfo("当前转化成本大于出价×120%,转化数大于50,建议降低出价;");
+            }
+            //4.  转化成本小于等于出价×120%,转化数大于10小于等于50
+            if (converCost <= bid * 1.2 && LinkUtils.isInTheInterval(String.valueOf(converNum), "(10,50]")){
+                unitInfo.setOperationAgree("成本合理 | 有转化");
+                unitInfo.setOperationAgreeContent("建议复制推广组或放开预算");
+                unitInfo.setOperationAgreeInfo("当前转化成本小于等于出价×120%,转化数大于10小于等于50,建议复制推广组或放开预算;");
+            }
+            //5.  消耗大于0小于等于100,转化数大于0小于等于10:
+            if (LinkUtils.isInTheInterval(String.valueOf(charge), "(0,100]") && LinkUtils.isInTheInterval(String.valueOf(converNum), "(0,10]")){
+                unitInfo.setOperationAgree("消耗少 | 转化少");
+                unitInfo.setOperationAgreeContent("建议启用加速探索");
+                unitInfo.setOperationAgreeInfo("当前广告组消耗大于0小于等于100,转化数大于0小于等于10,建议加速探索;");
+            }
+            //6.  消耗大于等于500,转化数等于0:
+            if (charge >= 500 && converNum == 0){
+                unitInfo.setOperationAgree("有消耗 | 无转化");
+                unitInfo.setOperationAgreeContent("建议暂停广告组");
+                unitInfo.setOperationAgreeInfo("当前广告组消耗大于等于500且转化数等于0,建议暂停推广组;");
+            }
+            //7.   消耗大于100小于等于500
+            if (LinkUtils.isInTheInterval(String.valueOf(charge), "(100,500]")){
+                unitInfo.setOperationAgree("有一定消耗");
+                unitInfo.setOperationAgreeContent("建议继续观察");
+                unitInfo.setOperationAgreeInfo("当前广告组消耗大于100小于等于500,建议继续观察;");
+            }
+        }
+
+        return Result.ok(unitList);
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 }

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

@@ -363,6 +363,7 @@ public interface IKuaishouInterfaceService {
      * @param time_filter_type
      */
     JSONArray getGroupList(CtopOauthToken token, Long campaignId, Date startDate, Date endDate, int time_filter_type);
+    JSONArray getKuaishouUnitList(CtopOauthToken token, Long unidId, Date startDate, Date endDate, int time_filter_type);
 
 
     /**

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

@@ -2,8 +2,12 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import com.alibaba.fastjson.JSONArray;
 
+import java.util.Map;
+
 public interface IKuaishouRealTimeDataService {
     JSONArray getCampaignDate(Long accountId, String token, Long campaignId, String startDate, String endDate);
 
     JSONArray getUnitDate(Long accountId, String token, Long unitId, String startDate, String endDate);
+
+    Map getUnitDatePage(Long accountId, String token,String startDate, String endDate,Integer pageNum,Integer pageSize);
 }

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

@@ -1249,6 +1249,43 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
 
+  @Override
+    public JSONArray getKuaishouUnitList(CtopOauthToken token, Long unitId, Date startDate,
+                                  Date endDate, int time_filter_type) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", token.getAccountId());
+        if (startDate != null && endDate != null) {
+            param.put("start_date", DateUtils.formatDate(startDate));
+            param.put("end_date", DateUtils.formatDate(endDate));
+        }
+
+        param.put("unit_id", unitId);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Access-Token", token.getAccessToken());
+        headers.put("Content-Type", "application/json");
+
+        String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        if (Check.isNull(resultJson)) {
+            log.error("获取广告组接口异常,advertiserId:{}", token.getAccountId());
+            return null;
+        }
+        Integer code = resultJson.getInteger("code");
+        if (null == code || code != 0) {
+            log.error("获取广告组返回结果异常,advertiserId:{},异常信息:{}", token.getAccountId(), resultJson);
+            return null;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (Check.isNull(details)) {
+            return null;
+        }
+
+        return details;
+    }
+
+
     @Override
     public void getGroupList(CtopOauthToken token, Date startDate, Date endDate) {
         getGroupListByPage(token, startDate, endDate, 1);
@@ -1398,7 +1435,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     }
 
                     //转化目标
-                    if (!Check.isNull(deepConversionType) && deepConversionType != 0 && !Check.isNullMap(ocpxMap)) {
+                    if (!Check.isNull(deepConversionType) && deepConversionType != 0 && !deepMap.isEmpty()) {
                         Long deepBid = deepMap.get(deepConversionType);
                         if (Check.isNull(deepBid)) {
                             //通过key未获取值,说明不包含该目标,进行关停

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

@@ -86,9 +86,12 @@ public class KuaishouRealTimeDataServiceImpl implements IKuaishouRealTimeDataSer
         param.put("page_size", 2000);
         param.put("page", 1);
 
-        JSONArray array = new JSONArray();
-        array.add(unitId);
-        param.put("unit_ids", array);
+        if (!Check.isNull(unitId)){
+            JSONArray array = new JSONArray();
+            array.add(unitId);
+            param.put("unit_ids", array);
+        }
+
         try {
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject jsonObject = JSONObject.parseObject(result);
@@ -107,4 +110,42 @@ public class KuaishouRealTimeDataServiceImpl implements IKuaishouRealTimeDataSer
         }
         return null;
     }
+
+
+
+    @Override
+    public Map getUnitDatePage(Long accountId, String token,String startDate, String endDate,Integer pageNum,Integer pageSize) {
+        Map map = new HashMap();
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", startDate);
+        param.put("end_date", endDate);
+        param.put("advertiser_id", accountId);
+        param.put("temporal_granularity", "DAILY");
+        param.put("page_size", pageSize);
+        param.put("page", pageNum);
+
+        try {
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            if (!Check.isNull(jsonObject)) {
+                Integer code = jsonObject.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = jsonObject.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        map.put("totalCount",data.getInteger("total_count"));
+                        map.put("details",data.getJSONArray("details"));
+                        return map;
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 }

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

@@ -127,4 +127,31 @@ public class KuaishouReportHourlyGroup implements Serializable {
     private Date createTime;
     @JsonProperty
     private Date updateTime;
+
+    @JsonProperty
+    private Long eventAppInvoked;
+
+    @JsonProperty
+    private Long keyAction;
+
+    @JsonProperty
+    private Integer totalCount;
+
+    //出价
+    private Double bid;
+    //出价类型 1:CPM,2:CPC,6:OCPC(使用 OCPC 代表 OCPX),10:OCPM,20:eCPC
+    private Integer bidType;
+    //转化类型
+    private Integer converType;
+    //转化数
+    private Integer converNum;
+    //转化成本
+    private Double converCost;
+    //激活成本
+    private String activationCost;
+    //操作建议
+    private String operationAgree;
+    private String operationAgreeContent;
+    private String operationAgreeInfo;
+
 }

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

@@ -270,8 +270,13 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
                 Integer network = unitTarget.getInteger("network");
                 target.setNetwork(network == null ? 0 : network);
 
-                Integer isOpen = unitDetail.getJSONObject("target").getJSONObject("intelli_extend").getInteger("is_open");
-                target.setIsOpen(isOpen == null ? 0 : isOpen);
+                JSONObject intelliExtend = unitDetail.getJSONObject("target").getJSONObject("intelli_extend");
+                Integer isOpen = 0;
+                if(!Check.isNull(intelliExtend)){
+                    isOpen = intelliExtend.getInteger("is_open");
+                }
+
+                target.setIsOpen(isOpen);
 
                 target.setDeepConversionBid(new BigDecimal(unitDetail.getLong("deep_conversion_bid")).divide(new BigDecimal("1000")));
                 target.setDeepConversionType(unitDetail.getInteger("deep_conversion_type"));

+ 120 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/utils/LinkUtils.java

@@ -2,6 +2,8 @@ package cn.com.ctop.kuaishou.modules.utils;
 
 import com.alibaba.fastjson.JSONObject;
 
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
@@ -46,4 +48,122 @@ public class LinkUtils {
         return link;
     }
 
+
+
+    /**
+     * 判断data_value是否在interval区间范围内
+     * @param data_value 数值类型的
+     * @param interval 正常的数学区间,包括无穷大等,如:(1,3)、>5%、(-∞,6]、(125%,135%)U(70%,80%)
+     * @return true:表示data_value在区间interval范围内,false:表示data_value不在区间interval范围内
+     */
+    public static boolean isInTheInterval(String data_value,String interval) {
+        //将区间和data_value转化为可计算的表达式
+        String formula = getFormulaByAllInterval(data_value,interval,"||");
+        ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");
+        try {
+            //计算表达式
+            return (Boolean) jse.eval(formula);
+        } catch (Exception t) {
+            return false;
+        }
+    }
+
+
+
+    /**
+     * 将所有阀值区间转化为公式:如
+     * [75,80) =》 date_value < 80 && date_value >= 75
+     * (125%,135%)U(70%,80%) =》 (date_value < 1.35 && date_value > 1.25) || (date_value < 0.8 && date_value > 0.7)
+     * @param date_value
+     * @param interval 形式如:(125%,135%)U(70%,80%)
+     * @param connector 连接符 如:") || ("
+     */
+    private static String getFormulaByAllInterval(String date_value, String interval, String connector) {
+        StringBuffer buff = new StringBuffer();
+        for(String limit:interval.split("U")){//如:(125%,135%)U (70%,80%)
+            buff.append("(").append(getFormulaByInterval(date_value, limit," && ")).append(")").append(connector);
+        }
+        String allLimitInvel = buff.toString();
+        int index = allLimitInvel.lastIndexOf(connector);
+        allLimitInvel = allLimitInvel.substring(0,index);
+        return allLimitInvel;
+    }
+
+    /**
+     * 将整个阀值区间转化为公式:如
+     * 145) =》 date_value < 145
+     * [75,80) =》 date_value < 80 && date_value >= 75
+     * @param date_value
+     * @param interval 形式如:145)、[75,80)
+     * @param connector 连接符 如:&&
+     */
+    private static String getFormulaByInterval(String date_value, String interval, String connector) {
+        StringBuffer buff = new StringBuffer();
+        for(String halfInterval:interval.split(",")){//如:[75,80)、≥80
+            buff.append(getFormulaByHalfInterval(halfInterval, date_value)).append(connector);
+        }
+        String limitInvel = buff.toString();
+        int index = limitInvel.lastIndexOf(connector);
+        limitInvel = limitInvel.substring(0,index);
+        return limitInvel;
+    }
+
+
+    /**
+     * 将半个阀值区间转化为公式:如
+     * 145) =》 date_value < 145
+     * ≥80% =》 date_value >= 0.8
+     * [130 =》 date_value >= 130
+     * <80% =》 date_value < 0.8
+     * @param halfInterval 形式如:145)、≥80%、[130、<80%
+     * @param date_value
+     * @return date_value < 145
+     */
+    private static String getFormulaByHalfInterval(String halfInterval, String date_value) {
+        halfInterval = halfInterval.trim();
+        if(halfInterval.contains("∞")){//包含无穷大则不需要公式
+            return "1 == 1";
+        }
+        StringBuffer formula = new StringBuffer();
+        String data = "";
+        String opera = "";
+        if(halfInterval.matches("^([<>≤≥\\[\\(]{1}(-?\\d+.?\\d*\\%?))$")){//表示判断方向(如>)在前面 如:≥80%
+            opera = halfInterval.substring(0,1);
+            data = halfInterval.substring(1);
+        }else{//[130、145)
+            opera = halfInterval.substring(halfInterval.length()-1);
+            data = halfInterval.substring(0,halfInterval.length()-1);
+        }
+        double value = dealPercent(data);
+        formula.append(date_value).append(" ").append(opera).append(" ").append(value);
+        String a = formula.toString();
+        //转化特定字符
+        return a.replace("[", ">=").replace("(", ">").replace("]", "<=").replace(")", "<").replace("≤", "<=").replace("≥", ">=");
+    }
+
+
+    /**
+     * 去除百分号,转为小数
+     * @param str 可能含百分号的数字
+     * @return
+     */
+    private static double dealPercent(String str){
+        double d = 0.0;
+        if(str.contains("%")){
+            str = str.substring(0,str.length()-1);
+            d = Double.parseDouble(str)/100;
+        }else{
+            d = Double.parseDouble(str);
+        }
+        return d;
+    }
+
+
+    public static void main(String[] args) {
+
+        System.out.println(LinkUtils.isInTheInterval("7", "(-1,9]"));
+    }
+
+
+
 }

+ 11 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceAdvertisePlan.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.material.entity;
 
 import cn.com.ctop.common.module.annotation.Dict;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -216,6 +217,12 @@ public class ByteDanceAdvertisePlan {
     @TableField(exist=false)
     private String useOpenUrl;
 
+
+    //点击监测链接
+    private String actionTrackUrl;
+
+
+
     public ByteDanceAdvertisePlan(JSONObject dataObject, String accountId) {
         this.id = dataObject.getLong("id");
         this.accountId = accountId;
@@ -391,6 +398,10 @@ public class ByteDanceAdvertisePlan {
         if (null != externalUrl && !"".equals(externalUrl.trim())) {
             this.externalUrl = externalUrl;
         }
+        JSONArray action_track_url = dataObject.getJSONArray("action_track_url");
+        if (!Check.isNull(action_track_url)){
+            this.actionTrackUrl = action_track_url.getString(0);
+        }
     }
 
     public ByteDanceAdvertisePlan(String advertiserId, Long adId, JSONObject params) {

+ 3 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/BytedanceImageInfoMapper.java

@@ -17,11 +17,11 @@ public interface BytedanceImageInfoMapper extends BaseMapper<BytedanceImageInfo>
     void replaceBatch(@Param(value = "imageInfos")List<BytedanceImageInfo> imageInfos);
 
     //大图横图
-    void updateImageHorizonType();
+    void updateImageHorizonType(Long accountId);
     //大图竖图
-    void updateImageVerticalType();
+    void updateImageVerticalType(Long accountId);
     //开屏
-    void updateImageUnionType();
+    void updateImageUnionType(Long accountId);
     //开屏 或者 竖图
     //void updateImageUnionIOrVerticalType();
 }

+ 12 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/BytedanceImageInfoMapper.xml

@@ -48,8 +48,11 @@
         update
             ctop_bytedance_image_info
         set type = 3
-        where width &lt; height and type is null or type = 2
-            and width = 1080 and height = 1920
+        where width = 1080 and height = 1920
+        <if test="accountId !=null and accountId != ''">
+            and account_id = #{accountId}
+        </if>
+
     </update>
     <!-- 大图竖图 -->
     <update id="updateImageVerticalType">
@@ -57,7 +60,10 @@
             ctop_bytedance_image_info
         set type = 2
         where height &gt; width and type is null
-        and (height between 1280 and 2560)  and (width between 720 and 1440);
+        and (height between 1280 and 2560)  and (width between 720 and 1440)
+        <if test="accountId !=null and accountId != ''">
+            and account_id = #{accountId}
+        </if>
     </update>
     <!-- 大图横图 -->
     <update id="updateImageHorizonType">
@@ -65,5 +71,8 @@
             set type = 1
         where height &lt; width and type is null
         and (width between 1280 and 2560)  and (height between 720 and 1440)
+        <if test="accountId !=null and accountId != ''">
+            and account_id = #{accountId}
+        </if>
     </update>
 </mapper>

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceImageInfoService.java

@@ -17,5 +17,5 @@ public interface IBytedanceImageInfoService extends IService<BytedanceImageInfo>
     /**
      * 清洗图片素材类型
      */
-    void updateType();
+    void updateType(Long accountId);
 }

+ 5 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -242,6 +242,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
                 advertisePlan.setDeepCpaBid(deepCpabid);
             }
             advertisePlanService.saveOrUpdate(advertisePlan);
+            //log.info("============保存头条计划=================");
         }
         getAd(token, pageNum + 1, ids, date, updateDate);
     }
@@ -644,6 +645,8 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         updaBytedanceVideoByAccountId(token);
         getVideoByPage(token, "", 1);
         getImageByPage(token, "", 1);
+        //修改图片类型
+        imageInfoService.updateType(token.getAccountId());
     }
 
     @Autowired
@@ -681,7 +684,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         }
         JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
         if (null == data || data.isEmpty()) {
-            log.info("获取图片素材完成==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
+            log.info("获取头条图片素材完成==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
             return;
         }
         List<BytedanceImageInfo> videoInfoList = new ArrayList<>();
@@ -725,7 +728,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         }
         JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
         if (null == data || data.isEmpty()) {
-            log.info("获取视频素材完成==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
+            log.info("获取头条视频素材完成==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
             return;
         }
         List<ByteDanceVideoInfo> videoInfoList = new ArrayList<>();

+ 7 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceImageInfoServiceImpl.java

@@ -4,6 +4,7 @@ import cn.com.ctop.toutiao.modules.material.entity.BytedanceImageInfo;
 import cn.com.ctop.toutiao.modules.material.mapper.BytedanceImageInfoMapper;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceImageInfoService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -17,6 +18,7 @@ import java.util.List;
  * @version V1.0
  */
 @Service
+@Slf4j
 public class BytedanceImageInfoServiceImpl extends ServiceImpl<BytedanceImageInfoMapper, BytedanceImageInfo> implements IBytedanceImageInfoService {
     @Resource
     private BytedanceImageInfoMapper imageInfoMapper;
@@ -26,13 +28,14 @@ public class BytedanceImageInfoServiceImpl extends ServiceImpl<BytedanceImageInf
     }
 
     @Override
-    public void updateType() {
+    public void updateType(Long accountId) {
         //大图竖图 -2
-        imageInfoMapper.updateImageVerticalType();
+        imageInfoMapper.updateImageVerticalType(accountId);
         //大图横图 -1
-        imageInfoMapper.updateImageHorizonType();
+        imageInfoMapper.updateImageHorizonType(accountId);
         //开屏-3
-        imageInfoMapper.updateImageUnionType();
+        imageInfoMapper.updateImageUnionType(accountId);
+        log.info("清洗头条图片类型成功=====>>>>>accountId:{}",accountId);
         //开屏 或者 竖图 -4
         //imageInfoMapper.updateImageUnionIOrVerticalType();
     }

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

@@ -562,6 +562,7 @@ public class ReportServiceImpl implements IReportService {
         conditions.setEndDate(DateUtils.formatDate(endDate));
         conditions.setPageSize(1000);
         conditions.setTimeGranularity(bytedanceReportTypePl);
+        conditions.setFields(conditions.getFieldsList());
         return conditions;
     }