fix 逻辑调整
This commit is contained in:
@@ -30,7 +30,7 @@ public class AppointmentsController : ControllerBase
|
||||
[Transactional]
|
||||
[IgnoreTenant]
|
||||
[HttpPost("receive")]
|
||||
public async Task ReceiveAsync(AppointmentReceiveRequest request)
|
||||
public async Task ReceiveAsync(VisitorAppointmentReceiveRequest request)
|
||||
{
|
||||
await _appointmentService.ReceiveAsync(request);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.External.Appointment.Request;
|
||||
|
||||
public class AppointmentReceiveRequest : IValidatableObject
|
||||
public class VisitorAppointmentReceiveRequest : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 流水号
|
||||
@@ -59,7 +59,7 @@ public class AppointmentReceiveRequest : IValidatableObject
|
||||
/// <summary>
|
||||
/// 申请车间区域
|
||||
/// </summary>
|
||||
public string ApplyWorkplaceArea { get; set; }
|
||||
public List<string> ApplyWorkplaceAreas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间访问开始
|
||||
@@ -99,12 +99,35 @@ public class AppointmentReceiveRequest : IValidatableObject
|
||||
{
|
||||
if (DoorStart >= DoorEnd)
|
||||
{
|
||||
yield return new ValidationResult("门禁来访时间不能大于等于离开时间", new[] { nameof(DoorStart), nameof(DoorEnd) });
|
||||
yield return new ValidationResult("门禁来访时间有误", new[] { nameof(DoorStart) });
|
||||
}
|
||||
|
||||
if (IsEnterWorkplace)
|
||||
{
|
||||
if (ApplyWorkplaceAreas.IsEmpty())
|
||||
{
|
||||
yield return new ValidationResult("车间区域不可为空", new[] { nameof(ApplyWorkplaceAreas) });
|
||||
}
|
||||
|
||||
if (WorkplaceStart >= WorkplaceEnd)
|
||||
{
|
||||
yield return new ValidationResult("车间来访时间有误", new[] { nameof(WorkplaceStart) });
|
||||
}
|
||||
|
||||
if (WorkplaceStart < DoorStart || WorkplaceStart > DoorEnd)
|
||||
{
|
||||
yield return new ValidationResult("车间来访时间需在门禁时间范围内", new[] { nameof(WorkplaceStart) });
|
||||
}
|
||||
|
||||
if (WorkplaceEnd < DoorStart || WorkplaceEnd > DoorEnd)
|
||||
{
|
||||
yield return new ValidationResult("车间来访时间需在门禁时间范围内", new[] { nameof(WorkplaceStart) });
|
||||
}
|
||||
|
||||
if (Items.Any(x => x.ImageUrl.IsEmpty()))
|
||||
{
|
||||
yield return new ValidationResult("请上传社保照片", new[] { nameof(WorkplaceStart) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,5 @@ namespace Dlhis.External.Appointment.Services;
|
||||
|
||||
public interface IAppointmentService : IScopeDependency
|
||||
{
|
||||
Task ReceiveAsync(AppointmentReceiveRequest request);
|
||||
Task ReceiveAsync(VisitorAppointmentReceiveRequest request);
|
||||
}
|
||||
@@ -21,12 +21,27 @@ public class AppointmentService : IAppointmentService
|
||||
_redisCache = redisCache;
|
||||
}
|
||||
|
||||
public async Task ReceiveAsync(AppointmentReceiveRequest request)
|
||||
public async Task ReceiveAsync(VisitorAppointmentReceiveRequest request)
|
||||
{
|
||||
var exists = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.No == request.No).AnyAsync();
|
||||
exists.ThrowIfTrue("已经存在申请");
|
||||
|
||||
var id = await _dbContext.InsertReturnIdentityAsync(new VisitorAppointmentEntity
|
||||
var existsDoorArea = await _dbContext.Queryable<AppointmentAreaEntity>()
|
||||
.Where(x => x.TenantId == request.Factory)
|
||||
.Where(x => x.Name == request.ApplyDoorArea)
|
||||
.AnyAsync();
|
||||
|
||||
var existsWorkplace = true;
|
||||
if (request.IsEnterWorkplace)
|
||||
{
|
||||
var count = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.TenantId == request.Factory)
|
||||
.Where(x => request.ApplyWorkplaceAreas.Contains(x.Name))
|
||||
.CountAsync();
|
||||
|
||||
existsWorkplace = request.ApplyWorkplaceAreas.Count == count;
|
||||
}
|
||||
|
||||
var mst = new VisitorAppointmentEntity
|
||||
{
|
||||
Id = 0,
|
||||
CreatedBy = 0,
|
||||
@@ -45,10 +60,16 @@ public class AppointmentService : IAppointmentService
|
||||
DoorEnd = request.DoorEnd,
|
||||
Remark = request.Remark,
|
||||
IsEnterWorkplace = request.IsEnterWorkplace,
|
||||
ApplyWorkplaceArea = request.ApplyWorkplaceArea,
|
||||
ApplyWorkplaceAreas = request.ApplyWorkplaceAreas,
|
||||
WorkplaceStart = request.WorkplaceStart,
|
||||
WorkplaceEnd = request.WorkplaceEnd
|
||||
});
|
||||
};
|
||||
if (!existsDoorArea || !existsWorkplace)
|
||||
{
|
||||
mst.Status = VisitorAppointmentStatusEnumType.Obsolete;
|
||||
}
|
||||
|
||||
await _dbContext.InsertAsync(mst);
|
||||
|
||||
foreach (var item in request.Items)
|
||||
{
|
||||
@@ -90,7 +111,9 @@ public class AppointmentService : IAppointmentService
|
||||
Name = item.Name,
|
||||
Phone = item.Phone,
|
||||
Remark = item.Remark,
|
||||
Status = AppointmentDetailEnumType.Wait,
|
||||
Status = mst.Status == VisitorAppointmentStatusEnumType.Valid
|
||||
? VisitorAppointmentDetailStatusEnumType.Wait
|
||||
: VisitorAppointmentDetailStatusEnumType.Obsolete,
|
||||
LicensePlate = item.LicensePlate
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user