Browse Source

Merge branches 'master' and 'video-dev' of http://39.106.184.70:3000/ctop/adsp-boot

hcst_sunzhen 5 years ago
parent
commit
a227bc58ce
14 changed files with 687 additions and 39 deletions
  1. 28 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectMemberController.java
  2. 13 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/ProjectMemberMapper.java
  3. 92 1
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/ProjectMemberMapper.xml
  4. 2 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/IProjectMemberService.java
  5. 26 0
      jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ProjectMemberServiceImpl.java
  6. 12 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/AccountVideoDTO.java
  7. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/DTO/DateDTO.java
  8. 17 7
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/ByteDanceVideoReportDailyController.java
  9. 13 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java
  10. 23 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/ByteDanceVideoReportDailyMapper.java
  11. 176 25
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/ByteDanceVideoReportDailyMapper.xml
  12. 218 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMapper.xml
  13. 5 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/IByteDanceVideoReportDailyService.java
  14. 60 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ByteDanceVideoReportDailyServiceImpl.java

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

@@ -10,9 +10,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
@@ -318,4 +320,30 @@ public class ProjectMemberController {
         }
         return result;
     }
+
+    /**
+     * 我参与项目
+     *
+     * @return
+     */
+    @AutoLog(value = "头条视频报表-参与项目列表")
+    @ApiOperation(value = "头条视频报表-参与项目列表", notes = "头条视频报表-参与项目列表")
+    @GetMapping(value = "/bytedanceProjectParticipateInList")
+    public  Result<List<ProjectMember>> bytedanceProjectParticipateInList() {
+        Result<List<ProjectMember>> result = new Result<>();
+        Integer mediaId = 1;
+        List<ProjectMember> projectMemberList = projectMemberService.getProjects(mediaId);
+        if (projectMemberList == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(projectMemberList);
+            result.setSuccess(true);
+        }
+        return result;
+
+    }
+
+
+
+
 }

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

@@ -16,4 +16,17 @@ import java.util.List;
 public interface ProjectMemberMapper extends BaseMapper<ProjectMember> {
 
     List<Long> selectProjectsByUserId(@Param("userId") String userId);
+
+    List<ProjectMember> adminProjects(@Param("mediaId")Integer mediaId);
+
+    List<ProjectMember> designLeaderProjects(@Param("companyId")String companyId ,@Param("mediaId")Integer mediaId);
+
+    List<ProjectMember> designProjects(@Param("userId")String userId, @Param("mediaId")Integer mediaId);
+
+    List<ProjectMember> operationProjects(@Param("userId")String userId, @Param("mediaId")Integer mediaId);
+
+    String getRoleCodeByUserId(@Param("userId")String userId);
+
+    String getCompanyIdByUserId(@Param("userId")String userId);
+
 }

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

@@ -9,4 +9,95 @@
         where user_id = #{userId}
     </select>
 
-</mapper>
+    <!-- 设计师展示所有自己的角色下制作的视频 -->
+    <select id="adminProjects" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
+        select
+        project_id,
+        project_name,
+        advertiser_id,
+        advertiser_name,
+        media_id,
+        maxBid,
+        advertiser_name,
+        responsible_name
+        from
+        ctop_project
+        where
+        media_id = #{mediaId}
+    </select>
+
+    <!-- 视频报表设计师leader展示自己所在公司的所有项目 -->
+    <select id="designLeaderProjects" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
+        select
+        b.project_id,
+        b.project_name,
+        b.advertiser_id,
+        b.advertiser_name,
+        b.media_id,
+        b.maxBid,
+        b.advertiser_name,
+        b.responsible_name
+        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}
+    </select>
+
+    <!-- 设计师展示所有自己的角色下制作的视频 -->
+    <select id="designProjects" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
+        select
+        b.project_id,
+        b.project_name,
+        b.advertiser_id,
+        b.advertiser_name,
+        b.media_id,
+        b.maxBid,
+        b.advertiser_name,
+        b.responsible_name
+        from
+        ctop_project_member a
+        left join ctop_project b on a.project_id = b.id
+        where user_id = #{userId}
+        and b.media_id = #{mediaId}
+        group by a.project_id
+    </select>
+
+    <!-- 运营和运营负责人展示所在项目视频 -->
+    <select id="operationProjects" resultType="org.jeecg.modules.ctop.entity.ProjectMember">
+        select
+        b.project_id,
+        b.project_name,
+        b.advertiser_id,
+        b.advertiser_name,
+        b.media_id,
+        b.maxBid,
+        b.advertiser_name,
+        b.responsible_name
+        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
+    </select>
+
+    <select id="getRoleCodeByUserId" resultType="string">
+        select
+        role_code
+        from
+        sys_user_role a
+        left join sys_role b on a.role_id = b.id
+        where a.user_id = #{userId}
+    </select>
+
+    <select id="getCompanyIdByUserId" resultType="string">
+            select
+            company_id
+        from
+        user_company
+        where user_id = #{userId}
+    </select>
+
+</mapper>

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

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

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

