fix 统计人数调整,移除无用接口

This commit is contained in:
2024-03-12 10:51:19 +08:00
parent 7bf97dbe5e
commit a5f80a0ef4
3 changed files with 12 additions and 20 deletions

View File

@@ -148,17 +148,6 @@ public class DevicesController : ControllerBase
return await _deviceService.CheckExistsAsync(deviceUniqueNo);
}
/// <summary>
/// 获取设备
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpGet]
public async Task<DeviceResponse> GetDeviceByNoAsync([FromQuery] DeviceByNoRequest request)
{
return await _deviceService.GetDeviceByNoAsync(request);
}
/// <summary>
/// 获取考勤设备
/// </summary>

View File

@@ -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;

View File

@@ -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<AttendanceSummaryResponse> 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<DeviceEntity>().Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance)).ToListAsync();
var devices = await _dbContext.Queryable<DeviceEntity>().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<DeviceRegistryEntity>()
@@ -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;
}