mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
管理端分析页统计图表接口数据结构修正;
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
package com.cf.imes.framework.common.constants;
|
||||
|
||||
/**
|
||||
* 统计图表常量
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2025/10/28 16:16
|
||||
*/
|
||||
public final class StatisticsConstants {
|
||||
|
||||
/**
|
||||
* 横轴日期列表key
|
||||
*/
|
||||
public static final String DATELIST_FIELD_NAME = "dateList";
|
||||
|
||||
/**
|
||||
* 纵轴数据列表key
|
||||
*/
|
||||
public static final String SERIES_FIELD_NAME = "series";
|
||||
}
|
||||
+2
-2
@@ -44,6 +44,8 @@ import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.DATELIST_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.SERIES_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.generateDateRangeAxis;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.getDateList;
|
||||
import static com.cf.imes.module.executor.enums.EsIndexEnum.ORDER_OPTIMIZE_PLATE_MODEL;
|
||||
@@ -76,8 +78,6 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
|
||||
private ElasticsearchClient client;
|
||||
|
||||
// 常用的字段key
|
||||
private static final String DATELIST_FIELD_NAME = "dateList";
|
||||
private static final String SERIES_FIELD_NAME = "series";
|
||||
private static final String ORDER_REMAIN_PLATE_MODEL_CREATE_TIME_FIELDNAME = "createTime";
|
||||
private static final String ORDER_REMAIN_PLATE_MODEL_GOODS_GROUP_NAME = "goods_group";
|
||||
private static final String ORDER_REMAIN_PLATE_MODEL_GOODS_COUNT_NAME = "goods_count";
|
||||
|
||||
+2
-4
@@ -40,6 +40,8 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.hutool.core.date.DatePattern.NORM_DATETIME_FORMATTER;
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.DATELIST_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.SERIES_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.generateDateRangeAxis;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.getDateList;
|
||||
@@ -70,10 +72,6 @@ public class OrganAmountServiceImpl implements OrganAmountService {
|
||||
@Resource
|
||||
private OrganMapper organMapper;
|
||||
|
||||
// 常用的字段key
|
||||
private static final String DATELIST_FIELD_NAME = "dateList";
|
||||
private static final String SERIES_FIELD_NAME = "series";
|
||||
|
||||
@Override
|
||||
public OrganAmountDO validOrganAmount(Long organId) {
|
||||
OrganAmountDO organAmountDO = organAmountMapper.selectOne(new LambdaQueryWrapper<OrganAmountDO>().eq(OrganAmountDO::getOrganId, organId));
|
||||
|
||||
+24
-6
@@ -8,13 +8,17 @@ import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.DATELIST_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.SERIES_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.generateDateRangeAxis;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.getDateList;
|
||||
|
||||
@@ -48,25 +52,39 @@ public class FundsStatisticsServiceImpl implements FundsStatisticsService {
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.groupingBy(FundsTradeTypeGroupStatisticsDO::getDate, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
List<Map<String, Object>> series = new ArrayList<>();
|
||||
Map<String, Object> rechargeSeriesItem = new HashMap<>();
|
||||
Map<String, Object> purchaseSeriesItem = new HashMap<>();
|
||||
BigDecimal[] rechargeCountArr = new BigDecimal[dateList.size()];
|
||||
BigDecimal[] purchaseCountArr = new BigDecimal[dateList.size()];
|
||||
// 遍历时间跨度列表,匹配数量存入数组,没有补0存入数组
|
||||
for (String dateStr : dateList) {
|
||||
BigDecimal[] countArr = new BigDecimal[2];
|
||||
for (int i = 0; i < dateList.size(); i++) {
|
||||
String dateStr = dateList.get(i);
|
||||
// 充值金额
|
||||
BigDecimal rechargeAmount = Optional.ofNullable(rechargeMap.get(dateStr))
|
||||
.map(list -> list.stream().findFirst().orElse(new FundsTradeTypeGroupStatisticsDO()))
|
||||
.map(FundsTradeTypeGroupStatisticsDO::getAmount)
|
||||
.orElse(BigDecimal.valueOf(0));
|
||||
countArr[0] = rechargeAmount;
|
||||
rechargeCountArr[i] = rechargeAmount;
|
||||
|
||||
// 软件购买金额
|
||||
BigDecimal purchaseAmount = Optional.ofNullable(purchaseMap.get(dateStr))
|
||||
.map(list -> list.stream().findFirst().orElse(new FundsTradeTypeGroupStatisticsDO()))
|
||||
.map(FundsTradeTypeGroupStatisticsDO::getAmount)
|
||||
.orElse(BigDecimal.valueOf(0));
|
||||
countArr[1] = purchaseAmount;
|
||||
|
||||
resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr);
|
||||
purchaseCountArr[i] = purchaseAmount;
|
||||
}
|
||||
rechargeSeriesItem.put("data", rechargeCountArr);
|
||||
rechargeSeriesItem.put("name", "充值");
|
||||
purchaseSeriesItem.put("data", purchaseCountArr);
|
||||
purchaseSeriesItem.put("name", "软件购买");
|
||||
series.add(rechargeSeriesItem);
|
||||
series.add(purchaseSeriesItem);
|
||||
|
||||
// x轴时间区间字符串
|
||||
resultMap.put(DATELIST_FIELD_NAME, dateList.stream().map(date -> generateDateRangeAxis(date, reqVO.getUnit())).toList());
|
||||
// 类别:类别:单量数组
|
||||
resultMap.put(SERIES_FIELD_NAME, series);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
+22
-6
@@ -78,6 +78,8 @@ import jakarta.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.DATELIST_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.SERIES_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.cf.imes.framework.common.util.json.JsonUtils.parseArray;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.generateDateRangeAxis;
|
||||
@@ -764,15 +766,20 @@ public class OrganServiceImpl implements OrganService {
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.groupingBy(OrgStatisticsIsLapseRespDTO::getDate, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
List<Map<String, Object>> series = new ArrayList<>();
|
||||
Map<String, Object> addSeriesItem = new HashMap<>();
|
||||
Map<String, Object> deleteSeriesItem = new HashMap<>();
|
||||
int[] addCountArr = new int[dateList.size()];
|
||||
int[] deleteCountArr = new int[dateList.size()];
|
||||
// 遍历时间跨度列表,匹配数量存入数组,没有补0存入数组
|
||||
for (String dateStr : dateList) {
|
||||
int[] countArr = new int[2];
|
||||
for (int i = 0; i < dateList.size(); i++) {
|
||||
String dateStr = dateList.get(i);
|
||||
// 组织有效数量
|
||||
Integer orderNotLapseCount = Optional.ofNullable(orderNotLapseRespMap.get(dateStr))
|
||||
.map(list -> list.stream().findFirst().orElse(new OrgStatisticsIsLapseRespDTO()))
|
||||
.map(OrgStatisticsIsLapseRespDTO::getOrgCount)
|
||||
.orElse(0);
|
||||
countArr[0] = orderNotLapseCount;
|
||||
addCountArr[i] = orderNotLapseCount;
|
||||
|
||||
|
||||
// 组织无效数量
|
||||
@@ -780,10 +787,19 @@ public class OrganServiceImpl implements OrganService {
|
||||
.map(list -> list.stream().findFirst().orElse(new OrgStatisticsIsLapseRespDTO()))
|
||||
.map(OrgStatisticsIsLapseRespDTO::getOrgCount)
|
||||
.orElse(0);
|
||||
countArr[1] = orderLapseCount;
|
||||
|
||||
resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr);
|
||||
deleteCountArr[i] = orderLapseCount;
|
||||
}
|
||||
addSeriesItem.put("data", addCountArr);
|
||||
addSeriesItem.put("name", "新增");
|
||||
deleteSeriesItem.put("data", deleteCountArr);
|
||||
deleteSeriesItem.put("name", "注销");
|
||||
series.add(addSeriesItem);
|
||||
series.add(deleteSeriesItem);
|
||||
|
||||
// x轴时间区间字符串
|
||||
resultMap.put(DATELIST_FIELD_NAME, dateList.stream().map(date -> generateDateRangeAxis(date, reqVO.getUnit())).toList());
|
||||
// 类别:类别:单量数组
|
||||
resultMap.put(SERIES_FIELD_NAME, series);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
+22
-6
@@ -75,6 +75,8 @@ import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.e
|
||||
import static com.cf.imes.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.generateDateRangeAxis;
|
||||
import static com.cf.imes.framework.common.util.time.StatisticsChangeUtils.getDateList;
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.DATELIST_FIELD_NAME;
|
||||
import static com.cf.imes.framework.common.constants.StatisticsConstants.SERIES_FIELD_NAME;
|
||||
import static com.cf.imes.module.system.dal.redis.RedisKeyConstants.OAUTH2_ACCESS_TOKEN;
|
||||
import static com.cf.imes.module.system.enums.ErrorCodeConstants.*;
|
||||
|
||||
@@ -828,15 +830,20 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.groupingBy(UserStatusGroupStatisticsDO::getDate, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
List<Map<String, Object>> series = new ArrayList<>();
|
||||
Map<String, Object> addSeriesItem = new HashMap<>();
|
||||
Map<String, Object> deleteSeriesItem = new HashMap<>();
|
||||
int[] addCountArr = new int[dateList.size()];
|
||||
int[] deleteCountArr = new int[dateList.size()];
|
||||
// 遍历时间跨度列表,匹配数量存入数组,没有补0存入数组
|
||||
for (String dateStr : dateList) {
|
||||
int[] countArr = new int[2];
|
||||
for (int i = 0; i < dateList.size(); i++) {
|
||||
String dateStr = dateList.get(i);
|
||||
// 新增数量
|
||||
Integer addCount = Optional.ofNullable(userAddMap.get(dateStr))
|
||||
.map(list -> list.stream().findFirst().orElse(new UserStatusGroupStatisticsDO()))
|
||||
.map(UserStatusGroupStatisticsDO::getUserCount)
|
||||
.orElse(0);
|
||||
countArr[0] = addCount;
|
||||
addCountArr[i] = addCount;
|
||||
|
||||
|
||||
// 注销数量
|
||||
@@ -844,10 +851,19 @@ public class AdminUserServiceImpl implements AdminUserService {
|
||||
.map(list -> list.stream().findFirst().orElse(new UserStatusGroupStatisticsDO()))
|
||||
.map(UserStatusGroupStatisticsDO::getUserCount)
|
||||
.orElse(0);
|
||||
countArr[1] = deleteCount;
|
||||
|
||||
resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr);
|
||||
deleteCountArr[i] = deleteCount;
|
||||
}
|
||||
addSeriesItem.put("data", addCountArr);
|
||||
addSeriesItem.put("name", "新增");
|
||||
deleteSeriesItem.put("data", deleteCountArr);
|
||||
deleteSeriesItem.put("name", "注销");
|
||||
series.add(addSeriesItem);
|
||||
series.add(deleteSeriesItem);
|
||||
|
||||
// x轴时间区间字符串
|
||||
resultMap.put(DATELIST_FIELD_NAME, dateList.stream().map(date -> generateDateRangeAxis(date, reqVO.getUnit())).toList());
|
||||
// 类别:类别:单量数组
|
||||
resultMap.put(SERIES_FIELD_NAME, series);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user