diff --git a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettleInvoiceRecordServiceImpl.java b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettleInvoiceRecordServiceImpl.java index 8eb2cda3d..8583a5f70 100644 --- a/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettleInvoiceRecordServiceImpl.java +++ b/emis-biz/src/main/java/com/xdadan/erp/emis/service/impl/EmisSettleInvoiceRecordServiceImpl.java @@ -578,7 +578,21 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen } // 格式化客户付款日期(格式:2025/10/30 付款2000元 A公司) - for (PaymentGroup group : paymentGroupMap.values()) { + // 按日期从小到大排序 + List sortedPaymentGroups = new ArrayList<>(paymentGroupMap.values()); + sortedPaymentGroups.sort((g1, g2) -> { + if (g1.date == null && g2.date == null) { + return 0; + } + if (g1.date == null) { + return -1; + } + if (g2.date == null) { + return 1; + } + return g1.date.compareTo(g2.date); + }); + for (PaymentGroup group : sortedPaymentGroups) { BigDecimal strippedMoney = group.totalMoney.stripTrailingZeros(); String paymentDateStr = group.dateStr + " 付款" + strippedMoney.toPlainString() + "元"; // 如果客户名称不为空,则追加客户名称 @@ -589,7 +603,21 @@ public class EmisSettleInvoiceRecordServiceImpl extends EmisBaseService implemen } // 格式化收款登记日期(格式:2025/10/30 登记2000元 A公司) - for (PaymentGroup group : registerGroupMap.values()) { + // 按日期从小到大排序 + List sortedRegisterGroups = new ArrayList<>(registerGroupMap.values()); + sortedRegisterGroups.sort((g1, g2) -> { + if (g1.date == null && g2.date == null) { + return 0; + } + if (g1.date == null) { + return -1; + } + if (g2.date == null) { + return 1; + } + return g1.date.compareTo(g2.date); + }); + for (PaymentGroup group : sortedRegisterGroups) { BigDecimal strippedMoney = group.totalMoney.stripTrailingZeros(); String registerDateStr = group.dateStr + " 登记" + strippedMoney.toPlainString() + "元"; // 如果客户名称不为空,则追加客户名称