fix 访客预约优化
This commit is contained in:
@@ -14,6 +14,12 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
|
|||||||
[SugarColumn(IsNullable = false, ColumnDescription = "父id")]
|
[SugarColumn(IsNullable = false, ColumnDescription = "父id")]
|
||||||
public long AppointmentId { get; set; }
|
public long AppointmentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// no
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = false, ColumnDescription = "用户no")]
|
||||||
|
public string UserNo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 流水号
|
/// 流水号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -70,4 +76,4 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsNullable = true, ColumnDescription = "备注")]
|
[SugarColumn(IsNullable = true, ColumnDescription = "备注")]
|
||||||
public string Remark { get; set; }
|
public string Remark { get; set; }
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Dlhis.Visitor.Appointment.Request;
|
using Dlhis.Visitor.Appointment.Request;
|
||||||
using Dlhis.Visitor.Appointment.Response;
|
using Dlhis.Visitor.Appointment.Response;
|
||||||
using Dlhis.Visitor.Appointment.Services;
|
using Dlhis.Visitor.Appointment.Services;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||||
using Kurisu.Core.DataAccess.Dto;
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -13,11 +14,11 @@ namespace Dlhis.Visitor.Appointment.Controllers;
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
[Route("api/[controller]")]
|
[Route("api/[controller]")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class ApponintmentAreasController : ControllerBase
|
public class AppointmentAreasController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IApponintmentAreaService _apponintmentAreaService;
|
private readonly IAppointmentAreaService _apponintmentAreaService;
|
||||||
|
|
||||||
public ApponintmentAreasController(IApponintmentAreaService apponintmentAreaService)
|
public AppointmentAreasController(IAppointmentAreaService apponintmentAreaService)
|
||||||
{
|
{
|
||||||
_apponintmentAreaService = apponintmentAreaService;
|
_apponintmentAreaService = apponintmentAreaService;
|
||||||
}
|
}
|
||||||
@@ -61,6 +62,7 @@ public class ApponintmentAreasController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("assign")]
|
[HttpPost("assign")]
|
||||||
|
[Transactional]
|
||||||
public async Task AssignAsync(AppointmentAreaAssignRequest request)
|
public async Task AssignAsync(AppointmentAreaAssignRequest request)
|
||||||
{
|
{
|
||||||
await _apponintmentAreaService.AssignAsync(request);
|
await _apponintmentAreaService.AssignAsync(request);
|
||||||
@@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
namespace Dlhis.Visitor.Appointment.Controllers;
|
namespace Dlhis.Visitor.Appointment.Controllers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ԤԼ
|
/// 预约
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
@@ -25,7 +25,7 @@ public class AppointmentsController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԤԼд<EFBFBD><EFBFBD>
|
/// 接受预约申请
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -39,7 +39,7 @@ public class AppointmentsController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ԤԼ<EFBFBD><EFBFBD>ҳ
|
/// 预约申请分页
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -50,7 +50,7 @@ public class AppointmentsController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ȷ<EFBFBD>ϵ<EFBFBD><EFBFBD><EFBFBD>
|
/// 确认到达
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -61,7 +61,7 @@ public class AppointmentsController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD>ԤԼ
|
/// 根据身份证获取当天预约信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idNo"></param>
|
/// <param name="idNo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@@ -69,12 +69,17 @@ public class AppointmentsController : ControllerBase
|
|||||||
[HttpGet("today")]
|
[HttpGet("today")]
|
||||||
public async Task<AppointmentDetailResponse> GetTodayByIdNoAsync(
|
public async Task<AppointmentDetailResponse> GetTodayByIdNoAsync(
|
||||||
[FromQuery]
|
[FromQuery]
|
||||||
[StringLength(18, MinimumLength = 18, ErrorMessage = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD>")]
|
[StringLength(18, MinimumLength = 18, ErrorMessage = "身份证有误")]
|
||||||
[Required(ErrorMessage = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>")]string idNo)
|
[Required(ErrorMessage = "身份证有误")]string idNo)
|
||||||
{
|
{
|
||||||
return await _appointmentService.GetTodayByIdNoAsync(idNo);
|
return await _appointmentService.GetTodayByIdNoAsync(idNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据身份证获取预约信息分页
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpGet("idno/page")]
|
[HttpGet("idno/page")]
|
||||||
public async Task<Pagination<AppointmentDetailResponse>> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request)
|
public async Task<Pagination<AppointmentDetailResponse>> GetRecordPageByIdNoAsync([FromQuery] AppointmentIdNoPageRequest request)
|
||||||
|
|||||||
@@ -2,5 +2,8 @@
|
|||||||
|
|
||||||
public class AppointmentConfirmRequest
|
public class AppointmentConfirmRequest
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 预约明细id
|
||||||
|
/// </summary>
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,10 @@ using Kurisu.Core.DataAccess.Dto;
|
|||||||
|
|
||||||
namespace Dlhis.Visitor.Appointment.Services;
|
namespace Dlhis.Visitor.Appointment.Services;
|
||||||
|
|
||||||
public interface IApponintmentAreaService : IScopeDependency
|
public interface IAppointmentAreaService : IScopeDependency
|
||||||
{
|
{
|
||||||
Task<Pagination<ApponintmentAreaPageResponse>> GetPageAsync(PageDto request);
|
Task<Pagination<ApponintmentAreaPageResponse>> GetPageAsync(PageDto request);
|
||||||
|
|
||||||
Task SaveAsync(AppointmentAreaSaveRequest request);
|
Task SaveAsync(AppointmentAreaSaveRequest request);
|
||||||
|
|
||||||
Task DeleteAsync(long id);
|
Task DeleteAsync(long id);
|
||||||
|
|
||||||
|
|
||||||
Task AssignAsync(AppointmentAreaAssignRequest request);
|
Task AssignAsync(AppointmentAreaAssignRequest request);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
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 Dlhis.Visitor.Appointment.Request;
|
||||||
|
using Dlhis.Visitor.Appointment.Response;
|
||||||
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
|
using Kurisu.SqlSugar.Extensions;
|
||||||
|
using Kurisu.SqlSugar.Services;
|
||||||
|
using Mapster;
|
||||||
|
|
||||||
|
namespace Dlhis.Visitor.Appointment.Services.Implements;
|
||||||
|
|
||||||
|
public class AppointmentAreaService : IAppointmentAreaService
|
||||||
|
{
|
||||||
|
private readonly IDbContext _dbContext;
|
||||||
|
|
||||||
|
public AppointmentAreaService(IDbContext dbContext)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Pagination<ApponintmentAreaPageResponse>> GetPageAsync(PageDto request)
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<AppointmentAreaEntity>()
|
||||||
|
.Select<ApponintmentAreaPageResponse>()
|
||||||
|
.ToPageListAsync(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task SaveAsync(AppointmentAreaSaveRequest request)
|
||||||
|
{
|
||||||
|
await CheckCustomCodeDuplicateAsync(request);
|
||||||
|
|
||||||
|
if (!request.Id.HasValue)
|
||||||
|
{
|
||||||
|
var entity = request.Adapt<AppointmentAreaEntity>();
|
||||||
|
entity.Type = request.Type;
|
||||||
|
entity.CustomCode = request.CustomCode;
|
||||||
|
|
||||||
|
await _dbContext.InsertAsync(entity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var entity = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
||||||
|
entity.ThrowIfNull("预约区域不存在");
|
||||||
|
|
||||||
|
request.Adapt(entity);
|
||||||
|
|
||||||
|
await _dbContext.UpdateAsync(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task DeleteAsync(long id)
|
||||||
|
{
|
||||||
|
var entity = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.Id == id).SingleAsync();
|
||||||
|
await _dbContext.DeleteAsync(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task AssignAsync(AppointmentAreaAssignRequest request)
|
||||||
|
{
|
||||||
|
var userNos = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||||
|
.LeftJoin<VisitorAppointmentEntity>((x, y) => x.FlowId == y.FlowId)
|
||||||
|
.Where(x => x.Status == AppointmentDetailEnumType.Arrived)
|
||||||
|
.Where((x, y) => y.AreaCustomCode == request.CustomCode)
|
||||||
|
.Select(x => x.UserNo)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
//通过人
|
||||||
|
var deviceCodes = await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
|
||||||
|
.Where(x => x.CustomCode == request.CustomCode).Select(x => x.DeviceCode).ToListAsync();
|
||||||
|
|
||||||
|
var userPermissions = userNos.ToDictionary(x => x, _ => deviceCodes.ToList());
|
||||||
|
|
||||||
|
await _dbContext.Client.Deleteable<AppointmentAreaAssignmentEntity>()
|
||||||
|
.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);
|
||||||
|
|
||||||
|
|
||||||
|
deviceCodes = await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
|
||||||
|
.Where(x => x.CustomCode == request.CustomCode).Select(x => x.DeviceCode).ToListAsync();
|
||||||
|
|
||||||
|
var devices = await _dbContext.Queryable<DeviceEntity>().Where(x => deviceCodes.Contains(x.Code)).ToListAsync();
|
||||||
|
|
||||||
|
var userCurrentPermissions = userNos.ToDictionary(x => x, _ => deviceCodes.ToList());
|
||||||
|
|
||||||
|
var tasks = new List<DeviceTaskEntity>();
|
||||||
|
foreach (var userNo in userNos)
|
||||||
|
{
|
||||||
|
var before = userPermissions[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 ***************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查编码重复
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task CheckCustomCodeDuplicateAsync(AppointmentAreaSaveRequest request)
|
||||||
|
{
|
||||||
|
var exists = await _dbContext.Queryable<AppointmentAreaEntity>()
|
||||||
|
.Where(x => x.CustomCode == request.CustomCode)
|
||||||
|
.WhereIF(request.Id.HasValue, x => x.Id == request.Id)
|
||||||
|
.AnyAsync();
|
||||||
|
|
||||||
|
exists.ThrowIfTrue("重复区域编码,请检查");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,15 +39,12 @@ public class AppointmentService : IAppointmentService
|
|||||||
area.ThrowIfNull("预约区域不存在");
|
area.ThrowIfNull("预约区域不存在");
|
||||||
|
|
||||||
var where = LinqExpressionExtensions.False<VisitorAppointmentDetailEntity>();
|
var where = LinqExpressionExtensions.False<VisitorAppointmentDetailEntity>();
|
||||||
request.Items.ForEach(item =>
|
request.Items.ForEach(item => { where = where.Or(x => !(x.End < request.Start || x.Start > request.End)).And(x => x.IdNo == item.IdNo); });
|
||||||
{
|
|
||||||
where = where.Or(x => !(x.End < request.Start || x.Start > request.End)).And(x => x.IdNo == item.IdNo);
|
|
||||||
});
|
|
||||||
|
|
||||||
var existsDetails = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
var existsDetails = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||||
.Where(where)
|
.Where(where)
|
||||||
.Where(x => x.Status == AppointmentDetailEnumType.Wait || x.Status == AppointmentDetailEnumType.Arrived)
|
.Where(x => x.Status == AppointmentDetailEnumType.Wait || x.Status == AppointmentDetailEnumType.Arrived)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
existsDetails.ThrowIfExists($"{existsDetails.Select(x => x.Name).Join(",")}存在预约时间冲突,请检查");
|
existsDetails.ThrowIfExists($"{existsDetails.Select(x => x.Name).Join(",")}存在预约时间冲突,请检查");
|
||||||
|
|
||||||
@@ -65,7 +62,8 @@ public class AppointmentService : IAppointmentService
|
|||||||
|
|
||||||
foreach (var item in request.Items)
|
foreach (var item in request.Items)
|
||||||
{
|
{
|
||||||
var isExternal = !await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.IdNo).AnyAsync();
|
var no = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdNo == item.IdNo).Select(x => x.No).SingleAsync();
|
||||||
|
var isExternal = no.IsEmpty();
|
||||||
if (isExternal)
|
if (isExternal)
|
||||||
{
|
{
|
||||||
var gainfoExternal = await _dbContext.Queryable<GainfoExternalEntity>().Where(x => x.IdNo == item.IdNo).FirstAsync();
|
var gainfoExternal = await _dbContext.Queryable<GainfoExternalEntity>().Where(x => x.IdNo == item.IdNo).FirstAsync();
|
||||||
@@ -89,10 +87,13 @@ public class AppointmentService : IAppointmentService
|
|||||||
|
|
||||||
await _dbContext.UpdateAsync(gainfoExternal);
|
await _dbContext.UpdateAsync(gainfoExternal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
no = gainfoExternal.No;
|
||||||
}
|
}
|
||||||
|
|
||||||
var detail = new VisitorAppointmentDetailEntity
|
var detail = new VisitorAppointmentDetailEntity
|
||||||
{
|
{
|
||||||
|
UserNo = no,
|
||||||
AppointmentId = id,
|
AppointmentId = id,
|
||||||
FlowId = request.FlowId,
|
FlowId = request.FlowId,
|
||||||
Start = request.Start,
|
Start = request.Start,
|
||||||
@@ -113,7 +114,7 @@ public class AppointmentService : IAppointmentService
|
|||||||
{
|
{
|
||||||
return await _dbContext.Queryable<VisitorAppointmentEntity>()
|
return await _dbContext.Queryable<VisitorAppointmentEntity>()
|
||||||
.WhereIF(request.SearchDateTimePeriod?.Start.HasValue == true && request.SearchDateTimePeriod?.End.HasValue == true,
|
.WhereIF(request.SearchDateTimePeriod?.Start.HasValue == true && request.SearchDateTimePeriod?.End.HasValue == true,
|
||||||
x => x.ApplyTime >= request.SearchDateTimePeriod.Start && x.ApplyTime <= request.SearchDateTimePeriod.End)
|
x => x.ApplyTime >= request.SearchDateTimePeriod.Start && x.ApplyTime <= request.SearchDateTimePeriod.End)
|
||||||
.WhereIF(request.Search.IsPresent(), x => x.Code == request.Search || x.Name == request.Search)
|
.WhereIF(request.Search.IsPresent(), x => x.Code == request.Search || x.Name == request.Search)
|
||||||
.Select<AppointmentPageResponse>()
|
.Select<AppointmentPageResponse>()
|
||||||
.ToPageListAsync(request);
|
.ToPageListAsync(request);
|
||||||
@@ -132,7 +133,9 @@ public class AppointmentService : IAppointmentService
|
|||||||
var detail = await _dbContext.Queryable<VisitorAppointmentDetailEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
var detail = await _dbContext.Queryable<VisitorAppointmentDetailEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
||||||
detail.ThrowIfNull("预约信息不存在");
|
detail.ThrowIfNull("预约信息不存在");
|
||||||
|
|
||||||
var mst = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.Id == detail.AppointmentId).FirstAsync();
|
var mst = await _dbContext.Queryable<VisitorAppointmentEntity>().Where(x => x.Id == detail.AppointmentId).SingleAsync();
|
||||||
|
|
||||||
|
//当前分配的设备codes
|
||||||
var deviceCodes = await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
|
var deviceCodes = await _dbContext.Queryable<AppointmentAreaAssignmentEntity>()
|
||||||
.Where(x => x.CustomCode == mst.AreaCustomCode)
|
.Where(x => x.CustomCode == mst.AreaCustomCode)
|
||||||
.Select(x => x.DeviceCode)
|
.Select(x => x.DeviceCode)
|
||||||
@@ -153,7 +156,8 @@ public class AppointmentService : IAppointmentService
|
|||||||
UserNo = userNo,
|
UserNo = userNo,
|
||||||
Type = DeviceTaskEnumType.Add,
|
Type = DeviceTaskEnumType.Add,
|
||||||
Priority = 100,
|
Priority = 100,
|
||||||
Version = 0,
|
Source = DeviceTaskSourceEnumType.Appointment,
|
||||||
|
Version = 0
|
||||||
}).ToList());
|
}).ToList());
|
||||||
|
|
||||||
detail.Status = AppointmentDetailEnumType.Arrived;
|
detail.Status = AppointmentDetailEnumType.Arrived;
|
||||||
@@ -176,11 +180,11 @@ public class AppointmentService : IAppointmentService
|
|||||||
}
|
}
|
||||||
|
|
||||||
var detail = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
var detail = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||||
.Where(x => x.IdNo == idNo)
|
.Where(x => x.IdNo == idNo)
|
||||||
.Where(x => SqlFunc.DateIsSame(x.Start, DateTime.Today, DateType.Day))
|
.Where(x => SqlFunc.DateIsSame(x.Start, DateTime.Today, DateType.Day))
|
||||||
.OrderBy(x => x.Start)
|
.OrderBy(x => x.Start)
|
||||||
.Select<AppointmentDetailResponse>()
|
.Select<AppointmentDetailResponse>()
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
|
|
||||||
return detail;
|
return detail;
|
||||||
}
|
}
|
||||||
@@ -198,11 +202,11 @@ public class AppointmentService : IAppointmentService
|
|||||||
}
|
}
|
||||||
|
|
||||||
var page = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
var page = await _dbContext.Queryable<VisitorAppointmentDetailEntity>()
|
||||||
.Where(x => x.IdNo == request.IdNo)
|
.Where(x => x.IdNo == request.IdNo)
|
||||||
.OrderBy(x => x.Start)
|
.OrderBy(x => x.Start)
|
||||||
.Select<AppointmentDetailResponse>()
|
.Select<AppointmentDetailResponse>()
|
||||||
.ToPageListAsync(request);
|
.ToPageListAsync(request);
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
using Dlhis.Entity.Visitor.Entity;
|
|
||||||
using Dlhis.Visitor.Appointment.Request;
|
|
||||||
using Dlhis.Visitor.Appointment.Response;
|
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
|
||||||
using Kurisu.Core.DataAccess.Dto;
|
|
||||||
using Kurisu.SqlSugar.Extensions;
|
|
||||||
using Kurisu.SqlSugar.Services;
|
|
||||||
using Mapster;
|
|
||||||
|
|
||||||
namespace Dlhis.Visitor.Appointment.Services.Implements;
|
|
||||||
|
|
||||||
public class ApponintmentAreaService : IApponintmentAreaService
|
|
||||||
{
|
|
||||||
private readonly IDbContext _dbContext;
|
|
||||||
|
|
||||||
public ApponintmentAreaService(IDbContext dbContext)
|
|
||||||
{
|
|
||||||
_dbContext = dbContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Pagination<ApponintmentAreaPageResponse>> GetPageAsync(PageDto request)
|
|
||||||
{
|
|
||||||
return await _dbContext.Queryable<AppointmentAreaEntity>()
|
|
||||||
.Select<ApponintmentAreaPageResponse>()
|
|
||||||
.ToPageListAsync(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async Task SaveAsync(AppointmentAreaSaveRequest request)
|
|
||||||
{
|
|
||||||
await CheckCustomCodeDuplicateAsync(request);
|
|
||||||
|
|
||||||
if (!request.Id.HasValue)
|
|
||||||
{
|
|
||||||
var entity = request.Adapt<AppointmentAreaEntity>();
|
|
||||||
entity.Type = request.Type;
|
|
||||||
entity.CustomCode = request.CustomCode;
|
|
||||||
|
|
||||||
await _dbContext.InsertAsync(entity);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var entity = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.Id == request.Id).SingleAsync();
|
|
||||||
entity.ThrowIfNull("预约区域不存在");
|
|
||||||
|
|
||||||
request.Adapt(entity);
|
|
||||||
|
|
||||||
await _dbContext.UpdateAsync(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async Task DeleteAsync(long id)
|
|
||||||
{
|
|
||||||
var entity = await _dbContext.Queryable<AppointmentAreaEntity>().Where(x => x.Id == id).SingleAsync();
|
|
||||||
await _dbContext.DeleteAsync(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public async Task AssignAsync(AppointmentAreaAssignRequest request)
|
|
||||||
{
|
|
||||||
await _dbContext.Client.Deleteable<AppointmentAreaAssignmentEntity>()
|
|
||||||
.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//********************************************************* help methods ***************************************************************
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检查编码重复
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private async Task CheckCustomCodeDuplicateAsync(AppointmentAreaSaveRequest request)
|
|
||||||
{
|
|
||||||
var exists = await _dbContext.Queryable<AppointmentAreaEntity>()
|
|
||||||
.Where(x => x.CustomCode == request.CustomCode)
|
|
||||||
.WhereIF(request.Id.HasValue, x => x.Id == request.Id)
|
|
||||||
.AnyAsync();
|
|
||||||
|
|
||||||
exists.ThrowIfTrue("重复区域编码,请检查");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user