refactor WellboreDto

This commit is contained in:
ngfrolov 2023-08-15 18:00:35 +05:00
parent 5ff75e519f
commit d62866919f
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
3 changed files with 26 additions and 36 deletions

View File

@ -5,6 +5,23 @@ using System.Linq;
namespace AsbCloudApp.Data
{
/// <summary>
/// базовая информация о скважине
/// </summary>
public class WellWithTimezoneDto : WellInfoDto
{
/// <inheritdoc/>
[Required]
public SimpleTimezoneDto Timezone { get; set; } = null!;
/// <summary>
/// 0 - неизвестно,
/// 1 - в работе,
/// 2 - завершена
/// </summary>
public int IdState { get; set; }
}
/// <summary>
/// Скважина
/// </summary>

View File

@ -7,41 +7,18 @@ namespace AsbCloudApp.Data;
/// </summary>
public class WellboreDto
{
/// <summary>
/// Идентификатор
/// </summary>
public int Id { get; set; }
public WellWithTimezoneDto Well { get; set; }
/// <summary>
/// Идентификатор
/// </summary>
public int Id { get; set; }
/// <summary>
/// Название
/// </summary>
public string Name { get; set; } = null!;
/// <summary>
/// Идентификатор скважины
/// </summary>
public int IdWell { get; set; }
/// <summary>
/// Состояние скважины
/// </summary>
public int IdWellState { get; set; }
/// <summary>
/// Идентификатор телеметрии
/// </summary>
public int? IdWellTelemetry { get; set; }
/// <summary>
/// Временная зона скважины
/// </summary>
public SimpleTimezoneDto? WellTimezone { get; set; }
/// <summary>
/// Название скважины
/// </summary>
public string WellName { get; set; } = null!;
/// <summary>
/// Начальная глубина ствола
/// </summary>

View File

@ -7,6 +7,7 @@ using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
using AsbCloudApp.Services;
using AsbCloudDb.Model;
using Mapster;
namespace AsbCloudInfrastructure.Services;
@ -55,13 +56,8 @@ public class WellboreService : IWellboreService
var groupedOperations = wellOperations.GroupBy(o => o.IdWellSectionType);
var wellWellbores = groupedOperations.Select(group => new WellboreDto {
Id = group.Key,
IdWell = well.Id,
IdWellState = well.IdState,
IdWellTelemetry = well.IdTelemetry,
Name = sections[group.Key].Caption,
WellName = well.Caption,
WellTimezone = well.Timezone,
Well = well.Adapt<WellWithTimezoneDto>(),
DateStart = group.Min(operation => operation.DateStart),
DateEnd = group.Max(operation => operation.DateStart.AddHours(operation.DurationHours)),
DepthStart = group.Min(operation => operation.DepthStart),
@ -71,7 +67,7 @@ public class WellboreService : IWellboreService
}
return wellbores
.OrderBy(w =>w.IdWell).ThenBy(w=>w.Id)
.OrderBy(w => w.Well.Id).ThenBy(w => w.Id)
.Skip(skip).Take(take);
}