From 114cd5d006e6c44f9c003978abb99a2872799bba Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 7 Jun 2024 22:17:26 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E8=8E=B7=E5=8F=96=E4=BA=BA=E8=84=B8?= =?UTF-8?q?=E7=99=BB=E8=AE=B0=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Summary/Controllers/SummariesController.cs | 12 +++++++++++- .../Summary/Services/ISummaryService.cs | 4 +++- .../Services/Implements/SummaryService.cs | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs b/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs index 4d83264a..924f8d19 100644 --- a/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs +++ b/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs @@ -46,4 +46,14 @@ public class SummariesController : ControllerBase { return await _summaryService.GetDoorDataAsync(); } -} + + /// + /// + /// + /// + [HttpGet("faceRecordDetail")] + public async Task GetCurrentFactoryFaceDetailAsync() + { + return await _summaryService.GetCurrentFactoryFaceDetailAsync(); + } +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs b/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs index ea0d21f4..12efd370 100644 --- a/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs +++ b/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs @@ -9,4 +9,6 @@ public interface ISummaryService : IScopeDependency Task GetDoorHomeDataAsync(); Task GetDoorDataAsync(); -} + + Task GetCurrentFactoryFaceDetailAsync(); +} \ No newline at end of file diff --git a/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs index 5ce43d10..37f540c8 100644 --- a/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs +++ b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs @@ -13,6 +13,7 @@ namespace Dlhis.Basic.Summary.Services.Implements; public class SummaryService : ISummaryService { private readonly IDbContext _dbContext; + private readonly IDbContext _faceDbContext; private readonly IGainfoStore _gainfoStore; private readonly ICurrentUser _currentUser; @@ -21,6 +22,8 @@ public class SummaryService : ISummaryService _dbContext = dbContext; _gainfoStore = gainfoStore; _currentUser = currentUser; + + _faceDbContext = dbContext.ChangeDb("face"); } public async Task GetAttendanceSummaryAsync() @@ -168,6 +171,20 @@ public class SummaryService : ISummaryService return res; } + /// + public async Task GetCurrentFactoryFaceDetailAsync() + { + var currentTenantId = _currentUser.GetStringTenantId(); + var userCodes = await _dbContext.Queryable().Where(x => x.Factory == currentTenantId).Select(x => x.Code).ToListAsync(); + var total = userCodes.Count; + var exists = await _faceDbContext.Queryable().Where(x => userCodes.Contains(x.UserCode)).CountAsync(); + + return new + { + total, exists + }; + } + private static List FixTrend(IEnumerable dtos, DateTime start, DateTime end) { var result = dtos.ToList();