diff --git a/src/main/java/com/ai/da/mapper/primary/DesignMapper.java b/src/main/java/com/ai/da/mapper/primary/DesignMapper.java index 2cc69ef9..1801da87 100644 --- a/src/main/java/com/ai/da/mapper/primary/DesignMapper.java +++ b/src/main/java/com/ai/da/mapper/primary/DesignMapper.java @@ -19,7 +19,7 @@ public interface DesignMapper extends CommonMapper { Long insertDesign(Design design); List getDesignStatistic(String startTime, String endTime, List ids, String email, - String role, String organizationName); + String role, String organizationName, boolean filterBySecond); List selectDeleteList(); } diff --git a/src/main/java/com/ai/da/service/impl/ConvenientInquiryServiceImpl.java b/src/main/java/com/ai/da/service/impl/ConvenientInquiryServiceImpl.java index 14992975..7d5011a8 100644 --- a/src/main/java/com/ai/da/service/impl/ConvenientInquiryServiceImpl.java +++ b/src/main/java/com/ai/da/service/impl/ConvenientInquiryServiceImpl.java @@ -149,7 +149,17 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl impleme .lt("create_date", endTime) .select("count(id) as count"); + // 如果startTime早于2024-05-01 00:00:00,添加额外的筛选条件 + LocalDateTime thresholdTime = LocalDateTime.of(2024, 5, 1, 0, 0, 0); + + try { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime startDateTime = LocalDateTime.parse(startTime, formatter); + + if (startDateTime.isBefore(thresholdTime)) { + // 使用 notLike 来排除以 ":01" 或 ":02" 结尾的时间 + // 方案2.1:使用 apply 方法执行数据库函数 (create_date 字段的实际存储格式(可能包含毫秒),所以取最后三个字符进行匹配) + queryWrapper.apply("DATE_FORMAT(create_date, '%s') NOT IN ('01', '02')"); + /*queryWrapper.notLike("create_date", "%:01") + .notLike("create_date", "%:02");*/ + } + } catch (Exception e) { + log.warn("Failed to parse startTime: {}, skip time-based filtering", startTime, e); + } + if (!Objects.isNull(accountIds) && !accountIds.isEmpty()) { queryWrapper.in("account_id", accountIds); } @@ -1676,7 +1695,7 @@ public class DesignServiceImpl extends ServiceImpl impleme List> result = baseMapper.selectMaps(queryWrapper); if (result != null && !result.isEmpty()) { Object countObj = result.get(0).get("count"); - return (Long) countObj; + return countObj != null ? ((Number) countObj).longValue() : 0L; } else { return 0L; } diff --git a/src/main/resources/mapper/primary/AccountMapper.xml b/src/main/resources/mapper/primary/AccountMapper.xml index df12240d..825dc459 100644 --- a/src/main/resources/mapper/primary/AccountMapper.xml +++ b/src/main/resources/mapper/primary/AccountMapper.xml @@ -61,10 +61,10 @@ - AND cd.create_time >= #{startTime} + AND create_time >= #{startTime} - AND cd.create_time <= #{endTime} + AND create_time <= #{endTime} GROUP BY account_id diff --git a/src/main/resources/mapper/primary/DesignMapper.xml b/src/main/resources/mapper/primary/DesignMapper.xml index 91e3d0a0..b0ca3da1 100644 --- a/src/main/resources/mapper/primary/DesignMapper.xml +++ b/src/main/resources/mapper/primary/DesignMapper.xml @@ -52,8 +52,10 @@ AND b.create_date between #{startTime} and #{endTime} - and b.create_date not like '%:01' - and b.create_date not like '%:02' + + and b.create_date not like '%:01' + and b.create_date not like '%:02' + and a.id in