forked from ddrilling/AsbCloudServer
Merge branch 'dev' into feature/refactoring_well_operation
# Conflicts: # AsbCloudInfrastructure/Repository/WellOperationRepository.cs
This commit is contained in:
commit
42e4a205b2
@ -12,6 +12,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data.WellOperation;
|
||||
using AsbCloudInfrastructure.Services.DetectOperations.Detectors;
|
||||
using AsbCloudInfrastructure.Services.SAUB;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.DetectOperations;
|
||||
|
||||
@ -155,6 +156,8 @@ public class DetectedOperationService : IDetectedOperationService
|
||||
|
||||
var detectableTelemetries = (await telemetryDataSaubService.GetByTelemetryAsync(idTelemetry, request, token))
|
||||
.Where(t => t.BlockPosition >= 0)
|
||||
.Select(t => t as TelemetryNewDataSaubDto)
|
||||
.Where (t => t is not null)
|
||||
.Select(t => new DetectableTelemetry
|
||||
{
|
||||
DateTime = t.DateTime,
|
||||
@ -192,7 +195,9 @@ public class DetectedOperationService : IDetectedOperationService
|
||||
positionBegin += 1;
|
||||
}
|
||||
|
||||
beginDate = isDetected ? lastDetectedOperation!.DateEnd : detectableTelemetries[positionEnd].DateTime;
|
||||
beginDate = isDetected
|
||||
? lastDetectedOperation!.DateEnd
|
||||
: detectableTelemetries[positionEnd].DateTime;
|
||||
}
|
||||
|
||||
return detectedOperations;
|
||||
|
@ -64,6 +64,11 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
};
|
||||
var wellOperations = await wellOperationRepository
|
||||
.GetAsync(requestWellOperationFact, token);
|
||||
|
||||
var orderedWellOperations = wellOperations
|
||||
.OrderBy(operation => operation.DateStart)
|
||||
.ToArray();
|
||||
|
||||
if (!wellOperations.Any())
|
||||
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
||||
|
||||
@ -76,13 +81,14 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
||||
|
||||
var wellOperationCategories = wellOperationCategoryRepository.Get(false);
|
||||
|
||||
var wellSectionTypes = wellOperationRepository.GetSectionTypes();
|
||||
|
||||
var result = CalcByIntervals(
|
||||
request,
|
||||
processMapPlanWellDrillings,
|
||||
dataSaubStats,
|
||||
wellOperations,
|
||||
dataSaubStats,
|
||||
orderedWellOperations,
|
||||
wellOperationCategories,
|
||||
wellSectionTypes);
|
||||
|
||||
@ -101,8 +107,23 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
var list = new List<ProcessMapReportDataSaubStatDto>();
|
||||
var firstElemInInterval = dataSaubStats[0];
|
||||
|
||||
int GetSection(DataSaubStatDto data)
|
||||
=> wellOperations.MinBy(o => data.DateStart - o.DateStart)!.IdWellSectionType;
|
||||
var orderedWellOperations = wellOperations
|
||||
.OrderBy(o => o.DateStart)
|
||||
.ToArray();
|
||||
|
||||
var lastFoundIndex = 1;
|
||||
|
||||
int GetSection(DataSaubStatDto data)
|
||||
{
|
||||
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)
|
||||
=> processMapPlanWellDrillings
|
||||
@ -145,6 +166,7 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
.First();
|
||||
|
||||
var elem = CalcStat(processMapPlan, span, wellOperationCategoryName, wellSectionType);
|
||||
|
||||
if (elem is not null)
|
||||
list.Add(elem);
|
||||
}
|
||||
|
@ -16,6 +16,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudInfrastructure.Services.SAUB;
|
||||
|
||||
class TelemetryNewDataSaubDto : TelemetryDataSaubDto
|
||||
{
|
||||
public new DateTimeOffset DateTime { get; set; }
|
||||
}
|
||||
|
||||
public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSaubDto, TelemetryDataSaub>, ITelemetryDataSaubService
|
||||
{
|
||||
private readonly ITelemetryUserService telemetryUserService;
|
||||
@ -124,10 +129,10 @@ public class TelemetryDataSaubService : TelemetryDataBaseService<TelemetryDataSa
|
||||
|
||||
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);
|
||||
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
|
||||
? src.BitDepth
|
||||
: src.WellDepth;
|
||||
|
Loading…
Reference in New Issue
Block a user