Browse Source

Merge remote-tracking branch 'origin/test' into test

zhaoxian 3 năm trước cách đây
mục cha
commit
8105707bcd

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

@@ -513,27 +513,28 @@ public class KuaiShouMaterialStareController {
     @GetMapping("/getOperationGroupData")
     public Result<JSONObject> getOperationGroupData(
                                                             @RequestParam(name="userId") String userId,
+                                                            @RequestParam(name="mediaType") String mediaType,
                                                             @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(userId,startTime,endTime, pageNum, pageSize);
+        return materialStareService.getOperationGroupData(userId,mediaType,startTime,endTime, pageNum, pageSize);
     }
 
 
 
 
     /**
-     * 运营组列表数据-导出-master
+     * 运营组列表数据-导出
      * @return
      */
     @GetMapping("/exportOperationGroupData")
-    public Result exportOperationGroupData(@RequestParam(name="userId") String userId,
+    public Result exportOperationGroupData(@RequestParam(name="userId") String userId,@RequestParam(name="mediaType") String mediaType,
                                            @RequestParam(name="startTime") String startTime,
                                                               @RequestParam(name="endTime") String endTime,HttpServletResponse response) {
 
-        return materialStareService.exportOperationGroupData(userId,startTime,endTime,response);
+        return materialStareService.exportOperationGroupData(userId,mediaType,startTime,endTime,response);
     }
 
 

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

@@ -64,8 +64,10 @@ public interface MaterialStareMapper {
 
     //快手-查询账户数据信息
     List<KuaiShouOperateVo> getKuaiShouOperateInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
+    List<KuaiShouOperateVo> getBytedanceOperateInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
 
     List<KuaiShouOperateVo> getKuaiShouOperateInfoHourly(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
+    List<KuaiShouOperateVo> getBytedanceOperateInfoHourly(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("list") Set<String> operatorUserIds);
 
     //查看 快手 有效 计划 组
     JSONObject getKuaiShouAccountBaseByUserId(@Param("list") Set<String> operatorUserIds, @Param("projectId") String projectId, @Param("accountId") String accountId, @Param("startDate") Long startDate, @Param("endDate") Long endDate);
@@ -87,6 +89,8 @@ public interface MaterialStareMapper {
     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);
+    //头条-查询消费 时报
+    List<KuaiShouOperateProjectVo> getBytedanceOperateProjectInfoHour(@Param("startDate")Long startDate, @Param("endDate")Long endDate,@Param("hour")int hour, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
 
     //快手 -查询 账户 数据信息
     List<KuaiShouOperateAccountVo> getKuaiShouOperateAccountInfo(@Param("startDate") Long startDate, @Param("endDate") Long endDate, @Param("projectId") String projectId, @Param("accountId") Long accountId, @Param("list") Set<String> operatorUserIds);

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

@@ -165,7 +165,7 @@
 
         SELECT
         SUM( t.cost ) AS totalCost,
-        ( SELECT realname FROM `jeecg-boot`.sys_user u WHERE u.id = user_id ) AS userName
+        ( SELECT realname FROM `jeecg-boot`.sys_user u WHERE u.id = t.user_id ) AS userName
         FROM
         application.bytedance_advertiser_report_daily_dw t
         WHERE
@@ -326,7 +326,7 @@
         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_ad_num) - SUM(abi.trust_campaign_num)),0) as trustUnitNum,
         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
@@ -487,6 +487,38 @@
     </select>
 
     <!-- 快手 快手-查询账户数据信息 -->
+    <select id="getBytedanceOperateInfo" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo">
+        SELECT
+        SUM( d.cost ) 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
+        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='list!=null'>
+            AND d.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY d.user_id
+        ORDER BY SUM( d.cost ) DESC
+    </select>
+
+
+    <!-- 快手 快手-查询账户数据信息 -->
     <select id="getKuaiShouOperateInfoHourly" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo">
         SELECT
         SUM( d.charge ) totalCost,
@@ -516,6 +548,36 @@
         GROUP BY d.user_id
         ORDER BY SUM( d.charge ) DESC
     </select>
+    <!-- 头条 -查询账户数据信息 -->
+    <select id="getBytedanceOperateInfoHourly" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo">
+        SELECT
+        SUM( d.cost ) 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
+        application.bytedance_advertiser_report_hourly_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='list!=null'>
+            AND d.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY d.user_id
+        ORDER BY SUM( d.cost ) DESC
+    </select>
 
     <!-- 快手 -查询项目数据信息 日报-->
     <select id="getKuaiShouOperateProjectInfo" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">
@@ -576,12 +638,13 @@
     <select id="getBytedanceOperateProjectInfo" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">
         SELECT
         COUNT( DISTINCT d.account_id ) AS accountNum,
+        COUNT( DISTINCT d.user_id ) AS userNum,
         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
+        ( SELECT realname FROM `jeecg-boot`.sys_user u WHERE u.id = d.user_id ) AS userName
         FROM
-        application.bytedance_advertiser_report_daily_dw d
+        application.bytedance_advertiser_report_hourly_dw d
         LEFT JOIN `jeecg-boot`.ctop_user_allocation u on d.account_id = u.account_id
         WHERE
         d.cost > 0
@@ -635,13 +698,45 @@
                 #{item}
             </foreach>
         </if>
-
-
         GROUP BY
         d.project_id
         ORDER BY
         SUM( d.charge ) DESC
+    </select>
 
+    <!-- 头条 -查询项目数据信息 时报-->
+    <select id="getBytedanceOperateProjectInfoHour" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">
+        SELECT
+        SUM( d.cost ) AS totalCost
+        FROM
+        application.bytedance_advertiser_report_hourly_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="endDate != null and endDate != '' ">
+            AND d.`hour` &lt;= #{hour}
+        </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>
 
 
@@ -1325,7 +1420,7 @@
         SELECT DISTINCT
         d.user_id
         FROM
-        application.bytedance_advertiser_report_daily_dw d
+        application.bytedance_advertiser_report_hourly_dw d
         WHERE
          d.cost > 0
         <if test="companyId != null and companyId != '' ">
@@ -1372,7 +1467,7 @@
         SELECT
         COUNT(DISTINCT d.project_id) as projectNum
         FROM
-        application.bytedance_advertiser_report_daily_dw d
+        application.bytedance_advertiser_report_hourly_dw d
         WHERE
          d.cost > 0
         <if test="startDate != null and startDate != '' ">

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

@@ -55,7 +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 userId,String startTime, String endTime, Integer pageNum, Integer pageSize);
-    Result exportOperationGroupData(String userId,String startTime, String endTime,HttpServletResponse response);
+    Result getOperationGroupData(String userId,String mediaType,String startTime, String endTime, Integer pageNum, Integer pageSize);
+    Result exportOperationGroupData(String userId,String mediaType,String startTime, String endTime,HttpServletResponse response);
 
 }

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

