Небольшой рефакторинг

1. Фикс неймингов свойств + удаление не используемых свойств
2. Правки запросов
3. Добавлена дата последнего редактирования в базовый класс редактируемых блоков
4. Добавлены проверки в тесты
This commit is contained in:
Степанов Дмитрий 2023-11-09 15:01:29 +05:00
parent b6edb0faff
commit 87c8c84660
15 changed files with 136 additions and 130 deletions

View File

@ -1,3 +1,5 @@
using System;
namespace AsbCloudApp.Data.DailyReport.Blocks; namespace AsbCloudApp.Data.DailyReport.Blocks;
/// <summary> /// <summary>
@ -9,4 +11,9 @@ public abstract class EditableBlock
/// Id пользователя внесшего изменения в блок /// Id пользователя внесшего изменения в блок
/// </summary> /// </summary>
public int IdUser { get; set; } public int IdUser { get; set; }
/// <summary>
/// Дата обновления блока
/// </summary>
public DateTime? DateLastUpdate { get; set; }
} }

View File

@ -11,12 +11,12 @@ public class SubsystemBlockDto : EditableBlock
/// <summary> /// <summary>
/// Длина ствола скважины /// Длина ствола скважины
/// </summary> /// </summary>
public double? WellBoreDepth { get; set; } public double? WellBore { get; set; }
/// <summary> /// <summary>
/// Кол-во замеров за сутки /// Кол-во замеров за сутки
/// </summary> /// </summary>
public double? MeasurementsPerDaily { get; set; } public double? MeasurementsPerDay { get; set; }
/// <summary> /// <summary>
/// Общая плановая мех. скорость /// Общая плановая мех. скорость
@ -29,7 +29,7 @@ public class SubsystemBlockDto : EditableBlock
public string? Comment { get; set; } public string? Comment { get; set; }
/// <summary> /// <summary>
/// Модули /// Подсистемы
/// </summary> /// </summary>
public IEnumerable<SubsystemRecordDto> Modules { get; set; } = Enumerable.Empty<SubsystemRecordDto>(); public IEnumerable<SubsystemRecordDto> Subsystems { get; set; } = Enumerable.Empty<SubsystemRecordDto>();
} }

View File

@ -33,7 +33,7 @@ public class TimeBalanceBlockDto : EditableBlock
/// <summary> /// <summary>
/// Кол-во наращиваний за сутки /// Кол-во наращиваний за сутки
/// </summary> /// </summary>
public double? CountWellOperationSlipsTime { get; set; } public double? WellOperationSlipsTimeCount { get; set; }
/// <summary> /// <summary>
/// Операции на скважине /// Операции на скважине

View File

@ -11,7 +11,7 @@ public class WellOperationBlockDto
/// <summary> /// <summary>
/// Продолжительность бурения за секцию /// Продолжительность бурения за секцию
/// </summary> /// </summary>
public double DurationHoursDrillingPerSection { get; set; } public double SectionDrillingHours { get; set; }
/// <summary> /// <summary>
/// Операции проводимые на скважине /// Операции проводимые на скважине

View File

