diff --git a/Src/Dlhis.Visitor/Appointment/Controllers/AppointmentAreasController.cs b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs
similarity index 58%
rename from Src/Dlhis.Visitor/Appointment/Controllers/AppointmentAreasController.cs
rename to Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs
index 984da794..a286e912 100644
--- a/Src/Dlhis.Visitor/Appointment/Controllers/AppointmentAreasController.cs
+++ b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentAreasController.cs
@@ -1,12 +1,12 @@
-using Dlhis.Visitor.Appointment.Request;
-using Dlhis.Visitor.Appointment.Response;
-using Dlhis.Visitor.Appointment.Services;
+using Dlhis.Basic.Appointment.Request;
+using Dlhis.Basic.Appointment.Response;
+using Dlhis.Basic.Appointment.Services;
using Kurisu.AspNetCore.DataAccess.Dto;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-namespace Dlhis.Visitor.Appointment.Controllers;
+namespace Dlhis.Basic.Appointment.Controllers;
///
/// 预约区域
@@ -16,24 +16,13 @@ namespace Dlhis.Visitor.Appointment.Controllers;
[ApiController]
public class AppointmentAreasController : ControllerBase
{
- private readonly IAppointmentAreaService _apponintmentAreaService;
+ private readonly IAppointmentAreaService _appointmentAreaService;
- public AppointmentAreasController(IAppointmentAreaService apponintmentAreaService)
+ public AppointmentAreasController(IAppointmentAreaService appointmentAreaService )
{
- _apponintmentAreaService = apponintmentAreaService;
+ _appointmentAreaService = appointmentAreaService;
}
-
- ///
- /// 预约区域
- ///
- ///
- ///
- [HttpGet("page")]
- public async Task> GetPageAsync([FromQuery] PageDto request)
- {
- return await _apponintmentAreaService.GetPageAsync(request);
- }
-
+
///
/// 保存
///
@@ -42,19 +31,18 @@ public class AppointmentAreasController : ControllerBase
[HttpPost("save")]
public async Task SaveAsync(AppointmentAreaSaveRequest request)
{
- await _apponintmentAreaService.SaveAsync(request);
+ await _appointmentAreaService.SaveAsync(request);
}
-
///
- /// 删除
+ /// 预约区域分页
///
- ///
+ ///
///
- [HttpDelete("{id}")]
- public async Task DeleteAsync(long id)
+ [HttpGet("page")]
+ public async Task> GetPageAsync([FromQuery] AppointmentAreaPageRequest request)
{
- await _apponintmentAreaService.DeleteAsync(id);
+ return await _appointmentAreaService.GetPageAsync(request);
}
///
@@ -65,6 +53,6 @@ public class AppointmentAreasController : ControllerBase
[Transactional]
public async Task AssignAsync(AppointmentAreaAssignRequest request)
{
- await _apponintmentAreaService.AssignAsync(request);
+ await _appointmentAreaService.AssignAsync(request);
}
}
diff --git a/Src/Dlhis.Visitor/Appointment/Controllers/AppointmentsController.cs b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs
similarity index 84%
rename from Src/Dlhis.Visitor/Appointment/Controllers/AppointmentsController.cs
rename to Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs
index b8d63ac1..11b988ef 100644
--- a/Src/Dlhis.Visitor/Appointment/Controllers/AppointmentsController.cs
+++ b/Src/Dlhis.Basic/Appointment/Controllers/AppointmentsController.cs
@@ -1,13 +1,13 @@
using System.ComponentModel.DataAnnotations;
-using Dlhis.Visitor.Appointment.Request;
-using Dlhis.Visitor.Appointment.Response;
-using Dlhis.Visitor.Appointment.Services;
+using Dlhis.Basic.Appointment.Request;
+using Dlhis.Basic.Appointment.Response;
+using Dlhis.Basic.Appointment.Services;
using Kurisu.AspNetCore.DataAccess.Dto;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-namespace Dlhis.Visitor.Appointment.Controllers;
+namespace Dlhis.Basic.Appointment.Controllers;
///
/// 预约
@@ -23,7 +23,7 @@ public class AppointmentsController : ControllerBase
{
_appointmentService = appointmentService;
}
-
+
///
/// 预约申请分页
///
@@ -41,6 +41,7 @@ public class AppointmentsController : ControllerBase
///
///
[HttpPost("confirm")]
+ [Transactional]
public async Task ConfirmAsync(AppointmentConfirmRequest request)
{
await _appointmentService.ConfirmAsync(request);
@@ -54,9 +55,8 @@ public class AppointmentsController : ControllerBase
[AllowAnonymous]
[HttpGet("today")]
public async Task GetTodayByIdNoAsync(
- [FromQuery]
- [StringLength(18, MinimumLength = 18, ErrorMessage = "身份证有误")]
- [Required(ErrorMessage = "身份证有误")]string idNo)
+ [FromQuery] [StringLength(18, MinimumLength = 18, ErrorMessage = "身份证有误")] [Required(ErrorMessage = "身份证有误")]
+ string idNo)
{
return await _appointmentService.GetTodayByIdNoAsync(idNo);
}
@@ -72,4 +72,4 @@ public class AppointmentsController : ControllerBase
{
return await _appointmentService.GetRecordPageByIdNoAsync(request);
}
-}
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Visitor/Appointment/Dto/AppointmentReceiveItemDto.cs b/Src/Dlhis.Basic/Appointment/Dto/AppointmentReceiveItemDto.cs
similarity index 94%
rename from Src/Dlhis.Visitor/Appointment/Dto/AppointmentReceiveItemDto.cs
rename to Src/Dlhis.Basic/Appointment/Dto/AppointmentReceiveItemDto.cs
index 57cf552c..2071e4c0 100644
--- a/Src/Dlhis.Visitor/Appointment/Dto/AppointmentReceiveItemDto.cs
+++ b/Src/Dlhis.Basic/Appointment/Dto/AppointmentReceiveItemDto.cs
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
-namespace Dlhis.Visitor.Appointment.Dto;
+namespace Dlhis.Basic.Appointment.Dto;
public class AppointmentReceiveItemDto
{
diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaAssignRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs
similarity index 87%
rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaAssignRequest.cs
rename to Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs
index 755a14a8..aec22aaf 100644
--- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaAssignRequest.cs
+++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaAssignRequest.cs
@@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
-namespace Dlhis.Visitor.Appointment.Request;
+namespace Dlhis.Basic.Appointment.Request;
public class AppointmentAreaAssignRequest
{
@@ -14,4 +14,4 @@ public class AppointmentAreaAssignRequest
/// 分组
///
public List DeviceCodes { get; set; }
-}
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaPageRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaPageRequest.cs
new file mode 100644
index 00000000..20a43294
--- /dev/null
+++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaPageRequest.cs
@@ -0,0 +1,14 @@
+using System.ComponentModel.DataAnnotations;
+using Dlhis.Entity.Visitor.Enums;
+using Kurisu.AspNetCore.DataAccess.Dto;
+
+namespace Dlhis.Basic.Appointment.Request;
+
+public class AppointmentAreaPageRequest : PageDto
+{
+ ///
+ /// 区域类型
+ ///
+ [EnumDataType(typeof(AppointmentAreaEnumType))]
+ public AppointmentAreaEnumType? Type { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaSaveRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaSaveRequest.cs
similarity index 83%
rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaSaveRequest.cs
rename to Src/Dlhis.Basic/Appointment/Request/AppointmentAreaSaveRequest.cs
index 7a0ba649..f7d5b03e 100644
--- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentAreaSaveRequest.cs
+++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentAreaSaveRequest.cs
@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using Dlhis.Entity.Visitor.Enums;
-namespace Dlhis.Visitor.Appointment.Request;
+namespace Dlhis.Basic.Appointment.Request;
public class AppointmentAreaSaveRequest
{
@@ -17,13 +17,13 @@ public class AppointmentAreaSaveRequest
public AppointmentAreaEnumType Type { get; set; }
///
- /// 预期编码
+ /// 编码
///
- [Required]
+ [Required(ErrorMessage = "编码不能为空")]
public string CustomCode { get; set; }
///
- /// 姓名
+ /// 名称
///
[Required]
public string Name { get; set; }
@@ -32,4 +32,4 @@ public class AppointmentAreaSaveRequest
/// 备注
///
public string Remark { get; set; }
-}
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentConfirmRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentConfirmRequest.cs
similarity index 74%
rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentConfirmRequest.cs
rename to Src/Dlhis.Basic/Appointment/Request/AppointmentConfirmRequest.cs
index c3cf17e5..c544bb98 100644
--- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentConfirmRequest.cs
+++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentConfirmRequest.cs
@@ -1,4 +1,4 @@
-namespace Dlhis.Visitor.Appointment.Request;
+namespace Dlhis.Basic.Appointment.Request;
public class AppointmentConfirmRequest
{
diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentIdNoPageRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentIdNoPageRequest.cs
similarity index 89%
rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentIdNoPageRequest.cs
rename to Src/Dlhis.Basic/Appointment/Request/AppointmentIdNoPageRequest.cs
index bc8682e0..e620a087 100644
--- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentIdNoPageRequest.cs
+++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentIdNoPageRequest.cs
@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using Kurisu.AspNetCore.DataAccess.Dto;
-namespace Dlhis.Visitor.Appointment.Request;
+namespace Dlhis.Basic.Appointment.Request;
public class AppointmentIdNoPageRequest : PageDto
{
diff --git a/Src/Dlhis.Basic/Appointment/Request/AppointmentPageRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentPageRequest.cs
new file mode 100644
index 00000000..5ac43759
--- /dev/null
+++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentPageRequest.cs
@@ -0,0 +1,20 @@
+using System.ComponentModel.DataAnnotations;
+using Kurisu.AspNetCore.CustomClass;
+using Kurisu.AspNetCore.DataAccess.Dto;
+
+namespace Dlhis.Basic.Appointment.Request;
+
+public class AppointmentPageRequest : PageDto , IValidatableObject
+{
+ public DateTimePeriod SearchDateTimePeriod { get; set; }
+
+ ///
+ public IEnumerable Validate(ValidationContext validationContext)
+ {
+ if (SearchDateTimePeriod.HasValue())
+ {
+ SearchDateTimePeriod.End = SearchDateTimePeriod.End!.Value.AddDays(1).AddSeconds(-1);
+ }
+ yield break;
+ }
+}
diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentReceiveRequest.cs b/Src/Dlhis.Basic/Appointment/Request/AppointmentReceiveRequest.cs
similarity index 96%
rename from Src/Dlhis.Visitor/Appointment/Request/AppointmentReceiveRequest.cs
rename to Src/Dlhis.Basic/Appointment/Request/AppointmentReceiveRequest.cs
index 3028e970..25565f62 100644
--- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentReceiveRequest.cs
+++ b/Src/Dlhis.Basic/Appointment/Request/AppointmentReceiveRequest.cs
@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
-using Dlhis.Visitor.Appointment.Dto;
+using Dlhis.Basic.Appointment.Dto;
-namespace Dlhis.Visitor.Appointment.Request;
+namespace Dlhis.Basic.Appointment.Request;
public class AppointmentReceiveRequest : IValidatableObject
{
diff --git a/Src/Dlhis.Visitor/Appointment/Response/ApponintmentAreaPageResponse.cs b/Src/Dlhis.Basic/Appointment/Response/AppointmentAreaPageResponse.cs
similarity index 86%
rename from Src/Dlhis.Visitor/Appointment/Response/ApponintmentAreaPageResponse.cs
rename to Src/Dlhis.Basic/Appointment/Response/AppointmentAreaPageResponse.cs
index 6197d54f..f6c27e7d 100644
--- a/Src/Dlhis.Visitor/Appointment/Response/ApponintmentAreaPageResponse.cs
+++ b/Src/Dlhis.Basic/Appointment/Response/AppointmentAreaPageResponse.cs
@@ -1,17 +1,17 @@
using Dlhis.Entity.Visitor.Enums;
using Kurisu.AspNetCore.Utils.Extensions;
-namespace Dlhis.Visitor.Appointment.Response;
+namespace Dlhis.Basic.Appointment.Response;
-public class ApponintmentAreaPageResponse
+public class AppointmentAreaPageResponse
{
public long Id { get; set; }
-
+
///
/// 区域类型
///
public AppointmentAreaEnumType Type { get; set; }
-
+
///
/// 区域类型
///
@@ -21,7 +21,7 @@ public class ApponintmentAreaPageResponse
/// 自定义编码
///
public string CustomCode { get; set; }
-
+
///
/// 名称
///
@@ -31,4 +31,4 @@ public class ApponintmentAreaPageResponse
/// 备注
///
public string Remark { get; set; }
-}
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Appointment/Response/AppointmentDetailResponse.cs b/Src/Dlhis.Basic/Appointment/Response/AppointmentDetailResponse.cs
new file mode 100644
index 00000000..9a0cd25c
--- /dev/null
+++ b/Src/Dlhis.Basic/Appointment/Response/AppointmentDetailResponse.cs
@@ -0,0 +1,102 @@
+using Dlhis.Entity.Visitor.Enums;
+
+namespace Dlhis.Basic.Appointment.Response;
+
+public class AppointmentDetailResponse
+{
+ ///
+ /// 流水号
+ ///
+ public string No { get; set; }
+
+ ///
+ /// no
+ ///
+ public string UserNo { get; set; }
+
+ ///
+ /// 证件类型
+ ///
+ public string IdType { get; set; }
+
+ ///
+ /// 证件号
+ ///
+ public string IdNo { get; set; }
+
+ ///
+ /// 访客名称
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 手机号
+ ///
+ public string Phone { get; set; }
+
+ ///
+ /// 车牌
+ ///
+ public string LicensePlate { get; set; }
+
+ ///
+ /// 进入门岗
+ ///
+ public bool IsEnterDoorArea { get; set; }
+
+ ///
+ /// 预约门禁区域
+ ///
+ public string ApplyDoorArea { get; set; }
+
+ ///
+ /// 访客开始
+ ///
+ public DateTime DoorStart { get; set; }
+
+ ///
+ /// 访问结束
+ ///
+ public DateTime DoorEnd { get; set; }
+
+ ///
+ /// 是否进入车间
+ ///
+ public bool IsEnterWorkplace { get; set; }
+
+ ///
+ /// 申请车间区域
+ ///
+ public List ApplyWorkplaceAreas { get; set; }
+
+ ///
+ /// 车间访问开始
+ ///
+ public DateTime? WorkplaceStart { get; set; }
+
+ ///
+ /// 车间访问结束
+ ///
+ public DateTime? WorkplaceEnd { get; set; }
+
+ ///
+ /// 社保照片url
+ ///
+ public string ImageUrl { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public string Remark { get; set; }
+
+
+ ///
+ /// 门禁状态
+ ///
+ public VisitorAppointmentDetailStatusEnumType DoorStatus { get; set; }
+
+ ///
+ /// 车间状态
+ ///
+ public VisitorAppointmentDetailStatusEnumType WorkplaceStatus { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Appointment/Response/AppointmentPageResponse.cs b/Src/Dlhis.Basic/Appointment/Response/AppointmentPageResponse.cs
new file mode 100644
index 00000000..90315d30
--- /dev/null
+++ b/Src/Dlhis.Basic/Appointment/Response/AppointmentPageResponse.cs
@@ -0,0 +1,41 @@
+namespace Dlhis.Basic.Appointment.Response;
+
+public class AppointmentPageResponse
+{
+ public string No { get; set; }
+
+ ///
+ /// 标题
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// 对接人工号
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// 来访人来源/公司
+ ///
+ public string Source { get; set; }
+
+ ///
+ /// 申请时间
+ ///
+ public DateTime Date { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public string Remark { get; set; }
+
+ ///
+ /// 预约厂区
+ ///
+ public string Factory { get; set; }
+
+ ///
+ /// 申请事由
+ ///
+ public string Reason { get; set; }
+}
diff --git a/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs b/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs
new file mode 100644
index 00000000..90fb0727
--- /dev/null
+++ b/Src/Dlhis.Basic/Appointment/Services/IAppointmentAreaService.cs
@@ -0,0 +1,29 @@
+using Dlhis.Basic.Appointment.Request;
+using Dlhis.Basic.Appointment.Response;
+using Kurisu.AspNetCore.DataAccess.Dto;
+
+namespace Dlhis.Basic.Appointment.Services;
+
+public interface IAppointmentAreaService : IScopeDependency
+{
+ ///
+ /// 区域分页
+ ///
+ ///
+ ///
+ Task> GetPageAsync(AppointmentAreaPageRequest request);
+
+ ///
+ /// 保存区域
+ ///
+ ///
+ ///
+ Task SaveAsync(AppointmentAreaSaveRequest request);
+
+ ///
+ /// 分配设备组到区域
+ ///
+ ///
+ ///
+ Task AssignAsync(AppointmentAreaAssignRequest request);
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Visitor/Appointment/Services/IAppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs
similarity index 84%
rename from Src/Dlhis.Visitor/Appointment/Services/IAppointmentService.cs
rename to Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs
index e601d02f..1480c464 100644
--- a/Src/Dlhis.Visitor/Appointment/Services/IAppointmentService.cs
+++ b/Src/Dlhis.Basic/Appointment/Services/IAppointmentService.cs
@@ -1,9 +1,9 @@
-using Dlhis.Visitor.Appointment.Request;
-using Dlhis.Visitor.Appointment.Response;
+using Dlhis.Basic.Appointment.Request;
+using Dlhis.Basic.Appointment.Response;
using Kurisu.AspNetCore.DataAccess.Dto;
using Microsoft.AspNetCore.Mvc;
-namespace Dlhis.Visitor.Appointment.Services;
+namespace Dlhis.Basic.Appointment.Services;
public interface IAppointmentService : IScopeDependency
{
@@ -17,9 +17,9 @@ public interface IAppointmentService : IScopeDependency
///
/// 查看明细
///
- ///
+ ///
///
- Task> GetAppointmentDetailsByIdAsync(long id);
+ Task> GetAppointmentDetailsByIdAsync(string no);
///
/// 确认到达
diff --git a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs
new file mode 100644
index 00000000..74e36c98
--- /dev/null
+++ b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentAreaService.cs
@@ -0,0 +1,180 @@
+using Dlhis.Basic.Appointment.Request;
+using Dlhis.Basic.Appointment.Response;
+using Dlhis.Entity.Basic.Entity;
+using Dlhis.Entity.Device.Entities;
+using Dlhis.Entity.Device.Enums;
+using Dlhis.Entity.Visitor.Entity;
+using Dlhis.Entity.Visitor.Enums;
+using Kurisu.AspNetCore.DataAccess.Dto;
+using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
+using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
+using Kurisu.AspNetCore.Utils.Extensions;
+using Mapster;
+
+namespace Dlhis.Basic.Appointment.Services.Implements;
+
+public class AppointmentAreaService : IAppointmentAreaService
+{
+ private readonly IDbContext _dbContext;
+
+ public AppointmentAreaService(IDbContext dbContext)
+ {
+ _dbContext = dbContext;
+ }
+
+ public async Task SaveAsync(AppointmentAreaSaveRequest request)
+ {
+ if (!request.Id.HasValue)
+ {
+ var entity = request.Adapt();
+ entity.CustomCode = request.CustomCode;
+ entity.Type = request.Type;
+ await _dbContext.InsertAsync(entity);
+ }
+ else
+ {
+ var entity = await _dbContext.Queryable().Where(x => x.Id == request.Id).SingleAsync();
+ entity.ThrowIfNull("预约区域不存在");
+ request.Adapt(entity);
+ await _dbContext.UpdateAsync(entity);
+ }
+ }
+
+ public async Task> GetPageAsync(AppointmentAreaPageRequest request)
+ {
+ return await _dbContext.Queryable()
+ .WhereIF(request.Type.HasValue, x => x.Type == request.Type)
+ .WhereIF(request.Search.IsPresent(), x => x.CustomCode == request.Search || x.Name.Contains(request.Search))
+ .Select()
+ .ToPageListAsync(request);
+ }
+
+ public async Task AssignAsync(AppointmentAreaAssignRequest request)
+ {
+ (await _dbContext.Queryable().Where(x => x.CustomCode == request.CustomCode).AnyAsync())
+ .ThrowIfFalse("区域不存在");
+
+ var userBeforePermissions = await GetMyPermissionsAsync(request.CustomCode);
+ var userNos = userBeforePermissions.Select(x => x.Key).ToList();
+
+ //删除原来的配置
+ await _dbContext.Client.Deleteable()
+ .Where(x => x.CustomCode == request.CustomCode)
+ .ExecuteCommandAsync();
+
+ //添加当前区域的设置
+ var data = request.DeviceCodes.Select(x => new AppointmentAreaAssignmentEntity
+ {
+ CustomCode = request.CustomCode,
+ DeviceCode = x
+ }).ToList();
+
+ await _dbContext.InsertAsync(data);
+
+ var userCurrentPermissions = await GetMyPermissionsAsync(request.CustomCode);
+
+ var allDeviceCodes = userCurrentPermissions.SelectMany(x => x.Value);
+ var devices = await _dbContext.Queryable().Where(x => allDeviceCodes.Contains(x.Code)).ToListAsync();
+
+ var tasks = new List();
+ foreach (var userNo in userNos)
+ {
+ var before = userBeforePermissions[userNo];
+ var current = userCurrentPermissions[userNo];
+
+ //被删除
+ var deletedItems = before.Where(x => !current.Contains(x)).ToList();
+ //新增
+ var addItems = current.Where(x => !before.Contains(x)).ToList();
+
+ if (!deletedItems.Any() && !addItems.Any())
+ {
+ continue;
+ }
+
+ tasks.AddRange(deletedItems.Select(x => new DeviceTaskEntity
+ {
+ Type = DeviceTaskEnumType.Delete,
+ DeviceType = DeviceTypeEnumType.Door,
+ UserNo = userNo,
+ DeviceUniqueNo = devices.First(item => item.Code == x).UniqueNo,
+ Status = DeviceTaskStatusEnumType.Wait,
+ Version = 0,
+ CancellationId = 0,
+ Source = DeviceTaskSourceEnumType.Appointment,
+ Priority = 99
+ }));
+
+ tasks.AddRange(addItems.Select(x => new DeviceTaskEntity
+ {
+ Type = DeviceTaskEnumType.Add,
+ DeviceType = DeviceTypeEnumType.Door,
+ UserNo = userNo,
+ DeviceUniqueNo = devices.First(item => item.Code == x).UniqueNo,
+ Status = DeviceTaskStatusEnumType.Wait,
+ Version = 0,
+ CancellationId = 0,
+ Source = DeviceTaskSourceEnumType.Appointment,
+ Priority = 99
+ }));
+ }
+
+ await _dbContext.InsertAsync(tasks);
+ }
+
+
+ //********************************************************* help methods ***************************************************************
+
+
+ private async Task>> GetMyPermissionsAsync(string areaCode)
+ {
+ //获取已经到达的数据
+ var arrivedInfos = await _dbContext.Queryable()
+ .Where(x => x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Arrived || x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Arrived)
+ .Select(x => new
+ {
+ x.UserNo,
+ x.DoorStatus,
+ x.WorkplaceStatus,
+ x.IsEnterDoorArea,
+ x.ApplyDoorArea,
+ x.IsEnterWorkplace,
+ x.ApplyWorkplaceAreas
+ })
+ .ToListAsync();
+
+ var userAreaCodes = arrivedInfos.GroupBy(x => x.UserNo).ToDictionary(p => p.Key, ls =>
+ {
+ return ls.SelectMany(x =>
+ {
+ var list = new List();
+ if (x.DoorStatus == VisitorAppointmentDetailStatusEnumType.Arrived)
+ {
+ list.Add(x.ApplyDoorArea);
+ }
+
+ if (x.WorkplaceStatus == VisitorAppointmentDetailStatusEnumType.Arrived)
+ {
+ list.AddRange(x.ApplyWorkplaceAreas);
+ }
+
+ return list;
+ });
+ });
+
+ userAreaCodes = userAreaCodes.Where(x => x.Value.Contains(areaCode)).ToDictionary(x => x.Key, x => x.Value);
+
+ var userBeforePermissions = new Dictionary>(userAreaCodes.Count);
+ foreach ((string currentUserNo, IEnumerable currentUseAreaCode) in userAreaCodes)
+ {
+ var deviceCodes = await _dbContext.Queryable()
+ .Where(x => currentUseAreaCode.Contains(x.CustomCode))
+ .Select(x => x.DeviceCode)
+ .ToListAsync();
+
+ userBeforePermissions.Add(currentUserNo, deviceCodes);
+ }
+
+ return userBeforePermissions;
+ }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs
new file mode 100644
index 00000000..ab32b99e
--- /dev/null
+++ b/Src/Dlhis.Basic/Appointment/Services/Implements/AppointmentService.cs
@@ -0,0 +1,145 @@
+using Dlhis.Basic.Appointment.Request;
+using Dlhis.Basic.Appointment.Response;
+using Dlhis.Entity.Basic.Entity;
+using Dlhis.Entity.Device.Entities;
+using Dlhis.Entity.Device.Enums;
+using Dlhis.Entity.Visitor.Entity;
+using Dlhis.Entity.Visitor.Enums;
+using Kurisu.AspNetCore.CustomClass;
+using Kurisu.AspNetCore.DataAccess.Dto;
+using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
+using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
+using Kurisu.AspNetCore.Utils.Extensions;
+using Microsoft.AspNetCore.DataProtection;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+
+namespace Dlhis.Basic.Appointment.Services.Implements;
+
+public class AppointmentService : IAppointmentService
+{
+ private readonly IDbContext _dbContext;
+ private readonly IDataProtectionProvider _dataProtectionProvider;
+
+ public AppointmentService(IDbContext dbContext, IDataProtectionProvider dataProtectionProvider)
+ {
+ _dbContext = dbContext;
+ _dataProtectionProvider = dataProtectionProvider;
+ }
+
+ public async Task> GetPageAsync(AppointmentPageRequest request)
+ {
+ return await _dbContext.Queryable()
+ .WhereIF(request.SearchDateTimePeriod.HasValue(),
+ x => x.Date >= request.SearchDateTimePeriod.Start && x.Date <= request.SearchDateTimePeriod.End)
+ .WhereIF(request.Search.IsPresent(), x => x.Code == request.Search)
+ .Select()
+ .ToPageListAsync(request);
+ }
+
+ public async Task> GetAppointmentDetailsByIdAsync(string no)
+ {
+ return await _dbContext.Queryable()
+ .Where(x => x.No == no)
+ .Select()
+ .ToListAsync();
+ }
+
+ public async Task ConfirmAsync(AppointmentConfirmRequest request)
+ {
+ var detail = await _dbContext.Queryable().Where(x => x.Id == request.Id).SingleAsync();
+ detail.ThrowIfNull("预约信息不存在");
+
+ var areaCodes = GetValidAreaCodes(detail);
+ var existsAreaCodes = await _dbContext.Queryable().Where(x => areaCodes.Contains(x.CustomCode)).Select(x => x.CustomCode).ToListAsync();
+
+ //当前分配的设备codes
+ var deviceCodes = await _dbContext.Queryable()
+ .Where(x => existsAreaCodes.Contains(x.CustomCode))
+ .Select(x => x.DeviceCode)
+ .ToListAsync();
+
+ var deviceUniqueNos = await _dbContext.Queryable().Where(x => deviceCodes.Contains(x.Code)).Select(x => new { x.UniqueNo, x.TenantId }).ToListAsync();
+
+ await _dbContext.InsertAsync(deviceUniqueNos.Select(x => new DeviceTaskEntity
+ {
+ DeviceType = DeviceTypeEnumType.Door,
+ DeviceUniqueNo = x.UniqueNo,
+ Status = DeviceTaskStatusEnumType.Wait,
+ UserNo = detail.UserNo,
+ Type = DeviceTaskEnumType.Add,
+ Priority = 100,
+ TenantId = x.TenantId,
+ Source = DeviceTaskSourceEnumType.Appointment,
+ Version = 0,
+ }).ToList());
+
+ detail.DoorStatus = VisitorAppointmentDetailStatusEnumType.Arrived;
+ detail.WorkplaceStatus = VisitorAppointmentDetailStatusEnumType.Arrived;
+ detail.ArrivedTime = DateTime.Now;
+ await _dbContext.UpdateAsync(detail);
+ }
+
+
+ private static IEnumerable GetValidAreaCodes(VisitorAppointmentDetailEntity detail)
+ {
+ if (detail.IsEnterDoorArea)
+ {
+ yield return detail.ApplyDoorArea;
+ }
+
+ if (detail.IsEnterWorkplace)
+ {
+ foreach (var item in detail.ApplyWorkplaceAreas)
+ {
+ yield return item;
+ }
+ }
+ }
+
+ //********************************************************** 用户操作 *******************************************************************
+
+
+ public async Task GetTodayByIdNoAsync(string idNo)
+ {
+ var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno");
+ try
+ {
+ idNo = protector.Unprotect(idNo);
+ }
+ catch (Exception)
+ {
+ throw new UserFriendlyException("凭证有误");
+ }
+
+ var now = DateTime.Now;
+ return await _dbContext.Queryable()
+ .LeftJoin((x, ga) => ga.IdNo == idNo)
+ .Where((x, ga) => ga.IdNo == idNo)
+ .Where(x => (x.IsEnterDoorArea && SqlFunc.DateIsSame(x.DoorStart, now)) || (x.IsEnterWorkplace && SqlFunc.DateIsSame(x.WorkplaceStart, now)))
+ .Select()
+ .SingleAsync();
+ }
+
+ public async Task> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request)
+ {
+ var protector = _dataProtectionProvider.CreateProtector("gainfo:external:idno");
+ try
+ {
+ request.IdNo = protector.Unprotect(request.IdNo);
+ }
+ catch (Exception)
+ {
+ throw new UserFriendlyException("凭证有误");
+ }
+
+ var page = await _dbContext.Queryable()
+ .LeftJoin((x, ga) => x.UserNo == ga.No)
+ .Where((x, ga) => ga.IdNo == request.IdNo)
+ .OrderBy(x => x.CreateTime)
+ .Select()
+ .ToPageListAsync(request);
+
+ return page;
+ }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
index 1e3f678b..332d1fcf 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
@@ -101,7 +101,7 @@ public class DeviceService : IDeviceService
.Where((dgr, dg) => dgr.DeviceCode == entity.Code)
.AnyAsync();
- existsG.ThrowIfTrue("存在设备分组,不可修改设备分类");
+ existsG.ThrowIfTrue("存在设备分组,不可修改设备类型");
}
request.Adapt(entity);
diff --git a/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentDetailEntity.cs b/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentDetailEntity.cs
index a73e98aa..c7b01aaa 100644
--- a/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentDetailEntity.cs
+++ b/Src/Dlhis.Entity/Visitor/Entity/VisitorAppointmentDetailEntity.cs
@@ -104,13 +104,18 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "备注")]
public string Remark { get; set; }
-
///
/// 门禁状态
///
[SugarColumn(IsNullable = false, ColumnDescription = "门禁状态", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
public VisitorAppointmentDetailStatusEnumType DoorStatus { get; set; }
+ ///
+ /// 到达时间
+ ///
+ [SugarColumn(IsNullable = true)]
+ public DateTime? ArrivedTime { get; set; }
+
///
/// 车间状态
///
diff --git a/Src/Dlhis.Visitor/Appointment/Request/AppointmentPageRequest.cs b/Src/Dlhis.Visitor/Appointment/Request/AppointmentPageRequest.cs
deleted file mode 100644
index cec11f6d..00000000
--- a/Src/Dlhis.Visitor/Appointment/Request/AppointmentPageRequest.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Kurisu.AspNetCore.CustomClass;
-using Kurisu.AspNetCore.DataAccess.Dto;
-
-namespace Dlhis.Visitor.Appointment.Request;
-
-public class AppointmentPageRequest : PageDto
-{
- public DateTimePeriod SearchDateTimePeriod { get; set; }
-}