Procházet zdrojové kódy

头条视频素材报表编写

hcst_sunzhen před 5 roky
rodič
revize
124eb667e5

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

@@ -88,7 +88,11 @@ public class ProjectMemberServiceImpl extends ServiceImpl<ProjectMemberMapper, P
             projectMemberList = memberMapper.adminProjects(mediaIds);
         }else if(roleCode.equals("operator") || roleCode.equals("operationAssistant") || roleCode.equals("touTiaoOperationManager")||roleCode.equals("huananyunying")){
             projectMemberList = memberMapper.operationProjects(userId, mediaIds);
+        }else{
+            //如果以上角色都不是的话直接查询此角色所属项目
+            projectMemberList = memberMapper.designProjects(userId, mediaIds);
         }
+
         if(null == projectMemberList){
             projectMemberList = new ArrayList<>();
         }

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

@@ -43,6 +43,8 @@ public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVid
 
     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> videoInfoListDetailOtherRoles(@Param("companyId") String companyId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("signature") String signature, @Param("accountIds") List<Long> accountIds);
+
     List<AccountVideoDTO> accountVideoMap();
 
     void replaceIntoAccountVideoMapBatch(@Param("accountVideoDTOList")List<AccountVideoDTO> accountVideoDTOList);
@@ -68,9 +70,13 @@ public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVid
     //运营
     List<ByteDanceVideoReportDaily> videoInfoListGroupOperator(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountIds") List<Long> accountIds, @Param("signature") String signature, @Param("cost") BigDecimal cost);
 
+    List<ByteDanceVideoReportDaily> videoInfoListGroupOtherRoles(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("accountIds") List<Long> accountIds, @Param("signature") String signature, @Param("cost") BigDecimal cost);
+
     List<Long> getAccountIdByprojectIds(@Param("projectIds")List<Long> projectIds);
 
     List<Long> getAccountIdsByOperatorIdAndMediaId(@Param("userId")String userId);
 
     List<Long> getAccountIds(@Param("companyId")String companyId, @Param("signature")String signature);
+
+    List<Long> getAccountIdsByUserIdAndMediaIds(@Param("userId")String userId, @Param("mediaIds")List<Integer> mediaIds);
 }

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

@@ -355,7 +355,7 @@
         order by stat_datetime desc
     </select>
 
-    <select id="videoInfoListDetailDesign" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListDetailOtherRoles" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         a.project_id as projectId,
         a.project_name as projectName,
@@ -375,6 +375,37 @@
         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>
+
+    <select id="videoInfoListDetailDesign" 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,
+        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
@@ -696,6 +727,28 @@
 
     </select>
 
+    <select id="videoInfoListGroupOtherRoles" 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
+        where stat_datetime &gt;= #{startDate}
+        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>
+        <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>
+
+    </select>
+
     <select id="videoInfoListGroupShot" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
@@ -753,7 +806,7 @@
         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} -->
+        and a.company_id = #{companyId}
         and f.material_id is not null
         <if test="accountIds != null">
             and a.account_id in
@@ -857,7 +910,27 @@
         ctop_bytedance_video_report_daily
         where
         signature = #{signature}
-        <!-- and company_id = #{companyId}  -->
+         and company_id = #{companyId}
+    </select>
+
+    <select id="getAccountIdsByUserIdAndMediaIds" resultType="long">
+        select
+        account_id
+        from
+        ctop_user_allocation
+        where
+        project_id in (
+            select
+            project_id
+            from ctop_project_member member
+            left join ctop_project pro on member.project_id = pro.id
+            where member.user_id =#{userId}
+            and pro.media_id in
+            <foreach collection="mediaIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        )
     </select>
 
 </mapper>

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

@@ -100,12 +100,15 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
-        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
+        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")||roleCode.equals("huananyunying")) {
             if (accountIdsList != null && !accountIdsList.isEmpty()){
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(userId);
+                if(accoutnIds == null || accoutnIds.isEmpty()){
+                    return new PageInfo<>(mList);
+                }
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
             }
@@ -124,6 +127,21 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         }else if(roleCode.equals("designTeamLeader")){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
+        }else{
+            if (accountIdsList != null && !accountIdsList.isEmpty()) {
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }else{
+                List<Integer> mediaIds = new ArrayList<>();
+                mediaIds.add(1);
+                mediaIds.add(3);
+                accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdsByUserIdAndMediaIds(userId,mediaIds);
+                if(accountIdsList == null || accountIdsList.isEmpty()){
+                    return new PageInfo<>(mList);
+                }
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }
         }
 
         //计算环比
@@ -169,12 +187,15 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
-        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
+        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")||roleCode.equals("huananyunying")) {
             if (accountIdsList != null && !accountIdsList.isEmpty()){
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(userId);
+                if(accoutnIds == null || accoutnIds.isEmpty()){
+                    return new PageInfo<>(mList);
+                }
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
             }