@ -7,105 +7,92 @@ namespace AsbCloudApp.Data.ProcessMaps.Report;
/// </summary> /// </summary>
public class ProcessMapReportWellDrillingDto public class ProcessMapReportWellDrillingDto
{ {
/// <summary>
/// Идентификатор скважины
/// </summary>
public int IdWell { get; set; }
/// <summary> /// <summary>
/// Режим работы /// Идентификатор скважины
/// 0 - ручной
/// 1 - ротор
/// 2 - слайд
/// </summary> /// </summary>
public int? IdMode { get; set; } public int IdWell { get; set; }
/// <summary> /// <summary>
/// Id секции скважины /// Id секции скважины
/// </summary> /// </summary>
public int IdWellSectionType { get; set; } public int IdWellSectionType { get; set; }
/// <summary> /// <summary>
/// Название секции скважины /// Название секции скважины
/// </summary> /// </summary>
public string WellSectionTypeName { get; set; } = null!; public string WellSectionTypeName { get; set; } = null!;
/// <summary> /// <summary>
/// Глубина по стволу от, м /// Глубина по стволу от, м
/// <para> /// <para>
/// на начало интервала /// на начало интервала
/// </para> /// </para>
/// </summary> /// </summary>
public double DepthStart { get; set; } public double DepthStart { get; set; }
/// <summary> /// <summary>
/// Глубина по стволу до, м /// Глубина по стволу до, м
/// <para> /// <para>
/// на конец интервала /// на конец интервала
/// </para> /// </para>
/// </summary> /// </summary>
public double DepthEnd { get; set; } public double DepthEnd { get; set; }
/// <summary> /// <summary>
/// Дата/ время /// Дата/ время
/// <para> /// <para>
/// на начало интервала /// на начало интервала
/// </para> /// </para>
/// </summary> /// </summary>
public DateTime DateStart { get; set; } public DateTime DateStart { get; set; }
/// <summary> /// <summary>
/// Время мех бурения, ч /// Время мех бурения, ч
/// </summary> /// </summary>
public double MechDrillingHours { get; set; } public double MechDrillingHours { get; set; }
/// <summary> /// <summary>
/// Режим бурения (Ротор/слайд/ручной) /// Режим бурения (Ротор/слайд/ручной)
/// </summary> /// </summary>
public string DrillingMode { get; set; } = null!; public string DrillingMode { get; set; } = null!;
/// <summary> /// <summary>
/// Проходка, м /// Проходка, м
/// </summary> /// </summary>
public double? DeltaDepth { get; set; } public double? DeltaDepth { get; set; }
/// <summary> /// <summary>
/// Перепад давления, атм /// Перепад давления, атм
/// </summary> /// </summary>
public ProcessMapReportWellDrillingParamsDto PressureDiff { get; set; } = new(); public ProcessMapReportWellDrillingParamsDto PressureDiff { get; set; } = new();
/// <summary> /// <summary>
/// Нагрузка, т /// Нагрузка, т
/// </summary> /// </summary>
public ProcessMapReportWellDrillingParamsDto AxialLoad { get; set; } = new(); public ProcessMapReportWellDrillingParamsDto AxialLoad { get; set; } = new();
/// <summary> /// <summary>
/// Момент на ВСП, кНхМ /// Момент на ВСП, кНхМ
/// </summary> /// </summary>
public ProcessMapReportWellDrillingParamsDto TopDriveTorque { get; set; } = new(); public ProcessMapReportWellDrillingParamsDto TopDriveTorque { get; set; } = new();
/// <summary> /// <summary>
/// Ограничение скорости, м/ч /// Ограничение скорости, м/ч
/// </summary> /// </summary>
public ProcessMapReportWellDrillingParamsDto SpeedLimit { get; set; } = new(); public ProcessMapReportWellDrillingParamsDto SpeedLimit { get; set; } = new();
/// <summary> /// <summary>
/// Процент использования системы АПД план, % /// Процент использования системы АПД план, %
/// </summary> /// </summary>
public double UsagePlan { get; set; } public double UsagePlan { get; set; }
/// <summary> /// <summary>
/// Процент использования системы АПД факт, % /// Процент использования системы АПД факт, %
/// </summary> /// </summary>
public double UsageFact { get; set; } public double UsageFact { get; set; }
/// <summary> /// <summary>
/// Плановая механическая скорость, м/ч /// Механическая скорость, м/ч
/// </summary> /// </summary>
public double? RopPlan { get; set; } public PlanFactDto<double?> Rop { get; set; }
/// <summary>
/// Фактическая механическая скорость, м/ч
/// </summary>
public double? RopFact { get; set; }
} }

View File

@ -20,5 +20,5 @@ public class TrajectoryGeoFactRequest : RequestBase
/// <summary> /// <summary>
/// Меньше или равно дате /// Меньше или равно дате
/// </summary> /// </summary>
public DateTime? LtDate { get; set; } public DateTime? LeDate { get; set; }
} }

View File

@ -41,10 +41,10 @@ public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyRep
var query = GetQuery().Where(d => d.IdWell == idWell); var query = GetQuery().Where(d => d.IdWell == idWell);
if (request.GeDate.HasValue) 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) 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) if (request.SortFields?.Any() == true)
{ {
@ -52,10 +52,14 @@ public class DailyReportRepository : CrudRepositoryBase<DailyReportDto, DailyRep
} }
var entities = await query var entities = await query
.Skip(skip)
.Take(take)
.AsNoTracking() .AsNoTracking()
.ToArrayAsync(cancellationToken); .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) public async Task<DailyReportDto?> GetOrDefaultAsync(int idWell, DateTime dateStart, CancellationToken cancellationToken)

View File

