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!;
|
public virtual User Author { get; set; } = null!;
|
||||||
|
|
||||||
[ForeignKey(nameof(IdEditor))]
|
[ForeignKey(nameof(IdEditor))]
|
||||||
public virtual User? Editor { get; set; } = null!;
|
public virtual User? Editor { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(IdWellSectionType))]
|
[ForeignKey(nameof(IdWellSectionType))]
|
||||||
public virtual WellSectionType WellSectionType { get; set; } = null!;
|
public virtual WellSectionType WellSectionType { get; set; } = null!;
|
||||||
|
@ -16,6 +16,7 @@ using AsbCloudApp.Services.ProcessMaps.WellDrilling;
|
|||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudDb.Model.DailyReports.Blocks.TimeBalance;
|
using AsbCloudDb.Model.DailyReports.Blocks.TimeBalance;
|
||||||
using AsbCloudDb.Model.Manuals;
|
using AsbCloudDb.Model.Manuals;
|
||||||
|
using AsbCloudDb.Model.ProcessMapPlan;
|
||||||
using AsbCloudDb.Model.ProcessMaps;
|
using AsbCloudDb.Model.ProcessMaps;
|
||||||
using AsbCloudDb.Model.Trajectory;
|
using AsbCloudDb.Model.Trajectory;
|
||||||
using AsbCloudDb.Model.WellSections;
|
using AsbCloudDb.Model.WellSections;
|
||||||
@ -62,6 +63,12 @@ namespace AsbCloudInfrastructure
|
|||||||
.ForType<ScheduleDto, Schedule>()
|
.ForType<ScheduleDto, Schedule>()
|
||||||
.Ignore(source => source.Driller);
|
.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
|
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||||
.ForType<DateTimeOffset, DateTime>()
|
.ForType<DateTimeOffset, DateTime>()
|
||||||
.MapWith((source) => source.DateTime);
|
.MapWith((source) => source.DateTime);
|
||||||
|
@ -240,7 +240,7 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
|||||||
.ThenBy(e => e.Obsolete)
|
.ThenBy(e => e.Obsolete)
|
||||||
.ThenBy(e => e.Id)
|
.ThenBy(e => e.Id)
|
||||||
.ToListAsync(token);
|
.ToListAsync(token);
|
||||||
var dtos = entities.Select(e => Convert(e, offset));
|
var dtos = entities.Select(e => ConvertChangeLogDto(e, offset));
|
||||||
|
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
|||||||
.ToArrayAsync(token);
|
.ToArrayAsync(token);
|
||||||
|
|
||||||
TimeSpan offset = GetTimezoneOffset(request);
|
TimeSpan offset = GetTimezoneOffset(request);
|
||||||
var dtos = entities.Select(e => e.Adapt<TDto>());
|
var dtos = entities.Select(e => Convert(e, offset));
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,14 +275,21 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
|
|||||||
return entity;
|
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>>();
|
var changeLogDto = entity.Adapt<ChangeLogDto<TDto>>();
|
||||||
dto.Creation = entity.Creation.ToOffset(offset);
|
changeLogDto.Creation = entity.Creation.ToOffset(offset);
|
||||||
|
|
||||||
if (entity.Obsolete.HasValue)
|
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;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ using AsbCloudApp.Requests;
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudDb.Model.ProcessMapPlan;
|
using AsbCloudDb.Model.ProcessMapPlan;
|
||||||
using Mapster;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -11,7 +10,7 @@ using System.Linq;
|
|||||||
namespace AsbCloudInfrastructure.Repository;
|
namespace AsbCloudInfrastructure.Repository;
|
||||||
|
|
||||||
public class ProcessMapPlanBaseRepository<TDto, TEntity> : ChangeLogRepositoryAbstract<TDto, TEntity, ProcessMapPlanBaseRequestWithWell>
|
public class ProcessMapPlanBaseRepository<TDto, TEntity> : ChangeLogRepositoryAbstract<TDto, TEntity, ProcessMapPlanBaseRequestWithWell>
|
||||||
where TDto : AsbCloudApp.Data.IId
|
where TDto : ProcessMapPlanBaseDto
|
||||||
where TEntity : ProcessMapPlanBase
|
where TEntity : ProcessMapPlanBase
|
||||||
{
|
{
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
@ -56,11 +55,18 @@ public class ProcessMapPlanBaseRepository<TDto, TEntity> : ChangeLogRepositoryAb
|
|||||||
return offset;
|
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)
|
protected override TEntity Convert(TDto dto)
|
||||||
{
|
{
|
||||||
var entity = base.Convert(dto);
|
var entity = base.Convert(dto);
|
||||||
entity.Author = null;
|
//entity.Author = null;
|
||||||
entity.Editor = null;
|
//entity.Editor = null;
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,13 +48,13 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
|||||||
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
||||||
|
|
||||||
var requestProcessMapPlan = new ProcessMapPlanBaseRequestWithWell(idWell);
|
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>();
|
return Enumerable.Empty<ProcessMapReportDataSaubStatDto>();
|
||||||
|
|
||||||
var geDepth = processMapPlanWellDrillings.Min(p => p.DepthStart);
|
var geDepth = changeLogProcessMaps.Min(p => p.Item.DepthStart);
|
||||||
var leDepth = processMapPlanWellDrillings.Max(p => p.DepthEnd);
|
var leDepth = changeLogProcessMaps.Max(p => p.Item.DepthEnd);
|
||||||
|
|
||||||
var requestWellOperationFact = new WellOperationRequest(new[] { idWell })
|
var requestWellOperationFact = new WellOperationRequest(new[] { idWell })
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
|||||||
|
|
||||||
var result = CalcByIntervals(
|
var result = CalcByIntervals(
|
||||||
request,
|
request,
|
||||||
processMapPlanWellDrillings,
|
changeLogProcessMaps,
|
||||||
dataSaubStats,
|
dataSaubStats,
|
||||||
orderedWellOperations,
|
orderedWellOperations,
|
||||||
wellOperationCategories,
|
wellOperationCategories,
|
||||||
@ -97,7 +97,7 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
|||||||
|
|
||||||
private static IEnumerable<ProcessMapReportDataSaubStatDto> CalcByIntervals(
|
private static IEnumerable<ProcessMapReportDataSaubStatDto> CalcByIntervals(
|
||||||
DataSaubStatRequest request,
|
DataSaubStatRequest request,
|
||||||
IEnumerable<ProcessMapPlanDrillingDto> processMapPlanWellDrillings,
|
IEnumerable<ChangeLogDto<ProcessMapPlanDrillingDto>> changeLogProcessMaps,
|
||||||
Span<DataSaubStatDto> dataSaubStats,
|
Span<DataSaubStatDto> dataSaubStats,
|
||||||
IEnumerable<WellOperationDto> wellOperations,
|
IEnumerable<WellOperationDto> wellOperations,
|
||||||
IEnumerable<WellOperationCategoryDto> wellOperationCategories,
|
IEnumerable<WellOperationCategoryDto> wellOperationCategories,
|
||||||
@ -126,15 +126,11 @@ public class ProcessMapReportDrillingService : IProcessMapReportDrillingService
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProcessMapPlanDrillingDto? GetProcessMapPlan(int idWellSectionType, DataSaubStatDto data)
|
ProcessMapPlanDrillingDto? GetProcessMapPlan(int idWellSectionType, DataSaubStatDto data)
|
||||||
=> processMapPlanWellDrillings
|
=> changeLogProcessMaps
|
||||||
.Where(p => p.IdWellSectionType == idWellSectionType)
|
.Where(p => p.Item.IdWellSectionType == idWellSectionType)
|
||||||
.Where(p => p.DepthStart <= data.DepthStart)
|
.Where(p => p.Item.DepthStart <= data.DepthStart)
|
||||||
.Where(p => p.DepthEnd >= data.DepthStart)
|
.Where(p => p.Item.DepthEnd >= data.DepthStart)
|
||||||
.Where(p => IsModeMatchOperationCategory(p.IdMode, data.IdCategory))
|
.Where(p => IsModeMatchOperationCategory(p.Item.IdMode, data.IdCategory))
|
||||||
.Select(p => new ChangeLogDto<ProcessMapPlanDrillingDto>()
|
|
||||||
{
|
|
||||||
Item = p,
|
|
||||||
})
|
|
||||||
.WhereActualAtMoment(data.DateStart)
|
.WhereActualAtMoment(data.DateStart)
|
||||||
.Select(p => p.Item)
|
.Select(p => p.Item)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user