Parcourir la source

视频报表修改

hcst_sunzhen il y a 5 ans
Parent
commit
4770c2b9eb

+ 4 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -1311,6 +1311,10 @@ public class DateUtils extends PropertyEditorSupport {
         return calendar.getTime();
     }
 
+    public static void main(String[] args) {
+        System.out.println(dateDiff("2020-05-26","2020-05-27"));
+    }
+
 }
 
 

+ 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;
 }

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

@@ -105,7 +105,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);
@@ -128,7 +128,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;
@@ -148,7 +148,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;
@@ -172,7 +172,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;
@@ -232,14 +232,7 @@ 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());
 
 		 //导出excel
@@ -248,6 +241,7 @@ 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());  //消耗
@@ -256,7 +250,7 @@ public class ByteDanceVideoReportDailyController {
 			 }
 		 }
 
-		 String[] groupHeaders = {"客户", "视频链接", "时间", "消耗","环比"};
+		 String[] groupHeaders = {"客户", "账户", "视频链接", "时间", "消耗","环比"};
 		 OutputStream os = response.getOutputStream();
 		 ExportExcelUtils eeu = new ExportExcelUtils();
 		 XSSFWorkbook workbook = new XSSFWorkbook();
@@ -288,7 +282,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")

+ 2 - 2
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);
 
@@ -37,7 +37,7 @@ public interface ByteDanceVideoReportDailyMapper extends BaseMapper<ByteDanceVid
 
     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> 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> 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();
 

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

@@ -2,7 +2,7 @@
 <!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 id="videoInfoList_old" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
        --  a.material_id as materialId,
         --         a.account_id as accountId,
@@ -244,7 +244,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>
 
@@ -459,11 +464,11 @@
         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               --  应用下载广告数据-安卓下载开始率  计算方法:安卓下载开始数/点击数
+        -- a.huanbi as huanbi
     </sql>
 
-     <select id="videoInfoListGroupAdmin" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+     <select id="videoInfoListGroupAdminOld" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
             select
             <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -500,7 +505,7 @@
         order by sum(a.cost)
     </select>
 
-    <select id="videoInfoListGroupdesignTeamLeader" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupdesignTeamLeaderOld" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -538,7 +543,7 @@
         order by sum(a.cost)
     </select>
 
-    <select id="videoInfoListGroupPlaneAndPlaneLeader" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupPlaneAndPlaneLeaderOld" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -569,7 +574,7 @@
         order by sum(a.cost)
     </select>
 
-    <select id="videoInfoListGroupPlan" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupPlanOld" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -600,7 +605,7 @@
         order by sum(a.cost)
     </select>
 
-    <select id="videoInfoListGroupClip" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupClipOld" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -631,7 +636,7 @@
         order by sum(a.cost)
     </select>
 
-    <select id="videoInfoListGroupShot" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupShotOld" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -662,7 +667,7 @@
         order by sum(a.cost)
     </select>
 
-    <select id="videoInfoListGroupOperator" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
+    <select id="videoInfoListGroupOperatorOld" resultType="cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily">
         select
         <include refid="selectSql"></include>
         from ctop_bytedance_video_report_daily a
@@ -757,6 +762,7 @@
                 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,
@@ -764,7 +770,8 @@
                 -- a.signature as signature,
                 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
@@ -831,7 +838,7 @@
     </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,
@@ -1062,10 +1069,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
@@ -1084,10 +1091,18 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+<!--
+        <choose>
+            <when test="order != null and order != '' and sort != null and sort != '' ">
+                order by #{order} #{sort}
+            </when>
+            <otherwise>
+                order by cost desc
+            </otherwise>
+        </choose>-->
     </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 +1125,18 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
+      <!--  <choose>
+            <when test="order != null and order != '' and sort != null and sort != '' ">
+                order by #{order} #{sort}
+            </when>
+            <otherwise>
+                order by cost desc
+            </otherwise>
+        </choose>-->
     </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 +1158,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 +1183,18 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
+       <!-- <choose>
+            <when test="order != null and order != '' and sort != null and sort != '' ">
+                order by #{order} #{sort}
+            </when>
+            <otherwise>
+                order by cost desc
+            </otherwise>
+        </choose>-->
     </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 +1217,18 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
+       <!-- <choose>
+            <when test="order != null and order != '' and sort != null and sort != '' ">
+                order by #{order} #{sort}
+            </when>
+            <otherwise>
+                order by cost desc
+            </otherwise>
+        </choose>-->
     </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 +1251,18 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
+      <!--  <choose>
+            <when test="order != null and order != '' and sort != null and sort != '' ">
+                order by #{order} #{sort}
+            </when>
+            <otherwise>
+                order by cost desc
+            </otherwise>
+        </choose>-->
     </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 +1285,15 @@
         <if test="cost != null">
             having sum(a.cost) &gt;= #{cost}
         </if>
-        order by sum(a.cost)
+
+       <!-- <choose>
+            <when test="order != null and order != '' and sort != null and sort != '' ">
+                order by #{order} #{sort}
+            </when>
+            <otherwise>
+                order by cost desc
+            </otherwise>
+        </choose>-->
     </select>
 
 </mapper>

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

@@ -17,13 +17,13 @@ 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);
 
@@ -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();
 

+ 231 - 397
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;
@@ -56,134 +57,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);
@@ -192,131 +143,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){
@@ -332,117 +212,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);
@@ -450,139 +280,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){
@@ -603,7 +419,25 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         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);
+        //计算环比
+        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);
+
+            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){