forked from ddrilling/AsbCloudServer
Переработка класса ChangeLogAbstract в ChangeLogDto<T> + изменения, связанные с этим. Начало.
This commit is contained in:
parent
d517033415
commit
edd5ca695f
@ -1,59 +0,0 @@
|
||||
using AsbCloudApp.Data.User;
|
||||
using System;
|
||||
|
||||
namespace AsbCloudApp.Data;
|
||||
|
||||
/// <summary>
|
||||
/// Часть записи описывающая изменение
|
||||
/// </summary>
|
||||
public abstract class ChangeLogAbstract
|
||||
{
|
||||
/// <summary>
|
||||
/// ИД записи
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Автор
|
||||
/// </summary>
|
||||
public UserDto? Author { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Автор
|
||||
/// </summary>
|
||||
public UserDto? Editor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата создания записи
|
||||
/// </summary>
|
||||
public DateTimeOffset Creation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата устаревания (например при удалении)
|
||||
/// </summary>
|
||||
public DateTimeOffset? Obsolete { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ИД состояния записи:
|
||||
/// <list type="table">
|
||||
/// <item>
|
||||
/// <term>0</term>
|
||||
/// <description>актуальная запись</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>1</term>
|
||||
/// <description>замененная запись</description>
|
||||
/// </item>
|
||||
/// <item>
|
||||
/// <term>2</term>
|
||||
/// <description>удаленная запись</description>
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public int IdState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id заменяемой записи
|
||||
/// </summary>
|
||||
public int? IdPrevious { get; set; }
|
||||
}
|
@ -5,13 +5,18 @@ using System.ComponentModel.DataAnnotations;
|
||||
namespace AsbCloudApp.Data.ProcessMaps;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract class ProcessMapPlanBaseDto : ChangeLogAbstract, IId, IWellRelated, IValidatableObject
|
||||
public abstract class ProcessMapPlanBaseDto : IId, IWellRelated, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Id скважины
|
||||
/// </summary>
|
||||
public int IdWell { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id записи
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Тип секции
|
||||
/// </summary>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.ProcessMaps;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -19,8 +20,8 @@ namespace AsbCloudApp.Extensions
|
||||
/// <param name="items"></param>
|
||||
/// <param name="moment"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<T> WhereActualAtMoment<T>(this IEnumerable<T> items, DateTimeOffset moment)
|
||||
where T : ChangeLogAbstract
|
||||
public static IEnumerable<ChangeLogDto<T>> WhereActualAtMoment<T>(this IEnumerable<ChangeLogDto<T>> items, DateTimeOffset moment)
|
||||
where T : ProcessMapPlanBaseDto
|
||||
{
|
||||
var actualItems = items
|
||||
.Where(item => item.Creation <= moment)
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.ProcessMaps;
|
||||
using AsbCloudApp.Requests;
|
||||
|
||||
namespace AsbCloudApp.Repositories;
|
||||
@ -11,7 +12,7 @@ namespace AsbCloudApp.Repositories;
|
||||
/// Репозиторий для записей с историей
|
||||
/// </summary>
|
||||
public interface IChangeLogRepository<TDto, TRequest>
|
||||
where TDto : ChangeLogAbstract
|
||||
where TDto : ProcessMapPlanBaseDto
|
||||
where TRequest : ChangeLogBaseRequest
|
||||
{
|
||||
/// <summary>
|
||||
@ -84,7 +85,7 @@ public interface IChangeLogRepository<TDto, TRequest>
|
||||
/// <param name="date">Фильтр по дате. Если null - вернет все</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<TDto>> GetChangeLog(TRequest request, DateOnly? date, CancellationToken token);
|
||||
Task<IEnumerable<ChangeLogDto<TDto>>> GetChangeLog(TRequest request, DateOnly? date, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Получение записей по параметрам
|
||||
|
@ -45,6 +45,10 @@ using System;
|
||||
using AsbCloudApp.Data.DetectedOperation;
|
||||
using AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
|
||||
using AsbCloudInfrastructure.Services.WellOperations.Factories;
|
||||
using AsbCloudDb.Model.ProcessMapPlan;
|
||||
using static Org.BouncyCastle.Math.EC.ECCurve;
|
||||
using AsbCloudApp.Data.User;
|
||||
using DocumentFormat.OpenXml.Drawing;
|
||||
|
||||
namespace AsbCloudInfrastructure
|
||||
{
|
||||
@ -127,6 +131,13 @@ namespace AsbCloudInfrastructure
|
||||
{
|
||||
Plan = src.WellDepthPlan
|
||||
});
|
||||
|
||||
TypeAdapterConfig<ChangeLogAbstract, ChangeLogDto<ProcessMapPlanDrillingDto>>.NewConfig()
|
||||
.Include<ProcessMapPlanDrilling, ChangeLogDto<ProcessMapPlanDrillingDto>>()
|
||||
.Map(dest => dest, src => new ChangeLogDto<ProcessMapPlanDrilling>()
|
||||
{
|
||||
Item = src.Adapt<ProcessMapPlanDrilling>()
|
||||
});
|
||||
}
|
||||
|
||||
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
||||
|
@ -1,4 +1,6 @@
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.ProcessMaps;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudDb.Model;
|
||||
@ -14,7 +16,7 @@ using System.Threading.Tasks;
|
||||
namespace AsbCloudInfrastructure.Repository;
|
||||
|
||||
public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : IChangeLogRepository<TDto, TRequest>
|
||||
where TDto : AsbCloudApp.Data.ChangeLogAbstract
|
||||
where TDto : ProcessMapPlanBaseDto
|
||||
where TEntity : ChangeLogAbstract
|
||||
where TRequest : ChangeLogBaseRequest
|
||||
{
|
||||
@ -217,7 +219,7 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
||||
return datesOnly;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TDto>> GetChangeLog(TRequest request, DateOnly? date, CancellationToken token)
|
||||
public async Task<IEnumerable<ChangeLogDto<TDto>>> GetChangeLog(TRequest request, DateOnly? date, CancellationToken token)
|
||||
{
|
||||
var query = BuildQuery(request);
|
||||
TimeSpan offset = GetTimezoneOffset(request);
|
||||
@ -238,7 +240,7 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
||||
.ThenBy(e => e.Obsolete)
|
||||
.ThenBy(e => e.Id)
|
||||
.ToListAsync(token);
|
||||
var dtos = entities.Select(e => Convert(e, offset));
|
||||
var dtos = entities.Select(e => Convert2(e, offset));
|
||||
|
||||
return dtos;
|
||||
}
|
||||
@ -253,7 +255,7 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
||||
.ToArrayAsync(token);
|
||||
|
||||
TimeSpan offset = GetTimezoneOffset(request);
|
||||
var dtos = entities.Select(e => Convert(e, offset));
|
||||
var dtos = entities.Select(e => e.Adapt<TDto>());
|
||||
return dtos;
|
||||
}
|
||||
|
||||
@ -272,9 +274,9 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
||||
return entity;
|
||||
}
|
||||
|
||||
protected virtual TDto Convert(TEntity entity, TimeSpan offset)
|
||||
protected ChangeLogDto<TDto> Convert2(TEntity entity, TimeSpan offset)
|
||||
{
|
||||
var dto = entity.Adapt<TDto>();
|
||||
var dto = entity.Adapt<ChangeLogDto<TDto>>();
|
||||
dto.Creation = entity.Creation.ToOffset(offset);
|
||||
|
||||
if (entity.Obsolete.HasValue)
|
||||
|
@ -3,6 +3,7 @@ using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudDb.Model.ProcessMapPlan;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
@ -58,9 +59,9 @@ public class ProcessMapPlanBaseRepository<TDto, TEntity> : ChangeLogRepositoryAb
|
||||
return offset;
|
||||
}
|
||||
|
||||
protected override TDto Convert(TEntity entity, TimeSpan offset)
|
||||
protected TDto Convert(TEntity entity, TimeSpan offset)
|
||||
{
|
||||
var dto = base.Convert(entity, offset);
|
||||
var dto = entity.Adapt<TDto>();
|
||||
dto.Section = entity.WellSectionType.Caption;
|
||||
return dto;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.ProcessMaps;
|
||||
using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Requests.ExportOptions;
|
||||
@ -12,7 +13,7 @@ using AsbCloudInfrastructure.Services.ExcelServices;
|
||||
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Export;
|
||||
|
||||
public abstract class ProcessMapPlanExportService<TDto> : ExportExcelService<TDto, WellRelatedExportRequest>
|
||||
where TDto : ChangeLogAbstract
|
||||
where TDto : ProcessMapPlanBaseDto
|
||||
{
|
||||
protected readonly IWellService wellService;
|
||||
|
||||
|
@ -131,7 +131,12 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
.Where(p => p.DepthStart <= data.DepthStart)
|
||||
.Where(p => p.DepthEnd >= data.DepthStart)
|
||||
.Where(p => IsModeMatchOperationCategory(p.IdMode, data.IdCategory))
|
||||
.Select(p => new ChangeLogDto<ProcessMapPlanDrillingDto>()
|
||||
{
|
||||
Item = p,
|
||||
})
|
||||
.WhereActualAtMoment(data.DateStart)
|
||||
.Select(p => p.Item)
|
||||
.FirstOrDefault();
|
||||
|
||||
var idWellSectionType = GetSection(firstElemInInterval);
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user