Просмотр исходного кода

盯盘运营经理-新增头条

yangzian 3 лет назад
Родитель
Сommit
5af67159f3

+ 4 - 2
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/KuaiShouMaterialStareController.java

@@ -60,7 +60,7 @@ public class KuaiShouMaterialStareController {
      * @time: 2022/2/15
      */
     @GetMapping("/kuaiShousumData")
-    public Result<JSONObject> kuaiShousumData(@RequestParam(name="mediaType",defaultValue = "2") String mediaType,
+    public Result<JSONObject> kuaiShousumData(@RequestParam(name="mediaType") String mediaType,
                                               @RequestParam(name="type") String type,
                                               @RequestParam(name="startTime") String startTime,
                                               @RequestParam(name="endTime") String endTime,
@@ -128,6 +128,7 @@ public class KuaiShouMaterialStareController {
      *
      * @param pageNum
      * @param pageSize
+     * @param mediaType 媒体类型 1-头条 2-快手
      * @param startTime
      * @param endTime
      * @param userId
@@ -138,11 +139,12 @@ public class KuaiShouMaterialStareController {
     @GetMapping("/getKuaiShouOperateProjectInfo")
     public Result<JSONObject> getKuaiShouOperateProjectInfo(@RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
                                                      @RequestParam(name="pageSize",defaultValue = "10") int pageSize,
+                                                     @RequestParam(name="mediaType") String mediaType,
                                                      @RequestParam(name="startTime") String startTime,
                                                      @RequestParam(name="endTime") String endTime,
                                                      @RequestParam(name="userId") String userId) {
 
-        return materialStareService.getKuaiShouOperateProjectInfo(pageNum, pageSize,startTime, endTime, userId);
+        return materialStareService.getKuaiShouOperateProjectInfo(pageNum, pageSize,mediaType,startTime, endTime, userId);
     }
 
 

+ 21 - 6
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -3,11 +3,7 @@ package org.jeecg.ctop.material.mapper;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
-import org.jeecg.ctop.material.entity.vo.KuaiShouAccountPieVo;
-import org.jeecg.ctop.material.entity.vo.KuaiShouOperateAccountVo;
-import org.jeecg.ctop.material.entity.vo.KuaiShouOperateGroupVo;
-import org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo;
-import org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo;
+import org.jeecg.ctop.material.entity.vo.*;
 
 import java.util.List;
 import java.util.Map;
@@ -29,27 +25,42 @@ public interface MaterialStareMapper {
 
     Set<String> getKuaiShouAllOperators(@Param("companyId") String companyId, @Param("startDate") Long start, @Param("endDate") Long endDate, @Param("userIds") Set<String> userIds);
 
+    // 头条 同公司所有下级运营人员 有消耗的
+    Set<String> getBytedanceAllOperators(@Param("companyId")String companyId,@Param("startDate")Long start, @Param("endDate")Long endDate,@Param("userIds")Set<String> userIds);
     //快手-在投项目数量
     String getKuaiShouOperatorProjectNum(@Param("startDate") Long start, @Param("endDate") Long endDate, @Param("userIds") Set<String> userIds);
+    //头条-在投项目数量
+    String getBytedanceOperatorProjectNum(@Param("startDate")Long start, @Param("endDate")Long endDate,@Param("userIds")Set<String> userIds);
 
 
     // 快手 - 时报 查询
     List<Map> getKuaiShouCostHourlyByUserIdList(@Param("startDate") Long today, @Param("endDate") Long yesterday, @Param("list") Set<String> operatorUserIds);
 
+    //头条-时报 查询
+    List<Map> getBytedanceCostHourlyByUserIdList(@Param("startDate") Long today, @Param("endDate") Long yesterday, @Param("list") Set<String> operatorUserIds);
     //快手-查询时报 消耗 前5
     List<JSONObject> getKuaiShouCostByTop5HourList(@Param("startDate") Long start, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
+    //头条-查询时报 消耗 前5
+    List<JSONObject> getBytedanceCostByTop5HourList(@Param("startDate")Long start, @Param("endDate")Long endDate, @Param("list")Set<String> operatorUserIds);
 
     //快手 -日报查询
     List<Map> getKuaiShouCostDailyByUserIdList(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
 
+    //头条-日报查询
+    List<Map> getBytedanceCostDailyByUserIdList(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("list")Set<String> operatorUserIds);
     //快手-查询日报 消耗 前5
     List<JSONObject> getKuaiShouCostByTop5DailyList(@Param("startDate") Long start, @Param("endDate") Long end, @Param("list") Set<String> operatorUserIds);
+    //头条-查询日报 消耗 前5
+    List<JSONObject> getBytedanceCostByTop5DailyList(@Param("startDate")Long start, @Param("endDate")Long end, @Param("list")Set<String> operatorUserIds);
 
     //快手 时报总消耗
     JSONObject getKuaiShouTotalCost(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("nowHour") int nowHour, @Param("list") Set<String> operatorUserIds);
-
+    //头条 时报总消耗
+    JSONObject getBytedanceTotalCost(@Param("startDate")Long startDate,@Param("endDate")Long endDate, @Param("nowHour")int nowHour, @Param("list")Set<String> operatorUserIds);
     //快手 日报总消耗
     JSONObject getKuaiShouTotalCostDaily(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
+    //头条 日报总消耗
+    JSONObject getBytedanceTotalCostDaily(@Param("startDate")Long startDate,@Param("endDate")Long endDate, @Param("list")Set<String> operatorUserIds);
 
     //快手-查询账户数据信息
     List<KuaiShouOperateVo> getKuaiShouOperateInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
@@ -58,6 +69,8 @@ public interface MaterialStareMapper {
 
     //查看 快手 有效 计划 组
     JSONObject getKuaiShouAccountBaseByUserId(@Param("list") Set<String> operatorUserIds, @Param("projectId") String projectId, @Param("accountId") String accountId, @Param("startDate") Long startDate, @Param("endDate") Long endDate);
+    //查看 头条 有效 计划 组
+    JSONObject getBytedanceAccountBaseByUserId(@Param("list")Set<String> operatorUserIds,@Param("projectId")String projectId,@Param("accountId")String accountId,@Param("startDate")Long startDate, @Param("endDate")Long endDate);
 
     //查看 快手  当天数据 有效 计划 组
     JSONObject getKuaiShouAccountNowBaseByUserId(@Param("list") Set<String> operatorUserIds, @Param("projectId") String projectId, @Param("accountId") String accountId, @Param("startDate") Long startDate, @Param("endDate") Long endDate);
@@ -70,6 +83,8 @@ public interface MaterialStareMapper {
 
     //快手 -查询 项目 数据信息
     List<KuaiShouOperateProjectVo> getKuaiShouOperateProjectInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
+    //头条 -查询 项目 数据信息
+    List<KuaiShouOperateProjectVo> getBytedanceOperateProjectInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
     //快手-查询消费 时报
     List<KuaiShouOperateProjectVo> getKuaiShouOperateProjectInfoHour(@Param("startDate")Long startDate, @Param("endDate")Long endDate,@Param("hour")int hour, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
 

+ 258 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml

@@ -23,6 +23,27 @@
         ORDER BY t.`hour`
     </select>
 
+ <!-- 头条 时报  -->
+    <select id="getBytedanceCostHourlyByUserIdList" resultType="Map">
+        SELECT
+        CONCAT( `hour`, ':00' ) `hour`,
+        ROUND( SUM( cost ), 3 ) AS totalCost
+        FROM
+        application.bytedance_advertiser_report_hourly_dw
+        where
+        stat_datetime &gt;= #{startDate}
+        AND stat_datetime &lt;= #{endDate}
+        <if test='list!=null'>
+            AND user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY `hour`
+        ORDER BY `hour`
+    </select>
+
 
 
 
@@ -48,6 +69,31 @@
     </select>
 
 
+    <!-- 头条-查询时报 消耗 前5 -->
+    <select id="getBytedanceCostByTop5HourList" resultType="com.alibaba.fastjson.JSONObject">
+
+        SELECT
+        user_id,
+        SUM( cost ) AS totalCost,
+        ( SELECT realname FROM `jeecg-boot`.sys_user u WHERE u.id = user_id ) AS userName
+        FROM
+        application.bytedance_advertiser_report_hourly_dw
+        WHERE
+        stat_datetime &gt;= #{startDate}
+        AND stat_datetime &lt;= #{endDate}
+        <if test='list!=null'>
+            AND user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY user_id
+        ORDER BY SUM( cost ) DESC
+        LIMIT 5
+    </select>
+
+
 
 
 <!--快手 -日报  -->
@@ -70,6 +116,28 @@
     </select>
 
 
+<!--头条 -日报  -->
+    <select id="getBytedanceCostDailyByUserIdList" resultType="Map">
+        SELECT
+        DATE_FORMAT( t.stat_datetime, '%Y-%m-%d' ) AS dateTime,
+        ROUND( SUM( t.cost ), 2 ) AS totalCost
+        FROM
+        bytedance_advertiser_report_daily_dw t
+        WHERE
+        t.stat_datetime &gt;= #{startDate}
+        AND t.stat_datetime &lt;= #{endDate}
+        <if test='list!=null'>
+            AND t.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY t.stat_datetime
+        ORDER BY t.stat_datetime;
+    </select>
+
+
     <!-- 快手-查询日报 消耗 前5 -->
     <select id="getKuaiShouCostByTop5DailyList" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
@@ -92,6 +160,30 @@
     </select>
 
 
+    <!-- 头条-查询日报 消耗 前5 -->
+    <select id="getBytedanceCostByTop5DailyList" resultType="com.alibaba.fastjson.JSONObject">
+
+        SELECT
+        SUM( t.cost ) AS totalCost,
+        ( SELECT realname FROM `jeecg-boot`.sys_user u WHERE u.id = user_id ) AS userName
+        FROM
+        application.bytedance_advertiser_report_daily_dw t
+        WHERE
+        t.stat_datetime &gt;= #{startDate}
+        AND t.stat_datetime &lt;= #{endDate}
+        <if test='list!=null'>
+            AND user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY user_id
+        ORDER BY SUM(cost) DESC
+        LIMIT 5
+    </select>
+
+
 
     <!-- 快手 时报总消耗 及 账户数量 -->
     <select id="getKuaiShouTotalCost" resultType="com.alibaba.fastjson.JSONObject">
@@ -120,6 +212,33 @@
     </select>
 
 
+    <!-- 头条 时报总消耗 及 账户数量 -->
+    <select id="getBytedanceTotalCost" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ROUND( SUM( cost ), 3 ) AS totalCost,
+        COUNT(DISTINCT account_id) accountNum
+        FROM
+        application.bytedance_advertiser_report_hourly_dw
+        where 1 = 1
+        <if test="startDate != null and startDate != '' ">
+            and stat_datetime &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and stat_datetime &lt;= #{endDate}
+        </if>
+        <if test="nowHour != null and nowHour != '' ">
+            AND hour &lt;= #{nowHour}
+        </if>
+        <if test='list!=null'>
+            AND user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
+
     <!-- 快手 日报总消耗 及 账户数量 -->
     <select id="getKuaiShouTotalCostDaily" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
@@ -143,6 +262,29 @@
         </if>
     </select>
 
+    <!-- 头条 日报总消耗 及 账户数量 -->
+    <select id="getBytedanceTotalCostDaily" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ROUND( SUM( cost ), 3 ) AS totalCost,
+        COUNT(DISTINCT account_id) accountNum
+        FROM
+        application.bytedance_advertiser_report_daily_dw
+        where cost > 0
+        <if test="startDate != null and startDate != '' ">
+            and stat_datetime &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and stat_datetime &lt;= #{endDate}
+        </if>
+        <if test='list!=null'>
+            AND user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+    </select>
+
     <!-- 查看 快手 有效 计划 组-->
     <select id="getKuaiShouAccountBaseByUserId" resultType="com.alibaba.fastjson.JSONObject">
         SELECT abi.account_id ,
@@ -179,6 +321,42 @@
         </if>
 
     </select>
+   <!-- 查看 头条 有效 计划 组-->
+    <select id="getBytedanceAccountBaseByUserId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT abi.account_id ,
+        IFNULL(SUM(abi.new_effect_num),0) as newEffectNum,
+        IFNULL(SUM(abi.new_campaign_num),0) as newCampaignNum,
+        IFNULL((SUM(abi.new_ad_num) - SUM(abi.trust_campaign_num)),0) as newUnitNum,
+        IFNULL(SUM( abi.new_video_num ),0) AS newVideoNum,
+        IFNULL(SUM( abi.new_hot_num ),0) AS newHotNum,
+        IFNULL(SUM( abi.trust_campaign_num ),0) AS newUnitNum
+        from application.app_bytedance_account_base_info_d abi,
+        `jeecg-boot`.ctop_user_allocation u
+        WHERE abi.account_id = u.account_id
+        and u.account_status = 0
+        <if test="startDate != null and startDate != '' ">
+            and abi.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and abi.stat_date &lt;= #{endDate}
+        </if>
+
+        <if test='list!=null'>
+            AND abi.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+
+        <if test="projectId != null and projectId != '' ">
+            and abi.project_id = #{projectId}
+        </if>
+        <if test="accountId != null and accountId != '' ">
+            and abi.account_id = #{accountId}
+        </if>
+
+    </select>
 
  <!-- 查看 快手 当天 有效 计划 组-->
     <select id="getKuaiShouAccountNowBaseByUserId" resultType="com.alibaba.fastjson.JSONObject">
@@ -394,6 +572,40 @@
         ORDER BY SUM( d.charge ) DESC
     </select>
 
+    <!-- 快手 -查询项目数据信息 日报-->
+    <select id="getBytedanceOperateProjectInfo" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">
+        SELECT
+        COUNT( DISTINCT d.account_id ) AS accountNum,
+        d.project_id AS projectId,
+        d.project_name AS projectName,
+        SUM( d.cost ) AS totalCost,
+        ( SELECT realname FROM `jeecg-boot`.sys_user u WHERE u.id = user_id ) AS userName
+        FROM
+        application.bytedance_advertiser_report_daily_dw d
+        LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
+        WHERE
+        d.cost > 0
+        and u.account_status = 0
+        <if test="startDate != null and startDate != '' ">
+            and d.stat_datetime &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_datetime &lt;= #{endDate}
+        </if>
+        <if test="projectId != null and projectId != '' ">
+            and d.project_id = #{projectId}
+        </if>
+        <if test='list!=null'>
+            AND d.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY d.project_id
+        ORDER BY SUM( d.cost ) DESC
+    </select>
+
     <!-- 快手 -查询项目数据信息 时报-->
     <select id="getKuaiShouOperateProjectInfoHour" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">
         SELECT
@@ -1108,6 +1320,30 @@
         </foreach>
     </select>
 
+    <!-- 头条 同公司所有下级运营人员 -->
+    <select id="getBytedanceAllOperators" resultType="java.lang.String">
+        SELECT DISTINCT
+        d.user_id
+        FROM
+        application.bytedance_advertiser_report_daily_dw d
+        WHERE
+         d.cost > 0
+        <if test="companyId != null and companyId != '' ">
+            and d.company_id = #{companyId}
+        </if>
+        <if test="startDate != null and startDate != '' ">
+            and d.stat_datetime &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_datetime &lt;= #{endDate}
+        </if>
+        AND d.user_id in
+        <foreach collection="userIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
 
     <!-- 快手 项目数量 -->
     <select id="getKuaiShouOperatorProjectNum" resultType="java.lang.String">
@@ -1131,6 +1367,28 @@
     </select>
 
 
+    <!-- 头条 项目数量 -->
+    <select id="getBytedanceOperatorProjectNum" resultType="java.lang.String">
+        SELECT
+        COUNT(DISTINCT d.project_id) as projectNum
+        FROM
+        application.bytedance_advertiser_report_daily_dw d
+        WHERE
+         d.cost > 0
+        <if test="startDate != null and startDate != '' ">
+            and d.stat_datetime &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_datetime &lt;= #{endDate}
+        </if>
+        AND d.user_id in
+        <foreach collection="userIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
+
     <!-- 快手组实时数据查询-当天创建的组+当天有消耗的组 -->
     <select id="kuaiShouRealTimeUnitDateInfo" resultType="com.alibaba.fastjson.JSONObject">
 

+ 1 - 1
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/MaterialStareService.java

@@ -28,7 +28,7 @@ public interface MaterialStareService {
     Result getKuaiShouOperateInfo(Integer pageNum,int pageSize,String startTime, String endTime, String userId);
     Result exportKuaiShouOperateInfo(String startTime, String endTime, String userId, HttpServletResponse response);
 
-    Result getKuaiShouOperateProjectInfo(Integer pageNum,int pageSize,String startTime, String endTime, String userId);
+    Result getKuaiShouOperateProjectInfo(Integer pageNum,int pageSize,String mediaType,String startTime, String endTime, String userId);
     List<KuaiShouOperateProjectVo> exportKuaiShouOperateProjectInfo(String startTime, String endTime, String userId);
 
     Result getKuaiShouOperateAccountInfo(Integer pageNum,int pageSize,String startTime, String endTime, String projectId,String userId);

+ 234 - 86
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialStareServiceImpl.java

@@ -65,7 +65,60 @@ public class MaterialStareServiceImpl implements MaterialStareService {
         Set<String> operatorUserIds = getAffiliateId(userId);
         //头条
         if (StringUtils.equals(mediaType,"1")){
-            return Result.successMsg("暂无头条数据。",null);
+            //return Result.successMsg("暂无头条数据。",null);
+            //汇总
+            if (StringUtils.equals(type,"1")){
+                //查询一天数据时 查询时报
+                if (stratDate == endDate){
+                    Map resultMap = new HashMap<>();
+                    //时报
+                    List<Map> todayList = materialStareMapper.getBytedanceCostHourlyByUserIdList(stratDate, endDate, operatorUserIds);
+                    long time = DateUtils.getDateInteger(DateUtils.addDayParse(Long.toString(endDate), -1));
+                    List<Map> yesterdayList = materialStareMapper.getBytedanceCostHourlyByUserIdList(time,time , operatorUserIds);
+                    resultMap.put("todayList",todayList);
+                    resultMap.put("yesterdayList",yesterdayList);
+                    return Result.successMsg("查询-头条-时报-汇总。",resultMap);
+                }
+                //多天 数据
+                // 日报
+                List<Map> dailyList = materialStareMapper.getBytedanceCostDailyByUserIdList(stratDate, endDate, operatorUserIds);
+                return Result.successMsg("查询-头条-日报-汇总成功。",dailyList);
+            }
+
+            //运营个人
+            if (StringUtils.equals(type,"2")){
+                if (stratDate == endDate){
+                    //时报 消耗前5
+                    List<JSONObject> userList = materialStareMapper.getBytedanceCostByTop5HourList(stratDate, endDate, operatorUserIds);
+                    List<Map> resultList = new ArrayList<>();
+                    for (JSONObject jsonObject : userList) {
+                        Map map = new HashMap();
+                        Set<String> userSet = new HashSet<String>(){{
+                            add(jsonObject.getString("user_id"));
+                        }};
+                        List<Map> usertopList = materialStareMapper.getBytedanceCostHourlyByUserIdList(stratDate, endDate, userSet);
+                        map.put("userName",jsonObject.getString("userName"));
+                        map.put("data",usertopList);
+                        resultList.add(map);
+                    }
+                    return Result.successMsg("查询-头条-时报-运营个人消耗top5成功。",resultList);
+                }
+                //日报 消耗前5
+                List<JSONObject> userList = materialStareMapper.getBytedanceCostByTop5DailyList(stratDate,endDate, operatorUserIds);
+                List<Map> resultList = new ArrayList<>();
+                for (JSONObject jsonObject : userList) {
+                    Map map = new HashMap();
+                    Set<String> userSet = new HashSet<String>(){{
+                        add(jsonObject.getString("user_id"));
+                    }};
+                    //日报
+                    List<Map> usertopList = materialStareMapper.getBytedanceCostDailyByUserIdList(stratDate, endDate, userSet);
+                    map.put("userName",jsonObject.getString("userName"));
+                    map.put("data",usertopList);
+                    resultList.add(map);
+                }
+                return Result.successMsg("查询-快手-日报-运营个人消耗top5成功。",resultList);
+            }
         }
         //快手
         if (StringUtils.equals(mediaType,"2")){
@@ -80,12 +133,12 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                     List<Map> yesterdayList = materialStareMapper.getKuaiShouCostHourlyByUserIdList(time,time , operatorUserIds);
                     resultMap.put("todayList",todayList);
                     resultMap.put("yesterdayList",yesterdayList);
-                    return Result.successMsg("查询-时报-汇总。",resultMap);
+                    return Result.successMsg("查询-快手-时报-汇总。",resultMap);
                 }
                 //多天 数据
                 // 日报
                 List<Map> dailyList = materialStareMapper.getKuaiShouCostDailyByUserIdList(stratDate, endDate, operatorUserIds);
-                return Result.successMsg("查询-日报-汇总成功。",dailyList);
+                return Result.successMsg("查询-快手-日报-汇总成功。",dailyList);
 
             //运营个人
             }else if (StringUtils.equals(type,"2")){
@@ -103,7 +156,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                         map.put("data",usertopList);
                         resultList.add(map);
                     }
-                    return Result.successMsg("查询-时报-运营个人消耗top5成功。",resultList);
+                    return Result.successMsg("查询-快手-时报-运营个人消耗top5成功。",resultList);
                 }
 
                 //日报 消耗前5
@@ -119,7 +172,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                     map.put("data",usertopList);
                     resultList.add(map);
                 }
-                return Result.successMsg("查询-日报-运营个人消耗top5成功。",resultList);
+                return Result.successMsg("查询-快手-日报-运营个人消耗top5成功。",resultList);
             }
         }
         return null;
@@ -191,15 +244,8 @@ public class MaterialStareServiceImpl implements MaterialStareService {
         //查询用户所属公司
         String companyId = materialStareMapper.getUserCompanyByUserId(userId);
         Set<String> operatorUserIds = null;
-        try {
-            //查询当前人员所有下级
-            operatorUserIds= getAffiliateId(userId);
-
-            //有消耗的账户
-            operatorUserIds = materialStareMapper.getKuaiShouAllOperators(companyId,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
 
-            //快手-在投项目数量
-            String projectNum = materialStareMapper.getKuaiShouOperatorProjectNum(DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+        try {
 
             SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
             // ==>> 20220202
@@ -209,28 +255,73 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             //昨天时间
             long time = DateUtils.getDateInteger(DateUtils.addDayParse(now, -1));
 
-            //当天总消耗
-            JSONObject jsonObjectNow = materialStareMapper.getKuaiShouTotalCost(nowDate,nowDate,nowHour,operatorUserIds);
-            resultMap.put("todayCost",jsonObjectNow.getString("totalCost"));
-            //昨天总消耗
-            JSONObject jsonObjectYesterday = materialStareMapper.getKuaiShouTotalCost(time,time,nowHour,operatorUserIds);
-            //今日同比 = (今天总消耗 - 昨天总消耗 ) / 昨天总消耗
-            Double d = (Double.valueOf(jsonObjectNow.getString("totalCost")) - Double.valueOf(jsonObjectYesterday.getString("totalCost"))) / Double.valueOf(jsonObjectYesterday.getString("totalCost"));
-            resultMap.put("compare",decimalFormat.format(d));
-
-            //时间段内 总消耗 及 账户数量
-            JSONObject totalCost = materialStareMapper.getKuaiShouTotalCostDaily(Long.valueOf(DateUtils.getDateInteger(startTime)),
-                    Long.valueOf(DateUtils.getDateInteger(endTime)),
-                    operatorUserIds);
-            resultMap.put("sectionCost",totalCost.getDoubleValue("totalCost"));
-            // 人均账户数量 = 时间段内 账户总数量 / 人数
-            Double userAverageAccount = Double.valueOf(totalCost.getString("accountNum")) / operatorUserIds.size();
-            // 人均消耗 = 时间段内 总消耗 / 人数
-            Double userAveragecost = Double.valueOf(totalCost.getString("totalCost")) / operatorUserIds.size();
-            DecimalFormat df = new DecimalFormat("#.000");
-            resultMap.put("userAverageAccount",new Double(Math.ceil(userAverageAccount)).intValue());
-            resultMap.put("userAveragecost",df.format(userAveragecost));
-            resultMap.put("projectNum",projectNum);
+            //查询当前人员所有下级
+            operatorUserIds= getAffiliateId(userId);
+
+            //头条
+            if (mediaType.equals("1")){
+
+                //有消耗的账户
+                operatorUserIds = materialStareMapper.getBytedanceAllOperators(companyId,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+                //头条-在投项目数量
+                String projectNum = materialStareMapper.getBytedanceOperatorProjectNum(DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+
+                //当天总消耗
+                JSONObject jsonObjectNow = materialStareMapper.getBytedanceTotalCost(nowDate,nowDate,nowHour,operatorUserIds);
+                resultMap.put("todayCost",jsonObjectNow.getString("totalCost"));
+                //昨天总消耗
+                JSONObject jsonObjectYesterday = materialStareMapper.getBytedanceTotalCost(time,time,nowHour,operatorUserIds);
+                //今日同比 = (今天总消耗 - 昨天总消耗 ) / 昨天总消耗
+                Double d = (Double.valueOf(jsonObjectNow.getString("totalCost")) - Double.valueOf(jsonObjectYesterday.getString("totalCost"))) / Double.valueOf(jsonObjectYesterday.getString("totalCost"));
+                resultMap.put("compare",decimalFormat.format(d));
+
+                //时间段内 总消耗 及 账户数量
+                JSONObject totalCost = materialStareMapper.getBytedanceTotalCostDaily(Long.valueOf(DateUtils.getDateInteger(startTime)),
+                        Long.valueOf(DateUtils.getDateInteger(endTime)),
+                        operatorUserIds);
+                resultMap.put("sectionCost",totalCost.getDoubleValue("totalCost"));
+                // 人均账户数量 = 时间段内 账户总数量 / 人数
+                Double userAverageAccount = Double.valueOf(totalCost.getString("accountNum")) / operatorUserIds.size();
+                // 人均消耗 = 时间段内 总消耗 / 人数
+                Double userAveragecost = Double.valueOf(totalCost.getString("totalCost")) / operatorUserIds.size();
+                DecimalFormat df = new DecimalFormat("#.000");
+                resultMap.put("userAverageAccount",new Double(Math.ceil(userAverageAccount)).intValue());
+                resultMap.put("userAveragecost",df.format(userAveragecost));
+                resultMap.put("projectNum",projectNum);
+            }
+
+            //快手
+            if (mediaType.equals("2")){
+
+                //有消耗的账户
+                operatorUserIds = materialStareMapper.getKuaiShouAllOperators(companyId,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+                //快手-在投项目数量
+                String projectNum = materialStareMapper.getKuaiShouOperatorProjectNum(DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+
+                //当天总消耗
+                JSONObject jsonObjectNow = materialStareMapper.getKuaiShouTotalCost(nowDate,nowDate,nowHour,operatorUserIds);
+                resultMap.put("todayCost",jsonObjectNow.getString("totalCost"));
+                //昨天总消耗
+                JSONObject jsonObjectYesterday = materialStareMapper.getKuaiShouTotalCost(time,time,nowHour,operatorUserIds);
+                //今日同比 = (今天总消耗 - 昨天总消耗 ) / 昨天总消耗
+                Double d = (Double.valueOf(jsonObjectNow.getString("totalCost")) - Double.valueOf(jsonObjectYesterday.getString("totalCost"))) / Double.valueOf(jsonObjectYesterday.getString("totalCost"));
+                resultMap.put("compare",decimalFormat.format(d));
+
+                //时间段内 总消耗 及 账户数量
+                JSONObject totalCost = materialStareMapper.getKuaiShouTotalCostDaily(Long.valueOf(DateUtils.getDateInteger(startTime)),
+                        Long.valueOf(DateUtils.getDateInteger(endTime)),
+                        operatorUserIds);
+                resultMap.put("sectionCost",totalCost.getDoubleValue("totalCost"));
+                // 人均账户数量 = 时间段内 账户总数量 / 人数
+                Double userAverageAccount = Double.valueOf(totalCost.getString("accountNum")) / operatorUserIds.size();
+                // 人均消耗 = 时间段内 总消耗 / 人数
+                Double userAveragecost = Double.valueOf(totalCost.getString("totalCost")) / operatorUserIds.size();
+                DecimalFormat df = new DecimalFormat("#.000");
+                resultMap.put("userAverageAccount",new Double(Math.ceil(userAverageAccount)).intValue());
+                resultMap.put("userAveragecost",df.format(userAveragecost));
+                resultMap.put("projectNum",projectNum);
+            }
+
         }catch (Exception e){
             e.printStackTrace();
         }
@@ -494,9 +585,10 @@ public class MaterialStareServiceImpl implements MaterialStareService {
      * @time: 2022/2/17
      */
     @Override
-    public Result getKuaiShouOperateProjectInfo(Integer pageNum, int pageSize, String startTime, String endTime, String userId) {
+    public Result getKuaiShouOperateProjectInfo(Integer pageNum, int pageSize, String mediaType,String startTime, String endTime, String userId) {
         DecimalFormat decimalFormat = new DecimalFormat("0.00%");
         long now = Long.valueOf(DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd")));
+        List<KuaiShouOperateProjectVo> listOperate = new ArrayList<>();
         try {
             //查询当前人员所有下级
             Set<String> operatorUserIds = getAffiliateId(userId);
@@ -518,75 +610,131 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 endEqually = DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(endTime)), -7));
             }
 
-            PageHelper.startPage(pageNum,pageSize);
-            //查询运营数据-项目维度
-            List<KuaiShouOperateProjectVo> listOperate = materialStareMapper.getKuaiShouOperateProjectInfo(startDate,entDate,null,operatorUserIds);
-            for (KuaiShouOperateProjectVo projectInfo : listOperate) {
-                String projectId = projectInfo.getProjectId();
+            //头条
+            if (mediaType.equals("1")){
 
-                //环比 = (当前 - 上阶段 ) / 上阶段
-                String yearOnYear = "0";
-
-                //当天
-                int newUnitNumNow = 0;
-                int trustUnitNum = 0;
-                if (startDate == now || entDate == now){
-                    //查询 当天有效 上新计划 上新组
-                    JSONObject newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(null,projectInfo.getProjectId(),null,now,now);
-                    newUnitNumNow = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum");//组
-                    trustUnitNum = Check.isNull(newEffect) ? 0 : newEffect.getInteger("trustUnitNum");//智能托管
-
-                    //时报 消费
+                PageHelper.startPage(pageNum,pageSize);
+                //查询运营数据-项目维度
+                listOperate = materialStareMapper.getBytedanceOperateProjectInfo(startDate,entDate,null,operatorUserIds);
+                for (KuaiShouOperateProjectVo projectInfo : listOperate) {
+
+                    //查询 有效 上新视频 爆款视频
+                    JSONObject newEffect = materialStareMapper.getBytedanceAccountBaseByUserId(null,projectInfo.getProjectId(),null,startDate,entDate);
+                    projectInfo.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
+                    projectInfo.setNewVideoNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newVideoNum"));//上新
+                    projectInfo.setNewHotNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newHotNum"));//爆款
+                    projectInfo.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//基建数
+                    projectInfo.setTrustUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("trustUnitNum"));//智能托管
+
+                    /*
+                    //查看 上传到助手、媒体的素材数量 分版位花费
+                    List<JSONObject> materailUpload = materialStareMapper.getKuaiShouMaterailUploadType(projectInfo.getProjectId(),startDate,entDate);
+                    projectInfo.setAdspNum(Check.isNull(materailUpload) ? 0L : JSONObject.parseObject(materailUpload.get(0)+"").getLong("num"));//上传到助手
+                    projectInfo.setMediaNum(Check.isNull(materailUpload) ? 0L : JSONObject.parseObject(materailUpload.get(1)+"").getLong("num"));//上传到媒体
+                    //分版位
+                    List<JSONObject> adSceneDate = materialStareMapper.getKuaiShouAdSceneData(projectInfo.getProjectId(),startDate,entDate);
+                    projectInfo.setAdSceneDate(adSceneDate);
+
+                    */
+
+                    String projectId = projectInfo.getProjectId();
                     //环比 = (当前 - 上阶段 ) / 上阶段
-                    int hour = DateUtils.getNowHour();
-                    List<KuaiShouOperateProjectVo> projectYearOnYearInfoNow = materialStareMapper.getKuaiShouOperateProjectInfoHour(startDate,entDate,hour,projectId,operatorUserIds);
-                    List<KuaiShouOperateProjectVo> projectYearOnYearInfoLast = materialStareMapper.getKuaiShouOperateProjectInfoHour(lastTimeStart,lastTimeEnd,hour,projectId,operatorUserIds);
-                    if (!Check.isNull(projectYearOnYearInfoNow) && !Check.isNull(projectYearOnYearInfoLast)){
-                        Double yearOnYearD = (projectYearOnYearInfoNow.get(0).getTotalCost() - projectYearOnYearInfoLast.get(0).getTotalCost()) / projectYearOnYearInfoNow.get(0).getTotalCost();
-                        yearOnYear = decimalFormat.format(yearOnYearD);
-                    }
-                    projectInfo.setYearOnYear(yearOnYear);
-                }else {
+                    String yearOnYear = "0";
                     //环比 日报
-                    List<KuaiShouOperateProjectVo> projectYearOnYearInfo = materialStareMapper.getKuaiShouOperateProjectInfo(lastTimeStart,lastTimeEnd,projectId,operatorUserIds);
+                    List<KuaiShouOperateProjectVo> projectYearOnYearInfo = materialStareMapper.getBytedanceOperateProjectInfo(lastTimeStart,lastTimeEnd,projectId,operatorUserIds);
                     if (!Check.isNull(projectYearOnYearInfo)){
                         Double yearOnYearD = (projectInfo.getTotalCost() - projectYearOnYearInfo.get(0).getTotalCost()) / projectYearOnYearInfo.get(0).getTotalCost();
                         yearOnYear = decimalFormat.format(yearOnYearD);
                     }
                     projectInfo.setYearOnYear(yearOnYear);
+
+
+                    //同比 日期超过 7 天 则不显示
+                    String equallyRate = "-";
+                    if (daysBetween <= 7){
+                        List<KuaiShouOperateProjectVo> projectEquallyInfo = materialStareMapper.getBytedanceOperateProjectInfo(startEqually,endEqually,projectId,operatorUserIds);
+                        if (!Check.isNull(projectEquallyInfo)){
+                            Double equallyRateD = (projectInfo.getTotalCost() - projectEquallyInfo.get(0).getTotalCost()) / projectEquallyInfo.get(0).getTotalCost();
+                            equallyRate = decimalFormat.format(equallyRateD);
+                        }
+                    }
+                    projectInfo.setEquallyRate(equallyRate);
                 }
 
-                //查询 有效 上新视频 爆款视频
-                JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(null,projectInfo.getProjectId(),null,startDate,entDate);
-                projectInfo.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
-                projectInfo.setNewVideoNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newVideoNum"));//上新
-                projectInfo.setNewHotNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newHotNum"));//爆款
 
-                projectInfo.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum")+newUnitNumNow);//基建数
-                projectInfo.setTrustUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("trustUnitNum")+trustUnitNum);//智能托管
+            }
+            //快手
+            if (mediaType.equals("2")){
+                PageHelper.startPage(pageNum,pageSize);
+                //查询运营数据-项目维度
+                listOperate = materialStareMapper.getKuaiShouOperateProjectInfo(startDate,entDate,null,operatorUserIds);
+                for (KuaiShouOperateProjectVo projectInfo : listOperate) {
+                    String projectId = projectInfo.getProjectId();
+                    //环比 = (当前 - 上阶段 ) / 上阶段
+                    String yearOnYear = "0";
+                    //当天
+                    int newUnitNumNow = 0;
+                    int trustUnitNum = 0;
+                    if (startDate == now || entDate == now){
+                        //查询 当天有效 上新计划 上新组
+                        JSONObject newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(null,projectInfo.getProjectId(),null,now,now);
+                        newUnitNumNow = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum");//组
+                        trustUnitNum = Check.isNull(newEffect) ? 0 : newEffect.getInteger("trustUnitNum");//智能托管
+
+                        //时报 消费
+                        //环比 = (当前 - 上阶段 ) / 上阶段
+                        int hour = DateUtils.getNowHour();
+                        List<KuaiShouOperateProjectVo> projectYearOnYearInfoNow = materialStareMapper.getKuaiShouOperateProjectInfoHour(startDate,entDate,hour,projectId,operatorUserIds);
+                        List<KuaiShouOperateProjectVo> projectYearOnYearInfoLast = materialStareMapper.getKuaiShouOperateProjectInfoHour(lastTimeStart,lastTimeEnd,hour,projectId,operatorUserIds);
+                        if (!Check.isNull(projectYearOnYearInfoNow) && !Check.isNull(projectYearOnYearInfoLast)){
+                            Double yearOnYearD = (projectYearOnYearInfoNow.get(0).getTotalCost() - projectYearOnYearInfoLast.get(0).getTotalCost()) / projectYearOnYearInfoNow.get(0).getTotalCost();
+                            yearOnYear = decimalFormat.format(yearOnYearD);
+                        }
+                        projectInfo.setYearOnYear(yearOnYear);
+                    }else {
+                        //环比 日报
+                        List<KuaiShouOperateProjectVo> projectYearOnYearInfo = materialStareMapper.getKuaiShouOperateProjectInfo(lastTimeStart,lastTimeEnd,projectId,operatorUserIds);
+                        if (!Check.isNull(projectYearOnYearInfo)){
+                            Double yearOnYearD = (projectInfo.getTotalCost() - projectYearOnYearInfo.get(0).getTotalCost()) / projectYearOnYearInfo.get(0).getTotalCost();
+                            yearOnYear = decimalFormat.format(yearOnYearD);
+                        }
+                        projectInfo.setYearOnYear(yearOnYear);
+                    }
 
-                //查看 上传到助手、媒体的素材数量 分版位花费
-                List<JSONObject> materailUpload = materialStareMapper.getKuaiShouMaterailUploadType(projectInfo.getProjectId(),startDate,entDate);
+                    //查询 有效 上新视频 爆款视频
+                    JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(null,projectInfo.getProjectId(),null,startDate,entDate);
+                    projectInfo.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
+                    projectInfo.setNewVideoNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newVideoNum"));//上新
+                    projectInfo.setNewHotNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newHotNum"));//爆款
 
-                projectInfo.setAdspNum(Check.isNull(materailUpload) ? 0L : JSONObject.parseObject(materailUpload.get(0)+"").getLong("num"));//上传到助手
-                projectInfo.setMediaNum(Check.isNull(materailUpload) ? 0L : JSONObject.parseObject(materailUpload.get(1)+"").getLong("num"));//上传到媒体
+                    projectInfo.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum")+newUnitNumNow);//基建数
+                    projectInfo.setTrustUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("trustUnitNum")+trustUnitNum);//智能托管
 
-                //分版位
-                List<JSONObject> adSceneDate = materialStareMapper.getKuaiShouAdSceneData(projectInfo.getProjectId(),startDate,entDate);
-                projectInfo.setAdSceneDate(adSceneDate);
+                    //查看 上传到助手、媒体的素材数量 分版位花费
+                    List<JSONObject> materailUpload = materialStareMapper.getKuaiShouMaterailUploadType(projectInfo.getProjectId(),startDate,entDate);
 
-                //同比 日期超过 7 天 则不显示
-                String equallyRate = "-";
-                if (daysBetween <= 7){
-                    List<KuaiShouOperateProjectVo> projectEquallyInfo = materialStareMapper.getKuaiShouOperateProjectInfo(startEqually,endEqually,projectId,operatorUserIds);
-                    if (!Check.isNull(projectEquallyInfo)){
-                        Double equallyRateD = (projectInfo.getTotalCost() - projectEquallyInfo.get(0).getTotalCost()) / projectEquallyInfo.get(0).getTotalCost();
-                        equallyRate = decimalFormat.format(equallyRateD);
+                    projectInfo.setAdspNum(Check.isNull(materailUpload) ? 0L : JSONObject.parseObject(materailUpload.get(0)+"").getLong("num"));//上传到助手
+                    projectInfo.setMediaNum(Check.isNull(materailUpload) ? 0L : JSONObject.parseObject(materailUpload.get(1)+"").getLong("num"));//上传到媒体
+
+                    //分版位
+                    List<JSONObject> adSceneDate = materialStareMapper.getKuaiShouAdSceneData(projectInfo.getProjectId(),startDate,entDate);
+                    projectInfo.setAdSceneDate(adSceneDate);
+
+                    //同比 日期超过 7 天 则不显示
+                    String equallyRate = "-";
+                    if (daysBetween <= 7){
+                        List<KuaiShouOperateProjectVo> projectEquallyInfo = materialStareMapper.getKuaiShouOperateProjectInfo(startEqually,endEqually,projectId,operatorUserIds);
+                        if (!Check.isNull(projectEquallyInfo)){
+                            Double equallyRateD = (projectInfo.getTotalCost() - projectEquallyInfo.get(0).getTotalCost()) / projectEquallyInfo.get(0).getTotalCost();
+                            equallyRate = decimalFormat.format(equallyRateD);
+                        }
                     }
+                    projectInfo.setEquallyRate(equallyRate);
                 }
-                projectInfo.setEquallyRate(equallyRate);
             }
 
+
+
             PageInfo<KuaiShouOperateProjectVo> pageInfo = new PageInfo<>(listOperate);
             return Result.successMsg("运营项目列表数据查询成功。",pageInfo);
         }catch (Exception e){