fix 逻辑调整

This commit is contained in:
2024-09-05 15:46:27 +08:00
parent 4b1d1520b8
commit 8330cb7095
13 changed files with 113 additions and 75 deletions

View File

@@ -236,7 +236,7 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
foreach (var period in periods) foreach (var period in periods)
{ {
period.IsDuplicate1(request.TimePeriod).ThrowIfTrue($"存在时间段重合[{period.Start}-{period.End}]"); period.IsDuplicate(request.TimePeriod).ThrowIfTrue($"存在时间段重合[{period.Start}-{period.End}]");
} }
} }

View File

@@ -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;
}
}
}
}
}

View File

@@ -55,7 +55,7 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
/// 状态 /// 状态
/// </summary> /// </summary>
[SugarColumn(IsNullable = false, ColumnDescription = "状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))] [SugarColumn(IsNullable = false, ColumnDescription = "状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
public AppointmentDetailEnumType Status { get; set; } public VisitorAppointmentDetailStatusEnumType Status { get; set; }
/// <summary> /// <summary>
/// 备注 /// 备注

View File

@@ -1,5 +1,7 @@
using Kurisu.AspNetCore.DataAccess.SqlSugar; using Dlhis.Entity.Visitor.Enums;
using Kurisu.AspNetCore.DataAccess.SqlSugar;
using SqlSugar; using SqlSugar;
using SqlSugar.DbConvert;
namespace Dlhis.Entity.Visitor.Entity; namespace Dlhis.Entity.Visitor.Entity;
@@ -59,7 +61,8 @@ public class VisitorAppointmentEntity : SugarBaseEntity
/// <summary> /// <summary>
/// 申请车间区域 /// 申请车间区域
/// </summary> /// </summary>
public string ApplyWorkplaceArea { get; set; } [SugarColumn(ColumnDescription = "车间区域", IsJson = true, DefaultValue = "[]")]
public List<string> ApplyWorkplaceAreas { get; set; }
/// <summary> /// <summary>
/// 车间访问开始 /// 车间访问开始
@@ -85,4 +88,10 @@ 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; }
} }

View File

@@ -6,7 +6,7 @@ namespace Dlhis.Entity.Visitor.Enums;
/// 访客预约明细状态 /// 访客预约明细状态
/// </summary> /// </summary>
[Description("预约状态")] [Description("预约状态")]
public enum AppointmentDetailEnumType public enum VisitorAppointmentDetailStatusEnumType
{ {
/// <summary> /// <summary>
/// 待来访 /// 待来访
@@ -26,10 +26,15 @@ public enum AppointmentDetailEnumType
[Description("到达")] [Description("到达")]
Arrived = 10, Arrived = 10,
/// <summary> /// <summary>
/// 离开 /// 离开
/// </summary> /// </summary>
[Description("离开")] [Description("离开")]
Leave = 99 Leave = 11,
/// <summary>
/// 作废
/// </summary>
[Description("作废")]
Obsolete = 99
} }

View File

@@ -6,17 +6,17 @@ namespace Dlhis.Entity.Visitor.Enums;
/// 访客预约明细状态 /// 访客预约明细状态
/// </summary> /// </summary>
[Description("访客预约状态")] [Description("访客预约状态")]
public enum VisitorAppointmentDetailEnumType public enum VisitorAppointmentStatusEnumType
{ {
/// <summary> /// <summary>
/// 到达 /// 到达
/// </summary> /// </summary>
[Description("到达")] [Description("到达")]
Arrived = 1, Valid = 1,
/// <summary> /// <summary>
/// 离开 /// 作废
/// </summary> /// </summary>
[Description("离开")] [Description("作废")]
Leave = 99 Obsolete = 99
} }

View File

@@ -30,7 +30,7 @@ public class AppointmentsController : ControllerBase
[Transactional] [Transactional]
[IgnoreTenant] [IgnoreTenant]
[HttpPost("receive")] [HttpPost("receive")]
public async Task ReceiveAsync(AppointmentReceiveRequest request) public async Task ReceiveAsync(VisitorAppointmentReceiveRequest request)
{ {
await _appointmentService.ReceiveAsync(request); await _appointmentService.ReceiveAsync(request);
} }

View File