@@ -3,6 +3,8 @@ package org.jeecg.modules.ctop.service.impl;
 import cn.com.ctop.common.module.service.ISysRoleService;
 import cn.com.ctop.common.module.utils.Check;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.modules.ctop.entity.Project;
 import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.ctop.mapper.ProjectMemberMapper;
@@ -59,4 +61,28 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
         return memberMapper.selectProjectsByUserId(userId);
     }
 
+    //视频报表
+    public List<ProjectMember> getProjects(Integer mediaId){
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = sysUser.getId();
+        String roleCode = memberMapper.getRoleCodeByUserId(userId);
+        String companyId = memberMapper.getCompanyIdByUserId(userId);
+
+        //角色权限判断
+        List<ProjectMember> projectMemberList = null;
+        if(roleCode.equals("plan") || roleCode.equals("plane") || roleCode.equals("shot") || roleCode.equals("plane")|| roleCode.equals("planeLeadert")){
+            projectMemberList = memberMapper.designProjects(userId, mediaId);
+        }else if( roleCode.equals("designTeamLeader")){
+            projectMemberList = memberMapper.designLeaderProjects(companyId, mediaId);
+        }else if(roleCode.equals("admin")){
+            projectMemberList = memberMapper.adminProjects(mediaId);
+        }else if(roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")){
+            projectMemberList = memberMapper.operationProjects(userId, mediaId);
+        }
+
+        return projectMemberList;
+    }
+
+
+
 }

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

@@ -0,0 +1,12 @@
+package cn.com.ctop.toutiao.modules.report.DTO;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+
+@Data
+public class AccountVideoDTO implements Serializable {
+    private Long accountId;
+    private String signature;
+}

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

@@ -14,4 +14,6 @@ public class DateDTO extends PageDTO implements Serializable {
     private String date;
     private BigDecimal cost;
     private String[] columns;
+    private Long[] projectIds;
+    private Long[] accountIds;
 }

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

@@ -6,6 +6,7 @@ import cn.com.ctop.toutiao.modules.report.DTO.ColumnDTO;
 import cn.com.ctop.toutiao.modules.report.DTO.DateDTO;
 import cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
