forked from ddrilling/AsbCloudServer
Расширение функциональности
1. Расширены репозитории: траектории, расписания 2. Расширил DTO, сервис РТК отчёт 3. Поправлен класс с методами расширения для формирования excel. В дальнейшем требуется удалить из него все неиспользуемые методы расширения
This commit is contained in:
parent
6dbed6c457
commit
6b0db1adbc
@ -11,8 +11,16 @@ public class ProcessMapReportWellDrillingDto
|
||||
/// Идентификатор скважины
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Режим работы
|
||||
/// 0 - ручной
|
||||
/// 1 - ротор
|
||||
/// 2 - слайд
|
||||
/// </summary>
|
||||
public int? IdMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Id секции скважины
|
||||
/// </summary>
|
||||
public int IdWellSectionType { get; set; }
|
||||
@ -91,8 +99,13 @@ public class ProcessMapReportWellDrillingDto
|
||||
/// </summary>
|
||||
public double UsageFact { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Плановая механическая скорость, м/ч
|
||||
/// </summary>
|
||||
public double? RopPlan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Фактическая механическая скорость, м/ч
|
||||
/// </summary>
|
||||
public double? Rop { get; set; }
|
||||
public double? RopFact { get; set; }
|
||||
}
|
@ -1,16 +1,23 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.WITS;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Requests;
|
||||
|
||||
namespace AsbCloudApp.Repositories
|
||||
{
|
||||
/// <summary>
|
||||
/// CRUD для работы с фактической траекторией из клиента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public interface ITrajectoryFactRepository : ITrajectoryRepository<TrajectoryGeoFactDto>
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// CRUD для работы с фактической траекторией из клиента
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public interface ITrajectoryFactRepository : ITrajectoryRepository<TrajectoryGeoFactDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить траектории скважины
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<TrajectoryGeoFactDto>> GetAsync(TrajectoryGeoFactRequest request, CancellationToken token);
|
||||
}
|
||||
}
|
24
AsbCloudApp/Requests/TrajectoryFactRequest.cs
Normal file
24
AsbCloudApp/Requests/TrajectoryFactRequest.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Запрос для получения фактической траектории
|
||||
/// </summary>
|
||||
public class TrajectoryGeoFactRequest : RequestBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор скважины
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Больше или равно дате
|
||||
/// </summary>
|
||||
public DateTime? GeDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Меньше или равно дате
|
||||
/// </summary>
|
||||
public DateTime? LtDate { get; set; }
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using AsbCloudApp.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -10,6 +11,15 @@ namespace AsbCloudApp.Services
|
||||
/// </summary>
|
||||
public interface IScheduleRepository : IRepositoryWellRelated<ScheduleDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// Получить расписание смен
|
||||
/// </summary>
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="workTime"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTime workTime, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// получить бурильщика по idWell и времени
|
||||
/// </summary>
|
||||
|
@ -1,17 +1,19 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Mapster;
|
||||
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
{
|
||||
|
||||
public class ScheduleRepository : CrudWellRelatedRepositoryBase<ScheduleDto, Schedule>, IScheduleRepository
|
||||
public class ScheduleRepository : CrudWellRelatedRepositoryBase<ScheduleDto, Schedule>,
|
||||
IScheduleRepository
|
||||
{
|
||||
private readonly IWellService wellService;
|
||||
|
||||
@ -21,31 +23,45 @@ namespace AsbCloudInfrastructure.Repository
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ScheduleDto>> GetAsync(int idWell, DateTime workTime, CancellationToken token)
|
||||
{
|
||||
var entities = await BuildQuery(idWell, workTime)
|
||||
.AsNoTracking()
|
||||
.ToArrayAsync(token);
|
||||
|
||||
return entities.Select(Convert);
|
||||
}
|
||||
|
||||
public async Task<DrillerDto?> GetOrDefaultDrillerAsync(int idWell, DateTime workTime, CancellationToken token)
|
||||
{
|
||||
var hoursOffset = wellService.GetTimezone(idWell).Hours;
|
||||
var date = workTime.ToUtcDateTimeOffset(hoursOffset);
|
||||
|
||||
var entities = await GetQuery()
|
||||
.Where(s => s.IdWell == idWell
|
||||
&& s.DrillStart <= date
|
||||
&& s.DrillEnd >= date)
|
||||
.ToListAsync(token);
|
||||
var entities = await BuildQuery(idWell, workTime)
|
||||
.AsNoTracking()
|
||||
.ToArrayAsync(token);
|
||||
|
||||
if (!entities.Any())
|
||||
return null;
|
||||
|
||||
var remoteDate = date.ToRemoteDateTime(hoursOffset);
|
||||
|
||||
var hoursOffset = wellService.GetTimezone(idWell).Hours;
|
||||
var remoteDate = workTime.ToUtcDateTimeOffset(hoursOffset).ToRemoteDateTime(hoursOffset);
|
||||
var time = new TimeOnly(remoteDate.Hour, remoteDate.Minute, remoteDate.Second);
|
||||
|
||||
|
||||
var entity = entities.FirstOrDefault(s =>
|
||||
s.ShiftStart > s.ShiftEnd ^
|
||||
(time >= s.ShiftStart && time < s.ShiftEnd)
|
||||
);
|
||||
|
||||
|
||||
return entity?.Driller.Adapt<DrillerDto>();
|
||||
}
|
||||
|
||||
private IQueryable<Schedule> BuildQuery(int idWell, DateTime workTime)
|
||||
{
|
||||
var hoursOffset = wellService.GetTimezone(idWell).Hours;
|
||||
|
||||
return GetQuery().Where(s => s.IdWell == idWell
|
||||
&& s.DrillStart <= workTime.ToUtcDateTimeOffset(hoursOffset)
|
||||
&& s.DrillEnd >= workTime.ToUtcDateTimeOffset(hoursOffset));
|
||||
}
|
||||
|
||||
protected override Schedule Convert(ScheduleDto dto)
|
||||
{
|
||||
var hoursOffset = wellService.GetTimezone(dto.IdWell).Hours;
|
||||
|
@ -1,53 +1,65 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudDb.Model.WITS;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AsbCloudInfrastructure.Repository
|
||||
namespace AsbCloudInfrastructure.Repository;
|
||||
|
||||
public class TrajectoryFactRepository : ITrajectoryFactRepository
|
||||
{
|
||||
internal class TrajectoryFactRepository : ITrajectoryFactRepository
|
||||
{
|
||||
private readonly IAsbCloudDbContext db;
|
||||
private readonly IWellService wellService;
|
||||
public TrajectoryFactRepository(IAsbCloudDbContext db, IWellService wellService)
|
||||
{
|
||||
this.db = db;
|
||||
this.wellService = wellService;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TrajectoryGeoFactDto>> GetAsync(int idWell, CancellationToken token)
|
||||
{
|
||||
var well = await wellService.GetOrDefaultAsync(idWell,
|
||||
token);
|
||||
|
||||
if (well is null)
|
||||
return Enumerable.Empty<TrajectoryGeoFactDto>();
|
||||
private readonly IAsbCloudDbContext dbContext;
|
||||
|
||||
var entities = await db.Record7
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdTelemetry == well.IdTelemetry)
|
||||
.Where(coord => coord.Deptsvym != null && coord.Svyinc != null && coord.Svyazc != null)
|
||||
.OrderBy(e => e.Deptsvym)
|
||||
.ToArrayAsync(token);
|
||||
public TrajectoryFactRepository(IAsbCloudDbContext dbContext)
|
||||
{
|
||||
this.dbContext = dbContext;
|
||||
}
|
||||
|
||||
var result = entities
|
||||
.Select(coord => new TrajectoryGeoFactDto
|
||||
{
|
||||
IdWell = idWell,
|
||||
AzimuthMagnetic = coord.Svymtf,
|
||||
VerticalDepth = coord.Deptsvyv,
|
||||
WellboreDepth = coord.Deptsvym!.Value,
|
||||
ZenithAngle = coord.Svyinc!.Value,
|
||||
AzimuthGeo = coord.Svyazc!.Value
|
||||
})
|
||||
.ToArray();
|
||||
public async Task<IEnumerable<TrajectoryGeoFactDto>> GetAsync(TrajectoryGeoFactRequest request, CancellationToken token) =>
|
||||
(await BuildQuery(request)
|
||||
.Where(coord => coord.Deptsvym.HasValue &&
|
||||
coord.Svyinc.HasValue &&
|
||||
coord.Svyazc.HasValue)
|
||||
.AsNoTracking()
|
||||
.ToArrayAsync(token))
|
||||
.Select(r => new TrajectoryGeoFactDto
|
||||
{
|
||||
IdWell = request.IdWell,
|
||||
AzimuthMagnetic = r.Svymtf,
|
||||
VerticalDepth = r.Deptsvyv,
|
||||
WellboreDepth = r.Deptsvym!.Value,
|
||||
ZenithAngle = r.Svyinc!.Value,
|
||||
AzimuthGeo = r.Svyazc!.Value
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
public Task<IEnumerable<TrajectoryGeoFactDto>> GetAsync(int idWell, CancellationToken token) =>
|
||||
GetAsync(new TrajectoryGeoFactRequest
|
||||
{
|
||||
IdWell = idWell
|
||||
}, token);
|
||||
|
||||
private IQueryable<Record7> BuildQuery(TrajectoryGeoFactRequest request)
|
||||
{
|
||||
var well = dbContext.Wells.SingleOrDefault(w => w.Id == request.IdWell);
|
||||
|
||||
if (well is null)
|
||||
throw new ArgumentInvalidException($"Скважина с Id: {request.IdWell} не найдена", nameof(request.IdWell));
|
||||
|
||||
var query = dbContext.Record7.Where(r => r.IdTelemetry == well.IdTelemetry)
|
||||
.Where(x => x.IdTelemetry == well.IdTelemetry);
|
||||
|
||||
if (request.GeDate.HasValue)
|
||||
query = query.Where(r => r.DateTime >= request.GeDate.Value);
|
||||
|
||||
if (request.LtDate.HasValue)
|
||||
query = query.Where(r => r.DateTime <= request.LtDate.Value);
|
||||
|
||||
return query.OrderBy(e => e.Deptsvym);
|
||||
}
|
||||
}
|
@ -149,7 +149,7 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr
|
||||
.SetVal(modeData.UsageFact);
|
||||
|
||||
sheet.Cell(row, columnRop)
|
||||
.SetVal(modeData.Rop);
|
||||
.SetVal(modeData.RopFact);
|
||||
|
||||
return row + 1;
|
||||
}
|
||||
|
@ -171,6 +171,7 @@ public class ProcessMapReportWellDrillingService : IProcessMapReportWellDrilling
|
||||
var result = new ProcessMapReportWellDrillingDto
|
||||
{
|
||||
IdWell = processMapByMode?.IdWell ?? processMapFirst.IdWell,
|
||||
IdMode = processMapByMode?.IdMode,
|
||||
IdWellSectionType = idWellSectionType,
|
||||
WellSectionTypeName = sectionTypes[idWellSectionType],
|
||||
|
||||
@ -188,7 +189,9 @@ public class ProcessMapReportWellDrillingService : IProcessMapReportWellDrilling
|
||||
TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan),
|
||||
SpeedLimit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan),
|
||||
|
||||
Rop = telemetryStat.Rop,
|
||||
RopPlan = processMapByMode?.RopPlan,
|
||||
RopFact = telemetryStat.Rop,
|
||||
|
||||
UsagePlan = processMapByMode?.UsageSaub ?? telemetryStat.UsagePredictPlan,
|
||||
UsageFact = telemetryStat.UsageSaub,
|
||||
};
|
||||
|
@ -186,17 +186,6 @@ internal static class XLExtentions
|
||||
return style;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Костыль исправляющий проблему в библиотеке IXLRange Range(this IXLWorksheet, IXLAddress, IXLAddress) с кастингом IXLAddress к XLAddress.
|
||||
/// </summary>
|
||||
/// <param name="sheet"></param>
|
||||
/// <param name="begin"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <returns></returns>
|
||||
internal static IXLRange _Range(this IXLWorksheet sheet, CellAddress begin, CellAddress end)
|
||||
=> sheet.Range(begin.RowNumber, begin.ColumnNumber, end.RowNumber, end.ColumnNumber);
|
||||
|
||||
|
||||
internal static T? GetCellValue<T>(this IXLCell cell)
|
||||
{
|
||||
try
|
||||
|
Loading…
Reference in New Issue
Block a user