|
@@ -1,10 +1,14 @@
|
|
package cn.com.ctop.toutiao.modules.report.service.impl;
|
|
package cn.com.ctop.toutiao.modules.report.service.impl;
|
|
|
|
|
|
|
|
+import cn.com.ctop.toutiao.modules.report.DTO.AccountVideoDTO;
|
|
import cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily;
|
|
import cn.com.ctop.toutiao.modules.report.entity.ByteDanceVideoReportDaily;
|
|
import cn.com.ctop.toutiao.modules.report.mapper.ByteDanceVideoReportDailyMapper;
|
|
import cn.com.ctop.toutiao.modules.report.mapper.ByteDanceVideoReportDailyMapper;
|
|
import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
|
|
import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
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.apache.shiro.SecurityUtils;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
@@ -13,6 +17,8 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -34,7 +40,6 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
|
|
videoInfoListByCompanyId(startDate, endDate, "d57fecdcf7a94d009736d9c850731582");
|
|
videoInfoListByCompanyId(startDate, endDate, "d57fecdcf7a94d009736d9c850731582");
|
|
//华东
|
|
//华东
|
|
videoInfoListByCompanyId(startDate, endDate, "4b10089775c040119e139087517aed88");
|
|
videoInfoListByCompanyId(startDate, endDate, "4b10089775c040119e139087517aed88");
|
|
- System.out.println(endDate + "结束");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
private void videoInfoListByCompanyId(String startDate, String endDate, String companyId){
|
|
private void videoInfoListByCompanyId(String startDate, String endDate, String companyId){
|
|
@@ -51,56 +56,215 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
|
|
|
|
|
|
//QueryWrapper<ByteDanceVideoReportDaily> queryWrapper = new QueryWrapper<>();
|
|
//QueryWrapper<ByteDanceVideoReportDaily> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
- List<ByteDanceVideoReportDaily> mList2 = byteDanceVideoReportDailyMapper.selectList(wrapper);
|
|
|
|
|
|
+ //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);
|
|
|
|
+ //}
|
|
|
|
+ }
|
|
|
|
|
|
- for(ByteDanceVideoReportDaily m:mList2){
|
|
|
|
- String statDate = DateUtils.formatDate(DateUtils.addDay(m.getStatDatetime(),-1));
|
|
|
|
- BigDecimal cost = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(statDate,statDate,m.getSignature(),companyId);
|
|
|
|
|
|
+ //视频按天列表
|
|
|
|
+ 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")){
|
|
|
|
+ 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 (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,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
|
|
|
|
+ }
|
|
|
|
+ }else if(roleCode.equals("shot")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("plan")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("plane")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("clip")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("designTeamLeader")){
|
|
|
|
+ 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;
|
|
BigDecimal huanbi =BigDecimal.ZERO;
|
|
- if(cost != null && cost.compareTo(BigDecimal.ZERO)>0){
|
|
|
|
- huanbi = m.getCost().subtract(cost).divide(cost,7, BigDecimal.ROUND_HALF_UP);
|
|
|
|
|
|
+ if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
|
|
|
|
+ huanbi = m.getCost().subtract(costBefore).divide(costBefore,7, BigDecimal.ROUND_HALF_UP);
|
|
}
|
|
}
|
|
|
|
|
|
m.setHuanbi(huanbi);
|
|
m.setHuanbi(huanbi);
|
|
- byteDanceVideoReportDailyMapper.updateById(m);
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
|
|
|
|
+ return pageInfo;
|
|
}
|
|
}
|
|
|
|
|
|
- //视频按天列表
|
|
|
|
- public List<ByteDanceVideoReportDaily> videoInfoListDaily(String startDate, String endDate, String signature, BigDecimal cost){
|
|
|
|
|
|
+
|
|
|
|
+ //视频报表月列表
|
|
|
|
+ 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();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
String userId = sysUser.getId();
|
|
String userId = sysUser.getId();
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(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<>();
|
|
|
|
|
|
- return mList;
|
|
|
|
|
|
+ List<Long> accountIdsList = null;
|
|
|
|
+ if(accountIds != null && accountIds.length != 0){
|
|
|
|
+ accountIdsList = Arrays.asList(accountIds);
|
|
|
|
+ }
|
|
|
|
+ //admin能看所有视频
|
|
|
|
+ if(roleCode.equals("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")) {
|
|
|
|
+ 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,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
|
|
|
|
+ }
|
|
|
|
+ }else if(roleCode.equals("shot")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("plan")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("plane")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("clip")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("designTeamLeader")){
|
|
|
|
+ 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);
|
|
|
|
+ return pageInfo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- //视频报表月列表
|
|
|
|
- public List<ByteDanceVideoReportDaily> videoInfoListMonth(String startDate, String endDate, String signature, BigDecimal cost){
|
|
|
|
|
|
+ //视频总报表列表
|
|
|
|
+ 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();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
String userId = sysUser.getId();
|
|
String userId = sysUser.getId();
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(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")){
|
|
|
|
+ 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 (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,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
|
|
|
|
+ }
|
|
|
|
+ }else if(roleCode.equals("shot")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("plan")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("plane")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("clip")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("designTeamLeader")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
|
|
|
|
+ }
|
|
|
|
|
|
//计算环比
|
|
//计算环比
|
|
for(ByteDanceVideoReportDaily m:mList){
|
|
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;
|
|
BigDecimal huanbi =BigDecimal.ZERO;
|
|
if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
|
|
if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
|
|
@@ -110,40 +274,130 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
|
|
m.setHuanbi(huanbi);
|
|
m.setHuanbi(huanbi);
|
|
}
|
|
}
|
|
|
|
|
|
- return mList;
|
|
|
|
|
|
+ PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
|
|
|
|
+ return pageInfo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //视频总报表列表导出excel
|
|
|
|
+ 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);
|
|
|
|
|
|
- //视频总报表列表
|
|
|
|
- public List<ByteDanceVideoReportDaily> videoInfoListTotal(String startDate, String endDate, String signature, BigDecimal cost){
|
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
String userId = sysUser.getId();
|
|
String userId = sysUser.getId();
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(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;
|
|
return mList;
|
|
}
|
|
}
|
|
|
|
|
|
- //视频报表月列表
|
|
|
|
- public List<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost){
|
|
|
|
|
|
+ //视频报表周列表
|
|
|
|
+ public PageInfo<ByteDanceVideoReportDaily> videoInfoListWeek(String startDate, String endDate, String signature, BigDecimal cost, Integer pageNo, Integer pageSize, Long[] projectIds, Long[] accountIds, String sort){
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
String userId = sysUser.getId();
|
|
String userId = sysUser.getId();
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
|
|
String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
|
|
|
|
|
|
- //QueryWrapper<ByteDanceVideoReportDaily> wrapper = new QueryWrapper<>();
|
|
|
|
- //wrapper.eq("stat_datetime",startDate);
|
|
|
|
- //byteDanceVideoReportDailyMapper.delete(wrapper);
|
|
|
|
|
|
+ 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<ByteDanceVideoReportDaily> 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")){
|
|
|
|
+ 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 (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,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupOperator(startDate,endDate,accoutnIds,signature,cost);
|
|
|
|
+ }
|
|
|
|
+ }else if(roleCode.equals("shot")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupShot(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("plan")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlan(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("plane")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupPlaneAndPlaneLeader(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("clip")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupClip(startDate, endDate, companyId, userId, accountIdsList, signature, cost);
|
|
|
|
+ }else if(roleCode.equals("designTeamLeader")){
|
|
|
|
+ PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListGroupdesignTeamLeader(startDate, endDate, companyId, accountIdsList, signature, cost);
|
|
|
|
+ }
|
|
|
|
|
|
//计算环比
|
|
//计算环比
|
|
for(ByteDanceVideoReportDaily m:mList){
|
|
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;
|
|
BigDecimal huanbi =BigDecimal.ZERO;
|
|
if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
|
|
if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
|
|
@@ -153,16 +407,69 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
|
|
m.setHuanbi(huanbi);
|
|
m.setHuanbi(huanbi);
|
|
}
|
|
}
|
|
|
|
|
|
- return mList;
|
|
|
|
|
|
+ PageInfo<ByteDanceVideoReportDaily> pageInfo = new PageInfo<>(mList);
|
|
|
|
+
|
|
|
|
+ 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();
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
String userId = sysUser.getId();
|
|
String userId = sysUser.getId();
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String roleCode = byteDanceVideoReportDailyMapper.getRoleCodeByUserId(userId);
|
|
String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
|
|
String companyId = byteDanceVideoReportDailyMapper.getCompanyIdByUserId(userId);
|
|
|
|
|
|
- return byteDanceVideoReportDailyMapper.videoInfoListDetail(companyId, startDate, endDate, signature, roleCode);
|
|
|
|
|
|
+ //List<ByteDanceVideoReportDaily> mList = byteDanceVideoReportDailyMapper.videoInfoListDetail(companyId, startDate, endDate, signature, roleCode);
|
|
|
|
+ List<ByteDanceVideoReportDaily> mList =new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<Long> accountIdsList = null;
|
|
|
|
+ if(accountIds != null && accountIds.length != 0){
|
|
|
|
+ accountIdsList = Arrays.asList(accountIds);
|
|
|
|
+ }
|
|
|
|
+ //admin能看所有视频
|
|
|
|
+ if(roleCode.equals("admin")){
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListDetail(companyId, startDate, endDate, signature, accountIdsList);
|
|
|
|
+ }else if(roleCode.equals("touTiaoOperationManager") || roleCode.equals("operator") || roleCode.equals("operationAssistant")) {
|
|
|
|
+ if (accountIdsList != null && accountIdsList.size() != 0){
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListDetailOperator(companyId, startDate,endDate,signature, accountIdsList);
|
|
|
|
+ }else{
|
|
|
|
+ accountIdsList= byteDanceVideoReportDailyMapper.getAccountIdsByOperatorIdAndMediaId(1,userId);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListDetailOperator(companyId, startDate,endDate,signature, accountIdsList);
|
|
|
|
+ }
|
|
|
|
+ }else if(roleCode.equals("shot")){
|
|
|
|
+ accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
|
|
|
|
+ }else if(roleCode.equals("plan")){
|
|
|
|
+ accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
|
|
|
|
+ }else if(roleCode.equals("plane")){
|
|
|
|
+ accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
|
|
|
|
+ }else if(roleCode.equals("clip")){
|
|
|
|
+ accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
|
|
|
|
+ }else if(roleCode.equals("designTeamLeader")){
|
|
|
|
+ accountIdsList = byteDanceVideoReportDailyMapper.getAccountIds(companyId, signature);
|
|
|
|
+ mList = byteDanceVideoReportDailyMapper.videoInfoListDetailDesign(companyId, startDate,endDate,signature, accountIdsList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //计算环比
|
|
|
|
+ for(ByteDanceVideoReportDaily m:mList){
|
|
|
|
+ //Integer datediff = DateUtils.dateDiff(startDate, endDate);
|
|
|
|
+ //String startMonthDate = DateUtils.formatDate(DateUtils.addDay(startDate,-(datediff + 1) ) );
|
|
|
|
+ String beforeDate = DateUtils.formatDate(DateUtils.addDay(m.getStatDatetime(),-1));
|
|
|
|
+ //List<Long> accountIdsList = new ArrayList<>();
|
|
|
|
+ //accountIdsList.add(m.getAccountId());
|
|
|
|
+ BigDecimal costBefore = byteDanceVideoReportDailyMapper.getVideoReportDailyByDateAndSignature(beforeDate,beforeDate,m.getSignature(),accountIdsList);
|
|
|
|
+
|
|
|
|
+ BigDecimal huanbi =BigDecimal.ZERO;
|
|
|
|
+ if(costBefore != null && costBefore.compareTo(BigDecimal.ZERO)>0){
|
|
|
|
+ huanbi = m.getCost().subtract(costBefore).divide(costBefore,7, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ m.setHuanbi(huanbi);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return mList;
|
|
}
|
|
}
|
|
|
|
|
|
public String getColumnJson(Integer columnType){
|
|
public String getColumnJson(Integer columnType){
|
|
@@ -195,5 +502,9 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void accountVideoMap(){
|
|
|
|
+ List<AccountVideoDTO> accountVideoDTOList = byteDanceVideoReportDailyMapper.accountVideoMap();
|
|
|
|
+ byteDanceVideoReportDailyMapper.replaceIntoAccountVideoMapBatch(accountVideoDTOList);
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|