Bläddra i källkod

新上监控提交

zhouzeyu@c-top.com.cn 3 år sedan
förälder
incheckning
a78e1cbf0e

+ 35 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/NewMonitorJob.java

@@ -0,0 +1,35 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.kuaishou.modules.clean.service.KuaiShouAccountCleanService;
+import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+@Slf4j
+public class NewMonitorJob {
+
+    @Resource
+    NewMonitorService newMonitorService;
+
+    /**
+     * 账户清理
+     *
+     * @param
+     * @return
+     * @throws
+     * @author ZZY
+     */
+    @XxlJob("synchronousMonitor")
+    public void execute() throws Exception {
+        try {
+            newMonitorService.synchronousMonitor("0");
+        } catch (Exception e) {
+            log.info("清理完成完成");
+        }
+
+    }
+}

+ 16 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/NewMonitorInfo.java

@@ -0,0 +1,16 @@
+package cn.com.ctop.kuaishou.modules.report.entity;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class NewMonitorInfo {
+    private String user_id;
+
+    private String user_name;
+
+    private String parent_id;
+
+    private List<NewMonitorInfo> children;
+}

+ 55 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/NewMonitorMapper.java

@@ -0,0 +1,55 @@
+package cn.com.ctop.kuaishou.modules.report.mapper;
+
+import cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface NewMonitorMapper {
+
+    List<Long> getAllAccountId();
+
+    List<Map> getKuaiShouGroup(@Param("date") String date, @Param("accountId") String accountId);
+
+    List<Map> getKuaiShouCampaign(@Param("date") String date, @Param("accountId") String accountId);
+
+    List<Map> getTouTiaoCampaign(@Param("date") String date, @Param("accountId") String accountId);
+
+    BigDecimal getGroupCharge(@Param("unitId") String unitId, @Param("afterDate") String afterDate);
+
+    BigDecimal getCampaignCharge(@Param("campaignId") String campaignId, @Param("afterDate") String afterDate);
+
+    BigDecimal getCampaignChargeTouTiao(@Param("campaignId") String campaignId, @Param("afterDate") String afterDate);
+
+    void saveMonitorGroup(@Param("accountId") String accountId, @Param("accountName") String accountName, @Param("operatingName") String operatingName, @Param("unitId") String unitId, @Param("createTime") String createTime, @Param("projectType") String projectType, @Param("effective") String effective);
+
+    void saveMonitorCampaign(@Param("accountId") String accountId, @Param("accountName") String accountName, @Param("operatingName") String operatingName, @Param("campaignId") String campaignId, @Param("createTime") String createTime, @Param("projectType") String projectType, @Param("effective") String effective);
+
+    String getMonitorGroupByUnitId(@Param("unitId") String unitId);
+
+    String getMonitorPlanByCampaignId(@Param("campaignId") String campaignId);
+
+    void updateMonitorGroupByUnitId(@Param("unitId") String unitId, @Param("effective") String effective);
+
+    void updateMonitorPlanByCampaignId(@Param("campaignId") String campaignId, @Param("effective") String effective);
+
+    List<JSONObject> getKuaiShouGroupMessage(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    JSONObject getKuaiShouGroupSum(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate);
+
+    List<JSONObject> getKuaiShouGroupMessageGroup(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group);
+
+    List<JSONObject> getPlanMessage(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
+
+    JSONObject getPlanSum(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("project") String project);
+
+    List<JSONObject> getPlanMessageGroup(@Param("array") JSONArray array, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("group") String group, @Param("project") String project);
+
+    List<NewMonitorInfo> getOperator(@Param("userId") String userId);
+}

+ 183 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/NewMonitorMapper.xml

@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper">
+    <resultMap id="BaseResultMap" type="cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper">
+        <id  column="id"  property="user_id" />
+        <result column="realname" property="user_name"/>
+        <result column="leader_id" property="parent_id"/>
+        <collection property="children" ofType="cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo"
+                    select="cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper.getOperator" column="id">
+        </collection>
+    </resultMap>
+
+    <select id="getOperator" resultMap="BaseResultMap"  parameterType="String">
+        SELECT id,realname,leader_id
+        FROM sys_user
+        WHERE leader_id=#{userId};
+    </select>
+
+    <select id="getAllAccountId" resultType="Long">
+        SELECT DISTINCT t.account_id  as 'accountId' from ctop_user_allocation t
+    </select>
+    <select id="getKuaiShouGroup" resultType="Map">
+    SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.unit_id as 'unitId',t.group_create_time as 'groupCreatTime',DATE_FORMAT(DATE_ADD(t.group_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
+     from ctop_user_allocation t1 LEFT JOIN  ctop_kuaishou_group t on t1.account_id=t.account_id and t.account_id=#{accountId}
+     <where>
+         <choose>
+             <when test="date!= null and date!=''">
+                 and  t.group_create_time &gt;= DATE_SUB(#{date},INTERVAL 7 DAY)
+             </when>
+             <otherwise>
+                 t.group_create_time &gt;= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
+             </otherwise>
+         </choose>
+     </where>
+    </select>
+
+    <select id="getKuaiShouCampaign" resultType="Map">
+        SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.campaign_id as 'campaignId',t.put_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.put_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
+        from ctop_user_allocation t1 LEFT JOIN  ctop_kuaishou_campaign t on t1.account_id=t.account_id and t.account_id=#{accountId}
+        <where>
+            <choose>
+                <when test="date != null and date !=''">
+                    and  t.put_create_time &gt;= DATE_SUB(#{date},INTERVAL 7 DAY)
+                </when>
+                <otherwise>
+                    t.put_create_time &gt;= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
+                </otherwise>
+            </choose>
+        </where>
+    </select>
+
+    <select id="getTouTiaoCampaign" resultType="Map">
+        SELECT t1.account_id as 'accountId',t1.auth_name as 'accountName',t1.user_name as 'userName',t.id as 'campaignId',t.ad_create_time as 'campaignCreatTime',DATE_FORMAT(DATE_ADD(t.ad_create_time,INTERVAL 7 DAY),'%Y-%m-%d') as 'afterTime'
+        from ctop_user_allocation t1 LEFT JOIN  ctop_bytedance_advertise_plan t on t1.account_id=t.account_id and t.account_id=#{accountId}
+        <where>
+            <choose>
+                <when test="date != null and date !=''">
+                    and  t.ad_create_time &gt;= DATE_SUB(#{date},INTERVAL 7 DAY)
+                </when>
+                <otherwise>
+                    t.ad_create_time &gt;= DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 1 YEAR),'%Y-%m-%d')
+                </otherwise>
+            </choose>
+        </where>
+    </select>
+
+    <select id="getGroupCharge" resultType="BigDecimal">
+
+        select sum(charge) from ctop_kuaishou_report_daily_group t where t.stat_date &lt; #{afterDate} and t.unit_id=#{unitId}
+    </select>
+
+    <select id="getCampaignCharge" resultType="BigDecimal">
+
+        select sum(charge) from ctop_kuaishou_report_daily_campaign t where t.stat_date &lt; #{afterDate} and t.campaign_id=#{campaignId}
+    </select>
+
+    <select id="getCampaignChargeTouTiao" resultType="BigDecimal">
+
+        select sum(cost) from ctop_bytedance_report_plan_daily t where t.stat_datetime &lt; #{afterDate} and t.ad_id=#{campaignId}
+    </select>
+
+    <insert id="saveMonitorGroup">
+        insert into  ctop_new_monitor_group(account_id,account_name,operating_name,unit_id,create_time,project_type,effective) values
+        (#{accountId},#{accountName},#{operatingName},#{unitId},#{createTime},#{projectType},#{effective})
+    </insert>
+
+    <insert id="saveMonitorCampaign">
+        insert into ctop_new_monitor_campaign (account_id,account_name,operating_name,campaign_id,create_time,project_type,effective) values
+        (#{accountId},#{accountName},#{operatingName},#{campaignId},#{createTime},#{projectType},#{effective})
+    </insert>
+
+    <select id="getMonitorGroupByUnitId" resultType="String" >
+        select  t.effective from ctop_new_monitor_group t where t.unit_id=#{unitId}
+    </select>
+
+    <select id="getMonitorPlanByCampaignId" resultType="String" >
+        select  t.effective from ctop_new_monitor_campaign t where t.campaign_id=#{campaignId}
+    </select>
+
+    <update id="updateMonitorGroupByUnitId" >
+        update ctop_new_monitor_group  t set t.effective=#{effective} where  t.unit_id=#{unitId}
+    </update>
+
+    <update id="updateMonitorPlanByCampaignId" >
+        update ctop_new_monitor_campaign  t set t.effective=#{effective} where  t.campaign_id=#{campaignId}
+    </update>
+
+    <select id="getKuaiShouGroupMessage" resultType="com.alibaba.fastjson.JSONObject">
+        select account_id as 'accountId',account_name as 'authName',MAX(create_time) as 'maxCreateTime',COUNT(IF(effective ='1', TRUE, NULL))  as 'valid',count(effective) as 'new',operating_name as 'userName','' as 'projectName'
+         from ctop_new_monitor_group  where ( create_time between #{startDate}  and #{endDate})
+        and account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+               #{item}
+        </foreach>
+        GROUP BY account_id
+
+    </select>
+
+
+    <select id="getPlanMessage" resultType="com.alibaba.fastjson.JSONObject">
+        select account_id as 'accountId',account_name as 'authName',MAX(create_time) as 'maxCreateTime',COUNT(IF(effective ='1', TRUE, NULL))  as 'valid',count(effective) as 'new',operating_name as 'userName','' as 'projectName'
+        from ctop_new_monitor_campaign  where ( create_time between #{startDate}  and #{endDate}) and project_type=#{project}
+        and account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+        GROUP BY account_id
+
+    </select>
+
+    <select id="getKuaiShouGroupSum" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective)  as 'new' from ctop_new_monitor_group t
+        where  create_time between #{startDate}  and #{endDate}
+        and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getPlanSum" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT COUNT(IF(t.effective ='1', TRUE, NULL)) as 'valid',COUNT(t.effective)  as 'new' from ctop_new_monitor_campaign t
+        where  (create_time between #{startDate}  and #{endDate}) and project_type=#{project}
+        and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="getKuaiShouGroupMessageGroup" resultType="com.alibaba.fastjson.JSONObject" >
+    SELECT DATE_FORMAT(t.create_time,'%Y-%m-%d') as 'statDate',COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL))  as 'valid' from ctop_new_monitor_group t
+     where  (create_time between #{startDate}  and #{endDate}) and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+        <choose>
+            <when test='group=="1"'>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m')
+            </when>
+            <otherwise>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m-%d')
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="getPlanMessageGroup" resultType="com.alibaba.fastjson.JSONObject" >
+        SELECT DATE_FORMAT(t.create_time,'%Y-%m-%d') as 'statDate',COUNT(t.effective) as 'new',COUNT(IF(t.effective ='1', TRUE, NULL))  as 'valid' from ctop_new_monitor_campaign t
+        where project_type=#{project} and  (create_time between #{startDate}  and #{endDate}) and t.account_id in
+        <foreach item="item" collection="array" separator="," open="(" close=")" index="">
+            #{item}
+        </foreach>
+        <choose>
+            <when test='group=="1"'>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m')
+            </when>
+            <otherwise>
+                GROUP BY  DATE_FORMAT(t.create_time,'%Y-%m-%d')
+            </otherwise>
+        </choose>
+    </select>
+
+
+
+</mapper>

+ 25 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/NewMonitorService.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.kuaishou.modules.report.service;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.jeecg.common.api.vo.Result;
+
+import java.util.List;
+
+public interface NewMonitorService {
+    public Result synchronousMonitor(String type);
+
+    List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate, String target);
+
+    JSONObject getKuaiShouGroupSum(JSONArray array, String startDate, String endDate);
+
+    List<JSONObject> getKuaiShouGroupMessageGroup(JSONArray array, String startDate, String endDate);
+
+    List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate, String target, String project);
+
+    JSONObject getPlanSum(JSONArray array, String startDate, String endDate, String project);
+
+    List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate, String project);
+
+    List<JSONObject> getOperator(String userId, String userName);
+}

+ 289 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/NewMonitorServiceImpl.java

@@ -0,0 +1,289 @@
+package cn.com.ctop.kuaishou.modules.report.service.impl;
+
+import cn.com.ctop.kuaishou.modules.report.entity.NewMonitorInfo;
+import cn.com.ctop.kuaishou.modules.report.mapper.NewMonitorMapper;
+import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+@Service
+@Slf4j
+public class NewMonitorServiceImpl implements NewMonitorService {
+
+    @Resource
+    NewMonitorMapper newMonitorMapper;
+
+    /**
+     * 同步新上监控数据
+     *
+     * @param
+     * @return
+     */
+    public Result synchronousMonitor(String type) {
+        Result result = new Result();
+        List<Map> kuaiShouGroup = new ArrayList<>();
+        List<Map> kuaiShouCampaign = new ArrayList<>();
+        List<Map> TouTiaoCampaign = new ArrayList<>();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        List<Long> allAccountId = newMonitorMapper.getAllAccountId();
+        if (!allAccountId.isEmpty()) {
+            for (Long accId : allAccountId) {
+                if (accId != null) {
+                    /*--------------------快手广告组-----------------------*/
+                    if (type.equals("0")) {
+                        //查询创建不满7天的快手组信息
+                        kuaiShouGroup = newMonitorMapper.getKuaiShouGroup(sdf.format(new Date()), String.valueOf(accId));
+                    } else {
+                        //查询全量快手组信息
+                        kuaiShouGroup = newMonitorMapper.getKuaiShouGroup(null, String.valueOf(accId));
+                    }
+                    //处理快手组数据
+                    if (!kuaiShouGroup.isEmpty()) {
+                        kuaiShouGroup.stream().forEach(obj -> {
+                            if (obj != null) {
+                                String unitId = obj.get("unitId") == null ? null : String.valueOf(obj.get("unitId"));
+                                String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
+                                String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
+                                String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
+                                String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
+                                String groupCreatTime = obj.get("groupCreatTime") == null ? null : (String) obj.get("groupCreatTime");
+                                if (unitId != null && afterTime != null) {
+                                    BigDecimal groupCharge = newMonitorMapper.getGroupCharge(unitId, afterTime);
+                                    //大于500为有效广告组
+                                    String effective = "0";
+                                    if (groupCharge != null && groupCharge.compareTo(new BigDecimal(500)) == 1) {
+                                        //有效
+                                        effective = "1";
+                                    }
+                                    String effectiveResult = newMonitorMapper.getMonitorGroupByUnitId(unitId);
+                                    //判断是否存在
+                                    if (effectiveResult != null) {
+                                        if (!effectiveResult.equals(effective)) {
+                                            //存在更新
+                                            newMonitorMapper.updateMonitorGroupByUnitId(unitId, effective);
+                                        }
+
+                                    } else {
+                                        //不存在插入
+                                        newMonitorMapper.saveMonitorGroup(accountId, accountName, userName, unitId, groupCreatTime, "1", effective);
+                                    }
+                                }
+                            }
+                        });
+                    }
+
+
+                    /*---------------快手广告计划------------------*/
+                    if (type.equals("0")) {
+                        //查询创建不满7天的快手广告计划
+                        kuaiShouCampaign = newMonitorMapper.getKuaiShouCampaign(sdf.format(new Date()), String.valueOf(accId));
+                    } else {
+                        //查询全量快手广告计划
+                        kuaiShouCampaign = newMonitorMapper.getKuaiShouCampaign(null, String.valueOf(accId));
+                    }
+                    //处理快手广告计划数据
+                    if (!kuaiShouCampaign.isEmpty()) {
+                        kuaiShouCampaign.stream().forEach(obj -> {
+                            if (obj != null) {
+                                String campaignId = obj.get("campaignId") == null ? null : String.valueOf(obj.get("campaignId"));
+                                String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
+                                String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
+                                String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
+                                String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
+                                String campaignCreatTime = obj.get("campaignCreatTime") == null ? null : (String) obj.get("campaignCreatTime");
+                                if (campaignId != null && afterTime != null) {
+                                    BigDecimal campaignCharge = newMonitorMapper.getCampaignCharge(campaignId, afterTime);
+                                    //大于500为有效广告计划
+                                    String effective = "0";
+                                    if (campaignCharge != null && campaignCharge.compareTo(new BigDecimal(500)) == 1) {
+                                        //有效
+                                        effective = "1";
+                                    }
+                                    String effectiveResult = newMonitorMapper.getMonitorPlanByCampaignId(campaignId);
+                                    //判断是否存在
+                                    if (effectiveResult != null) {
+                                        if (!effectiveResult.equals(effective)) {
+                                            //存在更新
+                                            newMonitorMapper.updateMonitorPlanByCampaignId(campaignId, effective);
+                                        }
+                                    } else {
+                                        //不存在插入
+                                        newMonitorMapper.saveMonitorCampaign(accountId, accountName, userName, campaignId, campaignCreatTime, "1", effective);
+                                    }
+                                }
+                            }
+                        });
+                    }
+
+                    /*---------------头条广告计划------------------*/
+                    if (type.equals("0")) {
+                        //查询创建不满7天的头条广告计划
+                        TouTiaoCampaign = newMonitorMapper.getTouTiaoCampaign(sdf.format(new Date()), String.valueOf(accId));
+                    } else {
+                        //查询全量头条广告计划
+                        TouTiaoCampaign = newMonitorMapper.getTouTiaoCampaign(null, String.valueOf(accId));
+                    }
+                    //处理快手广告计划数据
+                    if (!TouTiaoCampaign.isEmpty()) {
+                        TouTiaoCampaign.stream().forEach(obj -> {
+                            if (obj != null) {
+                                String campaignId = obj.get("campaignId") == null ? null : String.valueOf(obj.get("campaignId"));
+                                String afterTime = obj.get("afterTime") == null ? null : (String) obj.get("afterTime");
+                                String accountId = obj.get("accountId") == null ? null : String.valueOf(obj.get("accountId"));
+                                String accountName = obj.get("accountName") == null ? null : (String) obj.get("accountName");
+                                String userName = obj.get("userName") == null ? null : (String) obj.get("userName");
+                                String campaignCreatTime = obj.get("campaignCreatTime") == null ? null : (String) obj.get("campaignCreatTime");
+                                if (campaignId != null && afterTime != null) {
+                                    BigDecimal campaignCharge = newMonitorMapper.getCampaignChargeTouTiao(campaignId, afterTime);
+                                    //大于500为有效广告计划
+                                    String effective = "0";
+                                    if (campaignCharge != null && campaignCharge.compareTo(new BigDecimal(500)) == 1) {
+                                        //有效
+                                        effective = "1";
+                                    }
+                                    String effectiveResult = newMonitorMapper.getMonitorPlanByCampaignId(campaignId);
+                                    //判断是否存在
+                                    if (effectiveResult != null) {
+                                        if (!effectiveResult.equals(effective)) {
+                                            //存在更新
+                                            newMonitorMapper.updateMonitorPlanByCampaignId(campaignId, effective);
+                                        }
+                                    } else {
+                                        //不存在插入
+                                        newMonitorMapper.saveMonitorCampaign(accountId, accountName, userName, campaignId, campaignCreatTime, "0", effective);
+                                    }
+                                }
+                            }
+                        });
+                    }
+                }
+            }
+        }
+
+
+        return result;
+    }
+
+
+    /**
+     * 查询快手组信息
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public List<JSONObject> getKuaiShouGroupMessage(JSONArray array, String startDate, String endDate, String target) {
+        return newMonitorMapper.getKuaiShouGroupMessage(array, startDate, endDate);
+    }
+
+    /**
+     * 查询快手组新上和有效数量
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public JSONObject getKuaiShouGroupSum(JSONArray array, String startDate, String endDate) {
+        return newMonitorMapper.getKuaiShouGroupSum(array, startDate, endDate);
+    }
+
+    /**
+     * 查询快手组时间轴数据
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public List<JSONObject> getKuaiShouGroupMessageGroup(JSONArray array, String startDate, String endDate) {
+        String group = "0";
+        List<JSONObject> kuaiShouGroupMessageGroup = new ArrayList<>();
+        try {
+            if (DateUtils.isMoreSixMonth(startDate, endDate)) {
+                group = "1";
+            }
+            kuaiShouGroupMessageGroup = newMonitorMapper.getKuaiShouGroupMessageGroup(array, startDate, endDate, group);
+        } catch (Exception e) {
+            log.info("查询数据错误:{}", e.toString());
+        }
+
+        return kuaiShouGroupMessageGroup;
+    }
+
+    @Override
+    public List<JSONObject> getPlanMessage(JSONArray array, String startDate, String endDate, String target, String project) {
+        return newMonitorMapper.getPlanMessage(array, startDate, endDate, project);
+    }
+
+    /**
+     * 查询快手广告计划 新上和有效数量
+     *
+     * @param
+     * @return
+     */
+    @Override
+    public JSONObject getPlanSum(JSONArray array, String startDate, String endDate, String project) {
+        return newMonitorMapper.getPlanSum(array, startDate, endDate, project);
+    }
+
+    @Override
+    public List<JSONObject> getPlanMessageGroup(JSONArray array, String startDate, String endDate, String project) {
+        String group = "0";
+        List<JSONObject> planGroupMessageGroup = new ArrayList<>();
+        try {
+            if (DateUtils.isMoreSixMonth(startDate, endDate)) {
+                group = "1";
+            }
+            planGroupMessageGroup = newMonitorMapper.getPlanMessageGroup(array, startDate, endDate, group, project);
+        } catch (Exception e) {
+            log.info("查询数据错误:{}", e.toString());
+        }
+
+        return planGroupMessageGroup;
+    }
+
+    @Override
+    public List<JSONObject> getOperator(String userId, String userName) {
+        List<JSONObject> list = new ArrayList<>();
+        JSONObject ob = new JSONObject();
+        ob.put("user_id", userId);
+        ob.put("user_name", userName);
+        list.add(ob);
+        try {
+            if (userId != null) {
+                List<NewMonitorInfo> operator = newMonitorMapper.getOperator(userId);
+                list.addAll(getAllNode(operator));
+            }
+        } catch (Exception e) {
+            log.info("查询失败:{}", e.toString());
+        }
+        return list;
+    }
+
+    List<JSONObject> getAllNode(List<NewMonitorInfo> operator) {
+        List<JSONObject> objects = new ArrayList<>();
+        if (!operator.isEmpty()) {
+            for (NewMonitorInfo newMonitorInfo : operator) {
+                JSONObject js = new JSONObject();
+                js.put("user_id", newMonitorInfo.getUser_id());
+                js.put("user_name", newMonitorInfo.getUser_name());
+                objects.add(js);
+                if (newMonitorInfo.getChildren() != null && newMonitorInfo.getChildren().size() > 0) {
+                    objects.addAll(getAllNode(newMonitorInfo.getChildren()));
+                }
+            }
+        }
+        return objects;
+    }
+}