Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

yumeng 5 éve
szülő
commit
07af7f7844
19 módosított fájl, 534 hozzáadás és 1004 törlés
  1. 24 22
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java
  2. 22 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java
  3. 4 2
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  4. 4 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Advertiser.java
  5. 5 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java
  6. 4 4
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java
  7. 43 17
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml
  8. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java
  9. 9 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  10. 1 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysDictController.java
  11. 5 5
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysCategoryService.java
  12. 7 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java
  13. 1 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/PageDTO.java
  14. 9 16
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/ByteDanceVideoReportDailyController.java
  15. 4 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/ByteDanceVideoReportDaily.java
  16. 8 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/ByteDanceVideoReportDailyMapper.java
  17. 112 523
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/ByteDanceVideoReportDailyMapper.xml
  18. 6 6
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IByteDanceVideoReportDailyService.java
  19. 265 398
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ByteDanceVideoReportDailyServiceImpl.java

+ 24 - 22
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/AdvertiserController.java

@@ -27,11 +27,9 @@ import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.ctop.vo.SheetInfoVo;
 import org.jeecg.modules.excelutil.entity.KuaishouXxlEntity;
 import org.jeecg.modules.system.entity.SysCategory;
-import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.entity.UserCompany;
 import org.jeecg.modules.system.mapper.UserCompanyMapper;
 import org.jeecg.modules.system.service.ISysCategoryService;