@@ -19,6 +19,7 @@ import org.jeecg.ctop.material.mapper.MaterialStareMapper;
 import org.jeecg.ctop.material.service.MaterialStareService;
 import org.jeecg.ctop.material.utils.FeidNotNullUtils;
 import org.jeecg.ctop.material.utils.LinkUtil;
+import org.jeecg.ctop.material.utils.ListPageUtil;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -279,14 +280,15 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 JSONObject totalCost = materialStareMapper.getBytedanceTotalCostDaily(Long.valueOf(DateUtils.getDateInteger(startTime)),
                         Long.valueOf(DateUtils.getDateInteger(endTime)),
                         operatorUserIds);
-                resultMap.put("sectionCost",totalCost.getDoubleValue("totalCost"));
+                Double tCost = Check.isNull(totalCost.getDoubleValue("totalCost")) ? 0.0 : totalCost.getDoubleValue("totalCost");
+                resultMap.put("sectionCost",tCost);
                 // 人均账户数量 = 时间段内 账户总数量 / 人数
                 Double userAverageAccount = Double.valueOf(totalCost.getString("accountNum")) / operatorUserIds.size();
                 // 人均消耗 = 时间段内 总消耗 / 人数
-                Double userAveragecost = Double.valueOf(totalCost.getString("totalCost")) / operatorUserIds.size();
+                Double userAveragecost = tCost / operatorUserIds.size();
                 DecimalFormat df = new DecimalFormat("#.000");
                 resultMap.put("userAverageAccount",new Double(Math.ceil(userAverageAccount)).intValue());