@ -56,10 +56,12 @@ namespace AsbCloudInfrastructure.Repository
private IQueryable<Schedule> BuildQuery(int idWell, DateTime workTime) private IQueryable<Schedule> BuildQuery(int idWell, DateTime workTime)
{ {
var hoursOffset = wellService.GetTimezone(idWell).Hours; var hoursOffset = wellService.GetTimezone(idWell).Hours;
var workTimeDateTime = workTime.ToUtcDateTimeOffset(hoursOffset);
return GetQuery().Where(s => s.IdWell == idWell return GetQuery().Where(s => s.IdWell == idWell
&& s.DrillStart <= workTime.ToUtcDateTimeOffset(hoursOffset) && s.DrillStart <= workTimeDateTime
&& s.DrillEnd >= workTime.ToUtcDateTimeOffset(hoursOffset)); && s.DrillEnd >= workTimeDateTime);
} }
protected override Schedule Convert(ScheduleDto dto) protected override Schedule Convert(ScheduleDto dto)

View File

@ -57,8 +57,8 @@ public class TrajectoryFactRepository : ITrajectoryFactRepository
if (request.GeDate.HasValue) if (request.GeDate.HasValue)
query = query.Where(r => r.DateTime >= request.GeDate.Value); query = query.Where(r => r.DateTime >= request.GeDate.Value);
if (request.LtDate.HasValue) if (request.LeDate.HasValue)
query = query.Where(r => r.DateTime <= request.LtDate.Value); query = query.Where(r => r.DateTime <= request.LeDate.Value);
return query.OrderBy(e => e.Deptsvym); return query.OrderBy(e => e.Deptsvym);
} }

View File