-import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -114,13 +112,14 @@ public class AdvertiserController {
                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                    @RequestParam(name = "pageSize", defaultValue = "1000") Integer pageSize,
                                                    HttpServletRequest req) {
-
         Result<IPage<Advertiser>> result = new Result<>();
         String roleCode = sysRoleService.getRoleCodeByUserId(advertiser.getUserId());
         String userId = advertiser.getUserId();
         if ("admin".equals(roleCode) || "kuaishouOperationManager".equals(roleCode) || "touTiaoOperationManager".equals(roleCode) || "sale".equals(roleCode) || "saleDirector".equals(roleCode)) {
             advertiser.setUserId(null);
         }
+        String industryId = advertiser.getIndustryId();
+        advertiser.setIndustryId(null);
         QueryWrapper<Advertiser> queryWrapper = QueryGenerator.initQueryWrapper(advertiser, req.getParameterMap());
         if ("kuaishouOperationManager".equals(roleCode)) {
             QueryWrapper<UserCompany> userCompanyQueryWrapper = new QueryWrapper<>();
@@ -132,32 +131,19 @@ public class AdvertiserController {
                 queryWrapper.eq("company_id", userCompany.getCompanyId());
             }
         }
-        Page<Advertiser> page = new Page<>(pageNo, pageSize);
-        IPage<Advertiser> pageList = advertiserService.page(page, queryWrapper);
-        if (pageList != null && pageList.getRecords() != null && !pageList.getRecords().isEmpty()) {
-            List<Advertiser> list = new ArrayList<>();
-            for (int i = 0; i < pageList.getRecords().size(); i++) {
-                Advertiser advertiserRecord = pageList.getRecords().get(i);
-                SysCategory sysCategory = sysCategoryService.getById(advertiserRecord.getIndustryId());
-                if (sysCategory != null) {
-                    advertiserRecord.setIndustryId(sysCategory.getName());
-                }
-                SysUser user = sysUserService.getById(advertiserRecord.getSaleId());
-                if (null != user) {
-                    advertiserRecord.setSaleName(user.getRealname());
-                }
-                list.add(advertiserRecord);
+        if(null!=industryId&&!"".equals(industryId.trim())){
+            SysCategory category = sysCategoryService.getById(industryId);
+            if(null!=category){
+                queryWrapper.likeRight("industry_code",category.getCode());
             }
-            pageList.setRecords(list);
         }
+        Page<Advertiser> page = new Page<>(pageNo, pageSize);
+        IPage<Advertiser> pageList = advertiserService.page(page, queryWrapper);
         result.setSuccess(true);
         result.setResult(pageList);
         return result;
     }
 
-    @Autowired
-    private ISysUserService sysUserService;
-
     /**
      * 添加
      *
@@ -191,6 +177,14 @@ public class AdvertiserController {
             if (!Check.isNull(userCompany)) {
                 advertiser.setCompanyId(userCompany.getCompanyId());
             }
+            String industryId = advertiser.getIndustryId();
+            if(null!=industryId&&!"".equals(industryId.trim())){
+                SysCategory category = sysCategoryService.getById(industryId);
+                if(null!=category){
+                    advertiser.setIndustryId(category.getId());
+                    advertiser.setIndustryCode(category.getCode());
+                }
+            }
             advertiserService.save(advertiser);
             result.success("添加成功!");
         } catch (Exception e) {
@@ -218,6 +212,14 @@ public class AdvertiserController {
         if (advertiserEntity == null) {
             result.error500("未找到对应实体");
         } else {
+            String industryId = advertiser.getIndustryId();
+            if(null!=industryId&&!"".equals(industryId.trim())){
+                SysCategory category = sysCategoryService.getById(industryId);
+                if(null!=category){
+                    advertiser.setIndustryId(category.getId());
+                    advertiser.setIndustryCode(category.getCode());
+                }
+            }
             boolean ok = advertiserService.updateById(advertiser);
             QueryWrapper<Project> projectQueryWrapper = new QueryWrapper<>();
             projectQueryWrapper.eq("advertiser_id", advertiser.getId());

+ 22 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -25,7 +25,9 @@ import org.jeecg.modules.ctop.service.IAdvertiserService;
 import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.jeecg.modules.ctop.service.IProjectService;
 import org.jeecg.modules.ctop.service.ITransferAccountService;
+import org.jeecg.modules.system.entity.SysCategory;
 import org.jeecg.modules.system.entity.SysUser;
+import org.jeecg.modules.system.service.ISysCategoryService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -150,6 +152,8 @@ public class ProjectController {
         return map;
     }
 
+    @Autowired
+    private ISysCategoryService sysCategoryService;
 
     /**
      * 分页列表查询
@@ -168,6 +172,8 @@ public class ProjectController {
                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                 HttpServletRequest req) {
         Result<IPage<Project>> result = new Result<>();
+        String industryId = project.getIndustryId();
+        project.setIndustryId(null);
         QueryWrapper<Project> queryWrapper = QueryGenerator.initQueryWrapper(project, req.getParameterMap());
         Page<Project> page = new Page<>(pageNo, pageSize);
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -176,6 +182,12 @@ public class ProjectController {
             queryWrapper.eq("user_id", sysUser.getId());
             queryWrapper.orderByDesc("create_time");
         }
+        if(null!=industryId&&"".equals(industryId.trim())){
+            SysCategory category = sysCategoryService.getById(industryId);
+            if(null!=category){
+                queryWrapper.likeLeft("industry_code",category.getCode());
+            }
+        }
         IPage<Project> pageList = projectService.page(page, queryWrapper);
         result.setSuccess(true);
         result.setResult(pageList);
@@ -202,7 +214,11 @@ public class ProjectController {
             Map<String, String> memberMap = new HashMap<>();
             if (!Check.isNull(advertiser)) {
                 project.setCompanyId(advertiser.getCompanyId());
-
+            }
+            SysCategory category = sysCategoryService.getById(project.getIndustryId());
+            if(null!=category){
+                project.setIndustryCode(category.getCode());
+                project.setIndustryId(category.getId());
             }
             SysUser sysUser = sysUserService.getById(project.getResponsibleId());
             if (!Check.isNull(sysUser)) {
@@ -265,6 +281,11 @@ public class ProjectController {
             projectMemberService.addMember(sysUser, project);
         }
 
+        SysCategory category = sysCategoryService.getById(project.getIndustryId());
+        if(null!=category){
+            project.setIndustryCode(category.getCode());
+            project.setIndustryId(category.getId());
+        }
         SysUser designSysUser = sysUserService.getById(project.getDesignResponsibleId());
         if (!Check.isNull(designSysUser)) {
             project.setDesignResponsibleName(designSysUser.getRealname());

+ 4 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java

@@ -331,8 +331,10 @@ public class ProjectMemberController {
     @GetMapping(value = "/bytedanceProjectParticipateInList")
     public  Result<List<ProjectMember>> bytedanceProjectParticipateInList() {
         Result<List<ProjectMember>> result = new Result<>();
-        Integer mediaId = 1;
-        List<ProjectMember> projectMemberList = projectMemberService.getProjects(mediaId);
+        List<Integer> mediaIds = new ArrayList<>();
+        mediaIds.add(1);
+        mediaIds.add(3);
+        List<ProjectMember> projectMemberList = projectMemberService.getProjects(mediaIds);
         if (projectMemberList == null) {
             result.error500("未找到对应实体");
         } else {

+ 4 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Advertiser.java

@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.jeecg.common.aspect.annotation.Dict;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -46,12 +47,15 @@ public class Advertiser {
      */
     @Excel(name = "行业ID", width = 15)
     @ApiModelProperty(value = "行业ID")
+    @Dict(dicCode = "id",dictTable="sys_category",dicText="name")
     private String industryId;
+    private String industryCode;
     /**
      * 销售ID
      */
     @Excel(name = "销售ID", width = 15)
     @ApiModelProperty(value = "销售ID")
+    @Dict(dicCode = "id",dictTable="sys_user",dicText="realname")
     private String saleId;
     /**
      * 销售ID

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/entity/Project.java

@@ -10,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.jeecg.common.aspect.annotation.Dict;
 import org.jeecgframework.poi.excel.annotation.Excel;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -52,6 +53,10 @@ public class Project {
     @Excel(name = "广告主名称", width = 15)
     @ApiModelProperty(value = "广告主名称")
     private String advertiserName;
+
+    @Dict(dicCode = "id",dictTable="sys_category",dicText="name")
+    private String industryId;
+    private String industryCode;
     /**
      * 创建人
      */

+ 4 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java

@@ -17,13 +17,13 @@ public interface ProjectMemberMapper extends BaseMapper<ProjectMember> {
 
     List<Long> selectProjectsByUserId(@Param("userId") String userId);
 
-    List<ProjectMember> adminProjects(@Param("mediaId")Integer mediaId);
+    List<ProjectMember> adminProjects(@Param("mediaIds")List<Integer> mediaIds);
 
-    List<ProjectMember> designLeaderProjects(@Param("companyId")String companyId ,@Param("mediaId")Integer mediaId);
+    List<ProjectMember> designLeaderProjects(@Param("companyId")String companyId ,@Param("mediaIds")List<Integer> mediaIds);
 
-    List<ProjectMember> designProjects(@Param("userId")String userId, @Param("mediaId")Integer mediaId);
+    List<ProjectMember> designProjects(@Param("userId")String userId, @Param("mediaIds")List<Integer> mediaIds);
 
-    List<ProjectMember> operationProjects(@Param("userId")String userId, @Param("mediaId")Integer mediaId);
+    List<ProjectMember> operationProjects(@Param("userId")String userId, @Param("mediaIds")List<Integer> mediaIds);
 
     String getRoleCodeByUserId(@Param("userId")String userId);
 

+ 43 - 17
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml

@@ -12,54 +12,80 @@
     <!-- 设计师展示所有自己的角色下制作的视频 -->
     <select id="adminProjects" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
         select
-        id,
-        project_name,
-        advertiser_id,
-        advertiser_name,
-        media_id,
-        max_bid,
-        advertiser_name,
-        responsible_name
+        id as projectId,
+        project_name as projectName,
+        advertiser_id as advertiserId,
+        advertiser_name as advertiserName,
+        media_id as mediaId,
+        max_bid as maxBid,
+        advertiser_name as advertiserName ,
+        responsible_name as responsibleName
         from
         ctop_project
         where
-        media_id = #{mediaId}
+        media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
     </select>
 
     <!-- 视频报表设计师leader展示自己所在公司的所有项目 -->
     <select id="designLeaderProjects" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
         select
-            distinct b.id, b.project_name,b.advertiser_id,b.advertiser_name
+            distinct b.id as projectId,
+            b.project_name as projectName,
+            b.advertiser_id as advertiserId,
+            b.advertiser_name as advertiserName,
+            b.media_id as mediaId
         from
         ctop_project_member a
         left join ctop_project b on a.project_id = b.id
         where
         b.company_id = #{companyId}
-        and b.media_id = #{mediaId}
+        and b.media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
     </select>
 
     <!-- 设计师展示所有自己的角色下制作的视频 -->
     <select id="designProjects" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
         select
-            distinct a.project_id,b.project_name,b.advertiser_id,b.advertiser_name
+            distinct a.project_id as projectId,
+            b.project_name as projectName,
+            b.advertiser_id as advertiserId,
+            b.advertiser_name as advertiserName,
+            b.media_id as mediaId
         from
         ctop_project_member a
         left join ctop_project b on a.project_id = b.id
         where a.user_id = #{userId}
-        and b.media_id = #{mediaId}
-       -- group by a.project_id
+        and b.media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
     </select>
 
     <!-- 运营和运营负责人展示所在项目视频 -->
     <select id="operationProjects" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
         select
-           distinct b.id,b.project_name,b.advertiser_id,b.advertiser_name
+           distinct b.id as projectId,
+           b.project_name as projectName,
+           b.advertiser_id as advertiserId,
+           b.advertiser_name as advertiserName,
+           b.media_id as mediaId
         from
         ctop_user_allocation a
         left join ctop_project b on a.project_id = b.id
         where a.user_id = #{userId}
-        and b.media_id = #{mediaId}
-       -- group by a.project_id
+        and b.media_id in
+        <foreach collection="mediaIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
     </select>
 
     <select id="getRoleCodeByUserId" resultType="string">

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java

@@ -20,5 +20,5 @@ public interface IProjectMemberService extends IService<ProjectMember> {
 
     List<Long> selectProjectsByUserId(String userId);
 
-    List<ProjectMember> getProjects(Integer mediaId);
+    List<ProjectMember> getProjects(List<Integer> mediaIds);
 }

+ 9 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java

@@ -13,6 +13,7 @@ import org.jeecg.modules.system.entity.SysUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -62,22 +63,25 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
     }
 
     //视频报表
-    public List<ProjectMember> getProjects(Integer mediaId){
+    public List<ProjectMember> getProjects(List<Integer> mediaIds){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = memberMapper.getRoleCodeByUserId(userId);
         String companyId = memberMapper.getCompanyIdByUserId(userId);
 
+        //List<Integer> mediaIds = new ArrayList<>();
+        //mediaIds.add(1);
+        //mediaIds.add(3);
         //角色权限判断
         List<ProjectMember> projectMemberList = null;
         if(roleCode.equals("plan") || roleCode.equals("clip") || roleCode.equals("shot") || roleCode.equals("plane")|| roleCode.equals("planeLeader")){
-            projectMemberList = memberMapper.designProjects(userId, mediaId);
+            projectMemberList = memberMapper.designProjects(userId, mediaIds);
         }else if( roleCode.equals("designTeamLeader")){
-            projectMemberList = memberMapper.designLeaderProjects(companyId, mediaId);
+            projectMemberList = memberMapper.designLeaderProjects(companyId, mediaIds);
         }else if(roleCode.equals("admin")){
-            projectMemberList = memberMapper.adminProjects(mediaId);
+            projectMemberList = memberMapper.adminProjects(mediaIds);
         }else if(roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")){
-            projectMemberList = memberMapper.operationProjects(userId, mediaId);
+            projectMemberList = memberMapper.operationProjects(userId, mediaIds);
         }
 
         return projectMemberList;

+ 1 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/SysDictController.java

@@ -405,7 +405,7 @@ public class SysDictController {
 			@RequestParam(name="text") String text,
 			@RequestParam(name="code") String code,
 			@RequestParam(name="hasChildField") String hasChildField) {
-		Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
+		Result<List<TreeSelectModel>> result = new Result<>();
 		List<TreeSelectModel> ls = sysDictService.queryTreeList(tbname, text, code, pidField, pid,hasChildField);
 		result.setSuccess(true);
 		result.setResult(ls);

+ 5 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/ISysCategoryService.java

@@ -1,13 +1,12 @@
 package org.jeecg.modules.system.service;
 
-import java.util.List;
-
 import com.alibaba.fastjson.JSONArray;
+import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.modules.system.entity.SysCategory;
 import org.jeecg.modules.system.model.TreeSelectModel;
 
-import com.baomidou.mybatisplus.extension.service.IService;
+import java.util.List;
 
 /**
  * @Description: 分类字典
@@ -33,13 +32,14 @@ public interface ISysCategoryService extends IService<SysCategory> {
 	 * @param pcode
 	 * @return
 	 */
-	public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException;
+    List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException;
 
     /**
 	  * 根据pid查询子节点集合
 	 * @param pid
 	 * @return
 	 */
-	public List<TreeSelectModel> queryListByPid(String pid);
+    List<TreeSelectModel> queryListByPid(String pid);
 
+    SysCategory getByCode(String getCode);
 }

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/SysCategoryServiceImpl.java

@@ -121,4 +121,11 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
 		return baseMapper.queryListByPid(pid);
 	}
 
+	@Override
+	public SysCategory getByCode(String getCode) {
+		QueryWrapper<SysCategory>queryWrapper = new QueryWrapper<>();
+		queryWrapper.eq("code",getCode).orderByDesc("create_time").last("limit 1");
+		return this.getOne(queryWrapper);
+	}
+
 }

+ 1 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/PageDTO.java

@@ -9,4 +9,5 @@ import java.io.Serializable;
 public class PageDTO implements Serializable {
     private  Integer pageNo;
     private  Integer pageSize;
+    private  String  sort;
 }

+ 9 - 16
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/ByteDanceVideoReportDailyController.java

@@ -103,7 +103,7 @@ public class ByteDanceVideoReportDailyController {
 			 pageSize = 10;
 		 }
 
-		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListDaily(dateDTO.getDate(), dateDTO.getDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds());
+		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListDaily(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds(), dateDTO.getSort());
 
 		 result.setResult(list);
 		 result.setSuccess(true);
@@ -126,7 +126,7 @@ public class ByteDanceVideoReportDailyController {
 			 pageSize = 10;
 		 }
 
-		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListWeek(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds());
+		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListWeek(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds(), dateDTO.getSort());
 		 result.setResult(list);
 		 result.setSuccess(true);
 		 return result;
@@ -146,7 +146,7 @@ public class ByteDanceVideoReportDailyController {
 		 if(pageSize == null){
 			 pageSize = 10;
 		 }
-		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListTotal(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds());
+		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListTotal(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds(), dateDTO.getSort());
 		 result.setResult(list);
 		 result.setSuccess(true);
 		 return result;
@@ -170,7 +170,7 @@ public class ByteDanceVideoReportDailyController {
 		 if(pageSize == null){
 			 pageSize = 10;
 		 }
-		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListMonth(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds());
+		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListMonth(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds(), dateDTO.getSort());
 		 result.setResult(list);
 		 result.setSuccess(true);
 		 return result;
@@ -182,7 +182,7 @@ public class ByteDanceVideoReportDailyController {
 	 public Result<List<ByteDanceVideoReportDaily>> bytedanceVideoInfoListDetail(@RequestBody DateDTO dateDTO,
 																		   HttpServletRequest req){
 		 Result<List<ByteDanceVideoReportDaily>> result = new Result();
-		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListDetail(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature());
+		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListDetail(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getAccountIds());
 		 result.setResult(list);
 		 result.setSuccess(true);
 		 return result;
@@ -230,15 +230,8 @@ public class ByteDanceVideoReportDailyController {
 		 result.setSuccess(true);
 		 result.setMessage("success");
 
-		 //int perCode = videoReportDailyService.videoInfoListTotalExportExcelPermission();
-		 //if(perCode == 0){
-		 //	result.setMessage("无导出权限");
-		 //	result.setCode(500);
-			//return;
-		 //}
-
-		 //公司报表
-		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListDetail(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature());
+		 //按天明细
+		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListDetail(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getAccountIds());
 
 		 //导出excel
 		 List<List<Object>> group = new ArrayList<>();
@@ -254,7 +247,7 @@ public class ByteDanceVideoReportDailyController {
 			 }
 		 }
 
-		 String[] groupHeaders = {"客户", "视频链接", "时间", "消耗","环比"};
+		 String[] groupHeaders = {"客户","视频链接", "时间", "消耗","环比"};
 		 OutputStream os = response.getOutputStream();
 		 ExportExcelUtils eeu = new ExportExcelUtils();
 		 XSSFWorkbook workbook = new XSSFWorkbook();
@@ -286,7 +279,7 @@ public class ByteDanceVideoReportDailyController {
 
 		 String[] columns = dateDTO.getColumns();
 
-  		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListTotalExcel(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost());
+  		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListTotalExcel(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), dateDTO.getAccountIds(), dateDTO.getSort());
 
 		 //导出excel
 		 List<List<Object>> group = new ArrayList<>();

+ 4 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/entity/ByteDanceVideoReportDaily.java

@@ -46,6 +46,10 @@ public class ByteDanceVideoReportDaily {
 	@Excel(name = "广告主名称", width = 15)
     @ApiModelProperty(value = "广告主名称")
 	private String advertiserName;
+	/**广告主id*/
+	@Excel(name = "账户id", width = 15)
+	@ApiModelProperty(value = "账户id")
+	private Long accountId;
 	/**md5*/
 	@Excel(name = "md5", width = 15)
     @ApiModelProperty(value = "md5")

+ 8 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/ByteDanceVideoReportDailyMapper.java

@@ -19,7 +19,7 @@ public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVid
 
     List<ByteDanceVideoReportDaily> videoInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("companyId") String companyId);
 
-    BigDecimal getVideoReportDailyByDateAndSignature(@Param("startDate") String date, @Param("endDate") String endDate, @Param("signature") String signature, @Param("companyId") String companyId);
+    BigDecimal getVideoReportDailyByDateAndSignature(@Param("startDate") String date, @Param("endDate") String endDate, @Param("signature") String signature, @Param("accountIds")List<Long> accountIds);
 
     void updateHuanbiByDateAndSignature(@Param("date") Date date, @Param("signature") String signature, @Param("huanbi") BigDecimal huanbi);
 
@@ -35,9 +35,13 @@ public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVid
 
     void updateJsonByUserIdAndType(@Param("json") String json, @Param("userId") String userId, @Param("columnType") Integer columnType);
 
-    List<ByteDanceVideoReportDaily> videoInfoListDetail(@Param("companyId") String companyId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("signature") String signature, @Param("role") String role);
+    List<ByteDanceVideoReportDaily> videoInfoListDetail(@Param("companyId") String companyId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("signature") String signature, @Param("accountIds") List<Long> accountIds);
 
-    List<ByteDanceVideoReportDaily> bytedanceVideoInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("role") String role, @Param("userId") String userId, @Param("signature") String signature, @Param("companyId") String companyId, @Param("cost") BigDecimal cost);
+    List<ByteDanceVideoReportDaily> videoInfoListDetailDesign(@Param("companyId") String companyId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("signature") String signature, @Param("accountIds") List<Long> accountIds);
+
+    List<ByteDanceVideoReportDaily> videoInfoListDetailOperator(@Param("companyId") String companyId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("signature") String signature, @Param("accountIds") List<Long> accountIds);
+
+    //List<ByteDanceVideoReportDaily> bytedanceVideoInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("role") String role, @Param("userId") String userId, @Param("signature") String signature, @Param("companyId") String companyId, @Param("cost") BigDecimal cost);
 
     List<AccountVideoDTO> accountVideoMap();
 
@@ -68,4 +72,5 @@ public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVid
 
     List<Long> getAccountIdsByOperatorIdAndMediaId(@Param("mediaId")Integer mediaId, @Param("userId")String userId);
 
+    List<Long> getAccountIds(@Param("companyId")String companyId, @Param("signature")String signature);
 }

+ 112 - 523
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/ByteDanceVideoReportDailyMapper.xml

@@ -2,240 +2,6 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.toutiao.modules.report.mapper.ByteDanceVideoReportDailyMapper">
 
-    <select id="videoInfoList" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
-        --  a.material_id as materialId,
-        --         a.account_id as accountId,
-        --         b.auth_name as authName,
-        b.project_id as projectId,
-        b.project_name as projectName,
-        b.advertiser_id as advertiserId,
-        b.advertiser_name as advertiserName,
-        a.stat_datetime as statDatetime,
-        sum(a.cost) as cost,  -- 消耗
-        d.signature as signature,
-        d.video_url as videoUrl,
-        e.url as url,
-        <!-- e.material_name as materialName,  -->
-        '-' as materialDesc,
-        1 as appType,
-        sum(a.click) as click,   -- 点击数
-        case
-        when sum(a.total_play) != 0
-        then sum(a.play25_feed_break)/sum(a.total_play)
-        else 0 end as play25FeedBreakRate,  -- 25%进度播放率
-
-        case
-        when sum(a.total_play) != 0
-        then sum(a.play_over)/sum(a.total_play)
-        else 0 end as playOverRate,  -- 整体完播率
-
-        case
-        when sum(a.click) != 0
-        then sum(a.convert_material)/sum(a.click)
-        else 0 end as convertRate,  -- 转化率  转化数/点击数*100% !
-        sum(a.active) as active, -- 应用下载-激活
-        sum(a.download_finish) as downloadFinish, -- 应用下载-安卓下载完成
-        sum(a.download_start) as downloadStart, -- 应用下载-安卓下载开始
-        sum(a.install_finish) as installFinish, -- 应用下载-安卓安装完成
-        sum(a.register) as register, -- 应用下载-注册
-        sum(a.pay_count) as payCount, -- 应用下载-付费数
-        sum(a.in_app_uv) as inAppUv, -- 应用下载-到达uv
-        sum(a.in_app_detail_uv) as inAppDetailUv, -- 应用下载-详情页到站uv
-        sum(a.in_app_cart) as inAppCart, -- 应用下载-加入购物车
-        sum(a.in_app_order) as inAppOrder, -- 应用下载-提交订单
-        sum(a.in_app_pay) as inAppPay, -- 应用下载-付费
-        sum(a.phone) as phone, -- 落地页-电话拨打数
-        sum(a.form) as form, --  表单提交数
-        sum(a.map_search) as mapSearch, -- 落地页-地图搜索
-        sum(a.button) as button, -- 落地页-按钮button
-        sum(a.view_material) as viewMaterial, -- 落地页-关键页面浏览
-        sum(a.qq) as qq, -- 落地页-QQ咨询数
-        sum(a.lottery) as lottery, -- 落地页-抽奖数
-        sum(a.vote) as vote, -- 落地页-投票
-        sum(a.redirect) as redirect, -- 落地页-页面跳转
-        sum(a.shopping) as shopping, -- 落地页-商品购买
-        sum(a.consult) as consult, -- 落地页-在线咨询
-        sum(a.wechat) as wechat, -- 落地页-微信
-        sum(a.phone_confirm) as phoneConfirm, -- 落地页-智能电话确认拨打
-        sum(a.phone_connect) as phoneConnect, -- 落地页-智能电话确认接通
-        sum(a.consult_effective) as consultEffective, -- 落地页-智能电话有效咨询
-        sum(a.total_play) as totalPlay, -- 视频-总播放
-        sum(a.valid_play) as validPlay, -- 视频-有效播放
-        sum(a.wifi_play) as wifiPlay, -- 视频-wifi播放
-        <!-- sum(a.play_duration_sum) as play_duration_sum, --> -- 视频-播放时长,单位ms
-        sum(a.play25_feed_break) as play25FeedBreak, -- 视频-播放25%进度总数
-        sum(a.play50_feed_break) as play50FeedBreak, -- 视频-播放50%进度总数
-        sum(a.play75_feed_break) as play75FeedBreak, -- 视频-播放75%进度总数
-        sum(a.play100_feed_break) as play100FeedBreak, -- 视频-播放100%进度总数
-        sum(a.advanced_creative_phone_click) as advancedCreativePhoneClick, -- 附加创意-电话按钮
-        sum(a.advanced_creative_counsel_click) as advancedCreativeCounselClick, -- 附加创意-在线咨询
-        sum(a.advanced_creative_form_click) as advancedCreativeFormClick, -- 附加创意-表单提交
-        sum(a.share_material) as shareMaterial, -- 互动数据-分享数
-        sum(a.comment_material) as commentMaterial, -- 互动数据-评论数
-        sum(a.follow) as follow, -- 互动数据-新增关注数
-        sum(a.home_visited) as homeVisited, -- 互动数据-主页访问量
-        sum(a.ies_challenge_click) as iesChallengeClick, -- 互动数据-挑战赛查看数
-        sum(a.ies_music_click) as iesMusicClick, -- 互动数据-音乐查看数
-        sum(a.next_day_open) as nextDayOpen, -- 次留数
-        case
-        when sum(a.active) != 0
-        then sum(a.next_day_open)/sum(a.active)
-        else 0 end as nextDayOpenRate, -- 次留率 = 次留数/激活数
-
-        case
-        when sum(a.next_day_open) != 0
-        then sum(a.cost)/sum(a.next_day_open)
-        else 0 end as nextDayOpenCost, -- 次留成本 = 消耗/次留数
-
-        case when sum(a.pay_count) != 0
-        then sum(a.cost)/sum(a.pay_count)
-        else 0 end
-        as activePayCost, -- 应用下载广告数据-付费成本 = 消耗/付费次数
-
-
-        sum(a.active_pay_amount) as activePayAmount, -- 应用下载广告数据-付费次数
-
-        case
-        when sum(a.valid_play) != 0
-        then sum(a.cost)/sum(a.valid_play)
-        else 0 end validPlayCost, -- 视频数据-有效播放成本  计算公式:总花费/有效播放数,当天数据可能会有波动,次日早8点后稳定。
-        sum(a.advanced_creative_coupon_addition) as advancedCreativeCouponAddition, -- 附加创意-附加创意卡券领取
-        sum(a.convert_material) as convertMaterial, -- 转化数据-转化数
-
-        case
-        when sum(a.active_pay_amount) != 0
-        then sum(a.cost)/sum(a.active_pay_amount)
-        else 0 end as activePayCost, -- 应用下载广告数据-付费成本 = 消耗/付费次数
-        sum(a.download) as download, -- 落地页转化数据-下载开始
-        <!--sum(a.cpa) as cpa, -->--
-        case
-        when sum(a.click) != 0
-        then sum(a.cost) / sum(a.click)
-        else 0 end                           as cpc,                            -- 平均点击单价
-        sum(a.location_click) as locationClick, -- 互动数据-POI点击数
-        --  sum(a.play_over_rate) as playOverRate, -- 视频数据-播完率
-
-        case
-        when sum(a.show_material) != 0
-        then sum(a.click)/sum(a.show_material)
-        else 0 end as ctr, -- 展现数据-点击率   广告被点击的次数占展示次数的百分比。计算方法:点击数/展示数*100%
-
-        case
-        when sum(a.show_material) != 0
-        then sum(a.cost)/sum(a.show_material)*1000
-        else 0 end cpm, -- 平均千次展现费用  广告平均每一千次展现所付出的费用,计算公式是:总花费/展示数*1000。
-        sum(a.wifi_play_rate) as wifiPlayRate, -- 视频数据-WiFi播放占比
-        sum(a.like_material) as likeMaterial, -- 互动数据-点赞数
-        <!--  sum(a.active_pay_rate) as activePayRate,--> -- 应用下载广告数据-付费率
-
-        case
-        when sum(a.active) != 0
-        then sum(a.cost)/sum(a.active)
-        else 0 end activeCost, -- 应用下载广告数据-激活成本  计算方式:总花费/激活数。
-
-        case
-        when sum(a.game_addiction) != 0
-        then sum(a.cost)/sum(a.game_addiction)
-        else 0 end as gameAddictionCost, -- 应用下载广告数据-关键行为成本  广告主为每个有APP内关键行为的用户所付出的成本,计算公式是总花费/关键行为数。当天数据可能会有波动,次日早8点后稳定。
-        sum(a.game_addiction) as gameAddiction, -- 应用下载广告数据-关键行为数
-
-        case
-        when sum(a.click) != 0
-        then sum(a.active)/sum(a.click)
-        else 0 end as activeRate, -- 应用下载广告数据-激活率   计算方式:激活数/点击数*100%
-        <!-- sum(a.play_duration_10s) as playDuration10s,--> --
-        <!-- sum(a.phone_effective) as phone_effective,--> --
-
-        case
-        when sum(a.active) != 0
-        then sum(a.game_addiction)/sum(a.active)
-        else 0 end gameAddictionRate, -- 应用下载广告数据-关键行为率  关键行为用户占激活用户的比例
-
-        case
-        when sum(a.active) != 0
-        then sum(a.register)/sum(a.active)
-        else 0 end as activeRegisterRate, -- 应用下载广告数据-注册率   注册用户占激活用户的比例
-        <!-- sum(a.average_video_play) as averageVideoPlay,--> --
-
-        case
-        when sum(a.download_finish) != 0
-        then sum(a.cost)/sum(a.download_finish)
-        else 0 end as downloadFinishCost, -- 应用下载广告数据-安卓下载完成成本 计算方式:总花费/安卓下载完成数。
-        <!--sum(a.play_duration_3s) as playDuration3s,--> --
-
-        case
-        when sum(a.register) != 0
-        then sum(a.cost)/sum(a.register)
-        else 0 end as activeRegisterCost, -- 应用下载广告数据-注册成本  总花费/注册数,当天数据可能会有波动,次日早8点后稳定。
-        sum(a.show_material) as showMaterial, -- 展现数据-展示数
-
-        <!--  case
-        when sum(a.click) != 0
-        then sum(a.convert_material)/sum(a.click)
-        else 0 end as convertRate,  转化数据-转化率  计算方式:转化数/点击数*100%  -->
-
-        case
-        when sum(a.download_start) != 0
-        then sum(a.download_finish)/sum(a.download_start)
-        else 0 end as downloadFinishRate, -- 应用下载广告数据-安卓下载完成率  计算方式:安卓下载完成数/安卓下载开始数
-
-        case
-        when sum(a.download_finish) != 0
-        then sum(a.install_finish)/sum(a.download_finish)
-        else 0 end as installFinishRate, -- 应用下载广告数据-安卓安装完成率  计算方式:安卓安装完成数/安卓下载完成数
-        sum(a.coupon) as coupon, -- 落地页转化数据-建站卡券领取
-        sum(a.coupon_single_page) as couponSinglePage, -- 落地页转化数据-卡券页领取
-        sum(a.play_over) as playOver, -- 完播数
-
-        case
-        when sum(a.download_start) != 0
-        then sum(a.cost)/sum(a.download_start)
-        else 0 end as downloadStartCost, -- 应用下载广告数据-安卓下载开始成本  计算方法:总花费/安卓下载开始数。
-        sum(a.message) as message, -- 落地页转化数据-短信咨询  用户点击短信咨询的次数
-        <!-- sum(a.play_duration) as playDuration, --> --
-
-        case
-        when sum(a.show_material) != 0
-        then sum(a.valid_play)/sum(a.show_material)
-        else 0 end as validPlayRate, -- 视频数据-有效播放率  有效播放数/展示数
-
-        case
-        when sum(a.valid_play) != 0
-        then sum(a.average_play_time_per_play*a.valid_play)/sum(a.valid_play)
-        else 0 end as averagePlayTimePerPlay,         -- 视频数据-平均单次播放时长
-
-        case
-        when sum(a.convert_material) != 0
-        then sum(a.cost)/sum(a.convert_material)
-        else 0 end as convertCost, --  转化数据-转化成本=总花费/转化数
-        <!--  sum(a.convert_show_rate) as convert_show_rate, --> --
-
-        case
-        when sum(a.install_finish) != 0
-        then sum(a.cost)/sum(a.install_finish)
-        else 0 end as installFinishCost, --  应用下载广告数据-安卓安装完成成本  计算方式:总花费/安卓安装完成数
-
-        case
-        when sum(a.click) != 0
-        then sum(a.download_start)/sum(a.click)
-        else 0 end as downloadStartRate, --  应用下载广告数据-安卓下载开始率  计算方法:安卓下载开始数/点击数
-
-        #{companyId} as companyId
-        from ctop_bytedance_report_material_daily a
-        left join ctop_user_allocation b on a.account_id = b.account_id
-        left join user_company c on b.user_id = c.user_id
-        left join ctop_bytedance_video_info d on a.material_id = d.material_id
-        left join (select code,url,material_name from ctop_material_info group by code) e on d.signature = e.code
-        where c.company_id = #{companyId}      -- '6608ed13c0dd42de93c790dbdf124234'
-        and a.image_mode in ('CREATIVE_IMAGE_MODE_VIDEO',
-        'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL')
-        and date_format(stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
-        and date_format(stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
-        group by `statDatetime`,`signature`
-        order by `statDatetime`,`projectId`,`signature`
-    </select>
-
     <select id="getVideoReportDailyByDateAndSignature" resultType="java.math.BigDecimal">
         select
         sum(cost)
@@ -244,7 +10,12 @@
         where
         stat_datetime &gt;= #{startDate} and
         stat_datetime &lt;= #{endDate} and
-        company_id = #{companyId} and
+        <if test="accountIds != null">
+        account_id in
+            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
+                #{item}
+            </foreach> and
+        </if>
         signature = #{signature}
     </select>
 
@@ -258,9 +29,6 @@
     </update>
 
     <sql id="selectSql">
-        --         a.account_id as accountId,
-        --         b.auth_name as authName,
         a.project_id                             as projectId,
         a.project_name                           as projectName,
         a.advertiser_id                          as advertiserId,
@@ -459,244 +227,9 @@
         case
         when sum(a.click) != 0
         then sum(a.download_start) / sum(a.click)
-        else 0 end                           as downloadStartRate,               --  应用下载广告数据-安卓下载开始率  计算方法:安卓下载开始数/点击数
-        a.huanbi as huanbi
+        else 0 end                           as downloadStartRate               --  应用下载广告数据-安卓下载开始率  计算方法:安卓下载开始数/点击数
     </sql>
 
-    <select id="videoInfoListGroupAdmin" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
-        <include refid="selectSql"></include>
-        from ctop_bytedance_video_report_daily a
-        left join (select material_id,clip_id,shot_id,plan_id,plane_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
-        -- left join ctop_bytedance_account_video_map p on a.signature = p.signature
-        where stat_datetime &gt;= #{startDate}
-        and stat_datetime &lt;= #{endDate}
-        and f.material_id is not null
-        <!-- <if test="accountIds != null">
-             and p.account_id in
-                 <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
-                     #{item}
-                 </foreach>
-         </if>-->
-
-        <if test="accountIds != null">
-            and f.material_id in
-            (select signature from ctop_bytedance_account_video_map
-            where account_id in
-            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-            group by signature
-            )
-        </if>
-
-        <if test="signature != null and signature != '' ">
-            and a.signature = #{signature}
-        </if>
-        group by a.signature
-        <if test="cost != null">
-            having sum(a.cost) &gt;= #{cost}
-        </if>
-        order by sum(a.cost)
-    </select>
-
-    <select id="videoInfoListGroupdesignTeamLeader" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
-        <include refid="selectSql"></include>
-        from ctop_bytedance_video_report_daily a
-        left join (select material_id,clip_id,shot_id,plan_id,plane_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
-        -- left join ctop_bytedance_account_video_map p on a.signature = p.signature
-        where stat_datetime &gt;= #{startDate}
-        and stat_datetime &lt;= #{endDate}
-        and a.company_id = #{companyId}
-        and f.material_id is not null
-        <!--        and f.material_id is not null-->
-        <!--        <if test="accountIds != null">-->
-        <!--            and p.account_id in-->
-        <!--                <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">-->
-        <!--                    #{item}-->
-        <!--                </foreach>-->
-        <!--        </if>-->
-        <if test="accountIds != null">
-            and f.material_id in
-            (select signature from ctop_bytedance_account_video_map
-            where account_id in
-            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-            group by signature
-            )
-        </if>
-
-        <if test="signature != null and signature != '' ">
-            and a.signature = #{signature}
-        </if>
-        group by a.signature
-        <if test="cost != null">
-            having sum(a.cost) &gt;= #{cost}
-        </if>
-        order by sum(a.cost)
-    </select>
-
-    <select id="videoInfoListGroupPlaneAndPlaneLeader" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
-        <include refid="selectSql"></include>
-        from ctop_bytedance_video_report_daily a
-        left join (select material_id,clip_id,shot_id,plan_id,plane_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
-        -- left join ctop_bytedance_account_video_map p on a.signature = p.signature
-        where stat_datetime &gt;= #{startDate}
-        and stat_datetime &lt;= #{endDate}
-        and a.company_id = #{companyId}
-        and f.material_id is not null
-        and f.plane_id = #{userId}
-        <if test="accountIds != null">
-            and f.material_id in
-            (select signature from ctop_bytedance_account_video_map
-            where account_id in
-            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-            group by signature
-            )
-        </if>
-        <if test="signature != null and signature != '' ">
-            and a.signature = #{signature}
-        </if>
-        group by a.signature
-        <if test="cost != null">
-            having sum(a.cost) &gt;= #{cost}
-        </if>
-        order by sum(a.cost)
-    </select>
-
-    <select id="videoInfoListGroupPlan" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
-        <include refid="selectSql"></include>
-        from ctop_bytedance_video_report_daily a
-        left join (select material_id,clip_id,shot_id,plan_id,plane_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
-        -- left join ctop_bytedance_account_video_map p on a.signature = p.signature
-        where stat_datetime &gt;= #{startDate}
-        and stat_datetime &lt;= #{endDate}
-        and a.company_id = #{companyId}
-        and f.material_id is not null
-        and f.plan_id = #{userId}
-        <if test="accountIds != null">
-            and f.material_id in
-            (select signature from ctop_bytedance_account_video_map
-            where account_id in
-            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-            group by signature
-            )
-        </if>
-        <if test="signature != null and signature != '' ">
-            and a.signature = #{signature}
-        </if>
-        group by a.signature
-        <if test="cost != null">
-            having sum(a.cost) &gt;= #{cost}
-        </if>
-        order by sum(a.cost)
-    </select>
-
-    <select id="videoInfoListGroupClip" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
-        <include refid="selectSql"></include>
-        from ctop_bytedance_video_report_daily a
-        left join (select material_id,clip_id,shot_id,plan_id,plane_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
-        -- left join ctop_bytedance_account_video_map p on a.signature = p.signature
-        where stat_datetime &gt;= #{startDate}
-        and stat_datetime &lt;= #{endDate}
-        and a.company_id = #{companyId}
-        and f.material_id is not null
-        and f.clip_id = #{userId}
-        <if test="accountIds != null">
-            and f.material_id in
-            (select signature from ctop_bytedance_account_video_map
-            where account_id in
-            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-            group by signature
-            )
-        </if>
-        <if test="signature != null and signature != '' ">
-            and a.signature = #{signature}
-        </if>
-        group by a.signature
-        <if test="cost != null">
-            having sum(a.cost) &gt;= #{cost}
-        </if>
-        order by sum(a.cost)
-    </select>
-
-    <select id="videoInfoListGroupShot" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
-        <include refid="selectSql"></include>
-        from ctop_bytedance_video_report_daily a
-        left join (select material_id,clip_id,shot_id,plan_id,plane_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
-        -- left join ctop_bytedance_account_video_map p on a.signature = p.signature
-        where stat_datetime &gt;= #{startDate}
-        and stat_datetime &lt;= #{endDate}
-        and a.company_id = #{companyId}
-        and f.material_id is not null
-        and f.shot_id = #{userId}
-        <if test="accountIds != null">
-            and f.material_id in
-            (select signature from ctop_bytedance_account_video_map
-            where account_id in
-            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-            group by signature
-            )
-        </if>
-        <if test="signature != null and signature != '' ">
-            and a.signature = #{signature}
-        </if>
-        group by a.signature
-        <if test="cost != null">
-            having sum(a.cost) &gt;= #{cost}
-        </if>
-        order by sum(a.cost)
-    </select>
-
-    <select id="videoInfoListGroupOperator" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
-        <include refid="selectSql"></include>
-        from ctop_bytedance_video_report_daily a
-        left join (select material_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
-        -- left join ctop_bytedance_account_video_map p on a.signature = p.signature
-        where stat_datetime &gt;= #{startDate}
-        and stat_datetime &lt;= #{endDate}
-        and f.material_id is not null
-        <!--        and p.account_id in-->
-        <!--        <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">-->
-        <!--            #{item}-->
-        <!--        </foreach>-->
-
-        <if test="accountIds != null">
-            and f.material_id in
-            (select signature from ctop_bytedance_account_video_map
-            where account_id in
-            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
-                #{item}
-            </foreach>
-            group by signature
-            )
-        </if>
-
-        <if test="signature != null and signature != '' ">
-            and a.signature = #{signature}
-        </if>
-        group by a.signature
-        <if test="cost != null">
-            having sum(a.cost) &gt;= #{cost}
-        </if>
-        order by sum(a.cost)
-    </select>
-
     <select id="getRoleCodeByUserId" resultType="string">
         select
         role_code
@@ -754,27 +287,90 @@
     </update>
 
     <select id="videoInfoListDetail" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+                select
+                a.account_id as accountId,
+                a.advertiser_id as advertiserId,
+                a.advertiser_name as advertiserName,
+                a.stat_datetime as statDatetime,
+                sum(a.cost) as cost,  -- 消耗
+                a.video_url as videoUrl,
+                (select info.url from ctop_material_info info where info.code = a.signature limit 1) as url,
+                -- huanbi as huanbi,
+                signature as signature
+
+        from ctop_bytedance_video_report_daily a
+        left join (select material_id,clip_id,shot_id,plan_id,plane_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
+        where
+        stat_datetime &gt;= #{startDate}
+        and stat_datetime &lt;= #{endDate}
+<!--        <if test=" role != 'admin' ">
+            and a.company_id = #{companyId}
+        </if>-->
+        <if test="accountIds != null">
+            and a.account_id in
+            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        and f.material_id = #{signature}
+        group by stat_datetime
+        order by stat_datetime desc
+    </select>
+
+    <select id="videoInfoListDetailOperator" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
-        --  a.project_id as projectId,
-        --  a.project_name as projectName,
+        a.account_id as accountId,
         a.advertiser_id as advertiserId,
         a.advertiser_name as advertiserName,
         a.stat_datetime as statDatetime,
-        a.cost as cost,  -- 消耗
-        -- a.signature as signature,
+        sum(a.cost) as cost,  -- 消耗
         a.video_url as videoUrl,
         (select info.url from ctop_material_info info where info.code = a.signature limit 1) as url,
-        huanbi as huanbi
+        -- huanbi as huanbi,
+        signature as signature
 
         from ctop_bytedance_video_report_daily a
         left join (select material_id,clip_id,shot_id,plan_id,plane_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
         where
         stat_datetime &gt;= #{startDate}
         and stat_datetime &lt;= #{endDate}
-        <if test=" role != 'admin' ">
-            and a.company_id = #{companyId}
+        and a.company_id = #{companyId}
+        and a.account_id in
+            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+
+        and f.material_id = #{signature}
+        group by stat_datetime
+        order by stat_datetime desc
+    </select>
+
+    <select id="videoInfoListDetailDesign" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+        select
+        a.account_id as accountId,
+        a.advertiser_id as advertiserId,
+        a.advertiser_name as advertiserName,
+        a.stat_datetime as statDatetime,
+        sum(a.cost) as cost,  -- 消耗
+        a.video_url as videoUrl,
+        (select info.url from ctop_material_info info where info.code = a.signature limit 1) as url,
+        -- huanbi as huanbi,
+        signature as signature
+
+        from ctop_bytedance_video_report_daily a
+        left join (select material_id,clip_id,shot_id,plan_id,plane_id from ctop_material_ascription group by material_id) f on a.signature = f.material_id
+        where
+        stat_datetime &gt;= #{startDate}
+        and stat_datetime &lt;= #{endDate}
+        and a.company_id = #{companyId}
+        <if test="accountIds != null">
+            and a.account_id in
+            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
         </if>
         and f.material_id = #{signature}
+        group by stat_datetime
         order by stat_datetime desc
     </select>
 
@@ -793,19 +389,18 @@
         replace into
         ctop_bytedance_account_video_map
         (
-        account_id,
-        signature
+            account_id,
+            signature
         )
         values
         <foreach collection="accountVideoDTOList" item="accountVideo" separator=",">
-            (
+        (
             #{accountVideo.accountId},
             #{accountVideo.signature}
-            )
+        )
         </foreach>
     </insert>
 
-
     <select id="getAccountIdByprojectIds" resultType="long">
         select
         account_id
@@ -830,12 +425,8 @@
         and media_id = #{mediaId}
     </select>
 
-
-    <select id="videoInfoList2" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoList" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
-        --  a.material_id as materialId,
-        --         a.account_id as accountId,
-        --         b.auth_name as authName,
         a.account_id as accountId,
         b.project_id as projectId,
         b.project_name as projectName,
@@ -846,7 +437,6 @@
         d.signature as signature,
         d.video_url as videoUrl,
         e.url as url,
-        <!-- e.material_name as materialName,  -->
         '-' as materialDesc,
         1 as appType,
         sum(a.click) as click,   -- 点击数
@@ -893,7 +483,6 @@
         sum(a.total_play) as totalPlay, -- 视频-总播放
         sum(a.valid_play) as validPlay, -- 视频-有效播放
         sum(a.wifi_play) as wifiPlay, -- 视频-wifi播放
-        <!-- sum(a.play_duration_sum) as play_duration_sum, --> -- 视频-播放时长,单位ms
         sum(a.play25_feed_break) as play25FeedBreak, -- 视频-播放25%进度总数
         sum(a.play50_feed_break) as play50FeedBreak, -- 视频-播放50%进度总数
         sum(a.play75_feed_break) as play75FeedBreak, -- 视频-播放75%进度总数
@@ -923,7 +512,6 @@
         else 0 end
         as activePayCost, -- 应用下载广告数据-付费成本 = 消耗/付费次数
 
-
         sum(a.active_pay_amount) as activePayAmount, -- 应用下载广告数据-付费次数
 
         case
@@ -938,13 +526,12 @@
         then sum(a.cost)/sum(a.active_pay_amount)
         else 0 end as activePayCost, -- 应用下载广告数据-付费成本 = 消耗/付费次数
         sum(a.download) as download, -- 落地页转化数据-下载开始
-        <!--sum(a.cpa) as cpa, -->--
+
         case
         when sum(a.click) != 0
         then sum(a.cost) / sum(a.click)
         else 0 end                           as cpc,                            -- 平均点击单价
         sum(a.location_click) as locationClick, -- 互动数据-POI点击数
-        --  sum(a.play_over_rate) as playOverRate, -- 视频数据-播完率
 
         case
         when sum(a.show_material) != 0
@@ -957,7 +544,6 @@
         else 0 end cpm, -- 平均千次展现费用  广告平均每一千次展现所付出的费用,计算公式是:总花费/展示数*1000。
         sum(a.wifi_play_rate) as wifiPlayRate, -- 视频数据-WiFi播放占比
         sum(a.like_material) as likeMaterial, -- 互动数据-点赞数
-        <!--  sum(a.active_pay_rate) as activePayRate,--> -- 应用下载广告数据-付费率
 
         case
         when sum(a.active) != 0
@@ -974,8 +560,6 @@
         when sum(a.click) != 0
         then sum(a.active)/sum(a.click)
         else 0 end as activeRate, -- 应用下载广告数据-激活率   计算方式:激活数/点击数*100%
-        <!-- sum(a.play_duration_10s) as playDuration10s,--> --
-        <!-- sum(a.phone_effective) as phone_effective,--> --
 
         case
         when sum(a.active) != 0
@@ -986,13 +570,13 @@
         when sum(a.active) != 0
         then sum(a.register)/sum(a.active)
         else 0 end as activeRegisterRate, -- 应用下载广告数据-注册率   注册用户占激活用户的比例
-        <!-- sum(a.average_video_play) as averageVideoPlay,--> --
+
 
         case
         when sum(a.download_finish) != 0
         then sum(a.cost)/sum(a.download_finish)
         else 0 end as downloadFinishCost, -- 应用下载广告数据-安卓下载完成成本 计算方式:总花费/安卓下载完成数。
-        <!--sum(a.play_duration_3s) as playDuration3s,--> --
+
 
         case
         when sum(a.register) != 0
@@ -1000,11 +584,6 @@
         else 0 end as activeRegisterCost, -- 应用下载广告数据-注册成本  总花费/注册数,当天数据可能会有波动,次日早8点后稳定。
         sum(a.show_material) as showMaterial, -- 展现数据-展示数
 
-        <!--  case
-        when sum(a.click) != 0
-        then sum(a.convert_material)/sum(a.click)
-        else 0 end as convertRate,  转化数据-转化率  计算方式:转化数/点击数*100%  -->
-
         case
         when sum(a.download_start) != 0
         then sum(a.download_finish)/sum(a.download_start)
@@ -1062,10 +641,10 @@
         'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL')
         and date_format(stat_datetime,'%Y-%m-%d') &gt;= #{startDate}
         and date_format(stat_datetime,'%Y-%m-%d') &lt;= #{endDate}
-        group by `statDatetime`,`account_id`,`signature`
+        group by `statDatetime`,`accountId`,`signature`
     </select>
 
-    <select id="videoInfoListGroupOperator2" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupOperator" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -1074,9 +653,9 @@
         and stat_datetime &lt;= #{endDate}
         and f.material_id is not null
         and a.account_id in
-        <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
-            #{item}
-        </foreach>
+            <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
+                #{item}
+            </foreach>
         <if test="signature != null and signature != '' ">
             and a.signature = #{signature}
         </if>
@@ -1084,10 +663,10 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
     </select>
 
-    <select id="videoInfoListGroupShot2" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupShot" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -1110,10 +689,10 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
     </select>
 
-    <select id="videoInfoListGroupAdmin2" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupAdmin" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -1135,10 +714,9 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
     </select>
 
-    <select id="videoInfoListGroupdesignTeamLeader2" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupdesignTeamLeader" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -1161,10 +739,10 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
     </select>
 
-    <select id="videoInfoListGroupPlaneAndPlaneLeader2" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupPlaneAndPlaneLeader" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -1187,10 +765,10 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
     </select>
 
-    <select id="videoInfoListGroupPlan2" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupPlan" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -1213,10 +791,10 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
     </select>
 
-    <select id="videoInfoListGroupClip2" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupClip" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -1239,7 +817,17 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
+    </select>
+
+    <select id="getAccountIds" resultType="long">
+        select
+        account_id
+        from
+        ctop_bytedance_video_report_daily
+        where
+        signature = #{signature}
+        and company_id = #{companyId}
     </select>
 
 </mapper>

+ 6 - 6
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IByteDanceVideoReportDailyService.java

@@ -17,15 +17,15 @@ public interface IByteDanceVideoReportDailyService extends IService<ByteDanceVid
 
     void videoInfoList(String startDate, String endDate);
 
-    PageInfo<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds);
+    PageInfo<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort);
 
-    PageInfo<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds);
+    PageInfo<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort);
 
-    List<ByteDanceVideoReportDaily> videoInfoListTotalExcel(String startDate, String endDate, String signature, BigDecimal cost);
+    List<ByteDanceVideoReportDaily> videoInfoListTotalExcel(String startDate, String endDate, String signature, BigDecimal cost, Long[] accountIds, String sort);
 
-    PageInfo<ByteDanceVideoReportDaily> videoInfoListMonth(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds);
+    PageInfo<ByteDanceVideoReportDaily> videoInfoListMonth(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds,String sort);
 
-    List<ByteDanceVideoReportDaily> videoInfoListDetail(String startDate, String endDate, String signature);
+    List<ByteDanceVideoReportDaily> videoInfoListDetail(String startDate, String endDate, String signature, Long[] accountIds);
 
     String getColumnJson(Integer columnType);
 
@@ -34,7 +34,7 @@ public interface IByteDanceVideoReportDailyService extends IService<ByteDanceVid
     //excel导出权限
     int videoInfoListTotalExportExcelPermission();
 
-    PageInfo<ByteDanceVideoReportDaily> videoInfoListDaily(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds);
+    PageInfo<ByteDanceVideoReportDaily> videoInfoListDaily(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort);
 
     void accountVideoMap();
 

+ 265 - 398
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ByteDanceVideoReportDailyServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import org.apache.commons.lang.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
@@ -55,134 +56,84 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
 
         //QueryWrapper<ByteDanceVideoReportDaily> queryWrapper = new QueryWrapper<>();
 
-        List<ByteDanceVideoReportDaily> mList2 = byteDanceVideoReportDailyMapper.selectList(wrapper);
-
-        for(ByteDanceVideoReportDaily m:mList2){
-            String statDate  = DateUtils.formatDate(DateUtils.addDay(m.getStatDatetime(),-1));
-            BigDecimal cost = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(statDate,statDate,m.getSignature(),companyId);
-
-            BigDecimal huanbi =BigDecimal.ZERO;
-            if(cost != null && cost.compareTo(BigDecimal.ZERO)>0){
-                huanbi = m.getCost().subtract(cost).divide(cost,7, BigDecimal.ROUND_HALF_UP);
-            }
-
-            m.setHuanbi(huanbi);
-            byteDanceVideoReportDailyMapper.updateById(m);
-        }
+        //List<ByteDanceVideoReportDaily> mList2 = byteDanceVideoReportDailyMapper.selectList(wrapper);
+        //
+        //for(ByteDanceVideoReportDaily m:mList2){
+        //    String statDate  = DateUtils.formatDate(DateUtils.addDay(m.getStatDatetime(),-1));
+        //    BigDecimal cost = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(statDate,statDate,m.getSignature(),companyId);
+        //
+        //    BigDecimal huanbi =BigDecimal.ZERO;
+        //    if(cost != null && cost.compareTo(BigDecimal.ZERO)>0){
+        //        huanbi = m.getCost().subtract(cost).divide(cost,7, BigDecimal.ROUND_HALF_UP);
+        //    }
+        //
+        //    m.setHuanbi(huanbi);
+        //    byteDanceVideoReportDailyMapper.updateById(m);
+        //}
     }
 
     //视频按天列表
-    public PageInfo<ByteDanceVideoReportDaily> videoInfoListDaily(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds){
+    public PageInfo<ByteDanceVideoReportDaily> videoInfoListDaily(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
         String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
 
+        if(StringUtils.isBlank(sort)){
+            sort = "cost-";
+        }
+        sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
+        sort = sort.substring(0, sort.length() - 1);
         List<ByteDanceVideoReportDaily> mList = new ArrayList<>();
+
+        List<Long> accountIdsList = null;
+        if(accountIds != null && accountIds.length != 0){
+            accountIdsList = Arrays.asList(accountIds);
+        }
         //admin能看所有视频
         if(roleCode.equals("admin")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                PageHelper.startPage(pageNo,pageSize);
+            if (accountIdsList != null && accountIdsList.size() != 0){
+                PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(1,userId);
-                PageHelper.startPage(pageNo,pageSize);
+                PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
             }
         }else if(roleCode.equals("shot")){
-            //设计师传入projectIds,根据projectIds解析出accountIdsList
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size() != 0){
-                    if(accountIdsList.size()==0 || accountIdsList == null){
-                        accountIdsList.add(-1L);
-                    }
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("plan")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("plane")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("clip")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("designTeamLeader")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, null, signature, cost);
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
+        }
+
+        //计算环比
+        for(ByteDanceVideoReportDaily m:mList){
+            Integer datediff = DateUtils.dateDiff(startDate, endDate);
+            String startMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-(datediff + 1) ) );
+            String endMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-1));
+
+            BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(startMonthDate,endMonthDate,m.getSignature(),accountIdsList);
+
+            BigDecimal huanbi =BigDecimal.ZERO;
+            if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
+                huanbi = m.getCost().subtract(costBefore).divide(costBefore,7, BigDecimal.ROUND_HALF_UP);
             }
+
+            m.setHuanbi(huanbi);
         }
 
         PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
@@ -191,131 +142,60 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
 
 
     //视频报表月列表
-    public PageInfo<ByteDanceVideoReportDaily> videoInfoListMonth(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds){
+    public PageInfo<ByteDanceVideoReportDaily> videoInfoListMonth(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
         String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
 
+        if(StringUtils.isBlank(sort)){
+            sort = "cost-";
+        }
+        sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
+        sort = sort.substring(0, sort.length() - 1);
         List<ByteDanceVideoReportDaily> mList = new ArrayList<>();
+
+        List<Long> accountIdsList = null;
+        if(accountIds != null && accountIds.length != 0){
+            accountIdsList = Arrays.asList(accountIds);
+        }
         //admin能看所有视频
         if(roleCode.equals("admin")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                PageHelper.startPage(pageNo,pageSize);
+            if (accountIdsList != null && accountIdsList.size() != 0){
+                PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(1,userId);
-                PageHelper.startPage(pageNo,pageSize);
+                PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
             }
         }else if(roleCode.equals("shot")){
-            //设计师传入projectIds,根据projectIds解析出accountIdsList
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size() != 0){
-                    if(accountIdsList.size()==0 || accountIdsList == null){
-                        accountIdsList.add(-1L);
-                    }
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("plan")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("plane")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("clip")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("designTeamLeader")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, null, signature, cost);
-            }
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
         }
 
         //计算环比
         for(ByteDanceVideoReportDaily m:mList){
-            String startMonthDate = null;
-            String endMonthDate = null;
-            try {
-                startMonthDate = DateUtils.addMonth( DateUtils.formatDate(DateUtils.addDay(m.getStatDatetime(),1)) , -1);
-                endMonthDate = DateUtils.formatDate(DateUtils.addDay(m.getStatDatetime(),-1));
-            } catch (ParseException e) {
-                e.printStackTrace();
-            }
+            Integer datediff = DateUtils.dateDiff(startDate, endDate);
+            String startMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-(datediff + 1) ) );
+            String endMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-1));
 
-            BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(startMonthDate,endMonthDate,m.getSignature(),companyId);
+            BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(startMonthDate,endMonthDate,m.getSignature(),accountIdsList);
 
             BigDecimal huanbi =BigDecimal.ZERO;
             if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
@@ -331,117 +211,67 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
 
 
     //视频总报表列表
-    public PageInfo<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost , Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds){
+    public PageInfo<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost , Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
         String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
 
+        if(StringUtils.isBlank(sort)){
+            sort = "cost-";
+        }
+        sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
+        sort = sort.substring(0, sort.length() - 1);
         List<ByteDanceVideoReportDaily> mList = new ArrayList<>();
+
+        List<Long> accountIdsList = null;
+        if(accountIds != null && accountIds.length != 0){
+            accountIdsList = Arrays.asList(accountIds);
+        }
         //admin能看所有视频
         if(roleCode.equals("admin")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                PageHelper.startPage(pageNo,pageSize);
+            if (accountIdsList != null && accountIdsList.size() != 0){
+                PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(1,userId);
-                PageHelper.startPage(pageNo,pageSize);
+                PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
             }
         }else if(roleCode.equals("shot")){
-            //设计师传入projectIds,根据projectIds解析出accountIdsList
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size() != 0){
-                    if(accountIdsList.size()==0 || accountIdsList == null){
-                        accountIdsList.add(-1L);
-                    }
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("plan")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("plane")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("clip")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("designTeamLeader")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, null, signature, cost);
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
+        }
+
+        //计算环比
+        for(ByteDanceVideoReportDaily m:mList){
+            Integer datediff = DateUtils.dateDiff(startDate, endDate);
+            String startMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-(datediff + 1) ) );
+            String endMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-1));
+
+            BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(startMonthDate,endMonthDate,m.getSignature(),accountIdsList);
+
+            BigDecimal huanbi =BigDecimal.ZERO;
+            if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
+                huanbi = m.getCost().subtract(costBefore).divide(costBefore,7, BigDecimal.ROUND_HALF_UP);
             }
