diff --git a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs index 9f13fb7e..4b7c45f9 100644 --- a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs +++ b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs @@ -347,6 +347,7 @@ public class AppointmentService : IAppointmentService var gainfoLeaves = await _dbContext.Queryable() .Where(x => x.Type == GainfoUserTypeEnumType.External) .Where(x => SqlFunc.DateIsSame(x.ResignationDate, day)) + .Where(x => SqlFunc.Subqueryable().Where(p => p.No == x.No).NotAny()) .ToListAsync(); foreach (var gainfoLeave in gainfoLeaves) @@ -359,9 +360,17 @@ public class AppointmentService : IAppointmentService await _dbContext.InsertAsync(gainfo); await _dbContext.DeleteReallyAsync(gainfoLeave); - var detail = await _dbContext.Queryable().Where(x => x.UserNo == gainfo.No).SingleAsync(); + var detail = await _dbContext.Queryable().Where(x => x.UserNo == gainfo.No).OrderByDescending(x => x.Id).FirstAsync(); detail.ThrowIfNull("数据不存在"); - + if (detail.IsEnterDoorArea) + { + detail.DoorStatus = VisitorAppointmentDetailStatusEnumType.Arrived; + } + if (detail.IsEnterWorkplace) + { + detail.WorkplaceStatus = VisitorAppointmentDetailStatusEnumType.Arrived; + } + await _dbContext.UpdateAsync(detail); await GenerateDeviceTasksAsync(detail, true, DeviceTaskEnumType.Update, "数据恢复"); await _dbContext.Client.Ado.CommitTranAsync();