Browse Source

添加头条规则清洗字段实体类

syh 4 years ago
parent
commit
c69207591b
18 changed files with 173 additions and 28 deletions
  1. 1 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysBaseApiImpl.java
  3. 8 13
      jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
  4. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataAccountController.java
  5. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataCreativeController.java
  6. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataPlanController.java
  7. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataTargetController.java
  8. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataWasteCostController.java
  9. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccount.java
  10. 41 3
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataPlan.java
  11. 12 2
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTarget.java
  12. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataPlanService.java
  13. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataPlanServiceImpl.java
  14. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAgentAccount.java
  15. 3 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java
  16. 33 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  17. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IReportService.java
  18. 62 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java

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

@@ -59,6 +59,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/sys/mLogin", "anon");
         filterChainDefinitionMap.put("/sys/mLogin", "anon");
         filterChainDefinitionMap.put("/sys/login", "anon");
         filterChainDefinitionMap.put("/sys/login", "anon");
         filterChainDefinitionMap.put("/sys/wxlogin", "anon");
         filterChainDefinitionMap.put("/sys/wxlogin", "anon");
+        filterChainDefinitionMap.put("/ctop/rule/**", "anon");
         //第三方登录
         //第三方登录
         filterChainDefinitionMap.put("/thirdLogin/**", "anon");
         filterChainDefinitionMap.put("/thirdLogin/**", "anon");
         //获取加密串
         //获取加密串

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

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

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

@@ -118,6 +118,14 @@ public class SampleTest {
         }
         }
     }
     }
 
 
+    @Test
+    public void testLoadRulePlanData(){
+        List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
+        for(CtopOauthToken token :tokens){
+            reportService.getAdvertiserPlanRuleData(token,new Date(),new Date(),CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
+        }
+    }
+
     @Autowired
     @Autowired
     private IUserAllocationService allocationService;
     private IUserAllocationService allocationService;
 
 
@@ -245,19 +253,6 @@ public class SampleTest {
     }
     }
 
 
 
 
-
-    @Test
-    public void loadAccountData() {
-//        List<UserAllocation> allocations = allocationService.getByParams(776L,null,0);
-//        for (UserAllocation allocation:allocations) {
-            CtopOauthToken token = tokenService.getTokenByAccountId(93238965516L);
-            for(int i=92;i<100;i++){
-                Date getDate = DateUtils.addDay(new Date(),-i);
-                reportService.getAdvertiserReport(token, getDate, getDate, CtopAdConstant.BYTEDANCE_REPORT_TYPE_DAILY);
-            }
-//        }
-    }
-
     @Autowired
     @Autowired
     IUReportExportService uReportExportService;
     IUReportExportService uReportExportService;
     @Autowired
     @Autowired

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataAccountController.java

@@ -41,7 +41,7 @@ import java.util.Map;
 @Slf4j
 @Slf4j
 @Api(tags="规则账户清洗数据")
 @Api(tags="规则账户清洗数据")
 @RestController
 @RestController
