Merge branch 'development'

This commit is contained in:
2024-09-18 16:09:05 +08:00
9 changed files with 158 additions and 18 deletions

View File

@@ -51,6 +51,11 @@ public class VisitorAppointmentDetailEntity : SugarBaseEntity
[SugarColumn(ColumnDescription = "车牌")]
public string LicensePlate { get; set; }
/// <summary>
/// 进入门岗
/// </summary>
public bool IsEnterDoorArea { get; set; }
/// <summary>
/// 预约门禁区域
/// </summary>

View File

@@ -45,11 +45,14 @@ public class AppointmentReceiveItemDto : IValidatableObject
/// </summary>
public string ImageUrl { get; set; }
/// <summary>
/// 进入门岗
/// </summary>
public bool IsEnterDoorArea { get; set; }
/// <summary>
/// 预约门岗区域
/// </summary>
[Required(ErrorMessage = "预约门岗区域不可为空")]
public string ApplyDoorArea { get; set; }
/// <summary>
@@ -63,7 +66,7 @@ public class AppointmentReceiveItemDto : IValidatableObject
public DateTime DoorEnd { get; set; }
/// <summary>
/// 是否进入车间
/// 进入车间
/// </summary>
public bool IsEnterWorkplace { get; set; }
@@ -85,9 +88,17 @@ public class AppointmentReceiveItemDto : IValidatableObject
/// <inheritdoc />
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (DoorStart >= DoorEnd)
if (IsEnterDoorArea)
{
yield return new ValidationResult($"{Name}门禁来访时间有误", new[] { nameof(DoorStart) });
if (ApplyDoorArea.IsEmpty())
{
yield return new ValidationResult($"{Name}门岗区域不可为空", new[] { nameof(ApplyWorkplaceAreas) });
}
if (DoorStart >= DoorEnd)
{
yield return new ValidationResult($"{Name}门禁来访时间有误", new[] { nameof(DoorStart) });
}
}
if (IsEnterWorkplace)
@@ -102,14 +113,17 @@ public class AppointmentReceiveItemDto : IValidatableObject
yield return new ValidationResult($"{Name}车间来访时间有误", new[] { nameof(WorkplaceStart) });
}
if (WorkplaceStart < DoorStart || WorkplaceStart > DoorEnd)
if (IsEnterDoorArea)
{
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) });
if (WorkplaceEnd < DoorStart || WorkplaceEnd > DoorEnd)
{
yield return new ValidationResult($"{Name}车间来访时间需在门禁时间范围内", new[] { nameof(WorkplaceStart) });
}
}
}
}

View File

@@ -76,7 +76,8 @@ public class AppointmentService : IAppointmentService
}
}
(gainfo.Type == GainfoUserTypeEnumType.External && item.IsEnterWorkplace && item.ImageUrl.IsEmpty()).ThrowIfTrue($"{item.Name}的社保照片不可为空");
//todo
//(gainfo.Type == GainfoUserTypeEnumType.External && item.IsEnterWorkplace && item.ImageUrl.IsEmpty()).ThrowIfTrue($"{item.Name}的社保照片不可为空");
var detail = new VisitorAppointmentDetailEntity
{
@@ -87,19 +88,20 @@ public class AppointmentService : IAppointmentService
Name = item.Name,
Phone = item.Phone,
Remark = item.Remark,
DoorStatus = areas.Where(x => x.Type == AppointmentAreaEnumType.Door)
.Select(x => x.Name)
DoorStatus = item.IsEnterDoorArea && areas.Where(x => x.Type == AppointmentAreaEnumType.Door)
.Select(x => x.CustomCode)
.Contains(item.ApplyDoorArea)
? VisitorAppointmentDetailStatusEnumType.Wait
: VisitorAppointmentDetailStatusEnumType.Obsolete,
LicensePlate = item.LicensePlate,
IsEnterDoorArea = item.IsEnterDoorArea,
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)
.Select(x => x.CustomCode)
.Contains(p))
? VisitorAppointmentDetailStatusEnumType.Wait
: VisitorAppointmentDetailStatusEnumType.Obsolete,

View File

@@ -23,7 +23,6 @@
<ItemGroup>
<Folder Include="EMealVoucher\Response\" />
<Folder Include="MealSupplement\Response\" />
<Folder Include="OpenApi\Request\" />
</ItemGroup>
<ItemGroup>

View File

