zhang_nuo
昨天 852cc8afa71b117f83759b0e1e97176800752c9a
src/main/java/com/ruoyi/sales/service/impl/MetricStatisticsServiceImpl.java
@@ -51,9 +51,16 @@
        map.put("total", new BigDecimal(totalOrders));
        map.put("shipRate", "0.00%");
        //  发货率
        //  产品销售数量
        List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(new LambdaQueryWrapper<SalesLedgerProduct>()
                .eq(SalesLedgerProduct::getType, 1));
        BigDecimal productQuantityTotal = CollectionUtils.isEmpty(products) ? BigDecimal.ZERO :
                products.stream()
                        .map(SalesLedgerProduct::getQuantity)
                        .filter(Objects::nonNull)
                        .reduce(BigDecimal.ZERO, BigDecimal::add);
        map.put("productQuantityTotal", productQuantityTotal);
        if (CollectionUtils.isEmpty(products)) {
            return AjaxResult.success(map);
        }
@@ -62,17 +69,10 @@
                .filter(p -> p.getId() != null && p.getSalesLedgerId() != null)
                .collect(Collectors.toMap(SalesLedgerProduct::getId, SalesLedgerProduct::getSalesLedgerId, (k1, k2) -> k1));
        List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>()
                .eq(ShippingInfo::getStatus, "审核通过"));
        List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(null);
        long shippedOrderCount = shippingInfos.stream()
                .filter(info -> productIdToLedgerIdMap.containsKey(info.getSalesLedgerProductId()))
                .map(info -> {
                    if (info.getSalesLedgerId() != null) {
                        return info.getSalesLedgerId();
                    }
                    return productIdToLedgerIdMap.get(info.getSalesLedgerProductId());
                })
                .map(ShippingInfo::getSalesLedgerId)
                .filter(Objects::nonNull)
                .distinct()
                .count();
@@ -116,6 +116,7 @@
        List<String> dateList = new ArrayList<>();
        List<BigDecimal> orderCountList = new ArrayList<>();
        List<BigDecimal> salesAmountList = new ArrayList<>();
        List<BigDecimal> productQuantityList = new ArrayList<>();
        List<BigDecimal> shippingRateList = new ArrayList<>();
        Calendar tempCalendar = Calendar.getInstance();
@@ -136,10 +137,12 @@
            if (dto != null) {
                orderCountList.add(new BigDecimal(dto.getOrderCount()));
                salesAmountList.add(dto.getSalesAmount() != null ? dto.getSalesAmount() : BigDecimal.ZERO);
                productQuantityList.add(dto.getProductQuantity() != null ? dto.getProductQuantity() : BigDecimal.ZERO);
                shippingRateList.add(new BigDecimal(String.valueOf(dto.getShipRate())));
            } else {
                orderCountList.add(BigDecimal.ZERO);
                salesAmountList.add(BigDecimal.ZERO);
                productQuantityList.add(BigDecimal.ZERO);
                shippingRateList.add(BigDecimal.ZERO);
            }
@@ -150,6 +153,7 @@
        map.put("dateList", dateList);
        map.put("orderCountList", orderCountList);
        map.put("salesAmountList", salesAmountList);
        map.put("productQuantityList", productQuantityList);
        map.put("shippingRateList", shippingRateList);
        return AjaxResult.success(map);
    }