From 889efb7e93a0fbef965b2c562bb21dcd9648780b Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期二, 31 三月 2026 17:31:54 +0800
Subject: [PATCH] 销售区
---
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java | 90 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 89 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
index 988804f..b0cc3bd 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -2529,10 +2529,98 @@
map.put("price",sum/1000);//鍗曚綅w
//鎬诲彂璐у崟
map.put("delivery",salesDeliveries.stream().count());
- //鎬婚攢鍞尯?
+ //鎬婚攢鍞柟鏁�
+ long volume = salesDeliveries.stream().mapToLong(value -> Long.parseLong(value.getVolume().toString())).sum();
+ map.put("volume",volume);
//绱瀹㈡埛
Long count = customerMapper.selectCount(null);
map.put("customer",count);
return map;
}
+
+ @Override
+ public String salesAnalysis(SalesDeliveryDto salesDeliveryDto) {
+ List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays());
+ return null;
+ }
+
+ @Override
+ public String salesRanking(SalesDeliveryDto salesDeliveryDto) {
+ List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays());
+ return null;
+ }
+
+ @Override
+ public String salesAmount(SalesDeliveryDto salesDeliveryDto) {
+ List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays());
+ return null;
+ }
+
+ @Override
+ public String salesDataRanking(SalesDeliveryDto salesDeliveryDto) {
+ List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays());
+ return null;
+ }
+
+ @Override
+ public SalesTotalDto customerTrends(SalesDeliveryDto salesDeliveryDto) {
+ SalesTotalDto salesTotalDto = new SalesTotalDto();
+ List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays());
+ List<Map<String, Long>> maps = new ArrayList<>();
+ for (LocalDate date : dates) {
+ LocalDate firstDay = date.with(TemporalAdjusters.firstDayOfMonth());
+ LocalDate lastDay = date.with(TemporalAdjusters.lastDayOfMonth());
+ Date startDate = Date.from(firstDay.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ Date endDate = Date.from(lastDay.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant());
+ List<Customer> customers = customerMapper.selectList(Wrappers.<Customer>lambdaQuery()
+ .between(Customer::getMaintenanceTime, startDate, endDate));
+ Map<String, Long> regionCountMap = Arrays.stream(AddressRegionEnum.values())
+ .filter(addressRegionEnum -> addressRegionEnum.getRegionName().equals("SELF_PICKUP"))
+ .collect(Collectors.toMap(
+ AddressRegionEnum::getRegionName, // 鍖哄煙鍚嶄綔涓簁ey
+ enumItem -> 0L // 鍒濆鍊煎叏閮ㄤ负0
+ ));
+ if (!CollectionUtils.isEmpty(customers)) {
+ regionCountMap = customers.stream()
+ // 璋冪敤鏂规硶灏嗗師濮嬪湴鍧�杞崲涓虹洰鏍囧尯鍩�
+ .map(customer -> AddressRegionEnum.matchRegion(customer.getCompanyAddress()).getRegionName())
+ // 杩囨护鎺夎浆鎹㈠け璐�/绌虹殑鍖哄煙锛堝彲閫夛紝鏍规嵁涓氬姟闇�姹傦級
+ .filter(region -> region != null && !region.isEmpty())
+ // 鎸夊尯鍩熷垎缁勶紝缁熻姣忎釜鍖哄煙鐨勬暟閲�
+ .collect(Collectors.groupingBy(
+ region -> region, // 鍒嗙粍渚濇嵁锛氳浆鎹㈠悗鐨勫尯鍩�
+ Collectors.counting() // 璁℃暟
+ ));
+ }
+ regionCountMap.put("ALLIN",customers.stream().count());
+ maps.add(regionCountMap);
+ }
+ salesTotalDto.setDates(dates);
+ salesTotalDto.setCustomerTrends(maps);
+ return salesTotalDto;
+ }
+
+ /**
+ * 鏍规嵁鍓嶇浼犲弬 骞�/鏈� 杞崲涓哄搴擫ocalDate鍒楄〃
+ * @param days 鍓嶇鍙傛暟锛�"骞�" / "鏈�"
+ * @return List<LocalDate>
+ */
+ public static List<LocalDate> convertDateList(String days) {
+ List<LocalDate> resultList = new ArrayList<>();
+ LocalDate now = LocalDate.now();
+ int currentYear = now.getYear();
+
+ if ("骞�".equals(days)) {
+ // 闇�姹傦細杩�5骞� 鈫� 姣忓勾鐨� 1鏈�1鏃�
+ for (int i = 0; i < 5; i++) {
+ resultList.add(LocalDate.of(currentYear - i, 1, 1));
+ }
+ } else if ("鏈�".equals(days)) {
+ // 闇�姹傦細褰撳勾12涓湀 鈫� 姣忔湀1鏃�
+ for (int month = 1; month <= 12; month++) {
+ resultList.add(LocalDate.of(currentYear, month, 1));
+ }
+ }
+ return resultList;
+ }
}
--
Gitblit v1.9.3