forked from ddrilling/AsbCloudServer
correction CalcStatAsync
This commit is contained in:
parent
6d4cfabc9a
commit
5672e0b149
@ -1,4 +1,5 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.DetectedOperation;
|
||||
using AsbCloudApp.Data.Subsystems;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
@ -113,17 +114,23 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
{
|
||||
var groupedDataSubsystems = dtos
|
||||
.GroupBy(o => o.IdSubsystem);
|
||||
|
||||
//var _detectOperations = await detectedOperationService.GetAsync(, token);
|
||||
|
||||
var detectedOperationsRequest = new DetectedOperationRequest()
|
||||
{
|
||||
IdWell = request.IdWell,
|
||||
IdsCategories = new List<int>() {
|
||||
1,3
|
||||
},
|
||||
LtDate = request.LtDate,
|
||||
GtDate = request.GtDate,
|
||||
};
|
||||
var detectedOperations = await detectedOperationService.GetAsync(detectedOperationsRequest, token);
|
||||
|
||||
var periodGroupTotal = dtos.Sum(o => (o.DateEnd - o.DateStart).TotalHours);
|
||||
|
||||
var gtDate = request.GtDate ?? dtos.Min(o => o.DateStart);
|
||||
var ltDate = request.LtDate ?? dtos.Max(o => o.DateEnd);
|
||||
|
||||
var detectedOperations = db.DetectedOperations
|
||||
.Where(a => a.DateStart >= gtDate & a.DateEnd <= ltDate)
|
||||
.ToList();
|
||||
|
||||
|
||||
var periodRequest = (ltDate - gtDate).TotalHours;
|
||||
|
||||
@ -131,7 +138,7 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
{
|
||||
var periodGroup = g.Sum(o => (o.DateEnd - o.DateStart).TotalHours);
|
||||
var periodGroupDepth = g.Sum(o => o.DepthEnd - o.DepthStart);
|
||||
var depthInterval = GetDepthInterval(g.Key, detectedOperations);
|
||||
var depthInterval = GetDepthInterval(g.Key, detectedOperations.Operations);
|
||||
var subsystemStat = new SubsystemStatDto()
|
||||
{
|
||||
IdSubsystem = g.Key,
|
||||
@ -146,9 +153,11 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
|
||||
return result;
|
||||
}
|
||||
private double GetDepthInterval (int idSubsystem, List<DetectedOperation> detectedOperations)
|
||||
private double GetDepthInterval (int idSubsystem, IEnumerable<DetectedOperationDto>? detectedOperations)
|
||||
{
|
||||
var depthIntervalRotor = detectedOperations.Where(o => o.IdCategory == 3)
|
||||
if (detectedOperations is null)
|
||||
return 0;
|
||||
var depthIntervalRotor = detectedOperations.Where(o => o.IdCategory == 1)
|
||||
.Sum(o => o.DepthEnd - o.DepthStart);
|
||||
var depthIntervalSlide = detectedOperations.Where(o => o.IdCategory == 3)
|
||||
.Sum(o => o.DepthEnd - o.DepthStart);
|
||||
@ -157,12 +166,12 @@ namespace AsbCloudInfrastructure.Services.Subsystems
|
||||
{
|
||||
return depthIntervalRotor + depthIntervalSlide;
|
||||
}
|
||||
//Slide
|
||||
//Spin
|
||||
if (idSubsystem == 65536)
|
||||
{
|
||||
return depthIntervalSlide;
|
||||
}
|
||||
//Rotor
|
||||
//Torque
|
||||
if (idSubsystem == 65537)
|
||||
{
|
||||
return depthIntervalRotor;
|
||||
|
Loading…
Reference in New Issue
Block a user