feat 设备人员上传

This commit is contained in:
2025-09-29 16:04:33 +08:00
parent f71e58dfc1
commit d84d8cd809
5 changed files with 109 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
namespace Dlhis.ScheduledTask.DeviceUploadLog.Services;
public interface IDeviceUserService : IScopeDependency
{
Task UploadAsync(DeviceUploadUserCodeRequest request);
}

View File

@@ -0,0 +1,32 @@
using Dlhis.Entity.Device.Entities;
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
namespace Dlhis.ScheduledTask.DeviceUploadLog.Services.Implements;
public class DeviceUserService : IDeviceUserService
{
private readonly IDbContext _dbContext;
public DeviceUserService(IDbContext dbContext)
{
_dbContext = dbContext;
}
public async Task UploadAsync(DeviceUploadUserCodeRequest request)
{
if (!await _dbContext.Queryable<DeviceUserEntity>().Where(x => x.DeviceUniqueNo == request.DeviceUniqueNo).AnyAsync())
{
var userCodes = request.UserCodes.Distinct().ToList();
var entities = userCodes.Select(userCode => new DeviceUserEntity
{
DeviceUniqueNo = request.DeviceUniqueNo,
UserCode = userCode,
IsDeleted = false
}).ToList();
await _dbContext.InsertAsync(entities);
}
}
}