+
+            m.setHuanbi(huanbi);
         }
 
         PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
@@ -449,139 +279,125 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
     }
 
     //视频总报表列表导出excel
-    public List<ByteDanceVideoReportDaily> videoInfoListTotalExcel(String startDate, String endDate, String signature, BigDecimal cost){
+    public List<ByteDanceVideoReportDaily> videoInfoListTotalExcel(String startDate, String endDate, String signature, BigDecimal cost , Long[] accountIds, String sort){
+        //LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        //String userId = sysUser.getId();
+        //String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
+        //String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
+        //
+        //List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoListWeek(startDate, endDate, roleCode, userId, signature, companyId, cost);
+
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
         String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
 
-        List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoListWeek(startDate, endDate, roleCode, userId, signature, companyId, cost);
+        if(StringUtils.isBlank(sort)){
+            sort = "cost-";
+        }
+        sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
+        sort = sort.substring(0, sort.length() - 1);
+        List<ByteDanceVideoReportDaily> mList = new ArrayList<>();
+
+        List<Long> accountIdsList = null;
+        if(accountIds != null && accountIds.length != 0){
+            accountIdsList = Arrays.asList(accountIds);
+        }
+        //admin能看所有视频
+        if(roleCode.equals("admin")){
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
+        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
+            if (accountIdsList != null && accountIdsList.size() != 0){
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
+            }else{
+                List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(1,userId);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
+            }
+        }else if(roleCode.equals("shot")){
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
+        }else if(roleCode.equals("plan")){
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
+        }else if(roleCode.equals("plane")){
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
+        }else if(roleCode.equals("clip")){
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
+        }else if(roleCode.equals("designTeamLeader")){
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
+        }
 
+        //计算环比
+        //for(ByteDanceVideoReportDaily m:mList){
+        //    Integer datediff = DateUtils.dateDiff(startDate, endDate);
+        //    String startMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-(datediff + 1) ) );
+        //    String endMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-1));
+        //
+        //    BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(startMonthDate,endMonthDate,m.getSignature(),accountIdsList);
+        //
+        //    BigDecimal huanbi =BigDecimal.ZERO;
+        //    if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
+        //        huanbi = m.getCost().subtract(costBefore).divide(costBefore,7, BigDecimal.ROUND_HALF_UP);
+        //    }
+        //
+        //    m.setHuanbi(huanbi);
+        //}
         return mList;
     }
 
     //视频报表周列表
-    public PageInfo<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds){
+    public PageInfo<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
         String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
 
+        if(StringUtils.isBlank(sort)){
+            sort = "cost-";
+        }
+        sort = sort.replace("-", " desc,").replace("+", " asc,");  //sort=id-name+age+
+        sort = sort.substring(0, sort.length() - 1);
         List<ByteDanceVideoReportDaily> mList = new ArrayList<>();
-        //PageHelper.startPage(pageNo,pageSize);
-        //mList = byteDanceVideoReportDailyMapper.videoInfoListWeek(startDate, endDate, roleCode, userId, signature, companyId, cost);
 
+        List<Long> accountIdsList = null;
+        if(accountIds != null && accountIds.length != 0){
+            accountIdsList = Arrays.asList(accountIds);
+        }
         //admin能看所有视频
         if(roleCode.equals("admin")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
         }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                PageHelper.startPage(pageNo,pageSize);
+            if (accountIdsList != null && accountIdsList.size() != 0){
+                PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(1,userId);
-                PageHelper.startPage(pageNo,pageSize);
+                PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
             }
         }else if(roleCode.equals("shot")){
-            //设计师传入projectIds,根据projectIds解析出accountIdsList
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size() != 0){
-                    if(accountIdsList.size()==0 || accountIdsList == null){
-                        accountIdsList.add(-1L);
-                    }
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("plan")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("plane")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("clip")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
         }else if(roleCode.equals("designTeamLeader")){
-            if (projectIds != null && projectIds.length != 0){
-                List<Long> projectIdsList = Arrays.asList(projectIds);
-                List<Long> accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdByprojectIds(projectIdsList);
-                if(accountIdsList.size()==0 || accountIdsList == null){
-                    accountIdsList.add(-1L);
-                }
-                if(accountIdsList.size() != 0){
-                    PageHelper.startPage(pageNo,pageSize);
-                    mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
-                }
-            }else{
-                PageHelper.startPage(pageNo,pageSize);
-                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, null, signature, cost);
-            }
+            PageHelper.startPage(pageNo,pageSize,sort);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
         }
 
         //计算环比
         for(ByteDanceVideoReportDaily m:mList){
-            String startWeekDate  = DateUtils.formatDate(DateUtils.addDay(DateUtils.getDate(startDate),-1));
-            String endWeekDate = DateUtils.formatDate(DateUtils.addDay(startDate,-7));
-            BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(startWeekDate,endWeekDate,m.getSignature(),companyId);
+            Integer datediff = DateUtils.dateDiff(startDate, endDate);
+            String startMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-(datediff + 1) ) );
+            String endMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-1));
+
+            BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(startMonthDate,endMonthDate,m.getSignature(),accountIdsList);
 
             BigDecimal huanbi =BigDecimal.ZERO;
             if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
