forked from ddrilling/AsbCloudServer
Изменения блока с наработкой подсистем
This commit is contained in:
parent
3eeaa2b9eb
commit
cc4ef55c12
@ -0,0 +1,25 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AsbCloudApp.Data.DailyReport.Blocks.Subsystems;
|
||||
|
||||
/// <summary>
|
||||
/// Параметры наработки подсистемы
|
||||
/// </summary>
|
||||
public class SubsystemParametersDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Сумма изменения глубин при включенной подсистеме
|
||||
/// </summary>
|
||||
public double? SumDepthInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Наработка подсистемы
|
||||
/// </summary>
|
||||
public double? UsedTimeHours { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Коэффициент использования
|
||||
/// </summary>
|
||||
[Range(0, 1)]
|
||||
public double? KUsage { get; set; }
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AsbCloudApp.Data.DailyReport.Blocks.Subsystems;
|
||||
|
||||
/// <summary>
|
||||
@ -10,29 +8,15 @@ public class SubsystemRecordDto
|
||||
/// <summary>
|
||||
/// Название подсистемы
|
||||
/// </summary>
|
||||
public string SubsystemName { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Идентификатор временного интервала
|
||||
/// 1 - за сутки
|
||||
/// 2 - за скважину
|
||||
/// </summary>
|
||||
[Range(1, 2)]
|
||||
public int IdTimeInterval { get; set; }
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Сумма изменения глубин при включеной подсистеме
|
||||
/// Использование подсистемы за сутки
|
||||
/// </summary>
|
||||
public double? SumDepthInterval { get; set; }
|
||||
public SubsystemParametersDto? UsagePerDay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Наработка подсистемы
|
||||
/// Использование подсистемы за скважину
|
||||
/// </summary>
|
||||
public double? UsedTimeHours { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Коэффициент использования
|
||||
/// </summary>
|
||||
[Range(0, 100)]
|
||||
public double? KUsage { get; set; }
|
||||
public SubsystemParametersDto? UsagePerWell { get; set; }
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
namespace AsbCloudDb.Model.DailyReports.Blocks.Subsystem;
|
||||
|
||||
public class SubsystemParameters
|
||||
{
|
||||
public double? SumDepthInterval { get; set; }
|
||||
|
||||
public double? UsedTimeHours { get; set; }
|
||||
|
||||
public double? KUsage { get; set; }
|
||||
}
|
@ -2,13 +2,9 @@ namespace AsbCloudDb.Model.DailyReports.Blocks.Subsystem;
|
||||
|
||||
public class SubsystemRecord
|
||||
{
|
||||
public string SubsystemName { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public int IdTimeInterval { get; set; }
|
||||
|
||||
public double? SumDepthInterval { get; set; }
|
||||
|
||||
public double? UsedTimeHours { get; set; }
|
||||
|
||||
public double? KUsage { get; set; }
|
||||
public SubsystemParameters? UsagePerDay { get; set; }
|
||||
|
||||
public SubsystemParameters? UsagePerWell { get; set; }
|
||||
}
|
@ -25,7 +25,7 @@ public class DailyReportExportService : IDailyReportExportService
|
||||
private const int rowStartProcessMapWellDrillingBlock = 68;
|
||||
|
||||
private const int columnTimeBalanceDurationPlan = 3;
|
||||
private const int columnTimeBalanceDurationFact = 4;
|
||||
private const int columnTimeBalanceDurationFact = 6;
|
||||
private const int columnTimeBalanceReasonDeviation = 8;
|
||||
private const int columnTimeBalanceDrillingDeviationPerSection = 10;
|
||||
private const int columnTimeBalanceDrillingDeviationPerDay = 11;
|
||||
@ -179,25 +179,19 @@ public class DailyReportExportService : IDailyReportExportService
|
||||
|
||||
private static void AddSubsystemBlockToSheet(IXLWorksheet sheet, SubsystemBlockDto subsystemBlock)
|
||||
{
|
||||
var groupedSubsystems = subsystemBlock.Subsystems.OrderBy(m => m.SubsystemName)
|
||||
.GroupBy(m => m.SubsystemName);
|
||||
|
||||
var rowСurrent = rowStartSubsystemBlock;
|
||||
|
||||
foreach (var groupedModule in groupedSubsystems)
|
||||
foreach (var subsystem in subsystemBlock.Subsystems)
|
||||
{
|
||||
var useSubsystemPerDay = groupedModule.FirstOrDefault(m => m.IdTimeInterval == 1);
|
||||
var useSubsystemPerWell = groupedModule.FirstOrDefault(m => m.IdTimeInterval == 2);
|
||||
sheet.Cell(rowСurrent, columnSubsystemName).Value = subsystem.Name;
|
||||
|
||||
sheet.Cell(rowСurrent, columnSubsystemName).Value = groupedModule.Key;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerDayUsedTimeHours).Value = subsystem.UsagePerDay?.UsedTimeHours;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerDaySumDepthInterval).Value = subsystem.UsagePerDay?.SumDepthInterval;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerDayKUsage).Value = subsystem.UsagePerDay?.KUsage;
|
||||
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerDayUsedTimeHours).Value = useSubsystemPerDay?.UsedTimeHours;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerDaySumDepthInterval).Value = useSubsystemPerDay?.SumDepthInterval;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerDayKUsage).Value = useSubsystemPerDay?.KUsage;
|
||||
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerWellUsedTimeHours).Value = useSubsystemPerWell?.UsedTimeHours;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerWellSumDepthInterval).Value = useSubsystemPerWell?.SumDepthInterval;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerWellKUsage).Value = useSubsystemPerWell?.KUsage;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerWellUsedTimeHours).Value = subsystem.UsagePerWell?.UsedTimeHours;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerWellSumDepthInterval).Value = subsystem.UsagePerWell?.SumDepthInterval;
|
||||
sheet.Cell(rowСurrent, columnUseSubsystemPerWellKUsage).Value = subsystem.UsagePerWell?.KUsage;
|
||||
|
||||
rowСurrent++;
|
||||
}
|
||||
|
@ -296,39 +296,30 @@ public class DailyReportService : IDailyReportService
|
||||
|
||||
async Task<IEnumerable<SubsystemRecordDto>> GetSubsystemsAsync()
|
||||
{
|
||||
var subsystems = new List<SubsystemRecordDto>();
|
||||
var subsystemOperationTimesPerWell = await subsystemOperationTimeService.GetStatAsync(new SubsystemOperationTimeRequest
|
||||
{
|
||||
IdWell = dailyReport.IdWell
|
||||
}, cancellationToken);
|
||||
|
||||
var statSubsystemOperationTimePerDay = (await subsystemOperationTimeService.GetStatAsync(new SubsystemOperationTimeRequest
|
||||
var subsystemOperationTimesPerDay = await subsystemOperationTimeService.GetStatAsync(new SubsystemOperationTimeRequest
|
||||
{
|
||||
IdWell = dailyReport.IdWell,
|
||||
GtDate = dailyReport.Date,
|
||||
LtDate = dailyReport.Date.AddHours(24)
|
||||
}, cancellationToken)).Select(s =>
|
||||
{
|
||||
var subsystemRecord = s.Adapt<SubsystemRecordDto>();
|
||||
subsystemRecord.IdTimeInterval = 1;
|
||||
}, cancellationToken);
|
||||
|
||||
return subsystemRecord;
|
||||
});
|
||||
|
||||
var statSubsystemOperationTimePerWell = (await subsystemOperationTimeService.GetStatAsync(new SubsystemOperationTimeRequest
|
||||
{
|
||||
IdWell = dailyReport.IdWell
|
||||
}, cancellationToken)).Select(s =>
|
||||
{
|
||||
var subsystemRecord = s.Adapt<SubsystemRecordDto>();
|
||||
subsystemRecord.IdTimeInterval = 2;
|
||||
|
||||
return subsystemRecord;
|
||||
});
|
||||
|
||||
subsystems.AddRange(statSubsystemOperationTimePerDay);
|
||||
subsystems.AddRange(statSubsystemOperationTimePerWell);
|
||||
var subsystems = subsystemOperationTimesPerWell
|
||||
.Select(subsystemOperationTime => new SubsystemRecordDto
|
||||
{
|
||||
Name = subsystemOperationTime.SubsystemName,
|
||||
UsagePerDay = subsystemOperationTimesPerDay.FirstOrDefault(s => s.IdSubsystem == subsystemOperationTime.IdSubsystem)?.Adapt<SubsystemParametersDto>(),
|
||||
UsagePerWell = subsystemOperationTime.Adapt<SubsystemParametersDto>()
|
||||
}).ToList();
|
||||
|
||||
if (dailyReport.SubsystemBlock?.Subsystems != null && dailyReport.SubsystemBlock.Subsystems.Any())
|
||||
subsystems.AddRange(dailyReport.SubsystemBlock.Subsystems);
|
||||
|
||||
return subsystems.OrderBy(s => s.SubsystemName);
|
||||
return subsystems.OrderBy(s => s.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,11 +42,19 @@ public class DailyReportServiceTest
|
||||
{
|
||||
new SubsystemRecordDto
|
||||
{
|
||||
SubsystemName = "АвтоСПО",
|
||||
IdTimeInterval = 2,
|
||||
UsedTimeHours = 24,
|
||||
SumDepthInterval = 1500,
|
||||
KUsage = 100
|
||||
Name = "АвтоСПО",
|
||||
UsagePerDay = new SubsystemParametersDto
|
||||
{
|
||||
UsedTimeHours = 24,
|
||||
SumDepthInterval = 1500,
|
||||
KUsage = 15
|
||||
},
|
||||
UsagePerWell = new SubsystemParametersDto
|
||||
{
|
||||
UsedTimeHours = 500,
|
||||
SumDepthInterval = 3000,
|
||||
KUsage = 100
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -182,7 +190,7 @@ public class DailyReportServiceTest
|
||||
}
|
||||
};
|
||||
|
||||
private readonly SubsystemStatDto fakeStatSubsystemOperationTimePerDay = new()
|
||||
private readonly SubsystemStatDto fakeStatSubsystemOperationTime = new()
|
||||
{
|
||||
SubsystemName = "АПД",
|
||||
SumDepthInterval = 250,
|
||||
@ -258,7 +266,7 @@ public class DailyReportServiceTest
|
||||
.ReturnsForAnyArgs(fakeWellOperationSlipsTime);
|
||||
|
||||
subsystemOperationTimeServiceMock.GetStatAsync(Arg.Any<SubsystemOperationTimeRequest>(), Arg.Any<CancellationToken>())
|
||||
.ReturnsForAnyArgs(new[] { fakeStatSubsystemOperationTimePerDay });
|
||||
.ReturnsForAnyArgs(new[] { fakeStatSubsystemOperationTime });
|
||||
|
||||
scheduleRepositoryMock.GetAsync(idWell, dateDailyReport, Arg.Any<CancellationToken>())
|
||||
.ReturnsForAnyArgs(new[] { fakeShedule });
|
||||
@ -453,23 +461,29 @@ public class DailyReportServiceTest
|
||||
|
||||
//assert
|
||||
Assert.NotNull(result.SubsystemBlock);
|
||||
Assert.Equal(3, result.SubsystemBlock?.Subsystems.Count());
|
||||
Assert.Equal(2, result.SubsystemBlock?.Subsystems.Count());
|
||||
|
||||
var subsystemRecord0 = result.SubsystemBlock?.Subsystems.ElementAt(0);
|
||||
|
||||
Assert.Equal("АвтоСПО", subsystemRecord0?.SubsystemName);
|
||||
Assert.Equal(2, subsystemRecord0?.IdTimeInterval);
|
||||
Assert.Equal(24, subsystemRecord0?.UsedTimeHours);
|
||||
Assert.Equal(1500, subsystemRecord0?.SumDepthInterval);
|
||||
Assert.Equal(100, subsystemRecord0?.KUsage);
|
||||
Assert.Equal("АвтоСПО", subsystemRecord0?.Name);
|
||||
Assert.Equal(24, subsystemRecord0?.UsagePerDay?.UsedTimeHours);
|
||||
Assert.Equal(1500, subsystemRecord0?.UsagePerDay?.SumDepthInterval);
|
||||
Assert.Equal(15, subsystemRecord0?.UsagePerDay?.KUsage);
|
||||
|
||||
Assert.Equal(500, subsystemRecord0?.UsagePerWell?.UsedTimeHours);
|
||||
Assert.Equal(3000, subsystemRecord0?.UsagePerWell?.SumDepthInterval);
|
||||
Assert.Equal(100, subsystemRecord0?.UsagePerWell?.KUsage);
|
||||
|
||||
var subsystemRecord1 = result.SubsystemBlock?.Subsystems.ElementAt(1);
|
||||
|
||||
Assert.Equal(fakeStatSubsystemOperationTimePerDay.SubsystemName, subsystemRecord1?.SubsystemName);
|
||||
Assert.Equal(1, subsystemRecord1?.IdTimeInterval);
|
||||
Assert.Equal(fakeStatSubsystemOperationTimePerDay.UsedTimeHours, subsystemRecord1?.UsedTimeHours);
|
||||
Assert.Equal(fakeStatSubsystemOperationTimePerDay.SumDepthInterval, subsystemRecord1?.SumDepthInterval);
|
||||
Assert.Equal(fakeStatSubsystemOperationTimePerDay.KUsage, subsystemRecord1?.KUsage);
|
||||
Assert.Equal("АПД", subsystemRecord1?.Name);
|
||||
Assert.Equal(200, subsystemRecord1?.UsagePerDay?.UsedTimeHours);
|
||||
Assert.Equal(250, subsystemRecord1?.UsagePerDay?.SumDepthInterval);
|
||||
Assert.Equal(30, subsystemRecord1?.UsagePerDay?.KUsage);
|
||||
|
||||
Assert.Equal(200, subsystemRecord1?.UsagePerWell?.UsedTimeHours);
|
||||
Assert.Equal(250, subsystemRecord1?.UsagePerWell?.SumDepthInterval);
|
||||
Assert.Equal(30, subsystemRecord1?.UsagePerWell?.KUsage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -89,7 +89,7 @@ public class DailyReportController : ControllerBase
|
||||
{
|
||||
var validSubsystemNames = new[] { "АвтоСПО", "Автопроработка" };
|
||||
|
||||
if (subsystemBlock.Subsystems.Any(m => !validSubsystemNames.Contains(m.SubsystemName)))
|
||||
if (subsystemBlock.Subsystems.Any(m => !validSubsystemNames.Contains(m.Name)))
|
||||
throw new ArgumentInvalidException($"Возможно добавить подсистемы с именами {string.Join(", ", validSubsystemNames)}",
|
||||
nameof(subsystemBlock.Subsystems));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user