From c135bf294ad305767f56159b7d327bb2b6624354 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 25 Apr 2025 11:59:21 +0800 Subject: [PATCH] test . --- .../Controllers/WorkGridsController.cs | 7 +++++ .../Services/IWorkGridScheduleService.cs | 2 ++ .../Implements/WorkGridScheduleService.cs | 28 +++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/Src/Dlhis.Basic/WorkGrids/Controllers/WorkGridsController.cs b/Src/Dlhis.Basic/WorkGrids/Controllers/WorkGridsController.cs index 20bb2cc0..82d207f6 100644 --- a/Src/Dlhis.Basic/WorkGrids/Controllers/WorkGridsController.cs +++ b/Src/Dlhis.Basic/WorkGrids/Controllers/WorkGridsController.cs @@ -215,4 +215,11 @@ public class WorkGridsController : ControllerBase { await _workGridScheduleService.ManuallyUploadAsync(logIds); } + + + [HttpPost("test")] + public async Task Test(WorkGridScheduleSaveRequest request) + { + return await _workGridScheduleService.TestAsync(request); + } } \ 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 12a740bd..d32bd128 100644 --- a/Src/Dlhis.Basic/WorkGrids/Services/IWorkGridScheduleService.cs +++ b/Src/Dlhis.Basic/WorkGrids/Services/IWorkGridScheduleService.cs @@ -25,4 +25,6 @@ public interface IWorkGridScheduleService : IScopeDependency Task ManuallyUploadAsync(List logIds); Task> MaximumConsecutiveUserCodesAsync(List userCodes, int days, DateOnly date); + + Task TestAsync(WorkGridScheduleSaveRequest request); } \ 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 570edb3c..5f585e1d 100644 --- a/Src/Dlhis.Basic/WorkGrids/Services/Implements/WorkGridScheduleService.cs +++ b/Src/Dlhis.Basic/WorkGrids/Services/Implements/WorkGridScheduleService.cs @@ -142,6 +142,34 @@ public class WorkGridScheduleService : IWorkGridScheduleService _logger.LogError("推送信息错误save,{error}", e.Message); } } + + + public async Task TestAsync(WorkGridScheduleSaveRequest request) + { + request.UserCodes = request.UserCodes.Distinct().ToList(); + + var workGrid = await _dbContext.Queryable() + .LeftJoin((x, ga) => x.LeaderUserCode == ga.Code) + .Where(x => x.Code == request.WorkGridCode) + .Select((x, ga) => new + { + x.Code, x.Name, + x.LeaderUserCode, + LeaderUserName = ga.Name, + x.MaxConsecutiveLimitCount + }) + .SingleAsync(); + workGrid.ThrowIfNull("工作网格不存在"); + + var timeSetting = await _dbContext.Queryable().Where(x => x.Type == request.PeriodType).Select(x => new { x.Start, x.Before }).SingleAsync(); + timeSetting.ThrowIfNull("工作网格时间尚未配置,无法操作"); + + var currentLimit = request.Date.ToDateTime(timeSetting.Start.Add(-TimeSpan.FromSeconds(timeSetting.Before))); + (DateTime.Now >= currentLimit).ThrowIfTrue("当前时间不可修改排班信息"); + + return currentLimit; + } + /// public async Task RemoveAsync(WorkGridScheduleSaveRequest request)