浏览代码

Merge remote-tracking branch 'origin/master_rule_engine' into master_rule_engine

# Conflicts:
#	module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java
zhaoxian 5 年之前
父节点
当前提交
626c3c029f
共有 30 个文件被更改,包括 280 次插入53 次删除
  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. 30 18
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleAccountTemplateController.java
  5. 2 1
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleGroupController.java
  6. 3 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleTemplateController.java
  7. 1 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleAccountTemplate.java
  8. 1 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleIndicator.java
  9. 2 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/mapper/RuleIndicatorMapper.java
  10. 10 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/mapper/xml/RuleIndicatorMapper.xml
  11. 9 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/IRuleIndicatorService.java
  12. 0 3
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleAccountTemplateServiceImpl.java
  13. 21 2
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java
  14. 5 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleIndicatorServiceImpl.java
  15. 23 1
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java
  16. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataAccountController.java
  17. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataCreativeController.java
  18. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataPlanController.java
  19. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataTargetController.java
  20. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/controller/RuleDataWasteCostController.java
  21. 1 1
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccount.java
  22. 41 3
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataPlan.java
  23. 12 2
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTarget.java
  24. 0 1
      module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataPlanService.java
  25. 3 1
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataPlanServiceImpl.java
  26. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouAgentAccount.java
  27. 3 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IByteDanceAdvertiserDataService.java
  28. 33 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  29. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IReportService.java
  30. 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/login", "anon");
         filterChainDefinitionMap.put("/sys/wxlogin", "anon");
