fix 可获取记录设备保存时候自动产生初始日志
This commit is contained in:
@@ -5,7 +5,6 @@ using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.Scope;
|
||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
@@ -92,9 +91,10 @@ public class DeviceService : IDeviceService
|
||||
var template = await CheckTemplateExistsAsync(request.TemplateCode);
|
||||
await CheckTemplateFieldAsync(request.TemplateCode, request.ConnectionInfo);
|
||||
|
||||
DeviceEntity entity = null;
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<DeviceEntity>();
|
||||
entity = request.Adapt<DeviceEntity>();
|
||||
entity.Code = Guid.NewGuid();
|
||||
await _dbContext.InsertAsync(entity);
|
||||
//同时保存注册信息
|
||||
@@ -115,7 +115,7 @@ public class DeviceService : IDeviceService
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<DeviceEntity>().Where(x => x.Id == request.Id).FirstAsync();
|
||||
entity = await _dbContext.Queryable<DeviceEntity>().Where(x => x.Id == request.Id).FirstAsync();
|
||||
entity.ThrowIfNull("设备不存在,无法更新");
|
||||
|
||||
//分类发生变化,检查是否存在分组
|
||||
@@ -130,15 +130,42 @@ public class DeviceService : IDeviceService
|
||||
existsG.ThrowIfTrue("存在设备分组,不可修改设备分类");
|
||||
}
|
||||
|
||||
var uniqueNo = entity.UniqueNo;
|
||||
request.Adapt(entity).UniqueNo = uniqueNo;
|
||||
|
||||
request.Adapt(entity);
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
|
||||
await GenerateUploadRecordLogForBeginTimeAsync(entity);
|
||||
}
|
||||
|
||||
//******************************************************** help methods **********************************************************
|
||||
|
||||
private async Task GenerateUploadRecordLogForBeginTimeAsync(DeviceEntity entity)
|
||||
{
|
||||
if (entity.Type == DeviceTypeEnumType.Door || entity.Type == DeviceTypeEnumType.Attendance)
|
||||
{
|
||||
var exists = await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
.Where(x => x.DeviceUniqueNo == entity.UniqueNo)
|
||||
.Where(x => x.Type == DeviceUploadLogTypeEnumType.Raise)
|
||||
.AnyAsync();
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
await _dbContext.InsertAsync(new DeviceUploadLogEntity
|
||||
{
|
||||
DeviceUniqueNo = entity.UniqueNo,
|
||||
Type = DeviceUploadLogTypeEnumType.Raise,
|
||||
UserUniqueNo = string.Empty,
|
||||
RaiseDateTime = entity.CreateTime,
|
||||
|
||||
CreatedBy = 1,
|
||||
CreateTime = DateTime.Now,
|
||||
ModifiedBy = 1,
|
||||
ModifiedTime = DateTime.Now,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查设备模板是否存在
|
||||
/// </summary>
|
||||
@@ -230,6 +257,7 @@ public class DeviceService : IDeviceService
|
||||
{
|
||||
var devices = await _dbContext.Queryable<DeviceEntity>()
|
||||
.Where(x => x.Enable)
|
||||
.Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance))
|
||||
.Select(x => new DeviceResponse
|
||||
{
|
||||
FuncsStr = x.Funcs.ToString()
|
||||
|
||||
Reference in New Issue
Block a user