fix:【BPM 工作流】待办任务、已办任务,使用时间范围查询时,会拼接 OR 的情况(非完美修复方案)。

This commit is contained in:
YunaiV
2025-07-20 17:47:50 +08:00
parent dc7763ef0b
commit c645813725

View File

@@ -230,10 +230,10 @@ public class BpmTaskServiceImpl implements BpmTaskService {
if (StrUtil.isNotBlank(pageVO.getName())) {
taskQuery.taskNameLike("%" + pageVO.getName() + "%");
}
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
}
// if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
// taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
// taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
// }
// 执行查询
long count = taskQuery.count();
if (count == 0) {
@@ -244,6 +244,12 @@ public class BpmTaskServiceImpl implements BpmTaskService {
// 特殊:强制移除自动完成的“发起人”节点
// 补充说明:由于 taskQuery 无法方面的过滤,所以暂时通过内存过滤
tasks.removeIf(task -> task.getTaskDefinitionKey().equals(START_USER_NODE_ID));
// TODO @芋艿https://t.zsxq.com/MNzqp 【flowable bug】taskCreatedAfter、taskCreatedBefore 拼接的是 OR
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
tasks.removeIf(task -> task.getCreateTime() == null
|| task.getCreateTime().before(DateUtils.of(pageVO.getCreateTime()[0]))
|| task.getCreateTime().after(DateUtils.of(pageVO.getCreateTime()[1])));
}
return new PageResult<>(tasks, count);
}
@@ -259,16 +265,22 @@ public class BpmTaskServiceImpl implements BpmTaskService {
if (StrUtil.isNotEmpty(pageVO.getCategory())) {
taskQuery.taskCategory(pageVO.getCategory());
}
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
}
// if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
// taskQuery.taskCreatedAfter(DateUtils.of(pageVO.getCreateTime()[0]));
// taskQuery.taskCreatedBefore(DateUtils.of(pageVO.getCreateTime()[1]));
// }
// 执行查询
long count = taskQuery.count();
if (count == 0) {
return PageResult.empty();
}
List<HistoricTaskInstance> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
// TODO @芋艿https://t.zsxq.com/MNzqp 【flowable bug】taskCreatedAfter、taskCreatedBefore 拼接的是 OR
if (ArrayUtil.isNotEmpty(pageVO.getCreateTime())) {
tasks.removeIf(task -> task.getCreateTime() == null
|| task.getCreateTime().before(DateUtils.of(pageVO.getCreateTime()[0]))
|| task.getCreateTime().after(DateUtils.of(pageVO.getCreateTime()[1])));
}
return new PageResult<>(tasks, count);
}