From 67647a9bdb5ca2c0acf5c5f635ec28d2e4d6c9db Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 08 十月 2026 13:58:51 +0800
Subject: [PATCH] fix:countTodayByCreateTime方法加上null值判断
---
src/main/java/com/ruoyi/common/utils/OrderUtils.java | 23 +++++++++++++++++++----
1 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/ruoyi/common/utils/OrderUtils.java b/src/main/java/com/ruoyi/common/utils/OrderUtils.java
index a110ec9..b0cae7e 100644
--- a/src/main/java/com/ruoyi/common/utils/OrderUtils.java
+++ b/src/main/java/com/ruoyi/common/utils/OrderUtils.java
@@ -62,7 +62,14 @@
* @return 璁㈠崟缂栧彿
*/
public static <T> String countTodayByCreateTime(BaseMapper<T> mapper,String preFix,String code) {
- LocalDate today = LocalDate.now();
+ return countTodayByCreateTime(mapper, preFix,code,null);
+ }
+
+ public static <T> String countTodayByCreateTime(BaseMapper<T> mapper,String preFix,String code, LocalDateTime createTime) {
+ if (createTime == null) {
+ createTime = LocalDateTime.now();
+ }
+ LocalDate today = createTime.toLocalDate();
LocalDateTime todayStart = today.atStartOfDay();
LocalDateTime tomorrowStart = today.plusDays(1).atStartOfDay();
String dateStr = today.format(DateTimeFormatter.BASIC_ISO_DATE);
@@ -110,12 +117,20 @@
* @return 褰撳ぉ璁板綍鏁伴噺
*/
public static <T> String countAfterServiceTodayByCreateTime(BaseMapper<T> mapper,String preFix) {
+ return countAfterServiceTodayByCreateTime(mapper, preFix, null);
+ }
+
+ public static <T> String countAfterServiceTodayByCreateTime(BaseMapper<T> mapper,String preFix, LocalDateTime createTime) {
+ if (createTime == null) {
+ createTime = LocalDateTime.now();
+ }
+ LocalDate localDate = createTime.toLocalDate();
LocalDateTime todayStart = LocalDateTime.of(
- LocalDateTime.now().toLocalDate(),
+ localDate,
LocalTime.MIN
);
LocalDateTime todayEnd = LocalDateTime.of(
- LocalDateTime.now().toLocalDate(),
+ localDate,
LocalTime.MAX
);
@@ -127,6 +142,6 @@
.lt("create_time", endDate);
Long aLong = mapper.selectCount(queryWrapper);
- return preFix + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE).replaceAll("-", "") + String.format("%03d", (aLong + 1));
+ return preFix + localDate.format(DateTimeFormatter.ISO_LOCAL_DATE).replaceAll("-", "") + String.format("%03d", (aLong + 1));
}
}
--
Gitblit v1.9.3