Browse Source

Merge branch 'master_rule_engine' of http://git.tjyourong.com.cn/ctop/adsp-boot into master_rule_engine

zhaoxian 4 years ago
parent
commit
9125c92429
17 changed files with 328 additions and 85 deletions
  1. 59 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleAccountTemplateController.java
  2. 49 35
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleGroupController.java
  3. 12 5
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleIndicatorController.java
  4. 25 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleTemplateController.java
  5. 2 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/mapper/RuleIndicatorMapper.java
  6. 7 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/mapper/xml/RuleIndicatorMapper.xml
  7. 4 1
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/IRuleAccountTemplateService.java
  8. 1 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/IRuleIndicatorService.java
  9. 2 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/IRuleTemplateService.java
  10. 83 4
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleAccountTemplateServiceImpl.java
  11. 7 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleIndicatorServiceImpl.java
  12. 71 0
      module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleTemplateServiceImpl.java
  13. 1 7
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataAccount.java
  14. 1 10
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataCreative.java
  15. 1 8
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataPlan.java
  16. 1 8
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataTarget.java
  17. 2 7
      module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataWasteCost.java

+ 59 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleAccountTemplateController.java

@@ -1,8 +1,11 @@
 package cn.com.ctop.alarm.modules.controller;
 package cn.com.ctop.alarm.modules.controller;
 
 
 import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
 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.IRuleAccountTemplateService;
