From f8b236340b16d9dfe2ca88407343ac01f34f3cbf Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 21 五月 2026 15:09:42 +0800
Subject: [PATCH] Merge branch 'dev_New_pro' into dev_New_pro_财务
---
src/main/java/com/ruoyi/ai/tools/SalesAgentTools.java | 182 +++++++++++++++------------------------------
1 files changed, 61 insertions(+), 121 deletions(-)
diff --git a/src/main/java/com/ruoyi/ai/tools/SalesAgentTools.java b/src/main/java/com/ruoyi/ai/tools/SalesAgentTools.java
index b56144b..f9b09de 100644
--- a/src/main/java/com/ruoyi/ai/tools/SalesAgentTools.java
+++ b/src/main/java/com/ruoyi/ai/tools/SalesAgentTools.java
@@ -11,13 +11,9 @@
import com.ruoyi.basic.vo.CustomerVo;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.security.LoginUser;
-import com.ruoyi.sales.dto.InvoiceLedgerDto;
-import com.ruoyi.sales.mapper.InvoiceLedgerMapper;
-import com.ruoyi.sales.mapper.ReceiptPaymentMapper;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.sales.mapper.SalesQuotationMapper;
import com.ruoyi.sales.mapper.ShippingInfoMapper;
-import com.ruoyi.sales.pojo.ReceiptPayment;
import com.ruoyi.sales.pojo.SalesLedger;
import com.ruoyi.sales.pojo.SalesQuotation;
import com.ruoyi.sales.pojo.ShippingInfo;
@@ -34,16 +30,7 @@
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -62,8 +49,6 @@
private final SalesLedgerMapper salesLedgerMapper;
private final SalesQuotationMapper salesQuotationMapper;
private final ShippingInfoMapper shippingInfoMapper;
- private final ReceiptPaymentMapper receiptPaymentMapper;
- private final InvoiceLedgerMapper invoiceLedgerMapper;
private final SalesReceiptReturnMapper salesReceiptReturnMapper;
private final AiSessionUserContext aiSessionUserContext;
@@ -71,16 +56,12 @@
SalesLedgerMapper salesLedgerMapper,
SalesQuotationMapper salesQuotationMapper,
ShippingInfoMapper shippingInfoMapper,
- ReceiptPaymentMapper receiptPaymentMapper,
- InvoiceLedgerMapper invoiceLedgerMapper,
SalesReceiptReturnMapper salesReceiptReturnMapper,
AiSessionUserContext aiSessionUserContext) {
this.customerMapper = customerMapper;
this.salesLedgerMapper = salesLedgerMapper;
this.salesQuotationMapper = salesQuotationMapper;
this.shippingInfoMapper = shippingInfoMapper;
- this.receiptPaymentMapper = receiptPaymentMapper;
- this.invoiceLedgerMapper = invoiceLedgerMapper;
this.salesReceiptReturnMapper = salesReceiptReturnMapper;
this.aiSessionUserContext = aiSessionUserContext;
}
@@ -307,55 +288,56 @@
@P(value = "杩斿洖鏉℃暟锛岄粯璁�10锛屾渶澶�30", required = false) Integer limit) {
LoginUser loginUser = currentLoginUser(memoryId);
DateRange range = resolveDateRange(startDate, endDate, null);
- LambdaQueryWrapper<ReceiptPayment> wrapper = new LambdaQueryWrapper<>();
- applyTenantFilter(wrapper, loginUser.getTenantId(), ReceiptPayment::getTenantId);
- applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ReceiptPayment::getDeptId);
- wrapper.ge(ReceiptPayment::getReceiptPaymentDate, range.start())
- .le(ReceiptPayment::getReceiptPaymentDate, range.end())
- .orderByDesc(ReceiptPayment::getReceiptPaymentDate, ReceiptPayment::getId);
- List<ReceiptPayment> payments = defaultList(receiptPaymentMapper.selectList(wrapper));
- if (payments.isEmpty()) {
- return jsonResponse(true, "sales_customer_interaction_list", "鏈煡璇㈠埌瀹㈡埛寰�鏉ヨ褰�", rangeSummary(range, 0, keyword), Map.of("items", List.of()), Map.of());
- }
+// LambdaQueryWrapper<ReceiptPayment> wrapper = new LambdaQueryWrapper<>();
+// applyTenantFilter(wrapper, loginUser.getTenantId(), ReceiptPayment::getTenantId);
+// applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ReceiptPayment::getDeptId);
+// wrapper.ge(ReceiptPayment::getReceiptPaymentDate, range.start())
+// .le(ReceiptPayment::getReceiptPaymentDate, range.end())
+// .orderByDesc(ReceiptPayment::getReceiptPaymentDate, ReceiptPayment::getId);
+// List<ReceiptPayment> payments = defaultList(receiptPaymentMapper.selectList(wrapper));
+// if (payments.isEmpty()) {
+// return jsonResponse(true, "sales_customer_interaction_list", "鏈煡璇㈠埌瀹㈡埛寰�鏉ヨ褰�", rangeSummary(range, 0, keyword), Map.of("items", List.of()), Map.of());
+// }
+//
+// List<Long> ledgerIds = payments.stream()
+// .map(ReceiptPayment::getSalesLedgerId)
+// .filter(Objects::nonNull)
+// .distinct()
+// .collect(Collectors.toList());
+// Map<Long, SalesLedger> ledgerMap = defaultList(salesLedgerMapper.selectBatchIds(ledgerIds)).stream()
+// .filter(ledger -> tenantMatched(ledger.getTenantId(), loginUser.getTenantId()))
+// .collect(Collectors.toMap(SalesLedger::getId, item -> item, (a, b) -> a, LinkedHashMap::new));
+//
+// List<ReceiptPayment> filtered = payments.stream()
+// .filter(item -> matchInteractionKeyword(item, ledgerMap.get(item.getSalesLedgerId()), keyword))
+// .limit(normalizeLimit(limit))
+// .collect(Collectors.toList());
+//
+// BigDecimal totalReceiptAmount = filtered.stream()
+// .map(ReceiptPayment::getReceiptPaymentAmount)
+// .filter(Objects::nonNull)
+// .reduce(BigDecimal.ZERO, BigDecimal::add);
- List<Long> ledgerIds = payments.stream()
- .map(ReceiptPayment::getSalesLedgerId)
- .filter(Objects::nonNull)
- .distinct()
- .collect(Collectors.toList());
- Map<Long, SalesLedger> ledgerMap = defaultList(salesLedgerMapper.selectBatchIds(ledgerIds)).stream()
- .filter(ledger -> tenantMatched(ledger.getTenantId(), loginUser.getTenantId()))
- .collect(Collectors.toMap(SalesLedger::getId, item -> item, (a, b) -> a, LinkedHashMap::new));
+// List<Map<String, Object>> items = filtered.stream().map(item -> {
+// SalesLedger ledger = ledgerMap.get(item.getSalesLedgerId());
+// Map<String, Object> map = new LinkedHashMap<>();
+// map.put("id", item.getId());
+// map.put("salesLedgerId", item.getSalesLedgerId());
+// map.put("salesContractNo", ledger == null ? "" : safe(ledger.getSalesContractNo()));
+// map.put("customerName", ledger == null ? "" : safe(ledger.getCustomerName()));
+// map.put("projectName", ledger == null ? "" : safe(ledger.getProjectName()));
+// map.put("receiptPaymentDate", formatDate(item.getReceiptPaymentDate()));
+// map.put("receiptPaymentAmount", item.getReceiptPaymentAmount());
+// map.put("receiptPaymentType", safe(item.getReceiptPaymentType()));
+// map.put("registrant", safe(item.getRegistrant()));
+// return map;
+// }).collect(Collectors.toList());
- List<ReceiptPayment> filtered = payments.stream()
- .filter(item -> matchInteractionKeyword(item, ledgerMap.get(item.getSalesLedgerId()), keyword))
- .limit(normalizeLimit(limit))
- .collect(Collectors.toList());
-
- BigDecimal totalReceiptAmount = filtered.stream()
- .map(ReceiptPayment::getReceiptPaymentAmount)
- .filter(Objects::nonNull)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
-
- List<Map<String, Object>> items = filtered.stream().map(item -> {
- SalesLedger ledger = ledgerMap.get(item.getSalesLedgerId());
- Map<String, Object> map = new LinkedHashMap<>();
- map.put("id", item.getId());
- map.put("salesLedgerId", item.getSalesLedgerId());
- map.put("salesContractNo", ledger == null ? "" : safe(ledger.getSalesContractNo()));
- map.put("customerName", ledger == null ? "" : safe(ledger.getCustomerName()));
- map.put("projectName", ledger == null ? "" : safe(ledger.getProjectName()));
- map.put("receiptPaymentDate", formatDate(item.getReceiptPaymentDate()));
- map.put("receiptPaymentAmount", item.getReceiptPaymentAmount());
- map.put("receiptPaymentType", safe(item.getReceiptPaymentType()));
- map.put("registrant", safe(item.getRegistrant()));
- return map;
- }).collect(Collectors.toList());
-
- Map<String, Object> summary = rangeSummary(range, items.size(), keyword);
- summary.put("totalReceiptAmount", totalReceiptAmount);
- summary.put("customerCount", items.stream().map(item -> String.valueOf(item.get("customerName"))).filter(StringUtils::hasText).distinct().count());
- return jsonResponse(true, "sales_customer_interaction_list", "宸茶繑鍥炲鎴峰線鏉ユ槑缁�", summary, Map.of("items", items), Map.of());
+// Map<String, Object> summary = rangeSummary(range, items.size(), keyword);
+// summary.put("totalReceiptAmount", totalReceiptAmount);
+// summary.put("customerCount", items.stream().map(item -> String.valueOf(item.get("customerName"))).filter(StringUtils::hasText).distinct().count());
+// return jsonResponse(true, "sales_customer_interaction_list", "宸茶繑鍥炲鎴峰線鏉ユ槑缁�", summary, Map.of("items", items), Map.of());
+ return jsonResponse(true, "sales_customer_interaction_list", "宸茶繑鍥炲鎴峰線鏉ユ槑缁�", null, Map.of("items", List.of()), Map.of());
}
@Tool(name = "鏌ヨ鍙戣揣鍙拌处", value = "鎸夊叧閿瘝鍜屾椂闂磋寖鍥存煡璇㈠彂璐у彴璐�")
@@ -426,7 +408,7 @@
List<SalesLedger> ledgers = querySalesLedgers(loginUser, range);
List<SalesQuotation> quotations = querySalesQuotations(loginUser, range);
List<ShippingInfo> shippings = queryShippings(loginUser, range);
- List<ReceiptPayment> receipts = queryReceipts(loginUser, range);
+
BigDecimal contractAmountTotal = ledgers.stream()
.map(SalesLedger::getContractAmount)
@@ -436,11 +418,6 @@
.map(SalesQuotation::getTotalAmount)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
- BigDecimal receivedAmountTotal = receipts.stream()
- .map(ReceiptPayment::getReceiptPaymentAmount)
- .filter(Objects::nonNull)
- .reduce(BigDecimal.ZERO, BigDecimal::add);
- BigDecimal pendingAmountTotal = maxZero(contractAmountTotal.subtract(receivedAmountTotal));
long shippingCount = shippings.size();
long shippedCount = shippings.stream().filter(item -> isShippedStatus(item.getStatus())).count();
@@ -460,11 +437,12 @@
summary.put("shipRate", shipRate);
summary.put("contractAmountTotal", contractAmountTotal);
summary.put("quotationAmountTotal", quotationAmountTotal);
- summary.put("receivedAmountTotal", receivedAmountTotal);
- summary.put("pendingAmountTotal", pendingAmountTotal);
+ summary.put("receivedAmountTotal", BigDecimal.ZERO);
+ summary.put("pendingAmountTotal", BigDecimal.ZERO);
Map<String, Object> charts = new LinkedHashMap<>();
- charts.put("amountBarOption", buildAmountBarOption(contractAmountTotal, quotationAmountTotal, receivedAmountTotal, pendingAmountTotal));
+// charts.put("amountBarOption", buildAmountBarOption(contractAmountTotal, quotationAmountTotal, receivedAmountTotal, pendingAmountTotal));
+ charts.put("amountBarOption", buildAmountBarOption(contractAmountTotal, quotationAmountTotal, BigDecimal.ONE, BigDecimal.ONE));
charts.put("shippingPieOption", buildShippingPieOption(shippedCount, Math.max(shippingCount - shippedCount, 0)));
charts.put("customerTopBarOption", buildCustomerTopBarOption(topCustomers));
charts.put("contractTrendLineOption", buildContractTrendLineOption(trendData.labels(), trendData.values()));
@@ -858,28 +836,6 @@
return defaultList(shippingInfoMapper.selectList(wrapper));
}
- private List<ReceiptPayment> queryReceipts(LoginUser loginUser, DateRange range) {
- LambdaQueryWrapper<ReceiptPayment> wrapper = new LambdaQueryWrapper<>();
- applyTenantFilter(wrapper, loginUser.getTenantId(), ReceiptPayment::getTenantId);
- applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ReceiptPayment::getDeptId);
- if (range != null) {
- wrapper.ge(ReceiptPayment::getReceiptPaymentDate, range.start())
- .le(ReceiptPayment::getReceiptPaymentDate, range.end());
- }
- return defaultList(receiptPaymentMapper.selectList(wrapper));
- }
-
- private List<ReceiptPayment> queryReceiptsByLedgerIds(LoginUser loginUser, List<Long> ledgerIds) {
- if (ledgerIds == null || ledgerIds.isEmpty()) {
- return List.of();
- }
- LambdaQueryWrapper<ReceiptPayment> wrapper = new LambdaQueryWrapper<>();
- applyTenantFilter(wrapper, loginUser.getTenantId(), ReceiptPayment::getTenantId);
- applyDeptFilter(wrapper, loginUser.getCurrentDeptId(), ReceiptPayment::getDeptId);
- wrapper.in(ReceiptPayment::getSalesLedgerId, ledgerIds);
- return defaultList(receiptPaymentMapper.selectList(wrapper));
- }
-
private List<ShippingInfo> queryShippingsByLedgerIds(LoginUser loginUser, List<Long> ledgerIds) {
if (ledgerIds == null || ledgerIds.isEmpty()) {
return List.of();
@@ -896,23 +852,18 @@
return Map.of();
}
Map<Long, BigDecimal> result = new HashMap<>();
- for (InvoiceLedgerDto item : defaultList(invoiceLedgerMapper.invoicedTotal(ledgerIds))) {
- if (item.getSalesLedgerId() == null) {
- continue;
- }
- result.merge(item.getSalesLedgerId().longValue(), defaultDecimal(item.getInvoiceTotal()), BigDecimal::add);
- }
+// for (InvoiceLedgerDto item : defaultList(invoiceLedgerMapper.invoicedTotal(ledgerIds))) {
+// if (item.getSalesLedgerId() == null) {
+// continue;
+// }
+// result.merge(item.getSalesLedgerId().longValue(), defaultDecimal(item.getInvoiceTotal()), BigDecimal::add);
+// }
return result;
}
private Map<Long, BigDecimal> sumReceiptAmounts(LoginUser loginUser, List<Long> ledgerIds) {
Map<Long, BigDecimal> result = new HashMap<>();
- for (ReceiptPayment item : queryReceiptsByLedgerIds(loginUser, ledgerIds)) {
- if (item.getSalesLedgerId() == null) {
- continue;
- }
- result.merge(item.getSalesLedgerId(), defaultDecimal(item.getReceiptPaymentAmount()), BigDecimal::add);
- }
+
return result;
}
@@ -952,17 +903,6 @@
|| safe(customer.getContactPhone()).contains(text)
|| safe(customer.getCompanyPhone()).contains(text)
|| safe(customer.getUsageUserName()).contains(text);
- }
-
- private boolean matchInteractionKeyword(ReceiptPayment payment, SalesLedger ledger, String keyword) {
- if (!StringUtils.hasText(keyword)) {
- return true;
- }
- String text = keyword.trim();
- return safe(payment.getRegistrant()).contains(text)
- || (ledger != null && (safe(ledger.getCustomerName()).contains(text)
- || safe(ledger.getSalesContractNo()).contains(text)
- || safe(ledger.getProjectName()).contains(text)));
}
private boolean matchLedgerCustomerKeyword(SalesLedger ledger, String keyword) {
--
Gitblit v1.9.3