forked from ddrilling/AsbCloudServer
Небольшой рефакторинг
1. Фикс неймингов свойств + удаление не используемых свойств 2. Правки запросов 3. Добавлена дата последнего редактирования в базовый класс редактируемых блоков 4. Добавлены проверки в тесты
This commit is contained in:
parent
b6edb0faff
commit
87c8c84660
@ -1,3 +1,5 @@
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Data.DailyReport.Blocks;
|
||||
|
||||
/// <summary>
|
||||
@ -9,4 +11,9 @@ public abstract class EditableBlock
|
||||
/// Id пользователя внесшего изменения в блок
|
||||
/// </summary>
|
||||
public int IdUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата обновления блока
|
||||
/// </summary>
|
||||
public DateTime? DateLastUpdate { get; set; }
|
||||
}
|
@ -11,12 +11,12 @@ public class SubsystemBlockDto : EditableBlock
|
||||
/// <summary>
|
||||
/// Длина ствола скважины
|
||||
/// </summary>
|
||||
public double? WellBoreDepth { get; set; }
|
||||
public double? WellBore { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Кол-во замеров за сутки
|
||||
/// </summary>
|
||||
public double? MeasurementsPerDaily { get; set; }
|
||||
public double? MeasurementsPerDay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Общая плановая мех. скорость
|
||||
@ -29,7 +29,7 @@ public class SubsystemBlockDto : EditableBlock
|
||||
public string? Comment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Модули
|
||||
/// Подсистемы
|
||||
/// </summary>
|
||||
public IEnumerable<SubsystemRecordDto> Modules { get; set; } = Enumerable.Empty<SubsystemRecordDto>();
|
||||
public IEnumerable<SubsystemRecordDto> Subsystems { get; set; } = Enumerable.Empty<SubsystemRecordDto>();
|
||||
}
|
@ -33,7 +33,7 @@ public class TimeBalanceBlockDto : EditableBlock
|
||||
/// <summary>
|
||||
/// Кол-во наращиваний за сутки
|
||||
/// </summary>
|
||||
public double? CountWellOperationSlipsTime { get; set; }
|
||||
public double? WellOperationSlipsTimeCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Операции на скважине
|
||||
|
@ -11,7 +11,7 @@ public class WellOperationBlockDto
|
||||
/// <summary>
|
||||
/// Продолжительность бурения за секцию
|
||||
/// </summary>
|
||||
public double DurationHoursDrillingPerSection { get; set; }
|
||||
public double SectionDrillingHours { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Операции проводимые на скважине
|
||||
|
@ -7,105 +7,92 @@ namespace AsbCloudApp.Data.ProcessMaps.Report;
|
||||
/// </summary>
|
||||
public class ProcessMapReportWellDrillingDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Идентификатор скважины
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Режим работы
|
||||
/// 0 - ручной
|
||||
/// 1 - ротор
|
||||
/// 2 - слайд
|
||||
/// Идентификатор скважины
|
||||
/// </summary>
|
||||
public int? IdMode { get; set; }
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id секции скважины
|
||||
/// </summary>
|
||||
public int IdWellSectionType { get; set; }
|
||||
/// Id секции скважины
|
||||
/// </summary>
|
||||
public int IdWellSectionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Название секции скважины
|
||||
/// </summary>
|
||||
public string WellSectionTypeName { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Название секции скважины
|
||||
/// </summary>
|
||||
public string WellSectionTypeName { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Глубина по стволу от, м
|
||||
/// <para>
|
||||
/// на начало интервала
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public double DepthStart { get; set; }
|
||||
/// <summary>
|
||||
/// Глубина по стволу от, м
|
||||
/// <para>
|
||||
/// на начало интервала
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public double DepthStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Глубина по стволу до, м
|
||||
/// <para>
|
||||
/// на конец интервала
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public double DepthEnd { get; set; }
|
||||
/// <summary>
|
||||
/// Глубина по стволу до, м
|
||||
/// <para>
|
||||
/// на конец интервала
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public double DepthEnd { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата/ время
|
||||
/// <para>
|
||||
/// на начало интервала
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public DateTime DateStart { get; set; }
|
||||
/// <summary>
|
||||
/// Дата/ время
|
||||
/// <para>
|
||||
/// на начало интервала
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public DateTime DateStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Время мех бурения, ч
|
||||
/// </summary>
|
||||
public double MechDrillingHours { get; set; }
|
||||
/// <summary>
|
||||
/// Время мех бурения, ч
|
||||
/// </summary>
|
||||
public double MechDrillingHours { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Режим бурения (Ротор/слайд/ручной)
|
||||
/// </summary>
|
||||
public string DrillingMode { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Режим бурения (Ротор/слайд/ручной)
|
||||
/// </summary>
|
||||
public string DrillingMode { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Проходка, м
|
||||
/// </summary>
|
||||
public double? DeltaDepth { get; set; }
|
||||
/// <summary>
|
||||
/// Проходка, м
|
||||
/// </summary>
|
||||
public double? DeltaDepth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Перепад давления, атм
|
||||
/// </summary>
|
||||
public ProcessMapReportWellDrillingParamsDto PressureDiff { get; set; } = new();
|
||||
/// <summary>
|
||||
/// Перепад давления, атм
|
||||
/// </summary>
|
||||
public ProcessMapReportWellDrillingParamsDto PressureDiff { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Нагрузка, т
|
||||
/// </summary>
|
||||
public ProcessMapReportWellDrillingParamsDto AxialLoad { get; set; } = new();
|
||||
/// <summary>
|
||||
/// Нагрузка, т
|
||||
/// </summary>
|
||||
public ProcessMapReportWellDrillingParamsDto AxialLoad { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Момент на ВСП, кНхМ
|
||||
/// </summary>
|
||||
public ProcessMapReportWellDrillingParamsDto TopDriveTorque { get; set; } = new();
|
||||
/// <summary>
|
||||
/// Момент на ВСП, кНхМ
|
||||
/// </summary>
|
||||
public ProcessMapReportWellDrillingParamsDto TopDriveTorque { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Ограничение скорости, м/ч
|
||||
/// </summary>
|
||||
public ProcessMapReportWellDrillingParamsDto SpeedLimit { get; set; } = new();
|
||||
/// <summary>
|
||||
/// Ограничение скорости, м/ч
|
||||
/// </summary>
|
||||
public ProcessMapReportWellDrillingParamsDto SpeedLimit { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// Процент использования системы АПД план, %
|
||||
/// </summary>
|
||||
public double UsagePlan { get; set; }
|
||||
/// <summary>
|
||||
/// Процент использования системы АПД план, %
|
||||
/// </summary>
|
||||
public double UsagePlan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Процент использования системы АПД факт, %
|
||||
/// </summary>
|
||||
public double UsageFact { get; set; }
|
||||
/// <summary>
|
||||
/// Процент использования системы АПД факт, %
|
||||
/// </summary>
|
||||
public double UsageFact { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Плановая механическая скорость, м/ч
|
||||
/// </summary>
|
||||
public double? RopPlan { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Фактическая механическая скорость, м/ч
|
||||
/// </summary>
|
||||
public double? RopFact { get; set; }
|
||||
/// <summary>
|
||||
/// Механическая скорость, м/ч
|
||||
/// </summary>
|
||||
public PlanFactDto<double?> Rop { get; set; }
|
||||
}
|
@ -20,5 +20,5 @@ public class TrajectoryGeoFactRequest : RequestBase
|
||||
/// <summary>
|
||||
/// Меньше или равно дате
|
||||
/// </summary>
|
||||
public DateTime? LtDate { get; set; }
|
||||
public DateTime? LeDate { get; set; }
|
||||
}
|
@ -41,10 +41,10 @@ public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyRep
|
||||
var query = GetQuery().Where(d => d.IdWell == idWell);
|
||||
|
||||
if (request.GeDate.HasValue)
|
||||
query = query.Where(d => d.DateStart <= request.GeDate.Value.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc));
|
||||
query = query.Where(d => d.DateStart >= request.GeDate.Value.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc));
|
||||
|
||||
if (request.LeDate.HasValue)
|
||||
query = query.Where(d => d.DateStart >= request.LeDate.Value.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc));
|
||||
query = query.Where(d => d.DateStart <= request.LeDate.Value.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc));
|
||||
|
||||
if (request.SortFields?.Any() == true)
|
||||
{
|
||||
@ -52,10 +52,14 @@ public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyRep
|
||||
}
|
||||
|
||||
var entities = await query
|
||||
.Skip(skip)
|
||||
.Take(take)
|
||||
.AsNoTracking()
|
||||
.ToArrayAsync(cancellationToken);
|
||||
|
||||
return entities.Skip(skip).Take(take).Select(Convert);
|
||||
var dtos = entities.Select(Convert);
|
||||
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public async Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateTime dateStart, CancellationToken cancellationToken)
|
||||
|
@ -56,10 +56,12 @@ namespace AsbCloudInfrastructure.Repository
|
||||
private IQueryable<Schedule> BuildQuery(int idWell, DateTime workTime)
|
||||
{
|
||||
var hoursOffset = wellService.GetTimezone(idWell).Hours;
|
||||
|
||||
var workTimeDateTime = workTime.ToUtcDateTimeOffset(hoursOffset);
|
||||
|
||||
return GetQuery().Where(s => s.IdWell == idWell
|
||||
&& s.DrillStart <= workTime.ToUtcDateTimeOffset(hoursOffset)
|
||||
&& s.DrillEnd >= workTime.ToUtcDateTimeOffset(hoursOffset));
|
||||
&& s.DrillStart <= workTimeDateTime
|
||||
&& s.DrillEnd >= workTimeDateTime);
|
||||
}
|
||||
|
||||
protected override Schedule Convert(ScheduleDto dto)
|
||||
|
@ -57,8 +57,8 @@ public class TrajectoryFactRepository : ITrajectoryFactRepository
|
||||
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);
|
||||
if (request.LeDate.HasValue)
|
||||
query = query.Where(r => r.DateTime <= request.LeDate.Value);
|
||||
|
||||
return query.OrderBy(e => e.Deptsvym);
|
||||
}
|
||||
|
@ -70,13 +70,13 @@ public class DailyReportExportService : IDailyReportExportService
|
||||
|
||||
private const string cellTimeBalanceBlockSection = "C60";
|
||||
private const string cellTimeBalanceBlockWellDepthPlan = "C61";
|
||||
private const string cellDurationHoursDrillingPerSection = "F77";
|
||||
private const string cellSectionDrillingHours = "F77";
|
||||
private const string cellTimeBalanceBlockWellDepthFact = "F78";
|
||||
private const string cellTimeBalanceBlockCountWellOperationSlipsTime = "F79";
|
||||
private const string cellTimeBalanceBlockWellOperationSlipsTimeCount = "F79";
|
||||
|
||||
private const string cellSubsystemComment = "D35";
|
||||
private const string cellSubsystemMeasurementsPerDaily = "F80";
|
||||
private const string cellSubsystemWellBoreDepth = "C9";
|
||||
private const string cellSubsystemMeasurementsPerDay = "F80";
|
||||
private const string cellSubsystemWellBore = "C9";
|
||||
private const string cellSubsystemTotalRopPlan = "E70";
|
||||
|
||||
private const string cellSignDrillingMaster = "C84";
|
||||
@ -175,17 +175,17 @@ public class DailyReportExportService : IDailyReportExportService
|
||||
sheet.Cell(cellTimeBalanceBlockSection).Value = timeBalanceBlock.SectionName;
|
||||
sheet.Cell(cellTimeBalanceBlockWellDepthPlan).Value = timeBalanceBlock.WellDepthPlan;
|
||||
sheet.Cell(cellTimeBalanceBlockWellDepthFact).Value = timeBalanceBlock.WellDepthFact;
|
||||
sheet.Cell(cellTimeBalanceBlockCountWellOperationSlipsTime).Value = timeBalanceBlock.CountWellOperationSlipsTime;
|
||||
sheet.Cell(cellTimeBalanceBlockWellOperationSlipsTimeCount).Value = timeBalanceBlock.WellOperationSlipsTimeCount;
|
||||
}
|
||||
|
||||
private static void AddSubsystemBlockToSheet(IXLWorksheet sheet, SubsystemBlockDto subsystemBlock)
|
||||
{
|
||||
var groupedModules = subsystemBlock.Modules.OrderBy(m => m.SubsystemName)
|
||||
var groupedSubsystems = subsystemBlock.Subsystems.OrderBy(m => m.SubsystemName)
|
||||
.GroupBy(m => m.SubsystemName);
|
||||
|
||||
var rowСurrent = rowStartSubsystemBlock;
|
||||
|
||||
foreach (var groupedModule in groupedModules)
|
||||
foreach (var groupedModule in groupedSubsystems)
|
||||
{
|
||||
var useSubsystemPerDay = groupedModule.FirstOrDefault(m => m.IdTimeInterval == 1);
|
||||
var useSubsystemPerWell = groupedModule.FirstOrDefault(m => m.IdTimeInterval == 2);
|
||||
@ -204,8 +204,8 @@ public class DailyReportExportService : IDailyReportExportService
|
||||
}
|
||||
|
||||
sheet.Cell(cellSubsystemComment).Value = subsystemBlock.Comment;
|
||||
sheet.Cell(cellSubsystemMeasurementsPerDaily).Value = subsystemBlock.MeasurementsPerDaily;
|
||||
sheet.Cell(cellSubsystemWellBoreDepth).Value = subsystemBlock.WellBoreDepth;
|
||||
sheet.Cell(cellSubsystemMeasurementsPerDay).Value = subsystemBlock.MeasurementsPerDay;
|
||||
sheet.Cell(cellSubsystemWellBore).Value = subsystemBlock.WellBore;
|
||||
sheet.Cell(cellSubsystemTotalRopPlan).Value = subsystemBlock.TotalRopPlan;
|
||||
}
|
||||
|
||||
@ -242,7 +242,7 @@ public class DailyReportExportService : IDailyReportExportService
|
||||
|
||||
private static void AddFactWellOperationBlockToSheet(IXLWorksheet sheet, WellOperationBlockDto factWellOperationBlock)
|
||||
{
|
||||
sheet.Cell(cellDurationHoursDrillingPerSection).Value = factWellOperationBlock.DurationHoursDrillingPerSection;
|
||||
sheet.Cell(cellSectionDrillingHours).Value = factWellOperationBlock.SectionDrillingHours;
|
||||
|
||||
foreach (var factOperation in factWellOperationBlock.WellOperations.OrderBy(w => w.CategoryName))
|
||||
{
|
||||
|
@ -74,7 +74,8 @@ public class DailyReportService : IDailyReportService
|
||||
?? throw new ArgumentInvalidException(nameof(idDailyReport), $"Суточный отчёт с Id: {idDailyReport} не найден");
|
||||
|
||||
editableBlock.IdUser = idUser;
|
||||
|
||||
|
||||
editableBlock.DateLastUpdate = DateTime.UtcNow;
|
||||
dailyReport.DateLastUpdate = DateTime.UtcNow;
|
||||
|
||||
switch (editableBlock)
|
||||
@ -246,7 +247,7 @@ public class DailyReportService : IDailyReportService
|
||||
dailyReport.TimeBalanceBlock.SectionName = wellOperationRepository.GetSectionTypes()
|
||||
.FirstOrDefault(s => s.Id == dailyReport.TimeBalanceBlock.IdSection)?.Caption;
|
||||
|
||||
dailyReport.TimeBalanceBlock.CountWellOperationSlipsTime = (await detectedOperationService.GetAsync(
|
||||
dailyReport.TimeBalanceBlock.WellOperationSlipsTimeCount = (await detectedOperationService.GetAsync(
|
||||
new DetectedOperationRequest
|
||||
{
|
||||
IdsCategories = new[] { idWellOperationSlipsTime },
|
||||
@ -267,7 +268,7 @@ public class DailyReportService : IDailyReportService
|
||||
{
|
||||
IdWell = dailyReport.IdWell,
|
||||
GeDate = dailyReport.DateStart,
|
||||
LtDate = dailyReport.DateEnd
|
||||
LeDate = dailyReport.DateEnd
|
||||
}, cancellationToken)).LastOrDefault();
|
||||
|
||||
dailyReport.TrajectoryBlock = new TrajectoryBlockDto
|
||||
@ -294,9 +295,9 @@ public class DailyReportService : IDailyReportService
|
||||
{
|
||||
dailyReport.SubsystemBlock ??= new SubsystemBlockDto();
|
||||
|
||||
dailyReport.SubsystemBlock.Modules = await GetModulesAsync();
|
||||
dailyReport.SubsystemBlock.Subsystems = await GetSubsystemsAsync();
|
||||
|
||||
async Task<IEnumerable<SubsystemRecordDto>> GetModulesAsync()
|
||||
async Task<IEnumerable<SubsystemRecordDto>> GetSubsystemsAsync()
|
||||
{
|
||||
var modules = new List<SubsystemRecordDto>();
|
||||
|
||||
@ -327,8 +328,8 @@ public class DailyReportService : IDailyReportService
|
||||
modules.AddRange(statSubsystemOperationTimePerDaily);
|
||||
modules.AddRange(statSubsystemOperationTimePerWell);
|
||||
|
||||
if (dailyReport.SubsystemBlock?.Modules != null && dailyReport.SubsystemBlock.Modules.Any())
|
||||
modules.AddRange(dailyReport.SubsystemBlock.Modules);
|
||||
if (dailyReport.SubsystemBlock?.Subsystems != null && dailyReport.SubsystemBlock.Subsystems.Any())
|
||||
modules.AddRange(dailyReport.SubsystemBlock.Subsystems);
|
||||
|
||||
return modules;
|
||||
}
|
||||
@ -338,8 +339,7 @@ public class DailyReportService : IDailyReportService
|
||||
{
|
||||
dailyReport.ProcessMapWellDrillingBlock = (await processMapReportWellDrillingService.GetAsync(dailyReport.IdWell,
|
||||
cancellationToken)).Where(p => p.DateStart >= dailyReport.DateStart &&
|
||||
p.DateStart <= dailyReport.DateEnd &&
|
||||
p.IdMode.HasValue)
|
||||
p.DateStart <= dailyReport.DateEnd)
|
||||
.GroupBy(p => p.DrillingMode)
|
||||
.Select(g => new ProcessMapWellDrillingRecordDto
|
||||
{
|
||||
@ -347,8 +347,8 @@ public class DailyReportService : IDailyReportService
|
||||
WellBoreDepth = g.Sum(p => p.DeltaDepth),
|
||||
Rop = new PlanFactDto<double?>
|
||||
{
|
||||
Plan = g.Sum(p => p.RopPlan),
|
||||
Fact = g.Sum(p => p.RopFact)
|
||||
Plan = g.Sum(p => p.Rop.Plan),
|
||||
Fact = g.Sum(p => p.Rop.Fact)
|
||||
},
|
||||
MechDrillingHours = g.Sum(p => p.MechDrillingHours)
|
||||
});
|
||||
@ -367,7 +367,7 @@ public class DailyReportService : IDailyReportService
|
||||
DurationHours = g.Sum(o => o.DurationHours)
|
||||
}),
|
||||
|
||||
DurationHoursDrillingPerSection = factWellOperations
|
||||
SectionDrillingHours = factWellOperations
|
||||
.Where(o => o.IdParentCategory is idWellOperationCategoryDrilling)
|
||||
.Sum(o => o.DurationHours)
|
||||
};
|
||||
|
@ -149,7 +149,7 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr
|
||||
.SetVal(modeData.UsageFact);
|
||||
|
||||
sheet.Cell(row, columnRop)
|
||||
.SetVal(modeData.RopFact);
|
||||
.SetVal(modeData.Rop.Fact);
|
||||
|
||||
return row + 1;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.ProcessMaps;
|
||||
using AsbCloudApp.Data.ProcessMaps.Report;
|
||||
using AsbCloudApp.Data.SAUB;
|
||||
@ -171,7 +172,6 @@ public class ProcessMapReportWellDrillingService : IProcessMapReportWellDrilling
|
||||
var result = new ProcessMapReportWellDrillingDto
|
||||
{
|
||||
IdWell = processMapByMode?.IdWell ?? processMapFirst.IdWell,
|
||||
IdMode = processMapByMode?.IdMode,
|
||||
IdWellSectionType = idWellSectionType,
|
||||
WellSectionTypeName = sectionTypes[idWellSectionType],
|
||||
|
||||
@ -189,9 +189,12 @@ public class ProcessMapReportWellDrillingService : IProcessMapReportWellDrilling
|
||||
TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan),
|
||||
SpeedLimit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan),
|
||||
|
||||
RopPlan = processMapByMode?.RopPlan,
|
||||
RopFact = telemetryStat.Rop,
|
||||
|
||||
Rop = new PlanFactDto<double?>
|
||||
{
|
||||
Plan = processMapByMode?.RopPlan,
|
||||
Fact = telemetryStat.Rop
|
||||
},
|
||||
|
||||
UsagePlan = processMapByMode?.UsageSaub ?? telemetryStat.UsagePredictPlan,
|
||||
UsageFact = telemetryStat.UsageSaub,
|
||||
};
|
||||
|
@ -102,11 +102,11 @@ public class DailyReportServiceTest
|
||||
var fakeSubsystemBlock = new SubsystemBlockDto
|
||||
{
|
||||
IdUser = idUser,
|
||||
WellBoreDepth = 999,
|
||||
MeasurementsPerDaily = 999,
|
||||
WellBore = 999,
|
||||
MeasurementsPerDay = 999,
|
||||
TotalRopPlan = 999,
|
||||
Comment = "Увеличить обороты",
|
||||
Modules = new[]
|
||||
Subsystems = new[]
|
||||
{
|
||||
new SubsystemRecordDto
|
||||
{
|
||||
@ -123,6 +123,7 @@ public class DailyReportServiceTest
|
||||
var result = await dailyReportService.UpdateBlockAsync(idDailyReport, idUser, fakeSubsystemBlock, CancellationToken.None);
|
||||
|
||||
//assert
|
||||
Assert.NotNull(fakeSubsystemBlock.DateLastUpdate);
|
||||
Assert.NotNull(fakeDailyReport.DateLastUpdate);
|
||||
Assert.Equal(fakeDailyReport.SubsystemBlock, fakeSubsystemBlock);
|
||||
Assert.Equal(idDailyReport, result);
|
||||
@ -153,6 +154,7 @@ public class DailyReportServiceTest
|
||||
var result = await dailyReportService.UpdateBlockAsync(idDailyReport, idUser, fakeSignBlock, CancellationToken.None);
|
||||
|
||||
//assert
|
||||
Assert.NotNull(fakeSignBlock.DateLastUpdate);
|
||||
Assert.NotNull(fakeDailyReport.DateLastUpdate);
|
||||
Assert.Equal(fakeDailyReport.SignBlock, fakeSignBlock);
|
||||
Assert.Equal(idDailyReport, result);
|
||||
@ -187,6 +189,7 @@ public class DailyReportServiceTest
|
||||
var result = await dailyReportService.UpdateBlockAsync(idDailyReport, idUser, fakeTimeBalanceBlock, CancellationToken.None);
|
||||
|
||||
//assert
|
||||
Assert.NotNull(fakeTimeBalanceBlock.DateLastUpdate);
|
||||
Assert.NotNull(fakeDailyReport.DateLastUpdate);
|
||||
Assert.Equal(fakeDailyReport.TimeBalanceBlock, fakeTimeBalanceBlock);
|
||||
Assert.Equal(idDailyReport, result);
|
||||
|
@ -117,9 +117,9 @@ public class DailyReportController : ControllerBase
|
||||
{
|
||||
var validSubsystemNames = new[] { "АвтоСПО", "Автопроработка" };
|
||||
|
||||
if (subsystemBlock.Modules.Any(m => !validSubsystemNames.Contains(m.SubsystemName)))
|
||||
throw new ArgumentInvalidException($"Возможно добавить модули только с именами {string.Join(", ", validSubsystemNames)}",
|
||||
nameof(subsystemBlock.Modules));
|
||||
if (subsystemBlock.Subsystems.Any(m => !validSubsystemNames.Contains(m.SubsystemName)))
|
||||
throw new ArgumentInvalidException($"Возможно добавить подсистемы с именами {string.Join(", ", validSubsystemNames)}",
|
||||
nameof(subsystemBlock.Subsystems));
|
||||
|
||||
return UpdateBlockAsync(idWell, idDailyReport, subsystemBlock, cancellationToken);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user