forked from ddrilling/AsbCloudServer
Merge branch 'dev' into fix/shedule-report-template
This commit is contained in:
commit
29e0829bda
@ -15,10 +15,10 @@ namespace AsbCloudApp.Repositories
|
||||
/// добавить данные (для панели бурильщика)
|
||||
/// </summary>
|
||||
/// <param name="idTelemetry"></param>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task SaveDataAsync(int idTelemetry, WitsRecordDto dto, CancellationToken token);
|
||||
Task SaveDataAsync(int idTelemetry, IEnumerable<WitsRecordDto> dtos, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// получить данные для клиента
|
||||
|
@ -183,26 +183,30 @@ namespace AsbCloudInfrastructure.Repository
|
||||
return query;
|
||||
}
|
||||
|
||||
public async Task SaveDataAsync(int idTelemetry, WitsRecordDto dto, CancellationToken token)
|
||||
public async Task SaveDataAsync(int idTelemetry, IEnumerable<WitsRecordDto> dtos, CancellationToken token)
|
||||
{
|
||||
var timezoneHours = telemetryService.GetTimezone(idTelemetry).Hours;
|
||||
foreach (var item in dto.Items)
|
||||
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
var dateTime = dto.Date.ToUtcDateTimeOffset(timezoneHours);
|
||||
if (item.Value.Value is string valueString)
|
||||
foreach (var item in dto.Items)
|
||||
{
|
||||
var entity = MakeEntity<WitsItemString, string>(dto.Id, item.Key, idTelemetry, dateTime, valueString);
|
||||
db.WitsItemString.Add(entity);
|
||||
}
|
||||
if (item.Value.Value is float valueFloat)
|
||||
{
|
||||
var entity = MakeEntity<WitsItemFloat, float>(dto.Id, item.Key, idTelemetry, dateTime, valueFloat);
|
||||
db.WitsItemFloat.Add(entity);
|
||||
}
|
||||
if (item.Value.Value is int valueInt)
|
||||
{
|
||||
var entity = MakeEntity<WitsItemInt, int>(dto.Id, item.Key, idTelemetry, dateTime, valueInt);
|
||||
db.WitsItemInt.Add(entity);
|
||||
var dateTime = dto.Date.ToUtcDateTimeOffset(timezoneHours);
|
||||
if (item.Value.Value is string valueString)
|
||||
{
|
||||
var entity = MakeEntity<WitsItemString, string>(dto.Id, item.Key, idTelemetry, dateTime, valueString);
|
||||
db.WitsItemString.Add(entity);
|
||||
}
|
||||
if (item.Value.Value is float valueFloat)
|
||||
{
|
||||
var entity = MakeEntity<WitsItemFloat, float>(dto.Id, item.Key, idTelemetry, dateTime, valueFloat);
|
||||
db.WitsItemFloat.Add(entity);
|
||||
}
|
||||
if (item.Value.Value is int valueInt)
|
||||
{
|
||||
var entity = MakeEntity<WitsItemInt, int>(dto.Id, item.Key, idTelemetry, dateTime, valueInt);
|
||||
db.WitsItemInt.Add(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
await db.SaveChangesAsync(token);
|
||||
|
@ -100,21 +100,21 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
/// Сохраняет в БД.
|
||||
/// </summary>
|
||||
/// <param name="uid">уникальный идентификатор телеметрии</param>
|
||||
/// <param name="dto">WITS запись</param>
|
||||
/// <param name="dtos">WITS запись</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("{uid}")]
|
||||
public async Task<IActionResult> PostDataAsync(
|
||||
string uid,
|
||||
[FromBody] WitsRecordDto dto,
|
||||
[FromBody] IEnumerable<WitsRecordDto> dtos,
|
||||
CancellationToken token = default)
|
||||
{
|
||||
var idTelemetry = telemetryService.GetOrCreateTelemetryIdByUid(uid);
|
||||
await gtrRepository.SaveDataAsync(idTelemetry, dto, token).ConfigureAwait(false);
|
||||
await gtrRepository.SaveDataAsync(idTelemetry, dtos, token).ConfigureAwait(false);
|
||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||||
if (idWell is not null && dto is not null)
|
||||
if (idWell is not null && dtos is not null)
|
||||
_ = Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}_gtr")
|
||||
.SendAsync(SignalRMethodGetDataName, dto), CancellationToken.None);
|
||||
.SendAsync(SignalRMethodGetDataName, dtos), CancellationToken.None);
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user