+import cn.com.ctop.alarm.modules.service.IRuleTemplateService;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -48,6 +51,62 @@ import java.util.Map;
 public class RuleAccountTemplateController {
 public class RuleAccountTemplateController {
     @Autowired
     @Autowired
     private IRuleAccountTemplateService ruleAccountTemplateService;
     private IRuleAccountTemplateService ruleAccountTemplateService;
+    @Autowired
+    private IRuleTemplateService templateService;
+
+    @GetMapping(value = "/checkAccountTemplate")
+    public Result<JSONObject> checkAccountTemplate(Long accountId) {
+        Result<JSONObject> result = new Result<>();
+        JSONObject returnJson = new JSONObject();
+        QueryWrapper<RuleAccountTemplate> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("account_id", accountId);
+        queryWrapper.orderByDesc("create_time");
+        queryWrapper.last("limit 1");
+        RuleAccountTemplate ruleAccountTemplate = ruleAccountTemplateService.getOne(queryWrapper);
+        if (!Check.isNull(ruleAccountTemplate)) {
+            RuleTemplate ruleTemplate = templateService.getById(ruleAccountTemplate.getTemplateId());
+            returnJson.put("isApplication", true);
+            if (!Check.isNull(ruleTemplate)) {
+                returnJson.put("templateName", ruleTemplate.getTemplateName());
+            }
+        } else {
+            returnJson.put("isApplication", false);
+        }
+
+        result.setSuccess(true);
+        result.setResult(returnJson);
+        return result;
+    }
+
+
+    /**
+     * 推送 模板应用到某个账户
+     *
+     * @param ruleAccountTemplate
+     * @return
+     */
+    @PostMapping(value = "/pushTemplateToAccount")
+    public Result pushTemplateToAccount(@RequestBody RuleAccountTemplate ruleAccountTemplate) {
+        Result result = new Result<>();
+        try {
+            if (Check.isNull(ruleAccountTemplate.getAccountId())) {
+                throw new Exception("请选择需要推送的账户");
+            }
+
+            if (Check.isNull(ruleAccountTemplate.getTemplateId())) {
+                throw new Exception("请选择需要推送的模板");
+            }
+
+            JSONObject returnJson = ruleAccountTemplateService.pushTemplateToAccount(ruleAccountTemplate.getAccountId(), ruleAccountTemplate.getTemplateId());
+            result.setSuccess(true);
+            result.setResult(returnJson);
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+        return result;
+    }
+
 
 
     /**
     /**
      * 分页列表查询
      * 分页列表查询

+ 49 - 35
module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleGroupController.java

@@ -1,9 +1,11 @@
 package cn.com.ctop.alarm.modules.controller;
 package cn.com.ctop.alarm.modules.controller;
 
 
 import cn.com.ctop.alarm.modules.entity.RuleGroup;
 import cn.com.ctop.alarm.modules.entity.RuleGroup;
+import cn.com.ctop.alarm.modules.entity.RuleTemplate;
 import cn.com.ctop.alarm.modules.service.IRuleAccountThresholdService;
 import cn.com.ctop.alarm.modules.service.IRuleAccountThresholdService;
 import cn.com.ctop.alarm.modules.service.IRuleBaseService;
 import cn.com.ctop.alarm.modules.service.IRuleBaseService;
 import cn.com.ctop.alarm.modules.service.IRuleGroupService;
 import cn.com.ctop.alarm.modules.service.IRuleGroupService;
+import cn.com.ctop.alarm.modules.service.IRuleTemplateService;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
@@ -34,10 +36,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.net.URLDecoder;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 
 /**
 /**
  * 规则组
  * 规则组
@@ -57,6 +56,8 @@ public class RuleGroupController {
     private IRuleBaseService ruleBaseService;
     private IRuleBaseService ruleBaseService;
     @Autowired
     @Autowired
     private IRuleAccountThresholdService ruleAccountThresholdService;
     private IRuleAccountThresholdService ruleAccountThresholdService;
+    @Autowired
+    private IRuleTemplateService ruleTemplateService;
 
 
 
 
     /**
     /**
@@ -92,6 +93,50 @@ public class RuleGroupController {
 
 
 
 
     /**
     /**
+     * 通过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 {
+            RuleGroup ruleGroup = ruleGroupService.getById(id);
+            if (!Check.isNull(ruleGroup)) {
+                JSONArray ruleIds = JSONArray.parseArray(ruleGroup.getRuleIds());
+                for (int i = 0; i < ruleIds.size(); i++) {
+                    Long ruleId = ruleIds.getLong(i);
+                    ruleBaseService.removeById(ruleId);
+                    Map<String, Object> deleteMap = new HashMap<>();
+                    deleteMap.put("rule_id", ruleId);
+                    ruleAccountThresholdService.removeByMap(deleteMap);
+                }
+                Long templateId = ruleGroup.getTemplateId();
+                RuleTemplate ruleTemplate = ruleTemplateService.getById(templateId);
+                if (!Check.isNull(ruleTemplate)) {
+                    JSONArray groupIds = JSONArray.parseArray(ruleTemplate.getGroupIds());
+                    Iterator<Object> o = groupIds.iterator();
+                    while (o.hasNext()) {
+                        Long groupId = (Long) o.next();
+                        if (groupId.equals(id)) {
+                            o.remove();
+                        }
+                    }
+                    ruleTemplate.setGroupIds(groupIds.toJSONString());
+                    ruleTemplateService.updateById(ruleTemplate);
+                }
+                ruleGroupService.removeById(id);
+            }
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
      * 分页列表查询
      * 分页列表查询
      *
      *
      * @param ruleGroup
      * @param ruleGroup
@@ -161,37 +206,6 @@ public class RuleGroupController {
         return result;
         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 {
-            RuleGroup ruleGroup = ruleGroupService.getById(id);
-            if (!Check.isNull(ruleGroup)) {
-                JSONArray ruleIds = JSONArray.parseArray(ruleGroup.getRuleIds());
-                for (int i = 0; i < ruleIds.size(); i++) {
-                    Long ruleId = ruleIds.getLong(i);
-                    ruleBaseService.removeById(ruleId);
-                    Map<String, Object> deleteMap = new HashMap<>();
-                    deleteMap.put("rule_id", ruleId);
-                    ruleAccountThresholdService.removeByMap(deleteMap);
-                }
-                ruleGroupService.removeById(id);
-            }
-        } catch (Exception e) {
-            log.error("删除失败", e.getMessage());
-            return Result.error("删除失败!");
-        }
-        return Result.ok("删除成功!");
-    }
 
 
     /**
     /**
      * 批量删除
      * 批量删除

+ 12 - 5
module-alarm/src/main/java/cn/com/ctop/alarm/modules/controller/RuleIndicatorController.java

@@ -5,6 +5,7 @@ import cn.com.ctop.alarm.modules.service.IRuleIndicatorService;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.annotation.AutoLog;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
@@ -52,26 +53,32 @@ public class RuleIndicatorController {
     @AutoLog(value = "规则指标信息-分页列表查询")
     @AutoLog(value = "规则指标信息-分页列表查询")
     @ApiOperation(value = "规则指标信息-分页列表查询", notes = "规则指标信息-分页列表查询")
     @ApiOperation(value = "规则指标信息-分页列表查询", notes = "规则指标信息-分页列表查询")
     @GetMapping(value = "/list")
     @GetMapping(value = "/list")
-    public Result<JSONObject> queryPageList(RuleIndicator ruleIndicator) {
-        Result<JSONObject> result = new Result<>();
+    public Result<JSONArray> queryPageList(RuleIndicator ruleIndicator) {
+        Result<JSONArray> result = new Result<>();
         Integer mediaType = ruleIndicator.getMediaType();
         Integer mediaType = ruleIndicator.getMediaType();
         QueryWrapper<RuleIndicator> queryWrapper = new QueryWrapper();
         QueryWrapper<RuleIndicator> queryWrapper = new QueryWrapper();
         queryWrapper.eq("media_type", mediaType);
         queryWrapper.eq("media_type", mediaType);
         queryWrapper.groupBy("dimension");
         queryWrapper.groupBy("dimension");
         List<RuleIndicator> list = ruleIndicatorService.list(queryWrapper);
         List<RuleIndicator> list = ruleIndicatorService.list(queryWrapper);
-        JSONObject dataJson = new JSONObject();
+        JSONArray dataArr = new JSONArray();
         for (RuleIndicator indicator : list) {
         for (RuleIndicator indicator : list) {
             String dimension = indicator.getDimension();
             String dimension = indicator.getDimension();
+            JSONObject dimensionJson = new JSONObject();
             QueryWrapper<RuleIndicator> queryWrapperData = new QueryWrapper();
             QueryWrapper<RuleIndicator> queryWrapperData = new QueryWrapper();
             queryWrapperData.eq("media_type", mediaType);
             queryWrapperData.eq("media_type", mediaType);
             queryWrapperData.eq("dimension", dimension);
             queryWrapperData.eq("dimension", dimension);
             List<RuleIndicator> dataList = ruleIndicatorService.list(queryWrapperData);
             List<RuleIndicator> dataList = ruleIndicatorService.list(queryWrapperData);
             if (!Check.isNull(dataList)) {
             if (!Check.isNull(dataList)) {
-                dataJson.put(dimension, dataList);
+                dimensionJson.put("dimension", dimension);
+                // 获取指标名称
+                String dimensionName = ruleIndicatorService.getRuleIndicatorNameByMediaTypeAndDimension(mediaType, dimension);
+                dimensionJson.put("dimensionName", dimensionName);
+                dimensionJson.put("dimensionList", dataList);
+                dataArr.add(dimensionJson);
             }
             }
         }
         }
         result.setSuccess(true);
         result.setSuccess(true);
-        result.setResult(dataJson);
+        result.setResult(dataArr);
         return result;
         return result;
     }
     }
 
 

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

@@ -63,6 +63,31 @@ public class RuleTemplateController {
 
 
 
 
     /**
     /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "规则模板-通过id查询")
+    @ApiOperation(value = "规则模板-通过id查询", notes = "规则模板-通过id查询")
+    @GetMapping(value = "/queryDetailById")
+    public Result<JSONObject> queryDetailById(@RequestParam(name = "id", required = true) String id) {
+        Result<JSONObject> result = new Result<>();
+        try {
+            JSONObject ruleTemplateJson = ruleTemplateService.queryDetailById(id);
+            result.setSuccess(true);
+            result.setResult(ruleTemplateJson);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+        }
+
+        return result;
+    }
+
+
+    /**
      * 分页列表查询
      * 分页列表查询
      *
      *
      * @param ruleTemplate
      * @param ruleTemplate

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

@@ -2,6 +2,7 @@ package cn.com.ctop.alarm.modules.mapper;
 
 
 import cn.com.ctop.alarm.modules.entity.RuleIndicator;
 import cn.com.ctop.alarm.modules.entity.RuleIndicator;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 
 /**
 /**
  * 规则指标信息
  * 规则指标信息
@@ -12,4 +13,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
  */
 public interface RuleIndicatorMapper extends BaseMapper<RuleIndicator> {
 public interface RuleIndicatorMapper extends BaseMapper<RuleIndicator> {
 
 
+    String getRuleIndicatorNameByMediaTypeAndDimension(@Param("mediaType") Integer mediaType, @Param("dimension") String dimension);
 }
 }

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

@@ -2,4 +2,11 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.alarm.modules.mapper.RuleIndicatorMapper">
 <mapper namespace="cn.com.ctop.alarm.modules.mapper.RuleIndicatorMapper">
 
 
+    <select id="getRuleIndicatorNameByMediaTypeAndDimension" resultType="java.lang.String">
+      select  dimension_name
+      from ctop_rule_media_dimension
+      where  media_type = #{mediaType}
+      and dimension = #{dimension}
+      limit 1
+    </select>
 </mapper>
 </mapper>

+ 4 - 1
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/IRuleAccountTemplateService.java

@@ -1,14 +1,17 @@
 package cn.com.ctop.alarm.modules.service;
 package cn.com.ctop.alarm.modules.service;
 
 
 import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
 import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 
 /**
 /**
  * @Description: 规则模板
  * @Description: 规则模板
  * @Author: jeecg-boot
  * @Author: jeecg-boot
- * @Date:   2020-11-15
+ * @Date: 2020-11-15
  * @Version: V1.0
  * @Version: V1.0
  */
  */
 public interface IRuleAccountTemplateService extends IService<RuleAccountTemplate> {
 public interface IRuleAccountTemplateService extends IService<RuleAccountTemplate> {
 
 
+    // 推送模板到账户下
+    JSONObject pushTemplateToAccount(Long accountId, Long templateId) throws Exception;
 }
 }

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

@@ -11,4 +11,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
  */
 public interface IRuleIndicatorService extends IService<RuleIndicator> {
 public interface IRuleIndicatorService extends IService<RuleIndicator> {
 
 
+    String getRuleIndicatorNameByMediaTypeAndDimension(Integer mediaType, String dimension);
 }
 }

+ 2 - 0
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/IRuleTemplateService.java

@@ -13,4 +13,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 public interface IRuleTemplateService extends IService<RuleTemplate> {
 public interface IRuleTemplateService extends IService<RuleTemplate> {
 
 
     JSONObject createTemplate(JSONObject requestJson);
     JSONObject createTemplate(JSONObject requestJson);
+
+    JSONObject queryDetailById(String id) throws Exception;
 }
 }

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

@@ -1,19 +1,98 @@
 package cn.com.ctop.alarm.modules.service.impl;
 package cn.com.ctop.alarm.modules.service.impl;
 
 
-import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
+import cn.com.ctop.alarm.modules.entity.*;
 import cn.com.ctop.alarm.modules.mapper.RuleAccountTemplateMapper;
 import cn.com.ctop.alarm.modules.mapper.RuleAccountTemplateMapper;
-import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
+import cn.com.ctop.alarm.modules.service.*;
+import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import java.util.HashMap;
+import java.util.Map;
 
 
 /**
 /**
  * 规则模板
  * 规则模板
+ *
  * @author jeecg-boot
  * @author jeecg-boot
- * @date   2020-11-15
  * @version V1.0
  * @version V1.0
+ * @date 2020-11-15
  */
  */
 @Service
 @Service
 public class RuleAccountTemplateServiceImpl extends ServiceImpl<RuleAccountTemplateMapper, RuleAccountTemplate> implements IRuleAccountTemplateService {
 public class RuleAccountTemplateServiceImpl extends ServiceImpl<RuleAccountTemplateMapper, RuleAccountTemplate> implements IRuleAccountTemplateService {
+    @Autowired
+    private RuleAccountTemplateMapper ruleAccountTemplateMapper;
+    @Autowired
+    private IRuleTemplateService ruleTemplateService;
+    @Autowired
+    private IRuleGroupService ruleGroupService;
+    @Autowired
+    private IRuleBaseService ruleBaseService;
+    @Autowired
+    private IRuleAccountThresholdService ruleAccountThresholdService;
+
+    /**
+     * 推送模板到账会下
+     *
+     * @param accountId
+     * @param templateId
+     * @return
+     */
+    @Override
+    public JSONObject pushTemplateToAccount(Long accountId, Long templateId) throws Exception {
+
+        RuleTemplate ruleTemplate = ruleTemplateService.getById(templateId);
+        if (Check.isNull(ruleTemplate)) {
+            throw new Exception("推送失败,未获取到模板信息");
+
+        }
+        JSONArray groupIds = JSONArray.parseArray(ruleTemplate.getGroupIds());
+        if (Check.isNull(groupIds)) {
+            throw new Exception("推送失败,模板下战暂无可用规则");
+        }
+        Map<String, Object> deleteMap = new HashMap<>();
+        deleteMap.put("account_id", accountId);
+        ruleAccountTemplateMapper.deleteByMap(deleteMap);
+        ruleAccountThresholdService.removeByMap(deleteMap);
+        RuleAccountTemplate template = new RuleAccountTemplate();
+        template.setAccountId(accountId);
+        template.setTemplateId(templateId);
+        int insert = ruleAccountTemplateMapper.insert(template);
+        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);
+            RuleGroup ruleGroup = ruleGroupService.getById(groupId);
+            if (Check.isNull(ruleGroup)) {
+                continue;
+            }
+            groupCount += 1;
+            JSONArray ruleIds = JSONArray.parseArray(ruleGroup.getRuleIds());
+            if (Check.isNull(ruleIds)) {
+                continue;
+            }
+            for (int j = 0; j < ruleIds.size(); j++) {
+                Long ruleId = ruleIds.getLong(j);
+                RuleBase ruleBase = ruleBaseService.getById(ruleId);
+                if (Check.isNull(ruleBase)) {
+                    continue;
+                }
+                RuleAccountThreshold threshold = new RuleAccountThreshold();
+                threshold.setAccountId(accountId);
+                threshold.setRuleId(ruleBase.getId());
+                ruleAccountThresholdService.save(threshold);
+            }
 
 
+        }
+        returnJson.put("groupCount", groupCount);
+        return returnJson;
+    }
 }
 }

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

@@ -4,6 +4,7 @@ import cn.com.ctop.alarm.modules.entity.RuleIndicator;
 import cn.com.ctop.alarm.modules.mapper.RuleIndicatorMapper;
 import cn.com.ctop.alarm.modules.mapper.RuleIndicatorMapper;
 import cn.com.ctop.alarm.modules.service.IRuleIndicatorService;
 import cn.com.ctop.alarm.modules.service.IRuleIndicatorService;
 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;
 
 
 /**
 /**
@@ -15,5 +16,11 @@ import org.springframework.stereotype.Service;
  */
  */
 @Service
 @Service
 public class RuleIndicatorServiceImpl extends ServiceImpl<RuleIndicatorMapper, RuleIndicator> implements IRuleIndicatorService {
 public class RuleIndicatorServiceImpl extends ServiceImpl<RuleIndicatorMapper, RuleIndicator> implements IRuleIndicatorService {
+    @Autowired
+    private RuleIndicatorMapper ruleIndicatorMapper;
 
 
+    @Override
+    public String getRuleIndicatorNameByMediaTypeAndDimension(Integer mediaType, String dimension) {
+        return ruleIndicatorMapper.getRuleIndicatorNameByMediaTypeAndDimension(mediaType, dimension);
+    }
 }
 }

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

@@ -34,6 +34,9 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
     @Autowired
     @Autowired
     private IRuleGroupService ruleGroupService;
     private IRuleGroupService ruleGroupService;
 
 
+    @Autowired
+    private RuleTemplateMapper ruleTemplateMapper;
+
     /**
     /**
      * 创建规则模板
      * 创建规则模板
      *
      *
@@ -146,4 +149,72 @@ public class RuleTemplateServiceImpl extends ServiceImpl<RuleTemplateMapper, Rul
 
 
         return returnJson;
         return returnJson;
     }
     }
+
+
+    /**
+     * 获取模板详情
+     *
+     * @param id
+     * @return
+     */
+    @Override
+    public JSONObject queryDetailById(String id) throws Exception {
+        JSONObject returnJson = new JSONObject();
+        RuleTemplate template = ruleTemplateMapper.selectById(id);
+        if (Check.isNull(ruleTemplateMapper)) {
+            throw new Exception("获取模板基本信息为空");
+        }
+
+        returnJson.put("templateId", template.getId());
+        returnJson.put("templateName", template.getTemplateName());
+        returnJson.put("mediaType", template.getMediaType());
+        JSONArray groupIds = JSONArray.parseArray(template.getGroupIds());
+        if (Check.isNull(groupIds)) {
+            throw new Exception("未获取规则集");
+        }
+
+
+        JSONArray ruleList = new JSONArray();
+        for (int i = 0; i < groupIds.size(); i++) {
+            Long groupId = groupIds.getLong(i);
+            RuleGroup group = ruleGroupService.getById(groupId);
+            if (Check.isNull(group)) {
+                continue;
+            }
+            JSONObject groupJson = new JSONObject();
+            groupJson.put("groupId", group.getId());
+            groupJson.put("groupName", group.getGroupName());
+            groupJson.put("ruleType", group.getRuleType());
+            groupJson.put("ruleRelationship", group.getRuleRelationship());
+            groupJson.put("remark", group.getRemark());
+            groupJson.put("operate", group.getOperate());
+            groupJson.put("sendType", group.getSendType());
+            JSONArray ruleIds = JSONArray.parseArray(group.getRuleIds());
+            if (Check.isNull(ruleIds)) {
+                continue;
+            }
+            JSONArray ruleDetail = new JSONArray();
+            for (int j = 0; j < ruleIds.size(); j++) {
+                Long ruleId = ruleIds.getLong(j);
+                RuleBase ruleBase = ruleBaseService.getById(ruleId);
+                if (Check.isNull(ruleBase)) {
+                    continue;
+                }
+                JSONObject ruleJson = new JSONObject();
+                ruleJson.put("ruleId", ruleBase.getId());
+                ruleJson.put("ruleName", ruleBase.getRuleName());
+                ruleJson.put("indicatorCode", ruleBase.getIndicatorCode());
+                ruleJson.put("ruleCondition", ruleBase.getRuleCondition());
+                ruleJson.put("threshold", ruleBase.getThreshold());
+                ruleJson.put("ruleDimension", ruleBase.getRuleDimension());
+                ruleJson.put("variableType", ruleBase.getVariableType());
+                ruleDetail.add(ruleJson);
+            }
+            groupJson.put("ruleDetail", ruleDetail);
+            ruleList.add(groupJson);
+        }
+
+        returnJson.put("ruleList", ruleList);
+        return returnJson;
+    }
 }
 }

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

