feat 设备人员上传
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user