133 lines
3.6 KiB
C#
133 lines
3.6 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Dlhis.External.Appointment.Dto;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
|
|
namespace Dlhis.External.Appointment.Request;
|
|
|
|
public class VisitorAppointmentReceiveRequest : IValidatableObject
|
|
{
|
|
/// <summary>
|
|
/// 流水号
|
|
/// </summary>
|
|
[Required(ErrorMessage = "流程不可为空")]
|
|
public string No { get; set; }
|
|
|
|
/// <summary>
|
|
/// 标题
|
|
/// </summary>
|
|
[Required(ErrorMessage = "标题不可为空")]
|
|
public string Title { get; set; }
|
|
|
|
/// <summary>
|
|
/// 对接人工号
|
|
/// </summary>
|
|
[Required(ErrorMessage = "对接人工号不可为空")]
|
|
public string Code { get; set; }
|
|
|
|
/// <summary>
|
|
/// 预约门岗区域
|
|
/// </summary>
|
|
[Required(ErrorMessage = "预约门岗区域不可为空")]
|
|
public string ApplyDoorArea { get; set; }
|
|
|
|
/// <summary>
|
|
/// 来访人来源/公司
|
|
/// </summary>
|
|
[Required(ErrorMessage = "来源/公司不可为空")]
|
|
public string Source { get; set; }
|
|
|
|
/// <summary>
|
|
/// 申请时间
|
|
/// </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>
|
|
public string Remark { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 预约厂区
|
|
/// </summary>
|
|
[Required(ErrorMessage = "厂区不可为空")]
|
|
public string Factory { get; set; }
|
|
|
|
/// <summary>
|
|
/// 申请事由
|
|
/// </summary>
|
|
[Required(ErrorMessage = "申请事由不能为空")]
|
|
public string Reason { get; set; }
|
|
|
|
/// <summary>
|
|
/// 明细
|
|
/// </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) });
|
|
}
|
|
}
|
|
}
|
|
} |