forked from ddrilling/AsbCloudServer
правки по результатам ревью
This commit is contained in:
parent
98b99a041a
commit
28851e5c44
@ -24,7 +24,7 @@ public abstract class ProcessMapPlanBase : ChangeLogAbstract, IId, IWellRelated
|
||||
public virtual User Author { get; set; } = null!;
|
||||
|
||||
[ForeignKey(nameof(IdEditor))]
|
||||
public virtual User? Editor { get; set; } = null!;
|
||||
public virtual User? Editor { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdWellSectionType))]
|
||||
public virtual WellSectionType WellSectionType { get; set; } = null!;
|
||||
|
@ -16,6 +16,7 @@ using AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudDb.Model.DailyReports.Blocks.TimeBalance;
|
||||
using AsbCloudDb.Model.Manuals;
|
||||
using AsbCloudDb.Model.ProcessMapPlan;
|
||||
using AsbCloudDb.Model.ProcessMaps;
|
||||
using AsbCloudDb.Model.Trajectory;
|
||||
using AsbCloudDb.Model.WellSections;
|
||||
@ -62,6 +63,12 @@ namespace AsbCloudInfrastructure
|
||||
.ForType<ScheduleDto, Schedule>()
|
||||
.Ignore(source => source.Driller);
|
||||
|
||||
#pragma warning disable CS8603 // Possible null reference return.
|
||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||
.ForType<ProcessMapPlanBaseDto, ProcessMapPlanBase>()
|
||||
.Ignore(dst => dst.Author, dst => dst.Editor);
|
||||
#pragma warning restore CS8603 // Possible null reference return.
|
||||
|
||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||
.ForType<DateTimeOffset, DateTime>()
|
||||
.MapWith((source) => source.DateTime);
|
||||
|
@ -240,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 => ConvertChangeLogDto(e, offset));
|
||||
|
||||
return dtos;
|
||||
}
|
||||
@ -256,7 +256,7 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
||||
.ToArrayAsync(token);
|
||||
|
||||
TimeSpan offset = GetTimezoneOffset(request);
|
||||
var dtos = entities.Select(e => e.Adapt<TDto>());
|
||||
var dtos = entities.Select(e => Convert(e, offset));
|
||||
return dtos;
|
||||
}
|
||||
|
||||
@ -275,14 +275,21 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
||||
return entity;
|
||||
}
|
||||
|
||||
protected virtual ChangeLogDto<TDto> Convert(TEntity entity, TimeSpan offset)
|
||||
protected virtual ChangeLogDto<TDto> ConvertChangeLogDto(TEntity entity, TimeSpan offset)
|
||||
{
|
||||
var dto = entity.Adapt<ChangeLogDto<TDto>>();
|
||||
dto.Creation = entity.Creation.ToOffset(offset);
|
||||
var changeLogDto = entity.Adapt<ChangeLogDto<TDto>>();
|
||||
changeLogDto.Creation = entity.Creation.ToOffset(offset);
|
||||
|
||||
if (entity.Obsolete.HasValue)
|
||||
dto.Obsolete = entity.Obsolete.Value.ToOffset(offset);
|
||||
changeLogDto.Obsolete = entity.Obsolete.Value.ToOffset(offset);
|
||||
|
||||
changeLogDto.Item = Convert(entity, offset);
|
||||
return changeLogDto;
|
||||
}
|
||||
|
||||
protected virtual TDto Convert(TEntity entity, TimeSpan offset)
|
||||
{
|
||||
var dto = entity.Adapt<TDto>();
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudDb.Model.ProcessMapPlan;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Linq;
|
||||
@ -11,12 +10,12 @@ using System.Linq;
|
||||
namespace AsbCloudInfrastructure.Repository;
|
||||
|
||||
public class ProcessMapPlanBaseRepository<TDto, TEntity> : ChangeLogRepositoryAbstract<TDto, TEntity, ProcessMapPlanBaseRequestWithWell>
|
||||
where TDto : AsbCloudApp.Data.IId
|
||||
where TDto : ProcessMapPlanBaseDto
|
||||
where TEntity : ProcessMapPlanBase
|
||||
{
|
||||
private readonly IWellService wellService;
|
||||
|
||||
public ProcessMapPlanBaseRepository(IAsbCloudDbContext context, IWellService wellService)
|
||||
public ProcessMapPlanBaseRepository(IAsbCloudDbContext context, IWellService wellService)
|
||||
: base(context)
|
||||
{
|
||||
this.wellService = wellService;
|
||||
@ -56,11 +55,18 @@ public class ProcessMapPlanBaseRepository<TDto, TEntity> : ChangeLogRepositoryAb
|
||||
return offset;
|
||||
}
|
||||
|
||||
protected override TDto Convert(TEntity entity, TimeSpan offset)
|
||||
{
|
||||
var dto = base.Convert(entity, offset);
|
||||
dto.Section = entity.WellSectionType.Caption;
|
||||
return dto;
|
||||
}
|
||||
|
||||
protected override TEntity Convert(TDto dto)
|
||||
{
|
||||
var entity = base.Convert(dto);
|
||||
entity.Author = null;
|
||||
entity.Editor = null;
|
||||
//entity.Author = null;
|
||||
//entity.Editor = null;
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
@ -48,13 +48,13 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
||||
|
||||
var requestProcessMapPlan = new ProcessMapPlanBaseRequestWithWell(idWell);
|
||||
var processMapPlanWellDrillings = await processMapPlanBaseRepository.Get(requestProcessMapPlan, token);
|
||||
var changeLogProcessMaps = await processMapPlanBaseRepository.GetChangeLog(requestProcessMapPlan, null, token);
|
||||
|
||||
if (!processMapPlanWellDrillings.Any())
|
||||
if (!changeLogProcessMaps.Any())
|
||||
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
||||
|
||||
var geDepth = processMapPlanWellDrillings.Min(p => p.DepthStart);
|
||||
var leDepth = processMapPlanWellDrillings.Max(p => p.DepthEnd);
|
||||
var geDepth = changeLogProcessMaps.Min(p => p.Item.DepthStart);
|
||||
var leDepth = changeLogProcessMaps.Max(p => p.Item.DepthEnd);
|
||||
|
||||
var requestWellOperationFact = new WellOperationRequest(new[] { idWell })
|
||||
{
|
||||
@ -86,7 +86,7 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
|
||||
var result = CalcByIntervals(
|
||||
request,
|
||||
processMapPlanWellDrillings,
|
||||
changeLogProcessMaps,
|
||||
dataSaubStats,
|
||||
orderedWellOperations,
|
||||
wellOperationCategories,
|
||||
@ -97,7 +97,7 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
|
||||
private static IEnumerable<ProcessMapReportDataSaubStatDto> CalcByIntervals(
|
||||
DataSaubStatRequest request,
|
||||
IEnumerable<ProcessMapPlanDrillingDto> processMapPlanWellDrillings,
|
||||
IEnumerable<ChangeLogDto<ProcessMapPlanDrillingDto>> changeLogProcessMaps,
|
||||
Span<DataSaubStatDto> dataSaubStats,
|
||||
IEnumerable<WellOperationDto> wellOperations,
|
||||
IEnumerable<WellOperationCategoryDto> wellOperationCategories,
|
||||
@ -126,15 +126,11 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
||||
}
|
||||
|
||||
ProcessMapPlanDrillingDto? GetProcessMapPlan(int idWellSectionType, DataSaubStatDto data)
|
||||
=> processMapPlanWellDrillings
|
||||
.Where(p => p.IdWellSectionType == idWellSectionType)
|
||||
.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,
|
||||
})
|
||||
=> changeLogProcessMaps
|
||||
.Where(p => p.Item.IdWellSectionType == idWellSectionType)
|
||||
.Where(p => p.Item.DepthStart <= data.DepthStart)
|
||||
.Where(p => p.Item.DepthEnd >= data.DepthStart)
|
||||
.Where(p => IsModeMatchOperationCategory(p.Item.IdMode, data.IdCategory))
|
||||
.WhereActualAtMoment(data.DateStart)
|
||||
.Select(p => p.Item)
|
||||
.FirstOrDefault();
|
||||
|
Loading…
Reference in New Issue
Block a user