Browse Source

Merge branch 'test'

hcst_sunzhen 5 years ago
parent
commit
3ac5c4a945

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

@@ -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;
@@ -231,7 +231,7 @@ public class ByteDanceVideoReportDailyController {
 		 result.setMessage("success");
 
 		 //按天明细
-		 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<>();
@@ -239,7 +239,6 @@ public class ByteDanceVideoReportDailyController {
 			 for (ByteDanceVideoReportDaily sum : list) {
 				 List<Object> ByteDanceVideoReportDaily = new ArrayList();
 				 ByteDanceVideoReportDaily.add(sum.getAdvertiserName());  //客户
-				 ByteDanceVideoReportDaily.add(sum.getAccountId()+"");  //账户
 				 ByteDanceVideoReportDaily.add(sum.getVideoUrl() );  //视频链接
 				 ByteDanceVideoReportDaily.add(DateUtils.formatDate(sum.getStatDatetime()));  //时间
 				 ByteDanceVideoReportDaily.add(sum.getCost());  //消耗
@@ -248,7 +247,7 @@ public class ByteDanceVideoReportDailyController {
 			 }
 		 }
 
-		 String[] groupHeaders = {"客户", "账户", "视频链接", "时间", "消耗","环比"};
+		 String[] groupHeaders = {"客户","视频链接", "时间", "消耗","环比"};
 		 OutputStream os = response.getOutputStream();
 		 ExportExcelUtils eeu = new ExportExcelUtils();
 		 XSSFWorkbook workbook = new XSSFWorkbook();

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

@@ -35,7 +35,11 @@ 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> 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);
 
@@ -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);
 }

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

@@ -29,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,
@@ -295,10 +292,10 @@
                 a.advertiser_id as advertiserId,
                 a.advertiser_name as advertiserName,
                 a.stat_datetime as statDatetime,
-                a.cost as cost,  -- 消耗
+                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
@@ -306,10 +303,74 @@
         where
         stat_datetime &gt;= #{startDate}
         and stat_datetime &lt;= #{endDate}
-        <if test=" role != 'admin' ">
+<!--        <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.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}
+        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>
 
@@ -759,4 +820,14 @@
 
     </select>
 
+    <select id="getAccountIds" resultType="long">
+        select
+        account_id
+        from
+        ctop_bytedance_video_report_daily
+        where
+        signature = #{signature}
+        and company_id = #{companyId}
+    </select>
+
 </mapper>

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

@@ -25,7 +25,7 @@ public interface IByteDanceVideoReportDailyService extends IService<ByteDanceVid
 
     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);
 

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

@@ -412,21 +412,54 @@ 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);
 
-        List<ByteDanceVideoReportDaily> mList = 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 endMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-1));
-            List<Long> accountIdsList = new ArrayList<>();
-            accountIdsList.add(m.getAccountId());
-            BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(startMonthDate,endMonthDate,m.getSignature(),accountIdsList);
+            //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){