@@ -3,7 +3,6 @@ package cn.com.ctop.common.module.entity;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.IdType;
 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.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.EqualsAndHashCode;
@@ -23,17 +22,12 @@ import java.util.Date;
 @TableName("ctop_rule_data_account")
 @TableName("ctop_rule_data_account")
 @EqualsAndHashCode(callSuper = false)
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 @Accessors(chain = true)
-@ApiModel(value="ctop_rule_data_account对象", description="规则账户清洗数据")
 public class RuleDataAccount {
 public class RuleDataAccount {
 
 
-	/**id*/
 	@TableId(type = IdType.AUTO)
 	@TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "id")
 	private Long id;
 	private Long id;
-	/**账户id*/
-	@Excel(name = "账户id", width = 15)
-    @ApiModelProperty(value = "账户id")
 	private Long accountId;
 	private Long accountId;
+	private String accountName;
 	/**消耗*/
 	/**消耗*/
 	@Excel(name = "消耗", width = 15)
 	@Excel(name = "消耗", width = 15)
     @ApiModelProperty(value = "消耗")
     @ApiModelProperty(value = "消耗")

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

@@ -25,20 +25,11 @@ import java.util.Date;
 @ApiModel(value="ctop_rule_data_creative对象", description="规则创意清洗数据")
 @ApiModel(value="ctop_rule_data_creative对象", description="规则创意清洗数据")
 public class RuleDataCreative {
 public class RuleDataCreative {
 
 
-	/**id*/
 	@TableId(type = IdType.AUTO)
 	@TableId(type = IdType.AUTO)
 	private Long id;
 	private Long id;
-	/**accountId*/
-	@Excel(name = "accountId", width = 15)
-    @ApiModelProperty(value = "accountId")
 	private Long accountId;
 	private Long accountId;
-	/**planId*/
-	@Excel(name = "planId", width = 15)
-    @ApiModelProperty(value = "planId")
 	private Long planId;
 	private Long planId;
-	/**creativeId*/
-	@Excel(name = "creativeId", width = 15)
-    @ApiModelProperty(value = "creativeId")
+	private String planName;
 	private Long creativeId;
 	private Long creativeId;
 	/**presentedVideo*/
 	/**presentedVideo*/
 	@Excel(name = "presentedVideo", width = 15)
 	@Excel(name = "presentedVideo", width = 15)

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

@@ -26,18 +26,11 @@ import java.util.Date;
 @ApiModel(value="ctop_rule_data_plan对象", description="规则计划清洗数据")
 @ApiModel(value="ctop_rule_data_plan对象", description="规则计划清洗数据")
 public class RuleDataPlan {
 public class RuleDataPlan {
 
 
-	/**id*/
 	@TableId(type = IdType.AUTO)
 	@TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "id")
 	private Long id;
 	private Long id;
-	/**accountId*/
-	@Excel(name = "accountId", width = 15)
-    @ApiModelProperty(value = "accountId")
 	private Long accountId;
 	private Long accountId;
-	/**planId*/
-	@Excel(name = "planId", width = 15)
-    @ApiModelProperty(value = "planId")
 	private Long planId;
 	private Long planId;
+	private String planName;
 	/**externalUrl*/
 	/**externalUrl*/
 	@Excel(name = "externalUrl", width = 15)
 	@Excel(name = "externalUrl", width = 15)
     @ApiModelProperty(value = "externalUrl")
     @ApiModelProperty(value = "externalUrl")

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

@@ -25,18 +25,11 @@ import java.util.Date;
 @ApiModel(value="ctop_rule_data_target对象", description="规则定向清洗数据")
 @ApiModel(value="ctop_rule_data_target对象", description="规则定向清洗数据")
 public class RuleDataTarget {
 public class RuleDataTarget {
 
 
-	/**id*/
 	@TableId(type = IdType.AUTO)
 	@TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "id")
 	private Long id;
 	private Long id;
-	/**accountId*/
-	@Excel(name = "accountId", width = 15)
-    @ApiModelProperty(value = "accountId")
 	private Long accountId;
 	private Long accountId;
-	/**planId*/
-	@Excel(name = "planId", width = 15)
-    @ApiModelProperty(value = "planId")
 	private Long planId;
 	private Long planId;
+	private String planName;
 	/**retargetingTagsExclude*/
 	/**retargetingTagsExclude*/
 	@Excel(name = "retargetingTagsExclude", width = 15)
 	@Excel(name = "retargetingTagsExclude", width = 15)
     @ApiModelProperty(value = "retargetingTagsExclude")
     @ApiModelProperty(value = "retargetingTagsExclude")

+ 2 - 7
module-common/src/main/java/cn/com/ctop/common/module/entity/RuleDataWasteCost.java

@@ -28,16 +28,11 @@ public class RuleDataWasteCost {
 
 
 	/**id*/
 	/**id*/
 	@TableId(type = IdType.AUTO)
 	@TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "id")
 	private Long id;
 	private Long id;
-	/**accountId*/
-	@Excel(name = "accountId", width = 15)
-    @ApiModelProperty(value = "accountId")
 	private Long accountId;
 	private Long accountId;
-	/**planId*/
-	@Excel(name = "planId", width = 15)
-    @ApiModelProperty(value = "planId")
+	private String accountName;
 	private Long planId;
 	private Long planId;
+	private String planName;
 	/**wasteCost*/
 	/**wasteCost*/
 	@Excel(name = "wasteCost", width = 15)
 	@Excel(name = "wasteCost", width = 15)
     @ApiModelProperty(value = "wasteCost")
     @ApiModelProperty(value = "wasteCost")