From ef60f1dffc58423d1edafce592d2fcc01587fa2c Mon Sep 17 00:00:00 2001
From: cheche <717840555@qq.com>
Date: Wed, 21 Feb 2024 14:59:23 +0800
Subject: [PATCH] =?UTF-8?q?feat=20=E8=8E=B7=E5=8F=96=E6=9C=AC=E5=9F=BA?=
=?UTF-8?q?=E5=9C=B0=E7=AE=A1=E7=90=86=E5=91=98=E5=88=97=E8=A1=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Device/Controllers/DevicesController.cs | 14 ++++++-
.../Device/Response/DeviceNumberResponse.cs | 20 ++++++++++
.../Device/Services/IDeviceService.cs | 2 +
.../Services/Implements/DeviceService.cs | 16 ++++++++
.../Controllers/GainfosController.cs | 13 +++++++
.../Organization/Services/IGainfoService.cs | 2 +
.../Services/Implements/GainfoService.cs | 38 +++++++++++++++++++
7 files changed, 103 insertions(+), 2 deletions(-)
create mode 100644 Src/Dlhis.Basic/Device/Response/DeviceNumberResponse.cs
diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
index 6dfcd3f3..cfc4a1dd 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
@@ -164,7 +164,17 @@ public class DevicesController : ControllerBase
}
///
- /// 获取考勤设备总数
+ /// 获取考勤设备在线、离线及总数
+ ///
+ ///
+ [HttpGet("devicesnumber")]
+ public async Task GetDeviceNumberAsync()
+ {
+ return await _deviceService.GetDeviceNumberAsync();
+ }
+
+ ///
+ /// 获取考勤设备详情列表
///
///
[HttpGet("attendancestotal")]
@@ -174,7 +184,7 @@ public class DevicesController : ControllerBase
}
///
- /// 获取考勤在线/离线设备数
+ /// 获取考勤在线/离线设备详情列表
///
///
[HttpGet("attendancesoffline")]
diff --git a/Src/Dlhis.Basic/Device/Response/DeviceNumberResponse.cs b/Src/Dlhis.Basic/Device/Response/DeviceNumberResponse.cs
new file mode 100644
index 00000000..925e9e98
--- /dev/null
+++ b/Src/Dlhis.Basic/Device/Response/DeviceNumberResponse.cs
@@ -0,0 +1,20 @@
+namespace Dlhis.Basic.Device.Response
+{
+ public class DeviceNumberResponse
+ {
+ ///
+ ///在线
+ ///
+ public int OnlineNumber { get; set; }
+
+ ///
+ /// 离线
+ ///
+ public int OfflineNumber { get; set; }
+
+ ///
+ /// 总数
+ ///
+ public int TotalNumber { get; set; }
+ }
+}
diff --git a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
index 9d346d3e..745702d4 100644
--- a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
@@ -17,6 +17,8 @@ public interface IDeviceService : IScopeDependency
Task> GetAttendanceDevicesAsync();
+ Task GetDeviceNumberAsync();
+
Task> GetAttendanceTotalAsync(AttendanceTotalRequest request);
Task> GetAttendanceOfflineAsync(DeviceOnlineAndofflineRequest request);
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
index 9d61dd71..28b2f66c 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
@@ -196,6 +196,22 @@ public class DeviceService : IDeviceService
return devices.Where(x => x.Funcs.Contains(DeviceFuncEnumType.Attendance)).ToList();
}
+ public async Task GetDeviceNumberAsync()
+ {
+ var devices = await _dbContext.Queryable()
+ .Where(x => x.Type == DeviceTypeEnumType.Attendance)
+ .ToListAsync();
+ var onlineNumber = devices.Where(x => x.Enable).Count();
+ var offlineNumber = devices.Where(x => x.Enable == false).Count();
+ var res = new DeviceNumberResponse
+ {
+ OnlineNumber = onlineNumber,
+ OfflineNumber = offlineNumber,
+ TotalNumber = devices.Count()
+ };
+ return res;
+ }
+
public async Task> GetAttendanceTotalAsync(AttendanceTotalRequest request)
{
var page = await _dbContext.Queryable()
diff --git a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
index 2f1ee735..b6c09d43 100644
--- a/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
+++ b/Src/Dlhis.Basic/Organization/Controllers/GainfosController.cs
@@ -196,5 +196,18 @@ public class GainfosController : ControllerBase
return await _gainfoService.GetGainfoNumbersAsync(token);
}
+
+ ///
+ /// 获取本基地管理员列表
+ ///
+ ///
+ ///
+ [HttpGet("administrator")]
+ public async Task> GetAdministratorAsync([FromQuery] WeekNumberRequest request)
+ {
+ // 从请求头中获取 Token
+ string token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
+ return await _gainfoService.GetAdministratorAsync(request,token);
+ }
}
diff --git a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
index 56456bed..7bb8f0fc 100644
--- a/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/IGainfoService.cs
@@ -37,4 +37,6 @@ public interface IGainfoService : IScopeDependency
Task>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request, string token);
Task GetGainfoNumbersAsync(string token);
+
+ Task> GetAdministratorAsync(WeekNumberRequest request,string token);
}
diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
index 2acfff75..ce14552e 100644
--- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
+++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoService.cs
@@ -514,6 +514,44 @@ public class GainfoService : IGainfoService
return res;
}
+ public async Task> GetAdministratorAsync( WeekNumberRequest request, string token)
+ {
+ var werks = GetClaimValueFromToken(token, "tenant");
+ var info = 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.Werks == werks && ga.IdentityUserId != 0)
+ .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);
+
+ return info;
+ }
+
//-------------------------------------------help methods ------------------------------------------------
///