|
|
|
@ -46,9 +46,17 @@ namespace Shentun.Peis.QueueRegisters |
|
|
|
public async Task<QueueRegister> ManualQueuingRoomAsync(Guid PatientRegisterId, Guid RoomId) |
|
|
|
{ |
|
|
|
|
|
|
|
var maxDisplayOrder = await (await _queueRegisterRepository.GetQueryableAsync()) |
|
|
|
var displayOrderList = (await _queueRegisterRepository.GetQueryableAsync()) |
|
|
|
.Where(m => m.RoomId == RoomId && m.CreationTime >= DateTime.Now.Date) |
|
|
|
.MaxAsync(m => m.DisplayOrder); |
|
|
|
.Select(s => s.DisplayOrder); |
|
|
|
|
|
|
|
int maxDisplayOrder = 0; |
|
|
|
|
|
|
|
if (displayOrderList.Any()) |
|
|
|
{ |
|
|
|
maxDisplayOrder = await displayOrderList.MaxAsync(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var queueRegisterEnt = new QueueRegister |
|
|
|
{ |
|
|
|
@ -81,27 +89,45 @@ namespace Shentun.Peis.QueueRegisters |
|
|
|
throw new UserFriendlyException("该人员未登记项目"); |
|
|
|
|
|
|
|
//获取项目所属房间需要等待的时间
|
|
|
|
var query = from roomDetail in await _roomDetailRepository.GetQueryableAsync() |
|
|
|
join room in await _roomRepository.GetQueryableAsync() on roomDetail.RoomId equals room.Id |
|
|
|
join queueRegister in await _queueRegisterRepository.GetQueryableAsync() on room.Id equals queueRegister.RoomId into queueRegisterTemp |
|
|
|
from queueRegisterHaveEmpty in queueRegisterTemp.DefaultIfEmpty() |
|
|
|
where queueRegisterHaveEmpty.CreationTime >= DateTime.Now.Date && asbitemIds.Contains(roomDetail.AsbitemId) |
|
|
|
select new |
|
|
|
{ |
|
|
|
roomId = room.Id, |
|
|
|
queueTime = room.QueueTime, |
|
|
|
queueRegisterHaveEmpty |
|
|
|
}; |
|
|
|
|
|
|
|
var roomGroup = query.ToList().GroupBy(g => g.roomId).Select(s => new |
|
|
|
var query = (from roomDetail in await _roomDetailRepository.GetQueryableAsync() |
|
|
|
join room in await _roomRepository.GetQueryableAsync() on roomDetail.RoomId equals room.Id |
|
|
|
join queueRegister in await _queueRegisterRepository.GetQueryableAsync() on room.Id equals queueRegister.RoomId into queueRegisterTemp |
|
|
|
from queueRegisterHaveEmpty in queueRegisterTemp.DefaultIfEmpty() |
|
|
|
where queueRegisterHaveEmpty.CreationTime >= DateTime.Now.Date && asbitemIds.Contains(roomDetail.AsbitemId) |
|
|
|
select new |
|
|
|
{ |
|
|
|
roomId = room.Id, |
|
|
|
queueTime = room.QueueTime, |
|
|
|
queueRegisterHaveEmpty |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
if (query.Any()) |
|
|
|
{ |
|
|
|
roomId = s.Key, |
|
|
|
queueTime = s.FirstOrDefault().queueTime, |
|
|
|
sumQueueTime = s.Count(m => m.queueRegisterHaveEmpty != null) * s.FirstOrDefault().queueTime |
|
|
|
}).OrderBy(o => o.sumQueueTime).ThenBy(o => o.queueTime).First(); |
|
|
|
var roomGroup = query.ToList().GroupBy(g => g.roomId).Select(s => new |
|
|
|
{ |
|
|
|
roomId = s.Key, |
|
|
|
queueTime = s.FirstOrDefault().queueTime, |
|
|
|
sumQueueTime = s.Count(m => m.queueRegisterHaveEmpty != null) * s.FirstOrDefault().queueTime |
|
|
|
}).OrderBy(o => o.sumQueueTime).ThenBy(o => o.queueTime).First(); |
|
|
|
|
|
|
|
|
|
|
|
return await ManualQueuingRoomAsync(PatientRegisterId, roomGroup.roomId); |
|
|
|
return await ManualQueuingRoomAsync(PatientRegisterId, roomGroup.roomId); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
//无排队信息
|
|
|
|
var roomId = (from roomDetail in await _roomDetailRepository.GetQueryableAsync() |
|
|
|
join room in await _roomRepository.GetQueryableAsync() on roomDetail.RoomId equals room.Id |
|
|
|
where asbitemIds.Contains(roomDetail.AsbitemId) |
|
|
|
orderby room.QueueTime, room.DisplayOrder ascending |
|
|
|
select room.Id).FirstOrDefault(); |
|
|
|
if (roomId == Guid.Empty) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("该人员登记的项目未在房间中维护"); |
|
|
|
} |
|
|
|
|
|
|
|
return await ManualQueuingRoomAsync(PatientRegisterId, roomId); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|