测试IoTDB实体约束
This commit is contained in:
parent
cb6cfea4dd
commit
38283db1b2
@ -547,7 +547,7 @@ namespace JiShe.CollectBus.IoTDB.Provider
|
|||||||
|
|
||||||
if (entityTypeAttribute == null)
|
if (entityTypeAttribute == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentException($"{nameof(BuildDeviceMetadata)} 构建设备元数据时 {nameof(IoTEntity)}的EntityType 没有指定,属于异常情况,-101");
|
throw new ArgumentException($"{nameof(BuildDeviceMetadata)} 构建设备元数据时 {nameof(IoTEntity)} 的EntityType 没有指定,属于异常情况,-101");
|
||||||
}
|
}
|
||||||
|
|
||||||
metadata.EntityType = entityTypeAttribute.EntityType;
|
metadata.EntityType = entityTypeAttribute.EntityType;
|
||||||
|
|||||||
@ -68,7 +68,7 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
|
|||||||
messageHexString = messageHexString + timestamps;
|
messageHexString = messageHexString + timestamps;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElectricityMeter meter = new ElectricityMeter()
|
ElectricityMeterTreeModel meter = new ElectricityMeterTreeModel()
|
||||||
{
|
{
|
||||||
SystemName = "energy",
|
SystemName = "energy",
|
||||||
DeviceId = "402440506",
|
DeviceId = "402440506",
|
||||||
@ -90,7 +90,9 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task UseTableSessionPool()
|
public async Task UseTableSessionPool()
|
||||||
{
|
{
|
||||||
ElectricityMeter meter2 = new ElectricityMeter()
|
var testTime = Convert.ToDateTime("2025-04-21 08:35:55");
|
||||||
|
|
||||||
|
ElectricityMeterTreeModel meter2 = new ElectricityMeterTreeModel()
|
||||||
{
|
{
|
||||||
SystemName = "energy",
|
SystemName = "energy",
|
||||||
DeviceId = "402440506",
|
DeviceId = "402440506",
|
||||||
@ -99,13 +101,12 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
|
|||||||
MeterModel = "DDZY-1980",
|
MeterModel = "DDZY-1980",
|
||||||
ProjectCode = "10059",
|
ProjectCode = "10059",
|
||||||
Voltage = 10,
|
Voltage = 10,
|
||||||
Timestamps = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
Timestamps = new DateTimeOffset(testTime).ToUnixTimeMilliseconds(),
|
||||||
};
|
};
|
||||||
|
|
||||||
await _iotDBProvider.InsertAsync(meter2);
|
await _iotDBProvider.InsertAsync(meter2);
|
||||||
|
|
||||||
_dbContext.UseTableSessionPool = true;
|
_dbContext.UseTableSessionPool = true;
|
||||||
var testTime = Convert.ToDateTime("2025-04-21 08:32:55");
|
|
||||||
|
|
||||||
ElectricityMeter meter = new ElectricityMeter()
|
ElectricityMeter meter = new ElectricityMeter()
|
||||||
{
|
{
|
||||||
@ -119,6 +120,20 @@ public class SampleAppService : CollectBusAppService, ISampleAppService, IKafkaS
|
|||||||
Timestamps = new DateTimeOffset(testTime).ToUnixTimeMilliseconds(),
|
Timestamps = new DateTimeOffset(testTime).ToUnixTimeMilliseconds(),
|
||||||
};
|
};
|
||||||
await _iotDBProvider.InsertAsync(meter);
|
await _iotDBProvider.InsertAsync(meter);
|
||||||
|
|
||||||
|
ElectricityMeter meter3 = new ElectricityMeter()
|
||||||
|
{
|
||||||
|
SystemName = "energy",
|
||||||
|
DeviceId = "402440506",
|
||||||
|
DeviceType = "Ammeter",
|
||||||
|
Current = 10,
|
||||||
|
MeterModel = "DDZY-1980",
|
||||||
|
ProjectCode = "10059",
|
||||||
|
Voltage = 10,
|
||||||
|
Currentd = 22,
|
||||||
|
Timestamps = new DateTimeOffset(testTime).ToUnixTimeMilliseconds(),
|
||||||
|
};
|
||||||
|
await _iotDBProvider.InsertAsync(meter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -4,10 +4,12 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JiShe.CollectBus.IoTDB.Attribute;
|
using JiShe.CollectBus.IoTDB.Attribute;
|
||||||
|
using JiShe.CollectBus.IoTDB.Enums;
|
||||||
using JiShe.CollectBus.IoTDB.Provider;
|
using JiShe.CollectBus.IoTDB.Provider;
|
||||||
|
|
||||||
namespace JiShe.CollectBus.Ammeters
|
namespace JiShe.CollectBus.Ammeters
|
||||||
{
|
{
|
||||||
|
[EntityType(EntityTypeEnum.TableModel)]
|
||||||
public class ElectricityMeter : IoTEntity
|
public class ElectricityMeter : IoTEntity
|
||||||
{
|
{
|
||||||
[ATTRIBUTEColumn]
|
[ATTRIBUTEColumn]
|
||||||
|
|||||||
@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using JiShe.CollectBus.IoTDB.Attribute;
|
||||||
|
using JiShe.CollectBus.IoTDB.Enums;
|
||||||
|
using JiShe.CollectBus.IoTDB.Provider;
|
||||||
|
|
||||||
|
namespace JiShe.CollectBus.Ammeters
|
||||||
|
{
|
||||||
|
[EntityType(EntityTypeEnum.TreeModel)]
|
||||||
|
public class ElectricityMeterTreeModel : IoTEntity
|
||||||
|
{
|
||||||
|
[ATTRIBUTEColumn]
|
||||||
|
public string MeterModel { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 下发消息内容
|
||||||
|
/// </summary>
|
||||||
|
[FIELDColumn]
|
||||||
|
public string IssuedMessageHexString { get; set; }
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// 下发消息Id
|
||||||
|
///// </summary>
|
||||||
|
//[FIELDColumn]
|
||||||
|
//public string IssuedMessageId { get; set; }
|
||||||
|
|
||||||
|
[FIELDColumn]
|
||||||
|
public double Voltage { get; set; }
|
||||||
|
|
||||||
|
[FIELDColumn]
|
||||||
|
public double Current { get; set; }
|
||||||
|
|
||||||
|
[FIELDColumn]
|
||||||
|
public double Power => Voltage * Current;
|
||||||
|
|
||||||
|
[FIELDColumn]
|
||||||
|
public double? Currentd { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user