mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
分析页统计:生产单/排单数量、平方数统计接口回调数据格式修改为echarts标准,解决返回map自动根据key排序的问题
This commit is contained in:
+56
-13
@@ -156,7 +156,9 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
|
||||
seriesItem.put("name", orderStatusEnum.getDescription());
|
||||
series.add(seriesItem);
|
||||
}
|
||||
// x轴时间区间字符串
|
||||
resultMap.put(DATELIST_FIELD_NAME, dateList.stream().map(date -> generateDateRangeAxis(date, reqVO.getUnit())).toList());
|
||||
// 类别:订单类型:数量数组
|
||||
resultMap.put(SERIES_FIELD_NAME, series);
|
||||
|
||||
return resultMap;
|
||||
@@ -176,26 +178,42 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.groupingBy(OrderPlanStatisticsCountRespVO::getDate, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
// 类别:单量数组
|
||||
List<Map<String, Object>> series = new ArrayList<>();
|
||||
Map<String, Object> orderSeriesItem = new HashMap<>();
|
||||
Map<String, Object> planSeriesItem = new HashMap<>();
|
||||
int[] orderCountArr = new int[dateList.size()];
|
||||
int[] planCountArr = 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 orderCount = Optional.ofNullable(orderRespMap.get(dateStr))
|
||||
.map(list -> list.stream().findFirst().orElse(new OrderStatisticsStatusRespVO()))
|
||||
.map(OrderStatisticsStatusRespVO::getOrderCount)
|
||||
.orElse(0);
|
||||
countArr[0] = orderCount;
|
||||
orderCountArr[i] = orderCount;
|
||||
|
||||
// 存入排单数量
|
||||
Integer planCount = Optional.ofNullable(planRespMap.get(dateStr))
|
||||
.map(list -> list.stream().findFirst().orElse(new OrderPlanStatisticsCountRespVO()))
|
||||
.map(OrderPlanStatisticsCountRespVO::getCount)
|
||||
.orElse(0);
|
||||
countArr[1] = planCount;
|
||||
|
||||
resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), countArr);
|
||||
planCountArr[i] = planCount;
|
||||
}
|
||||
|
||||
orderSeriesItem.put("data", orderCountArr);
|
||||
orderSeriesItem.put("name", "生产单单量");
|
||||
planSeriesItem.put("data", planCountArr);
|
||||
planSeriesItem.put("name", "排单单量");
|
||||
series.add(orderSeriesItem);
|
||||
series.add(planSeriesItem);
|
||||
|
||||
// x轴时间区间字符串
|
||||
resultMap.put(DATELIST_FIELD_NAME, dateList.stream().map(date -> generateDateRangeAxis(date, reqVO.getUnit())).toList());
|
||||
// 类别:类别:单量数组
|
||||
resultMap.put(SERIES_FIELD_NAME, series);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@@ -213,21 +231,37 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
|
||||
.sorted(Comparator.naturalOrder())
|
||||
.collect(Collectors.groupingBy(OrderPlanStatisticsAreaRespVO::getDate, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
// 类别:平方数数组
|
||||
List<Map<String, Object>> series = new ArrayList<>();
|
||||
Map<String, Object> orderSeriesItem = new HashMap<>();
|
||||
Map<String, Object> planSeriesItem = new HashMap<>();
|
||||
BigDecimal[] orderAreaArr = new BigDecimal[dateList.size()];
|
||||
BigDecimal[] planAreaArr = new BigDecimal[dateList.size()];
|
||||
// 遍历时间跨度列表,匹配数量存入数组,没有补0存入数组
|
||||
for (String dateStr : dateList) {
|
||||
BigDecimal[] areaArr = new BigDecimal[2];
|
||||
for (int i = 0; i < dateList.size(); i++) {
|
||||
String dateStr = dateList.get(i);
|
||||
|
||||
// 存生产单面积
|
||||
List<OrderStatisticsAreaRespVO> orderCountRespVOS = orderRespMap.get(dateStr);
|
||||
areaArr[0] = orderCountRespVOS != null && !orderCountRespVOS.isEmpty() ? orderCountRespVOS.get(0).getAreaSum() : BigDecimal.ZERO;
|
||||
orderAreaArr[i] = orderCountRespVOS != null && !orderCountRespVOS.isEmpty() ? orderCountRespVOS.get(0).getAreaSum() : BigDecimal.ZERO;
|
||||
|
||||
// 存排单面积
|
||||
List<OrderPlanStatisticsAreaRespVO> planCountRespVOS = planRespMap.get(dateStr);
|
||||
areaArr[1] = planCountRespVOS != null && !planCountRespVOS.isEmpty() ? planCountRespVOS.get(0).getAreaSum() : BigDecimal.ZERO;
|
||||
|
||||
resultMap.put(generateDateRangeAxis(dateStr, reqVO.getUnit()), areaArr);
|
||||
planAreaArr[i] = planCountRespVOS != null && !planCountRespVOS.isEmpty() ? planCountRespVOS.get(0).getAreaSum() : BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
orderSeriesItem.put("data", orderAreaArr);
|
||||
orderSeriesItem.put("name", "生产单平方数");
|
||||
planSeriesItem.put("data", planAreaArr);
|
||||
planSeriesItem.put("name", "排单平方数");
|
||||
series.add(orderSeriesItem);
|
||||
series.add(planSeriesItem);
|
||||
|
||||
// x轴时间区间字符串
|
||||
resultMap.put(DATELIST_FIELD_NAME, dateList.stream().map(date -> generateDateRangeAxis(date, reqVO.getUnit())).toList());
|
||||
// 类别:类别:平方数数组
|
||||
resultMap.put(SERIES_FIELD_NAME, series);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@@ -297,7 +331,10 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
|
||||
seriesItem.put("name", goodsName);
|
||||
series.add(seriesItem);
|
||||
}
|
||||
|
||||
// x轴时间区间字符串
|
||||
resultMap.put(DATELIST_FIELD_NAME, dateList.stream().map(date -> generateDateRangeAxis(date, reqVO.getUnit())).toList());
|
||||
// 类别:大板信息:小板数量数组
|
||||
resultMap.put(SERIES_FIELD_NAME, series);
|
||||
return resultMap;
|
||||
}
|
||||
@@ -367,7 +404,10 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
|
||||
seriesItem.put("name", goodsName);
|
||||
series.add(seriesItem);
|
||||
}
|
||||
|
||||
// x轴时间区间字符串
|
||||
resultMap.put(DATELIST_FIELD_NAME, dateList.stream().map(date -> generateDateRangeAxis(date, reqVO.getUnit())).toList());
|
||||
// 类别:大板信息:小板平方数数组
|
||||
resultMap.put(SERIES_FIELD_NAME, series);
|
||||
return resultMap;
|
||||
}
|
||||
@@ -403,7 +443,7 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
|
||||
Aggregate goodsCountAgg = goodsCountAggMap.get(ORDER_REMAIN_PLATE_MODEL_GOODS_GROUP_NAME);
|
||||
|
||||
List<String> goodsIds = new ArrayList<>();
|
||||
// 构建map:{日期:{goodsId、count}}
|
||||
// 构建map:日期:goodsId、count
|
||||
Map<String, List<OrderGoodsPlateRespVO>> goodsDateGroupMap = new HashMap<>();
|
||||
/**
|
||||
* 获取数量最大前十的goodsId列表
|
||||
@@ -487,7 +527,10 @@ public class OrderStatisticsServiceImpl implements OrderStatisticsService {
|
||||
seriesItem.put("name", goodsName);
|
||||
series.add(seriesItem);
|
||||
}
|
||||
|
||||
// x轴时间区间字符串
|
||||
resultMap.put(DATELIST_FIELD_NAME, dateList.stream().map(date -> generateDateRangeAxis(date, unit)).toList());
|
||||
// 类别:大板信息:大板数量数组
|
||||
resultMap.put(SERIES_FIELD_NAME, series);
|
||||
} catch (IOException e) {
|
||||
log.error("[getBigPlateCountGroup][统计大板数量异常:{}]", e.getMessage(), e);
|
||||
|
||||
Reference in New Issue
Block a user