maven
3 天以前 389b60c882b93a8e06600e1ab14c5b60a2a2878d
yys  修改bug
已修改1个文件
18 ■■■■■ 文件已修改
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -29,6 +29,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -78,6 +79,8 @@
    @Override
    public HomeBusinessDto business() {
        // 构建结果
        HomeBusinessDto homeBusinessDto = new HomeBusinessDto();
        LocalDate now = LocalDate.now();
        YearMonth currentMonth = YearMonth.from(now);
        // 创建LambdaQueryWrapper
@@ -85,6 +88,9 @@
        salesLedgerLambdaQueryWrapper.ge(SalesLedger::getEntryDate, currentMonth.atDay(1).atStartOfDay())  // 大于等于本月第一天
                .lt(SalesLedger::getEntryDate, currentMonth.plusMonths(1).atDay(1).atStartOfDay()); // 小于下月第一天
        List<SalesLedger> salesLedgers = salesLedgerMapper.selectList(salesLedgerLambdaQueryWrapper);
        if(CollectionUtils.isEmpty(salesLedgers)){
            return homeBusinessDto;
        }
        // 合计合同金额
        BigDecimal contractAmount = salesLedgers.stream().map(SalesLedger::getContractAmount)
                .filter(Objects::nonNull)
@@ -97,7 +103,8 @@
        BigDecimal noInvoiceAmountTotal = salesLedgerProducts.stream().map(SalesLedgerProduct::getNoInvoiceAmount)
                .filter(Objects::nonNull)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        homeBusinessDto.setMonthSaleMoney(contractAmount);
        homeBusinessDto.setMonthSaleHaveMoney(noInvoiceAmountTotal);
        // 创建LambdaQueryWrapper
        LambdaQueryWrapper<PurchaseLedger> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.ge(PurchaseLedger::getEntryDate, currentMonth.atDay(1).atStartOfDay())  // 大于等于本月第一天
@@ -105,6 +112,9 @@
        // 执行查询并计算总和
        List<PurchaseLedger> purchaseLedgers = purchaseLedgerMapper.selectList(queryWrapper);
        if(CollectionUtils.isEmpty(purchaseLedgers)){
            return homeBusinessDto;
        }
        LambdaQueryWrapper<SalesLedgerProduct> salesLedgerProductMapperLambdaQueryWrapperCopy = new LambdaQueryWrapper<SalesLedgerProduct>();
        salesLedgerProductMapperLambdaQueryWrapper.eq(SalesLedgerProduct::getType, 2)
@@ -142,15 +152,11 @@
                .map(ProcurementRecordStorage::getInboundNum)
                .filter(Objects::nonNull)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        // 构建结果
        HomeBusinessDto homeBusinessDto = new HomeBusinessDto();
        homeBusinessDto.setMonthSaleMoney(contractAmount);
        homeBusinessDto.setMonthSaleHaveMoney(noInvoiceAmountTotal);
        homeBusinessDto.setMonthPurchaseMoney(receiveAmount);
        homeBusinessDto.setMonthPurchaseHaveMoney(unReceiptPaymentAmount);
        homeBusinessDto.setInventoryNum(stock);
        homeBusinessDto.setTodayInventoryNum(stockAmount1);
        return homeBusinessDto;
    }