Browse Source

Merge remote-tracking branch 'origin/master'

jiequan.bi 4 years ago
parent
commit
5044fe140b

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

@@ -279,29 +279,38 @@ public class MatchLogic {
      * @throws
      * @throws
      * @author ZHAOXA
      * @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();
         JSONArray sendData = new JSONArray();
         if (!Check.isNull(accountDatas) && Check.isNull(groupDatas) && Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
         if (!Check.isNull(accountDatas) && Check.isNull(groupDatas) && Check.isNull(planDatas) && Check.isNull(creativeDatas) && Check.isNull(targetDatas)) {
             sendData = accountDatas;
             sendData = accountDatas;
         } else {
         } 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;
                     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;
                     sendData = targetDatas;
                 }
                 }
             } else {
             } 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.SysUserMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.mapper.UserAllocationMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 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.IRuleDataAccountService;
 import cn.com.ctop.common.module.service.ISendMessageService;
 import cn.com.ctop.common.module.service.ISendMessageService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.Check;
@@ -82,6 +83,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
     @Autowired
     @Autowired
     private IRuleDataAccountService ruleDataAccountService;
     private IRuleDataAccountService ruleDataAccountService;
     @Autowired
     @Autowired
+    private IRuleDataAccountKuaishouService ruleDataAccountKuaishouService;
+    @Autowired
     private AlarmEventSendMapper alarmEventSendMapper;
     private AlarmEventSendMapper alarmEventSendMapper;
     @Autowired
     @Autowired
     private UserAllocationMapper userAllocationMapper;
     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());
         Map<Long, Object> map = (Map<Long, Object>) ruleGroupMap.get(templates.getTemplateId());
         Integer type = (Integer) map.get("type");
         Integer type = (Integer) map.get("type");
         JSONObject matchData = null;
         JSONObject matchData = null;
-        //媒体类型 1:头条2:快手
+        //媒体类型 1,3:头条2:快手
         if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
         if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
             //查询抖音匹配数据
             //查询抖音匹配数据
