|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.ctop.toutiao.modules.report.service.impl;
|
|
|
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
import cn.com.ctop.common.module.vo.ByteDanceReportAccountDailyDTOEntity;
|
|
|
import cn.com.ctop.common.module.vo.SheetInfoVo;
|
|
@@ -38,7 +39,7 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
|
|
|
@Autowired
|
|
|
BytedanceAccountReportMapper bytedanceAccountReportMapper;
|
|
|
|
|
|
- private static final BigDecimal zero=BigDecimal.ZERO;
|
|
|
+ private static final BigDecimal zero = BigDecimal.ZERO;
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getSumDataBy(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate) {
|
|
@@ -51,12 +52,12 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
|
|
|
return result;
|
|
|
}
|
|
|
before = bytedanceAccountReportMapper.queryTodaySumByHour(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), after.getInteger("maxHour"), accounts);
|
|
|
- if(before==null){
|
|
|
+ if (before == null) {
|
|
|
before = after;
|
|
|
}
|
|
|
} else {
|
|
|
after = bytedanceAccountReportMapper.querySumByStartEndDate(endDate, startDate, accounts);
|
|
|
- if(after==null){
|
|
|
+ if (after == null) {
|
|
|
return result;
|
|
|
}
|
|
|
before = after;
|
|
@@ -67,16 +68,16 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
|
|
|
|
|
|
@Override
|
|
|
public List<JSONObject> getChartDataBy(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate) throws ParseException {
|
|
|
- List<JSONObject> result=new ArrayList<>();
|
|
|
+ List<JSONObject> result = new ArrayList<>();
|
|
|
String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.dicMapBy);
|
|
|
if (startDate.equals(endDate)) {
|
|
|
List<JSONObject> after = bytedanceAccountReportMapper.queryTodayDetailReportBy(filedAll, startDate, accounts);
|
|
|
List<JSONObject> before = bytedanceAccountReportMapper.queryTodayDetailReportBy(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), accounts);
|
|
|
- if(after.size()==0){
|
|
|
+ if (after.size() == 0) {
|
|
|
return result;
|
|
|
}
|
|
|
- if(before.size()==0){
|
|
|
- before=nullDataHandle();
|
|
|
+ if (before.size() == 0) {
|
|
|
+ before = nullDataHandle();
|
|
|
}
|
|
|
List<JSONObject> afterDis = this.countDiscountCost(mediaId, discount, after);
|
|
|
List<JSONObject> beforeDis = this.countDiscountCost(mediaId, discount, before);
|
|
@@ -84,13 +85,12 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
|
|
|
} else {
|
|
|
List<JSONObject> after;
|
|
|
//判断是不是日期间隔大于半年
|
|
|
- if(DateUtils.isMoreSixMonth(startDate,endDate)){
|
|
|
+ if (DateUtils.isMoreSixMonth(startDate, endDate)) {
|
|
|
after = bytedanceAccountReportMapper.queryDetailGroupMonthByDate(endDate, startDate, accounts);
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
after = bytedanceAccountReportMapper.queryDetailByStartEndDate(endDate, startDate, accounts);
|
|
|
}
|
|
|
- if(after==null){
|
|
|
+ if (after == null) {
|
|
|
return result;
|
|
|
}
|
|
|
result = this.countDiscountCost(mediaId, discount, after);
|
|
@@ -110,9 +110,9 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
|
|
|
result.add(beforeSum);
|
|
|
result.add(countTotal(afterSum, beforeSum));
|
|
|
} else {
|
|
|
- if(accounts.size()>1){
|
|
|
+ if (accounts.size() > 1) {
|
|
|
result = bytedanceAccountReportMapper.querySumByDateGroupAccount(filedAll, endDate, startDate, accounts, target, order);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
result = bytedanceAccountReportMapper.querySumByDateGroupAccountAndDate(filedAll, endDate, startDate, accounts, target, order);
|
|
|
}
|
|
|
result.add(bytedanceAccountReportMapper.queryAllSumByStartEndDate(filedAll, endDate, startDate, accounts));
|
|
@@ -187,45 +187,40 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
after.forEach((k, v) -> {
|
|
|
//去除没法计算的字段
|
|
|
- if (k.equals("accountId") || k.equals("authName") || v.toString().contains("%")||before.getString(k).contains("%")) {
|
|
|
+ if (k.equals("accountId") || k.equals("authName") || v.toString().contains("%") || before.getString(k).contains("%")) {
|
|
|
jsonObject.put(k, "-");
|
|
|
} else {
|
|
|
- jsonObject.put(k, LinkUtils.countLink(after.getBigDecimal(k)==null?zero:after.getBigDecimal(k), before.getBigDecimal(k)==null?zero:before.getBigDecimal(k)));
|
|
|
+ jsonObject.put(k, LinkUtils.countLink(after.getBigDecimal(k) == null ? zero : after.getBigDecimal(k), before.getBigDecimal(k) == null ? zero : before.getBigDecimal(k)));
|
|
|
}
|
|
|
});
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn){
|
|
|
+ public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceSaleProjectInfo(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn) {
|
|
|
|
|
|
- if(projectList==null || projectList.size()==0){
|
|
|
+ if (Check.isNull(projectList)) {
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
String userId = sysUser.getId();
|
|
|
- //String userId = "388e787edd294ecfb9243fe176a3ae56";
|
|
|
String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
|
|
|
-
|
|
|
List<Long> mediaIds = new ArrayList<>();
|
|
|
mediaIds.add(1L);
|
|
|
mediaIds.add(3L);
|
|
|
-
|
|
|
- if("admin".equals(roleCode)){
|
|
|
+ if ("admin".equals(roleCode)) {
|
|
|
projectList = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
|
|
|
- }else{
|
|
|
- projectList = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
|
|
|
+ } else {
|
|
|
+ projectList = bytedanceAccountReportMapper.getSaleProjects(userId, mediaIds);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- PageHelper.startPage(pageNum,pageSize);
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
List<ByteDanceReportAccountDailyDTO> p = bytedanceAccountReportMapper.getBytedanceProjectInfo(startDate, endDate, projectList, yn);
|
|
|
-
|
|
|
return new PageInfo<>(p);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public SheetInfoVo getBytedanceSaleProjectInfoSheetVO(String startDate, String endDate, List<Long> projectList, Integer pageNum, Integer pageSize, String sort, Integer yn) {
|
|
|
SheetInfoVo vo = new SheetInfoVo<ByteDanceReportAccountDailyDTOEntity>();
|
|
|
- if(projectList==null || projectList.size()==0){
|
|
|
+ if (Check.isNull(projectList)) {
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
String userId = sysUser.getId();
|
|
|
String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
|
|
@@ -234,14 +229,14 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
|
|
|
mediaIds.add(1L);
|
|
|
mediaIds.add(3L);
|
|
|
|
|
|
- if("admin".equals(roleCode)){
|
|
|
+ if ("admin".equals(roleCode)) {
|
|
|
projectList = bytedanceAccountReportMapper.queryProjectInfoByAdmin(mediaIds);
|
|
|
- }else{
|
|
|
- projectList = bytedanceAccountReportMapper.getSaleProjects(userId,mediaIds);
|
|
|
+ } else {
|
|
|
+ projectList = bytedanceAccountReportMapper.getSaleProjects(userId, mediaIds);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- PageHelper.startPage(pageNum,pageSize);
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
List<ByteDanceReportAccountDailyDTOEntity> dtos = bytedanceAccountReportMapper.getBytedanceProjectInfoEntity(startDate, endDate, projectList, yn);
|
|
|
vo.setSheetName("头条销售报表");
|
|
|
vo.setDetails(dtos);
|
|
@@ -249,7 +244,7 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort, Integer yn){
|
|
|
+ public PageInfo<ByteDanceReportAccountDailyDTO> getBytedanceAccountInfoByProjectId(String startDate, String endDate, Long projectId, Integer pageNo, Integer pageSize, String sort, Integer yn) {
|
|
|
|
|
|
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
//String userId = "e9ca23d68d884d4ebb19d07889727dae";
|
|
@@ -257,33 +252,33 @@ public class BytedanceAccountReportServiceImpl implements IBytedanceAccountRepor
|
|
|
String roleCode = bytedanceAccountReportMapper.getRoleCodeByUserId(userId);
|
|
|
|
|
|
List<Long> accountIds = null;
|
|
|
- if(projectId == null){
|
|
|
- if("admin".equals(roleCode)){
|
|
|
+ if (projectId == null) {
|
|
|
+ if ("admin".equals(roleCode)) {
|
|
|
accountIds = bytedanceAccountReportMapper.getUserProjectAccountIdsByAdmin();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
accountIds = bytedanceAccountReportMapper.getSaleProjectAccountIds(userId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(StringUtils.isBlank(sort)){
|
|
|
+ if (StringUtils.isBlank(sort)) {
|
|
|
sort = "cost-";
|
|
|
}
|
|
|
sort = sort.replace("-", " desc,").replace("+", " asc,"); //sort=id-name+age+
|
|
|
sort = sort.substring(0, sort.length() - 1);
|
|
|
- PageHelper.startPage(pageNo,pageSize,sort);
|
|
|
- return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate,endDate,projectId,accountIds,yn));
|
|
|
+ PageHelper.startPage(pageNo, pageSize, sort);
|
|
|
+ return new PageInfo<>(bytedanceAccountReportMapper.getBytedanceAccountInfoByProjectId(startDate, endDate, projectId, accountIds, yn));
|
|
|
}
|
|
|
|
|
|
- private List<JSONObject> nullDataHandle(){
|
|
|
- List<JSONObject> objectList= new ArrayList<>();
|
|
|
+ private List<JSONObject> nullDataHandle() {
|
|
|
+ List<JSONObject> objectList = new ArrayList<>();
|
|
|
JSONObject jsonObject;
|
|
|
- for(int i=0;i<24;i++){
|
|
|
- jsonObject=new JSONObject();
|
|
|
- jsonObject.put("cost",0);
|
|
|
- jsonObject.put("showNum",0);
|
|
|
- jsonObject.put("click",0);
|
|
|
- jsonObject.put("convertNum",0);
|
|
|
- jsonObject.put("statHour",i);
|
|
|
+ for (int i = 0; i < 24; i++) {
|
|
|
+ jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("cost", 0);
|
|
|
+ jsonObject.put("showNum", 0);
|
|
|
+ jsonObject.put("click", 0);
|
|
|
+ jsonObject.put("convertNum", 0);
|
|
|
+ jsonObject.put("statHour", i);
|
|
|
objectList.add(jsonObject);
|
|
|
}
|
|
|
return objectList;
|