diff --git a/Dlhis.Jinko.Face.sln b/Dlhis.Jinko.Face.sln
index ec9870dc..b7e65f3f 100644
--- a/Dlhis.Jinko.Face.sln
+++ b/Dlhis.Jinko.Face.sln
@@ -47,7 +47,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Message", "Src\Dlhis.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.InfoCheck", "Src\Dlhis.InfoCheck\Dlhis.InfoCheck.csproj", "{4D656761-8CE7-4316-A3DF-8C1722D69CCE}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Middle", "Src\Dlhis.Middle\Dlhis.Middle.csproj", "{762C944C-36A1-4F1A-803F-08F9BD8891D1}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.Middle", "Src\Dlhis.Middle\Dlhis.Middle.csproj", "{762C944C-36A1-4F1A-803F-08F9BD8891D1}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Dlhis.DataPermission.Model", "Src\Dlhis.DataPermission.Model\Dlhis.DataPermission.Model.csproj", "{CA1427E2-CC70-4489-8653-1C05630C8392}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -123,6 +125,10 @@ Global
{762C944C-36A1-4F1A-803F-08F9BD8891D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{762C944C-36A1-4F1A-803F-08F9BD8891D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{762C944C-36A1-4F1A-803F-08F9BD8891D1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CA1427E2-CC70-4489-8653-1C05630C8392}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CA1427E2-CC70-4489-8653-1C05630C8392}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CA1427E2-CC70-4489-8653-1C05630C8392}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CA1427E2-CC70-4489-8653-1C05630C8392}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Src/Dlhis.Basic/BusinessShift/Request/BusinessPlaceShiftSaveMealShiftRequest.cs b/Src/Dlhis.Basic/BusinessShift/Request/BusinessPlaceShiftSaveMealShiftRequest.cs
index a897d312..8093c05a 100644
--- a/Src/Dlhis.Basic/BusinessShift/Request/BusinessPlaceShiftSaveMealShiftRequest.cs
+++ b/Src/Dlhis.Basic/BusinessShift/Request/BusinessPlaceShiftSaveMealShiftRequest.cs
@@ -27,6 +27,7 @@ public class BusinessPlaceShiftSaveMealShiftRequest : IValidatableObject
///
/// 时间段
///
+ [Required(ErrorMessage = "时间段不可为空")]
public TimePeriod TimePeriod { get; set; }
@@ -37,14 +38,14 @@ public class BusinessPlaceShiftSaveMealShiftRequest : IValidatableObject
yield return new ValidationResult("时间段配置错误", new[] { nameof(TimePeriod) });
}
- if (TimePeriod?.Start == null || TimePeriod?.End == null)
+ if (TimePeriod!.Start == null || TimePeriod!.End == null)
{
yield return new ValidationResult("时间段配置错误", new[] { nameof(TimePeriod) });
}
- if (TimePeriod.Start == TimePeriod.End)
+ if (TimePeriod!.Start == TimePeriod!.End)
{
yield return new ValidationResult("时间段设置区间有误,开始时段不能等于结束时段.", new[] { nameof(TimePeriod) });
}
}
-}
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/BusinessShift/Services/IBusinessPlaceShiftService.cs b/Src/Dlhis.Basic/BusinessShift/Services/IBusinessPlaceShiftService.cs
index 93bc40fe..ab289c96 100644
--- a/Src/Dlhis.Basic/BusinessShift/Services/IBusinessPlaceShiftService.cs
+++ b/Src/Dlhis.Basic/BusinessShift/Services/IBusinessPlaceShiftService.cs
@@ -18,7 +18,7 @@ public interface IBusinessPlaceShiftService : IScopeDependency
Task GetShiftsByPlaceCustomCodeAsync(string placeCustomCode);
- Task> GetDevicesByCode(BusinessPlaceGetByCodeRequest request);
+ Task> GetAssignmentsAsync(Guid code);
- Task DispositionDeviceAsync(DispositionDeviceRequest request);
+ Task AssignAsync(DispositionDeviceRequest request);
}
diff --git a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs
index 3461d811..311be07e 100644
--- a/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs
+++ b/Src/Dlhis.Basic/BusinessShift/Services/Implements/BusinessPlaceShiftService.cs
@@ -102,8 +102,8 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
entity.ShiftCode = shift.Code;
entity.ShiftCustomCode = shift.CustomCode;
- entity.Start = request.TimePeriod.Start.Value;
- entity.End = request.TimePeriod.End.Value;
+ entity.Start = request.TimePeriod.Start!.Value;
+ entity.End = request.TimePeriod.End!.Value;
await _dbContext.InsertAsync(entity);
}
@@ -112,11 +112,11 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
var entity = await _dbContext.Queryable()
.Where(x => x.ShiftCode == shiftCode)
.SingleAsync(x => x.Id == request.Id);
-
+
entity.ThrowIfNull("餐次段不存在");
- entity.Start = request.TimePeriod.Start.Value;
- entity.End = request.TimePeriod.End.Value;
+ entity.Start = request.TimePeriod.Start!.Value;
+ entity.End = request.TimePeriod.End!.Value;
request.Adapt(entity);
await _dbContext.UpdateAsync(entity);
@@ -183,62 +183,30 @@ public class BusinessPlaceShiftService : IBusinessPlaceShiftService
};
}
- public async Task> GetDevicesByCode(BusinessPlaceGetByCodeRequest request)
+ public async Task> GetAssignmentsAsync(Guid code)
{
- var regiss = await _dbContext.Queryable()
- .Where(x => x.BusinessPlaceCode.ToString() == request.Code)
- .ToListAsync();
-
- var devices = await _dbContext.Queryable().ToListAsync();
-
- var list = new List();
- if (regiss.Count > 0)
- {
- foreach (var regis in regiss)
+ return await _dbContext.Queryable()
+ .LeftJoin((x, d) => x.DeviceUniqueNo == d.UniqueNo)
+ .Where(x => x.BusinessPlaceCode == code)
+ .Select((x, d) => new DeviceCodeNameDetail
{
- var device = devices.Where(x => x.UniqueNo == regis.DeviceUniqueNo)
- .FirstOrDefault();
- if (device != null)
- {
- var detail = new DeviceCodeNameDetail
- {
- UniqueNo = regis.DeviceUniqueNo,
- UniqueName = device.Supplier
- };
- list.Add(detail);
- }
- }
- }
-
- //分页
- var startIndex = (request.PageIndex - 1) * request.PageSize;
- var pagedData = list.Skip(startIndex).Take(request.PageSize).ToList();
-
- var pagination = new Pagination
- {
- PageIndex = request.PageIndex,
- PageSize = request.PageSize,
- Total = list.Count, // 使用原始列表的总数进行分页
- Data = pagedData
- };
-
- return pagination;
+ UniqueNo = x.DeviceUniqueNo,
+ UniqueName = d.DeployPlace
+ })
+ .ToListAsync();
}
- public async Task DispositionDeviceAsync(DispositionDeviceRequest request)
+ public async Task AssignAsync(DispositionDeviceRequest request)
{
var place = await _dbContext.Queryable().Where(x => x.Code == request.PlaceCode).SingleAsync();
place.ThrowIfNull("营业点不存在");
var registries = await _dbContext.Queryable()
- .Where(x => request.UniqueNos.Contains(x.DeviceUniqueNo))
+ .Where(x => x.BusinessPlaceCode == request.PlaceCode || request.UniqueNos.Contains(x.DeviceUniqueNo))
.ToListAsync();
- foreach (var item in registries)
- {
- item.BusinessPlaceCode = request.PlaceCode;
- }
+ registries.ForEach(item => { item.BusinessPlaceCode = request.UniqueNos.Contains(item.DeviceUniqueNo) ? request.PlaceCode : null; });
await _dbContext.UpdateAsync(registries);
}
diff --git a/Src/Dlhis.Basic/DataPermissions/GetDataPermissionService.cs b/Src/Dlhis.Basic/DataPermissions/GetDataPermissionService.cs
new file mode 100644
index 00000000..531db40d
--- /dev/null
+++ b/Src/Dlhis.Basic/DataPermissions/GetDataPermissionService.cs
@@ -0,0 +1,93 @@
+using Dlhis.Entity.Device.Entities;
+using Dlhis.Entity.Sys.Entities;
+using Dlhis.Entity.Sys.Enums;
+using Kurisu.AspNetCore.Authentication.Abstractions;
+using Kurisu.AspNetCore.DataAccess.Entity;
+using Kurisu.AspNetCore.DataAccess.SqlSugar.Attributes;
+using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
+
+namespace Dlhis.Basic.DataPermissions;
+
+public class GetDataPermissionService : IGetDataPermissions, ISingletonDependency
+{
+ private readonly ICurrentUser _currentUser;
+ private readonly IServiceProvider _serviceProvider;
+
+ public GetDataPermissionService(ICurrentUser currentUser, IServiceProvider serviceProvider)
+ {
+ _currentUser = currentUser;
+ _serviceProvider = serviceProvider;
+ }
+
+
+ public Dictionary> GetData()
+ {
+ var dict = new Dictionary>(2);
+ var currentRole = _currentUser.GetRole();
+ if (currentRole is "admin" or "tenant-admin")
+ {
+ return dict;
+ }
+
+ using var scope = _serviceProvider.CreateScope();
+
+ var db = scope.ServiceProvider.GetService();
+ db.Ignore(() =>
+ {
+ var userDataPermissions = db.Queryable()
+ .Where(x => x.AssignType == AssignTypeEnumType.User)
+ .Where(x => x.AssignValue == _currentUser.GetStringSubjectId())
+ .ToList();
+
+ var deviceCodeProperty = typeof(T)
+ .GetProperties()
+ .FirstOrDefault(x => x.IsDefined(typeof(DeviceCodeAttribute), false));
+
+ var deviceGroupCodeProperty = typeof(T)
+ .GetProperties()
+ .FirstOrDefault(x => x.IsDefined(typeof(DeviceGroupCodeAttribute), false));
+
+ var deviceCodes = new List();
+
+ //先计算分组权限下的设备
+ var deviceGroupCodes = userDataPermissions.Where(x => x.UniqueType == DeviceAssignmentTypeEnumType.Group).Select(x => x.UniqueValue).ToList();
+ if (deviceGroupCodes.Any() && deviceCodeProperty != null)
+ {
+ var data = db.Queryable().ToList();
+ //开始递归处理
+ var tops = data.Where(x => !x.PCode.HasValue).ToList();
+ tops.ForEach(x => { DeviceGroupRecursionGetNext(x, data, deviceGroupCodes, deviceGroupCodes.Contains(x.Code)); });
+ deviceGroupCodes = deviceGroupCodes.Distinct().ToList();
+ deviceCodes = db.Queryable().Where(x => deviceGroupCodes.Contains(x.GroupCode)).Select(x => x.DeviceCode).ToList();
+ }
+
+ if (deviceGroupCodeProperty != null && deviceGroupCodes.Any())
+ {
+ dict.Add(deviceGroupCodeProperty.Name, deviceGroupCodes);
+ }
+
+ if (deviceCodeProperty != null)
+ {
+ var currentDeviceCodes = userDataPermissions.Where(x => x.UniqueType == DeviceAssignmentTypeEnumType.Device).Select(x => x.UniqueValue).ToList();
+ deviceCodes.AddRange(currentDeviceCodes);
+ dict.Add(deviceCodeProperty.Name, deviceCodes.Distinct().ToList());
+ }
+ });
+
+ return dict;
+ }
+
+ static void DeviceGroupRecursionGetNext(DeviceGroupEntity current, List data, List result, bool add)
+ {
+ var next = data.Where(x => x.PCode == current.Code).ToList();
+ foreach (var item in next)
+ {
+ if (add)
+ {
+ result.Add(item.Code);
+ }
+
+ DeviceGroupRecursionGetNext(item, data, result, result.Contains(item.Code));
+ }
+ }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
index f4ed6272..ea5ca7ac 100644
--- a/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
+++ b/Src/Dlhis.Basic/Device/Controllers/DevicesController.cs
@@ -43,7 +43,7 @@ public class DevicesController : ControllerBase
{
return await _deviceTemplateService.GetPageAsync(request);
}
-
+
///
/// 设备模板保存
///
@@ -82,14 +82,14 @@ public class DevicesController : ControllerBase
{
return await _deviceConnectService.RegisterAsync(request);
}
-
-
+
///
/// 设备分页
///
///
///
[HttpGet("page")]
+ [DataPermission(true)]
public async Task> GetPageAsync([FromQuery] DevicePageRequest request)
{
return await _deviceService.GetPageAsync(request);
@@ -173,44 +173,14 @@ public class DevicesController : ControllerBase
return await _deviceService.GetDeviceNumberAsync();
}
- ///
- /// 获取考勤设备详情列表
- ///
- ///
- [HttpGet("attendancestotal")]
- public async Task> GetAttendanceTotalAsync([FromQuery] AttendanceTotalRequest request)
- {
- return await _deviceService.GetAttendanceTotalAsync(request);
- }
-
///
/// 获取考勤在线/离线设备详情列表
///
///
- [HttpGet("attendancesoffline")]
- public async Task> GetAttendanceOfflineAsync([FromQuery] DeviceOnlineAndOfflineRequest request)
+ [HttpGet("onlineStatus/page")]
+ public async Task> GetOnlineStatusPageAsync([FromQuery] DeviceOnlineAndOfflineRequest request)
{
- return await _deviceService.GetAttendanceOfflineAsync(request);
- }
-
- ///
- /// 获取门禁在线/离线设备详情列表
- ///
- ///
- [HttpGet("dooroffline")]
- public async Task> GetDoorOfflineAsync([FromQuery] GetDoorOfflineRequest request)
- {
- return await _deviceService.GetDoorOfflineAsync(request);
- }
-
- ///
- /// 获取近期30天考勤新增设备数
- ///
- ///
- [HttpGet("recentnumbers")]
- public async Task> GetRecentNumbersAsync()
- {
- return await _deviceService.GetRecentNumbersAsync();
+ return await _deviceService.GetOnlineStatusPageAsync(request);
}
///
diff --git a/Src/Dlhis.Basic/Device/Filters/AssignPermissionLimitAttribute.cs b/Src/Dlhis.Basic/Device/Filters/AssignPermissionLimitAttribute.cs
index 42675f51..9809093d 100644
--- a/Src/Dlhis.Basic/Device/Filters/AssignPermissionLimitAttribute.cs
+++ b/Src/Dlhis.Basic/Device/Filters/AssignPermissionLimitAttribute.cs
@@ -15,10 +15,8 @@ public class AssignPermissionLimitAttribute : Attribute, IAsyncActionFilter
var currentTenantId = currentUser.GetStringTenantId();
- await using (var handler = await redisCache.LockAsync($"permission:generate:{currentTenantId}"))
- {
- handler.Acquired.ThrowIfFalse("请勿频繁分配");
- await next();
- }
+ await using var handler = await redisCache.LockAsync($"permission:generate:{currentTenantId}");
+ handler.Acquired.ThrowIfFalse("请勿频繁分配");
+ await next();
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Device/Request/DeviceOnlineAndOfflineRequest.cs b/Src/Dlhis.Basic/Device/Request/DeviceOnlineAndOfflineRequest.cs
new file mode 100644
index 00000000..7521326b
--- /dev/null
+++ b/Src/Dlhis.Basic/Device/Request/DeviceOnlineAndOfflineRequest.cs
@@ -0,0 +1,19 @@
+using System.ComponentModel.DataAnnotations;
+using Dlhis.Entity.Device.Enums;
+using Kurisu.AspNetCore.DataAccess.Dto;
+
+namespace Dlhis.Basic.Device.Request;
+
+public class DeviceOnlineAndOfflineRequest : PageDto
+{
+ ///
+ /// 是否在线
+ ///
+ public bool IsOnline { get; set; }
+
+ ///
+ /// 设备类型
+ ///
+ [EnumDataType(typeof(DeviceTypeEnumType))]
+ public DeviceTypeEnumType Type { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Device/Request/DeviceOnlineAndofflineRequest.cs b/Src/Dlhis.Basic/Device/Request/DeviceOnlineAndofflineRequest.cs
deleted file mode 100644
index 82bdea8b..00000000
--- a/Src/Dlhis.Basic/Device/Request/DeviceOnlineAndofflineRequest.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using Kurisu.AspNetCore.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 5592e608..8ebcb7f3 100644
--- a/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/IDeviceService.cs
@@ -16,13 +16,7 @@ public interface IDeviceService : IScopeDependency
Task GetDeviceNumberAsync();
- Task> GetAttendanceTotalAsync(AttendanceTotalRequest request);
-
- Task> GetAttendanceOfflineAsync(DeviceOnlineAndOfflineRequest request);
-
- Task> GetDoorOfflineAsync(GetDoorOfflineRequest request);
-
- Task> GetRecentNumbersAsync();
+ Task> GetOnlineStatusPageAsync(DeviceOnlineAndOfflineRequest request);
Task ImportAsync(List request);
diff --git a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
index 049b31a1..9c34262a 100644
--- a/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
+++ b/Src/Dlhis.Basic/Device/Services/Implements/DeviceService.cs
@@ -71,7 +71,7 @@ public class DeviceService : IDeviceService
var registry = await _dbContext.Queryable().Where(x => x.DeviceUniqueNo == request.UniqueNo).FirstAsync();
if (registry == null)
{
- registry = new DeviceRegistryEntity()
+ registry = new DeviceRegistryEntity
{
DeviceUniqueNo = request.UniqueNo,
LastHeartbeatTime = DateTime.Now,
@@ -180,12 +180,10 @@ public class DeviceService : IDeviceService
///
///
///
- private async Task CheckTemplateExistsAsync(Guid templateCode)
+ private async Task CheckTemplateExistsAsync(Guid templateCode)
{
var entity = await _dbContext.Queryable().Where(x => x.Code == templateCode).FirstAsync();
entity.ThrowIfNull("设备模板不存在");
-
- return entity;
}
///
@@ -246,6 +244,7 @@ public class DeviceService : IDeviceService
}
catch (Exception)
{
+ //ignore
}
true.ThrowIfTrue($"设备已添加{factory}厂区");
@@ -342,84 +341,31 @@ public class DeviceService : IDeviceService
var list = devices.Where(x => offUniqueNos.Contains(x.UniqueNo)).ToList();
return list;
}
+
-
- public async Task> GetAttendanceTotalAsync(AttendanceTotalRequest request)
+ public async Task> GetOnlineStatusPageAsync(DeviceOnlineAndOfflineRequest request)
{
- var page = await _dbContext.Queryable()
- .LeftJoin((d, dt) => d.TemplateCode == dt.Code)
- .Where(d => d.Type == DeviceTypeEnumType.Attendance || (d.Type == DeviceTypeEnumType.Door && d.AsAttendance))
- .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)
- {
- return await GetDeviceStatusPageAsync(request.IsOnAndOff, request, DeviceTypeEnumType.Attendance);
- }
-
-
- public async Task> GetDoorOfflineAsync(GetDoorOfflineRequest request)
- {
- return await GetDeviceStatusPageAsync(request.IsOnAndOff, request, DeviceTypeEnumType.Door);
- }
-
-
- public async Task> GetRecentNumbersAsync()
- {
- //获取近30天并转化为"yyyy-MM-dd"集合
- DateTime currentDate = DateTime.Now;
- var 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().Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance)).ToListAsync();
-
- var list = new List();
- times.ForEach(time =>
- {
- var count = devices.Count(x => x.CreateTime.ToString("yyyy-MM-dd") == time);
- var res = new RecentNumberResponse
- {
- Date = time,
- Num = count,
- };
- list.Add(res);
- });
-
- return list;
+ return await GetDeviceStatusPageAsync(request.IsOnline, request, request.Type);
}
//************************************************************* help methods ************************************************************************
- private async Task> GetDeviceStatusPageAsync(bool isOnAndOff, PageDto pageDto, DeviceTypeEnumType deviceType)
+ private async Task> GetDeviceStatusPageAsync(bool isOnline, PageDto pageDto, DeviceTypeEnumType type)
{
- var devices = deviceType == DeviceTypeEnumType.Attendance
- ? await _dbContext.Queryable().Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance)).ToListAsync()
+ var devices = type == DeviceTypeEnumType.Attendance
+ ? await _dbContext.Queryable().Where(x => x.Type == DeviceTypeEnumType.Attendance).ToListAsync()
: await _dbContext.Queryable().Where(x => x.Type == DeviceTypeEnumType.Door).ToListAsync();
var offDevices = await GetOfflineDevicesCount(devices);
//离线
var ids = offDevices.Select(x => x.Id).ToList();
- if (!isOnAndOff)
+ if (!isOnline)
{
ids = devices.Select(x => x.Id).Except(ids).ToList();
}
return await _dbContext.Queryable()
.LeftJoin((d, dt) => d.TemplateCode == dt.Code)
- .Where(d => d.Type == DeviceTypeEnumType.Attendance)
.Where(d => ids.Contains(d.Id))
.WhereIF(pageDto.Search.IsPresent(), d => d.UniqueNo == pageDto.Search
|| d.DeployPlace.Contains(pageDto.Search))
@@ -427,7 +373,7 @@ public class DeviceService : IDeviceService
{
FuncsStr = d.Funcs.ToString(),
Brand = dt.Brand,
- Type = d.Type,
+ Type = d.Type
}, true)
.ToPageListAsync(pageDto);
}
diff --git a/Src/Dlhis.Basic/Places/Controllers/BusinessPlacesController.cs b/Src/Dlhis.Basic/Places/Controllers/BusinessPlacesController.cs
index edf388e1..635b6103 100644
--- a/Src/Dlhis.Basic/Places/Controllers/BusinessPlacesController.cs
+++ b/Src/Dlhis.Basic/Places/Controllers/BusinessPlacesController.cs
@@ -1,4 +1,5 @@
using Dlhis.Basic.BusinessShift.Services;
+using Dlhis.Basic.Device.Filters;
using Dlhis.Basic.Places.Request;
using Dlhis.Basic.Places.Response;
using Dlhis.Basic.Places.Services;
@@ -109,12 +110,12 @@ public class BusinessPlacesController : ControllerBase
///
/// 根据营业点获取下面的设备
///
- ///
+ ///
///
- [HttpGet("devicenos")]
- public async Task> GetDevicesByCode([FromQuery] BusinessPlaceGetByCodeRequest request)
+ [HttpGet("device/assignments")]
+ public async Task> GetAssignments(Guid code)
{
- return await _businessPlaceShiftService.GetDevicesByCode(request);
+ return await _businessPlaceShiftService.GetAssignmentsAsync(code);
}
///
@@ -122,9 +123,11 @@ public class BusinessPlacesController : ControllerBase
///
///
///
- [HttpPost("disposition")]
- public async Task DispositionDeviceAsync(DispositionDeviceRequest request)
+ [HttpPost("device/assign")]
+ [AssignPermissionLimit]
+ [DataPermission]
+ public async Task Assign(DispositionDeviceRequest request)
{
- await _businessPlaceShiftService.DispositionDeviceAsync(request);
+ await _businessPlaceShiftService.AssignAsync(request);
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Places/Request/BusinessPlaceGetByCodeRequest.cs b/Src/Dlhis.Basic/Places/Request/BusinessPlaceGetByCodeRequest.cs
deleted file mode 100644
index a8087d14..00000000
--- a/Src/Dlhis.Basic/Places/Request/BusinessPlaceGetByCodeRequest.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-using Kurisu.AspNetCore.DataAccess.Dto;
-
-namespace Dlhis.Basic.Places.Request
-{
- public class BusinessPlaceGetByCodeRequest : PageDto
- {
- ///
- /// 营业点号
- ///
- [Required(ErrorMessage = "营业点号不能为空")]
- public string Code { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Places/Response/DeviceCodeNameDetail.cs b/Src/Dlhis.Basic/Places/Response/DeviceCodeNameDetail.cs
index 2ccfd906..b95f5056 100644
--- a/Src/Dlhis.Basic/Places/Response/DeviceCodeNameDetail.cs
+++ b/Src/Dlhis.Basic/Places/Response/DeviceCodeNameDetail.cs
@@ -1,8 +1,7 @@
-namespace Dlhis.Basic.Places.Response
+namespace Dlhis.Basic.Places.Response;
+
+public class DeviceCodeNameDetail
{
- public class DeviceCodeNameDetail
- {
- public string UniqueNo { get; set; }
- public string UniqueName { get; set; }
- }
-}
+ public string UniqueNo { get; set; }
+ public string UniqueName { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs b/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs
index bfb8f69f..e8662def 100644
--- a/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs
+++ b/Src/Dlhis.Basic/Summary/Controllers/SummariesController.cs
@@ -1,5 +1,6 @@
using Dlhis.Basic.Summary.Response;
using Dlhis.Basic.Summary.Services;
+using Dlhis.Entity.Device.Enums;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@@ -18,32 +19,12 @@ public class SummariesController : ControllerBase
}
///
- /// 考勤首页
+ /// 首页
///
///
- [HttpGet("attendance-summary")]
- public async Task GetKaoQingSummary()
+ [HttpGet("home-summary")]
+ public async Task GetHomeSummaryAsync(DeviceTypeEnumType type)
{
- return await _summaryService.GetAttendanceSummaryAsync();
- }
-
- ///
- /// 门禁首页设备数据
- ///
- ///
- [HttpGet("door-summary")]
- public async Task GetDoorHomeDataAsync()
- {
- return await _summaryService.GetDoorHomeDataAsync();
- }
-
- ///
- /// 门禁首页数据
- ///
- ///
- [HttpGet("door-data")]
- public async Task GetDoorDataAsync()
- {
- return await _summaryService.GetDoorDataAsync();
+ return await _summaryService.GetHomeSummaryAsync(type);
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Summary/Response/AttendanceSummaryResponse.cs b/Src/Dlhis.Basic/Summary/Response/AttendanceSummaryResponse.cs
deleted file mode 100644
index ab930d60..00000000
--- a/Src/Dlhis.Basic/Summary/Response/AttendanceSummaryResponse.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Dlhis.Basic.Summary.Response
-{
- public class AttendanceSummaryResponse
- {
- public AttendanceDeviceSummary DeviceSummary { get; set; }
-
- public AttendanceDetailSummary AttendanceDetailSummary { get; set; }
- }
-}
diff --git a/Src/Dlhis.Basic/Summary/Response/AttendanceDeviceSummary.cs b/Src/Dlhis.Basic/Summary/Response/DeviceSummary.cs
similarity index 94%
rename from Src/Dlhis.Basic/Summary/Response/AttendanceDeviceSummary.cs
rename to Src/Dlhis.Basic/Summary/Response/DeviceSummary.cs
index 77a92955..32173118 100644
--- a/Src/Dlhis.Basic/Summary/Response/AttendanceDeviceSummary.cs
+++ b/Src/Dlhis.Basic/Summary/Response/DeviceSummary.cs
@@ -2,7 +2,7 @@
namespace Dlhis.Basic.Summary.Response;
-public class AttendanceDeviceSummary
+public class DeviceSummary
{
///
/// 总数
diff --git a/Src/Dlhis.Basic/Summary/Response/DoorDataResponse.cs b/Src/Dlhis.Basic/Summary/Response/DoorDataResponse.cs
deleted file mode 100644
index 184971f1..00000000
--- a/Src/Dlhis.Basic/Summary/Response/DoorDataResponse.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-namespace Dlhis.Basic.Summary.Response;
-
-public class DoorDataResponse
-{
- ///
- /// 门禁总人数
- ///
- public int Total => Employed + Unemployed;
-
- ///
- /// 在职人数
- ///
- public int Employed { get; set; }
-
- ///
- /// 非在职人数
- ///
- public int Unemployed { get; set; }
-
- ///
- /// 人员趋势 7天
- ///
- public GainfoTrendResponse GainfoTrend { get; set; }
-}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Summary/Response/DoorHomeDataResponse.cs b/Src/Dlhis.Basic/Summary/Response/DoorHomeDataResponse.cs
deleted file mode 100644
index 163a35fe..00000000
--- a/Src/Dlhis.Basic/Summary/Response/DoorHomeDataResponse.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using Dlhis.Basic.Summary.Dto;
-
-namespace Dlhis.Basic.Summary.Response
-{
- public class DoorHomeDataResponse
- {
- public int OffNum { get; set; }
- public int TotalNum { get; set; }
- public List Trend { get; set; }
- }
-}
diff --git a/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs b/Src/Dlhis.Basic/Summary/Response/GainfoDetailSummary.cs
similarity index 92%
rename from Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs
rename to Src/Dlhis.Basic/Summary/Response/GainfoDetailSummary.cs
index a013bb6a..812bb3c1 100644
--- a/Src/Dlhis.Basic/Summary/Response/AttendanceDetailSummary.cs
+++ b/Src/Dlhis.Basic/Summary/Response/GainfoDetailSummary.cs
@@ -1,6 +1,6 @@
namespace Dlhis.Basic.Summary.Response;
-public class AttendanceDetailSummary
+public class GainfoDetailSummary
{
///
/// 考勤总人数
diff --git a/Src/Dlhis.Basic/Summary/Response/GainfoTrendResponse.cs b/Src/Dlhis.Basic/Summary/Response/GainfoTrendResponse.cs
index 4050c983..7bb9449b 100644
--- a/Src/Dlhis.Basic/Summary/Response/GainfoTrendResponse.cs
+++ b/Src/Dlhis.Basic/Summary/Response/GainfoTrendResponse.cs
@@ -1,10 +1,9 @@
using Dlhis.Basic.Summary.Dto;
-namespace Dlhis.Basic.Summary.Response
+namespace Dlhis.Basic.Summary.Response;
+
+public class GainfoTrendResponse
{
- public class GainfoTrendResponse
- {
- public List EmployedTrend { get; set; }
- public List UnemployedTrend { get; set; }
- }
-}
+ public List EmployedTrend { get; set; }
+ public List UnemployedTrend { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Summary/Response/HomeSummaryResponse.cs b/Src/Dlhis.Basic/Summary/Response/HomeSummaryResponse.cs
new file mode 100644
index 00000000..ca24d629
--- /dev/null
+++ b/Src/Dlhis.Basic/Summary/Response/HomeSummaryResponse.cs
@@ -0,0 +1,14 @@
+namespace Dlhis.Basic.Summary.Response;
+
+public class HomeSummaryResponse
+{
+ ///
+ /// 设备
+ ///
+ public DeviceSummary DeviceSummary { get; set; }
+
+ ///
+ /// 明细
+ ///
+ public GainfoDetailSummary DetailSummary { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs b/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs
index dfb99fa3..38810872 100644
--- a/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs
+++ b/Src/Dlhis.Basic/Summary/Services/ISummaryService.cs
@@ -1,12 +1,9 @@
using Dlhis.Basic.Summary.Response;
+using Dlhis.Entity.Device.Enums;
namespace Dlhis.Basic.Summary.Services;
public interface ISummaryService : IScopeDependency
{
- Task GetAttendanceSummaryAsync();
-
- Task GetDoorHomeDataAsync();
-
- Task GetDoorDataAsync();
+ Task GetHomeSummaryAsync(DeviceTypeEnumType type);
}
\ No newline at end of file
diff --git a/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs
index 83cdace3..0844b6ed 100644
--- a/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs
+++ b/Src/Dlhis.Basic/Summary/Services/Implements/SummaryService.cs
@@ -23,7 +23,7 @@ public class SummaryService : ISummaryService
_currentUser = currentUser;
}
- public async Task GetAttendanceSummaryAsync()
+ public async Task GetHomeSummaryAsync(DeviceTypeEnumType type)
{
var now = DateTime.Now;
var tenantId = _currentUser.GetStringTenantId();
@@ -33,7 +33,7 @@ public class SummaryService : ISummaryService
var before7Day = DateTime.Today.AddDays(-6);
var devices = await _dbContext.Queryable()
- .Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance))
+ .Where(x => x.Type == type)
.ToListAsync();
var deviceUniqueNos = devices.Select(x => x.UniqueNo).ToList();
@@ -54,9 +54,9 @@ public class SummaryService : ISummaryService
.Where(x => x.Factory == tenantId)
.ToListAsync();
- return new AttendanceSummaryResponse
+ return new HomeSummaryResponse
{
- DeviceSummary = new AttendanceDeviceSummary
+ DeviceSummary = new DeviceSummary
{
Total = devices.Count,
EnableCount = devices.Count(x => x.Enable),
@@ -73,7 +73,7 @@ public class SummaryService : ISummaryService
.GroupBy(x => x.CreateTime.Date)
.Select(x => new TrendDto { Date = x.Key, Count = x.Count() }), before30Day, currentDay)
},
- AttendanceDetailSummary = new AttendanceDetailSummary
+ DetailSummary = new GainfoDetailSummary
{
Employed = workingGainfos.Count,
Unemployed = leaveGainfos.Count,
@@ -90,64 +90,7 @@ public class SummaryService : ISummaryService
};
}
- public async Task GetDoorHomeDataAsync()
- {
- var devices = await _dbContext.Queryable().Where(x => x.Type == DeviceTypeEnumType.Door).ToListAsync();
-
- var offDevices = await GetOfflineDevicesCount(devices);
-
- DateTime currentDate = DateTime.Now;
- var 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 list = new List();
- times.ForEach(time =>
- {
- var count = devices.Count(x => x.CreateTime.ToString("yyyy-MM-dd") == time);
- var trend = new TrendDto
- {
- Date = DateTime.ParseExact(time, "yyyy-MM-dd", null),
- Count = count,
- };
- list.Add(trend);
- });
- var res = new DoorHomeDataResponse
- {
- OffNum = offDevices.Count,
- TotalNum = devices.Count,
- Trend = list
- };
- return res;
- }
-
- public async Task GetDoorDataAsync()
- {
- var workingGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Working).ToListAsync();
- var leaveGainfos = await _gainfoStore.Queryable(GainfoStatusEnumType.Leave).ToListAsync();
-
- var currentDay = DateTime.Today.AddDays(1).AddSeconds(-1);
- var before7Day = DateTime.Today.AddDays(-6);
-
- return new DoorDataResponse
- {
- Employed = workingGainfos.Count,
- Unemployed = leaveGainfos.Count,
- GainfoTrend = new GainfoTrendResponse()
- {
- EmployedTrend = FixTrend(workingGainfos.Where(x => x.EntryDate >= before7Day && x.EntryDate <= currentDay)
- .GroupBy(x => x.EntryDate)
- .Select(x => new TrendDto { Date = x.Key!.Value, Count = x.Count() }), before7Day, currentDay),
- UnemployedTrend = FixTrend(leaveGainfos.Where(x => x.ResignationDate >= before7Day && x.ResignationDate <= currentDay)
- .GroupBy(x => x.ResignationDate)
- .Select(x => new TrendDto { Date = x.Key!.Value, Count = x.Count() }), before7Day, currentDay)
- }
- };
- }
+ //********************************************************************************************************************************************
private static List FixTrend(IEnumerable dtos, DateTime start, DateTime end)
@@ -173,48 +116,4 @@ public class SummaryService : ISummaryService
return result.OrderBy(x => x.Date).ToList();
}
-
- ///
- /// 获取离线设备
- ///
- ///
- private async Task> GetOfflineDevicesCount(List devices)
- {
- var now = DateTime.Now;
-
- var deviceUniqueNos = devices.Select(x => x.UniqueNo).ToList();
-
- var deviceRegistries = await _dbContext.Queryable()
- .LeftJoin((x, d) => x.DeviceUniqueNo == d.UniqueNo)
- .Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo))
- .Select((x, d) => new
- {
- UniqueNo = d.UniqueNo,
- d.HeartbeatInterval,
- x.LastHeartbeatTime
- })
- .ToListAsync();
-
- var onlineDevices = deviceRegistries
- .Where(x =>
- {
- if (x.HeartbeatInterval <= 0)
- {
- return true;
- }
-
- return x.LastHeartbeatTime.AddSeconds(x.HeartbeatInterval) >= now;
- })
- .Select(x => new
- {
- UniqueNo = x.UniqueNo,
- })
- .ToList();
- var onlineUniqueNos = new List();
- onlineDevices.ForEach(x => onlineUniqueNos.Add(x.UniqueNo));
-
- var offUniqueNos = deviceUniqueNos.Except(onlineUniqueNos).ToList();
- var list = devices.Where(x => offUniqueNos.Contains(x.UniqueNo)).ToList();
- return list;
- }
}
\ No newline at end of file
diff --git a/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs b/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs
index 4176fec9..870ade09 100644
--- a/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs
+++ b/Src/Dlhis.Canteen/MealSupplementRecord/Services/Implements/MealSupplementRecordService.cs
@@ -86,7 +86,7 @@ public class MealSupplementRecordService : IMealSupplementRecordService
.Where(x => x.Status == BalanceRecordStatusEnumType.Valid)
.Where(x => x.ApplicationType == CanteenApplicationTypeEnumType.MealSupplement)
.Where(x => x.UserCode == code)
- .OrderBy(x => x.CostDateTime, OrderByType.Desc)
+ .OrderBy(x => x.CostDateTime)
.Select(x => new MealSupplementRecordItemResponse
{
CurrentAmount = x.Amount,
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
index 088844f3..74382ee9 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
@@ -303,7 +303,7 @@ public class BalanceService : IBalanceService
.WhereIF(request.SearchDateTimePeriod?.End.HasValue == true, record => record.CostDate <= request.SearchDateTimePeriod.End)
.WhereIF(request.ApplicationType.HasValue, record => record.ApplicationType == request.ApplicationType)
.Where((record, ga) => ga.Code == jinkoCode)
- .OrderBy(record => record.CreateTime, OrderByType.Desc)
+ .OrderBy(record => record.CostDateTime)
.Select((record, ga, department, bPlace) => new BalanceRecordUserPageResponse
{
Id = record.Id,
@@ -523,20 +523,21 @@ public class BalanceService : IBalanceService
await _dbContext.InsertAsync(gainfoMeal);
}
- var businessPlace = await _dbContext.Queryable()
+ var businessPlaceInfo = await _dbContext.Queryable()
.LeftJoin((a, b) => a.Code == b.PlaceCode)
.LeftJoin((a, b, c) => b.ShiftCode == c.Code)
.Where((a, b, c) => a.CustomCode == request.BusinessPlaceCode)
.Select((a, b, c) => new
{
a.Code,
- ShiftCode = c.Code
+ ShiftCode = c.Code,
+ a.TenantId
})
.SingleAsync();
if (request.Type == BalanceRecordTypeEnumType.Out)
{
- businessPlace.ThrowIfNull($"营业点{request.BusinessPlaceCode}不存在");
+ businessPlaceInfo.ThrowIfNull($"营业点{request.BusinessPlaceCode}不存在");
}
await _dbContext.InsertAsync(new BalanceRecordEntity
@@ -544,8 +545,8 @@ public class BalanceService : IBalanceService
Amount = request.Amount,
ApplicationType = request.ApplicationType,
Type = request.Type,
- BusinessPlaceCode = businessPlace?.Code,
- BusinessShiftCode = businessPlace?.ShiftCode,
+ BusinessPlaceCode = businessPlaceInfo?.Code,
+ BusinessShiftCode = businessPlaceInfo?.ShiftCode,
ShiftType = request.ShiftType,
CostDate = request.CostDate,
CostDateTime = request.CostDateTime,
@@ -557,7 +558,7 @@ public class BalanceService : IBalanceService
Remark = request.Remark,
CostId = gainfo.CostId,
SubsidiesFromMonth = request.CostDate.ToString("yyyyMM"),
- TenantId = request.Factory,
+ TenantId = businessPlaceInfo?.TenantId ?? request.Factory,
OriginTenantId = gainfo.Factory,
Werks = gainfo.Werks,
Name = gainfo.Name,
@@ -621,7 +622,7 @@ public class BalanceService : IBalanceService
.Where(x => x.Code == request.UserCode)
.SingleAsync();
- (gainfo == null).ThrowIfTrue($"工号{request.UserCode}不存在");
+ gainfo.ThrowIfNull($"工号{request.UserCode}不存在");
await _dbContext.InsertAsync(new BalanceRecordEntity
{
@@ -686,7 +687,7 @@ public class BalanceService : IBalanceService
}
}
-
+
public async Task ReCalcAsync(BalanceReCalcRequest request)
{
await CommonHelper.RetryAsync(async () =>
diff --git a/Src/Dlhis.DataPermission.Model/DeviceCodeAttribute.cs b/Src/Dlhis.DataPermission.Model/DeviceCodeAttribute.cs
new file mode 100644
index 00000000..764d995b
--- /dev/null
+++ b/Src/Dlhis.DataPermission.Model/DeviceCodeAttribute.cs
@@ -0,0 +1,8 @@
+using Kurisu.AspNetCore.DataAccess.SqlSugar.Attributes;
+
+namespace Dlhis.Basic.DataPermissions;
+
+[AttributeUsage(AttributeTargets.Property)]
+public class DeviceCodeAttribute : BaseDataPermissionAttribute
+{
+}
\ No newline at end of file
diff --git a/Src/Dlhis.DataPermission.Model/DeviceGroupCodeAttribute.cs b/Src/Dlhis.DataPermission.Model/DeviceGroupCodeAttribute.cs
new file mode 100644
index 00000000..3f232bc4
--- /dev/null
+++ b/Src/Dlhis.DataPermission.Model/DeviceGroupCodeAttribute.cs
@@ -0,0 +1,8 @@
+using Kurisu.AspNetCore.DataAccess.SqlSugar.Attributes;
+
+namespace Dlhis.Basic.DataPermissions;
+
+[AttributeUsage(AttributeTargets.Property)]
+public class DeviceGroupCodeAttribute : BaseDataPermissionAttribute
+{
+}
\ No newline at end of file
diff --git a/Src/Dlhis.DataPermission.Model/Dlhis.DataPermission.Model.csproj b/Src/Dlhis.DataPermission.Model/Dlhis.DataPermission.Model.csproj
new file mode 100644
index 00000000..ddf857f3
--- /dev/null
+++ b/Src/Dlhis.DataPermission.Model/Dlhis.DataPermission.Model.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs
index ef074069..a4b3eb62 100644
--- a/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs
+++ b/Src/Dlhis.Entity/Basic/Entity/DeviceEntity.cs
@@ -1,4 +1,5 @@
-using Dlhis.Entity.Device.Enums;
+using Dlhis.Basic.DataPermissions;
+using Dlhis.Entity.Device.Enums;
using Kurisu.AspNetCore.DataAccess.Entity;
using Kurisu.AspNetCore.DataAccess.SqlSugar;
using Mapster;
@@ -16,6 +17,7 @@ namespace Dlhis.Entity.Basic.Entity
///
/// 设备code
///
+ [DeviceCode]
[SugarColumn(ColumnDescription = "设备code")]
public Guid Code { get; set; }
diff --git a/Src/Dlhis.Entity/Dlhis.Entity.csproj b/Src/Dlhis.Entity/Dlhis.Entity.csproj
index 6daa5ed5..3a1c5245 100644
--- a/Src/Dlhis.Entity/Dlhis.Entity.csproj
+++ b/Src/Dlhis.Entity/Dlhis.Entity.csproj
@@ -7,7 +7,11 @@
-
+
+
+
+
+
diff --git a/Src/Dlhis.Entity/Sys/Entities/DataPermissionEntity.cs b/Src/Dlhis.Entity/Sys/Entities/DataPermissionEntity.cs
new file mode 100644
index 00000000..803502d0
--- /dev/null
+++ b/Src/Dlhis.Entity/Sys/Entities/DataPermissionEntity.cs
@@ -0,0 +1,17 @@
+using Dlhis.Entity.Sys.Enums;
+using Kurisu.AspNetCore.DataAccess.SqlSugar;
+using SqlSugar;
+
+namespace Dlhis.Entity.Sys.Entities;
+
+[SugarTable(TableName = "DataPermissions")]
+public class DataPermissionEntity : SugarBaseEntity
+{
+ public AssignTypeEnumType AssignType { get; set; }
+
+ public string AssignValue { get; set; }
+
+ public DeviceAssignmentTypeEnumType UniqueType { get; set; }
+
+ public Guid UniqueValue { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Entity/Visitor/Entity/BusinessTripEntity.cs b/Src/Dlhis.Entity/Visitor/Entity/BusinessTripEntity.cs
new file mode 100644
index 00000000..00d59918
--- /dev/null
+++ b/Src/Dlhis.Entity/Visitor/Entity/BusinessTripEntity.cs
@@ -0,0 +1,71 @@
+using Kurisu.AspNetCore.DataAccess.SqlSugar;
+using SqlSugar;
+
+namespace Dlhis.Entity.Visitor.Entity;
+
+[SugarTable(TableName = "BusinessTrip")]
+public class BusinessTripEntity : SugarBaseEntity
+{
+ ///
+ /// 工号
+ ///
+ [SugarColumn(IsNullable = false, UniqueGroupNameList = new[] { "unique_BusinessTrip_code_begin_end" })]
+ public string Code { get; set; }
+
+ ///
+ /// 姓名
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 开始日期
+ ///
+ [SugarColumn(IsNullable = false, UniqueGroupNameList = new[] { "unique_BusinessTrip_code_begin_end" })]
+ public string BeginDate { get; set; }
+
+ ///
+ /// 结束日期
+ ///
+ [SugarColumn(IsNullable = false, UniqueGroupNameList = new[] { "unique_BusinessTrip_code_begin_end" })]
+ public string EndDate { get; set; }
+
+ ///
+ /// 开始时间
+ ///
+ public DateTime BeginDateTime { get; set; }
+
+ ///
+ /// 结束时间
+ ///
+ public DateTime EndDateTime { get; set; }
+
+ ///
+ /// 出差类型
+ ///
+ public string Type { get; set; }
+
+ ///
+ /// 出差类型描述
+ ///
+ public string TypeDesc { get; set; }
+
+ ///
+ /// 出差时数
+ ///
+ public int Hour { get; set; }
+
+ ///
+ /// 出差天数
+ ///
+ public double Day { get; set; }
+
+ ///
+ /// 出差目的地
+ ///
+ public string Destination { get; set; }
+
+ ///
+ /// 出差目的地描述
+ ///
+ public string DestinationDesc { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/Common/Response/SapBusinessTripInfoResponse.cs b/Src/Dlhis.ScheduledTask/Common/Response/SapBusinessTripInfoResponse.cs
new file mode 100644
index 00000000..4d1495d2
--- /dev/null
+++ b/Src/Dlhis.ScheduledTask/Common/Response/SapBusinessTripInfoResponse.cs
@@ -0,0 +1,87 @@
+using Newtonsoft.Json;
+
+namespace Dlhis.ScheduledTask.Common.Response;
+
+public class SapBusinessTripInfoResponse
+{
+ ///
+ /// 明细数据
+ ///
+ [JsonProperty("OT_2002")]
+ public List Items { get; set; }
+}
+
+public class SapBusinessTripInfoItem
+{
+ ///
+ /// 工号
+ ///
+ [JsonProperty("OV_GONGH")]
+ public string Code { get; set; }
+
+ ///
+ /// 姓名
+ ///
+ [JsonProperty("OV_ENAME")]
+ public string Name { get; set; }
+
+ ///
+ /// 开始日期
+ ///
+ [JsonProperty("OV_BEGDA")]
+ public string BeginDate { get; set; }
+
+ ///
+ /// 结束日期
+ ///
+ [JsonProperty("OV_ENDDA")]
+ public string EndDate { get; set; }
+
+ ///
+ /// 开始时间
+ ///
+ [JsonProperty("OV_BEGUZ")]
+ public DateTime BeginDateTime { get; set; }
+
+ ///
+ /// 结束时间
+ ///
+ [JsonProperty("OV_ENDUZ")]
+ public DateTime EndDateTime { get; set; }
+
+ ///
+ /// 出差类型
+ ///
+ [JsonProperty("OV_AWART")]
+ public string Type { get; set; }
+
+ ///
+ /// 出差类型描述
+ ///
+ [JsonProperty("OV_ATEXT")]
+ public string TypeDesc { get; set; }
+
+ ///
+ /// 出差时数
+ ///
+ [JsonProperty("OV_STDAZ")]
+ public int Hour { get; set; }
+
+ ///
+ /// 出差天数
+ ///
+ [JsonProperty("OV_ABWTG")]
+ public double Day { get; set; }
+
+ ///
+ /// 出差目的地
+ ///
+ [JsonProperty("OV_CCMDD")]
+ public string Destination { get; set; }
+
+ ///
+ /// 出差目的地描述
+ ///
+ [JsonProperty("OV_CCMDDM")]
+ public string DestinationDesc { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/Common/Response/SapTravelInfoResponse.cs b/Src/Dlhis.ScheduledTask/Common/Response/SapTravelInfoResponse.cs
deleted file mode 100644
index c706f9bd..00000000
--- a/Src/Dlhis.ScheduledTask/Common/Response/SapTravelInfoResponse.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using Newtonsoft.Json;
-
-namespace Dlhis.ScheduledTask.Common.Response
-{
- public class SapTravelInfoResponse
- {
- ///
- /// 明细数据
- ///
- [JsonProperty("OT_2002")]
- public List Items { get; set; }
- }
-
- public class SapTravelInfoItem
- {
- ///
- /// 工号
- ///
- [JsonProperty("OV_GONGH")]
- public string Code { get; set; }
-
- ///
- /// 姓名
- ///
- [JsonProperty("OV_ENAME")]
- public string Name { get; set; }
-
- ///
- /// 开始日期
- ///
- [JsonProperty("OV_BEGDA")]
- public string BeginDate { get; set; }
-
- ///
- /// 结束日期
- ///
- [JsonProperty("OV_ENDDA")]
- public string EndDate { get; set; }
-
- ///
- /// 开始时间
- ///
- [JsonProperty("OV_BEGUZ")]
- public DateTime BeginDateTime { get; set; }
-
- ///
- /// 结束时间
- ///
- [JsonProperty("OV_ENDUZ")]
- public DateTime EndDateTime { get; set; }
-
- ///
- /// 出差类型
- ///
- [JsonProperty("OV_AWART")]
- public string Type { get; set; }
-
- ///
- /// 出差类型描述
- ///
- [JsonProperty("OV_ATEXT")]
- public string TypeDesc { get; set; }
-
- ///
- /// 出差时数
- ///
- [JsonProperty("OV_STDAZ")]
- public int Hour { get; set; }
-
- ///
- /// 出差天数
- ///
- [JsonProperty("OV_ABWTG")]
- public double Day { get; set; }
-
- ///
- /// 出差目的地
- ///
- [JsonProperty("OV_CCMDD")]
- public string Destination { get; set; }
-
- ///
- /// 出差目的地描述
- ///
- [JsonProperty("OV_CCMDDM")]
- public string DestinationDesc { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/Common/Services/IJinkoJIPService.cs b/Src/Dlhis.ScheduledTask/Common/Services/IJinkoJIPService.cs
index b80442e0..038e5ec0 100644
--- a/Src/Dlhis.ScheduledTask/Common/Services/IJinkoJIPService.cs
+++ b/Src/Dlhis.ScheduledTask/Common/Services/IJinkoJIPService.cs
@@ -9,5 +9,15 @@ public interface IJinkoJIPService : ISingletonDependency
Task SyncMealSupplementRecordsAsync(List requests);
- public string IssueToken();
-}
+
+ ///
+ /// 获取出差信息
+ ///
+ ///
+ ///
+ ///
+ ///
+ Task GetTravelInfosAsync(DateTime begin, DateTime end, string departmentNo);
+
+ string IssueToken();
+}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/Common/Services/IJinkoSapService.cs b/Src/Dlhis.ScheduledTask/Common/Services/IJinkoSapService.cs
index 9ed75d5e..badd62b3 100644
--- a/Src/Dlhis.ScheduledTask/Common/Services/IJinkoSapService.cs
+++ b/Src/Dlhis.ScheduledTask/Common/Services/IJinkoSapService.cs
@@ -11,12 +11,4 @@ public interface IJinkoSapService : IScopeDependency
Task GetPersonsByWerkAsync(string werk);
Task GetPersonsByCodeAsync(string code);
-
- ///
- /// 获取出差信息
- ///
- ///
- ///
- ///
- Task GetTravelInfosAsync(DateTime begin, DateTime end);
}
\ No newline at end of file
diff --git a/Src/Dlhis.ScheduledTask/Common/Services/Implements/JinkoJIPService.cs b/Src/Dlhis.ScheduledTask/Common/Services/Implements/JinkoJIPService.cs
index c0f7e21b..b6722bc9 100644
--- a/Src/Dlhis.ScheduledTask/Common/Services/Implements/JinkoJIPService.cs
+++ b/Src/Dlhis.ScheduledTask/Common/Services/Implements/JinkoJIPService.cs
@@ -4,7 +4,6 @@ using System.Security.Claims;
using System.Text;
using Dlhis.ScheduledTask.Common.Request;
using Dlhis.ScheduledTask.Common.Response;
-using Dlhis.ScheduledTask.Common.Services;
using Kurisu.AspNetCore.Utils.Extensions;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json.Linq;
@@ -85,6 +84,7 @@ public class JinkoJIPService : IJinkoJIPService
{
true.ThrowIfTrue(exp.Value());
}
+
if (jobj.TryGetValue("message", out var message) && !jobj.ContainsKey("code"))
{
true.ThrowIfTrue(message.Value());
@@ -95,6 +95,39 @@ public class JinkoJIPService : IJinkoJIPService
return responseJson;
}
+
+ public async Task GetTravelInfosAsync(DateTime begin, DateTime end, string departmentNo)
+ {
+ const string apiUrl = "/JIP/HCM/HCM_TRAVELINFO";
+
+ var beginDay = begin.ToString("yyyyMMdd");
+ var endDay = end.ToString("yyyyMMdd");
+
+ var obj = new
+ {
+ IV_BEGDA = beginDay,
+ IV_ENDDA = endDay,
+ IT_2002GH = new List