diff --git a/AsbCloudApp/Data/WellOperationDto.cs b/AsbCloudApp/Data/WellOperationDto.cs
index 75ad2248..3ef0054f 100644
--- a/AsbCloudApp/Data/WellOperationDto.cs
+++ b/AsbCloudApp/Data/WellOperationDto.cs
@@ -2,6 +2,12 @@
namespace AsbCloudApp.Data
{
+ public enum WellOpertaionType
+ {
+ Plan,
+ Fact
+ }
+
public class WellOperationDto : IId
{
public int Id { get; set; }
@@ -12,11 +18,16 @@ namespace AsbCloudApp.Data
public string WellSectionTypeName { get; set; }
- public int IdOperationCategory { get; set; }
+ public int IdCategory { get; set; }
public string CategoryName { get; set; }
- public int Type { get; set; }
+ public string CategoryInfo { get; set; }
+
+ ///
+ /// План или факт
+ ///
+ public WellOpertaionType Type { get; set; }
public double WellDepth { get; set; }
@@ -24,8 +35,6 @@ namespace AsbCloudApp.Data
public double DurationHours { get; set; }
- public string Info { get; set; }
-
public string Comment { get; set; }
}
}
diff --git a/AsbCloudApp/Data/WellSectionDto.cs b/AsbCloudApp/Data/WellSectionDto.cs
index 1b72d36c..c1a2cd10 100644
--- a/AsbCloudApp/Data/WellSectionDto.cs
+++ b/AsbCloudApp/Data/WellSectionDto.cs
@@ -21,22 +21,22 @@
///
/// Период план, д
///
- public double BuildDaysPlan { get; set; }
+ public double DurationPlan { get; set; }
///
/// Период факт, д
///
- public double BuildDaysFact { get; set; }
+ public double DurationFact { get; set; }
///
/// Механическая скорость проходки план, м/час
///
- public double RateOfPenetrationPlan { get; set; }
+ public double MechSpeedPlan { get; set; }
///
/// Механическая скорость проходки факт, м/час
///
- public double RateOfPenetrationFact { get; set; }
+ public double MechSpeedFact { get; set; }
///
/// Рейсовая скорость план, м/час
diff --git a/AsbCloudApp/Services/IWellOperationService.cs b/AsbCloudApp/Services/IWellOperationService.cs
index 8dca0e31..81f1cf30 100644
--- a/AsbCloudApp/Services/IWellOperationService.cs
+++ b/AsbCloudApp/Services/IWellOperationService.cs
@@ -8,7 +8,7 @@ namespace AsbCloudApp.Services
{
public interface IWellOperationService
{
- IEnumerable GetTypes();
+ IEnumerable GetCategories();
Task> GetAllByWellIdAsync(int idWell,
int skip = 0, int take = 32, CancellationToken token = default);
diff --git a/AsbCloudApp/Services/IWellSectionService.cs b/AsbCloudApp/Services/IWellSectionService.cs
index 84693d4f..1deb15ba 100644
--- a/AsbCloudApp/Services/IWellSectionService.cs
+++ b/AsbCloudApp/Services/IWellSectionService.cs
@@ -7,12 +7,12 @@ namespace AsbCloudApp.Services
{
public interface IWellSectionService
{
- Task> GetAllByWellIdAsync(int idWell, int skip = 0, int take = 32, CancellationToken token = default);
- Task GetAsync(int id, CancellationToken token = default);
- Task InsertAsync(WellSectionDto newItem, int idWell, CancellationToken token = default);
- Task> InsertRangeAsync(int idWell, IEnumerable newItems, CancellationToken token = default);
- Task UpdateAsync(int idWell, int idSection, WellSectionDto item, CancellationToken token = default);
- Task DeleteAsync(IEnumerable ids, CancellationToken token = default);
Task GetTypesAsync(CancellationToken token);
+ Task> GetSectionsByWellIdAsync(int idWell, int skip = 0, int take = 32, CancellationToken token = default);
+ Task GetSectionByWellIdAsync(int id, CancellationToken token = default);
+ //Task InsertAsync(WellSectionDto newItem, int idWell, CancellationToken token = default);
+ //Task> InsertRangeAsync(int idWell, IEnumerable newItems, CancellationToken token = default);
+ //Task UpdateAsync(int idWell, int idSection, WellSectionDto item, CancellationToken token = default);
+ //Task DeleteAsync(IEnumerable ids, CancellationToken token = default);
}
}
diff --git a/AsbCloudInfrastructure/Services/ClusterService.cs b/AsbCloudInfrastructure/Services/ClusterService.cs
index 9421c9eb..e398becb 100644
--- a/AsbCloudInfrastructure/Services/ClusterService.cs
+++ b/AsbCloudInfrastructure/Services/ClusterService.cs
@@ -158,12 +158,12 @@ namespace AsbCloudInfrastructure.Services
BhaDownSpeedPlan = s.BhaDownSpeedPlan,
BhaUpSpeedFact = s.BhaUpSpeedFact,
BhaUpSpeedPlan = s.BhaUpSpeedPlan,
- BuildDaysFact = s.BuildDaysFact,
- BuildDaysPlan = s.BuildDaysPlan,
+ DurationFact = s.BuildDaysFact,
+ DurationPlan = s.BuildDaysPlan,
CasingDownSpeedFact = s.CasingDownSpeedFact,
CasingDownSpeedPlan = s.CasingDownSpeedPlan,
- RateOfPenetrationFact = s.RateOfPenetrationFact,
- RateOfPenetrationPlan = s.RateOfPenetrationPlan,
+ MechSpeedFact = s.RateOfPenetrationFact,
+ MechSpeedPlan = s.RateOfPenetrationPlan,
RouteSpeedFact = s.RouteSpeedFact,
RouteSpeedPlan = s.RouteSpeedPlan,
SectionType = s.WellSectionType.Caption,
diff --git a/AsbCloudInfrastructure/Services/WellSectionService.cs b/AsbCloudInfrastructure/Services/WellSectionService.cs
index f6d81900..d3d1da8b 100644
--- a/AsbCloudInfrastructure/Services/WellSectionService.cs
+++ b/AsbCloudInfrastructure/Services/WellSectionService.cs
@@ -14,57 +14,93 @@ namespace AsbCloudInfrastructure.Services
{
public class WellSectionService: IWellSectionService
{
- private readonly IAsbCloudDbContext context;
- private readonly DbSet dbSet;
+ private readonly IAsbCloudDbContext db;
private readonly CacheTable cachedSectionsTypes;
- public WellSectionService(IAsbCloudDbContext context, Cache.CacheDb cache)
+ public WellSectionService(IAsbCloudDbContext db, Cache.CacheDb cache)
{
- this.context = context;
- dbSet = context.Set();
- cachedSectionsTypes = cache.GetCachedTable((DbContext)context);
+ this.db = db;
+ cachedSectionsTypes = cache.GetCachedTable((DbContext)db);
}
public Task GetTypesAsync(CancellationToken token) =>
- context.WellSectionTypes.Select(e => e.Caption).Distinct().AsNoTracking().ToArrayAsync(token);
-
- public async Task> GetAllByWellIdAsync(int idWell, int skip, int take, CancellationToken token = default)
+ db.WellSectionTypes.Select(e => e.Caption).Distinct().AsNoTracking().ToArrayAsync(token);
+
+ public async Task> GetSectionsByWellIdAsync(int idWell,
+ int skip, int take, CancellationToken token = default)
{
- var query = dbSet
- .Include(s => s.WellSectionType)
- .Where(s => s.IdWell == idWell)
- .AsNoTracking();
+ var groupedWellOperationsQuery = (from w in db.WellOperations
+ where w.IdWell == idWell
+ select w)
+ .Include(w => w.WellSectionType)
+ .GroupBy(op => op.IdWellSectionType);
+
+ if (skip > 0)
+ groupedWellOperationsQuery = groupedWellOperationsQuery.Skip(skip);
+
+ var wellOperationsGroupedBySections = await groupedWellOperationsQuery
+ .Take(take).ToListAsync(token)
+ .ConfigureAwait(false);
var result = new PaginationContainer
{
Skip = skip,
Take = take,
- Count = await query.CountAsync(token).ConfigureAwait(false),
+ Count = wellOperationsGroupedBySections.Count
};
- query = query
- .OrderBy(e => e.WellDepthPlan);
+ if (!wellOperationsGroupedBySections.Any())
+ return result;
- if (skip > 0)
- query = query.Skip(skip);
+ // TODO: Подставить нормальные ID операций спускоа, подъема и т.д.
+ var depthsPlanFactList = GetWellDepthPlanFact(wellOperationsGroupedBySections).ToList();
- query = query.Take(take);
+ var durationsPlanFactList = GetWellDurationPlanFact(wellOperationsGroupedBySections).ToList();
- var entities = await query.Take(take).ToListAsync(token).ConfigureAwait(false);
+ var mechSpeedsList = GetWellMechSpeedPlanFact(wellOperationsGroupedBySections).ToList();
- foreach (var item in entities)
+ var bhaUpSpeedList = GetWellBhaUpSpeedPlanFact(wellOperationsGroupedBySections).ToList();
+
+ var bhaDownSpeedList = GetWellBhaDownSpeedPlanFact(wellOperationsGroupedBySections).ToList();
+
+ var casingDownList = GetWellCasingDownPlanFact(wellOperationsGroupedBySections).ToList();
+
+ var routeSpeeds = GetWellRouteSpeedsPlanFact(wellOperationsGroupedBySections).ToList();
+
+ var dtos = new List();
+
+ for(int i = 0; i <= wellOperationsGroupedBySections.Count; i++)
{
- var dto = item.Adapt();
- dto.SectionType = item.WellSectionType.Caption;
- result.Items.Add(dto);
+ var dto = new WellSectionDto
+ {
+ SectionType = wellOperationsGroupedBySections[i].FirstOrDefault().OperationCategory.Name,
+ WellDepthPlan = depthsPlanFactList[i].DepthPlan,
+ WellDepthFact = depthsPlanFactList[i].DepthFact,
+ DurationPlan = durationsPlanFactList[i].DurationPlan,
+ DurationFact = durationsPlanFactList[i].DurationFact,
+ MechSpeedPlan = mechSpeedsList[i].MechSpeedPlan,
+ MechSpeedFact = mechSpeedsList[i].MechSpeedFact,
+ BhaUpSpeedPlan = bhaUpSpeedList[i].BhaUpSpeedPlan,
+ BhaUpSpeedFact = bhaUpSpeedList[i].BhaUpSpeedFact,
+ BhaDownSpeedPlan = bhaDownSpeedList[i].BhaDownSpeedPlan,
+ BhaDownSpeedFact = bhaDownSpeedList[i].BhaDownSpeedFact,
+ CasingDownSpeedPlan = casingDownList[i].CasingDownSpeedPlan,
+ CasingDownSpeedFact = casingDownList[i].CasingDownSpeedFact,
+ RouteSpeedPlan = routeSpeeds[i].RouteSpeedPlan,
+ RouteSpeedFact = routeSpeeds[i].RouteSpeedFact
+ };
+
+ dtos.Add(dto);
}
+ result.Items = dtos;
+
return result;
}
- public async Task GetAsync(int id, CancellationToken token = default)
+ public async Task GetSectionByWellIdAsync(int id, CancellationToken token = default)
{
- var entity = await dbSet
+ var entity = await db.WellSections
.Include(s => s.WellSectionType)
.FirstOrDefaultAsync(e => e.Id == id, token)
.ConfigureAwait(false);
@@ -77,69 +113,227 @@ namespace AsbCloudInfrastructure.Services
return dto;
}
- public async Task InsertAsync(WellSectionDto item, int idWell, CancellationToken token = default)
+ //public async Task InsertAsync(WellSectionDto item, int idWell, CancellationToken token = default)
+ //{
+ // var sectionType = await GetWellSectionTypeFromCacheAndAssertAsync(item.SectionType);
+
+ // var entity = item.Adapt();
+ // entity.Id = default;
+ // entity.IdWell = idWell;
+ // entity.IdWellSectionType = sectionType.Id;
+ // var dbEntity = dbSet.Add(entity);
+ // await context.SaveChangesAsync(token).ConfigureAwait(false);
+
+ // var dto = dbEntity.Entity.Adapt();
+ // dto.SectionType = sectionType.Caption;
+ // return dto;
+ //}
+
+ //public async Task> InsertRangeAsync(int idWell, IEnumerable items, CancellationToken token = default)
+ //{
+ // var dbEntities = new Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry[items.Count()];
+
+ // for (int i = 0; i < dbEntities.Length; i++)
+ // {
+ // var sectionType = await GetWellSectionTypeFromCacheAndAssertAsync(items.ElementAt(i).SectionType, token);
+ // var item = items.ElementAt(i).Adapt();
+ // item.IdWell = idWell;
+ // item.IdWellSectionType = sectionType.Id;
+ // dbEntities[i] = dbSet.Add(item);
+ // }
+
+ // await context.SaveChangesAsync(token).ConfigureAwait(false);
+
+ // var dtos = dbEntities.Select((e) => {
+ // var dto = e.Entity.Adapt();
+ // var sectionType = cachedSectionsTypes.FirstOrDefault(s => s.Id == e.Entity.IdWellSectionType);
+ // dto.SectionType = sectionType.Caption;
+ // return dto;
+ // });
+
+ // return dtos;
+ //}
+
+ //public async Task UpdateAsync(int idWell, int idSection, WellSectionDto item, CancellationToken token = default)
+ //{
+ // var sectionType = await GetWellSectionTypeFromCacheAndAssertAsync(item.SectionType, token)
+ // .ConfigureAwait(false);
+
+ // var entity = item.Adapt();
+ // entity.Id = idSection;
+ // entity.IdWell = idWell;
+ // entity.IdWellSectionType = sectionType.Id;
+ // var dbEntity = dbSet.Update(entity);
+ // await context.SaveChangesAsync(token).ConfigureAwait(false);
+
+ // var dto = dbEntity.Entity.Adapt();
+ // dto.SectionType = sectionType.Caption;
+ // return dto;
+ //}
+
+ //public Task DeleteAsync(IEnumerable ids, CancellationToken token = default)
+ //{
+ // var entities = dbSet.Where(e => ids.Contains(e.Id));
+ // dbSet.RemoveRange(entities);
+ // return context.SaveChangesAsync(token);
+ //}
+
+ private static IEnumerable<(double DepthPlan, double DepthFact)> GetWellDepthPlanFact(
+ IEnumerable> groupedOperations)
{
- var sectionType = await GetWellSectionTypeFromCacheAndAssertAsync(item.SectionType);
-
- var entity = item.Adapt();
- entity.Id = default;
- entity.IdWell = idWell;
- entity.IdWellSectionType = sectionType.Id;
- var dbEntity = dbSet.Add(entity);
- await context.SaveChangesAsync(token).ConfigureAwait(false);
-
- var dto = dbEntity.Entity.Adapt();
- dto.SectionType = sectionType.Caption;
- return dto;
+ return groupedOperations
+ .Select(group =>
+ (
+ DepthPlan: group.Where(o => o.Type == 0).Max(w => w.WellDepth),
+ DepthFact: group.Where(o => o.Type == 1).Max(w => w.WellDepth)
+ ));
}
-
- public async Task> InsertRangeAsync(int idWell, IEnumerable items, CancellationToken token = default)
+
+ private static IEnumerable<(double DurationPlan, double DurationFact)> GetWellDurationPlanFact(
+ IEnumerable> groupedOperations)
{
- var dbEntities = new Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry[items.Count()];
-
- for (int i = 0; i < dbEntities.Length; i++)
+ var durationsPlanFactsBase = groupedOperations.Select(group => new
{
- var sectionType = await GetWellSectionTypeFromCacheAndAssertAsync(items.ElementAt(i).SectionType, token);
- var item = items.ElementAt(i).Adapt();
- item.IdWell = idWell;
- item.IdWellSectionType = sectionType.Id;
- dbEntities[i] = dbSet.Add(item);
- }
+ DurationMaxPlan = group.Where(o => o.Type == 0).Select(op => op.StartDate +
+ TimeSpan.FromHours(op.DurationHours)).Max(),
- await context.SaveChangesAsync(token).ConfigureAwait(false);
-
- var dtos = dbEntities.Select((e) => {
- var dto = e.Entity.Adapt();
- var sectionType = cachedSectionsTypes.FirstOrDefault(s => s.Id == e.Entity.IdWellSectionType);
- dto.SectionType = sectionType.Caption;
- return dto;
+ DurationMinPlan = group.Where(o => o.Type == 0).Min(i => i.StartDate),
+
+ DurationMaxFact = group.Where(o => o.Type == 1).Select(op => op.StartDate +
+ TimeSpan.FromHours(op.DurationHours)).Max(),
+
+ DurationMinFact = group.Where(o => o.Type == 1).Min(i => i.StartDate)
});
- return dtos;
+ return durationsPlanFactsBase.Select(o =>
+ (
+ DurationPlan: (o.DurationMaxPlan - o.DurationMinPlan).TotalHours,
+ DurationFact: (o.DurationMaxFact - o.DurationMinFact).TotalHours
+ ));
}
- public async Task UpdateAsync(int idWell, int idSection, WellSectionDto item, CancellationToken token = default)
+ private static IEnumerable<(double MechSpeedPlan, double MechSpeedFact)> GetWellMechSpeedPlanFact(
+ IEnumerable> groupedOperations)
{
- var sectionType = await GetWellSectionTypeFromCacheAndAssertAsync(item.SectionType, token)
- .ConfigureAwait(false);
+ var mechSpeedBase = groupedOperations.Select(g => new
+ {
+ DepthChangePlanSum = g.Where(o => o.Type == 0 && o.IdOperationCategory == 1)
+ .Select((el, i) => i > 0 ? el.WellDepth - g.ElementAt(i - 1).WellDepth : 0).Sum(),
+ DurationsPlanSum = g.Where(o => o.Type == 0 && o.IdOperationCategory == 1)
+ .Select(el => el.DurationHours).Sum(),
+ DepthChangeFactSum = g.Where(o => o.Type == 1 && o.IdOperationCategory == 1)
+ .Select((el, i) => i > 0 ? el.WellDepth - g.ElementAt(i - 1).WellDepth : 0).Sum(),
+ DurationsFactSum = g.Where(o => o.Type == 1 && o.IdOperationCategory == 1)
+ .Select(el => el.DurationHours).Sum()
+ });
- var entity = item.Adapt();
- entity.Id = idSection;
- entity.IdWell = idWell;
- entity.IdWellSectionType = sectionType.Id;
- var dbEntity = dbSet.Update(entity);
- await context.SaveChangesAsync(token).ConfigureAwait(false);
-
- var dto = dbEntity.Entity.Adapt();
- dto.SectionType = sectionType.Caption;
- return dto;
+ return mechSpeedBase.Select(el =>
+ (
+ MechSpeedPlan: el.DepthChangePlanSum / el.DurationsPlanSum,
+ MechSpeedFact: el.DepthChangeFactSum / el.DurationsFactSum
+ ));
}
- public Task DeleteAsync(IEnumerable ids, CancellationToken token = default)
+ private static IEnumerable<(double BhaUpSpeedPlan, double BhaUpSpeedFact)> GetWellBhaUpSpeedPlanFact(
+ IEnumerable> groupedOperations)
{
- var entities = dbSet.Where(e => ids.Contains(e.Id));
- dbSet.RemoveRange(entities);
- return context.SaveChangesAsync(token);
+ var bhaUpSpeedBase = GetParams(groupedOperations, 2);
+
+ return bhaUpSpeedBase.Select(el =>
+ (
+ BhaUpSpeedPlan: el.DepthDifferencePlanSum / el.DurationDifferencePlanSum,
+ BhaUpSpeedFact: el.DepthDifferenceFactSum / el.DurationDifferenceFactSum
+ ));
+ }
+
+ private static IEnumerable<(double BhaDownSpeedPlan, double BhaDownSpeedFact)> GetWellBhaDownSpeedPlanFact(
+ IEnumerable> groupedOperations)
+ {
+ var bhaDownSpeedBase = GetParams(groupedOperations, 3);
+
+ return bhaDownSpeedBase.Select(el =>
+ (
+ BhaDownSpeedPlan: el.DepthDifferencePlanSum / el.DurationDifferencePlanSum,
+ BhaDownSpeedFact: el.DepthDifferenceFactSum / el.DurationDifferenceFactSum
+ ));
+ }
+
+ private static IEnumerable<(double CasingDownSpeedPlan, double CasingDownSpeedFact)> GetWellCasingDownPlanFact(
+ IEnumerable> groupedOperations)
+ {
+ var casingDownBase = GetParams(groupedOperations, 4);
+
+ return casingDownBase.Select(el =>
+ (
+ CasingDownSpeedPlan: el.DepthDifferencePlanSum / el.DurationDifferencePlanSum,
+ CasingDownSpeedFact: el.DepthDifferenceFactSum / el.DurationDifferenceFactSum
+ )).ToList();
+ }
+
+ private static IEnumerable<(double DepthDifferencePlanSum,
+ double DurationDifferencePlanSum, double DepthDifferenceFactSum,
+ double DurationDifferenceFactSum)> GetParams(IEnumerable> items,
+ int idOperationCategory)
+ {
+ return items.Select(g =>
+ (
+ DepthDifferencePlanSum: g.Where(o => o.Type == 0 && o.IdOperationCategory == idOperationCategory)
+ .Select((el, i) => i > 0 ? el.WellDepth - g.ElementAt(i - 1).WellDepth : 0).Sum(),
+ DurationDifferencePlanSum: g.Where(o => o.Type == 0 && o.IdOperationCategory == idOperationCategory)
+ .Select(el => el.DurationHours).Sum(),
+ DepthDifferenceFactSum: g.Where(o => o.Type == 1 && o.IdOperationCategory == idOperationCategory)
+ .Select((el, i) => i > 0 ? el.WellDepth - g.ElementAt(i - 1).WellDepth : 0).Sum(),
+ DurationDifferenceFactSum: g.Where(o => o.Type == 1 && o.IdOperationCategory == idOperationCategory)
+ .Select(el => el.DurationHours).Sum()
+ ));
+ }
+
+ private static IEnumerable<(double RouteSpeedPlan, double RouteSpeedFact)> GetWellRouteSpeedsPlanFact(
+ IEnumerable> groupedOperations)
+ {
+ var bhaRaiseDecreaseCollection = new List<(WellOperation FirstDecreasePlan, WellOperation LastIncreasePlan,
+ WellOperation FirstDecreaseFact, WellOperation LastIncreaseFact)>();
+
+ foreach (var group in groupedOperations)
+ {
+ var firstBhaPositionDecreasePlan = group.Any(o => o.IdOperationCategory == 5 && o.Type == 0)
+ ? group.First(o => o.IdOperationCategory == 5 && o.Type == 0)
+ : null;
+
+ var lastBhaPositionIncreasePlan = group.Any(o => o.IdOperationCategory == 6 && o.Type == 0)
+ ? group.First(o => o.IdOperationCategory == 5 && o.Type == 0)
+ : null;
+
+ var firstBhaPositionDecreaseFact = group.Any(o => o.IdOperationCategory == 5 && o.Type == 1)
+ ? group.First(o => o.IdOperationCategory == 5 && o.Type == 1)
+ : null;
+
+ var lastBhaPositionIncreaseFact = group.Any(o => o.IdOperationCategory == 6 && o.Type == 1)
+ ? group.First(o => o.IdOperationCategory == 5 && o.Type == 1)
+ : null;
+
+ bhaRaiseDecreaseCollection.Add((firstBhaPositionDecreasePlan,
+ lastBhaPositionIncreasePlan, firstBhaPositionDecreaseFact,
+ lastBhaPositionIncreaseFact));
+ }
+
+ var routeSpeedsBase = bhaRaiseDecreaseCollection.Select(el => new // TODO: check value for null
+ {
+ RouteDepthPlan = el.FirstDecreasePlan.WellDepth - el.LastIncreasePlan.WellDepth,
+ RouteDepthFact = el.FirstDecreaseFact.WellDepth - el.LastIncreaseFact.WellDepth,
+ RouteDurationPlan = (el.LastIncreasePlan.StartDate +
+ TimeSpan.FromHours(el.LastIncreasePlan.DurationHours) -
+ el.FirstDecreasePlan.StartDate).TotalHours,
+ RouteDurationFact = (el.LastIncreaseFact.StartDate +
+ TimeSpan.FromHours(el.LastIncreaseFact.DurationHours) -
+ el.FirstDecreaseFact.StartDate).TotalHours
+ });
+
+ return routeSpeedsBase.Select(el =>
+ (
+ RouteSpeedPlan: el.RouteDepthPlan / el.RouteDurationPlan,
+ RouteSpeedFact: el.RouteDepthFact / el.RouteDurationFact
+ )).ToList();
}
private async Task GetWellSectionTypeFromCacheAndAssertAsync(string wellSectionType, CancellationToken token = default)
@@ -153,7 +347,7 @@ namespace AsbCloudInfrastructure.Services
if (sectionType is null)
{
- throw new ArgumentException($"Тип секции '{wellSectionType}' отсутствует в справочнике", nameof(WellSectionDto.SectionType)) ;
+ throw new ArgumentException($"Тип секции '{wellSectionType}' отсутствует в справочнике", nameof(WellSectionDto.SectionType));
//sectionType = await cachedSectionsTypes.InsertAsync(new WellSectionType { Caption = item.SectionType}, token);
}
diff --git a/AsbCloudWebApi/Controllers/WellSectionController.cs b/AsbCloudWebApi/Controllers/WellSectionController.cs
index a0daa41d..227b9c3e 100644
--- a/AsbCloudWebApi/Controllers/WellSectionController.cs
+++ b/AsbCloudWebApi/Controllers/WellSectionController.cs
@@ -2,7 +2,6 @@
using AsbCloudApp.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
-using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -42,7 +41,7 @@ namespace AsbCloudWebApi.Controllers
if(!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid();
- var result = await sectionsService.GetAllByWellIdAsync(idWell, skip, take, token).ConfigureAwait(false);
+ var result = await sectionsService.GetSectionsByWellIdAsync(idWell, skip, take, token).ConfigureAwait(false);
return Ok(result);
}
@@ -55,50 +54,50 @@ namespace AsbCloudWebApi.Controllers
if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
return Forbid();
- var result = await sectionsService.GetAsync(idSection, token).ConfigureAwait(false);
+ var result = await sectionsService.GetSectionByWellIdAsync(idSection, token).ConfigureAwait(false);
return Ok(result);
}
- [HttpPost]
- [ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)]
- public async Task InsertAsync(int idWell, [FromBody] IEnumerable values,
- CancellationToken token = default)
- {
- if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
- return Forbid();
+ //[HttpPost]
+ //[ProducesResponseType(typeof(IEnumerable), (int)System.Net.HttpStatusCode.OK)]
+ //public async Task InsertAsync(int idWell, [FromBody] IEnumerable values,
+ // CancellationToken token = default)
+ //{
+ // if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
+ // return Forbid();
- var result = await sectionsService.InsertRangeAsync(idWell, values, token).ConfigureAwait(false);
- return Ok(result);
- }
+ // var result = await sectionsService.InsertRangeAsync(idWell, values, token).ConfigureAwait(false);
+ // return Ok(result);
+ //}
- [HttpPut("{idSection}")]
- [ProducesResponseType(typeof(WellSectionDto), (int)System.Net.HttpStatusCode.OK)]
- public async Task UpdateAsync(int idWell, int idSection, [FromBody] WellSectionDto value, CancellationToken token = default)
- {
- if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
- return Forbid();
+ //[HttpPut("{idSection}")]
+ //[ProducesResponseType(typeof(WellSectionDto), (int)System.Net.HttpStatusCode.OK)]
+ //public async Task UpdateAsync(int idWell, int idSection, [FromBody] WellSectionDto value, CancellationToken token = default)
+ //{
+ // if (!await CanUserAccessToWellAsync(idWell, token).ConfigureAwait(false))
+ // return Forbid();
- var result = await sectionsService.UpdateAsync(idWell, idSection, value, token).ConfigureAwait(false);
- return Ok(result);
- }
+ // var result = await sectionsService.UpdateAsync(idWell, idSection, value, token).ConfigureAwait(false);
+ // return Ok(result);
+ //}
- [HttpDelete("{idSection}")]
- [ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
- public async Task DeleteAsync(int idWell, int idItem, CancellationToken token = default)
- {
- if (!await CanUserAccessToWellAsync(idWell,
- token).ConfigureAwait(false))
- return Forbid();
+ //[HttpDelete("{idSection}")]
+ //[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
+ //public async Task DeleteAsync(int idWell, int idItem, CancellationToken token = default)
+ //{
+ // if (!await CanUserAccessToWellAsync(idWell,
+ // token).ConfigureAwait(false))
+ // return Forbid();
- var result = await sectionsService.DeleteAsync(new int[] { idItem }, token).ConfigureAwait(false);
- return Ok(result);
- }
+ // var result = await sectionsService.DeleteAsync(new int[] { idItem }, token).ConfigureAwait(false);
+ // return Ok(result);
+ //}
private async Task CanUserAccessToWellAsync(int idWell, CancellationToken token = default)
{
- int? idCompany = User.GetCompanyId();
- return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
- idWell, token).ConfigureAwait(false);
+ int? idCompany = User.GetCompanyId();
+ return idCompany is not null && await wellService.IsCompanyInvolvedInWellAsync((int)idCompany,
+ idWell, token).ConfigureAwait(false);
}
}
}