@@ -193,6 +214,21 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         }else if(roleCode.equals("designTeamLeader")){
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
+        }else {
+            if (accountIdsList != null && !accountIdsList.isEmpty()) {
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }else{
+                List<Integer> mediaIds = new ArrayList<>();
+                mediaIds.add(1);
+                mediaIds.add(3);
+                accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdsByUserIdAndMediaIds(userId,mediaIds);
+                if(accountIdsList == null || accountIdsList.isEmpty()){
+                    return new PageInfo<>(mList);
+                }
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }
         }
 
         //计算环比
@@ -237,12 +273,15 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
-        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
+        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")||roleCode.equals("huananyunying")) {
             if (accountIdsList != null && !accountIdsList.isEmpty()){
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(userId);
+                if(accoutnIds == null || accoutnIds.isEmpty()){
+                    return new PageInfo<>(mList);
+                }
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
             }
@@ -261,6 +300,21 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         }else if(roleCode.equals("designTeamLeader")){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
+        }else {
+            if (accountIdsList != null && !accountIdsList.isEmpty()) {
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }else{
+                List<Integer> mediaIds = new ArrayList<>();
+                mediaIds.add(1);
+                mediaIds.add(3);
+                accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdsByUserIdAndMediaIds(userId,mediaIds);
+                if(accountIdsList == null || accountIdsList.isEmpty()){
+                    return new PageInfo<>(mList);
+                }
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }
         }
 
         //计算环比
@@ -308,12 +362,15 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             PageHelper.orderBy(sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
-        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
+        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")||roleCode.equals("huananyunying")) {
             if (accountIdsList != null && !accountIdsList.isEmpty()){
                 PageHelper.orderBy(sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(userId);
+                if(accoutnIds == null || accoutnIds.isEmpty()){
+                    return mList;
+                }
                 PageHelper.orderBy(sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
             }
@@ -332,6 +389,20 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         }else if(roleCode.equals("designTeamLeader")){
             PageHelper.orderBy(sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
+        }else {
+            if (accountIdsList != null && !accountIdsList.isEmpty()) {
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }else{
+                List<Integer> mediaIds = new ArrayList<>();
+                mediaIds.add(1);
+                mediaIds.add(3);
+                accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdsByUserIdAndMediaIds(userId,mediaIds);
+                if(accountIdsList == null || accountIdsList.isEmpty()){
+                    return mList;
+                }
+
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }
         }
         return mList;
     }
@@ -359,12 +430,15 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupAdmin(startDate, endDate, accountIdsList, signature, cost);
-        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
+        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")||roleCode.equals("huananyunying")) {
             if (accountIdsList != null && !accountIdsList.isEmpty()){
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accountIdsList,signature,cost);
             }else{
                 List<Long> accoutnIds= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(userId);
+                if(accoutnIds == null || accoutnIds.isEmpty()){
+                    return new PageInfo<>(mList);
+                }
                 PageHelper.startPage(pageNo,pageSize,sort);
                 mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
             }
@@ -383,6 +457,21 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         }else if(roleCode.equals("designTeamLeader")){
             PageHelper.startPage(pageNo,pageSize,sort);
             mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
+        }else{
+            if (accountIdsList != null && !accountIdsList.isEmpty()) {
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }else{
+                List<Integer> mediaIds = new ArrayList<>();
+                mediaIds.add(1);
+                mediaIds.add(3);
+                accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdsByUserIdAndMediaIds(userId,mediaIds);
+                if(accountIdsList == null || accountIdsList.isEmpty()){
+                    return new PageInfo<>(mList);
+                }
+                PageHelper.startPage(pageNo,pageSize,sort);
+                mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOtherRoles(startDate,endDate,accountIdsList,signature,cost);
+            }
         }
 
         //计算环比
@@ -420,7 +509,7 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         //admin能看所有视频
         if(roleCode.equals(CtopRoleCodeConstant.COMMON_ROLE_CODE_ADMIN)){
             mList = byteDanceVideoReportDailyMapper.videoInfoListDetail(companyId, startDate, endDate, signature, accountIdsList);
-        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
+        }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")||roleCode.equals("huananyunying")) {
             if (accountIdsList != null && !accountIdsList.isEmpty()){
                 mList = byteDanceVideoReportDailyMapper.videoInfoListDetailOperator(companyId, startDate,endDate,signature, accountIdsList);
             }else{
@@ -432,6 +521,19 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         }else if(roleCode.equals("designTeamLeader")){
             accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
             mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
+        }else {
+            if (accountIdsList != null && !accountIdsList.isEmpty()) {
+                mList = byteDanceVideoReportDailyMapper.videoInfoListDetailOtherRoles(companyId, startDate, endDate, signature, accountIdsList);
+            }else{
+                List<Integer> mediaIds = new ArrayList<>();
+                mediaIds.add(1);
+                mediaIds.add(3);
+                accountIdsList = byteDanceVideoReportDailyMapper.getAccountIdsByUserIdAndMediaIds(userId,mediaIds);
+                if(accountIdsList == null || accountIdsList.isEmpty()){
+                    return mList;
+                }
+                mList = byteDanceVideoReportDailyMapper.videoInfoListDetailOtherRoles(companyId, startDate, endDate, signature, accountIdsList);
+            }
         }
 
         //计算环比