From f65f8494fd2e292e5c15c02112fa9217ce655361 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 29 四月 2026 10:22:03 +0800
Subject: [PATCH] fix: 收入管理根据收款方式查询错误
---
src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java | 113 ++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 88 insertions(+), 25 deletions(-)
diff --git a/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java b/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java
index 0439103..1d197f1 100644
--- a/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java
+++ b/src/main/java/com/ruoyi/account/service/impl/AccountIncomeServiceImpl.java
@@ -1,30 +1,30 @@
package com.ruoyi.account.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.account.dto.AccountDto2;
import com.ruoyi.account.dto.AccountDto3;
-import com.ruoyi.account.mapper.AccountFileMapper;
+import com.ruoyi.account.dto.ReportDateDto;
import com.ruoyi.account.mapper.AccountIncomeMapper;
-import com.ruoyi.account.pojo.AccountFile;
import com.ruoyi.account.pojo.AccountIncome;
-import com.ruoyi.account.service.AccountFileService;
import com.ruoyi.account.service.AccountIncomeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.dto.DateQueryDto;
-import com.ruoyi.quality.pojo.QualityInspect;
+import com.ruoyi.project.system.domain.SysDictData;
+import com.ruoyi.project.system.mapper.SysDictDataMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Collections;
import java.util.List;
-import java.util.Map;
+import java.util.stream.Collectors;
@AllArgsConstructor
@Service
@@ -32,11 +32,44 @@
private AccountIncomeMapper accountIncomeMapper;
+ private SysDictDataMapper sysDictDataMapper;
+
//鍒嗛〉鏌ヨ
@Override
public IPage<AccountIncome> accountIncomeListPage(Page page, AccountIncome accountIncome) {
+ resolveIncomeMethodLabelFilter(accountIncome);
return accountIncomeMapper.accountIncomeListPage(page,accountIncome);
+ }
+
+ private void resolveIncomeMethodLabelFilter(AccountIncome accountIncome) {
+ if (accountIncome == null) {
+ return;
+ }
+ if (accountIncome.getIncomeMethodLabel() == null || accountIncome.getIncomeMethodLabel().trim().isEmpty()) {
+ return;
+ }
+ String targetLabel = accountIncome.getIncomeMethodLabel().trim();
+ List<String> paymentMethodList = selectDictValuesByLabel("payment_methods", targetLabel);
+ List<String> receiptPaymentMethodList = selectDictValuesByLabel("receipt_payment_type", targetLabel);
+ if (paymentMethodList.isEmpty()) {
+ paymentMethodList = Collections.singletonList("__NO_MATCH__");
+ }
+ if (receiptPaymentMethodList.isEmpty()) {
+ receiptPaymentMethodList = Collections.singletonList("__NO_MATCH__");
+ }
+ accountIncome.setPaymentMethodList(paymentMethodList);
+ accountIncome.setReceiptPaymentMethodList(receiptPaymentMethodList);
+ accountIncome.setIncomeMethod(null);
+ }
+
+ private List<String> selectDictValuesByLabel(String dictType, String label) {
+ return sysDictDataMapper.selectDictDataByType(dictType).stream()
+ .filter(item -> label.equals(item.getDictLabel()))
+ .map(SysDictData::getDictValue)
+ .filter(v -> v != null && !v.trim().isEmpty())
+ .distinct()
+ .collect(Collectors.toList());
}
//瀵煎嚭
@@ -49,25 +82,55 @@
//璐㈠姟鎶ヨ〃骞存煡璇�
@Override
- public AccountDto3 reportIncome() {
- AccountDto3 accountDto3 = new AccountDto3();
+ public List<AccountDto3> reportIncome(ReportDateDto reportDateDto) {
+ List<AccountDto3> accountDto3s = new ArrayList<>();
+ //鍏堟煡璇㈡敹鍏ョ被鍨嬫湁鍝簺
+ List<SysDictData> incomeTypes = sysDictDataMapper.selectDictDataByType("income_types");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
- int currentYear = LocalDate.now().getYear(); // 鑾峰彇褰撳墠骞翠唤锛堝2025锛�
- List<String> months = new ArrayList<>();
- Map<String, List<AccountDto2>> map = new HashMap<>();
- for (int i = 1; i <= 12; i++) {
- months.add(i + "鏈�");
- // 褰撴湀绗竴澶╋細骞翠唤涓哄綋鍓嶅勾锛屾湀浠戒负i锛屾棩鏈熶负1
- LocalDate firstDay = LocalDate.of(currentYear, i, 1);
- DateQueryDto dateQueryDto = new DateQueryDto();
- dateQueryDto.setEntryDateStart(firstDay.format(formatter));
- // 褰撴湀鏈�鍚庝竴澶╋細绗竴澶╃殑鏈堜唤鐨勬渶鍚庝竴澶�
- dateQueryDto.setEntryDateEnd(firstDay.plusMonths(1).minusDays(1).format(formatter));
- List<AccountDto2> report = accountIncomeMapper.report(dateQueryDto);
- map.put(i + "鏈�",report);
+// int currentYear = LocalDate.now().getYear(); // 鑾峰彇褰撳墠骞翠唤锛堝2025锛�
+ for (SysDictData incomeType : incomeTypes) {
+ AccountDto3 accountDto3 = new AccountDto3();
+ accountDto3.setTypeName(incomeType.getDictLabel());//绫诲瀷
+ List<BigDecimal> account=new ArrayList<>();
+ LocalDate startDate = reportDateDto.getEntryDateStart();
+ LocalDate endDate = reportDateDto.getEntryDateEnd();
+
+ // 鍒濆鍖栧惊鐜彉閲忎负璧峰鏃ユ湡
+ LocalDate currentDate = startDate;
+
+ // 寰幆锛氬綋鍓嶆棩鏈熶笉瓒呰繃缁撴潫鏃ユ湡鏃剁户缁�
+ while (!currentDate.isAfter(endDate)) {
+ // 褰撴湀绗竴澶�
+ LocalDate firstDay = currentDate.withDayOfMonth(1);
+ DateQueryDto dateQueryDto = new DateQueryDto();
+ dateQueryDto.setEntryDateStart(firstDay.format(formatter));
+
+ // 褰撴湀鏈�鍚庝竴澶�
+ LocalDate lastDay = firstDay.plusMonths(1).minusDays(1);
+ dateQueryDto.setEntryDateEnd(lastDay.format(formatter));
+
+ // 绱姞鏁版嵁
+ account.add(accountIncomeMapper.report1(dateQueryDto, incomeType.getDictValue()));
+
+ // 鏈堜唤鍔犱竴锛堣嚜鍔ㄥ鐞嗚法骞达紝姣斿12鏈堝姞1涓湀浼氬彉鎴愪笅涓�骞�1鏈堬級
+ currentDate = currentDate.plusMonths(1);
+ }
+ accountDto3.setAccount(account);//绫诲瀷
+ accountDto3s.add(accountDto3);
}
- accountDto3.setMonth(months);
- accountDto3.setAccountType(map);
- return accountDto3;
+ return accountDto3s;
+ }
+
+ @Override
+ public AccountIncome getByInvoiceNumber(String purchaseContractNumber) {
+ AccountIncome accountIncome = accountIncomeMapper.selectOne(new LambdaQueryWrapper<AccountIncome>()
+ .eq(AccountIncome::getInvoiceNumber, purchaseContractNumber));
+ return accountIncome;
+ }
+
+ @Override
+ public List<AccountIncome> getByInvoiceNumberList(String purchaseContractNumber) {
+ return accountIncomeMapper.selectList(new LambdaQueryWrapper<AccountIncome>()
+ .eq(AccountIncome::getInvoiceNumber, purchaseContractNumber));
}
}
--
Gitblit v1.9.3