-            matchData = getRuleData(templates.getAccountId());
+            matchData = getRuleData(templates.getAccountId(), "TT");
         } else {
         } else {
-            //TODO 获取快手数据
+            matchData = getRuleData(templates.getAccountId(), "KS");
         }
         }
         if (Check.isNull(matchData)) {
         if (Check.isNull(matchData)) {
             log.warn("获取匹配数据失败");
             log.warn("获取匹配数据失败");
@@ -818,9 +821,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
      * @throws
      * @throws
      * @author ZHAOXA
      * @author ZHAOXA
      */
      */
-    private JSONObject getRuleData(Long accountId) {
+    private JSONObject getRuleData(Long accountId, String type) {
         try {
         try {
-            return ruleDataAccountService.getRuleDataByAccountId(accountId);
+            if ("TT".equals(type)) {
+                return ruleDataAccountService.getRuleDataByAccountId(accountId);
+            }
+            if ("KS".equals(type)) {
+                return ruleDataAccountKuaishouService.getKuaiShouRuleDataByAccountId(accountId);
+            }
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("获取匹配数据集异常", 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;
 package cn.com.ctop.common.module.service;
 
 
 import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
 import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 
 /**
 /**
@@ -8,4 +9,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
  */
 public interface IRuleDataAccountKuaishouService extends IService<RuleDataAccountKuaishou> {
 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;
 package cn.com.ctop.common.module.service.impl;
 
 
 import cn.com.ctop.common.module.entity.RuleDataAccountKuaishou;
 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.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 cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 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 org.springframework.stereotype.Service;
 
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
 /**
  * 快手预警数据账户维度
  * 快手预警数据账户维度
+ *
  * @author jeecg-boot
  * @author jeecg-boot
- * @date   2020-12-03
  * @version V1.0
  * @version V1.0
+ * @date 2020-12-03
  */
  */
 @Service
 @Service
 public class RuleDataAccountKuaishouServiceImpl extends ServiceImpl<RuleDataAccountKuaishouMapper, RuleDataAccountKuaishou> implements IRuleDataAccountKuaishouService {
 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;
+    }
 }
 }

+ 3 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouCampaignMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCampaign;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
@@ -17,4 +18,6 @@ public interface KuaiShouCampaignMapper extends BaseMapper<KuaiShouCampaign> {
     void replaceBatch(@Param(value = "campaigns") List<KuaiShouCampaign> campaigns);
     void replaceBatch(@Param(value = "campaigns") List<KuaiShouCampaign> campaigns);
 
 
     List<Long> queryIdsByPutStatus(Long accountId,String putStatus);
     List<Long> queryIdsByPutStatus(Long accountId,String putStatus);
+
+    JSONArray queryCampaignIdByAccountId(Long accountId);
 }
 }

+ 6 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouCampaignMapper.xml

@@ -41,4 +41,10 @@
         WHERE account_id = #{accountId}
         WHERE account_id = #{accountId}
         AND put_status = #{putStatus}
         AND put_status = #{putStatus}
     </select>
     </select>
+    <select id="queryCampaignIdByAccountId" resultType="java.lang.Long">
+        SELECT campaign_id
+        FROM
+        ctop_kuaishou_campaign
+        WHERE account_id = #{accountId}
+    </select>
 </mapper>
 </mapper>

+ 6 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java

@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.common.module.utils.PropertiesUtils;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouCampaignMapper;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDaily;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyAge;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBussiness;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAudienceReportDailyBussiness;
@@ -43,6 +44,8 @@ import java.util.Map;
 public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyMapper, KuaishouAudienceReportDaily> implements IKuaishouAudienceReportDailyService {
 public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<KuaishouAudienceReportDailyMapper, KuaishouAudienceReportDaily> implements IKuaishouAudienceReportDailyService {
 
 
     @Autowired
     @Autowired
+    private KuaiShouCampaignMapper kuaiShouCampaignMapper;
+    @Autowired
     private KuaishouAudienceReportDailyProvinceMapper provinceMapper;
     private KuaishouAudienceReportDailyProvinceMapper provinceMapper;
     @Autowired
     @Autowired
     private KuaishouAudienceReportDailyAgeMapper ageMapper;
     private KuaishouAudienceReportDailyAgeMapper ageMapper;
@@ -70,6 +73,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
     public void crowdAnalysisReport(CtopOauthToken token, String date, String type, Integer page, Integer pageSize) {
     public void crowdAnalysisReport(CtopOauthToken token, String date, String type, Integer page, Integer pageSize) {
         long start = System.currentTimeMillis();
         long start = System.currentTimeMillis();
         try {
         try {
+            JSONArray campaignIdList = kuaiShouCampaignMapper.queryCampaignIdByAccountId(token.getAccountId());
             String url = urlPath + KuaishouInterfaceConstant.AUDIENCE_REPORT;
             String url = urlPath + KuaishouInterfaceConstant.AUDIENCE_REPORT;
             JSONArray reportDims = new JSONArray();
             JSONArray reportDims = new JSONArray();
             reportDims.add(type);
             reportDims.add(type);
@@ -78,6 +82,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
             headers.put("Content-Type", "application/json");
             headers.put("Content-Type", "application/json");
             JSONObject requestJson = new JSONObject();
             JSONObject requestJson = new JSONObject();
             requestJson.put("advertiser_id", token.getAccountId());
             requestJson.put("advertiser_id", token.getAccountId());
+            requestJson.put("campaign_ids", campaignIdList);
             requestJson.put("start_date", date);
             requestJson.put("start_date", date);
             requestJson.put("end_date", date);
             requestJson.put("end_date", date);
             requestJson.put("report_dims", reportDims);
             requestJson.put("report_dims", reportDims);
@@ -91,7 +96,6 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                     JSONObject datas = resultJson.getJSONObject("data");
                     JSONObject datas = resultJson.getJSONObject("data");
                     JSONArray details = datas.getJSONArray("details");
                     JSONArray details = datas.getJSONArray("details");
                     if (!Check.isNull(details)) {
                     if (!Check.isNull(details)) {
-                        System.out.println(type + ",size:" + details.size());
                         for (int i = 0; i < details.size(); i++) {
                         for (int i = 0; i < details.size(); i++) {
                             JSONObject obj = details.getJSONObject(i);
                             JSONObject obj = details.getJSONObject(i);
                             if ("province".equals(type)) {
                             if ("province".equals(type)) {
@@ -145,7 +149,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                             }
                             }
                         }
                         }
                     }
                     }
-                }else{
+                } else {
                     log.error("查询人群分析报表数据返回信息错误:accountId:{},返回信息:{}", token.getAccountId(), resultJson);
                     log.error("查询人群分析报表数据返回信息错误:accountId:{},返回信息:{}", token.getAccountId(), resultJson);
                 }
                 }
             }
             }