修改挂单功能
This commit is contained in:
@@ -58,7 +58,7 @@ namespace Model
|
||||
|
||||
// 找出在日期範圍內被占用的床位 Uuid(包括長期占用 ScheduleDate = null)
|
||||
var busyBedUuidsQuery = db.RegionAndRoomAndBedSchedule
|
||||
.Where(s => s.IsDeleted == false && s.IsActive
|
||||
.Where(s => s.IsDeleted == false && !s.IsCancel
|
||||
&& (s.ScheduleDate == null
|
||||
|| (end.HasValue
|
||||
&& s.ScheduleDate >= start
|
||||
@@ -79,25 +79,28 @@ namespace Model
|
||||
public static async Task<bool> IsBedAvailableAsync(ezEntities db, Guid targetUuid, DateTime start, DateTime? end)
|
||||
{
|
||||
// 如果 end 為 null,表示長期占用,直接判斷是否已有長期占用
|
||||
//不包含结束时间那一天
|
||||
if (end == null)
|
||||
{
|
||||
var hasLongTerm = await db.RegionAndRoomAndBedSchedule
|
||||
.AnyAsync(s => s.IsDeleted == false
|
||||
&& s.IsActive
|
||||
&& !s.IsCancel
|
||||
&& s.TargetUuid == targetUuid
|
||||
&& s.ScheduleDate == null);
|
||||
return !hasLongTerm;
|
||||
}
|
||||
|
||||
// 短期占用,查詢每日排程中有無衝突
|
||||
var totalDays = (end.Value.Date - start.Date).Days + 1;
|
||||
var totalDays = (end.Value.Date - start.Date).Days;
|
||||
for (int i = 0; i < totalDays; i++)
|
||||
{
|
||||
var date = start.Date.AddDays(i);
|
||||
|
||||
var conflict = await db.RegionAndRoomAndBedSchedule
|
||||
.Where(s => s.GuaDanOrderGuest.StatusCode != GuaDanOrderGuest.STATUS_CANCELLED)
|
||||
.Where(s => s.GuaDanOrderGuest.StatusCode != GuaDanOrderGuest.STATUS_CHECKED_OUT)
|
||||
.AnyAsync(s => s.IsDeleted == false
|
||||
&& s.IsActive
|
||||
&& !s.IsCancel
|
||||
&& s.TargetUuid == targetUuid
|
||||
&& s.ScheduleDate == date);
|
||||
|
||||
@@ -114,7 +117,10 @@ namespace Model
|
||||
|
||||
// 找出所有在日期範圍內被占用的床位
|
||||
var busyBedUuids = await db.RegionAndRoomAndBedSchedule
|
||||
.Where(s => s.IsDeleted == false && s.IsActive
|
||||
.Where(s => s.GuaDanOrderGuest.StatusCode != "403")
|
||||
.Where(s => s.GuaDanOrderGuest.StatusCode != "404")
|
||||
.Where(a => a.IsCancel == false)
|
||||
.Where(s => s.IsDeleted == false
|
||||
&& (s.ScheduleDate == null // 長期占用
|
||||
|| (s.ScheduleDate >= start && s.ScheduleDate <= end)))
|
||||
.Select(s => s.TargetUuid)
|
||||
|
||||
Reference in New Issue
Block a user