diff --git a/AsbCloudApp/Data/StatCriticalMessageDto.cs b/AsbCloudApp/Data/StatCriticalMessageDto.cs
index e8640ab6..8595934a 100644
--- a/AsbCloudApp/Data/StatCriticalMessageDto.cs
+++ b/AsbCloudApp/Data/StatCriticalMessageDto.cs
@@ -7,9 +7,9 @@ namespace AsbCloudApp.Data;
public class StatCriticalMessageDto
{
///
- /// ключ телеметрии
+ /// ключ скважины
///
- public int IdTelemetry { get; set; }
+ public int IdWell { get; set; }
///
/// ключ категории
diff --git a/AsbCloudApp/Requests/MessageRequest.cs b/AsbCloudApp/Requests/MessageRequest.cs
index 413b9091..f11f6290 100644
--- a/AsbCloudApp/Requests/MessageRequest.cs
+++ b/AsbCloudApp/Requests/MessageRequest.cs
@@ -92,13 +92,13 @@ public class MessageTelemetryRequest : MessageRequestBase
///
/// телеметрии
///
- public IEnumerable Telemetries { get; set; } = Enumerable.Empty();
+ public IEnumerable Telemetries { get; set; } = Enumerable.Empty();
///
public MessageTelemetryRequest(
MessageRequestBase request,
IEnumerable events,
- IEnumerable telemetries) : base(request)
+ IEnumerable telemetries) : base(request)
{
Events = events;
Telemetries = telemetries;
diff --git a/AsbCloudApp/Services/ITelemetryService.cs b/AsbCloudApp/Services/ITelemetryService.cs
index 02f93461..fa6c88f4 100644
--- a/AsbCloudApp/Services/ITelemetryService.cs
+++ b/AsbCloudApp/Services/ITelemetryService.cs
@@ -52,7 +52,7 @@ public interface ITelemetryService
///
/// ключи скважин
///
- IEnumerable GetOrDefaultTelemetriesByIdsWells(IEnumerable idsWells);
+ IEnumerable GetOrDefaultTelemetriesByIdsWells(IEnumerable idsWells);
///
/// получить диапазон дат за которые есть данные
///
diff --git a/AsbCloudInfrastructure.Tests/Services/MessageServiceTest.cs b/AsbCloudInfrastructure.Tests/Services/MessageServiceTest.cs
index 8cb94ca5..f3bc4bf3 100644
--- a/AsbCloudInfrastructure.Tests/Services/MessageServiceTest.cs
+++ b/AsbCloudInfrastructure.Tests/Services/MessageServiceTest.cs
@@ -17,19 +17,21 @@ namespace AsbCloudInfrastructure.Tests.Services;
public class MessageServiceTest
{
- private static readonly List telemetries = new List()
+ private static readonly List telemetries = new List()
{
- new TelemetryBaseDto()
+ new TelemetryDto()
{
Id = 1,
+ IdWell = 1,
TimeZone = new SimpleTimezoneDto()
{
Hours = 5
}
},
- new TelemetryBaseDto()
+ new TelemetryDto()
{
Id = 2,
+ IdWell = 2,
TimeZone = new SimpleTimezoneDto()
{
Hours = 5
@@ -243,47 +245,47 @@ public class MessageServiceTest
Assert.Equal(6, result.Count());
- var сообщение_1_1 = result
- .Where(x => x.IdTelemetry == 1)
+ var messageStat_1_1 = result
+ .Where(x => x.IdWell == 1)
.Where(x => x.IdCategory == 1)
.Where(x => x.MessageTemplate == "Шаблон сообщения 1 категории 1")
.Single();
- Assert.Equal(3, сообщение_1_1.MessagesCount);
+ Assert.Equal(3, messageStat_1_1.MessagesCount);
- var сообщение_1_2 = result
- .Where(x => x.IdTelemetry == 1)
+ var messageStat_1_2 = result
+ .Where(x => x.IdWell == 1)
.Where(x => x.IdCategory == 1)
.Where(x => x.MessageTemplate == "Шаблон сообщения 2 категории 1")
.Single();
- Assert.Equal(3, сообщение_1_2.MessagesCount);
+ Assert.Equal(3, messageStat_1_2.MessagesCount);
- var сообщение_1_3 = result
- .Where(x => x.IdTelemetry == 1)
+ var messageStat_1_3 = result
+ .Where(x => x.IdWell == 1)
.Where(x => x.IdCategory == 1)
.Where(x => x.MessageTemplate == "Шаблон сообщения 3 категории 1")
.Single();
- Assert.Equal(3, сообщение_1_3.MessagesCount);
+ Assert.Equal(3, messageStat_1_3.MessagesCount);
- var сообщение_2_2 = result
- .Where(x => x.IdTelemetry == 1)
+ var messageStat_2_2 = result
+ .Where(x => x.IdWell == 1)
.Where(x => x.IdCategory == 2)
.Where(x => x.MessageTemplate == "Шаблон сообщения 2 категории 2")
.Single();
- Assert.Equal(2, сообщение_2_2.MessagesCount);
+ Assert.Equal(2, messageStat_2_2.MessagesCount);
- var сообщение_2_1 = result
- .Where(x => x.IdTelemetry == 1)
+ var messageStat_2_1 = result
+ .Where(x => x.IdWell == 1)
.Where(x => x.IdCategory == 2)
.Where(x => x.MessageTemplate == "Шаблон сообщения 1 категории 2")
.Single();
- Assert.Equal(2, сообщение_2_1.MessagesCount);
+ Assert.Equal(2, messageStat_2_1.MessagesCount);
- var сообщение_3_1 = result
- .Where(x => x.IdTelemetry == 2)
+ var messageStat_3_1 = result
+ .Where(x => x.IdWell == 2)
.Where(x => x.IdCategory == 3)
.Where(x => x.MessageTemplate == "Шаблон сообщения 1 категории 3")
.Single();
- Assert.Equal(3, сообщение_3_1.MessagesCount);
+ Assert.Equal(3, messageStat_3_1.MessagesCount);
}
diff --git a/AsbCloudInfrastructure/Services/MessageService.cs b/AsbCloudInfrastructure/Services/MessageService.cs
index 24d703c1..e4a5b333 100644
--- a/AsbCloudInfrastructure/Services/MessageService.cs
+++ b/AsbCloudInfrastructure/Services/MessageService.cs
@@ -45,20 +45,23 @@ public class MessageService : IMessageService
var groupedMessages = telemetryMessages.GroupBy(x => new { x.IdTelemetry, x.IdEvent });
var events = messageTelemetryRequest.Events.ToDictionary(e => e.Id);
+ var idsWellsDict = messageTelemetryRequest.Telemetries.ToDictionary(e => e.Id, e => e.IdWell);
+
var result = groupedMessages
.Select(m => new
{
- m.Key.IdTelemetry,
+ IdWell = idsWellsDict.GetValueOrDefault(m.Key.IdTelemetry),
events.GetValueOrDefault(m.Key.IdEvent)?.IdCategory,
events.GetValueOrDefault(m.Key.IdEvent)?.MessageTemplate,
- Count = m.Count()
+ Count = m.Count(),
})
.Where(m => m.IdCategory != null)
+ .Where(m => m.IdWell != null)
.Where(m => m.MessageTemplate != null)
- .GroupBy(m => new { m.IdTelemetry, m.IdCategory, m.MessageTemplate })
+ .GroupBy(m => new { m.IdWell, m.IdCategory, m.MessageTemplate })
.Select(m => new StatCriticalMessageDto()
{
- IdTelemetry = m.Key.IdTelemetry,
+ IdWell = m.First().IdWell!.Value,
IdCategory = m.Key.IdCategory,
MessageTemplate = m.Key.MessageTemplate,
MessagesCount = m.Select(z => z.Count).Sum()
diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs
index 521fd8dd..a501f37c 100644
--- a/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs
+++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryService.cs
@@ -150,7 +150,7 @@ public class TelemetryService : ITelemetryService
return dto;
}
- public IEnumerable GetOrDefaultTelemetriesByIdsWells(IEnumerable idsWells)
+ public IEnumerable GetOrDefaultTelemetriesByIdsWells(IEnumerable idsWells)
{
var entities = GetTelemetryCache()
.Where(t => t.Well != null)
@@ -162,7 +162,12 @@ public class TelemetryService : ITelemetryService
});
- var dtos = entities.Select(t => t.Adapt());
+ var dtos = entities.Select(t => {
+ var dto = t.Adapt();
+ dto.IdWell = t.Well?.Id;
+
+ return dto;
+ });
return dtos;
}