@ -70,13 +70,13 @@ public class DailyReportExportService : IDailyReportExportService
private const string cellTimeBalanceBlockSection = "C60"; private const string cellTimeBalanceBlockSection = "C60";
private const string cellTimeBalanceBlockWellDepthPlan = "C61"; private const string cellTimeBalanceBlockWellDepthPlan = "C61";
private const string cellDurationHoursDrillingPerSection = "F77"; private const string cellSectionDrillingHours = "F77";
private const string cellTimeBalanceBlockWellDepthFact = "F78"; private const string cellTimeBalanceBlockWellDepthFact = "F78";
private const string cellTimeBalanceBlockCountWellOperationSlipsTime = "F79"; private const string cellTimeBalanceBlockWellOperationSlipsTimeCount = "F79";
private const string cellSubsystemComment = "D35"; private const string cellSubsystemComment = "D35";
private const string cellSubsystemMeasurementsPerDaily = "F80"; private const string cellSubsystemMeasurementsPerDay = "F80";
private const string cellSubsystemWellBoreDepth = "C9"; private const string cellSubsystemWellBore = "C9";
private const string cellSubsystemTotalRopPlan = "E70"; private const string cellSubsystemTotalRopPlan = "E70";
private const string cellSignDrillingMaster = "C84"; private const string cellSignDrillingMaster = "C84";
@ -175,17 +175,17 @@ public class DailyReportExportService : IDailyReportExportService
sheet.Cell(cellTimeBalanceBlockSection).Value = timeBalanceBlock.SectionName; sheet.Cell(cellTimeBalanceBlockSection).Value = timeBalanceBlock.SectionName;
sheet.Cell(cellTimeBalanceBlockWellDepthPlan).Value = timeBalanceBlock.WellDepthPlan; sheet.Cell(cellTimeBalanceBlockWellDepthPlan).Value = timeBalanceBlock.WellDepthPlan;
sheet.Cell(cellTimeBalanceBlockWellDepthFact).Value = timeBalanceBlock.WellDepthFact; 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) 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); .GroupBy(m => m.SubsystemName);
var rowСurrent = rowStartSubsystemBlock; var rowСurrent = rowStartSubsystemBlock;
foreach (var groupedModule in groupedModules) foreach (var groupedModule in groupedSubsystems)
{ {
var useSubsystemPerDay = groupedModule.FirstOrDefault(m => m.IdTimeInterval == 1); var useSubsystemPerDay = groupedModule.FirstOrDefault(m => m.IdTimeInterval == 1);
var useSubsystemPerWell = groupedModule.FirstOrDefault(m => m.IdTimeInterval == 2); var useSubsystemPerWell = groupedModule.FirstOrDefault(m => m.IdTimeInterval == 2);
@ -204,8 +204,8 @@ public class DailyReportExportService : IDailyReportExportService
} }
sheet.Cell(cellSubsystemComment).Value = subsystemBlock.Comment; sheet.Cell(cellSubsystemComment).Value = subsystemBlock.Comment;
sheet.Cell(cellSubsystemMeasurementsPerDaily).Value = subsystemBlock.MeasurementsPerDaily; sheet.Cell(cellSubsystemMeasurementsPerDay).Value = subsystemBlock.MeasurementsPerDay;
sheet.Cell(cellSubsystemWellBoreDepth).Value = subsystemBlock.WellBoreDepth; sheet.Cell(cellSubsystemWellBore).Value = subsystemBlock.WellBore;
sheet.Cell(cellSubsystemTotalRopPlan).Value = subsystemBlock.TotalRopPlan; sheet.Cell(cellSubsystemTotalRopPlan).Value = subsystemBlock.TotalRopPlan;
} }
@ -242,7 +242,7 @@ public class DailyReportExportService : IDailyReportExportService
private static void AddFactWellOperationBlockToSheet(IXLWorksheet sheet, WellOperationBlockDto factWellOperationBlock) 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)) foreach (var factOperation in factWellOperationBlock.WellOperations.OrderBy(w => w.CategoryName))
{ {

View File

@ -74,7 +74,8 @@ public class DailyReportService : IDailyReportService
?? throw new ArgumentInvalidException(nameof(idDailyReport), $"Суточный отчёт с Id: {idDailyReport} не найден"); ?? throw new ArgumentInvalidException(nameof(idDailyReport), $"Суточный отчёт с Id: {idDailyReport} не найден");
editableBlock.IdUser = idUser; editableBlock.IdUser = idUser;
editableBlock.DateLastUpdate = DateTime.UtcNow;
dailyReport.DateLastUpdate = DateTime.UtcNow; dailyReport.DateLastUpdate = DateTime.UtcNow;
switch (editableBlock) switch (editableBlock)
@ -246,7 +247,7 @@ public class DailyReportService : IDailyReportService
dailyReport.TimeBalanceBlock.SectionName = wellOperationRepository.GetSectionTypes() dailyReport.TimeBalanceBlock.SectionName = wellOperationRepository.GetSectionTypes()
.FirstOrDefault(s => s.Id == dailyReport.TimeBalanceBlock.IdSection)?.Caption; .FirstOrDefault(s => s.Id == dailyReport.TimeBalanceBlock.IdSection)?.Caption;
dailyReport.TimeBalanceBlock.CountWellOperationSlipsTime = (await detectedOperationService.GetAsync( dailyReport.TimeBalanceBlock.WellOperationSlipsTimeCount = (await detectedOperationService.GetAsync(
new DetectedOperationRequest new DetectedOperationRequest
{ {
IdsCategories = new[] { idWellOperationSlipsTime }, IdsCategories = new[] { idWellOperationSlipsTime },
@ -267,7 +268,7 @@ public class DailyReportService : IDailyReportService
{ {
IdWell = dailyReport.IdWell, IdWell = dailyReport.IdWell,
GeDate = dailyReport.DateStart, GeDate = dailyReport.DateStart,
LtDate = dailyReport.DateEnd LeDate = dailyReport.DateEnd
}, cancellationToken)).LastOrDefault(); }, cancellationToken)).LastOrDefault();
dailyReport.TrajectoryBlock = new TrajectoryBlockDto dailyReport.TrajectoryBlock = new TrajectoryBlockDto
@ -294,9 +295,9 @@ public class DailyReportService : IDailyReportService
{ {
dailyReport.SubsystemBlock ??= new SubsystemBlockDto(); 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>(); var modules = new List<SubsystemRecordDto>();
@ -327,8 +328,8 @@ public class DailyReportService : IDailyReportService
modules.AddRange(statSubsystemOperationTimePerDaily); modules.AddRange(statSubsystemOperationTimePerDaily);
modules.AddRange(statSubsystemOperationTimePerWell); modules.AddRange(statSubsystemOperationTimePerWell);
if (dailyReport.SubsystemBlock?.Modules != null && dailyReport.SubsystemBlock.Modules.Any()) if (dailyReport.SubsystemBlock?.Subsystems != null && dailyReport.SubsystemBlock.Subsystems.Any())
modules.AddRange(dailyReport.SubsystemBlock.Modules); modules.AddRange(dailyReport.SubsystemBlock.Subsystems);
return modules; return modules;
} }
@ -338,8 +339,7 @@ public class DailyReportService : IDailyReportService
{ {
dailyReport.ProcessMapWellDrillingBlock = (await processMapReportWellDrillingService.GetAsync(dailyReport.IdWell, dailyReport.ProcessMapWellDrillingBlock = (await processMapReportWellDrillingService.GetAsync(dailyReport.IdWell,
cancellationToken)).Where(p => p.DateStart >= dailyReport.DateStart && cancellationToken)).Where(p => p.DateStart >= dailyReport.DateStart &&
p.DateStart <= dailyReport.DateEnd && p.DateStart <= dailyReport.DateEnd)
p.IdMode.HasValue)
.GroupBy(p => p.DrillingMode) .GroupBy(p => p.DrillingMode)
.Select(g => new ProcessMapWellDrillingRecordDto .Select(g => new ProcessMapWellDrillingRecordDto
{ {
@ -347,8 +347,8 @@ public class DailyReportService : IDailyReportService
WellBoreDepth = g.Sum(p => p.DeltaDepth), WellBoreDepth = g.Sum(p => p.DeltaDepth),
Rop = new PlanFactDto<double?> Rop = new PlanFactDto<double?>
{ {
Plan = g.Sum(p => p.RopPlan), Plan = g.Sum(p => p.Rop.Plan),
Fact = g.Sum(p => p.RopFact) Fact = g.Sum(p => p.Rop.Fact)
}, },
MechDrillingHours = g.Sum(p => p.MechDrillingHours) MechDrillingHours = g.Sum(p => p.MechDrillingHours)
}); });
@ -367,7 +367,7 @@ public class DailyReportService : IDailyReportService
DurationHours = g.Sum(o => o.DurationHours) DurationHours = g.Sum(o => o.DurationHours)
}), }),
DurationHoursDrillingPerSection = factWellOperations SectionDrillingHours = factWellOperations
.Where(o => o.IdParentCategory is idWellOperationCategoryDrilling) .Where(o => o.IdParentCategory is idWellOperationCategoryDrilling)
.Sum(o => o.DurationHours) .Sum(o => o.DurationHours)
}; };

