fix 结构变更
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.External.Appointment.Dto;
|
||||
|
||||
public class AppointmentReceiveItemDto
|
||||
public class AppointmentReceiveItemDto : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 姓名
|
||||
@@ -28,7 +29,7 @@ public class AppointmentReceiveItemDto
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "证件号/工号")]
|
||||
public string IdNo { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 车牌
|
||||
/// </summary>
|
||||
@@ -43,4 +44,73 @@ public class AppointmentReceiveItemDto
|
||||
/// 社保照片
|
||||
/// </summary>
|
||||
public string ImageUrl { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 预约门岗区域
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "预约门岗区域不可为空")]
|
||||
public string ApplyDoorArea { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访客开始
|
||||
/// </summary>
|
||||
public DateTime DoorStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访问结束
|
||||
/// </summary>
|
||||
public DateTime DoorEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否进入车间
|
||||
/// </summary>
|
||||
public bool IsEnterWorkplace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申请车间区域
|
||||
/// </summary>
|
||||
public List<string> ApplyWorkplaceAreas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间访问开始
|
||||
/// </summary>
|
||||
public DateTime? WorkplaceStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间访问结束
|
||||
/// </summary>
|
||||
public DateTime? WorkplaceEnd { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (DoorStart >= DoorEnd)
|
||||
{
|
||||
yield return new ValidationResult($"{Name}门禁来访时间有误", new[] { nameof(DoorStart) });
|
||||
}
|
||||
|
||||
if (IsEnterWorkplace)
|
||||
{
|
||||
if (ApplyWorkplaceAreas.IsEmpty())
|
||||
{
|
||||
yield return new ValidationResult($"{Name}车间区域不可为空", new[] { nameof(ApplyWorkplaceAreas) });
|
||||
}
|
||||
|
||||
if (WorkplaceStart >= WorkplaceEnd)
|
||||
{
|
||||
yield return new ValidationResult($"{Name}车间来访时间有误", new[] { nameof(WorkplaceStart) });
|
||||
}
|
||||
|
||||
if (WorkplaceStart < DoorStart || WorkplaceStart > DoorEnd)
|
||||
{
|
||||
yield return new ValidationResult($"{Name}车间来访时间需在门禁时间范围内", new[] { nameof(WorkplaceStart) });
|
||||
}
|
||||
|
||||
if (WorkplaceEnd < DoorStart || WorkplaceEnd > DoorEnd)
|
||||
{
|
||||
yield return new ValidationResult($"{Name}车间来访时间需在门禁时间范围内", new[] { nameof(WorkplaceStart) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.External.Appointment.Dto;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.External.Appointment.Request;
|
||||
|
||||
public class VisitorAppointmentReceiveRequest : IValidatableObject
|
||||
public class VisitorAppointmentReceiveRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 流水号
|
||||
@@ -24,12 +23,6 @@ public class VisitorAppointmentReceiveRequest : IValidatableObject
|
||||
[Required(ErrorMessage = "对接人工号不可为空")]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预约门岗区域
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "预约门岗区域不可为空")]
|
||||
public string ApplyDoorArea { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 来访人来源/公司
|
||||
/// </summary>
|
||||
@@ -41,36 +34,6 @@ public class VisitorAppointmentReceiveRequest : IValidatableObject
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访客开始
|
||||
/// </summary>
|
||||
public DateTime DoorStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 访问结束
|
||||
/// </summary>
|
||||
public DateTime DoorEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否进入车间
|
||||
/// </summary>
|
||||
public bool IsEnterWorkplace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申请车间区域
|
||||
/// </summary>
|
||||
public List<string> ApplyWorkplaceAreas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间访问开始
|
||||
/// </summary>
|
||||
public DateTime? WorkplaceStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间访问结束
|
||||
/// </summary>
|
||||
public DateTime? WorkplaceEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
@@ -94,40 +57,4 @@ public class VisitorAppointmentReceiveRequest : IValidatableObject
|
||||
/// </summary>
|
||||
[MinLength(1, ErrorMessage = "明细必填")]
|
||||
public List<AppointmentReceiveItemDto> Items { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (DoorStart >= 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) });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,20 +26,7 @@ public class AppointmentService : IAppointmentService
|
||||
var exists = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.No == request.No).AnyAsync();
|
||||
exists.ThrowIfTrue("已经存在申请");
|
||||
|
||||
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 areas = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.TenantId == request.Factory).ToListAsync();
|
||||
|
||||
var mst = new VisitorAppointmentEntity
|
||||
{
|
||||
@@ -53,21 +40,10 @@ public class AppointmentService : IAppointmentService
|
||||
Code = request.Code,
|
||||
Source = request.Source,
|
||||
Date = request.Date,
|
||||
ApplyDoorArea = request.ApplyDoorArea,
|
||||
Factory = request.Factory,
|
||||
Reason = request.Reason,
|
||||
DoorStart = request.DoorStart,
|
||||
DoorEnd = request.DoorEnd,
|
||||
Remark = request.Remark,
|
||||
IsEnterWorkplace = request.IsEnterWorkplace,
|
||||
ApplyWorkplaceAreas = request.ApplyWorkplaceAreas,
|
||||
WorkplaceStart = request.WorkplaceStart,
|
||||
WorkplaceEnd = request.WorkplaceEnd
|
||||
};
|
||||
if (!existsDoorArea || !existsWorkplace)
|
||||
{
|
||||
mst.Status = VisitorAppointmentStatusEnumType.Obsolete;
|
||||
}
|
||||
|
||||
await _dbContext.InsertAsync(mst);
|
||||
|
||||
@@ -100,7 +76,7 @@ public class AppointmentService : IAppointmentService
|
||||
}
|
||||
}
|
||||
|
||||
(gainfo.Type == GainfoUserTypeEnumType.External && request.IsEnterWorkplace && item.ImageUrl.IsEmpty()).ThrowIfTrue($"{item.Name}的社保照片不可为空");
|
||||
(gainfo.Type == GainfoUserTypeEnumType.External && item.IsEnterWorkplace && item.ImageUrl.IsEmpty()).ThrowIfTrue($"{item.Name}的社保照片不可为空");
|
||||
|
||||
var detail = new VisitorAppointmentDetailEntity
|
||||
{
|
||||
@@ -111,10 +87,26 @@ public class AppointmentService : IAppointmentService
|
||||
Name = item.Name,
|
||||
Phone = item.Phone,
|
||||
Remark = item.Remark,
|
||||
Status = mst.Status == VisitorAppointmentStatusEnumType.Valid
|
||||
DoorStatus = areas.Where(x => x.Type == AppointmentAreaEnumType.Door)
|
||||
.Select(x => x.Name)
|
||||
.Contains(item.ApplyDoorArea)
|
||||
? VisitorAppointmentDetailStatusEnumType.Wait
|
||||
: VisitorAppointmentDetailStatusEnumType.Obsolete,
|
||||
LicensePlate = item.LicensePlate
|
||||
LicensePlate = item.LicensePlate,
|
||||
ApplyDoorArea = item.ApplyDoorArea,
|
||||
DoorStart = item.DoorStart,
|
||||
DoorEnd = item.DoorEnd,
|
||||
IsEnterWorkplace = item.IsEnterWorkplace,
|
||||
WorkplaceStatus = item.IsEnterWorkplace &&
|
||||
item.ApplyWorkplaceAreas.All(p => areas.Where(x => x.Type == AppointmentAreaEnumType.Workplace)
|
||||
.Select(x => x.Name)
|
||||
.Contains(p))
|
||||
? VisitorAppointmentDetailStatusEnumType.Wait
|
||||
: VisitorAppointmentDetailStatusEnumType.Obsolete,
|
||||
ApplyWorkplaceAreas = item.ApplyWorkplaceAreas,
|
||||
WorkplaceStart = item.WorkplaceStart,
|
||||
WorkplaceEnd = item.WorkplaceEnd,
|
||||
ImageUrl = item.ImageUrl
|
||||
};
|
||||
|
||||
await _dbContext.InsertAsync(detail);
|
||||
|
||||
Reference in New Issue
Block a user