应该按照时间范围查询

This commit is contained in:
2025-07-15 16:59:06 +08:00
parent b524e12fb5
commit 6c13daead9

View File

@@ -61,11 +61,23 @@ public class OaReportScheduleServiceImpl implements IOaReportScheduleService {
private LambdaQueryWrapper<OaReportSchedule> buildQueryWrapper(OaReportScheduleBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<OaReportSchedule> lqw = Wrappers.lambdaQuery();
// 其他条件保持不变
lqw.eq(bo.getProjectId() != null, OaReportSchedule::getProjectId, bo.getProjectId());
lqw.like(StringUtils.isNotBlank(bo.getScheduleName()), OaReportSchedule::getScheduleName, bo.getScheduleName());
lqw.eq(bo.getType() != null, OaReportSchedule::getType, bo.getType());
lqw.eq(bo.getStartDate() != null, OaReportSchedule::getStartDate, bo.getStartDate());
lqw.eq(bo.getEndDate() != null, OaReportSchedule::getEndDate, bo.getEndDate());
// 将等于查询改为范围查询startDate <= 记录的开始时间 <= endDate
if (bo.getStartDate() != null && bo.getEndDate() != null) {
lqw.between(OaReportSchedule::getStartDate, bo.getStartDate(), bo.getEndDate())
.between(OaReportSchedule::getEndDate, bo.getStartDate(), bo.getEndDate());
} else if (bo.getStartDate() != null) {
lqw.ge(OaReportSchedule::getStartDate, bo.getStartDate()); // 大于等于开始时间
} else if (bo.getEndDate() != null) {
lqw.le(OaReportSchedule::getEndDate, bo.getEndDate()); // 小于等于结束时间
}
// 其他条件保持不变
lqw.eq(bo.getAmount() != null, OaReportSchedule::getAmount, bo.getAmount());
lqw.eq(StringUtils.isNotBlank(bo.getHeader()), OaReportSchedule::getHeader, bo.getHeader());
lqw.eq(StringUtils.isNotBlank(bo.getContactPhone()), OaReportSchedule::getContactPhone, bo.getContactPhone());
@@ -75,6 +87,7 @@ public class OaReportScheduleServiceImpl implements IOaReportScheduleService {
lqw.eq(StringUtils.isNotBlank(bo.getAccessory()), OaReportSchedule::getAccessory, bo.getAccessory());
lqw.eq(bo.getSort() != null, OaReportSchedule::getSort, bo.getSort());
lqw.eq(bo.getStatus() != null, OaReportSchedule::getStatus, bo.getStatus());
return lqw;
}