-                resultMap.put("userAveragecost",df.format(userAveragecost));
+                resultMap.put("userAveragecost",userAveragecost == 0.0 ? 0 : df.format(userAveragecost));
                 resultMap.put("projectNum",projectNum);
             }
 
@@ -612,21 +614,60 @@ public class MaterialStareServiceImpl implements MaterialStareService {
 
             //头条
             if (mediaType.equals("1")){
-
                 PageHelper.startPage(pageNum,pageSize);
                 //查询运营数据-项目维度
                 listOperate = materialStareMapper.getBytedanceOperateProjectInfo(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){
+
+                        //查询当天数据
+
+
+                        //时报 消费
+                        //环比 = (当前 - 上阶段 ) / 上阶段
+                        int hour = DateUtils.getNowHour();
+                        List<KuaiShouOperateProjectVo> projectYearOnYearInfoNow = materialStareMapper.getBytedanceOperateProjectInfoHour(startDate,entDate,hour,projectId,operatorUserIds);
+                        List<KuaiShouOperateProjectVo> projectYearOnYearInfoLast = materialStareMapper.getBytedanceOperateProjectInfoHour(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.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);
+                    }
 
                     //查询 有效 上新视频 爆款视频
-                    JSONObject newEffect = materialStareMapper.getBytedanceAccountBaseByUserId(null,projectInfo.getProjectId(),null,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.setNewUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum")+newUnitNumNow);//基建数
+                    projectInfo.setTrustUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("trustUnitNum")+trustUnitNum);//智能托管
+*/
+                    //查询 有效 上新计划 上新组
+                    JSONObject newEffect = materialStareMapper.getBytedanceAccountBaseByUserId(null,projectInfo.getProjectId(),null,now,now);
                     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"));//上传到助手
@@ -634,20 +675,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                     //分版位
                     List<JSONObject> adSceneDate = materialStareMapper.getKuaiShouAdSceneData(projectInfo.getProjectId(),startDate,entDate);
                     projectInfo.setAdSceneDate(adSceneDate);
-
-                    */
-
-                    String projectId = projectInfo.getProjectId();
-                    //环比 = (当前 - 上阶段 ) / 上阶段
-                    String yearOnYear = "0";
-                    //环比 日报
-                    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 = "-";
@@ -662,6 +690,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 }
 
 
+
             }
             //快手
             if (mediaType.equals("2")){
@@ -1259,9 +1288,10 @@ public class MaterialStareServiceImpl implements MaterialStareService {
      * @time: 2022/8/31 15:16
      */
     @Override
-    public Result getOperationGroupData(String userId,String startTime,String endTime,Integer pageNum,Integer pageSize) {
+    public Result getOperationGroupData(String userId,String mediaType,String startTime,String endTime,Integer pageNum,Integer pageSize) {
         DecimalFormat decimalFormat = new DecimalFormat("0.00%");
         try {
+
             long nowDate = Long.valueOf(DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd")));
 
             long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
@@ -1275,8 +1305,14 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             //查询用户角色
             String roleCode = materialStareMapper.getRoleCodeByUserId(userId);
 
-            //所有运营经理
-            List<KuaiShouOperateGroupVo> allOperationManagerList = materialStareMapper.getOperationManagerUser("kuaishouOperationManager");
+            //所有运营经理 1-头条 2-快手
+            String roleCodeName = "";
+            if (mediaType.equals("1")){
+                roleCodeName = "touTiaoOperationManager";
+            }else {
+                roleCodeName = "kuaishouOperationManager";
+            }
+            List<KuaiShouOperateGroupVo> allOperationManagerList = materialStareMapper.getOperationManagerUser(roleCodeName);
             List<String> allManagerList = allOperationManagerList.stream().map(KuaiShouOperateGroupVo:: getUserId).collect(Collectors.toList());
 
             List<KuaiShouOperateGroupVo> operationManagerList = new ArrayList<>();
@@ -1299,11 +1335,19 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 Result.successMsg("运营组列表数据查询成功。",null);
             }
 
-            for (KuaiShouOperateGroupVo groupVo : operationManagerList) {
+           List<KuaiShouOperateGroupVo> operationList = ListPageUtil.page(operationManagerList, pageSize, pageNum);
+            for (KuaiShouOperateGroupVo groupVo : operationList) {
                 //下级员工
                 Set<String> operatorUserIds = getAffiliateId(groupVo.getUserId());
                 //有消耗的账户
-                operatorUserIds = materialStareMapper.getKuaiShouAllOperators(null,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+
+                if (mediaType.equals("1")){
+                    operatorUserIds = materialStareMapper.getBytedanceAllOperators(null,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+
+                }else {
+                    operatorUserIds = materialStareMapper.getKuaiShouAllOperators(null,DateUtils.getDateInteger(startTime).longValue(),DateUtils.getDateInteger(endTime).longValue(),operatorUserIds);
+                }
+
 
                 if (Check.isNull(operatorUserIds) || operatorUserIds.size() < 1){
                     continue;
@@ -1315,14 +1359,27 @@ public class MaterialStareServiceImpl implements MaterialStareService {
 
                 //查询账户数据
                 List<KuaiShouOperateVo> listOperate= new ArrayList<>();
-                PageHelper.startPage(pageNum,pageSize);
-                if (daysBetween <= 1){
-                    //时报
-                    listOperate= materialStareMapper.getKuaiShouOperateInfoHourly(startDate,entDate,operatorUserIds);
+
+                if (mediaType.equals("1")){
+                    if (daysBetween <= 1){
+                        //时报
+                        listOperate= materialStareMapper.getBytedanceOperateInfoHourly(startDate,entDate,operatorUserIds);
+                    }else {
+
+                        listOperate = materialStareMapper.getBytedanceOperateInfo(startDate,entDate,operatorUserIds);
+                    }
                 }else {
-                    listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
+                    if (daysBetween <= 1){
+                        //时报
+                        listOperate= materialStareMapper.getKuaiShouOperateInfoHourly(startDate,entDate,operatorUserIds);
+                    }else {
+
+                        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());
@@ -1343,8 +1400,14 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 //平均账户消耗 总花费/账户数量
                 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);
+                List<KuaiShouOperateVo> yearOnYearInfo = new ArrayList<>();
+                if (mediaType.equals("1")){
+                    yearOnYearInfo = materialStareMapper.getBytedanceOperateInfo(lastTimeStart,lastTimeEnd,operatorUserIds);
+                }else {
+                    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();
@@ -1354,22 +1417,36 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 //花费环比
                 groupVo.setYearOnYearCost(yearOnYear);
 
-
                 //当天
                 int newUnitNumNow = 0;
                 if (startDate == nowDate || entDate == nowDate){
-                    //查询 当天有效 上新计划 上新组
-                    JSONObject newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(operatorUserIds,null,null,nowDate,nowDate);
+                    JSONObject newEffect = new JSONObject();
+                    if (mediaType.equals("1")){
+                        //查询 当天有效 上新计划 上新组
+                        newEffect = materialStareMapper.getBytedanceAccountBaseByUserId(operatorUserIds,null,null,nowDate,nowDate);
+                    }else {
+                        //查询 当天有效 上新计划 上新组
+                        newEffect = materialStareMapper.getKuaiShouAccountNowBaseByUserId(operatorUserIds,null,null,nowDate,nowDate);
+                    }
                     newUnitNumNow = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum");//组
                 }
 
-                //查询 历史上新组
-                JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operatorUserIds,null,null,startDate,entDate);
+                if (mediaType.equals("1")){
+                }else {
+                    //查询 历史上新组
+                    JSONObject newEffect = materialStareMapper.getKuaiShouAccountBaseByUserId(operatorUserIds,null,null,startDate,entDate);
+                    newUnitNumNow = Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum")+newUnitNumNow;
+                }
+
                 //基建数量
-                groupVo.setUnitNum(Check.isNull(newEffect) ? 0 : newEffect.getInteger("newUnitNum")+newUnitNumNow);//组
+                groupVo.setUnitNum(newUnitNumNow);//组
             }
-
-            PageInfo<KuaiShouOperateGroupVo> pageInfo = new PageInfo<>(operationManagerList);
+            PageInfo<KuaiShouOperateGroupVo> pageInfo = new PageInfo<>(operationList);
+            pageInfo.setTotal(operationManagerList.size());
+            pageInfo.setPageSize(pageSize);
+            pageInfo.setPageNum(pageNum);
+            pageInfo.setIsLastPage(false);
+            pageInfo.setHasNextPage(true);
             return Result.successMsg("运营组列表数据查询成功。",pageInfo);
         }catch (Exception e){
             e.printStackTrace();
@@ -1378,7 +1455,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
     }
 
 
-    public Result exportOperationGroupData(String userId,String startTime,String endTime, HttpServletResponse response) {
+    public Result exportOperationGroupData(String userId,String mediaType,String startTime,String endTime, HttpServletResponse response) {
         DecimalFormat decimalFormat = new DecimalFormat("0.00%");
         try {
             long nowDate = Long.valueOf(DateUtils.getDateInteger(DateUtils.getDate("yyyy-MM-dd")));
@@ -1393,8 +1470,14 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             //查询用户角色
             String roleCode = materialStareMapper.getRoleCodeByUserId(userId);
 
-            //所有运营经理
-            List<KuaiShouOperateGroupVo> allOperationManagerList = materialStareMapper.getOperationManagerUser("kuaishouOperationManager");
+            //所有运营经理 1-头条 2-快手
+            String roleCodeName = "";
+            if (mediaType.equals("1")){
+                roleCodeName = "touTiaoOperationManager";
+            }else {
+                roleCodeName = "kuaishouOperationManager";
+            }
+            List<KuaiShouOperateGroupVo> allOperationManagerList = materialStareMapper.getOperationManagerUser(roleCodeName);
             List<String> allManagerList = allOperationManagerList.stream().map(KuaiShouOperateGroupVo:: getUserId).collect(Collectors.toList());
 
             List<KuaiShouOperateGroupVo> operationManagerList = new ArrayList<>();
@@ -1418,7 +1501,6 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             }
 
             for (KuaiShouOperateGroupVo groupVo : operationManagerList) {
-
                 //下级员工
                 Set<String> operatorUserIds = getAffiliateId(groupVo.getUserId());
                 //有消耗的账户
@@ -1430,26 +1512,31 @@ public class MaterialStareServiceImpl implements MaterialStareService {
 
                 //运营数量
                 int operationNum = Check.isNull(operatorUserIds) ? 0 : operatorUserIds.size();
-
                 groupVo.setOperationNum(operationNum);
+
                 //查询账户数据
                 List<KuaiShouOperateVo> listOperate= new ArrayList<>();
+
                 if (daysBetween <= 1){
                     //时报
                     listOperate= materialStareMapper.getKuaiShouOperateInfoHourly(startDate,entDate,operatorUserIds);
                 }else {
+
                     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());
                 //人均消耗
                 Double avePeople = totalCost/operationNum;
-                groupVo.setAveragePeopleCost(avePeople);
-                  //项目数量
+                groupVo.setAveragePeopleCost(new BigDecimal(avePeople).setScale(3,BigDecimal.ROUND_HALF_UP).doubleValue());
+
+                //项目数量
                 Double projectNum = Check.isNull(listOperate) ? 0 : listOperate.stream().mapToDouble(KuaiShouOperateVo::getProjectNum).sum();
                 groupVo.setProjectNum(projectNum.longValue());
                 //账户数量
@@ -1468,6 +1555,7 @@ public class MaterialStareServiceImpl implements MaterialStareService {
                 }
                 //花费环比
                 groupVo.setYearOnYearCost(yearOnYear);
+
                 //当天
                 int newUnitNumNow = 0;
                 if (startDate == nowDate || entDate == nowDate){

+ 19 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/utils/ListPageUtil.java

@@ -0,0 +1,19 @@
+package org.jeecg.ctop.material.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ListPageUtil {
+
+    public static <T> List<T> page(List<T> dataList, int pageSize, int currentPage) {
+        List<T> currentPageList = new ArrayList<>();
+        if (dataList != null && dataList.size() > 0) {
+            int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
+            for (int i = 0; i < pageSize && i < dataList.size() - currIdx; i++) {
+                T data = dataList.get(currIdx + i);
+                currentPageList.add(data);
+            }
+        }
+        return currentPageList;
+    }
+}