@@ -596,13 +412,64 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         return pageInfo;
     }
 
-    public List<ByteDanceVideoReportDaily> videoInfoListDetail(String startDate, String endDate, String signature){
+    public List<ByteDanceVideoReportDaily> videoInfoListDetail(String startDate, String endDate, String signature, Long[] accountIds){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
         String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
 
-        return byteDanceVideoReportDailyMapper.videoInfoListDetail(companyId, startDate, endDate, signature, roleCode);
+        //List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoListDetail(companyId, startDate, endDate, signature, roleCode);
+        List<ByteDanceVideoReportDaily> mList =new ArrayList<>();
+
+        List<Long> accountIdsList = null;
+        if(accountIds != null && accountIds.length != 0){
+            accountIdsList = Arrays.asList(accountIds);
+        }
+        //admin能看所有视频
+        if(roleCode.equals("admin")){
+            mList = byteDanceVideoReportDailyMapper.videoInfoListDetail(companyId, startDate, endDate, signature, accountIdsList);
+        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
+            if (accountIdsList != null && accountIdsList.size() != 0){
+                mList = byteDanceVideoReportDailyMapper.videoInfoListDetailOperator(companyId, startDate,endDate,signature, accountIdsList);
+            }else{
+                accountIdsList= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(1,userId);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListDetailOperator(companyId, startDate,endDate,signature, accountIdsList);
+            }
+        }else if(roleCode.equals("shot")){
+            accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
+        }else if(roleCode.equals("plan")){
+            accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
+        }else if(roleCode.equals("plane")){
+            accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
+        }else if(roleCode.equals("clip")){
+            accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
+        }else if(roleCode.equals("designTeamLeader")){
+            accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
+            mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
+        }
+
+        //计算环比
+        for(ByteDanceVideoReportDaily m:mList){
+            //Integer datediff = DateUtils.dateDiff(startDate, endDate);
+            //String startMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-(datediff + 1) ) );
+            String beforeDate = DateUtils.formatDate(DateUtils.addDay(m.getStatDatetime(),-1));
+            //List<Long> accountIdsList = new ArrayList<>();
+            //accountIdsList.add(m.getAccountId());
+            BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(beforeDate,beforeDate,m.getSignature(),accountIdsList);
+
+            BigDecimal huanbi =BigDecimal.ZERO;
+            if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
+                huanbi = m.getCost().subtract(costBefore).divide(costBefore,7, BigDecimal.ROUND_HALF_UP);
+            }
+
+            m.setHuanbi(huanbi);
+        }
+
+        return mList;
     }
 
     public String getColumnJson(Integer columnType){