fix 结构变更
This commit is contained in:
@@ -52,10 +52,46 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
|
|||||||
public string LicensePlate { get; set; }
|
public string LicensePlate { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 状态
|
/// 预约门禁区域
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
public string ApplyDoorArea { get; set; }
|
||||||
public VisitorAppointmentDetailStatusEnumType Status { 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>
|
||||||
|
[SugarColumn(ColumnDescription = "车间区域", IsJson = true, DefaultValue = "[]")]
|
||||||
|
public List<string> ApplyWorkplaceAreas { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 车间访问开始
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? WorkplaceStart { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 车间访问结束
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? WorkplaceEnd { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 社保照片url
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "社保照片url")]
|
||||||
|
public string ImageUrl { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 备注
|
/// 备注
|
||||||
@@ -63,9 +99,16 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
|
|||||||
[SugarColumn(ColumnDescription = "备注")]
|
[SugarColumn(ColumnDescription = "备注")]
|
||||||
public string Remark { get; set; }
|
public string Remark { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 社保照片url
|
/// 门禁状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "社保照片url")]
|
[SugarColumn(IsNullable = false, ColumnDescription = "门禁状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||||
public string ImageUrl { get; set; }
|
public VisitorAppointmentDetailStatusEnumType DoorStatus { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 车间状态
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = false, ColumnDescription = "车间状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||||
|
public VisitorAppointmentDetailStatusEnumType WorkplaceStatus { get; set; }
|
||||||
}
|
}
|
||||||
@@ -37,43 +37,6 @@ public class VisitorAppointmentEntity : SugarBaseEntity
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 预约门禁区域
|
|
||||||
/// </summary>
|
|
||||||
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>
|
|
||||||
[SugarColumn(ColumnDescription = "车间区域", IsJson = true, DefaultValue = "[]")]
|
|
||||||
public List<string> ApplyWorkplaceAreas { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 车间访问开始
|
|
||||||
/// </summary>
|
|
||||||
public DateTime? WorkplaceStart { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 车间访问结束
|
|
||||||
/// </summary>
|
|
||||||
public DateTime? WorkplaceEnd { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 备注
|
/// 备注
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -88,10 +51,4 @@ public class VisitorAppointmentEntity : SugarBaseEntity
|
|||||||
/// 申请事由
|
/// 申请事由
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 状态
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
|
||||||
public VisitorAppointmentStatusEnumType Status { get; set; }
|
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
|
||||||
namespace Dlhis.External.Appointment.Dto;
|
namespace Dlhis.External.Appointment.Dto;
|
||||||
|
|
||||||
public class AppointmentReceiveItemDto
|
public class AppointmentReceiveItemDto : IValidatableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 姓名
|
/// 姓名
|
||||||
@@ -28,7 +29,7 @@ public class AppointmentReceiveItemDto
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[Required(ErrorMessage = "证件号/工号")]
|
[Required(ErrorMessage = "证件号/工号")]
|
||||||
public string IdNo { get; set; }
|
public string IdNo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 车牌
|
/// 车牌
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -43,4 +44,73 @@ public class AppointmentReceiveItemDto
|
|||||||
/// 社保照片
|
/// 社保照片
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ImageUrl { get; set; }
|
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 System.ComponentModel.DataAnnotations;
|
||||||
using Dlhis.External.Appointment.Dto;
|
using Dlhis.External.Appointment.Dto;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
|
||||||
|
|
||||||
namespace Dlhis.External.Appointment.Request;
|
namespace Dlhis.External.Appointment.Request;
|
||||||
|
|
||||||
public class VisitorAppointmentReceiveRequest : IValidatableObject
|
public class VisitorAppointmentReceiveRequest
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 流水号
|
/// 流水号
|
||||||
@@ -24,12 +23,6 @@ public class VisitorAppointmentReceiveRequest : IValidatableObject
|
|||||||
[Required(ErrorMessage = "对接人工号不可为空")]
|
[Required(ErrorMessage = "对接人工号不可为空")]
|
||||||
public string Code { get; set; }
|
public string Code { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 预约门岗区域
|
|
||||||
/// </summary>
|
|
||||||
[Required(ErrorMessage = "预约门岗区域不可为空")]
|
|
||||||
public string ApplyDoorArea { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 来访人来源/公司
|
/// 来访人来源/公司
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -41,36 +34,6 @@ public class VisitorAppointmentReceiveRequest : IValidatableObject
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime Date { get; set; }
|
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>
|
||||||
/// 备注
|
/// 备注
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -94,40 +57,4 @@ public class VisitorAppointmentReceiveRequest : IValidatableObject
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[MinLength(1, ErrorMessage = "明细必填")]
|
[MinLength(1, ErrorMessage = "明细必填")]
|
||||||
public List<AppointmentReceiveItemDto> Items { get; set; }
|
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();
|
var exists = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.No == request.No).AnyAsync();
|
||||||
exists.ThrowIfTrue("已经存在申请");
|
exists.ThrowIfTrue("已经存在申请");
|
||||||
|
|
||||||
var existsDoorArea = await _dbContext.Queryable<AppointmentAreaEntity>()
|
var areas = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.TenantId == request.Factory).ToListAsync();
|
||||||
.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
|
var mst = new VisitorAppointmentEntity
|
||||||
{
|
{
|
||||||
@@ -53,21 +40,10 @@ public class AppointmentService : IAppointmentService
|
|||||||
Code = request.Code,
|
Code = request.Code,
|
||||||
Source = request.Source,
|
Source = request.Source,
|
||||||
Date = request.Date,
|
Date = request.Date,
|
||||||
ApplyDoorArea = request.ApplyDoorArea,
|
|
||||||
Factory = request.Factory,
|
Factory = request.Factory,
|
||||||
Reason = request.Reason,
|
Reason = request.Reason,
|
||||||
DoorStart = request.DoorStart,
|
|
||||||
DoorEnd = request.DoorEnd,
|
|
||||||
Remark = request.Remark,
|
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);
|
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
|
var detail = new VisitorAppointmentDetailEntity
|
||||||
{
|
{
|
||||||
@@ -111,10 +87,26 @@ public class AppointmentService : IAppointmentService
|
|||||||
Name = item.Name,
|
Name = item.Name,
|
||||||
Phone = item.Phone,
|
Phone = item.Phone,
|
||||||
Remark = item.Remark,
|
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.Wait
|
||||||
: VisitorAppointmentDetailStatusEnumType.Obsolete,
|
: 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);
|
await _dbContext.InsertAsync(detail);
|
||||||
|
|||||||
Reference in New Issue
Block a user