0

我需要解决方案,我需要检查重叠、结束开始匹配和开始结束匹配,例如

startDateTime=2020-10-24T11:30:34 endDateTime=2020-10-27T17:00:02

jpqlQuery.where(
                (
                    (start.loe(startDateTime)
                    .and(end.goe(startDateTime)))

                    .or((start.loe(endDateTime)
                    .and(end.goe(endDateTime))))

                    .or((start.loe(startDateTime)
                    .and(end.goe(endDateTime))))

                    .or((start.loe(endDateTime)
                    .and(end.goe(startDateTime))))
                    )
                );

以下场景需要替换 where

场景 ------------------------- 结果
开始:2020-10-24T11:30:34
结束:2020-10 -27T17:00:02 -- 错误

开始:2020-10-24T11:30:34
结束:2020-10-28T17:00:02 -- 假

开始:2020-10-23T11:30:34
结束:2020-10-25T17:00:02 -- false

开始:2020-10-25T11:30:34
结束:2020-10-26T17:00:02 -- false

开始:2020-10-23T11:30:34
结束:2020-10-28T17:00:02 -- 假

开始:2020-10-28T11:30:34
结束:2020-10-30T17:00:02 -- true

开始:2020-10-22T11:30:34
结束:2020-10-23T17:00:02 -- true

开始:2020-10-22T11:30:34
结束:2020-10-24T11:30:34 -- 真

开始:2020-10-27T17:00:02
结束:2020-10-30T17:00:02 -- true

以上所有场景都应该在单一的 where 条件下工作

4

0 回答 0