diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs index 7460cf1a..a89f549d 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/SapBusinessTripService.cs @@ -1,4 +1,3 @@ -using Dlhis.Basic.Device.Services; using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; diff --git a/Src/Dlhis.Basic/WorkGrids/Controllers/WorkGridsController.cs b/Src/Dlhis.Basic/WorkGrids/Controllers/WorkGridsController.cs index 4549aca8..c8a31385 100644 --- a/Src/Dlhis.Basic/WorkGrids/Controllers/WorkGridsController.cs +++ b/Src/Dlhis.Basic/WorkGrids/Controllers/WorkGridsController.cs @@ -51,7 +51,7 @@ public class WorkGridsController : ControllerBase { return await _workGridService.GetPageAsync(request); } - + /// /// 修改网格管理者 /// @@ -61,7 +61,7 @@ public class WorkGridsController : ControllerBase { await _workGridService.ChangeAsync(request.From, request.To); } - + /// /// 获取我的网格信息 /// @@ -151,4 +151,25 @@ public class WorkGridsController : ControllerBase { return await _workGridScheduleService.GetListSummaryAsync(workGridCode, start, end); } + + /// + /// 获取网格人员考勤记录分页 + /// + /// + /// + [HttpGet("user/attendance/page")] + public async Task> GetAttendancePageAsync(WorkGridScheduleAttendancePageRequest request) + { + return await _workGridScheduleService.GetAttendancePageAsync(request); + } + + /// + /// 网格人员考勤记录补传 + /// + /// + [HttpPost("user/attendance/upload")] + public async Task ManuallyUploadAsync(List logIds) + { + await _workGridScheduleService.ManuallyUploadAsync(logIds); + } } \ No newline at end of file diff --git a/Src/Dlhis.Basic/WorkGrids/Request/WorkGridScheduleAttendancePageRequest.cs b/Src/Dlhis.Basic/WorkGrids/Request/WorkGridScheduleAttendancePageRequest.cs new file mode 100644 index 00000000..bc783d40 --- /dev/null +++ b/Src/Dlhis.Basic/WorkGrids/Request/WorkGridScheduleAttendancePageRequest.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; +using Kurisu.AspNetCore.CustomClass; +using Kurisu.AspNetCore.DataAccess.Dto; + +namespace Dlhis.Basic.WorkGrids.Request; + +public class WorkGridScheduleAttendancePageRequest : PageDto +{ + [Required(ErrorMessage = "工号不能为空")] + public string UserCode { get; set; } + + public DateTimePeriod DateTimePeriod { get; set; } +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/WorkGrids/Response/WorkGridScheduleAttendancePageResponse.cs b/Src/Dlhis.Basic/WorkGrids/Response/WorkGridScheduleAttendancePageResponse.cs new file mode 100644 index 00000000..e4e3ff16 --- /dev/null +++ b/Src/Dlhis.Basic/WorkGrids/Response/WorkGridScheduleAttendancePageResponse.cs @@ -0,0 +1,63 @@ +using Newtonsoft.Json; + +namespace Dlhis.Basic.WorkGrids.Response; + +public class WorkGridScheduleAttendancePageResponse +{ + public long Id { get; set; } + + /// + /// 设备号 + /// + public string DeviceUniqueNo { get; set; } + + /// + /// 设备部署点 + /// + public string DeployPlace { get; set; } + + /// + /// 用户学工号 + /// + public string UserCode { get; set; } + + + /// + /// 用户名称 + /// + public string UserName { get; set; } + + /// + /// 上传时间 + /// + public DateTime RaiseDateTime { get; set; } + + /// + /// 记录创建时间 + /// + public DateTime CreateTime { get; set; } + + /// + /// 序列号 + /// + public string SerialNo { get; set; } + + + [JsonIgnore] + public string OriginUserUniqueNo { get; set; } + + /// + /// 是否同步sap + /// + public bool Sync { get; set; } + + /// + /// 是否需要上传 + /// + public bool NeedUpload { get; set; } + + /// + /// 是否有效 + /// + public bool Status { get; set; } +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/WorkGrids/Services/IWorkGridScheduleService.cs b/Src/Dlhis.Basic/WorkGrids/Services/IWorkGridScheduleService.cs index 2b6783d9..df2d46fc 100644 --- a/Src/Dlhis.Basic/WorkGrids/Services/IWorkGridScheduleService.cs +++ b/Src/Dlhis.Basic/WorkGrids/Services/IWorkGridScheduleService.cs @@ -1,5 +1,6 @@ using Dlhis.Basic.WorkGrids.Request; using Dlhis.Basic.WorkGrids.Response; +using Kurisu.AspNetCore.DataAccess.Dto; namespace Dlhis.Basic.WorkGrids.Services; @@ -13,4 +14,8 @@ public interface IWorkGridScheduleService : IScopeDependency Task> GetListAsync(Guid workGridCode, DateOnly date); Task> GetListSummaryAsync(Guid workGridCode, DateOnly start, DateOnly end); + + Task> GetAttendancePageAsync(WorkGridScheduleAttendancePageRequest request); + + Task ManuallyUploadAsync(List logIds); } \ No newline at end of file diff --git a/Src/Dlhis.Basic/WorkGrids/Services/Implements/WorkGridScheduleService.cs b/Src/Dlhis.Basic/WorkGrids/Services/Implements/WorkGridScheduleService.cs index 1e2f25c7..40c2d706 100644 --- a/Src/Dlhis.Basic/WorkGrids/Services/Implements/WorkGridScheduleService.cs +++ b/Src/Dlhis.Basic/WorkGrids/Services/Implements/WorkGridScheduleService.cs @@ -1,6 +1,12 @@ using Dlhis.Basic.WorkGrids.Request; using Dlhis.Basic.WorkGrids.Response; using Dlhis.Entity.Basic.Entity; +using Dlhis.Entity.Device.Entities; +using Dlhis.Jip.Api; +using Dlhis.Jip.Api.Requests; +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; @@ -9,10 +15,12 @@ namespace Dlhis.Basic.WorkGrids.Services.Implements; public class WorkGridScheduleService : IWorkGridScheduleService { private readonly IDbContext _dbContext; + private readonly IJinkoJipApi _jinkoJipApi; - public WorkGridScheduleService(IDbContext dbContext) + public WorkGridScheduleService(IDbContext dbContext ,IJinkoJipApi jinkoJipApi) { _dbContext = dbContext; + _jinkoJipApi = jinkoJipApi; } public async Task SaveAsync(WorkGridScheduleSaveRequest request) @@ -78,4 +86,62 @@ public class WorkGridScheduleService : IWorkGridScheduleService }; }); } + + /// + public async Task> GetAttendancePageAsync(WorkGridScheduleAttendancePageRequest request) + { + return await _dbContext.Queryable() + .LeftJoin((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) + .OrderBy(log => log.RaiseDateTime) + .Select((log, d) => new WorkGridScheduleAttendancePageResponse + { + Id = log.Id, + OriginUserUniqueNo = log.UserUniqueNo, + DeviceUniqueNo = log.DeviceUniqueNo, + RaiseDateTime = log.RaiseDateTime, + CreateTime = log.CreateTime, + SerialNo = log.SerialNo, + DeployPlace = d.DeployPlace, + Sync = log.Sync, + Status = log.Status + }) + .ToPageListAsync(request); + } + + /// + public async Task ManuallyUploadAsync(List logIds) + { + var requests = await _dbContext.Queryable() + .LeftJoin((x, device) => x.DeviceUniqueNo == device.UniqueNo) + .Where(x => logIds.Contains(x.Id)) + .Where(x => x.NeedUpload && x.Sync == false) + .Select((x, device) => new UploadAttendanceRequestItem + { + Id = x.Id, + RaiseDateTime = x.RaiseDateTime, + ZNOTE = device.DeployPlace, + ZWORKCODE = x.UserUniqueNo + }) + .ToListAsync(); + + if (requests.Any()) + { + foreach (var items in requests.Chunk(500)) + { + var ids = items.Select(x => x.Id).ToList(); + var r = await _jinkoJipApi.UploadAttendancesAsync(new UploadAttendanceRequest { Data = items.ToList() }); + if (r.OLX == "0") + { + await _dbContext.Updateable() + .SetColumns(x => x.Sync == true) + .SetColumns(x => x.ModifiedTime == DateTime.Now) + .Where(x => ids.Contains(x.Id)) + .ExecuteCommandAsync(); + } + } + } + } } \ No newline at end of file