+        filterChainDefinitionMap.put("/ctop/rule/**", "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
-    @Cacheable(cacheNames = CacheConstant.SYS_USERS_CACHE, key = "#username")
+//    @Cacheable(cacheNames = CacheConstant.SYS_USERS_CACHE, key = "#username")
     public LoginUser getUserByName(String username) {
         if (oConvertUtils.isEmpty(username)) {
             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
     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
     IUReportExportService uReportExportService;
     @Autowired

+ 30 - 18
module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleAccountTemplateController.java

@@ -3,6 +3,7 @@ package cn.com.ctop.alarm.modules.controller;
 import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
 import cn.com.ctop.alarm.modules.entity.RuleTemplate;
 import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
+import cn.com.ctop.alarm.modules.service.IRuleAccountThresholdService;
 import cn.com.ctop.alarm.modules.service.IRuleTemplateService;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.utils.Check;
@@ -34,6 +35,7 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -53,6 +55,8 @@ public class RuleAccountTemplateController {
     private IRuleAccountTemplateService ruleAccountTemplateService;
     @Autowired
     private IRuleTemplateService templateService;
+    @Autowired
+    private IRuleAccountThresholdService accountThresholdService;
 
     @GetMapping(value = "/checkAccountTemplate")
     public Result<JSONObject> checkAccountTemplate(Long accountId) {
@@ -109,6 +113,32 @@ public class RuleAccountTemplateController {
 
 
     /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "规则模板-通过id删除")
+    @ApiOperation(value = "规则模板-通过id删除", notes = "规则模板-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            RuleAccountTemplate accountTemplate = ruleAccountTemplateService.getById(id);
+            if (!Check.isNull(accountTemplate)) {
+                Map<String, Object> deleteMap = new HashMap<>();
+                deleteMap.put("account_id", accountTemplate.getAccountId());
+                accountThresholdService.removeByMap(deleteMap);
+                ruleAccountTemplateService.removeById(id);
+            }
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+
+    /**
      * 分页列表查询
      *
      * @param ruleAccountTemplate
@@ -193,24 +223,6 @@ public class RuleAccountTemplateController {
         return result;
     }
 
-    /**
-     * 通过id删除
-     *
-     * @param id
-     * @return
-     */
-    @AutoLog(value = "规则模板-通过id删除")
-    @ApiOperation(value = "规则模板-通过id删除", notes = "规则模板-通过id删除")
-    @DeleteMapping(value = "/delete")
-    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
-        try {
-            ruleAccountTemplateService.removeById(id);
-        } catch (Exception e) {
-            log.error("删除失败", e.getMessage());
-            return Result.error("删除失败!");
-        }
-        return Result.ok("删除成功!");
-    }
 
     /**
      * 批量删除

+ 2 - 1
module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleGroupController.java

@@ -119,7 +119,8 @@ public class RuleGroupController {
                     JSONArray groupIds = JSONArray.parseArray(ruleTemplate.getGroupIds());
                     Iterator<Object> o = groupIds.iterator();
                     while (o.hasNext()) {
-                        Long groupId = (Long) o.next();
+                        System.err.println(o.next());
+                        String groupId = String.valueOf(o.next());
                         if (groupId.equals(id)) {
                             o.remove();
                         }

+ 3 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleTemplateController.java

@@ -211,6 +211,9 @@ public class RuleTemplateController {
                 if (!Check.isNull(groupList)) {
                     for (RuleGroup group : groupList) {
                         JSONArray ruleIds = JSONArray.parseArray(group.getRuleIds());
+                        if (Check.isNull(ruleIds)) {
+                            continue;
+                        }
                         for (int i = 0; i < ruleIds.size(); i++) {
                             Long ruleId = ruleIds.getLong(i);
                             ruleBaseService.removeById(ruleId);

+ 1 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleAccountTemplate.java

@@ -44,6 +44,7 @@ public class RuleAccountTemplate {
     @Excel(name = "模板id", width = 15)
     @ApiModelProperty(value = "模板id")
     private Long templateId;
+
     /**
      * createTime
      */

+ 1 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/entity/RuleIndicator.java

@@ -56,6 +56,7 @@ public class RuleIndicator {
     @Excel(name = "数据类型", width = 15)
     @ApiModelProperty(value = "数据类型")
     private String dataType;
+    private String modelType;
     /**
      * 数据单位
      */

+ 2 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/mapper/RuleIndicatorMapper.java

@@ -14,4 +14,6 @@ import org.apache.ibatis.annotations.Param;
 public interface RuleIndicatorMapper extends BaseMapper<RuleIndicator> {
 
     String getRuleIndicatorNameByMediaTypeAndDimension(@Param("mediaType") Integer mediaType, @Param("dimension") String dimension);
+
+    String getDataTypeByRuleDimensionAndIndicatorCode(@Param("ruleDimension") String ruleDimension,@Param("indicatorCode") String indicatorCode);
 }

+ 10 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/mapper/xml/RuleIndicatorMapper.xml

@@ -9,4 +9,14 @@
       and dimension = #{dimension}
       limit 1
     </select>
+
+    <select id="getDataTypeByRuleDimensionAndIndicatorCode" resultType="java.lang.String">
+      select  data_type
+      from ctop_rule_indicator
+      where  code = #{indicatorCode}
+      and dimension = #{ruleDimension}
+      limit 1
+    </select>
+
+
 </mapper>

+ 9 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/IRuleIndicatorService.java

@@ -12,4 +12,13 @@ import com.baomidou.mybatisplus.extension.service.IService;
 public interface IRuleIndicatorService extends IService<RuleIndicator> {
 
     String getRuleIndicatorNameByMediaTypeAndDimension(Integer mediaType, String dimension);
+
+    /**
+     * 根据数据维度和指标查询 数据类型
+     *
+     * @param ruleDimension
+     * @param indicatorCode
+     * @return
+     */
+    String getDataTypeByRuleDimensionAndIndicatorCode(String ruleDimension, String indicatorCode);
 }

+ 0 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleAccountTemplateServiceImpl.java

@@ -63,10 +63,7 @@ public class RuleAccountTemplateServiceImpl extends ServiceImpl<RuleAccountTempl
         if (insert == 0) {
             throw new Exception("推送失败,请联系相关技术人员");
         }
-
-
         JSONObject returnJson = new JSONObject();
-
         Integer groupCount = 0;
         for (int i = 0; i < groupIds.size(); i++) {
             Long groupId = groupIds.getLong(i);

+ 21 - 2
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -14,6 +14,8 @@ import cn.com.ctop.alarm.modules.mapper.RuleBaseMapper;
 import cn.com.ctop.alarm.modules.mapper.RuleGroupMapper;
 import cn.com.ctop.alarm.modules.mapper.RuleIndicatorMapper;
 import cn.com.ctop.alarm.modules.mapper.RuleTemplateMapper;
+import cn.com.ctop.alarm.modules.entity.*;
+import cn.com.ctop.alarm.modules.mapper.*;
 import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
 import cn.com.ctop.alarm.modules.service.IRuleGroupService;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
@@ -331,7 +333,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
     public JSONObject createRuleGroup(com.alibaba.fastjson.JSONObject requestJson) {
         JSONObject returnJson = new JSONObject();
         try {
-            String templateId = requestJson.getString("templateId");
+            Long templateId = requestJson.getLong("templateId");
             if (Check.isNull(templateId)) {
                 throw new Exception("请选择需要创建的规则模板id");
             }
@@ -369,10 +371,17 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                         if (!Check.isNull(accountList)) {
                             for (RuleAccountTemplate accountTemplate : accountList) {
                                 Long accountId = accountTemplate.getAccountId();
+                                QueryWrapper<RuleAccountThreshold> thresholdQueryWrapper = new QueryWrapper<>();
+                                thresholdQueryWrapper.eq("account_id", accountId);
+                                thresholdQueryWrapper.eq("rule_id", ruleBase.getId());
+                                thresholdQueryWrapper.last("limit 1");
+                                RuleAccountThreshold accountThreshold = ruleAccountThresholdMapper.selectOne(thresholdQueryWrapper);
+                                if (!Check.isNull(accountThreshold)) {
+                                    continue;
+                                }
                                 RuleAccountThreshold threshold = new RuleAccountThreshold();
                                 threshold.setAccountId(accountId);
                                 threshold.setRuleId(ruleBase.getId());
-                                // threshold.setThreshoId(ruleDetailJson.getString("threshold"));
                                 ruleAccountThresholdMapper.insert(threshold);  // 默认将新建的规则同步到已应用的账户下
                             }
                         }
@@ -382,11 +391,21 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 RuleGroup ruleGroup = new RuleGroup();
                 ruleGroup.setRuleIds(ruleIds.toJSONString());
                 ruleGroup.setRuleType(groupJson.getString("ruleType"));
+                ruleGroup.setTemplateId(templateId);
                 ruleGroup.setRuleRelationship(groupJson.getString("ruleRelationship"));
                 ruleGroup.setGroupName(groupJson.getString("groupName"));
                 ruleGroup.setRemark(groupJson.getString("remark"));
                 boolean save = ruleGroupService.save(ruleGroup); // 新增规则组
                 if (save) {
+
+                    for (int j = 0; j < ruleIds.size(); j++) {
+                        Long ruleId = ruleIds.getLong(j);
+                        RuleBase updateRuleBase = new RuleBase();
+                        updateRuleBase.setId(ruleId);
+                        updateRuleBase.setGroupId(ruleGroup.getId());
+                        ruleBaseMapper.updateById(updateRuleBase);
+                    }
+
                     JSONArray groupIds = JSONArray.parseArray(template.getGroupIds());
                     groupIds.add(ruleGroup.getId());
                     template.setGroupIds(groupIds.toJSONString());

+ 5 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleIndicatorServiceImpl.java

@@ -23,4 +23,9 @@ public class RuleIndicatorServiceImpl extends ServiceImpl<RuleIndicatorMapper, R
     public String getRuleIndicatorNameByMediaTypeAndDimension(Integer mediaType, String dimension) {
         return ruleIndicatorMapper.getRuleIndicatorNameByMediaTypeAndDimension(mediaType, dimension);
     }
+
+    @Override
+    public String getDataTypeByRuleDimensionAndIndicatorCode(String ruleDimension, String indicatorCode) {
+        return ruleIndicatorMapper.getDataTypeByRuleDimensionAndIndicatorCode(ruleDimension, indicatorCode);
+    }
 }

+ 23 - 1
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java

@@ -2,11 +2,13 @@ package cn.com.ctop.alarm.modules.service.impl;
 
 import cn.com.ctop.alarm.modules.entity.RuleBase;
 import cn.com.ctop.alarm.modules.entity.RuleGroup;
+import cn.com.ctop.alarm.modules.entity.RuleIndicator;
 import cn.com.ctop.alarm.modules.entity.RuleTemplate;
 import cn.com.ctop.alarm.modules.mapper.RuleBaseMapper;
 import cn.com.ctop.alarm.modules.mapper.RuleTemplateMapper;
 import cn.com.ctop.alarm.modules.service.IRuleBaseService;
 import cn.com.ctop.alarm.modules.service.IRuleGroupService;
+import cn.com.ctop.alarm.modules.service.IRuleIndicatorService;
 import cn.com.ctop.alarm.modules.service.IRuleTemplateService;
 import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSONArray;
@@ -37,6 +39,9 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
     @Autowired
     private RuleTemplateMapper ruleTemplateMapper;
 
+    @Autowired
+    private IRuleIndicatorService ruleIndicatorService;
+
     /**
      * 创建规则模板
      *
@@ -45,7 +50,6 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
      */
     @Override
     public JSONObject createTemplate(JSONObject requestJson) {
-        System.err.println(requestJson);
         JSONObject returnJson = new JSONObject();
         try {
             Integer mediaType = requestJson.getInteger("mediaType");
@@ -157,6 +161,8 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
      * @param id
      * @return
      */
+
+
     @Override
     public JSONObject queryDetailById(String id) throws Exception {
         JSONObject returnJson = new JSONObject();
@@ -208,6 +214,22 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
                 ruleJson.put("threshold", ruleBase.getThreshold());
                 ruleJson.put("ruleDimension", ruleBase.getRuleDimension());
                 ruleJson.put("variableType", ruleBase.getVariableType());
+                /**
+                 * 查询指标对应信息
+                 */
+                QueryWrapper<RuleIndicator> indicatorQueryWrapper = new QueryWrapper<>();
+                indicatorQueryWrapper.eq("code", ruleBase.getIndicatorCode());
+                indicatorQueryWrapper.eq("dimension", ruleBase.getRuleDimension());
+                indicatorQueryWrapper.last("limit 1");
+                RuleIndicator ruleIndicator = ruleIndicatorService.getOne(indicatorQueryWrapper);
+                if (!Check.isNull(ruleIndicator)) {
+                    ruleJson.put("dataType", ruleIndicator.getDataType());
+                    ruleJson.put("dictId", ruleIndicator.getDictId());
+                    ruleJson.put("dataUnit", ruleIndicator.getDataUnit());
+                    ruleJson.put("name", ruleIndicator.getName());
+                    ruleJson.put("modelType", ruleIndicator.getModelType());
+                }
+
                 ruleDetail.add(ruleJson);
             }
             groupJson.put("ruleDetail", ruleDetail);

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

@@ -41,7 +41,7 @@ import java.util.Map;
 @Slf4j
 @Api(tags="规则账户清洗数据")
 @RestController
-@RequestMapping("/ctop/ruleDataAccount")
+@RequestMapping("/ctop/rule/account")
 public class RuleDataAccountController {
 	@Autowired
 	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
 @Api(tags="规则创意清洗数据")
 @RestController
-@RequestMapping("/ctop/ruleDataCreative")
+@RequestMapping("/ctop/rule/creative")
 public class RuleDataCreativeController {
 	@Autowired
 	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
 @Api(tags="规则计划清洗数据")
 @RestController
-@RequestMapping("/ctop/ruleDataPlan")
+@RequestMapping("/ctop/rule/plan")
 public class RuleDataPlanController {
 	@Autowired
 	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
 @Api(tags="规则定向清洗数据")
 @RestController
-@RequestMapping("/ctop/ruleDataTarget")
+@RequestMapping("/ctop/rule/target")
 public class RuleDataTargetController {
 	@Autowired
 	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
 @Api(tags="规则空耗清洗数据")
 @RestController
-@RequestMapping("/ctop/ruleDataWasteCost")
+@RequestMapping("/ctop/rule/wasteCost")
 public class RuleDataWasteCostController {
 	@Autowired
 	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)
     @ApiModelProperty(value = "转化数")
-	private Long convert;
+	private Long convertNum;
 	/**转化成本*/
 	@Excel(name = "转化成本", width = 15)
     @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;
 
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -26,9 +26,10 @@ import java.util.Date;
 @ApiModel(value="ctop_rule_data_plan对象", description="规则计划清洗数据")
 public class RuleDataPlan {
 
-	@TableId(type = IdType.AUTO)
+	@TableId
 	private Long id;
 	private Long accountId;
+	private String accountName;
 	private Long planId;
 	private String planName;
 	/**externalUrl*/
@@ -46,7 +47,7 @@ public class RuleDataPlan {
 	/**convert*/
 	@Excel(name = "convert", width = 15)
     @ApiModelProperty(value = "convert")
-	private Long convert;
+	private Long convertNum;
 	/**convertCost*/
 	@Excel(name = "convertCost", width = 15)
     @ApiModelProperty(value = "convertCost")
@@ -55,6 +56,8 @@ public class RuleDataPlan {
 	@Excel(name = "nextDayOpenRate", width = 15)
     @ApiModelProperty(value = "nextDayOpenRate")
 	private BigDecimal nextDayOpenRate;
+	private BigDecimal nextDayOpenCost;
+	private Long nextDayOpen;
 	/**付费方式*/
 	@Excel(name = "付费方式", width = 15)
     @ApiModelProperty(value = "付费方式")
@@ -69,4 +72,39 @@ public class RuleDataPlan {
 	/**updateTime*/
     @ApiModelProperty(value = "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;
 
-import com.baomidou.mybatisplus.annotation.IdType;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -25,9 +25,10 @@ import java.util.Date;
 @ApiModel(value="ctop_rule_data_target对象", description="规则定向清洗数据")
 public class RuleDataTarget {
 
-	@TableId(type = IdType.AUTO)
+	@TableId
 	private Long id;
 	private Long accountId;
+	private String accountName;
 	private Long planId;
 	private String planName;
 	/**retargetingTagsExclude*/
@@ -84,4 +85,13 @@ public class RuleDataTarget {
 	/**updateTime*/
     @ApiModelProperty(value = "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
  */
 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.service.IRuleDataPlanService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * 规则计划清洗数据
  * @author jeecg-boot
@@ -14,5 +17,4 @@ import org.springframework.stereotype.Service;
  */
 @Service
 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*/
 	@Excel(name = "userId", width = 15)
     @ApiModelProperty(value = "userId")
-	private Integer userId;
+	private Long userId;
 	/**accountName*/
 	@Excel(name = "accountName", width = 15)
     @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;
 
 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.JSONObject;
 
@@ -15,6 +16,8 @@ public interface IByteDanceAdvertiserDataService {
 
     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> 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();
     }
 
+    @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) {
         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 getAdvertiserPlanRuleData(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);

+ 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;
 
 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.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.CtopAdConstant;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 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.report.entity.*;
 import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
@@ -146,12 +153,66 @@ public class ReportServiceImpl implements IReportService {
         getCampaignReportByPage(token, conditions, page + 1);
     }
 
+
     @Override
     public void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
         var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
         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) {
         conditions.setPage(page);
         var config = new SerializeConfig();
@@ -185,6 +246,7 @@ public class ReportServiceImpl implements IReportService {
                 hourlyReports.add(hourlyReport);
             } else {
                 var dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());
+                //获取计划详情
                 dailyReports.add(dailyReport);
             }
         }