From eb63e4dfa4355191271ac603bb1b7808259cfcd4 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 29 一月 2026 18:31:57 +0800
Subject: [PATCH] feat: 支收对比分析统计DTO
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 68 ++++++++++------------------------
1 files changed, 20 insertions(+), 48 deletions(-)
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index 7464933..f62f179 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -1,7 +1,6 @@
package com.ruoyi.sales.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
@@ -9,14 +8,11 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.account.pojo.AccountIncome;
import com.ruoyi.account.service.AccountIncomeService;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.mapper.ProductMapper;
import com.ruoyi.basic.mapper.ProductModelMapper;
import com.ruoyi.basic.pojo.Customer;
-import com.ruoyi.basic.pojo.Product;
-import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.common.enums.FileNameType;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils;
@@ -27,7 +23,6 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.other.mapper.TempFileMapper;
import com.ruoyi.other.pojo.TempFile;
-import com.ruoyi.production.dto.ProductStructureDto;
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
import com.ruoyi.project.system.domain.SysDept;
@@ -151,6 +146,7 @@
private ProductMapper productMapper;
@Autowired
private ProductStructureMapper productStructureMapper;
+;
@Override
public List<SalesLedger> selectSalesLedgerList(SalesLedgerDto salesLedgerDto) {
@@ -267,75 +263,51 @@
@Override
public List<MonthlyAmountDto> getAmountHalfYear(Integer type) {
+
LocalDate now = LocalDate.now();
- LocalDateTime currentDateTime = LocalDateTime.now();
-
- // 鏍规嵁 type 纭畾鏌ヨ鐨勬椂闂撮棿闅旓紙澶╂暟锛夊拰鎬绘煡璇㈠ぉ鏁�
- int daysPerPeriod;
- int totalDays;
- switch (type) {
- case 1:
- daysPerPeriod = 5; // 姣�5澶╂煡涓�娆�
- totalDays = 30; // 6娆� 脳 5澶� = 30澶�
- break;
- case 2:
- daysPerPeriod = 15; // 姣�15澶╂煡涓�娆�
- totalDays = 90; // 6娆� 脳 15澶� = 90澶�
- break;
- case 3:
- daysPerPeriod = 30; // 姣�30澶╂煡涓�娆�
- totalDays = 180; // 6娆� 脳 30澶� = 180澶�
- break;
- default:
- throw new IllegalArgumentException("Invalid type value: " + type);
- }
-
List<MonthlyAmountDto> result = new ArrayList<>();
- // 寰幆6娆★紝姣忔鏌ヨ涓�涓椂闂存鐨勬暟鎹�
- for (int i = 0; i < 6; i++) {
- // 璁$畻褰撳墠鏃堕棿娈电殑璧峰鍜岀粨鏉熸椂闂�
- LocalDateTime endTime = currentDateTime.minusDays(i * daysPerPeriod);
- LocalDateTime startTime = endTime.minusDays(daysPerPeriod);
+ for (int i = 5; i >= 0; i--) {
+ YearMonth yearMonth = YearMonth.from(now.minusMonths(i));
+ LocalDateTime startTime = yearMonth.atDay(1).atStartOfDay();
+ LocalDateTime endTime = yearMonth.atEndOfMonth().atTime(23, 59, 59);
- // 鏌ヨ鍥炴閲戦
+ // 鍥炴閲戦
LambdaQueryWrapper<ReceiptPayment> receiptPaymentQuery = new LambdaQueryWrapper<>();
receiptPaymentQuery
.ge(ReceiptPayment::getCreateTime, startTime)
- .lt(ReceiptPayment::getCreateTime, endTime);
- List<ReceiptPayment> receiptPayments = receiptPaymentMapper.selectList(receiptPaymentQuery);
+ .le(ReceiptPayment::getCreateTime, endTime);
- // 鏌ヨ寮�绁ㄩ噾棰�
- LambdaQueryWrapper<InvoiceLedger> invoiceLedgerQuery = new LambdaQueryWrapper<>();
- invoiceLedgerQuery
- .ge(InvoiceLedger::getCreateTime, startTime)
- .lt(InvoiceLedger::getCreateTime, endTime);
- List<InvoiceLedger> invoiceLedgers = invoiceLedgerMapper.selectList(invoiceLedgerQuery);
+ List<ReceiptPayment> receiptPayments =
+ receiptPaymentMapper.selectList(receiptPaymentQuery);
- // 璁$畻鍥炴鎬婚
BigDecimal receiptAmount = receiptPayments.stream()
.map(ReceiptPayment::getReceiptPaymentAmount)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
- // 璁$畻寮�绁ㄦ�婚
+ // 寮�绁ㄩ噾棰�
+ LambdaQueryWrapper<InvoiceLedger> invoiceLedgerQuery = new LambdaQueryWrapper<>();
+ invoiceLedgerQuery
+ .ge(InvoiceLedger::getCreateTime, startTime)
+ .le(InvoiceLedger::getCreateTime, endTime);
+
+ List<InvoiceLedger> invoiceLedgers =
+ invoiceLedgerMapper.selectList(invoiceLedgerQuery);
+
BigDecimal invoiceAmount = invoiceLedgers.stream()
.map(InvoiceLedger::getInvoiceTotal)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
- // 鏋勯�犺繑鍥炵殑 DTO
MonthlyAmountDto dto = new MonthlyAmountDto();
- dto.setMonth(startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + " ~ " +
- endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
+ dto.setMonth(yearMonth.format(DateTimeFormatter.ofPattern("yyyy-MM")));
dto.setReceiptAmount(receiptAmount);
dto.setInvoiceAmount(invoiceAmount);
result.add(dto);
}
- // 鍙嶈浆鍒楄〃锛屼娇鏃堕棿椤哄簭浠庢棭鍒版櫄
- Collections.reverse(result);
return result;
}
--
Gitblit v1.9.3