@@ -1,5 +1,7 @@
using Dlhis.External.OpenApi.Response;
using Dlhis.External.OpenApi.Request;
using Dlhis.External.OpenApi.Response;
using Dlhis.External.OpenApi.Services;
using Kurisu.AspNetCore.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -26,4 +28,15 @@ public class GainfosController : ControllerBase
{
return await _gainfoService.GetAllGainfosAsync();
}
}
/// <summary>
/// 获取考勤数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpGet("attendance/pagination")]
public async Task<Pagination<DeviceUploadLogResponse>> GetAttendanceRecordPageAsync([FromQuery] DeviceUploadLogMyRecordRequest request)
{
return await _gainfoService.GetAttendanceRecordPageAsync(request);
}
}

View File

@@ -0,0 +1,27 @@
using System.ComponentModel.DataAnnotations;
using Kurisu.AspNetCore.CustomClass;
using Kurisu.AspNetCore.DataAccess.Dto;
namespace Dlhis.External.OpenApi.Request;
public class DeviceUploadLogMyRecordRequest : PageDto, IValidatableObject
{
public DateTimePeriod DateTimePeriod { get; set; }
[Required(ErrorMessage = "工号不能为空")]
public string UserCode { get; set; }
/// <inheritdoc />
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
DateTimePeriod ??= new DateTimePeriod();
if (DateTimePeriod.Start != null)
{
DateTimePeriod.End = DateTimePeriod.Start.Value.AddDays(1);
}
yield break;
}
}

View File

@@ -0,0 +1,48 @@
namespace Dlhis.External.OpenApi.Response;
public class DeviceUploadLogResponse
{
public long Id { get; set; }
/// <summary>
/// 设备号
/// </summary>
public string DeviceUniqueNo { get; set; }
/// <summary>
/// 设备部署点
/// </summary>
public string DeployPlace { get; set; }
/// <summary>
/// 用户学工号
/// </summary>
public string UserCode { get; set; }
/// <summary>
/// 用户名称
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 上传时间
/// </summary>
public DateTime RaiseDateTime { get; set; }
/// <summary>
/// 序列号
/// </summary>
public string SerialNo { get; set; }
/// <summary>
/// 是否同步sap
/// </summary>
public bool Sync { get; set; }
/// <summary>
/// 是否有效
/// </summary>
public bool Status { get; set; }
}

View File

@@ -1,4 +1,6 @@
using Dlhis.External.OpenApi.Response;
using Dlhis.External.OpenApi.Request;
using Dlhis.External.OpenApi.Response;
using Kurisu.AspNetCore.DataAccess.Dto;
namespace Dlhis.External.OpenApi.Services;
@@ -7,4 +9,7 @@ public interface IGainfoService : IScopeDependency
Task<List<GainfoOpenResponse>> GetAllGainfosAsync();
Task<List<DepartmentOpenResponse>> GetDepartmentsAsync();
Task<Pagination<DeviceUploadLogResponse>> GetAttendanceRecordPageAsync(DeviceUploadLogMyRecordRequest request);
}

View File

@@ -1,6 +1,12 @@
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Basic.Enums;
using Dlhis.Entity.Device.Entities;
using Dlhis.Entity.Device.Enums;
using Dlhis.External.OpenApi.Request;
using Dlhis.External.OpenApi.Response;
using Kurisu.AspNetCore.CustomClass;
using Kurisu.AspNetCore.DataAccess.Dto;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
namespace Dlhis.External.OpenApi.Services.Implements;
@@ -57,4 +63,25 @@ public class GainfoService : IGainfoService
PNo = x.PNo
}).ToListAsync();
}
public async Task<Pagination<DeviceUploadLogResponse>> GetAttendanceRecordPageAsync(DeviceUploadLogMyRecordRequest request)
{
return await _dbContext.Queryable<DeviceUploadLogEntity>()
.LeftJoin<DeviceEntity>((log, d) => log.DeviceUniqueNo == d.UniqueNo)
.Where(log => log.UserUniqueNo == request.UserCode)
.WhereIF(request.DateTimePeriod.HasValue(), log => log.RaiseDateTime >= request.DateTimePeriod.Start && log.RaiseDateTime <= request.DateTimePeriod.End)
.Where((log, d) => d.Type == DeviceTypeEnumType.Attendance || (d.Type == DeviceTypeEnumType.Door && d.AsAttendance))
.OrderBy(log => log.RaiseDateTime)
.Select((log, d) => new DeviceUploadLogResponse
{
DeviceUniqueNo = log.DeviceUniqueNo,
Id = log.Id,
RaiseDateTime = log.RaiseDateTime,
SerialNo = log.SerialNo,
DeployPlace = d.DeployPlace,
Sync = log.Sync,
Status = log.Status
})
.ToPageListAsync(request);
}
}