fix 逻辑调整
This commit is contained in:
@@ -236,7 +236,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
|
||||
|
||||
foreach (var period in periods)
|
||||
{
|
||||
period.IsDuplicate1(request.TimePeriod).ThrowIfTrue($"存在时间段重合[{period.Start}-{period.End}]");
|
||||
period.IsDuplicate(request.TimePeriod).ThrowIfTrue($"存在时间段重合[{period.Start}-{period.End}]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
|
||||
namespace Dlhis.Basic.BusinessShift;
|
||||
|
||||
/// <summary>
|
||||
/// 临时的扩展类 todo: 嵌入框架
|
||||
/// </summary>
|
||||
public static class TimePeriodExtensions
|
||||
{
|
||||
public static bool IsDuplicate1(this TimePeriod current, TimePeriod period)
|
||||
{
|
||||
return !Check();
|
||||
|
||||
bool Check()
|
||||
{
|
||||
if (current.IsCrossDay())
|
||||
{
|
||||
if (period.IsCrossDay())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return period.Start > current.End && period.End < current.Start;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (period.IsCrossDay())
|
||||
{
|
||||
return period.Start > current.End && period.End < current.Start;
|
||||
}
|
||||
else
|
||||
{
|
||||
return period.Start > current.End || period.End < current.Start;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
|
||||
/// 状态
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public AppointmentDetailEnumType Status { get; set; }
|
||||
public VisitorAppointmentDetailStatusEnumType Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||
using Dlhis.Entity.Visitor.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
namespace Dlhis.Entity.Visitor.Entity;
|
||||
|
||||
@@ -39,7 +41,7 @@ public class VisitorAppointmentEntity : SugarBaseEntity
|
||||
/// 预约门禁区域
|
||||
/// </summary>
|
||||
public string ApplyDoorArea { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 访客开始
|
||||
@@ -59,7 +61,8 @@ public class VisitorAppointmentEntity : SugarBaseEntity
|
||||
/// <summary>
|
||||
/// 申请车间区域
|
||||
/// </summary>
|
||||
public string ApplyWorkplaceArea { get; set; }
|
||||
[SugarColumn(ColumnDescription = "车间区域", IsJson = true, DefaultValue = "[]")]
|
||||
public List<string> ApplyWorkplaceAreas { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 车间访问开始
|
||||
@@ -70,12 +73,12 @@ public class VisitorAppointmentEntity : SugarBaseEntity
|
||||
/// 车间访问结束
|
||||
/// </summary>
|
||||
public DateTime? WorkplaceEnd { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 预约厂区
|
||||
/// </summary>
|
||||
@@ -85,4 +88,10 @@ public class VisitorAppointmentEntity : SugarBaseEntity
|
||||
/// 申请事由
|
||||
/// </summary>
|
||||
public string Reason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public VisitorAppointmentStatusEnumType Status { get; set; }
|
||||
}
|
||||
@@ -6,7 +6,7 @@ namespace Dlhis.Entity.Visitor.Enums;
|
||||
/// 访客预约明细状态
|
||||
/// </summary>
|
||||
[Description("预约状态")]
|
||||
public enum AppointmentDetailEnumType
|
||||
public enum VisitorAppointmentDetailStatusEnumType
|
||||
{
|
||||
/// <summary>
|
||||
/// 待来访
|
||||
@@ -25,11 +25,16 @@ public enum AppointmentDetailEnumType
|
||||
/// </summary>
|
||||
[Description("到达")]
|
||||
Arrived = 10,
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 离开
|
||||
/// </summary>
|
||||
[Description("离开")]
|
||||
Leave = 99
|
||||
Leave = 11,
|
||||
|
||||
/// <summary>
|
||||
/// 作废
|
||||
/// </summary>
|
||||
[Description("作废")]
|
||||
Obsolete = 99
|
||||
}
|
||||
@@ -6,17 +6,17 @@ namespace Dlhis.Entity.Visitor.Enums;
|
||||
/// 访客预约明细状态
|
||||
/// </summary>
|
||||
[Description("访客预约状态")]
|
||||
public enum VisitorAppointmentDetailEnumType
|
||||
public enum VisitorAppointmentStatusEnumType
|
||||
{
|
||||
/// <summary>
|
||||
/// 到达
|
||||
/// </summary>
|
||||
[Description("到达")]
|
||||
Arrived = 1,
|
||||
Valid = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 离开
|
||||
/// 作废
|
||||
/// </summary>
|
||||
[Description("离开")]
|
||||
Leave = 99
|
||||
[Description("作废")]
|
||||
Obsolete = 99
|
||||
}
|
||||
@@ -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
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"dotnetRunMessages": true,
|
||||
"applicationUrl": "http://*:6000"
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
}
|
||||
},
|
||||
"$schema": "https://json.schemastore.org/launchsettings.json"
|
||||
|
||||
@@ -16,10 +16,7 @@ public class Startup
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddEndpointsApiExplorer();
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Gateway API", Version = "v1", Description = "gateway api" });
|
||||
});
|
||||
services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Gateway API", Version = "v1", Description = "gateway api" }); });
|
||||
|
||||
services.AddOcelot();
|
||||
}
|
||||
@@ -37,5 +34,4 @@ public class Startup
|
||||
});
|
||||
app.UseOcelot().Wait();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,17 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"UpstreamPathTemplate": "/basic/swagger/v1/swagger.json",
|
||||
"DownstreamPathTemplate": "/swagger/v1/swagger.json",
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 5002
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"UpstreamPathTemplate": "/api/scheduled/{url}",
|
||||
"DownstreamPathTemplate": "/api/{url}",
|
||||
@@ -66,14 +77,25 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"UpstreamPathTemplate": "/api/external/{url}",
|
||||
"DownstreamPathTemplate": "/api/{url}",
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "localhost",
|
||||
"Port": 5020
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"UpstreamPathTemplate": "/{url}/swagger/v1/swagger.json",
|
||||
"DownstreamPathTemplate": "/{url}/swagger/v1/swagger.json",
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "192.168.199.115",
|
||||
"Port": 6000
|
||||
"Host": "localhost",
|
||||
"Port": 5000
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user