Jelajahi Sumber

兼容快手数据

zhaoxian 4 tahun lalu
induk
melakukan
4402921b58

+ 24 - 15
module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java

@@ -279,29 +279,38 @@ public class MatchLogic {
      * @throws
      * @author ZHAOXA
      */
-    public static JSONArray getKuaiShouSendData(JSONArray accountDatas, JSONArray groupDatas, JSONArray planDatas, JSONArray creativeDatas, JSONArray targetDatas) {
+    public static JSONArray getKuaiShouSendData(JSONArray accountDatas, JSONArray planDatas, JSONArray groupDatas, JSONArray creativeDatas, JSONArray targetDatas) {
         JSONArray sendData = new JSONArray();
         if (!Check.isNull(accountDatas) && Check.isNull(groupDatas) && Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
             sendData = accountDatas;
         } else {
-            if (Check.isNull(groupDatas)) {
-                if (!Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
-                    sendData = planDatas;
-                } else if (Check.isNull(planDatas) && !Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
+            if (Check.isNull(planDatas)) {
+                if (!Check.isNull(groupDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
+                    sendData = groupDatas;
+                } else if (Check.isNull(groupDatas) && !Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
                     sendData = creativeDatas;
-                } else if (Check.isNull(planDatas) && Check.isNull(creativeDatas) && !Check.isNull(targetDatas)) {
+                } else if (Check.isNull(groupDatas) && Check.isNull(creativeDatas) && !Check.isNull(targetDatas)) {
                     sendData = targetDatas;
                 }
             } else {
-                if (Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
-                    sendData = groupDatas;
-                } else if (!Check.isNull(targetDatas)) {
-                    for (int i = 0; i < groupDatas.size(); i++) {
-                        Long gGroupId = groupDatas.getJSONObject(i).getLong("groupId");
-                        for (int k = 0; k < targetDatas.size(); k++) {
-                            Long tgGroupId = targetDatas.getJSONObject(k).getLong("groupId");
-                            if (tgGroupId == gGroupId) {
-                                sendData.add(creativeDatas.getJSONObject(k));
+                if (Check.isNull(groupDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
+                    sendData = planDatas;
+                } else {
+                    for (int i = 0; i < planDatas.size(); i++) {
+                        Long planId = planDatas.getJSONObject(i).getLong("planId");
+                        if (!Check.isNull(targetDatas) && Check.isNull(groupDatas)) {
+                            for (int k = 0; k < targetDatas.size(); k++) {
+                                Long tgPlanId = targetDatas.getJSONObject(k).getLong("planId");
+                                if (tgPlanId == planId) {
+                                    sendData.add(creativeDatas.getJSONObject(k));
+                                }
+                            }
+                        } else if (Check.isNull(targetDatas) && !Check.isNull(groupDatas)) {
+                            for (int k = 0; k < groupDatas.size(); k++) {
+                                Long tgPlanId = groupDatas.getJSONObject(k).getLong("planId");
+                                if (tgPlanId == planId) {
+                                    sendData.add(creativeDatas.getJSONObject(k));
+                                }
                             }
                         }
                     }

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

@@ -22,6 +22,7 @@ import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.mapper.SysUserMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
 import cn.com.ctop.common.module.service.IRuleDataAccountService;
 import cn.com.ctop.common.module.service.ISendMessageService;
 import cn.com.ctop.common.module.utils.Check;
@@ -82,6 +83,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
     @Autowired
     private IRuleDataAccountService ruleDataAccountService;
     @Autowired
+    private IRuleDataAccountKuaishouService ruleDataAccountKuaishouService;
+    @Autowired
     private AlarmEventSendMapper alarmEventSendMapper;
     @Autowired
     private UserAllocationMapper userAllocationMapper;
@@ -142,12 +145,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
         Map<Long, Object> map = (Map<Long, Object>) ruleGroupMap.get(templates.getTemplateId());
         Integer type = (Integer) map.get("type");
         JSONObject matchData = null;
-        //媒体类型 1:头条2:快手
+        //媒体类型 1,3:头条2:快手
         if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
             //查询抖音匹配数据
-            matchData = getRuleData(templates.getAccountId());
+            matchData = getRuleData(templates.getAccountId(), "TT");
         } else {
-            //TODO 获取快手数据
+            matchData = getRuleData(templates.getAccountId(), "KS");
         }
         if (Check.isNull(matchData)) {
             log.warn("获取匹配数据失败");
@@ -818,9 +821,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
      * @throws
      * @author ZHAOXA
      */
-    private JSONObject getRuleData(Long accountId) {
+    private JSONObject getRuleData(Long accountId, String type) {
         try {
-            return ruleDataAccountService.getRuleDataByAccountId(accountId);
+            if ("TT".equals(type)) {
+                return ruleDataAccountService.getRuleDataByAccountId(accountId);
+            }
+            if ("KS".equals(type)) {
+                return ruleDataAccountKuaishouService.getKuaiShouRuleDataByAccountId(accountId);
+            }
         } catch (Exception e) {
             log.error("获取匹配数据集异常", e);
         }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IRuleDataAccountKuaishouService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.common.module.service;
 
 import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 /**
@@ -8,4 +9,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IRuleDataAccountKuaishouService extends IService<RuleDataAccountKuaishou> {
 
+    JSONObject getKuaiShouRuleDataByAccountId(Long accountId);
 }

+ 40 - 1
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RuleDataAccountKuaishouServiceImpl.java

@@ -1,18 +1,57 @@
 package cn.com.ctop.common.module.service.impl;
 
 import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import cn.com.ctop.common.module.entity.RuleDataTargetKuaishou;
+import cn.com.ctop.common.module.entity.RuleDatePlanKuaishou;
+import cn.com.ctop.common.module.entity.RuleDateUnitKuaishou;
 import cn.com.ctop.common.module.mapper.RuleDataAccountKuaishouMapper;
+import cn.com.ctop.common.module.mapper.RuleDataTargetKuaishouMapper;
+import cn.com.ctop.common.module.mapper.RuleDatePlanKuaishouMapper;
+import cn.com.ctop.common.module.mapper.RuleDateUnitKuaishouMapper;
 import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxl.job.core.enums.NoEn;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * 快手预警数据账户维度
+ *
  * @author jeecg-boot
- * @date   2020-12-03
  * @version V1.0
+ * @date 2020-12-03
  */
 @Service
 public class RuleDataAccountKuaishouServiceImpl extends ServiceImpl<RuleDataAccountKuaishouMapper, RuleDataAccountKuaishou> implements IRuleDataAccountKuaishouService {
 
+    @Autowired
+    private RuleDataAccountKuaishouMapper ruleDataAccountKuaishouMapper;
+    @Autowired
+    private RuleDataTargetKuaishouMapper ruleDataTargetKuaishouMapper;
+    @Autowired
+    private RuleDateUnitKuaishouMapper ruleDateUnitKuaishouMapper;
+    @Autowired
+    private RuleDatePlanKuaishouMapper ruleDatePlanKuaishouMapper;
+
+    @Override
+    public JSONObject getKuaiShouRuleDataByAccountId(Long accountId) {
+        JSONObject obj = new JSONObject();
+        Map<String, Object> map = new HashMap<>();
+        map.put("account_id", accountId);
+        map.put("status", NoEn.NO1.valueInt());
+        List<RuleDataAccountKuaishou> accountList = ruleDataAccountKuaishouMapper.selectByMap(map);
+        obj.put("account", accountList);
+        List<RuleDateUnitKuaishou> unitKuaishous = ruleDateUnitKuaishouMapper.selectByMap(map);
+        obj.put("group", unitKuaishous);
+        List<RuleDataTargetKuaishou> targetKuaishous = ruleDataTargetKuaishouMapper.selectByMap(map);
+        obj.put("target", targetKuaishous);
+        List<RuleDatePlanKuaishou> planKuaishous = ruleDatePlanKuaishouMapper.selectByMap(map);
+        obj.put("plan", planKuaishous);
+        return obj;
+    }
 }