-@RequestMapping("/ctop/ruleDataAccount")
+@RequestMapping("/ctop/rule/account")
 public class RuleDataAccountController {
 public class RuleDataAccountController {
 	@Autowired
 	@Autowired
 	private IRuleDataAccountService ruleDataAccountService;
 	private IRuleDataAccountService ruleDataAccountService;

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataCreativeController.java

@@ -25,7 +25,7 @@ import java.util.Arrays;
 @Slf4j
 @Slf4j
 @Api(tags="规则创意清洗数据")
 @Api(tags="规则创意清洗数据")
 @RestController
 @RestController
-@RequestMapping("/ctop/ruleDataCreative")
+@RequestMapping("/ctop/rule/creative")
 public class RuleDataCreativeController {
 public class RuleDataCreativeController {
 	@Autowired
 	@Autowired
 	private IRuleDataCreativeService ruleDataCreativeService;
 	private IRuleDataCreativeService ruleDataCreativeService;

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataPlanController.java

@@ -25,7 +25,7 @@ import java.util.Arrays;
 @Slf4j
 @Slf4j
 @Api(tags="规则计划清洗数据")
 @Api(tags="规则计划清洗数据")
 @RestController
 @RestController
-@RequestMapping("/ctop/ruleDataPlan")
+@RequestMapping("/ctop/rule/plan")
 public class RuleDataPlanController {
 public class RuleDataPlanController {
 	@Autowired
 	@Autowired
 	private IRuleDataPlanService ruleDataPlanService;
 	private IRuleDataPlanService ruleDataPlanService;

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataTargetController.java

@@ -25,7 +25,7 @@ import java.util.Arrays;
 @Slf4j
 @Slf4j
 @Api(tags="规则定向清洗数据")
 @Api(tags="规则定向清洗数据")
 @RestController
 @RestController
-@RequestMapping("/ctop/ruleDataTarget")
+@RequestMapping("/ctop/rule/target")
 public class RuleDataTargetController {
 public class RuleDataTargetController {
 	@Autowired
 	@Autowired
 	private IRuleDataTargetService ruleDataTargetService;
 	private IRuleDataTargetService ruleDataTargetService;

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataWasteCostController.java

@@ -25,7 +25,7 @@ import java.util.Arrays;
 @Slf4j
 @Slf4j
 @Api(tags="规则空耗清洗数据")
 @Api(tags="规则空耗清洗数据")
 @RestController
 @RestController
-@RequestMapping("/ctop/ruleDataWasteCost")
+@RequestMapping("/ctop/rule/wasteCost")
 public class RuleDataWasteCostController {
 public class RuleDataWasteCostController {
 	@Autowired
 	@Autowired
 	private IRuleDataWasteCostService ruleDataWasteCostService;
 	private IRuleDataWasteCostService ruleDataWasteCostService;

+ 1 - 1
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccount.java

@@ -39,7 +39,7 @@ public class RuleDataAccount {
 	/**转化数*/
 	/**转化数*/
 	@Excel(name = "转化数", width = 15)
 	@Excel(name = "转化数", width = 15)
     @ApiModelProperty(value = "转化数")
     @ApiModelProperty(value = "转化数")
-	private Long convert;
+	private Long convertNum;
 	/**转化成本*/
 	/**转化成本*/
 	@Excel(name = "转化成本", width = 15)
 	@Excel(name = "转化成本", width = 15)
     @ApiModelProperty(value = "转化成本")
     @ApiModelProperty(value = "转化成本")

+ 41 - 3
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataPlan.java

@@ -1,6 +1,6 @@
 package cn.com.ctop.common.module.entity;
 package cn.com.ctop.common.module.entity;
 
 
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
@@ -26,9 +26,10 @@ import java.util.Date;
 @ApiModel(value="ctop_rule_data_plan对象", description="规则计划清洗数据")
 @ApiModel(value="ctop_rule_data_plan对象", description="规则计划清洗数据")
 public class RuleDataPlan {
 public class RuleDataPlan {
 
 
-	@TableId(type = IdType.AUTO)
+	@TableId
 	private Long id;
 	private Long id;
 	private Long accountId;
 	private Long accountId;
+	private String accountName;
 	private Long planId;
 	private Long planId;
 	private String planName;
 	private String planName;
 	/**externalUrl*/
 	/**externalUrl*/
@@ -46,7 +47,7 @@ public class RuleDataPlan {
 	/**convert*/
 	/**convert*/
 	@Excel(name = "convert", width = 15)
 	@Excel(name = "convert", width = 15)
     @ApiModelProperty(value = "convert")
     @ApiModelProperty(value = "convert")
-	private Long convert;
+	private Long convertNum;
 	/**convertCost*/
 	/**convertCost*/
 	@Excel(name = "convertCost", width = 15)
 	@Excel(name = "convertCost", width = 15)
     @ApiModelProperty(value = "convertCost")
     @ApiModelProperty(value = "convertCost")
@@ -55,6 +56,8 @@ public class RuleDataPlan {
 	@Excel(name = "nextDayOpenRate", width = 15)
 	@Excel(name = "nextDayOpenRate", width = 15)
     @ApiModelProperty(value = "nextDayOpenRate")
     @ApiModelProperty(value = "nextDayOpenRate")
 	private BigDecimal nextDayOpenRate;
 	private BigDecimal nextDayOpenRate;
+	private BigDecimal nextDayOpenCost;
+	private Long nextDayOpen;
 	/**付费方式*/
 	/**付费方式*/
 	@Excel(name = "付费方式", width = 15)
 	@Excel(name = "付费方式", width = 15)
     @ApiModelProperty(value = "付费方式")
     @ApiModelProperty(value = "付费方式")
@@ -69,4 +72,39 @@ public class RuleDataPlan {
 	/**updateTime*/
 	/**updateTime*/
     @ApiModelProperty(value = "updateTime")
     @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
 	private Date updateTime;
+
+	public RuleDataPlan(JSONObject data, Long accountId) {
+		Long nextDayOpen = data.getLong("attribution_next_day_open_cnt");
+		if (null != nextDayOpen) {
+			this.nextDayOpen = nextDayOpen;
+		}
+		Long convert = data.getLong("convert");
+		if (null != convert) {
+			this.convertNum = convert;
+		}
+		BigDecimal nextDayOpenCost = data.getBigDecimal("attribution_next_day_open_cost");
+		if (null != nextDayOpenCost) {
+			this.nextDayOpenCost = nextDayOpenCost;
+		}
+
+		BigDecimal nextDayOpenRate = data.getBigDecimal("attribution_next_day_open_rate");
+		if (null != nextDayOpenRate) {
+			this.nextDayOpenRate = nextDayOpenRate;
+		}
+		this.accountId = accountId;
+		BigDecimal cost = data.getBigDecimal("cost");
+		if (null != cost) {
+			this.cost = cost;
+		}
+
+		String adName = data.getString("ad_name");
+		if (null != adName) {
+			this.planName = adName;
+		}
+		Long adId = data.getLong("ad_id");
+		this.id = adId;
+		this.planId = adId;
+		this.createTime = new Date();
+		this.updateTime = new Date();
+	}
 }
 }

+ 12 - 2
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTarget.java

@@ -1,6 +1,6 @@
 package cn.com.ctop.common.module.entity;
 package cn.com.ctop.common.module.entity;
 
 
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
@@ -25,9 +25,10 @@ import java.util.Date;
 @ApiModel(value="ctop_rule_data_target对象", description="规则定向清洗数据")
 @ApiModel(value="ctop_rule_data_target对象", description="规则定向清洗数据")
 public class RuleDataTarget {
 public class RuleDataTarget {
 
 
-	@TableId(type = IdType.AUTO)
+	@TableId
 	private Long id;
 	private Long id;
 	private Long accountId;
 	private Long accountId;
+	private String accountName;
 	private Long planId;
 	private Long planId;
 	private String planName;
 	private String planName;
 	/**retargetingTagsExclude*/
 	/**retargetingTagsExclude*/
@@ -84,4 +85,13 @@ public class RuleDataTarget {
 	/**updateTime*/
 	/**updateTime*/
     @ApiModelProperty(value = "updateTime")
     @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
 	private Date updateTime;
+
+	public RuleDataTarget(CtopOauthToken token, Long planId, JSONObject data, String authName) {
+		this.accountId = token.getAccountId();
+		this.accountName = authName;
+		this.planId = planId;
+		this.id = planId;
+		this.createTime = new Date();
+		this.updateTime = new Date();
+	}
 }
 }

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

@@ -10,5 +10,4 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @Version: V1.0
  * @Version: V1.0
  */
  */
 public interface IRuleDataPlanService extends IService<RuleDataPlan> {
 public interface IRuleDataPlanService extends IService<RuleDataPlan> {
-
 }
 }

+ 3 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataPlanServiceImpl.java

@@ -4,8 +4,11 @@ import cn.com.ctop.common.module.entity.RuleDataPlan;
 import cn.com.ctop.common.module.mapper.RuleDataPlanMapper;
 import cn.com.ctop.common.module.mapper.RuleDataPlanMapper;
 import cn.com.ctop.common.module.service.IRuleDataPlanService;
 import cn.com.ctop.common.module.service.IRuleDataPlanService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.List;
+
 /**
 /**
  * 规则计划清洗数据
  * 规则计划清洗数据
  * @author jeecg-boot
  * @author jeecg-boot
@@ -14,5 +17,4 @@ import org.springframework.stereotype.Service;
  */
  */
 @Service
 @Service
 public class RuleDataPlanServiceImpl extends ServiceImpl<RuleDataPlanMapper, RuleDataPlan> implements IRuleDataPlanService {
 public class RuleDataPlanServiceImpl extends ServiceImpl<RuleDataPlanMapper, RuleDataPlan> implements IRuleDataPlanService {
-
 }
 }

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

@@ -34,7 +34,7 @@ public class KuaishouAgentAccount {
 	/**accountId*/
 	/**accountId*/
 	@Excel(name = "userId", width = 15)
 	@Excel(name = "userId", width = 15)
     @ApiModelProperty(value = "userId")
     @ApiModelProperty(value = "userId")
-	private Integer userId;
+	private Long userId;
 	/**accountName*/
 	/**accountName*/
 	@Excel(name = "accountName", width = 15)
 	@Excel(name = "accountName", width = 15)
     @ApiModelProperty(value = "accountName")
     @ApiModelProperty(value = "accountName")

+ 3 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.material.service;
 package cn.com.ctop.toutiao.modules.material.service;
 
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 
 
@@ -15,6 +16,8 @@ public interface IByteDanceAdvertiserDataService {
 
 
     Map<String, Object> getAdvertiserInfo(String accountId, String token);
     Map<String, Object> getAdvertiserInfo(String accountId, String token);
 
 
+    ByteDanceAdvertisePlan getSinglePlanById(CtopOauthToken token, String id);
+
     Map<String, Object> getAdvertiserPlan(CtopOauthToken token, String ids, String date, String updateDate);
     Map<String, Object> getAdvertiserPlan(CtopOauthToken token, String ids, String date, String updateDate);
 
 
     Map<String, Object> getAdvertiserBudget(String accountId);
     Map<String, Object> getAdvertiserBudget(String accountId);

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

@@ -156,6 +156,39 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         return new JSONArray();
         return new JSONArray();
     }
     }
 
 
+    @Override
+    public ByteDanceAdvertisePlan getSinglePlanById(CtopOauthToken token, String id){
+        JSONArray getIds = new JSONArray();
+        getIds.add(id);
+        // 请求地址
+        String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get");
+        // 请求参数
+        Map<String, Object> filtering = new HashMap<>();
+        filtering.put("ids", getIds);
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", token.getAccountId());
+        param.put("page", 1);
+        param.put("page_size", 100);
+        param.put("filtering", filtering);
+        JSONObject resultObject = HttpUtils.bytedanceGetRequest(token.getAccessToken(), url, param);
+        Integer code = resultObject.getInteger("code");
+        if (null == code || !code.equals(0)) {
+            log.error("获取广告计划信息接口异常==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
+            return null;
+        }
+        JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
+        if (null == data || data.isEmpty()) {
+            return null;
+        }
+        JSONObject dataObject = data.getJSONObject(0);
+        ByteDanceAdvertisePlan advertisePlan = new ByteDanceAdvertisePlan(dataObject, String.valueOf(token.getAccountId()));
+        BigDecimal deepCpabid = dataObject.getBigDecimal("deep_cpabid");
+        if (null != deepCpabid) {
+            advertisePlan.setDeepCpaBid(deepCpabid);
+        }
+        return advertisePlan;
+    }
+
 
 
     public void getAd(CtopOauthToken token, int pageNum, String ids, String date, String updateDate) {
     public void getAd(CtopOauthToken token, int pageNum, String ids, String date, String updateDate) {
         JSONArray getIds = null;
         JSONArray getIds = null;

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

@@ -16,6 +16,8 @@ public interface IReportService {
 
 
     void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
     void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
 
 
+    void getAdvertiserPlanRuleData(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl);
+
     void getAdvertiserCreativeReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
     void getAdvertiserCreativeReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePL);
 
 
     void getMaterialReportByPage(CtopOauthToken token, String startDate, String endDate, Integer pageNum);
     void getMaterialReportByPage(CtopOauthToken token, String startDate, String endDate, Integer pageNum);

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

@@ -1,12 +1,19 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.RuleDataPlan;
+import cn.com.ctop.common.module.entity.RuleDataTarget;
+import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataPlanService;
+import cn.com.ctop.common.module.service.IRuleDataTargetService;
+import cn.com.ctop.common.module.service.IUserAllocationService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.common.module.vo.ByteDanceAdvertiserReportDTO;
 import cn.com.ctop.common.module.vo.ByteDanceAdvertiserReportDTO;
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import cn.com.ctop.toutiao.modules.report.entity.*;
 import cn.com.ctop.toutiao.modules.report.entity.*;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
@@ -146,12 +153,66 @@ public class ReportServiceImpl implements IReportService {
         getCampaignReportByPage(token, conditions, page + 1);
         getCampaignReportByPage(token, conditions, page + 1);
     }
     }
 
 
+
     @Override
     @Override
     public void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
     public void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
         var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
         var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
         getPlanReportByPage(token, conditions, 1);
         getPlanReportByPage(token, conditions, 1);
     }
     }
 
 
+    @Override
+    public void getAdvertiserPlanRuleData(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
+        var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
+        getPlanRuleDataByPage(token, conditions, 1);
+    }
+
+    private void getPlanRuleDataByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
+        conditions.setPage(page);
+        var config = new SerializeConfig();
+        config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
+        var jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
+
+        JSONObject getObject = getAdStat(token, jsonObject);
+        if (null == getObject) {
+            log.error("广告计划报表数据获取异常=》account:{};message:{}", token.getAccountId(), "返回数据异常");
+            return;
+        }
+        Integer code = getObject.getInteger("code");
+        var message = getObject.getString("message");
+        if (null == code || code != 0) {
+            log.error("广告计划报表数据获取异常=》account:{};message:{}", token.getAccountId(), message);
+            return;
+        }
+        var dataArray = getObject.getJSONObject("data").getJSONArray("list");
+        if (null == dataArray || dataArray.size() <= 0) {
+            return;
+        }
+        UserAllocation allocation = userAllocationService.getByAccountId(token.getAccountId());
+        for (var i = 0; i < dataArray.size(); i++) {
+            var data = dataArray.getJSONObject(i);
+            var dailyReport = new RuleDataPlan(data, token.getAccountId());
+            dailyReport.setAccountName(allocation.getAuthName());
+            ByteDanceAdvertisePlan plan = advertiserDataService.getSinglePlanById(token,dailyReport.getId()+"");
+            if(null!=plan){
+                dailyReport.setBudget(plan.getBudget());
+                dailyReport.setDownloadUrl(plan.getDownloadUrl());
+                dailyReport.setExternalUrl(plan.getExternalUrl());
+                dailyReport.setPricing(plan.getPricing());
+                RuleDataTarget target = new RuleDataTarget(token,dailyReport.getId(),data,allocation.getAuthName());
+
+            }
+            ruleDataPlanService.saveOrUpdate(dailyReport);
+        }
+        getPlanRuleDataByPage(token, conditions, page + 1);
+    }
+
+    @Autowired
+    private IUserAllocationService userAllocationService;
+    @Autowired
+    private IRuleDataPlanService ruleDataPlanService;
+    @Autowired
+    private IRuleDataTargetService ruleDataTargetService;
+
     private void getPlanReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
     private void getPlanReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
         conditions.setPage(page);
         conditions.setPage(page);
         var config = new SerializeConfig();
         var config = new SerializeConfig();
@@ -185,6 +246,7 @@ public class ReportServiceImpl implements IReportService {
                 hourlyReports.add(hourlyReport);
                 hourlyReports.add(hourlyReport);
             } else {
             } else {
                 var dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());
                 var dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());
+                //获取计划详情
                 dailyReports.add(dailyReport);
                 dailyReports.add(dailyReport);
             }
             }
         }
         }