From 6e492595f8187fcfb6c0da7beb8aebe4ee4f82eb Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Wed, 21 Feb 2024 11:09:38 +0800
Subject: [PATCH] =?UTF-8?q?feat=20=E4=BA=8C=E7=BA=A7=E8=B7=AF=E7=94=B1?=
=?UTF-8?q?=E6=9B=B4=E6=94=B9=E5=8F=8A=E8=AE=BE=E5=A4=87=E4=BA=BA=E5=91=98?=
=?UTF-8?q?=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Device/Controllers/DevicesController.cs | 30 ++++
.../Device/Request/AttendanceTotalRequest.cs | 8 ++
.../Request/DeviceOnlineAndofflineRequest.cs | 9 ++
.../Device/Services/IDeviceService.cs | 7 +
.../Services/Implements/DeviceService.cs | 58 ++++++++
.../Controllers/GainfosController.cs | 31 +++++
.../Organization/Request/WeekNumberRequest.cs | 8 ++
.../Response/GainfoGainfoNumbersResponse.cs | 9 ++
.../Organization/Services/IGainfoService.cs | 7 +
.../Services/Implements/GainfoService.cs | 130 ++++++++++++++++++
Src/Dlhis.Sys/Menu/Services/IMenuService.cs | 2 +-
.../Menu/Services/Implements/MenuService.cs | 20 ++-
12 files changed, 314 insertions(+), 5 deletions(-)
create mode 100644 Src/Dlhis.Basic/Device/Request/AttendanceTotalRequest.cs
create mode 100644 Src/Dlhis.Basic/Device/Request/DeviceOnlineAndofflineRequest.cs
create mode 100644 Src/Dlhis.Basic/Organization/Request/WeekNumberRequest.cs
create mode 100644 Src/Dlhis.Basic/Organization/Response/GainfoGainfoNumbersResponse.cs
diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
index dc903205..6dfcd3f3 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
@@ -162,4 +162,34 @@ public class DevicesController : ControllerBase
{
return await _deviceService.GetAttendanceDevicesAsync();
}
+
+ ///
+ /// 获取考勤设备总数
+ ///
+ ///
+ [HttpGet("attendancestotal")]
+ public async Task> GetAttendanceTotalAsync([FromQuery]AttendanceTotalRequest request)
+ {
+ return await _deviceService.GetAttendanceTotalAsync(request);
+ }
+
+ ///
+ /// 获取考勤在线/离线设备数
+ ///
+ ///
+ [HttpGet("attendancesoffline")]
+ public async Task> GetAttendanceOfflineAsync([FromQuery] DeviceOnlineAndofflineRequest request)
+ {
+ return await _deviceService.GetAttendanceOfflineAsync(request);
+ }
+
+ ///
+ /// 获取近期30天新增设备数
+ ///
+ ///
+ [HttpGet("recentnumbers")]
+ public async Task> GetRecentNumbersAsync()
+ {
+ return await _deviceService.GetRecentNumbersAsync();
+ }
}
diff --git a/Src/Dlhis.Basic/Device/Request/AttendanceTotalRequest.cs b/Src/Dlhis.Basic/Device/Request/AttendanceTotalRequest.cs
new file mode 100644
index 00000000..df7fa9fa
--- /dev/null
+++ b/Src/Dlhis.Basic/Device/Request/AttendanceTotalRequest.cs
@@ -0,0 +1,8 @@
+using Kurisu.Core.DataAccess.Dto;
+
+namespace Dlhis.Basic.Device.Request
+{
+ public class AttendanceTotalRequest : PageDto
+ {
+ }
+}
diff --git a/Src/Dlhis.Basic/Device/Request/DeviceOnlineAndofflineRequest.cs b/Src/Dlhis.Basic/Device/Request/DeviceOnlineAndofflineRequest.cs
new file mode 100644
index 00000000..14b9b1b5
--- /dev/null
+++ b/Src/Dlhis.Basic/Device/Request/DeviceOnlineAndofflineRequest.cs
@@ -0,0 +1,9 @@
+using Kurisu.Core.DataAccess.Dto;
+
+namespace Dlhis.Basic.Device.Request
+{
+ public class DeviceOnlineAndofflineRequest :PageDto
+ {
+ public bool IsOnAndOff { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
index 095effcb..9d346d3e 100644
--- a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
@@ -1,6 +1,7 @@
using Dlhis.Basic.Device.Request;
using Dlhis.Basic.Device.Response;
using Kurisu.Core.DataAccess.Dto;
+using Microsoft.AspNetCore.Mvc;
namespace Dlhis.Basic.Device.Services;
@@ -15,4 +16,10 @@ public interface IDeviceService : IScopeDependency
Task GetDeviceByNoAsync(DeviceByNoRequest request);
Task> GetAttendanceDevicesAsync();
+
+ Task> GetAttendanceTotalAsync(AttendanceTotalRequest request);
+
+ Task> GetAttendanceOfflineAsync(DeviceOnlineAndofflineRequest request);
+
+ Task> GetRecentNumbersAsync();
}
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
index d398e296..9d61dd71 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
@@ -10,6 +10,7 @@ using Kurisu.SqlSugar.Attributes;
using Kurisu.SqlSugar.Extensions;
using Kurisu.SqlSugar.Services;
using Mapster;
+using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -194,5 +195,62 @@ public class DeviceService : IDeviceService
return devices.Where(x => x.Funcs.Contains(DeviceFuncEnumType.Attendance)).ToList();
}
+
+ public async Task> GetAttendanceTotalAsync(AttendanceTotalRequest request)
+ {
+ var page = await _dbContext.Queryable()
+ .LeftJoin((d, dt) => d.TemplateCode == dt.Code)
+ .Where(d => d.Type == DeviceTypeEnumType.Attendance)
+ .Select((d, dt) => new DevicePageResponse
+ {
+ FuncsStr = d.Funcs.ToString(),
+ Brand = dt.Brand,
+ Type = d.Type,
+
+ }, true)
+ .ToPageListAsync(request);
+
+ return page;
+ }
+
+ public async Task> GetAttendanceOfflineAsync(DeviceOnlineAndofflineRequest request)
+ {
+ var page = await _dbContext.Queryable()
+ .LeftJoin((d, dt) => d.TemplateCode == dt.Code)
+ .Where(d => d.Type == DeviceTypeEnumType.Attendance && d.Enable == request.IsOnAndOff)
+ .Select((d, dt) => new DevicePageResponse
+ {
+ FuncsStr = d.Funcs.ToString(),
+ Brand = dt.Brand,
+ Type = d.Type,
+
+ }, true)
+ .ToPageListAsync(request);
+
+ return page;
+ }
+
+ public async Task> GetRecentNumbersAsync()
+ {
+ //获取近30天并转化为"yyyy-MM-dd"集合
+ DateTime currentDate = DateTime.Now;
+ List times = new List();
+ for (int i = 0; i < 30; i++)
+ {
+ DateTime date = currentDate.AddDays(-i);
+ string dateString = date.ToString("yyyy-MM-dd");
+ times.Add(dateString);
+ }
+
+ var devices = await _dbContext.Queryable().ToListAsync();
+
+ var dic = new Dictionary();
+ times.ForEach(time =>
+ {
+ var count = devices.Where(x => x.CreateTime.ToString("yyyy-MM-dd") == time).Count();
+ dic[time] = count;
+ });
+ return dic;
+ }
}
diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
index 667ab402..fc98f815 100644
--- a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
+++ b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
@@ -2,6 +2,7 @@
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Organization.Response;
using Dlhis.Basic.Organization.Services;
+using Dlhis.Entity.Basic.Entity;
using Kurisu.AspNetCore.MVC;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
@@ -156,5 +157,35 @@ public class GainfosController : ControllerBase
{
return await _gainfoService.GetGainfoDetailTaskAsync(request);
}
+
+ ///
+ /// 获取近七天入职人数及列表
+ ///
+ ///
+ [HttpGet("weeknumber")]
+ public async Task>> GetWeekNumberAsync([FromQuery] WeekNumberRequest request)
+ {
+ return await _gainfoService.GetWeekNumberAsync(request);
+ }
+
+ ///
+ /// 获取近七天离职人数及列表
+ ///
+ ///
+ [HttpGet("weeknumberdimission")]
+ public async Task>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request)
+ {
+ return await _gainfoService.GetDimissionWeekNumberAsync(request);
+ }
+
+ ///
+ /// 获取基地在职、离职、考勤数
+ ///
+ ///
+ [HttpGet("gainfonumbers")]
+ public async Task GetGainfoNumbersAsync(string Werks)
+ {
+ return await _gainfoService.GetGainfoNumbersAsync(Werks);
+ }
}
diff --git a/Src/Dlhis.Basic/Organization/Request/WeekNumberRequest.cs b/Src/Dlhis.Basic/Organization/Request/WeekNumberRequest.cs
new file mode 100644
index 00000000..6bd60bc9
--- /dev/null
+++ b/Src/Dlhis.Basic/Organization/Request/WeekNumberRequest.cs
@@ -0,0 +1,8 @@
+using Kurisu.Core.DataAccess.Dto;
+
+namespace Dlhis.Basic.Organization.Request
+{
+ public class WeekNumberRequest : PageDto
+ {
+ }
+}
diff --git a/Src/Dlhis.Basic/Organization/Response/GainfoGainfoNumbersResponse.cs b/Src/Dlhis.Basic/Organization/Response/GainfoGainfoNumbersResponse.cs
new file mode 100644
index 00000000..182a22cb
--- /dev/null
+++ b/Src/Dlhis.Basic/Organization/Response/GainfoGainfoNumbersResponse.cs
@@ -0,0 +1,9 @@
+namespace Dlhis.Basic.Organization.Response
+{
+ public class GainfoGainfoNumbersResponse
+ {
+ public int OnlineNumber { get; set; }
+ public int OfflineNumber { get; set; }
+ public int AttendanceNumber{ get; set; }
+ }
+}
diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
index 51949307..59e285f9 100644
--- a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
@@ -1,5 +1,6 @@
using Dlhis.Basic.Organization.Request;
using Dlhis.Basic.Organization.Response;
+using Dlhis.Entity.Basic.Entity;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Mvc;
@@ -30,4 +31,10 @@ public interface IGainfoService : IScopeDependency
Task> GetGainfoListTaskAsync(GainfoListRequest request);
Task GetGainfoDetailTaskAsync(GainfoDetailRequest request);
+
+ Task>> GetWeekNumberAsync(WeekNumberRequest request);
+
+ Task>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request);
+
+ Task GetGainfoNumbersAsync(string Werks);
}
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
index 7a5506f2..233bdd70 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
@@ -377,6 +377,136 @@ public class GainfoService : IGainfoService
return info;
}
+ public async Task>> GetWeekNumberAsync(WeekNumberRequest request)
+ {
+ //获取近7天并转化为"yyyy-MM-dd"集合
+ DateTime currentDate = DateTime.Now;
+ List times = new List();
+ for (int i = 0; i < 7; i++)
+ {
+ DateTime date = currentDate.AddDays(-i);
+ string dateString = date.ToString("yyyy-MM-dd");
+ times.Add(dateString);
+ }
+
+ var dic = new Dictionary>();
+
+ foreach (var time in times)
+ {
+ var infos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
+ .LeftJoin((ga, de) => ga.DepartmentNo == de.No)
+ .LeftJoin((ga, de, type) => ga.Native == type.Code && type.Type == "native")
+ .LeftJoin((ga, de, type, posi) => ga.Position == posi.Name)
+ .LeftJoin((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
+ .LeftJoin((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation")
+ .Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time)
+ .Select((ga, de, type, posi, type2, type3) => new GainfoDetailResponse
+ {
+ No = ga.No,
+ SapNo = ga.SapNo,
+ Name = ga.Name,
+ Code = ga.Code,
+ DepartmentName = de.Name,
+ IdClass = ga.IdClass,
+ IdNo = ga.IdNo,
+ Gender = ga.Gender,
+ NativeName = type.Display,
+ Address = ga.Address,
+ Birthday = ga.Birthday,
+ Phone = ga.Phone,
+ Position = ga.Position,
+ Grade = posi.Grade,
+ Degree = ga.Degree,
+ Werks = ga.Werks,
+ CostId = ga.CostId,
+ Marital = ga.Marital,
+ CountryName = type2.Display,
+ NationName = type3.Display,
+ IsActive = ga.Employed == "Active" ? true : false,
+ }).ToPageListAsync(request);
+ //var infos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
+ // .Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time)
+ // .ToPageListAsync(request);
+ dic[time] = infos;
+ }
+ return dic;
+ }
+
+ public async Task>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request)
+ {
+ //获取近7天并转化为"yyyy-MM-dd"集合
+ DateTime currentDate = DateTime.Now;
+ List times = new List();
+ for (int i = 0; i < 7; i++)
+ {
+ DateTime date = currentDate.AddDays(-i);
+ string dateString = date.ToString("yyyy-MM-dd");
+ times.Add(dateString);
+ }
+
+ var dic = new Dictionary>();
+ foreach (var time in times)
+ {
+ var infos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave)
+ .LeftJoin((ga, de) => ga.DepartmentNo == de.No)
+ .LeftJoin((ga, de, type) => ga.Native == type.Code && type.Type == "native")
+ .LeftJoin((ga, de, type, posi) => ga.Position == posi.Name)
+ .LeftJoin((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
+ .LeftJoin((ga, de, type, posi, type2, type3) => ga.Nation == type3.Code && type3.Type == "nation")
+ .Where(ga => ga.CreateTime.ToString("yyyy-MM-dd") == time)
+ .Select((ga, de, type, posi, type2, type3) => new GainfoDetailResponse
+ {
+ No = ga.No,
+ SapNo = ga.SapNo,
+ Name = ga.Name,
+ Code = ga.Code,
+ DepartmentName = de.Name,
+ IdClass = ga.IdClass,
+ IdNo = ga.IdNo,
+ Gender = ga.Gender,
+ NativeName = type.Display,
+ Address = ga.Address,
+ Birthday = ga.Birthday,
+ Phone = ga.Phone,
+ Position = ga.Position,
+ Grade = posi.Grade,
+ Degree = ga.Degree,
+ Werks = ga.Werks,
+ CostId = ga.CostId,
+ Marital = ga.Marital,
+ CountryName = type2.Display,
+ NationName = type3.Display,
+ IsActive = ga.Employed == "Active" ? true : false,
+ }).ToPageListAsync(request);
+ dic[time] = infos;
+ }
+ return dic;
+ }
+
+ public async Task GetGainfoNumbersAsync(string Werks)
+ {
+ //在职人数
+ var onlineNumber = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
+ .Where(ga => ga.Werks == Werks)
+ .CountAsync();
+
+ //离职人数
+ var offlineNumber = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave)
+ .Where(ga => ga.Werks == Werks)
+ .CountAsync();
+
+ //考勤总人数
+ var attendanceNumber = onlineNumber + offlineNumber;
+
+ var res = new GainfoGainfoNumbersResponse
+ {
+ OnlineNumber = onlineNumber,
+ OfflineNumber = offlineNumber,
+ AttendanceNumber = attendanceNumber
+ };
+ return res;
+ }
+
//-------------------------------------------help methods ------------------------------------------------
///
diff --git a/Src/Dlhis.Sys/Menu/Services/IMenuService.cs b/Src/Dlhis.Sys/Menu/Services/IMenuService.cs
index 94a29d5c..79f47c66 100644
--- a/Src/Dlhis.Sys/Menu/Services/IMenuService.cs
+++ b/Src/Dlhis.Sys/Menu/Services/IMenuService.cs
@@ -9,7 +9,7 @@ public interface IMenuService : IScopeDependency
{
Task> GetListAsync(PlatformEnumType platform);
- Task SaveMenuAsync(SaveMenuRequest request);
+ Task SaveMenuAsync(SaveMenuRequest request);
Task AssignmentAsync(MenuPermissionAssignmentRequest request);
diff --git a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
index 6abefa92..b6c8601d 100644
--- a/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
+++ b/Src/Dlhis.Sys/Menu/Services/Implements/MenuService.cs
@@ -42,7 +42,7 @@ public class MenuService : IMenuService
}
[Transactional]
- public async Task SaveMenuAsync(SaveMenuRequest request)
+ public async Task SaveMenuAsync(SaveMenuRequest request)
{
await CheckAsync(request);
@@ -50,6 +50,7 @@ public class MenuService : IMenuService
{
var entity = request.Adapt();
await _dbContext.InsertAsync(entity);
+ return entity.Code;
}
else
{
@@ -59,6 +60,7 @@ public class MenuService : IMenuService
request.Adapt(entity);
await _dbContext.UpdateAsync(entity);
+ return entity.Code;
}
}
@@ -187,9 +189,10 @@ public class MenuService : IMenuService
foreach (var item in request)
{
- await SaveMenuAsync(item);
+ var code = await SaveMenuAsync(item);
if (item.Items?.Any() == true)
{
+ item.Items.ForEach(x => x.PCode = code);
await RecursionSaveNextAsync(item.Items);
}
}
@@ -199,9 +202,11 @@ public class MenuService : IMenuService
{
foreach (var item in menus)
{
- await SaveMenuAsync(item);
+ var code = await SaveMenuAsync(item);
+
if (item.Items?.Any() == true)
{
+ item.Items.ForEach(x => x.PCode = code);
await RecursionSaveNextAsync(item.Items);
}
}
@@ -221,6 +226,7 @@ public class MenuService : IMenuService
private async Task CheckAsync(SaveMenuRequest request)
{
+
//检查重复code
var exists = await _dbContext.Queryable()
.Where(x => x.Code == request.Code)
@@ -248,7 +254,11 @@ public class MenuService : IMenuService
if (request.MenuType == MenuEnumType.Folder)
{
- request.PCode = null;
+ //request.PCode = null;
+ if (string.IsNullOrEmpty(request.PCode))
+ {
+ request.PCode = null;
+ }
}
else if (request.MenuType == MenuEnumType.Menu)
{
@@ -300,4 +310,6 @@ public class MenuService : IMenuService
await _dbContext.UpdateAsync(permissions);
}
}
+
+
}
\ No newline at end of file