feat 门禁首页数据
This commit is contained in:
@@ -29,7 +29,7 @@ public class SummariesController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 门禁首页数据
|
/// 门禁首页设备数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("door-summary")]
|
[HttpGet("door-summary")]
|
||||||
@@ -37,4 +37,14 @@ public class SummariesController : ControllerBase
|
|||||||
{
|
{
|
||||||
return await _summaryService.GetDoorHomeDataAsync();
|
return await _summaryService.GetDoorHomeDataAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 门禁首页数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("door-data")]
|
||||||
|
public async Task<DoorDataResponse> GetDoorDataAsync()
|
||||||
|
{
|
||||||
|
return await _summaryService.GetDoorDataAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
Src/Dlhis.Basic/Summary/Response/DoorDataResponse.cs
Normal file
35
Src/Dlhis.Basic/Summary/Response/DoorDataResponse.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
namespace Dlhis.Basic.Summary.Response
|
||||||
|
{
|
||||||
|
public class DoorDataResponse
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 门禁总人数
|
||||||
|
/// </summary>
|
||||||
|
public int Total => Employed + Unemployed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 在职人数
|
||||||
|
/// </summary>
|
||||||
|
public int Employed { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 周在职人数
|
||||||
|
/// </summary>
|
||||||
|
public int WeekEmployed { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 非在职人数
|
||||||
|
/// </summary>
|
||||||
|
public int Unemployed { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 周非在职人数
|
||||||
|
/// </summary>
|
||||||
|
public int WeekUnemployed { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 人员趋势 7天
|
||||||
|
/// </summary>
|
||||||
|
public GainfoTrendResponse GainfoTrend { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,4 +8,6 @@ public interface ISummaryService : IScopeDependency
|
|||||||
Task<AttendanceSummaryResponse> GetAttendanceSummaryAsync();
|
Task<AttendanceSummaryResponse> GetAttendanceSummaryAsync();
|
||||||
|
|
||||||
Task<DoorHomeDataResponse> GetDoorHomeDataAsync();
|
Task<DoorHomeDataResponse> GetDoorHomeDataAsync();
|
||||||
|
|
||||||
|
Task<DoorDataResponse> GetDoorDataAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,52 @@ public class SummaryService : ISummaryService
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<DoorDataResponse> GetDoorDataAsync()
|
||||||
|
{
|
||||||
|
var res = new DoorDataResponse();
|
||||||
|
List<GainfoEntity> workingGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).ToListAsync();
|
||||||
|
var leaveGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave).ToListAsync();
|
||||||
|
res.Employed = workingGainfos.Count;
|
||||||
|
res.Unemployed = leaveGainfos.Count;
|
||||||
|
|
||||||
|
var employedTrend = new List<TrendDto>();
|
||||||
|
var unemployedTrend = new List<TrendDto>();
|
||||||
|
|
||||||
|
//获取近7天并转化为"yyyy-MM-dd"集合
|
||||||
|
DateTime currentDate = DateTime.Now;
|
||||||
|
List<string> times = new List<string>();
|
||||||
|
for (int i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
DateTime date = currentDate.AddDays(-i);
|
||||||
|
string dateString = date.ToString("yyyy-MM-dd");
|
||||||
|
times.Add(dateString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var time in times)
|
||||||
|
{
|
||||||
|
var emDto = new TrendDto
|
||||||
|
{
|
||||||
|
Date = DateTime.ParseExact(time, "yyyy-MM-dd", null),
|
||||||
|
Count = workingGainfos.Where(x => x.CreateTime.ToString("yyy-MM-dd") == time).ToList().Count,
|
||||||
|
};
|
||||||
|
employedTrend.Add(emDto);
|
||||||
|
var unDto = new TrendDto
|
||||||
|
{
|
||||||
|
Date = DateTime.ParseExact(time, "yyyy-MM-dd", null),
|
||||||
|
Count = leaveGainfos.Where(x => x.CreateTime.ToString("yyy-MM-dd") == time).ToList().Count,
|
||||||
|
};
|
||||||
|
unemployedTrend.Add(unDto);
|
||||||
|
}
|
||||||
|
var ginfoTrendResponse = new GainfoTrendResponse();
|
||||||
|
ginfoTrendResponse.EmployedTrend = employedTrend;
|
||||||
|
ginfoTrendResponse.UnemployedTrend = unemployedTrend;
|
||||||
|
res.GainfoTrend = ginfoTrendResponse;
|
||||||
|
employedTrend.ForEach(x => res.WeekEmployed += x.Count);
|
||||||
|
unemployedTrend.ForEach(x => res.WeekUnemployed+=x.Count);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
private static List<TrendDto> FixTrend(IEnumerable<TrendDto> dtos, DateTime start, DateTime end)
|
private static List<TrendDto> FixTrend(IEnumerable<TrendDto> dtos, DateTime start, DateTime end)
|
||||||
{
|
{
|
||||||
var result = dtos.ToList();
|
var result = dtos.ToList();
|
||||||
|
|||||||
Reference in New Issue
Block a user