فهرست منبع

盯盘运营经理

yangzian 3 سال پیش
والد
کامیت
040196e983

+ 26 - 1
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/KuaiShouMaterialStareController.java

@@ -2,6 +2,7 @@ package org.jeecg.ctop.material.controller;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
 import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.hssf.usermodel.*;
@@ -344,7 +345,7 @@ public class KuaiShouMaterialStareController {
 
 
     @GetMapping("/exportKuaiShouOperateProjectInfo")
-    public Result<JSONObject> getKuaiShouOperateProjectInfo(@RequestParam(name="startTime") String startTime,
+    public Result<JSONObject> exportKuaiShouOperateProjectInfo(@RequestParam(name="startTime") String startTime,
                                                             @RequestParam(name="endTime") String endTime,
                                                             @RequestParam(name="userId") String userId,HttpServletResponse response) {
 
@@ -501,10 +502,34 @@ public class KuaiShouMaterialStareController {
     }
 
 
+    /**
+     * 运营组列表数据
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @GetMapping("/getOperationGroupData")
+    public Result<PageInfo<JSONObject>> getOperationGroupData(@RequestParam(name="startTime") String startTime,
+                                                              @RequestParam(name="endTime") String endTime,
+                                                              @RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
+                                                              @RequestParam(name="pageSize",defaultValue = "5") Integer pageSize) {
+
+        return materialStareService.getOperationGroupData(startTime,endTime, pageNum, pageSize);
+    }
+
 
 
 
+    /**
+     * 运营组列表数据
+     * @return
+     */
+    @GetMapping("/exportOperationGroupData")
+    public Result exportOperationGroupData(@RequestParam(name="startTime") String startTime,
+                                                              @RequestParam(name="endTime") String endTime,HttpServletResponse response) {
 
+        return materialStareService.exportOperationGroupData(startTime,endTime,response);
+    }
 
 
 

+ 62 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateGroupVo.java

@@ -0,0 +1,62 @@
+package org.jeecg.ctop.material.entity.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.alibaba.fastjson.JSONObject;
+import lombok.Data;
+import org.jeecg.ctop.material.constants.Check;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 盯盘-运营组数据
+ * zian Y
+ * 2022/2/16
+ **/
+
+@Data
+public class KuaiShouOperateGroupVo implements Serializable {
+
+
+    @Excel(name = "运营经理",width = 15)
+    private String realname;
+    private String userId;
+
+    //运营数量
+    @Excel(name = "运营数量",width = 15)
+    private Integer operationNum;
+
+    //总花费
+    @Excel(name = "总花费",width = 15)
+    private Double totalCost;
+
+    //日均消耗 总花费/天数
+    @Excel(name = "日均消耗",width = 15)
+    private Double averageDayCost;
+    //人均消耗
+    @Excel(name = "人均消耗",width = 15)
+    private Double averagePeopleCost;
+
+    //项目数量
+    @Excel(name = "项目数量",width = 15)
+    private long projectNum;
+
+    //账户数量
+    @Excel(name = "账户数量",width = 15)
+    private long accountNum;
+
+    //平均账户消耗 总花费/账户数量
+    @Excel(name = "平均账户消耗",width = 15)
+    private Double averageAccountCost;
+
+    //花费环比
+    @Excel(name = "花费环比",width = 15)
+    private String yearOnYearCost;
+
+    //基建数量
+    @Excel(name = "基建数量",width = 15)
+    private long unitNum;//组
+
+
+
+}

+ 15 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateProjectVo.java

@@ -104,6 +104,21 @@ public class KuaiShouOperateProjectVo {
     private String equallyRate;
 
 
+    @ApiModelProperty(value = "智能托管")
+    private Integer trustUnitNum;
+
+
+    @ApiModelProperty(value = "基建数")
+    private Integer newUnitNum;
+
+    @ApiModelProperty(value = "上传助手素材数")
+    private String adspNum;
+    @ApiModelProperty(value = "上传媒体素材数")
+    private String mediaNum;
+    @ApiModelProperty(value = "版位数据")
+    private String adSceneNum;
+
+
 
 
 

+ 5 - 2
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateVo.java

@@ -23,6 +23,9 @@ public class KuaiShouOperateVo implements Serializable {
     @Excel(name = "账户数量",width = 10)
     private Integer accountNum;
 
+    @Excel(name = "项目数量",width = 10)
+    private Integer projectNum;
+
     @Excel(name = "总花费",width = 20)
     private Double totalCost;
 
@@ -31,8 +34,8 @@ public class KuaiShouOperateVo implements Serializable {
 
     private String userId;
 
-    @Excel(name = "有效素材数",width = 15)
-    private Integer newEffectNum;
+    //@Excel(name = "有效素材数",width = 15)
+    //private Integer newEffectNum;
 
     @Excel(name = "新上计划数",width = 15)
     private Integer newCampaignNum;

+ 14 - 5
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -3,10 +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.KuaiShouOperateProjectVo;
-import org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo;
+import org.jeecg.ctop.material.entity.vo.*;
 
 import java.util.List;
 import java.util.Map;
@@ -22,6 +19,8 @@ public interface MaterialStareMapper {
     Set<String> getAffiliateId(@Param("leaderId")String leaderId,@Param("companyId")String companyId);
     Set<String> querySubordinateRecursive(@Param("companyId")String companyId,@Param("leaderIds")Set<String> leaderIds);
     Set<String> getKuaiShouAllOperators(@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);
 
 
 
@@ -44,7 +43,11 @@ public interface MaterialStareMapper {
     List<KuaiShouOperateVo> getKuaiShouOperateInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("list")Set<String> operatorUserIds);
 
     //查看 快手 有效 计划 组
-    JSONObject getKuaiShouAccountBaseByUserId(@Param("userId")String userId,@Param("projectId")String projectId,@Param("accountId")String accountId,@Param("startDate")Long startDate, @Param("endDate")Long endDate);
+    JSONObject getKuaiShouAccountBaseByUserId(@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);
+    //查看 上传到助手、媒体的素材数量 分版位花费
+    List<JSONObject> getKuaiShouMaterailUploadType(@Param("projectId")String projectId,@Param("startDate")Long startDate, @Param("endDate")Long endDate);
 
     //快手 -查询 项目 数据信息
     List<KuaiShouOperateProjectVo> getKuaiShouOperateProjectInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
@@ -103,5 +106,11 @@ public interface MaterialStareMapper {
 
     JSONObject getColumnInfo(@Param("userId") String userId,@Param("columnType") String columnType);
 
+    /**
+     * 查询运营经理角色的人
+     * @return
+     */
+    List<JSONObject> getOperationManagerUser();
+
 
 }

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

@@ -150,7 +150,8 @@
         IFNULL(SUM(abi.new_campaign_num),0) as newCampaignNum,
         IFNULL(SUM(abi.new_unit_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.new_hot_num ),0) AS newHotNum,
+        IFNULL(SUM( abi.trust_unit_num ),0) AS trustUnitNum
         from application.app_kuaishou_account_base_info_d abi,
         `jeecg-boot`.ctop_user_allocation u
         WHERE abi.account_id = u.account_id
@@ -161,9 +162,15 @@
         <if test="endDate != null and endDate != '' ">
             and abi.stat_date &lt;= #{endDate}
         </if>
-        <if test="userId != null and userId != '' ">
-            and abi.user_id = #{userId}
+
+        <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>
@@ -173,6 +180,92 @@
 
     </select>
 
+ <!-- 查看 快手 当天 有效 计划 组-->
+    <select id="getKuaiShouAccountNowBaseByUserId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT abi.account_id ,
+        IFNULL(SUM(abi.new_all_unit_num),0) as newUnitNum
+        from application.app_kuaishou_account_today_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="getKuaiShouMaterailUploadType" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        IFNULL( SUM( material_num ), 0 ) 'num',
+        'adspNum'
+        FROM
+        application.new_material_num_in_project
+        <where>
+            <if test="projectId != null and projectId != '' ">
+                and project_id = #{projectId}
+            </if>
+            <if test="startDate != null and startDate != '' ">
+                and stat_date &gt;= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != '' ">
+                and stat_date &lt;= #{endDate}
+            </if>
+        </where>
+        UNION
+        SELECT
+        IFNULL(SUM( material_upload_media_num ),0) 'num',
+        'mediaNum'
+        FROM
+        application.today_material_upload_num
+        WHERE
+        type_id = 1
+        <if test="projectId != null and projectId != '' ">
+            and dimension = #{projectId}
+        </if>
+        <if test="startDate != null and startDate != '' ">
+            and stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and stat_date &lt;= #{endDate}
+        </if>
+        UNION
+        SELECT
+        IFNULL(SUM(charge),0) 'num','adsceneNum'
+        FROM
+        application.app_kuaishou_account_ad_scene_report_d
+        <where>
+            <if test="projectId != null and projectId != '' ">
+                and project_id = #{projectId}
+            </if>
+            <if test="startDate != null and startDate != '' ">
+                and stat_date &gt;= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != '' ">
+                and stat_date &lt;= #{endDate}
+            </if>
+        </where>
+
+    </select>
+
 
 
     <!-- 快手 快手-查询账户数据信息 -->
@@ -180,6 +273,7 @@
         SELECT
         SUM( d.charge ) totalCost,
         COUNT(DISTINCT d.account_id) accountNum,
+        COUNT(DISTINCT d.project_id) projectNum,
         d.user_id as userId,
         (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
         FROM
@@ -936,6 +1030,28 @@
     </select>
 
 
+    <!-- 快手 项目数量 -->
+    <select id="getKuaiShouOperatorProjectNum" resultType="java.lang.String">
+        SELECT
+        COUNT(DISTINCT d.project_id) as projectNum
+        FROM
+        application.kuaishou_account_report_daily_dw d
+        WHERE
+         d.charge > 0
+        <if test="startDate != null and startDate != '' ">
+            and d.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_date &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">
 
@@ -1168,4 +1284,27 @@
     </select>
 
 
+    <!-- 查询运营经理角色的人员 -->
+    <select id="getOperationManagerUser" resultType="com.alibaba.fastjson.JSONObject">
+
+        SELECT
+            u.id as userId,
+            u.username,
+            u.realname,
+            r.role_name as roleName
+        FROM
+            `jeecg-boot`.sys_user u,
+            `jeecg-boot`.sys_role r,
+            `jeecg-boot`.sys_user_role sur
+        WHERE
+            r.role_code LIKE '%OperationManager%'
+          AND u.id = sur.user_id
+          AND r.id = sur.role_id
+          AND u.STATUS = 1
+          AND u.del_flag = 0
+        ORDER BY u.create_time
+
+    </select>
+
+
 </mapper>

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

@@ -1,9 +1,11 @@
 package org.jeecg.ctop.material.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageInfo;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.ctop.material.entity.vo.KuaiShouOperateAccountVo;
 import org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
@@ -53,4 +55,7 @@ public interface MaterialStareService {
     List<JSONObject> getProjectByUserIdAndMediaIdsSubordinate(Set<String> userIds, List<Integer> mediaIds);
     Map<Long, List<JSONObject>> getAccountListByProjectListSubordinate(Set<String> userIds,List<JSONObject> projectList);
 
+    Result getOperationGroupData(String startTime, String endTime, Integer pageNum, Integer pageSize);
+    Result exportOperationGroupData(String startTime, String endTime,HttpServletResponse response);
+
 }

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

@@ -13,10 +13,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.ctop.material.constants.Check;
-import org.jeecg.ctop.material.entity.vo.KuaiShouAccountPieVo;
-import org.jeecg.ctop.material.entity.vo.KuaiShouOperateAccountVo;
-import org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo;
-import org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo;
+import org.jeecg.ctop.material.entity.vo.*;
 import org.jeecg.ctop.material.mapper.MaterialStareMapper;
 import org.jeecg.ctop.material.service.MaterialStareService;
 import org.jeecg.ctop.material.utils.FeidNotNullUtils;
@@ -25,10 +22,13 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.DoubleStream;
+import java.util.stream.IntStream;
 
 /**
  * 盯盘接口
@@ -196,6 +196,9 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             //有消耗的账户
             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);
+
             SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
             // ==>> 20220202
             String now = sdf.format(new Date());
@@ -225,6 +228,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             DecimalFormat df = new DecimalFormat("#.000");
             resultMap.put("userAverageAccount",new Double(Math.ceil(userAverageAccount)).intValue());
             resultMap.put("userAveragecost",df.format(userAveragecost));
+            resultMap.put("peojectNum",projectNum);
         }catch (Exception e){
             e.printStackTrace();
         }
@@ -352,6 +356,8 @@ public class MaterialStareServiceImpl implements MaterialStareService {
     public Result getKuaiShouOperateInfo(Integer pageNum, int pageSize, String startTime, String endTime, String userId) {
         DecimalFormat decimalFormat = new DecimalFormat("0.00%");
 
+
+
         try {
         //查询当前人员所有下级
         Set<String> operatorUserIds = getAffiliateId(userId);
@@ -363,16 +369,29 @@ public class MaterialStareServiceImpl implements MaterialStareService {
         long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
         long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
 
+        long now = Long.valueOf(DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd")));
+
         PageHelper.startPage(pageNum,pageSize);
         //查询运营数据
         List<KuaiShouOperateVo> listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
         for (KuaiShouOperateVo operate : listOperate) {
 
-            //查询 有效 上新计划 上新组
-            JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operate.getUserId(),null,null,startDate,entDate);
-            operate.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
-            operate.setNewCampaignNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newCampaignNum"));//计划
-            operate.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+            Set<String> ids = new HashSet<String>(){{
+                add(operate.getUserId());
+            }};
+
+            //当天
+            if (startDate == entDate && entDate == now){
+                //查询 当天有效 上新计划 上新组
+                JSONObject newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(ids,null,null,startDate,entDate);
+                operate.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+            }else {
+                //查询 有效 上新计划 上新组
+                JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(ids,null,null,startDate,entDate);
+                //operate.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
+                operate.setNewCampaignNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newCampaignNum"));//计划
+                operate.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+            }
 
             Set<String> userSet = new HashSet<String>(){{
                 add(operate.getUserId());
@@ -408,15 +427,29 @@ public class MaterialStareServiceImpl implements MaterialStareService {
         long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
         long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
 
-        //查询运营数据
+        long now = Long.valueOf(DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd")));
+
+            //查询运营数据
         List<KuaiShouOperateVo> listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
         for (KuaiShouOperateVo operate : listOperate) {
 
-            //查询 有效 上新计划 上新组
-            JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operate.getUserId(),null,null,startDate,entDate);
-            operate.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
-            operate.setNewCampaignNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newCampaignNum"));//计划
-            operate.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+            Set<String> ids = new HashSet<String>(){{
+                add(operate.getUserId());
+            }};
+
+            //当天
+            if (startDate == entDate && entDate == now){
+                //查询 当天有效 上新计划 上新组
+                JSONObject newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(ids,null,null,startDate,entDate);
+                operate.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+            }else {
+                //查询 有效 上新计划 上新组
+                JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(ids,null,null,startDate,entDate);
+                //operate.setNewEffectNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newEffectNum"));//有效
+                operate.setNewCampaignNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newCampaignNum"));//计划
+                operate.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+            }
+
 
             Set<String> userSet = new HashSet<String>(){{
                 add(operate.getUserId());
@@ -491,6 +524,15 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 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) ? "0" : JSONObject.parseObject(materailUpload.get(0)+"").getString("num"));//上传到助手
+                projectInfo.setMediaNum(Check.isNull(materailUpload) ? "0" : JSONObject.parseObject(materailUpload.get(1)+"").getString("num"));//上传到媒体
+                projectInfo.setAdSceneNum(Check.isNull(materailUpload) ? "0" : JSONObject.parseObject(materailUpload.get(2)+"").getString("num"));//分版位
 
                 String projectId = projectInfo.getProjectId();
                 List<KuaiShouOperateProjectVo> projectYearOnYearInfo = materialStareMapper.getKuaiShouOperateProjectInfo(lastTimeStart,lastTimeEnd,projectId,operatorUserIds);
@@ -558,6 +600,15 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 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) ? "0" : JSONObject.parseObject(materailUpload.get(0)+"").getString("num"));//上传到助手
+                projectInfo.setMediaNum(Check.isNull(materailUpload) ? "0" : JSONObject.parseObject(materailUpload.get(1)+"").getString("num"));//上传到媒体
+                projectInfo.setAdSceneNum(Check.isNull(materailUpload) ? "0" : JSONObject.parseObject(materailUpload.get(2)+"").getString("num"));//分版位
 
                 String projectId = projectInfo.getProjectId();
                 List<KuaiShouOperateProjectVo> projectYearOnYearInfo = materialStareMapper.getKuaiShouOperateProjectInfo(lastTimeStart,lastTimeEnd,projectId,operatorUserIds);
@@ -989,6 +1040,170 @@ public class MaterialStareServiceImpl implements MaterialStareService {
     }
 
 
+
+    /**
+     *
+     * @description: 运营组列表数据
+     *
+     * @param startTime
+     * @param endTime
+     * @param pageNum
+     * @param pageSize
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/8/31 15:16
+     */
+    @Override
+    public Result getOperationGroupData(String startTime,String endTime,Integer pageNum,Integer pageSize) {
+        List<KuaiShouOperateGroupVo> resultList = new ArrayList<>();
+        DecimalFormat decimalFormat = new DecimalFormat("0.00%");
+        try {
+            long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+            long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+            //计算环比 时间值 上阶段时间 以及 两个日期之间的 间隔天数
+            Map<String,String> lastTime = DateUtils.getStartEndTime(startTime,endTime);
+            long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
+            long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
+            Integer daysBetween = Integer.valueOf(lastTime.get("daysBetween"))+1;
+            PageHelper.startPage(pageNum,pageSize);
+            //查询运营经理
+            List<JSONObject> operationManagerList = materialStareMapper.getOperationManagerUser();
+            for (JSONObject operationManagerUser : operationManagerList) {
+                KuaiShouOperateGroupVo groupVo = new KuaiShouOperateGroupVo();
+                groupVo.setRealname(operationManagerUser.getString("realname"));
+                //下级员工
+                Set<String> operatorUserIds = getAffiliateId(operationManagerUser.getString("userId"));
+                //运营数量
+                int operationNum = Check.isNull(operatorUserIds) ? 0 : operatorUserIds.size();
+                groupVo.setOperationNum(operationNum);
+                //查询账户数据
+                List<KuaiShouOperateVo> listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
+                //总花费
+                Double totalCost = Check.isNull(listOperate) ? 0 : listOperate.stream().mapToDouble(KuaiShouOperateVo::getTotalCost).sum();
+                groupVo.setTotalCost(new BigDecimal(totalCost).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+
+                //日均消耗 总花费/天数
+                Double aveDay = daysBetween == 0 ? 0 : totalCost/daysBetween;
+                groupVo.setAverageDayCost(new BigDecimal(aveDay).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+                //人均消耗
+                OptionalDouble avePeople = listOperate.stream().mapToDouble(KuaiShouOperateVo::getTotalCost).average();
+                groupVo.setAveragePeopleCost(Check.isNull(listOperate) ? 0 : new BigDecimal( avePeople.getAsDouble()).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+
+                //项目数量
+                Double projectNum = Check.isNull(listOperate) ? 0 : listOperate.stream().mapToDouble(KuaiShouOperateVo::getProjectNum).sum();
+                groupVo.setProjectNum(projectNum.longValue());
+                //账户数量
+                Double accountNum = Check.isNull(listOperate) ? 0 : listOperate.stream().mapToDouble(KuaiShouOperateVo::getAccountNum).sum();
+                groupVo.setAccountNum(accountNum.longValue());
+                //平均账户消耗 总花费/账户数量
+                Double aveAccount = accountNum.intValue() == 0 ? 0 : totalCost/accountNum;
+                groupVo.setAverageAccountCost(new BigDecimal(aveAccount).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+                //环比 = (当前 - 上阶段 ) / 上阶段
+                List<KuaiShouOperateVo> yearOnYearInfo = materialStareMapper.getKuaiShouOperateInfo(lastTimeStart,lastTimeEnd,operatorUserIds);
+                String yearOnYear = "0";
+                if (!Check.isNull(yearOnYearInfo)){
+                    Double lastTotalCost = Check.isNull(yearOnYearInfo) ? 0 : yearOnYearInfo.stream().mapToDouble(KuaiShouOperateVo::getTotalCost).sum();
+                    Double yearOnYearD = (totalCost - lastTotalCost) / lastTotalCost;
+                    yearOnYear = decimalFormat.format(yearOnYearD);
+                }
+                //花费环比
+                groupVo.setYearOnYearCost(yearOnYear);
+                //查询 上新组
+                JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operatorUserIds,null,null,startDate,entDate);
+                //基建数量
+                groupVo.setUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+                resultList.add(groupVo);
+            }
+
+            PageInfo<KuaiShouOperateGroupVo> pageInfo = new PageInfo<>(resultList);
+            return Result.successMsg("运营组列表数据查询成功。",pageInfo);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return Result.errorMsg("哎呀,查询失败了。");
+    }
+
+
+    public Result exportOperationGroupData(String startTime,String endTime, HttpServletResponse response) {
+        List<KuaiShouOperateGroupVo> resultList = new ArrayList<>();
+        DecimalFormat decimalFormat = new DecimalFormat("0.00%");
+        try {
+            long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+            long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+            //计算环比 时间值 上阶段时间 以及 两个日期之间的 间隔天数
+            Map<String,String> lastTime = DateUtils.getStartEndTime(startTime,endTime);
+            long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
+            long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
+            Integer daysBetween = Integer.valueOf(lastTime.get("daysBetween"))+1;
+
+            //查询运营经理
+            List<JSONObject> operationManagerList = materialStareMapper.getOperationManagerUser();
+            for (JSONObject operationManagerUser : operationManagerList) {
+                KuaiShouOperateGroupVo groupVo = new KuaiShouOperateGroupVo();
+                groupVo.setRealname(operationManagerUser.getString("realname"));
+                //下级员工
+                Set<String> operatorUserIds = getAffiliateId(operationManagerUser.getString("userId"));
+                //运营数量
+                int operationNum = Check.isNull(operatorUserIds) ? 0 : operatorUserIds.size();
+                groupVo.setOperationNum(operationNum);
+                //查询账户数据
+                List<KuaiShouOperateVo> listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
+                //总花费
+                Double totalCost = Check.isNull(listOperate) ? 0 : listOperate.stream().mapToDouble(KuaiShouOperateVo::getTotalCost).sum();
+                groupVo.setTotalCost(new BigDecimal(totalCost).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+                //日均消耗 总花费/天数
+                Double aveDay = daysBetween == 0 ? 0 : totalCost/daysBetween;
+                groupVo.setAverageDayCost(new BigDecimal(aveDay).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+                //人均消耗
+                OptionalDouble avePeople = listOperate.stream().mapToDouble(KuaiShouOperateVo::getTotalCost).average();
+
+                groupVo.setAveragePeopleCost(Check.isNull(listOperate) ? 0 : new BigDecimal(String.valueOf( avePeople.getAsDouble())).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+                //项目数量
+                Double projectNum = Check.isNull(listOperate) ? 0 : listOperate.stream().mapToDouble(KuaiShouOperateVo::getProjectNum).sum();
+                groupVo.setProjectNum(projectNum.longValue());
+                //账户数量
+                Double accountNum = Check.isNull(listOperate) ? 0 : listOperate.stream().mapToDouble(KuaiShouOperateVo::getAccountNum).sum();
+                groupVo.setAccountNum(accountNum.longValue());
+                //平均账户消耗 总花费/账户数量
+                Double aveAccount = accountNum.intValue() == 0 ? 0 : totalCost/accountNum;
+                groupVo.setAverageAccountCost(new BigDecimal(aveAccount).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+                //环比 = (当前 - 上阶段 ) / 上阶段
+                List<KuaiShouOperateVo> yearOnYearInfo = materialStareMapper.getKuaiShouOperateInfo(lastTimeStart,lastTimeEnd,operatorUserIds);
+                String yearOnYear = "0";
+                if (!Check.isNull(yearOnYearInfo)){
+                    Double lastTotalCost = Check.isNull(yearOnYearInfo) ? 0 : yearOnYearInfo.stream().mapToDouble(KuaiShouOperateVo::getTotalCost).sum();
+                    Double yearOnYearD = (totalCost - lastTotalCost) / lastTotalCost;
+                    yearOnYear = decimalFormat.format(yearOnYearD);
+                }
+                //花费环比
+                groupVo.setYearOnYearCost(yearOnYear);
+                //查询 上新组
+                JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operatorUserIds,null,null,startDate,entDate);
+                //基建数量
+                groupVo.setUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum"));//组
+                resultList.add(groupVo);
+            }
+            Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("运营组数据详情", "运营组数据"), KuaiShouOperateGroupVo.class, resultList);
+            response.setCharacterEncoding("UTF-8");
+            response.setHeader("content-Type", "application/vnd.ms-excel");
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("运营组数据详情.xlsx", "UTF-8"));
+            workbook.write(response.getOutputStream());
+            return null;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return Result.errorMsg("哎呀,查询失败了。");
+    }
+
+
+
+
+
+
+
+
+
+
 //===========================================查询下级员工========================
 
     public Result getCompanyAllSubordinateByUserId(String userId){