From 4ec71930da15cc83b2fbf67fdeade89b8900b14c Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期二, 31 三月 2026 17:32:36 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_宁夏_中盛建材' into dev_宁夏_中盛建材

---
 src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java |  100 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 96 insertions(+), 4 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..e59bd8d 100644
--- a/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -2525,14 +2525,106 @@
         Map<String, Long> map = new HashMap<>();
         //鎬婚攢鍞噾棰�
         List<SalesDelivery> salesDeliveries = salesDeliveryMapper.selectList(null);
-        long sum = salesDeliveries.stream().mapToLong(value -> Long.parseLong(value.getPrice().toString())).sum();
-        map.put("price",sum/1000);//鍗曚綅w
+        BigDecimal sum = salesDeliveries.stream()
+                .map(item -> item.getPrice() != null ? new BigDecimal(item.getPrice().toString()) : BigDecimal.ZERO)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        long finalPrice = sum.divide(new BigDecimal("1000"), 0, RoundingMode.HALF_UP).longValue();
+
+        map.put("price", finalPrice);//鍗曚綅w
         //鎬诲彂璐у崟
-        map.put("delivery",salesDeliveries.stream().count());
-        //鎬婚攢鍞尯?
+        map.put("delivery", (long) salesDeliveries.size());
+        //鎬婚攢鍞柟鏁�
+        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