保存iotdb增加地址信息和集中器地址
This commit is contained in:
parent
802e07f129
commit
15a66c1275
@ -222,6 +222,32 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
SingleMeasuring = (IotDbFieldConst.DatabaseBusiID, data.DatabaseBusiID)
|
||||
};
|
||||
await _dbProvider.GetSessionPool(false).InsertAsync(meterIsDatabaseBusiID);
|
||||
|
||||
// 表地址
|
||||
var meterAddress = new TreeModelSingleMeasuringEntity<string>()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DeviceType = $"{data.DeviceType}",
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
IoTDataType = analysisBaseDto.DataType,
|
||||
Timestamps = meter.Timestamps,
|
||||
SingleMeasuring = (IotDbFieldConst.MeterAddress, data.DeviceAddress)
|
||||
};
|
||||
await _dbProvider.GetSessionPool(false).InsertAsync(meterAddress);
|
||||
|
||||
// 集中器地址
|
||||
var focusAddress = new TreeModelSingleMeasuringEntity<string>()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DeviceType = $"{data.DeviceType}",
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
IoTDataType = analysisBaseDto.DataType,
|
||||
Timestamps = meter.Timestamps,
|
||||
SingleMeasuring = (IotDbFieldConst.FocusAddress, analysisBaseDto.Code)
|
||||
};
|
||||
await _dbProvider.GetSessionPool(false).InsertAsync(focusAddress);
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
@ -241,6 +267,9 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
List<TreeModelSingleMeasuringEntity<T>> treeModelSingleMeasuringEntities = new List<TreeModelSingleMeasuringEntity<T>>();
|
||||
List<TreeModelSingleMeasuringEntity<bool>> meterIsSyncs = new List<TreeModelSingleMeasuringEntity<bool>>();
|
||||
List<TreeModelSingleMeasuringEntity<int>> meterDataBaseIDs = new List<TreeModelSingleMeasuringEntity<int>>();
|
||||
List<TreeModelSingleMeasuringEntity<string>> meterAddresss = new List<TreeModelSingleMeasuringEntity<string>>();
|
||||
List<TreeModelSingleMeasuringEntity<string>> focusAddresss = new List<TreeModelSingleMeasuringEntity<string>>();
|
||||
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
@ -363,6 +392,34 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
if (!meterDataBaseIDs.Any(a => a.IoTDataType == meterIsSync.IoTDataType && a.ProjectId == meterIsSync.ProjectId && a.SystemName == meterIsSync.SystemName && a.DeviceId == meterIsSync.DeviceId && a.Timestamps == meterIsSync.Timestamps))
|
||||
meterDataBaseIDs.Add(meterIsDatabaseBusiID);
|
||||
|
||||
// 表地址
|
||||
var meterAddress = new TreeModelSingleMeasuringEntity<string>()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceId = $"{item.DeviceId}",
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
IoTDataType = analysisBaseDto.DataType,
|
||||
Timestamps = meter.Timestamps,
|
||||
SingleMeasuring = (IotDbFieldConst.MeterAddress, item.DeviceAddress)
|
||||
};
|
||||
if (!meterAddresss.Any(a => a.IoTDataType == meterAddress.IoTDataType && a.ProjectId == meterAddress.ProjectId && a.SystemName == meterAddress.SystemName && a.DeviceId == meterAddress.DeviceId && a.Timestamps == meterAddress.Timestamps))
|
||||
meterAddresss.Add(meterAddress);
|
||||
|
||||
// 集中器地址
|
||||
var focusAddress = new TreeModelSingleMeasuringEntity<string>()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceId = $"{item.DeviceId}",
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
IoTDataType = analysisBaseDto.DataType,
|
||||
Timestamps = meter.Timestamps,
|
||||
SingleMeasuring = (IotDbFieldConst.FocusAddress, analysisBaseDto.Code)
|
||||
};
|
||||
if (!focusAddresss.Any(a => a.IoTDataType == focusAddress.IoTDataType && a.ProjectId == focusAddress.ProjectId && a.SystemName == focusAddress.SystemName && a.DeviceId == focusAddress.DeviceId && a.Timestamps == focusAddress.Timestamps))
|
||||
focusAddresss.Add(focusAddress);
|
||||
|
||||
}
|
||||
}
|
||||
// 批量保存数据
|
||||
@ -374,7 +431,8 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
// 报存标识字段
|
||||
await _dbProvider.GetSessionPool(false).BatchInsertAsync(meterIsSyncs);
|
||||
await _dbProvider.GetSessionPool(false).BatchInsertAsync(meterDataBaseIDs);
|
||||
|
||||
await _dbProvider.GetSessionPool(false).BatchInsertAsync(meterAddresss);
|
||||
await _dbProvider.GetSessionPool(false).BatchInsertAsync(focusAddresss);
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
@ -410,6 +468,19 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
SingleMeasuring = (data.FiledName!, data.DataValue!)
|
||||
};
|
||||
await _dbProvider.GetSessionPool(false).InsertAsync(treeData);
|
||||
|
||||
var focusAddressData = new TreeModelSingleMeasuringEntity<T>()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceId = $"{data.DeviceId}",
|
||||
DeviceType = $"{data.DeviceType}",
|
||||
ProjectId = $"{data.ProjectId}",
|
||||
IoTDataType = IOTDBDataTypeConst.Status,
|
||||
Timestamps = timestamps,
|
||||
SingleMeasuring = (IotDbFieldConst.FocusAddress, data.DataValue!)
|
||||
};
|
||||
await _dbProvider.GetSessionPool(false).InsertAsync(focusAddressData);
|
||||
|
||||
// 数据帧
|
||||
var treeFrameData = new TreeModelSingleMeasuringEntity<string>()
|
||||
{
|
||||
@ -512,6 +583,20 @@ namespace JiShe.CollectBus.Protocol.T37612012.AnalysisData
|
||||
SingleMeasuring = (item.FiledName!, item.DataValue!)
|
||||
};
|
||||
await _dbProvider.GetSessionPool(false).InsertAsync(treeData);
|
||||
|
||||
|
||||
var focusAddressData = new TreeModelSingleMeasuringEntity<T>()
|
||||
{
|
||||
SystemName = _applicationOptions.SystemType,
|
||||
DeviceId = $"{item.DeviceId}",
|
||||
DeviceType = $"{item.DeviceType}",
|
||||
ProjectId = $"{item.ProjectId}",
|
||||
IoTDataType = IOTDBDataTypeConst.Status,
|
||||
Timestamps = timestamps,
|
||||
SingleMeasuring = (IotDbFieldConst.FocusAddress, item.DataValue!)
|
||||
};
|
||||
await _dbProvider.GetSessionPool(false).InsertAsync(focusAddressData);
|
||||
|
||||
// 数据帧
|
||||
var treeFrameData = new TreeModelSingleMeasuringEntity<string>()
|
||||
{
|
||||
|
||||
@ -80,15 +80,14 @@ namespace JiShe.CollectBus.Subscribers
|
||||
switch (input.MeterType)
|
||||
{
|
||||
case MeterTypeEnum.Ammeter:
|
||||
await SendArchivalDataIssued(input);
|
||||
tempResult = await SendArchivalDataIssued(input);
|
||||
break;
|
||||
case MeterTypeEnum.WaterMeter:
|
||||
|
||||
await SendArchivalDataIssued(input);
|
||||
tempResult = await SendArchivalDataIssued(input);
|
||||
break;
|
||||
}
|
||||
}
|
||||
//tempResult = await SendArchivalDataIssued(focusCacheInfo);
|
||||
}
|
||||
break;
|
||||
case ServiceCommunicationTypeEnum.SetItemCodeTask:
|
||||
@ -96,7 +95,7 @@ namespace JiShe.CollectBus.Subscribers
|
||||
SetItemCodeTaskInput? input = tempFirstKeyInfo.Value!.Deserialize<SetItemCodeTaskInput>();
|
||||
if(input != null)
|
||||
{
|
||||
await AutoCollectionItemsSetAsync(input);
|
||||
tempResult = await AutoCollectionItemsSetAsync(input);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -135,7 +134,7 @@ namespace JiShe.CollectBus.Subscribers
|
||||
Pn =deviceCacheInfo.MeteringCode,
|
||||
BaudRate = Build3761SendData.GetBaudreate($"{deviceCacheInfo.Baudrate}"),
|
||||
Port = deviceCacheInfo.MeteringPort,
|
||||
ProtocolType = deviceCacheInfo.Protocol.Value,
|
||||
ProtocolType = deviceCacheInfo.Protocol ?? 30,
|
||||
Address = deviceCacheInfo.MeterAddress,
|
||||
Password = deviceCacheInfo.Password,
|
||||
RateNumber = deviceCacheInfo.SingleRate == true ? 1 : 4,
|
||||
@ -151,6 +150,8 @@ namespace JiShe.CollectBus.Subscribers
|
||||
reqParameter = returnParameter;
|
||||
});
|
||||
|
||||
string frame = bytes.ToHexString();
|
||||
|
||||
// TODO: 需要插入iotdb 日志
|
||||
await SaveLogTodIotDbAsync(deviceCacheInfo, reqParameter);
|
||||
|
||||
|
||||
@ -210,6 +210,16 @@ namespace JiShe.CollectBus.Common.Consts
|
||||
/// </summary>
|
||||
public const string DatabaseBusiID= "DatabaseBusiID";
|
||||
|
||||
/// <summary>
|
||||
/// 集中器地址
|
||||
/// </summary>
|
||||
public const string FocusAddress = "FocusAddress";
|
||||
|
||||
/// <summary>
|
||||
/// 表地址
|
||||
/// </summary>
|
||||
public const string MeterAddress = "MeterAddress";
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user