Selaa lähdekoodia

伊对报表计划数据获取

syh 5 vuotta sitten
vanhempi
commit
5ead49bc42

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

@@ -79,6 +79,8 @@ spring:
     exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure
   datasource:
     druid:
+      removeAbandoned: true
+      removeAbandonedTimeout: 300
       stat-view-servlet:
         enabled: true
         loginUsername: admin

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

@@ -1,6 +1,7 @@
 spring:
   profiles:
-    active: @activatedProperties@
+    active: prod
+  #      active: @activatedProperties@
   application:
     name: system-web
 eureka:

+ 1 - 13
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -267,20 +267,8 @@ public class SampleTest {
     @Test
     public void loadBtPlanData() {
         List<CtopOauthToken> tokens = tokenService.getTokenListByType(CtopAdConstant.PLATFORM_TYPE_BYTEDANCE);
-        executorService = Executors.newFixedThreadPool(10);
         tokens.forEach(token -> {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        //1:获取当日广告计划数据
-                        advertiserDataService.getAdvertiserPlan(token, "", null, null);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                    } finally {
-                    }
-                }
-            });
+            advertiserDataService.getAdvertiserPlan(token, "", null, null);
         });
     }
 

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

@@ -59,4 +59,9 @@ public class CtopAdConstant {
      * 华北头条销售机构号
      */
     public static final String HB_BYTEDANCE_SALE_ORG_CODE = "A01A11A02";
+
+    public static final String BYTEDANCE_GENDER_TYPE_NONE = "NONE";
+    public static final String BYTEDANCE_GENDER_TYPE_GENDER_MALE = "GENDER_MALE";
+    public static final String BYTEDANCE_GENDER_TYPE_GENDER_FEMALE = "GENDER_FEMALE";
+
 }

+ 40 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/entity/ByteDanceAdvertisePlan.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.entity;
 
-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;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -12,6 +13,7 @@ import lombok.experimental.Accessors;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * 今日头条广告计划信息
@@ -219,10 +221,22 @@ public class ByteDanceAdvertisePlan {
      */
     @Excel(name = "audience", width = 15)
     @ApiModelProperty(value = "audience")
-    private Object audience;
+    private String audience;
     @Excel(name = "上次修改时间", width = 15)
     @ApiModelProperty(value = "上次修改时间")
     private String modifyTime;
+    /**
+     * 受众性别
+     */
+    private String gender;
+    /**
+     * 受众平台
+     */
+    private String platform;
+
+    private Date createTime;
+
+    private Date updateTime;
 
     public ByteDanceAdvertisePlan(JSONObject dataObject, String accountId) {
         Long id = dataObject.getLong("id");
@@ -232,7 +246,30 @@ public class ByteDanceAdvertisePlan {
         if (null != name && !"".equals(name.trim())) {
             this.name = name;
         }
-
+        JSONObject audience = dataObject.getJSONObject("audience");
+        if (null != audience) {
+            this.audience = audience.toJSONString();
+            JSONArray platform = audience.getJSONArray("platform");
+            if (null != platform && platform.size() > 0) {
+                String plat = "";
+                for (int i = 0; i < platform.size(); i++) {
+                    plat += platform.getString(i) + ",";
+                }
+                this.platform = plat.substring(0, plat.length() - 1);
+            }
+            String gender = audience.getString("gender");
+            if (null != gender) {
+                if (CtopAdConstant.BYTEDANCE_GENDER_TYPE_NONE.equals(gender)) {
+                    this.gender = "不限";
+                } else if (CtopAdConstant.BYTEDANCE_GENDER_TYPE_GENDER_MALE.equals(gender)) {
+                    this.gender = "男";
+                } else {
+                    this.gender = "女";
+                }
+            }
+        }
+        this.createTime = new Date();
+        this.updateTime = new Date();
         Long advertiserId = dataObject.getLong("advertiser_id");
         if (null != advertiserId) {
             this.toutiaoId = advertiserId;

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -111,6 +111,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         param.put("page_size", 100);
         param.put("filtering", filtering);
         JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
+        System.out.println(resultObject.toJSONString());
         Integer code = resultObject.getInteger("code");
         if (null == code || !code.equals(0)) {
             log.error("获取广告计划信息接口异常==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
@@ -123,7 +124,6 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         }
         for (int i = 0; i < data.size(); i++) {
             JSONObject dataObject = data.getJSONObject(i);
-            System.out.println(dataObject.toJSONString());
             ByteDanceAdvertisePlan advertisePlan = new ByteDanceAdvertisePlan(dataObject, String.valueOf(token.getAccountId()));
             BigDecimal deepCpabid = dataObject.getBigDecimal("deep_cpabid");
             if (null != deepCpabid) {