feat 获取本基地管理员列表

This commit is contained in:
cheche
2024-02-21 14:59:23 +08:00
parent 7f7afb251c
commit ef60f1dffc
7 changed files with 103 additions and 2 deletions

View File

@@ -164,7 +164,17 @@ public class DevicesController : ControllerBase
}
/// <summary>
/// 获取考勤设备总数
/// 获取考勤设备在线、离线及总数
/// </summary>
/// <returns></returns>
[HttpGet("devicesnumber")]
public async Task<DeviceNumberResponse> GetDeviceNumberAsync()
{
return await _deviceService.GetDeviceNumberAsync();
}
/// <summary>
/// 获取考勤设备详情列表
/// </summary>
/// <returns></returns>
[HttpGet("attendancestotal")]
@@ -174,7 +184,7 @@ public class DevicesController : ControllerBase
}
/// <summary>
/// 获取考勤在线/离线设备数
/// 获取考勤在线/离线设备详情列表
/// </summary>
/// <returns></returns>
[HttpGet("attendancesoffline")]

View File

@@ -0,0 +1,20 @@
namespace Dlhis.Basic.Device.Response
{
public class DeviceNumberResponse
{
/// <summary>
///在线
/// </summary>
public int OnlineNumber { get; set; }
/// <summary>
/// 离线
/// </summary>
public int OfflineNumber { get; set; }
/// <summary>
/// 总数
/// </summary>
public int TotalNumber { get; set; }
}
}

View File

@@ -17,6 +17,8 @@ public interface IDeviceService : IScopeDependency
Task<List<DeviceResponse>> GetAttendanceDevicesAsync();
Task<DeviceNumberResponse> GetDeviceNumberAsync();
Task<Pagination<DevicePageResponse>> GetAttendanceTotalAsync(AttendanceTotalRequest request);
Task<Pagination<DevicePageResponse>> GetAttendanceOfflineAsync(DeviceOnlineAndofflineRequest request);

View File

@@ -196,6 +196,22 @@ public class DeviceService : IDeviceService
return devices.Where(x => x.Funcs.Contains(DeviceFuncEnumType.Attendance)).ToList();
}
public async Task<DeviceNumberResponse> GetDeviceNumberAsync()
{
var devices = await _dbContext.Queryable<DeviceEntity>()
.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<Pagination<DevicePageResponse>> GetAttendanceTotalAsync(AttendanceTotalRequest request)
{
var page = await _dbContext.Queryable<DeviceEntity>()

View File

@@ -196,5 +196,18 @@ public class GainfosController : ControllerBase
return await _gainfoService.GetGainfoNumbersAsync(token);
}
/// <summary>
/// 获取本基地管理员列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpGet("administrator")]
public async Task<Pagination<GainfoDetailResponse>> GetAdministratorAsync([FromQuery] WeekNumberRequest request)
{
// 从请求头中获取 Token
string token = HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
return await _gainfoService.GetAdministratorAsync(request,token);
}
}

View File

@@ -37,4 +37,6 @@ public interface IGainfoService : IScopeDependency
Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request, string token);
Task<GainfoGainfoNumbersResponse> GetGainfoNumbersAsync(string token);
Task<Pagination<GainfoDetailResponse>> GetAdministratorAsync(WeekNumberRequest request,string token);
}

View File

@@ -514,6 +514,44 @@ public class GainfoService : IGainfoService
return res;
}
public async Task<Pagination<GainfoDetailResponse>> GetAdministratorAsync( WeekNumberRequest request, string token)
{
var werks = GetClaimValueFromToken(token, "tenant");
var info = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
.LeftJoin<DepartmentEntity>((ga, de) => ga.DepartmentNo == de.No)
.LeftJoin<BasicTypeEntity>((ga, de, type) => ga.Native == type.Code && type.Type == "native")
.LeftJoin<PositionEntity>((ga, de, type, posi) => ga.Position == posi.Name)
.LeftJoin<BasicTypeEntity>((ga, de, type, posi, type2) => ga.CountryNo == type2.Code && type2.Type == "country")
.LeftJoin<BasicTypeEntity>((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 ------------------------------------------------
/// <summary>