+import com.github.pagehelper.PageInfo;
 import io.micrometer.core.instrument.util.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -95,11 +96,20 @@ public class ByteDanceVideoReportDailyController {
 	 @AutoLog(value = "头条视频按周汇总")
 	 @ApiOperation(value = "头条视频按周汇总", notes = "头条视频按周汇总")
 	 @PostMapping(value = "/bytedanceVideoInfoListWeek")
-	 public Result<List<ByteDanceVideoReportDaily>> bytedanceVideoInfoListWeek(@RequestBody DateDTO dateDTO,
+	 public Result<PageInfo<ByteDanceVideoReportDaily>> bytedanceVideoInfoListWeek(@RequestBody DateDTO dateDTO,
 																		   HttpServletRequest req){
-		 Result<List<ByteDanceVideoReportDaily>> result = new Result();
+		 Result<PageInfo<ByteDanceVideoReportDaily>> result = new Result();
 
-		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListWeek(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost());
+		 Integer pageNo = dateDTO.getPageNo();
+		 Integer pageSize = dateDTO.getPageSize();
+		 if(pageNo == null){
+			 pageNo = 0;
+		 }
+		 if(pageSize == null){
+			 pageSize = 10;
+		 }
+
+		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListWeek(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost(), pageNo, pageSize, dateDTO.getProjectIds(), dateDTO.getAccountIds());
 		 result.setResult(list);
 		 result.setSuccess(true);
 		 return result;
@@ -108,11 +118,11 @@ public class ByteDanceVideoReportDailyController {
 	 @AutoLog(value = "头条视频汇总")
 	 @ApiOperation(value = "头条视频汇总", notes = "头条视频汇总")
 	 @PostMapping(value = "/videoInfoListTotal")
-	 public Result<List<ByteDanceVideoReportDaily>> videoInfoListTotal(@RequestBody DateDTO dateDTO,
+	 public Result<PageInfo<ByteDanceVideoReportDaily>> videoInfoListTotal(@RequestBody DateDTO dateDTO,
 																		HttpServletRequest req){
-		 Result<List<ByteDanceVideoReportDaily>> result = new Result();
+		 Result<PageInfo<ByteDanceVideoReportDaily>> result = new Result();
 
-		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListTotal(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost());
+		 PageInfo<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListTotal(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost());
 		 result.setResult(list);
 		 result.setSuccess(true);
 		 return result;
@@ -236,7 +246,7 @@ public class ByteDanceVideoReportDailyController {
 
 		 String[] columns = dateDTO.getColumns();
 
-  		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListTotal(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost());
+  		 List<ByteDanceVideoReportDaily> list = videoReportDailyService.videoInfoListTotalExcel(dateDTO.getStartDate(), dateDTO.getEndDate(), dateDTO.getSignature(), dateDTO.getCost());
 
 		 //导出excel
 		 List<List<Object>> group = new ArrayList<>();

+ 13 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/controller/BytedanceReportController.java

@@ -208,4 +208,17 @@ public class BytedanceReportController {
     }
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
 }

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.toutiao.modules.report.mapper;
 
+import cn.com.ctop.toutiao.modules.report.DTO.AccountVideoDTO;
 import cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
@@ -38,4 +39,26 @@ public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVid
 
     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();
+
+    void replaceIntoAccountVideoMapBatch(@Param("accountVideoDTOList")List<AccountVideoDTO> accountVideoDTOList);
+
+    //admin角色查询视频报表
+    List<ByteDanceVideoReportDaily> videoInfoListGroupAdmin(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountIds") List<Long> accountIds, @Param("signature") String signature, @Param("cost") BigDecimal cost);
+
+    //teamLeader角色查询视频报表
+    List<ByteDanceVideoReportDaily> videoInfoListGroupdesignTeamLeader(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("companyId")String companyId, @Param("accountIds") List<Long> accountIds, @Param("signature") String signature, @Param("cost") BigDecimal cost);
+
+    //平面设计角色查询视频报表
+    List<ByteDanceVideoReportDaily> videoInfoListGroupPlaneAndPlaneLeader(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("companyId")String companyId, @Param("userId")String userId, @Param("accountIds") List<Long> accountIds, @Param("signature") String signature, @Param("cost") BigDecimal cost);
+
+    //编导角色查询视频报表
+    List<ByteDanceVideoReportDaily> videoInfoListGroupPlan(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("companyId")String companyId, @Param("userId")String userId, @Param("accountIds") List<Long> accountIds, @Param("signature") String signature, @Param("cost") BigDecimal cost);
+
+    //剪辑角色查询视频报表
+    List<ByteDanceVideoReportDaily> videoInfoListGroupClip(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("companyId")String companyId, @Param("userId")String userId, @Param("accountIds") List<Long> accountIds, @Param("signature") String signature, @Param("cost") BigDecimal cost);
+
+    //拍摄
+    List<ByteDanceVideoReportDaily> videoInfoListGroupShot(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("companyId")String companyId, @Param("userId")String userId, @Param("accountIds") List<Long> accountIds, @Param("signature") String signature, @Param("cost") BigDecimal cost);
+
 }

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

@@ -257,9 +257,8 @@
         and signature = #{signature}
     </update>
 
-    <select id="videoInfoListWeek" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
-        select
-        --  a.material_id as materialId,
+    <sql id="selectSql">
+--  a.material_id as materialId,
         --         a.account_id as accountId,
         --         b.auth_name as authName,
         a.project_id                             as projectId,
@@ -461,43 +460,165 @@
         when sum(a.click) != 0
         then sum(a.download_start) / sum(a.click)
         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=" role != 'admin' ">
-           and a.company_id = #{companyId}
+        <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
 
-        <choose>   <!-- 编导、剪辑、拍摄、平面只能查看自己本职工作制作的视频,设计组长和管理员能查看所有的-->
-            <when test="role == 'plan'">
-                and f.plan = #{userId}
-            </when>
-            <when test="role == 'clip'">
-                and f.clip = #{userId}
-            </when>
-            <when test="role == 'shot' ">
-                and f.shot = #{userId}
-            </when>
-            <when test="role == 'plane'  or role == 'planeLeader' ">
-                and f.plan = #{userId}
-            </when>
-            <when test="role == 'admin' or role == 'designTeamLeader'">
-                and 1=1
-            </when>
-            <otherwise>F
-                and a.id = 0
-            </otherwise>
-        </choose>
+        <if test="accountIds != null">
+        and p.account_id in
+        <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        </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 = #{userId}
+        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="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 = #{userId}
+        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="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 = #{userId}
+        <if test="accountIds != null">
+        and p.account_id in
+        <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        </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 = #{userId}
+        <if test="accountIds != null">
+        and p.account_id in
+        <foreach item="item" index="index" collection="accountIds" open="(" separator="," close=")">
+            #{item}
+        </foreach>
+        </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}
@@ -738,4 +859,34 @@
         </if>
     </select>
 
+    <select id="accountVideoMap" resultType="cn.com.ctop.toutiao.modules.report.DTO.AccountVideoDTO">
+            select
+            a.account_id,b.signature
+        FROM
+        ctop_bytedance_report_material_daily a
+        left join ctop_bytedance_video_info b on a.material_id = b.material_id
+        where a.image_mode in ('CREATIVE_IMAGE_MODE_VIDEO','CREATIVE_IMAGE_MODE_VIDEO_VERTICAL')
+        and b.signature is not null
+        group by a.account_id,b.signature
+    </select>
+
+    <insert id="replaceIntoAccountVideoMapBatch">
+        replace into
+        ctop_bytedance_account_video_map
+        (
+            account_id,
+            signature
+        )
+        values
+        <foreach collection="accountVideoDTOList" item="accountVideo" separator=",">
+        (
+            #{accountVideo.accountId},
+            #{accountVideo.signature}
+        )
+        </foreach>
+    </insert>
+
+
+
+
 </mapper>

+ 218 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceReportMapper.xml

@@ -197,4 +197,222 @@
     </select>
 
 
+
+
+
+    <select id="videoInfoListWeek" 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.project_id                             as projectId,
+        a.project_name                           as projectName,
+        a.advertiser_id                          as advertiserId,
+        a.advertiser_name                        as advertiserName,
+        a.stat_datetime                          as statDatetime,
+        sum(a.cost)                              as cost,                           -- 消耗
+        a.signature                              as signature,
+        a.video_url                              as videoUrl,
+        '-'                                      as materialDesc,
+        (select info.url from ctop_material_info info where info.code = a.signature limit 1)                                    as url,
+        1                                        as appType,
+        sum(a.click)                             as clickMaterial,                  -- 点击数
+
+        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.form)                              as form,                           --  表单提交数
+        sum(a.total_play)                        as totalPlay,                      -- 视频-总播放
+        sum(a.valid_play)                        as validPlay,                      -- 视频-有效播放
+        sum(a.wifi_play)                         as wifiPlay,                       -- 视频-wifi播放
+        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.share_material)                    as shareMaterial,                  -- 互动数据-分享数
+        sum(a.follow)                            as follow,                         -- 互动数据-新增关注数
+        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,                -- 次留成本 = 消耗/次留数
+
+        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.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,                  -- 应用下载广告数据-付费成本 = 消耗/付费次数
+
+        case
+        when sum(a.click) != 0
+        then sum(a.cost) / sum(a.click)
+        else 0 end                           as cpc,                            -- 平均点击单价
+        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,                   -- 互动数据-点赞数
+
+
+        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%
+
+
+        case
+        when sum(a.active) != 0
+        then sum(a.game_addiction) / sum(a.active)
+        else 0 end                            as  gameAddictionRate,              -- 应用下载广告数据-关键行为率  关键行为用户占激活用户的比例
+
+        case
+        when sum(a.active) != 0
+        then sum(a.register) / sum(a.active)
+        else 0 end                           as activeRegisterRate,             -- 应用下载广告数据-注册率   注册用户占激活用户的比例
+
+
+        case
+        when sum(a.download_finish) != 0
+        then sum(a.cost) / sum(a.download_finish)
+        else 0 end                           as downloadFinishCost,             -- 应用下载广告数据-安卓下载完成成本 计算方式:总花费/安卓下载完成数。
+
+
+        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.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.play_over)                         as playOver,                       -- 完播数
+
+        case
+        when sum(a.download_start) != 0
+        then sum(a.cost) / sum(a.download_start)
+        else 0 end                           as downloadStartCost,              -- 应用下载广告数据-安卓下载开始成本  计算方法:总花费/安卓下载开始数。
+
+        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,                    --  转化数据-转化成本=总花费/转化数
+
+        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               --  应用下载广告数据-安卓下载开始率  计算方法:安卓下载开始数/点击数
+
+        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>
+
+        and f.material_id is not null
+
+        <choose>   <!-- 编导、剪辑、拍摄、平面只能查看自己本职工作制作的视频,设计组长和管理员能查看所有的-->
+            <when test="role == 'plan'">
+                and f.plan = #{userId}
+            </when>
+            <when test="role == 'clip'">
+                and f.clip = #{userId}
+            </when>
+            <when test="role == 'shot' ">
+                and f.shot = #{userId}
+            </when>
+            <when test="role == 'plane'  or role == 'planeLeader' ">
+                and f.plan = #{userId}
+            </when>
+            <when test="role == 'admin' or role == 'designTeamLeader'">
+                and 1=1
+            </when>
+            <otherwise>F
+                and a.id = 0
+            </otherwise>
+        </choose>
+
+        <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>
+
+
 </mapper>

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

@@ -2,6 +2,7 @@ package cn.com.ctop.toutiao.modules.report.service;
 
 import cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.pagehelper.PageInfo;
 
 import java.math.BigDecimal;
 import java.util.List;
@@ -16,9 +17,11 @@ public interface IByteDanceVideoReportDailyService extends IService<ByteDanceVid
 
     void videoInfoList(String startDate, String endDate);
 
-    List<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost);
+    PageInfo<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds);
 