View File

@ -149,7 +149,7 @@ public class ProcessMapReportWellDrillingExportService : IProcessMapReportWellDr
.SetVal(modeData.UsageFact); .SetVal(modeData.UsageFact);
sheet.Cell(row, columnRop) sheet.Cell(row, columnRop)
.SetVal(modeData.RopFact); .SetVal(modeData.Rop.Fact);
return row + 1; return row + 1;
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using AsbCloudApp.Data;
using AsbCloudApp.Data.ProcessMaps; using AsbCloudApp.Data.ProcessMaps;
using AsbCloudApp.Data.ProcessMaps.Report; using AsbCloudApp.Data.ProcessMaps.Report;
using AsbCloudApp.Data.SAUB; using AsbCloudApp.Data.SAUB;
@ -171,7 +172,6 @@ public class ProcessMapReportWellDrillingService : IProcessMapReportWellDrilling
var result = new ProcessMapReportWellDrillingDto var result = new ProcessMapReportWellDrillingDto
{ {
IdWell = processMapByMode?.IdWell ?? processMapFirst.IdWell, IdWell = processMapByMode?.IdWell ?? processMapFirst.IdWell,
IdMode = processMapByMode?.IdMode,
IdWellSectionType = idWellSectionType, IdWellSectionType = idWellSectionType,
WellSectionTypeName = sectionTypes[idWellSectionType], WellSectionTypeName = sectionTypes[idWellSectionType],
@ -189,9 +189,12 @@ public class ProcessMapReportWellDrillingService : IProcessMapReportWellDrilling
TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan), TopDriveTorque = telemetryStat.RotorTorque.MakeParams(processMapByMode?.TopDriveTorque.Plan),
SpeedLimit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan), SpeedLimit = telemetryStat.BlockSpeed.MakeParams(processMapByMode?.RopPlan),
RopPlan = processMapByMode?.RopPlan, Rop = new PlanFactDto<double?>
RopFact = telemetryStat.Rop, {
Plan = processMapByMode?.RopPlan,
Fact = telemetryStat.Rop
},
UsagePlan = processMapByMode?.UsageSaub ?? telemetryStat.UsagePredictPlan, UsagePlan = processMapByMode?.UsageSaub ?? telemetryStat.UsagePredictPlan,
UsageFact = telemetryStat.UsageSaub, UsageFact = telemetryStat.UsageSaub,
}; };

