添加设备类、设备日志类、设备服务类、设备控制器

This commit is contained in:
2026-08-28 17:28:16 +08:00
parent 6c20630a40
commit cfa8e78d33
11 changed files with 667 additions and 23 deletions
+89
View File
@@ -1,6 +1,8 @@
using Model.Dto.Asset;
using Model.Dto.Config;
using Model.Dto.Inspection;
using Model.Entity.Asset;
using Model.Entity.Config;
using Model.Entity.Inspection;
namespace Model.Mapper
@@ -387,5 +389,92 @@ namespace Model.Mapper
};
}
#endregion
#region IOT设备
/// <summary>
/// IotDeviceEntity → IotDeviceDto
/// </summary>
public static IotDeviceDto ToDto(this IotDeviceEntity entity)
{
if (entity == null) return null;
return new IotDeviceDto
{
Id = entity.Id.ToString(),
Code = entity.Code,
Name = entity.Name,
DeviceType = entity.DeviceType,
GatewayCode = entity.GatewayCode,
SlaveId = entity.SlaveId,
Manufacturer = entity.Manufacturer,
Description = entity.Description,
ProtocolType = entity.ProtocolType,
IsEnabled = entity.IsEnabled,
OnlineStatus = entity.OnlineStatus,
LastCollectTime = entity.LastCollectTime,
LastError = entity.LastError,
Remark = entity.Remark,
CreateTime = entity.CreateTime
};
}
/// <summary>
/// List&lt;IotDeviceEntity&gt; → List&lt;IotDeviceDto&gt;
/// </summary>
public static List<IotDeviceDto> ToDtoList(this List<IotDeviceEntity> entities)
{
return entities?.Select(e => e.ToDto()).ToList() ?? new List<IotDeviceDto>();
}
/// <summary>
/// IotDeviceDto → IotDeviceEntity(入参映射,IsDel/CreateTime/OnlineStatus 等服务端管控字段不映射)
/// </summary>
public static IotDeviceEntity ToEntity(this IotDeviceDto dto)
{
if (dto == null) return null;
return new IotDeviceEntity
{
Id = ParseId(dto.Id),
Code = dto.Code,
Name = dto.Name,
DeviceType = dto.DeviceType,
GatewayCode = dto.GatewayCode,
SlaveId = dto.SlaveId,
Manufacturer = dto.Manufacturer,
Description = dto.Description,
ProtocolType = dto.ProtocolType,
IsEnabled = dto.IsEnabled,
Remark = dto.Remark
};
}
#endregion
#region
/// <summary>
/// DeviceLogEntity → DeviceLogDto
/// </summary>
public static DeviceLogDto ToDto(this DeviceLogEntity entity)
{
if (entity == null) return null;
return new DeviceLogDto
{
Id = entity.Id.ToString(),
DeviceId = entity.DeviceId.ToString(),
DeviceCode = entity.DeviceCode,
Level = entity.Level,
LogType = entity.LogType,
Message = entity.Message,
LogTime = entity.LogTime,
CreateTime = entity.CreateTime
};
}
/// <summary>
/// List&lt;DeviceLogEntity&gt; → List&lt;DeviceLogDto&gt;
/// </summary>
public static List<DeviceLogDto> ToDtoList(this List<DeviceLogEntity> entities)
{
return entities?.Select(e => e.ToDto()).ToList() ?? new List<DeviceLogDto>();
}
#endregion
}
}