Merge branch 'dev' into feature/refactoring_well_operation

# Conflicts:
#	AsbCloudInfrastructure/Repository/WellOperationRepository.cs
This commit is contained in:
Степанов Дмитрий 2024-03-29 07:42:48 +03:00
commit 42e4a205b2
3 changed files with 39 additions and 7 deletions

View File

@ -12,6 +12,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsbCloudApp.Data.WellOperation; using AsbCloudApp.Data.WellOperation;
using AsbCloudInfrastructure.Services.DetectOperations.Detectors; using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
using AsbCloudInfrastructure.Services.SAUB;
namespace AsbCloudInfrastructure.Services.DetectOperations; namespace AsbCloudInfrastructure.Services.DetectOperations;
@ -155,6 +156,8 @@ public class DetectedOperationService : IDetectedOperationService
var detectableTelemetries = (await telemetryDataSaubService.GetByTelemetryAsync(idTelemetry, request, token)) var detectableTelemetries = (await telemetryDataSaubService.GetByTelemetryAsync(idTelemetry, request, token))
.Where(t => t.BlockPosition >= 0) .Where(t => t.BlockPosition >= 0)
.Select(t => t as TelemetryNewDataSaubDto)
.Where (t => t is not null)
.Select(t => new DetectableTelemetry .Select(t => new DetectableTelemetry
{ {
DateTime = t.DateTime, DateTime = t.DateTime,
@ -192,7 +195,9 @@ public class DetectedOperationService : IDetectedOperationService
positionBegin += 1; positionBegin += 1;
} }
beginDate = isDetected ? lastDetectedOperation!.DateEnd : detectableTelemetries[positionEnd].DateTime; beginDate = isDetected
? lastDetectedOperation!.DateEnd
: detectableTelemetries[positionEnd].DateTime;
} }
return detectedOperations; return detectedOperations;

View File

@ -64,6 +64,11 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
}; };
var wellOperations = await wellOperationRepository var wellOperations = await wellOperationRepository
.GetAsync(requestWellOperationFact, token); .GetAsync(requestWellOperationFact, token);
var orderedWellOperations = wellOperations
.OrderBy(operation => operation.DateStart)
.ToArray();
if (!wellOperations.Any()) if (!wellOperations.Any())
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>(); return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
@ -76,13 +81,14 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>(); return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
var wellOperationCategories = wellOperationCategoryRepository.Get(false); var wellOperationCategories = wellOperationCategoryRepository.Get(false);
var wellSectionTypes = wellOperationRepository.GetSectionTypes(); var wellSectionTypes = wellOperationRepository.GetSectionTypes();
var result = CalcByIntervals( var result = CalcByIntervals(
request, request,
processMapPlanWellDrillings, processMapPlanWellDrillings,
dataSaubStats, dataSaubStats,
wellOperations, orderedWellOperations,
wellOperationCategories, wellOperationCategories,
wellSectionTypes); wellSectionTypes);
@ -101,8 +107,23 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
var list = new List<ProcessMapReportDataSaubStatDto>(); var list = new List<ProcessMapReportDataSaubStatDto>();
var firstElemInInterval = dataSaubStats[0]; var firstElemInInterval = dataSaubStats[0];
var orderedWellOperations = wellOperations
.OrderBy(o => o.DateStart)
.ToArray();
var lastFoundIndex = 1;
int GetSection(DataSaubStatDto data) int GetSection(DataSaubStatDto data)
=> wellOperations.MinBy(o => data.DateStart - o.DateStart)!.IdWellSectionType; {
if(lastFoundIndex < orderedWellOperations.Length - 1)
{
lastFoundIndex = Array.FindIndex(orderedWellOperations, lastFoundIndex, o => o.DateStart > data.DateStart) - 1;
lastFoundIndex = lastFoundIndex < 0 ? orderedWellOperations.Length - 1 : lastFoundIndex;
}
var operation = orderedWellOperations[lastFoundIndex];
return operation.IdWellSectionType;
}
ProcessMapPlanDrillingDto? GetProcessMapPlan(int idWellSectionType, DataSaubStatDto data) ProcessMapPlanDrillingDto? GetProcessMapPlan(int idWellSectionType, DataSaubStatDto data)
=> processMapPlanWellDrillings => processMapPlanWellDrillings
@ -145,6 +166,7 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
.First(); .First();
var elem = CalcStat(processMapPlan, span, wellOperationCategoryName, wellSectionType); var elem = CalcStat(processMapPlan, span, wellOperationCategoryName, wellSectionType);
if (elem is not null) if (elem is not null)
list.Add(elem); list.Add(elem);
} }

View File

@ -16,6 +16,11 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.SAUB; namespace AsbCloudInfrastructure.Services.SAUB;
class TelemetryNewDataSaubDto : TelemetryDataSaubDto
{
public new DateTimeOffset DateTime { get; set; }
}
public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>, ITelemetryDataSaubService public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>, ITelemetryDataSaubService
{ {
private readonly ITelemetryUserService telemetryUserService; private readonly ITelemetryUserService telemetryUserService;
@ -124,10 +129,10 @@ public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSa
protected override TelemetryDataSaubDto Convert(TelemetryDataSaub src, double timezoneOffset) protected override TelemetryDataSaubDto Convert(TelemetryDataSaub src, double timezoneOffset)
{ {
var dto = src.Adapt<TelemetryDataSaubDto>(); var dto = src.Adapt<TelemetryNewDataSaubDto>();
var telemetryUser = telemetryUserService.GetOrDefault(src.IdTelemetry, src.IdUser ?? int.MinValue); var telemetryUser = telemetryUserService.GetOrDefault(src.IdTelemetry, src.IdUser ?? int.MinValue);
dto.User = telemetryUser?.MakeDisplayName(); dto.User = telemetryUser?.MakeDisplayName();
dto.DateTime = src.DateTime.ToRemoteDateTime(timezoneOffset); dto.DateTime = src.DateTime.ToOffset(TimeSpan.FromHours(timezoneOffset)); // src.DateTime.ToRemoteDateTime(timezoneOffset);
dto.BitDepth = src.BitDepth <= src.WellDepth dto.BitDepth = src.BitDepth <= src.WellDepth
? src.BitDepth ? src.BitDepth
: src.WellDepth; : src.WellDepth;