forked from ddrilling/AsbCloudServer
GetDepthIntervalSubsystem при АПД в роторе и слайде
This commit is contained in:
parent
e66f716e62
commit
19117d988f
@ -26,6 +26,8 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
private readonly ICrudRepository<SubsystemDto> subsystemService;
|
private readonly ICrudRepository<SubsystemDto> subsystemService;
|
||||||
private readonly IDetectedOperationService detectedOperationService;
|
private readonly IDetectedOperationService detectedOperationService;
|
||||||
public const int IdSubsystemAKB = 1;
|
public const int IdSubsystemAKB = 1;
|
||||||
|
public const int IdSubsystemAKBRotor = 11;
|
||||||
|
public const int IdSubsystemAKBSlide = 12;
|
||||||
public const int IdSubsystemMSE = 2;
|
public const int IdSubsystemMSE = 2;
|
||||||
public const int IdSubsystemSpin = 65536;
|
public const int IdSubsystemSpin = 65536;
|
||||||
public const int IdSubsystemTorque = 65537;
|
public const int IdSubsystemTorque = 65537;
|
||||||
@ -105,7 +107,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
return null;
|
return null;
|
||||||
var depthInterval = GetDepthInterval(detectedOperations);
|
var depthInterval = GetDepthInterval(detectedOperations);
|
||||||
|
|
||||||
var statList = CalcStat(data,depthInterval);
|
var statList = CalcStat(data,depthInterval, request);
|
||||||
return statList;
|
return statList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +159,10 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<SubsystemStatDto> CalcStat(IEnumerable<SubsystemOperationTimeDto> dtos, (double depthIntervalRotor, double depthIntervalSlide) depthInterval)
|
private IEnumerable<SubsystemStatDto> CalcStat(
|
||||||
|
IEnumerable<SubsystemOperationTimeDto> dtos,
|
||||||
|
(double depthIntervalRotor, double depthIntervalSlide) depthInterval,
|
||||||
|
SubsystemOperationTimeRequest? request = null)
|
||||||
{
|
{
|
||||||
var groupedDataSubsystems = dtos
|
var groupedDataSubsystems = dtos
|
||||||
.OrderBy(o => o.Id)
|
.OrderBy(o => o.Id)
|
||||||
@ -167,6 +172,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
var result = groupedDataSubsystems.Select(g =>
|
var result = groupedDataSubsystems.Select(g =>
|
||||||
{
|
{
|
||||||
var depthIntervalSubsystem = GetDepthIntervalSubsystem(g.Key, depthInterval);
|
var depthIntervalSubsystem = GetDepthIntervalSubsystem(g.Key, depthInterval);
|
||||||
|
//var depthIntervalSubsystem = CalcInterval(request?.GtDepth, request?.LtDepth, g);
|
||||||
var periodGroup = g.Sum(o => (o.DateEnd - o.DateStart).TotalHours);
|
var periodGroup = g.Sum(o => (o.DateEnd - o.DateStart).TotalHours);
|
||||||
var periodGroupDepth = g.Sum(o => o.DepthEnd - o.DepthStart);
|
var periodGroupDepth = g.Sum(o => o.DepthEnd - o.DepthStart);
|
||||||
var subsystemStat = new SubsystemStatDto()
|
var subsystemStat = new SubsystemStatDto()
|
||||||
@ -174,7 +180,10 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
IdSubsystem = g.Key,
|
IdSubsystem = g.Key,
|
||||||
SubsystemName = subsystemService.GetOrDefault(g.Key)?.Name ?? "unknown",
|
SubsystemName = subsystemService.GetOrDefault(g.Key)?.Name ?? "unknown",
|
||||||
UsedTimeHours = periodGroup,
|
UsedTimeHours = periodGroup,
|
||||||
|
//% использования = суммарная проходка АПД в слайде
|
||||||
|
/// суммарную проходку автоопределенных операций в слайде.
|
||||||
KUsage = periodGroupDepth / depthIntervalSubsystem,
|
KUsage = periodGroupDepth / depthIntervalSubsystem,
|
||||||
|
//KUsage = depthIntervalSubsystem / ((request?.LtDepth ?? 0) - (request?.GtDepth ?? 0)),
|
||||||
SumDepthInterval = periodGroupDepth,
|
SumDepthInterval = periodGroupDepth,
|
||||||
OperationCount = g.Count(),
|
OperationCount = g.Count(),
|
||||||
};
|
};
|
||||||
@ -191,7 +200,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
IdSubsystem = 1,
|
IdSubsystem = 1,
|
||||||
SubsystemName = "АПД",
|
SubsystemName = "АПД",
|
||||||
UsedTimeHours = apdParts.Sum(part => part.UsedTimeHours),
|
UsedTimeHours = apdParts.Sum(part => part.UsedTimeHours),
|
||||||
KUsage = apdParts.Sum(part => part.KUsage) / apdParts.Count(),
|
KUsage = apdParts.Sum(part => part.KUsage),
|
||||||
SumDepthInterval = apdParts.Sum(part => part.SumDepthInterval),
|
SumDepthInterval = apdParts.Sum(part => part.SumDepthInterval),
|
||||||
OperationCount = apdParts.Sum(part => part.OperationCount),
|
OperationCount = apdParts.Sum(part => part.OperationCount),
|
||||||
};
|
};
|
||||||
@ -200,6 +209,34 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double CalcInterval(double? gtDepth, double? ltDepth, IGrouping<int, SubsystemOperationTimeDto> g)
|
||||||
|
{
|
||||||
|
var operations = g.ToList();
|
||||||
|
double sum = 0;
|
||||||
|
foreach(var operation in operations)
|
||||||
|
{
|
||||||
|
var start = operation.DepthStart;
|
||||||
|
if(gtDepth.HasValue)
|
||||||
|
{
|
||||||
|
if (operation.DepthStart < gtDepth)
|
||||||
|
{
|
||||||
|
start = (double)gtDepth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var end = operation.DepthEnd;
|
||||||
|
if (ltDepth.HasValue)
|
||||||
|
{
|
||||||
|
if (operation.DepthEnd > ltDepth)
|
||||||
|
{
|
||||||
|
start = (double)ltDepth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sum += (end - start);
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
private static (double depthIntervalRotor, double depthIntervalSlide) GetDepthInterval (IEnumerable<DetectedOperationDto> detectedOperations)
|
private static (double depthIntervalRotor, double depthIntervalSlide) GetDepthInterval (IEnumerable<DetectedOperationDto> detectedOperations)
|
||||||
{
|
{
|
||||||
var depthIntervalRotor = detectedOperations.Where(o => o.IdCategory == WellOperationCategory.IdRotor)
|
var depthIntervalRotor = detectedOperations.Where(o => o.IdCategory == WellOperationCategory.IdRotor)
|
||||||
@ -218,6 +255,16 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
|||||||
{
|
{
|
||||||
depthIntervalSubsystem = depthInterval.depthIntervalRotor + depthInterval.depthIntervalSlide;
|
depthIntervalSubsystem = depthInterval.depthIntervalRotor + depthInterval.depthIntervalSlide;
|
||||||
}
|
}
|
||||||
|
//AKB - Rotor
|
||||||
|
if (idSubsystem == IdSubsystemAKBRotor)
|
||||||
|
{
|
||||||
|
depthIntervalSubsystem = depthInterval.depthIntervalRotor;
|
||||||
|
}
|
||||||
|
//AKB - Slide
|
||||||
|
if (idSubsystem == IdSubsystemAKBSlide)
|
||||||
|
{
|
||||||
|
depthIntervalSubsystem = depthInterval.depthIntervalSlide;
|
||||||
|
}
|
||||||
//Spin
|
//Spin
|
||||||
if (idSubsystem == IdSubsystemSpin)
|
if (idSubsystem == IdSubsystemSpin)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user