forked from ddrilling/AsbCloudServer
parent
577b699663
commit
312d653aec
@ -16,7 +16,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<ClusterRopStatDto> GetRopStatAsync(int idWell, CancellationToken token);
|
Task<ClusterRopStatDto?> GetOrDefaultRopStatAsync(int idWell, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить статистику по скважинам куста, которые доступны компании
|
/// Получить статистику по скважинам куста, которые доступны компании
|
||||||
@ -25,7 +25,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="idCompany"></param>
|
/// <param name="idCompany"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<StatClusterDto> GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default);
|
Task<StatClusterDto?> GetOrDefaultStatClusterAsync(int idCluster, int idCompany, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// получить статистику по скважине
|
/// получить статистику по скважине
|
||||||
@ -33,7 +33,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<StatWellDto> GetWellStatAsync(int idWell, CancellationToken token = default);
|
Task<StatWellDto?> GetOrDefaultWellStatAsync(int idWell, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить данные для графика TVD
|
/// Получить данные для графика TVD
|
||||||
|
@ -43,7 +43,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
.Where(t => t.BlockPosition > 0.0001)
|
.Where(t => t.BlockPosition > 0.0001)
|
||||||
.Where(t => t.WellDepth > 0.0001)
|
.Where(t => t.WellDepth > 0.0001)
|
||||||
.Where(t => t.Mode != null)
|
.Where(t => t.Mode != null)
|
||||||
.Where(t => modes.Contains(t.Mode.Value))
|
.Where(t => modes.Contains(t.Mode!.Value))
|
||||||
.Where(t => t.WellDepth - t.BitDepth < 0.01)
|
.Where(t => t.WellDepth - t.BitDepth < 0.01)
|
||||||
.GroupBy(t => new {
|
.GroupBy(t => new {
|
||||||
t.DateTime.Hour,
|
t.DateTime.Hour,
|
||||||
|
@ -7,12 +7,12 @@ using Microsoft.Extensions.Caching.Memory;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.WellOperationService
|
namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
public class OperationsStatService : IOperationsStatService
|
public class OperationsStatService : IOperationsStatService
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext db;
|
private readonly IAsbCloudDbContext db;
|
||||||
@ -26,8 +26,15 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<StatClusterDto> GetStatClusterAsync(int idCluster, int idCompany, CancellationToken token = default)
|
public async Task<StatClusterDto?> GetOrDefaultStatClusterAsync(int idCluster, int idCompany, CancellationToken token)
|
||||||
{
|
{
|
||||||
|
var cluster = (await memoryCache
|
||||||
|
.GetOrCreateBasicAsync(db.Set<Cluster>(), token))
|
||||||
|
.FirstOrDefault(c => c.Id == idCluster);
|
||||||
|
|
||||||
|
if (cluster is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
var allWellsByCompany = await wellService.GetAsync(new() { IdCompany = idCompany }, token).ConfigureAwait(false);
|
var allWellsByCompany = await wellService.GetAsync(new() { IdCompany = idCompany }, token).ConfigureAwait(false);
|
||||||
|
|
||||||
var idWellsByCompany = allWellsByCompany.Select(w => w.Id).Distinct();
|
var idWellsByCompany = allWellsByCompany.Select(w => w.Id).Distinct();
|
||||||
@ -41,9 +48,6 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
|
|
||||||
var statsWells = await GetWellsStatAsync(wells, token).ConfigureAwait(false);
|
var statsWells = await GetWellsStatAsync(wells, token).ConfigureAwait(false);
|
||||||
|
|
||||||
var cluster = (await memoryCache
|
|
||||||
.GetOrCreateBasicAsync(db.Set<Cluster>(), token))
|
|
||||||
.FirstOrDefault(c => c.Id == idCluster);
|
|
||||||
var statClusterDto = new StatClusterDto
|
var statClusterDto = new StatClusterDto
|
||||||
{
|
{
|
||||||
Id = idCluster,
|
Id = idCluster,
|
||||||
@ -71,7 +75,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
return statsWells;
|
return statsWells;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<StatWellDto> GetWellStatAsync(int idWell,
|
public async Task<StatWellDto?> GetOrDefaultWellStatAsync(int idWell,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var well = await db.Wells
|
var well = await db.Wells
|
||||||
@ -79,11 +83,14 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
.FirstOrDefaultAsync(w => w.Id == idWell, token)
|
.FirstOrDefaultAsync(w => w.Id == idWell, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
if(well is null)
|
||||||
|
return null;
|
||||||
|
|
||||||
var statWellDto = await CalcWellStatAsync(well, token);
|
var statWellDto = await CalcWellStatAsync(well, token);
|
||||||
return statWellDto;
|
return statWellDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ClusterRopStatDto> GetRopStatAsync(int idWell, CancellationToken token)
|
public async Task<ClusterRopStatDto?> GetOrDefaultRopStatAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var clusterWellsIds = await wellService.GetClusterWellsIdsAsync(idWell, token)
|
var clusterWellsIds = await wellService.GetClusterWellsIdsAsync(idWell, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
@ -110,13 +117,15 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
.ToListAsync(token)
|
.ToListAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var statsList = clusterWellsIds.Select(clusterWellId =>
|
var statsList = new List<StatOperationsDto>(clusterWellsIds.Count());
|
||||||
|
foreach (var clusterWellId in clusterWellsIds)
|
||||||
{
|
{
|
||||||
var currentWellOps = operations.Where(o => o.IdWell == clusterWellId);
|
var currentWellOps = operations.Where(o => o.IdWell == clusterWellId);
|
||||||
var timezoneOffsetH = wellService.GetTimezone(clusterWellId).Hours;
|
var timezoneOffsetHours = wellService.GetTimezone(clusterWellId).Hours;
|
||||||
var stat = CalcStat(currentWellOps, timezoneOffsetH);
|
var stat = CalcStat(currentWellOps, timezoneOffsetHours);
|
||||||
return stat;
|
if(stat is not null)
|
||||||
}).Where(c => c is not null);
|
statsList.Add(stat);
|
||||||
|
};
|
||||||
|
|
||||||
if (!statsList.Any())
|
if (!statsList.Any())
|
||||||
return null;
|
return null;
|
||||||
@ -130,7 +139,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
return clusterRops;
|
return clusterRops;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<StatWellDto> CalcWellStatAsync(Well well, CancellationToken token = default)
|
private async Task<StatWellDto> CalcWellStatAsync(Well well, CancellationToken token)
|
||||||
{
|
{
|
||||||
var wellType = (await memoryCache
|
var wellType = (await memoryCache
|
||||||
.GetOrCreateBasicAsync(db.Set<WellType>(), token))
|
.GetOrCreateBasicAsync(db.Set<WellType>(), token))
|
||||||
@ -164,7 +173,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
return statWellDto;
|
return statWellDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double CalcTvdLagDays(IOrderedEnumerable<WellOperation> wellOperations)
|
private static double CalcTvdLagDays(IOrderedEnumerable<WellOperation> wellOperations)
|
||||||
{
|
{
|
||||||
var operationsOrdered = wellOperations
|
var operationsOrdered = wellOperations
|
||||||
.OrderBy(o => o.DateStart);
|
.OrderBy(o => o.DateStart);
|
||||||
@ -178,9 +187,13 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
if (lastCorrespondingFactOperation is null)
|
if (lastCorrespondingFactOperation is null)
|
||||||
return 0d;
|
return 0d;
|
||||||
|
|
||||||
var lastCorrespondingPlanOperation = wellOperations.FirstOrDefault(o => o.Id == lastCorrespondingFactOperation.IdPlan);
|
var lastCorrespondingPlanOperation = wellOperations
|
||||||
|
.FirstOrDefault(o => o.Id == lastCorrespondingFactOperation.IdPlan);
|
||||||
|
|
||||||
var lastFactOperation = factOperations.LastOrDefault();
|
if (lastCorrespondingPlanOperation is null)
|
||||||
|
return 0d;
|
||||||
|
|
||||||
|
var lastFactOperation = factOperations.Last();
|
||||||
|
|
||||||
var remainingPlanOperations = operationsOrdered
|
var remainingPlanOperations = operationsOrdered
|
||||||
.Where(o => o.IdType == WellOperation.IdOperationTypePlan)
|
.Where(o => o.IdType == WellOperation.IdOperationTypePlan)
|
||||||
@ -240,27 +253,27 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
return section;
|
return section;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StatOperationsDto CalcSectionStat(IEnumerable<WellOperation> operations, int idSectionType, double timezoneOffsetH)
|
private static StatOperationsDto? CalcSectionStat(IEnumerable<WellOperation> operations, int idSectionType, double timezoneOffsetHours)
|
||||||
{
|
{
|
||||||
var sectionOperations = operations
|
var sectionOperations = operations
|
||||||
.Where(o => o.IdWellSectionType == idSectionType)
|
.Where(o => o.IdWellSectionType == idSectionType)
|
||||||
.OrderBy(o => o.DateStart)
|
.OrderBy(o => o.DateStart)
|
||||||
.ThenBy(o => o.DepthStart);
|
.ThenBy(o => o.DepthStart);
|
||||||
|
|
||||||
return CalcStat(sectionOperations, timezoneOffsetH);
|
return CalcStat(sectionOperations, timezoneOffsetHours);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StatOperationsDto CalcStat(IEnumerable<WellOperation> operations, double timezoneOffsetH)
|
private static StatOperationsDto? CalcStat(IEnumerable<WellOperation> operations, double timezoneOffsetHours)
|
||||||
{
|
{
|
||||||
if (!operations.Any())
|
if (!operations.Any())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var races = GetCompleteRaces(operations, timezoneOffsetH);
|
var races = GetCompleteRaces(operations, timezoneOffsetHours);
|
||||||
|
|
||||||
var section = new StatOperationsDto
|
var section = new StatOperationsDto
|
||||||
{
|
{
|
||||||
Start = operations.FirstOrDefault()?.DateStart.ToRemoteDateTime(timezoneOffsetH),
|
Start = operations.FirstOrDefault()?.DateStart.ToRemoteDateTime(timezoneOffsetHours),
|
||||||
End = operations.Max(o => o.DateStart.ToRemoteDateTime(timezoneOffsetH).AddHours(o.DurationHours)),
|
End = operations.Max(o => o.DateStart.ToRemoteDateTime(timezoneOffsetHours).AddHours(o.DurationHours)),
|
||||||
WellDepthStart = operations.Min(o => o.DepthStart),
|
WellDepthStart = operations.Min(o => o.DepthStart),
|
||||||
WellDepthEnd = operations.Max(o => o.DepthStart),
|
WellDepthEnd = operations.Max(o => o.DepthStart),
|
||||||
Rop = CalcROP(operations),
|
Rop = CalcROP(operations),
|
||||||
@ -356,7 +369,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
{
|
{
|
||||||
var dDepth = 0d;
|
var dDepth = 0d;
|
||||||
var dHours = 0d;
|
var dHours = 0d;
|
||||||
foreach (var race in races)
|
foreach (Race race in races)
|
||||||
{
|
{
|
||||||
dDepth += race.StartWellDepth;
|
dDepth += race.StartWellDepth;
|
||||||
for (var i = 0; i < race.Operations.Count; i++)
|
for (var i = 0; i < race.Operations.Count; i++)
|
||||||
@ -417,78 +430,71 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
|
|
||||||
var tzOffsetHours = wellService.GetTimezone(idWell).Hours;
|
var tzOffsetHours = wellService.GetTimezone(idWell).Hours;
|
||||||
|
|
||||||
if (!wellOperationsPlan.Any())
|
var merged = MergeArraysBySections(sectionsIds, wellOperationsPlan, wellOperationsFact).ToList();
|
||||||
return null;
|
|
||||||
|
|
||||||
var merged = MergeArraysBySections(sectionsIds, wellOperationsPlan, wellOperationsFact);
|
|
||||||
var tvd = new List<PlanFactPredictBase<WellOperationDto>>(merged.Count);
|
var tvd = new List<PlanFactPredictBase<WellOperationDto>>(merged.Count);
|
||||||
var firstPoint = merged.First();
|
var (Plan, Fact) = merged.First();
|
||||||
var dateStart = firstPoint.Item1?.DateStart ?? firstPoint.Item2.DateStart;
|
var dateStart = Plan?.DateStart ?? Fact!.DateStart;
|
||||||
int iLastMatch = 0;
|
int? iLastMatch = null;
|
||||||
int iLastFact = 0;
|
int iLastFact = 0;
|
||||||
var nptHours = 0d;
|
var nptHours = 0d;
|
||||||
for (int i = 0; i < merged.Count; i++)
|
for (int i = 0; i < merged.Count; i++)
|
||||||
{
|
{
|
||||||
var item = merged[i];
|
var item = merged[i];
|
||||||
var plan = item.Item1;
|
var plan = item.Plan;
|
||||||
var fact = item.Item2;
|
var fact = item.Fact;
|
||||||
|
|
||||||
if (fact is not null && WellOperationCategory.NonProductiveTimeSubIds.Contains(fact.IdCategory))
|
var planFactPredict = new PlanFactPredictBase<WellOperationDto>();
|
||||||
|
if (plan is not null)
|
||||||
{
|
{
|
||||||
nptHours += fact.DurationHours;
|
planFactPredict.Plan = Convert(plan, tzOffsetHours);
|
||||||
|
planFactPredict.Plan.Day = (planFactPredict.Plan.DateStart - dateStart).TotalDays;
|
||||||
|
if (fact is not null)
|
||||||
|
iLastMatch = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
var planFactPredict = new PlanFactPredictBase<WellOperationDto>
|
if (fact is not null)
|
||||||
{
|
{
|
||||||
Plan = Convert(plan, tzOffsetHours),
|
if(WellOperationCategory.NonProductiveTimeSubIds.Contains(fact.IdCategory))
|
||||||
Fact = Convert(fact, tzOffsetHours),
|
nptHours += fact.DurationHours;
|
||||||
Predict = null,
|
|
||||||
};
|
|
||||||
|
|
||||||
if (planFactPredict.Plan is not null)
|
planFactPredict.Fact = Convert(fact, tzOffsetHours);
|
||||||
planFactPredict.Plan.Day = (planFactPredict.Plan.DateStart - dateStart).TotalDays;
|
|
||||||
|
|
||||||
if (planFactPredict.Fact is not null)
|
|
||||||
{
|
|
||||||
planFactPredict.Fact.Day = (planFactPredict.Fact.DateStart - dateStart).TotalDays;
|
planFactPredict.Fact.Day = (planFactPredict.Fact.DateStart - dateStart).TotalDays;
|
||||||
planFactPredict.Fact.NptHours = nptHours;
|
planFactPredict.Fact.NptHours = nptHours;
|
||||||
|
iLastFact = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
tvd.Add(planFactPredict);
|
tvd.Add(planFactPredict);
|
||||||
if ((plan is not null) && (fact is not null))
|
|
||||||
iLastMatch = i;
|
|
||||||
if (fact is not null)
|
|
||||||
iLastFact = i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iLastMatch == 0 || iLastMatch == merged.Count - 1)
|
if (iLastMatch is null || iLastMatch == merged.Count - 1)
|
||||||
return tvd;
|
return tvd;
|
||||||
|
|
||||||
var lastMatchPlan = merged[iLastMatch].Item1;
|
var lastMatchPlan = merged[iLastMatch.Value].Plan!;
|
||||||
var lastMatchPlanOperationEnd = lastMatchPlan.DateStart.AddHours(lastMatchPlan.DurationHours);
|
var lastMatchPlanOperationEnd = lastMatchPlan.DateStart.AddHours(lastMatchPlan.DurationHours);
|
||||||
var lastFact = merged[iLastFact].Item2;
|
var lastFact = merged[iLastFact].Fact!;
|
||||||
var lastFactDateEnd = lastFact.DateStart.AddHours(lastFact.DurationHours);
|
var lastFactDateEnd = lastFact.DateStart.AddHours(lastFact.DurationHours);
|
||||||
var startOffset = lastFactDateEnd - lastMatchPlanOperationEnd;
|
var startOffset = lastFactDateEnd - lastMatchPlanOperationEnd;
|
||||||
|
|
||||||
for (int i = iLastMatch + 1; i < merged.Count; i++)
|
for (int i = iLastMatch.Value + 1; i < merged.Count; i++)
|
||||||
{
|
{
|
||||||
if (merged[i].Item1 is null)
|
if (merged[i].Plan is null)
|
||||||
continue;
|
continue;
|
||||||
tvd[i].Predict = Convert(merged[i].Item1, tzOffsetHours);
|
var predict = Convert(merged[i].Plan!, tzOffsetHours);
|
||||||
tvd[i].Predict.IdType = 2;
|
predict.IdType = 2;
|
||||||
tvd[i].Predict.DateStart = tvd[i].Predict.DateStart + startOffset;
|
predict.DateStart = predict.DateStart + startOffset;
|
||||||
tvd[i].Predict.Day = (tvd[i].Predict.DateStart - dateStart).TotalDays;
|
predict.Day = (predict.DateStart - dateStart).TotalDays;
|
||||||
|
tvd[i].Predict = predict;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tvd;
|
return tvd;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Tuple<WellOperation, WellOperation>> MergeArraysBySections(
|
private static IEnumerable<(WellOperation? Plan, WellOperation? Fact)> MergeArraysBySections(
|
||||||
IEnumerable<int> sectionsIds,
|
IEnumerable<int> sectionsIds,
|
||||||
IOrderedEnumerable<WellOperation> wellOperationsPlan,
|
IOrderedEnumerable<WellOperation> wellOperationsPlan,
|
||||||
IOrderedEnumerable<WellOperation> wellOperationsFact)
|
IOrderedEnumerable<WellOperation> wellOperationsFact)
|
||||||
{
|
{
|
||||||
var merged = new List<Tuple<WellOperation, WellOperation>>(wellOperationsPlan.Count());
|
var merged = new List<(WellOperation? Plan, WellOperation? Fact)>(wellOperationsPlan.Count());
|
||||||
foreach (var sectionId in sectionsIds)
|
foreach (var sectionId in sectionsIds)
|
||||||
{
|
{
|
||||||
var sectionOperationsPlan = wellOperationsPlan
|
var sectionOperationsPlan = wellOperationsPlan
|
||||||
@ -501,46 +507,38 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
return merged;
|
return merged;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Tuple<WellOperation, WellOperation>> MergeArrays(IEnumerable<WellOperation> operationsPlan, IEnumerable<WellOperation> operationsFact)
|
private static IEnumerable<(WellOperation? Plan, WellOperation? Fact)> MergeArrays(IEnumerable<WellOperation> operationsPlan, IEnumerable<WellOperation> operationsFact)
|
||||||
{
|
{
|
||||||
var result = new List<Tuple<WellOperation, WellOperation>>();
|
var operationsFactWithNoPlan = operationsFact.Where(x => x.IdPlan == null).ToArray();
|
||||||
|
var operationsFactWithPlan = operationsFact.Where(x => x.IdPlan != null).ToArray();
|
||||||
|
|
||||||
var oparationsFactWithNoPlan = operationsFact
|
var idsPlanWithFact = operationsFact.Where(x => x.IdPlan is not null).Select(x => x.IdPlan).Distinct();
|
||||||
.Where(x => x.IdPlan == null)
|
var operationsPlanWithNoFact = operationsPlan.Where(x => !idsPlanWithFact.Contains(x.IdPlan)).ToArray();
|
||||||
.Select(x => new Tuple<WellOperation, WellOperation>(null, x));
|
|
||||||
|
|
||||||
var oparationsFactWithPlan = operationsFact
|
var result = new List<(WellOperation? Plan, WellOperation? Fact)>(operationsFactWithNoPlan.Length + operationsFactWithPlan.Length + operationsPlanWithNoFact.Length);
|
||||||
.Where(x => x.IdPlan != null)
|
|
||||||
.Select(x => new Tuple<WellOperation, WellOperation>(x.OperationPlan, x));
|
|
||||||
|
|
||||||
var idsPlanWithFact = operationsFact
|
foreach (var operation in operationsFactWithPlan)
|
||||||
.Where(x => x.IdPlan is not null)
|
result.Add((operation.OperationPlan, operation));
|
||||||
.Select(x => x.IdPlan)
|
|
||||||
.Distinct();
|
|
||||||
var oparationsPlanWithNoFact = operationsPlan
|
|
||||||
.Where(x => !idsPlanWithFact.Contains(x.IdPlan))
|
|
||||||
.Select(x => new Tuple<WellOperation, WellOperation>(x, null));
|
|
||||||
|
|
||||||
result.AddRange(oparationsFactWithNoPlan);
|
foreach (var operation in operationsFactWithNoPlan)
|
||||||
result.AddRange(oparationsFactWithPlan);
|
result.Add((null, operation));
|
||||||
result.AddRange(oparationsPlanWithNoFact);
|
|
||||||
|
|
||||||
result = result
|
foreach (var operation in operationsPlanWithNoFact)
|
||||||
.OrderBy(x => x.Item1?.DateStart)
|
result.Add((operation, null));
|
||||||
.ThenBy(x => x.Item2?.DateStart)
|
|
||||||
.ToList();
|
return result
|
||||||
return result;
|
.OrderBy(x => x.Plan?.DateStart)
|
||||||
|
.ThenBy(x => x.Fact?.DateStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WellOperationDto Convert(WellOperation source, double tzOffsetHours)
|
private static WellOperationDto Convert(WellOperation source, double tzOffsetHours)
|
||||||
{
|
{
|
||||||
if (source is null)
|
var destination = source.Adapt<WellOperationDto>();
|
||||||
return null;
|
destination.CategoryName = source.OperationCategory?.Name;
|
||||||
var dest = source.Adapt<WellOperationDto>();
|
destination.WellSectionTypeName = source.WellSectionType?.Caption;
|
||||||
dest.CategoryName = source.OperationCategory?.Name;
|
destination.DateStart = source.DateStart.ToRemoteDateTime(tzOffsetHours);
|
||||||
dest.WellSectionTypeName = source.WellSectionType?.Caption;
|
return destination;
|
||||||
dest.DateStart = source.DateStart.ToRemoteDateTime(tzOffsetHours);
|
|
||||||
return dest;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services.WellOperationService
|
namespace AsbCloudInfrastructure.Services.WellOperationService
|
||||||
{
|
{
|
||||||
@ -60,7 +61,7 @@ namespace AsbCloudInfrastructure.Services.WellOperationService
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Список операций за рейс
|
/// Список операций за рейс
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<WellOperation>? Operations { get; internal set; }
|
public List<WellOperation> Operations { get; internal set; } = new List<WellOperation>();
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Статистика по операциям (заведенным вручную) на скважине
|
/// Статистика по операциям (заведенным вручную) на скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -41,7 +42,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await operationsStatService.GetRopStatAsync(
|
var result = await operationsStatService.GetOrDefaultRopStatAsync(
|
||||||
idWell, token).ConfigureAwait(false);
|
idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
@ -64,7 +65,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idWell is null)
|
if (idWell is null)
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
var result = await operationsStatService.GetRopStatAsync(
|
var result = await operationsStatService.GetOrDefaultRopStatAsync(
|
||||||
(int)idWell, token).ConfigureAwait(false);
|
(int)idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
@ -87,7 +88,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (idCompany is null)
|
if (idCompany is null)
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await operationsStatService.GetStatClusterAsync(idCluster, idCompany.Value, token)
|
var result = await operationsStatService.GetOrDefaultStatClusterAsync(idCluster, idCompany.Value, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
|
||||||
return Forbid();
|
return Forbid();
|
||||||
|
|
||||||
var result = await operationsStatService.GetWellStatAsync(idWell, token)
|
var result = await operationsStatService.GetOrDefaultWellStatAsync(idWell, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
@ -165,4 +166,5 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
idWell, token).ConfigureAwait(false);
|
idWell, token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[Route("template")]
|
[Route("template")]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public IActionResult GetTamplate()
|
public IActionResult GetTemplate()
|
||||||
{
|
{
|
||||||
var stream = wellOperationImportService.GetExcelTemplateStream();
|
var stream = wellOperationImportService.GetExcelTemplateStream();
|
||||||
var fileName = "ЕЦП_шаблон_файла_операций.xlsx";
|
var fileName = "ЕЦП_шаблон_файла_операций.xlsx";
|
||||||
|
46
AsbCloudWebApi/Rest/OperationStat.http
Normal file
46
AsbCloudWebApi/Rest/OperationStat.http
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
@baseUrl = http://127.0.0.1:5000
|
||||||
|
@contentType = application/json
|
||||||
|
@auth = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCIsImN0eSI6IkpXVCJ9.eyJpZCI6IjEiLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiZGV2IiwiaWRDb21wYW55IjoiMSIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6InJvb3QiLCJuYmYiOjE2NjI1NDgxNjIsImV4cCI6MTY5NDEwNTc2MiwiaXNzIjoiYSIsImF1ZCI6ImEifQ.OEAlNzxi7Jat6pzDBTAjTbChskc-tdJthJexyWwwUKE
|
||||||
|
|
||||||
|
@uid = 20210910_012752700
|
||||||
|
@idCluster = 1
|
||||||
|
@idWell = 1
|
||||||
|
#295
|
||||||
|
|
||||||
|
# https://marketplace.visualstudio.com/items?itemName=humao.rest-client
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{baseUrl}}/api/well/{{idWell}}/ropStat
|
||||||
|
Content-Type: {{contentType}}
|
||||||
|
accept: */*
|
||||||
|
Authorization: {{auth}}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{baseUrl}}/api/telemetry/{{uid}}/ropStat
|
||||||
|
Content-Type: {{contentType}}
|
||||||
|
accept: */*
|
||||||
|
Authorization: {{auth}}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{baseUrl}}/api/cluster/{{idCluster}}/stat
|
||||||
|
Content-Type: {{contentType}}
|
||||||
|
accept: */*
|
||||||
|
Authorization: {{auth}}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{baseUrl}}/api/wellsStats?idWells=1&idWells={{idWell}}
|
||||||
|
Content-Type: {{contentType}}
|
||||||
|
accept: */*
|
||||||
|
Authorization: {{auth}}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{baseUrl}}/api/well/{{idWell}}/stat
|
||||||
|
Content-Type: {{contentType}}
|
||||||
|
accept: */*
|
||||||
|
Authorization: {{auth}}
|
||||||
|
|
||||||
|
###
|
||||||
|
GET {{baseUrl}}/api/well/{{idWell}}/tvd
|
||||||
|
Content-Type: {{contentType}}
|
||||||
|
accept: */*
|
||||||
|
Authorization: {{auth}}
|
Loading…
Reference in New Issue
Block a user