feat 获取考勤数据接口
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
<ItemGroup>
|
||||
<Folder Include="EMealVoucher\Response\" />
|
||||
<Folder Include="MealSupplement\Response\" />
|
||||
<Folder Include="OpenApi\Request\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user