@@ -4,7 +4,7 @@ using Kurisu.AspNetCore.Utils.Extensions;
namespace Dlhis.External.Appointment.Request; namespace Dlhis.External.Appointment.Request;
public class AppointmentReceiveRequest : IValidatableObject public class VisitorAppointmentReceiveRequest : IValidatableObject
{ {
/// <summary> /// <summary>
/// 流水号 /// 流水号
@@ -59,7 +59,7 @@ public class AppointmentReceiveRequest : IValidatableObject
/// <summary> /// <summary>
/// 申请车间区域 /// 申请车间区域
/// </summary> /// </summary>
public string ApplyWorkplaceArea { get; set; } public List<string> ApplyWorkplaceAreas { get; set; }
/// <summary> /// <summary>
/// 车间访问开始 /// 车间访问开始
@@ -99,12 +99,35 @@ public class AppointmentReceiveRequest : IValidatableObject
{ {
if (DoorStart >= DoorEnd) if (DoorStart >= DoorEnd)
{ {
yield return new ValidationResult("门禁来访时间不能大于等于离开时间", new[] { nameof(DoorStart), nameof(DoorEnd) }); yield return new ValidationResult("门禁来访时间有误", new[] { nameof(DoorStart) });
} }
if (IsEnterWorkplace) 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) });
}
} }
} }
} }

View File

@@ -4,5 +4,5 @@ namespace Dlhis.External.Appointment.Services;
public interface IAppointmentService : IScopeDependency public interface IAppointmentService : IScopeDependency
{ {
Task ReceiveAsync(AppointmentReceiveRequest request); Task ReceiveAsync(VisitorAppointmentReceiveRequest request);
} }

View File

@@ -21,12 +21,27 @@ public class AppointmentService : IAppointmentService
_redisCache = redisCache; _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(); var exists = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.No == request.No).AnyAsync();
exists.ThrowIfTrue("已经存在申请"); 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, Id = 0,
CreatedBy = 0, CreatedBy = 0,
@@ -45,10 +60,16 @@ public class AppointmentService : IAppointmentService
DoorEnd = request.DoorEnd, DoorEnd = request.DoorEnd,
Remark = request.Remark, Remark = request.Remark,
IsEnterWorkplace = request.IsEnterWorkplace, IsEnterWorkplace = request.IsEnterWorkplace,
ApplyWorkplaceArea = request.ApplyWorkplaceArea, ApplyWorkplaceAreas = request.ApplyWorkplaceAreas,
WorkplaceStart = request.WorkplaceStart, WorkplaceStart = request.WorkplaceStart,
WorkplaceEnd = request.WorkplaceEnd WorkplaceEnd = request.WorkplaceEnd
}); };
if (!existsDoorArea || !existsWorkplace)
{
mst.Status = VisitorAppointmentStatusEnumType.Obsolete;
}
await _dbContext.InsertAsync(mst);
foreach (var item in request.Items) foreach (var item in request.Items)
{ {
@@ -90,7 +111,9 @@ public class AppointmentService : IAppointmentService
Name = item.Name, Name = item.Name,
Phone = item.Phone, Phone = item.Phone,
Remark = item.Remark, Remark = item.Remark,
Status = AppointmentDetailEnumType.Wait, Status = mst.Status == VisitorAppointmentStatusEnumType.Valid
? VisitorAppointmentDetailStatusEnumType.Wait
: VisitorAppointmentDetailStatusEnumType.Obsolete,
LicensePlate = item.LicensePlate LicensePlate = item.LicensePlate
}; };

View File

@@ -7,7 +7,7 @@
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"dotnetRunMessages": true, "dotnetRunMessages": true,
"applicationUrl": "http://*:6000" "applicationUrl": "http://localhost:5000"
} }
}, },
"$schema": "https://json.schemastore.org/launchsettings.json" "$schema": "https://json.schemastore.org/launchsettings.json"

View File

@@ -16,10 +16,7 @@ public class Startup
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddEndpointsApiExplorer(); services.AddEndpointsApiExplorer();
services.AddSwaggerGen(c => services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Gateway API", Version = "v1", Description = "gateway api" }); });
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "Gateway API", Version = "v1", Description = "gateway api" });
});
services.AddOcelot(); services.AddOcelot();
} }
@@ -37,5 +34,4 @@ public class Startup
}); });
app.UseOcelot().Wait(); app.UseOcelot().Wait();
} }
} }

View File

@@ -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}", "UpstreamPathTemplate": "/api/scheduled/{url}",
"DownstreamPathTemplate": "/api/{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", "UpstreamPathTemplate": "/{url}/swagger/v1/swagger.json",
"DownstreamPathTemplate": "/{url}/swagger/v1/swagger.json", "DownstreamPathTemplate": "/{url}/swagger/v1/swagger.json",
"DownstreamScheme": "http", "DownstreamScheme": "http",
"DownstreamHostAndPorts": [ "DownstreamHostAndPorts": [
{ {
"Host": "192.168.199.115", "Host": "localhost",
"Port": 6000 "Port": 5000
} }
] ]
} }