71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using JiShe.CollectBus.Common.Attributes;
|
||
using JiShe.CollectBus.Common.Consts;
|
||
using JiShe.CollectBus.IoTDB.Attributes;
|
||
using Volo.Abp.Domain.Entities;
|
||
|
||
namespace JiShe.CollectBus.IoTDB.Model
|
||
{
|
||
/// <summary>
|
||
/// IoT实体基类,此类适用于多个数据测点记录场景,单个测点请使用子类 SingleMeasuring,新增字段只能现有字段末尾添加,否则会导致数据写入失败。
|
||
/// </summary>
|
||
public abstract class IoTEntity
|
||
{
|
||
/// <summary>
|
||
/// 系统名称
|
||
/// </summary>
|
||
[TAGColumn]
|
||
public string SystemName { get; set; }
|
||
|
||
/// <summary>
|
||
/// 项目编码
|
||
/// </summary>
|
||
[TAGColumn]
|
||
public string ProjectId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 数据类型
|
||
/// </summary>
|
||
[TAGColumn]
|
||
public string DataType { get; set; } = IOTDBDataTypeConst.Data;
|
||
|
||
/// <summary>
|
||
/// 设备类型集中器、电表、水表、流量计、传感器等
|
||
/// </summary>
|
||
[TAGColumn]
|
||
public string DeviceType { get; set; }
|
||
|
||
/// <summary>
|
||
/// 设备ID,数据生成者,例如集中器ID,电表ID、水表ID、流量计ID、传感器ID等
|
||
/// </summary>
|
||
[TAGColumn]
|
||
public string DeviceId { get; set; }
|
||
|
||
/// <summary>
|
||
/// 时标,也就是业务时间戳,单位毫秒,必须通过DateTimeOffset获取
|
||
/// </summary>
|
||
public long Timestamps { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||
|
||
/// <summary>
|
||
/// 设备路径
|
||
/// </summary>
|
||
public virtual string DevicePath
|
||
{
|
||
get
|
||
{
|
||
return $"root.{SystemName.ToLower()}.`{ProjectId}`.`{DeviceType}`.{DataType}.`{DeviceId}`";
|
||
}
|
||
set
|
||
{
|
||
if (string.IsNullOrWhiteSpace(value))
|
||
{
|
||
DevicePath = $"root.{SystemName.ToLower()}.`{ProjectId}`.`{DeviceType}`.{DataType}.`{DeviceId}`";
|
||
}
|
||
else
|
||
{
|
||
DevicePath = value;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|