-    List<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost);
+    PageInfo<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost);
+
+    List<ByteDanceVideoReportDaily> videoInfoListTotalExcel(String startDate, String endDate, String signature, BigDecimal cost);
 
     List<ByteDanceVideoReportDaily> videoInfoListMonth(String startDate, String endDate, String signature, BigDecimal cost);
 

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

@@ -1,10 +1,13 @@
 package cn.com.ctop.toutiao.modules.report.service.impl;
 
+import cn.com.ctop.toutiao.modules.report.DTO.AccountVideoDTO;
 import cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily;
 import cn.com.ctop.toutiao.modules.report.mapper.ByteDanceVideoReportDailyMapper;
 import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
 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.shiro.SecurityUtils;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.DateUtils;
@@ -13,6 +16,7 @@ import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
 import java.text.ParseException;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -115,7 +119,22 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
 
 
     //视频总报表列表
-    public List<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost){
+    public PageInfo<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost){
+        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        String userId = sysUser.getId();
+        String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
+        String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
+
+        PageHelper.startPage(0,10);
+        List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoListWeek(startDate, endDate, roleCode, userId, signature, companyId, cost);
+        PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
+
+
+        return pageInfo;
+    }
+
+    //视频总报表列表导出excel
+    public List<ByteDanceVideoReportDaily> videoInfoListTotalExcel(String startDate, String endDate, String signature, BigDecimal cost){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
@@ -127,7 +146,7 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
     }
 
     //视频报表月列表
