diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs index e1438ab7..51b5bfaa 100644 --- a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs +++ b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs @@ -148,17 +148,6 @@ public class DevicesController : ControllerBase return await _deviceService.CheckExistsAsync(deviceUniqueNo); } - /// - /// 获取设备 - /// - /// - /// - [HttpGet] - public async Task GetDeviceByNoAsync([FromQuery] DeviceByNoRequest request) - { - return await _deviceService.GetDeviceByNoAsync(request); - } - /// /// 获取考勤设备 /// diff --git a/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs b/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs index cf79395e..4d83264a 100644 --- a/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs +++ b/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs @@ -1,5 +1,4 @@ -using Dlhis.Basic.Device.Response; -using Dlhis.Basic.Summary.Response; +using Dlhis.Basic.Summary.Response; using Dlhis.Basic.Summary.Services; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; diff --git a/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs index cdd29667..d35cc869 100644 --- a/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs +++ b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs @@ -1,11 +1,11 @@ -using Dlhis.Basic.Device.Response; -using Dlhis.Basic.Organization.Services; +using Dlhis.Basic.Organization.Services; using Dlhis.Basic.Summary.Dto; using Dlhis.Basic.Summary.Response; using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Basic.Enums; using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; +using Kurisu.Core.User.Abstractions; using Kurisu.SqlSugar.Services; namespace Dlhis.Basic.Summary.Services.Implements; @@ -14,22 +14,26 @@ public class SummaryService : ISummaryService { private readonly IDbContext _dbContext; private readonly IGainfoStore _gainfoStore; + private readonly ICurrentUser _currentUser; - public SummaryService(IDbContext dbContext, IGainfoStore gainfoStore) + public SummaryService(IDbContext dbContext, IGainfoStore gainfoStore, ICurrentUser currentUser) { _dbContext = dbContext; _gainfoStore = gainfoStore; + _currentUser = currentUser; } public async Task GetAttendanceSummaryAsync() { var now = DateTime.Now; + var tenantId = _currentUser.GetStringTenantId(); var currentDay = DateTime.Today.AddDays(1).AddSeconds(-1); var before30Day = DateTime.Today.AddDays(-29); var before7Day = DateTime.Today.AddDays(-6); - var devices = await _dbContext.Queryable().Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance)).ToListAsync(); + var devices = await _dbContext.Queryable().Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance)) + .ToListAsync(); var deviceUniqueNos = devices.Select(x => x.UniqueNo).ToList(); var deviceRegistries = await _dbContext.Queryable() @@ -42,8 +46,8 @@ public class SummaryService : ISummaryService }) .ToListAsync(); - var workingGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).ToListAsync(); - var leaveGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave).ToListAsync(); + var workingGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).Where(x => x.Factory == tenantId).ToListAsync(); + var leaveGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave).Where(x => x.Factory == tenantId).ToListAsync(); return new AttendanceSummaryResponse { @@ -160,7 +164,7 @@ public class SummaryService : ISummaryService ginfoTrendResponse.UnemployedTrend = unemployedTrend; res.GainfoTrend = ginfoTrendResponse; employedTrend.ForEach(x => res.WeekEmployed += x.Count); - unemployedTrend.ForEach(x => res.WeekUnemployed+=x.Count); + unemployedTrend.ForEach(x => res.WeekUnemployed += x.Count); return res; }