View File

@ -102,11 +102,11 @@ public class DailyReportServiceTest
var fakeSubsystemBlock = new SubsystemBlockDto var fakeSubsystemBlock = new SubsystemBlockDto
{ {
IdUser = idUser, IdUser = idUser,
WellBoreDepth = 999, WellBore = 999,
MeasurementsPerDaily = 999, MeasurementsPerDay = 999,
TotalRopPlan = 999, TotalRopPlan = 999,
Comment = "Увеличить обороты", Comment = "Увеличить обороты",
Modules = new[] Subsystems = new[]
{ {
new SubsystemRecordDto new SubsystemRecordDto
{ {
@ -123,6 +123,7 @@ public class DailyReportServiceTest
var result = await dailyReportService.UpdateBlockAsync(idDailyReport, idUser, fakeSubsystemBlock, CancellationToken.None); var result = await dailyReportService.UpdateBlockAsync(idDailyReport, idUser, fakeSubsystemBlock, CancellationToken.None);
//assert //assert
Assert.NotNull(fakeSubsystemBlock.DateLastUpdate);
Assert.NotNull(fakeDailyReport.DateLastUpdate); Assert.NotNull(fakeDailyReport.DateLastUpdate);
Assert.Equal(fakeDailyReport.SubsystemBlock, fakeSubsystemBlock); Assert.Equal(fakeDailyReport.SubsystemBlock, fakeSubsystemBlock);
Assert.Equal(idDailyReport, result); Assert.Equal(idDailyReport, result);
@ -153,6 +154,7 @@ public class DailyReportServiceTest
var result = await dailyReportService.UpdateBlockAsync(idDailyReport, idUser, fakeSignBlock, CancellationToken.None); var result = await dailyReportService.UpdateBlockAsync(idDailyReport, idUser, fakeSignBlock, CancellationToken.None);
//assert //assert
Assert.NotNull(fakeSignBlock.DateLastUpdate);
Assert.NotNull(fakeDailyReport.DateLastUpdate); Assert.NotNull(fakeDailyReport.DateLastUpdate);
Assert.Equal(fakeDailyReport.SignBlock, fakeSignBlock); Assert.Equal(fakeDailyReport.SignBlock, fakeSignBlock);
Assert.Equal(idDailyReport, result); Assert.Equal(idDailyReport, result);
@ -187,6 +189,7 @@ public class DailyReportServiceTest
var result = await dailyReportService.UpdateBlockAsync(idDailyReport, idUser, fakeTimeBalanceBlock, CancellationToken.None); var result = await dailyReportService.UpdateBlockAsync(idDailyReport, idUser, fakeTimeBalanceBlock, CancellationToken.None);
//assert //assert
Assert.NotNull(fakeTimeBalanceBlock.DateLastUpdate);
Assert.NotNull(fakeDailyReport.DateLastUpdate); Assert.NotNull(fakeDailyReport.DateLastUpdate);
Assert.Equal(fakeDailyReport.TimeBalanceBlock, fakeTimeBalanceBlock); Assert.Equal(fakeDailyReport.TimeBalanceBlock, fakeTimeBalanceBlock);
Assert.Equal(idDailyReport, result); Assert.Equal(idDailyReport, result);

View File

@ -117,9 +117,9 @@ public class DailyReportController : ControllerBase
{ {
var validSubsystemNames = new[] { "АвтоСПО", "Автопроработка" }; var validSubsystemNames = new[] { "АвтоСПО", "Автопроработка" };
if (subsystemBlock.Modules.Any(m => !validSubsystemNames.Contains(m.SubsystemName))) if (subsystemBlock.Subsystems.Any(m => !validSubsystemNames.Contains(m.SubsystemName)))
throw new ArgumentInvalidException($"Возможно добавить модули только с именами {string.Join(", ", validSubsystemNames)}", throw new ArgumentInvalidException($"Возможно добавить подсистемы с именами {string.Join(", ", validSubsystemNames)}",
nameof(subsystemBlock.Modules)); nameof(subsystemBlock.Subsystems));
return UpdateBlockAsync(idWell, idDailyReport, subsystemBlock, cancellationToken); return UpdateBlockAsync(idWell, idDailyReport, subsystemBlock, cancellationToken);
} }