-    public List<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost){
+    public PageInfo<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds){
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         String userId = sysUser.getId();
         String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
@@ -136,8 +155,40 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         //QueryWrapper<ByteDanceVideoReportDaily> wrapper = new QueryWrapper<>();
         //wrapper.eq("stat_datetime",startDate);
         //byteDanceVideoReportDailyMapper.delete(wrapper);
+        List<ByteDanceVideoReportDaily> mList = new ArrayList<>();
+        //PageHelper.startPage(pageNo,pageSize);
+        PageHelper.startPage(0,10);
+        mList = byteDanceVideoReportDailyMapper.videoInfoListWeek(startDate, endDate, roleCode, userId, signature, companyId, cost);
+        //PageInfo<ByteDanceVideoReportDaily> pageInfo =
+
+        //PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(dailyList);
+        //result.put("data", pageInfo);
+
+        //admin能看所有视频
+        if(roleCode == "admin"){
+
+
+
+        }else if(roleCode == "touTiaoOperationManager" || roleCode == "operator" || roleCode == "operationAssistant") {
+
+
+        }else if(roleCode == "shot"){
+
+
+        }else if(roleCode == "plan"){
+
+
+        }else if(roleCode == "plane"){
+
+
+        }else if(roleCode == "clip"){
+
+
+        }else if(roleCode == "designTeamLeader"){
+
+
+        }
 
-        List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoListWeek(startDate, endDate, roleCode, userId, signature, companyId, cost);
 
         //计算环比
         for(ByteDanceVideoReportDaily m:mList){
@@ -153,7 +204,9 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
             m.setHuanbi(huanbi);
         }
 
-        return mList;
+        PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
+
+        return pageInfo;
     }
 
     public List<ByteDanceVideoReportDaily> videoInfoListDetail(String startDate, String endDate, String signature){
@@ -195,5 +248,8 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         }
     }
 
+    public void accountVideoMap(){
+        List<AccountVideoDTO> accountVideoDTOList = byteDanceVideoReportDailyMapper.accountVideoMap();
+    }
 
 }