Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development
This commit is contained in:
@@ -162,4 +162,34 @@ public class DevicesController : ControllerBase
|
||||
{
|
||||
return await _deviceService.GetAttendanceDevicesAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取考勤设备总数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("attendancestotal")]
|
||||
public async Task<Pagination<DevicePageResponse>> GetAttendanceTotalAsync([FromQuery]AttendanceTotalRequest request)
|
||||
{
|
||||
return await _deviceService.GetAttendanceTotalAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取考勤在线/离线设备数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("attendancesoffline")]
|
||||
public async Task<Pagination<DevicePageResponse>> GetAttendanceOfflineAsync([FromQuery] DeviceOnlineAndofflineRequest request)
|
||||
{
|
||||
return await _deviceService.GetAttendanceOfflineAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取近期30天新增设备数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("recentnumbers")]
|
||||
public async Task<Dictionary<string, int>> GetRecentNumbersAsync()
|
||||
{
|
||||
return await _deviceService.GetRecentNumbersAsync();
|
||||
}
|
||||
}
|
||||
|
||||
8
Src/Dlhis.Basic/Device/Request/AttendanceTotalRequest.cs
Normal file
8
Src/Dlhis.Basic/Device/Request/AttendanceTotalRequest.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Device.Request
|
||||
{
|
||||
public class AttendanceTotalRequest : PageDto
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Device.Request
|
||||
{
|
||||
public class DeviceOnlineAndofflineRequest :PageDto
|
||||
{
|
||||
public bool IsOnAndOff { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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<DeviceResponse> GetDeviceByNoAsync(DeviceByNoRequest request);
|
||||
|
||||
Task<List<DeviceResponse>> GetAttendanceDevicesAsync();
|
||||
|
||||
Task<Pagination<DevicePageResponse>> GetAttendanceTotalAsync(AttendanceTotalRequest request);
|
||||
|
||||
Task<Pagination<DevicePageResponse>> GetAttendanceOfflineAsync(DeviceOnlineAndofflineRequest request);
|
||||
|
||||
Task<Dictionary<string, int>> GetRecentNumbersAsync();
|
||||
}
|
||||
|
||||
@@ -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<Pagination<DevicePageResponse>> GetAttendanceTotalAsync(AttendanceTotalRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<DeviceEntity>()
|
||||
.LeftJoin<DeviceTemplateEntity>((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<Pagination<DevicePageResponse>> GetAttendanceOfflineAsync(DeviceOnlineAndofflineRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<DeviceEntity>()
|
||||
.LeftJoin<DeviceTemplateEntity>((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<Dictionary<string, int>> GetRecentNumbersAsync()
|
||||
{
|
||||
//获取近30天并转化为"yyyy-MM-dd"集合
|
||||
DateTime currentDate = DateTime.Now;
|
||||
List<string> times = new List<string>();
|
||||
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<DeviceEntity>().ToListAsync();
|
||||
|
||||
var dic = new Dictionary<string, int>();
|
||||
times.ForEach(time =>
|
||||
{
|
||||
var count = devices.Where(x => x.CreateTime.ToString("yyyy-MM-dd") == time).Count();
|
||||
dic[time] = count;
|
||||
});
|
||||
return dic;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取近七天入职人数及列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("weeknumber")]
|
||||
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetWeekNumberAsync([FromQuery] WeekNumberRequest request)
|
||||
{
|
||||
return await _gainfoService.GetWeekNumberAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取近七天离职人数及列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("weeknumberdimission")]
|
||||
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request)
|
||||
{
|
||||
return await _gainfoService.GetDimissionWeekNumberAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取基地在职、离职、考勤数
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("gainfonumbers")]
|
||||
public async Task<GainfoGainfoNumbersResponse> GetGainfoNumbersAsync(string Werks)
|
||||
{
|
||||
return await _gainfoService.GetGainfoNumbersAsync(Werks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Organization.Request
|
||||
{
|
||||
public class WeekNumberRequest : PageDto
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
@@ -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<Pagination<GainfoListResponse>> GetGainfoListTaskAsync(GainfoListRequest request);
|
||||
|
||||
Task<GainfoDetailResponse> GetGainfoDetailTaskAsync(GainfoDetailRequest request);
|
||||
|
||||
Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetWeekNumberAsync(WeekNumberRequest request);
|
||||
|
||||
Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request);
|
||||
|
||||
Task<GainfoGainfoNumbersResponse> GetGainfoNumbersAsync(string Werks);
|
||||
}
|
||||
|
||||
@@ -377,6 +377,136 @@ public class GainfoService : IGainfoService
|
||||
return info;
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, Pagination<GainfoDetailResponse>>> GetWeekNumberAsync(WeekNumberRequest request)
|
||||
{
|
||||
//获取近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);
|
||||
}
|
||||
|
||||
var dic = new Dictionary<string, Pagination<GainfoDetailResponse>>();
|
||||
|
||||
foreach (var time in times)
|
||||
{
|
||||
var infos = 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.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<Dictionary<string, Pagination<GainfoDetailResponse>>> GetDimissionWeekNumberAsync([FromQuery] WeekNumberRequest request)
|
||||
{
|
||||
//获取近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);
|
||||
}
|
||||
|
||||
var dic = new Dictionary<string, Pagination<GainfoDetailResponse>>();
|
||||
foreach (var time in times)
|
||||
{
|
||||
var infos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave)
|
||||
.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.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<GainfoGainfoNumbersResponse> 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 ------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,7 +9,7 @@ public interface IMenuService : IScopeDependency
|
||||
{
|
||||
Task<List<MenuResponse>> GetListAsync(PlatformEnumType platform);
|
||||
|
||||
Task SaveMenuAsync(SaveMenuRequest request);
|
||||
Task<string> SaveMenuAsync(SaveMenuRequest request);
|
||||
|
||||
Task AssignmentAsync(MenuPermissionAssignmentRequest request);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MenuService : IMenuService
|
||||
}
|
||||
|
||||
[Transactional]
|
||||
public async Task SaveMenuAsync(SaveMenuRequest request)
|
||||
public async Task<string> SaveMenuAsync(SaveMenuRequest request)
|
||||
{
|
||||
await CheckAsync(request);
|
||||
|
||||
@@ -50,6 +50,7 @@ public class MenuService : IMenuService
|
||||
{
|
||||
var entity = request.Adapt<MenuEntity>();
|
||||
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,8 +189,10 @@ public class MenuService : IMenuService
|
||||
|
||||
foreach (var item in request)
|
||||
{
|
||||
var code = await SaveMenuAsync(item);
|
||||
if (item.Items?.Any() == true)
|
||||
{
|
||||
item.Items.ForEach(x => x.PCode = code);
|
||||
await RecursionSaveNextAsync(item.Items);
|
||||
}
|
||||
}
|
||||
@@ -198,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);
|
||||
}
|
||||
}
|
||||
@@ -220,6 +226,7 @@ public class MenuService : IMenuService
|
||||
|
||||
private async Task CheckAsync(SaveMenuRequest request)
|
||||
{
|
||||
|
||||
//检查重复code
|
||||
var exists = await _dbContext.Queryable<MenuEntity>()
|
||||
.Where(x => x.Code == request.Code)
|
||||
@@ -247,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)
|
||||
{
|
||||
@@ -299,4 +310,6 @@ public class MenuService : IMenuService
|
||||
await _dbContext.UpdateAsync(permissions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user