73 lines
2.2 KiB
C#
Raw Normal View History

2025-04-28 16:37:31 +08:00
using JiShe.CollectBus.Common.Attributes;
using JiShe.CollectBus.Common.Consts;
using JiShe.CollectBus.IoTDB.Attributes;
using Volo.Abp.Domain.Entities;
2025-04-17 20:28:50 +08:00
2025-04-21 14:20:49 +08:00
namespace JiShe.CollectBus.IoTDB.Model
2025-04-02 17:23:52 +08:00
{
/// <summary>
2025-04-28 16:37:31 +08:00
/// IoT实体基类此类适用于多个数据测点记录场景单个测点请使用子类 SingleMeasuring新增字段只能现有字段末尾添加否则会导致数据写入失败。
2025-04-02 17:23:52 +08:00
/// </summary>
public abstract class IoTEntity
{
/// <summary>
/// 系统名称
/// </summary>
[TAGColumn]
2025-04-23 11:13:59 +08:00
public string SystemName { get; set; }
2025-04-02 17:23:52 +08:00
/// <summary>
/// 项目编码
/// </summary>
2025-04-23 11:13:59 +08:00
[TAGColumn]
public string ProjectId { get; set; }
2025-04-02 17:23:52 +08:00
/// <summary>
/// 数据类型
/// </summary>
[TAGColumn]
public string DataType { get; set; } = IOTDBDataTypeConst.Data;
2025-04-02 17:23:52 +08:00
/// <summary>
/// 设备类型集中器、电表、水表、流量计、传感器等
/// </summary>
2025-04-23 11:13:59 +08:00
[TAGColumn]
public string DeviceType { get; set; }
2025-04-02 17:23:52 +08:00
/// <summary>
2025-04-23 11:13:59 +08:00
/// 设备ID,数据生成者例如集中器ID,电表ID、水表ID、流量计ID、传感器ID等
2025-04-02 17:23:52 +08:00
/// </summary>
[TAGColumn]
2025-04-23 11:13:59 +08:00
public string DeviceId { get; set; }
2025-04-02 17:23:52 +08:00
/// <summary>
/// 时标,也就是业务时间戳,单位毫秒,必须通过DateTimeOffset获取
2025-04-02 17:23:52 +08:00
/// </summary>
2025-04-23 11:13:59 +08:00
public long Timestamps { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
/// <summary>
/// 设备路径
/// </summary>
private string _devicePath;
/// <summary>
/// 设备路径
/// </summary>
public virtual string DevicePath
{
get
{
// 如果未手动设置路径,则自动生成
if (string.IsNullOrWhiteSpace(_devicePath))
{
return $"root.{SystemName.ToLower()}.`{ProjectId}`.`{DeviceType}`.{DataType}.`{DeviceId}`";
}
return _devicePath;
}
set
{
_devicePath = value; // 直接赋值给支持字段,避免递归
}
}
2025-04-02 17:23:52 +08:00
}
}