forked from ddrilling/AsbCloudServer
#8103063 nit prettify
This commit is contained in:
parent
5644c06fac
commit
5956f8238f
@ -30,7 +30,7 @@ namespace AsbCloudApp.Repositories
|
||||
/// <param name="requests"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ProcessMapDto>?> GetProcessMaplAsync(IEnumerable<ProcessMapRequest> requests, CancellationToken token);
|
||||
Task<IEnumerable<ProcessMapDto>> GetProcessMapAsync(IEnumerable<ProcessMapRequest> requests, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
@ -35,7 +35,7 @@ namespace AsbCloudApp.Repositories
|
||||
/// <param name="idWell"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task<IEnumerable<ProcessMapDto>?> GetCompositeProcessMap(int idWell, CancellationToken token);
|
||||
Task<IEnumerable<ProcessMapDto>> GetCompositeProcessMap(int idWell, CancellationToken token);
|
||||
}
|
||||
#nullable disable
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace AsbCloudApp.Requests
|
||||
/// <summary>
|
||||
/// Тип секции
|
||||
/// </summary>
|
||||
public int? IdWellSectionTypes { get; set; }
|
||||
public int? IdWellSectionType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Дата обновления
|
||||
|
@ -4,8 +4,10 @@ using AsbCloudApp.Repositories;
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudDb.Model;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Mapster;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -32,7 +34,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
public async Task<IEnumerable<ProcessMapDto>> GetAllAsync(int idWell,
|
||||
DateTime? updateFrom, CancellationToken token)
|
||||
{
|
||||
var request = new[]
|
||||
var requests = new[]
|
||||
{
|
||||
new ProcessMapRequest {
|
||||
IdWell = idWell,
|
||||
@ -40,7 +42,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
};
|
||||
|
||||
var entities = await BuildQuery(request)
|
||||
var entities = await BuildQuery(requests)
|
||||
.OrderBy(e => e.DepthStart)
|
||||
.ThenBy(e => e.Id)
|
||||
.ToListAsync(token)
|
||||
@ -50,7 +52,7 @@ namespace AsbCloudInfrastructure.Repository
|
||||
return dtos;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ProcessMapDto>?> GetProcessMaplAsync(IEnumerable<ProcessMapRequest> requests, CancellationToken token)
|
||||
public async Task<IEnumerable<ProcessMapDto>> GetProcessMapAsync(IEnumerable<ProcessMapRequest> requests, CancellationToken token)
|
||||
{
|
||||
var entities = await BuildQuery(requests)
|
||||
.ToListAsync(token)
|
||||
@ -75,25 +77,30 @@ namespace AsbCloudInfrastructure.Repository
|
||||
return result;
|
||||
}
|
||||
|
||||
private IQueryable<ProcessMap> BuildQuery(IEnumerable<ProcessMapRequest> request)
|
||||
private IQueryable<ProcessMap> BuildQuery(IEnumerable<ProcessMapRequest> requests)
|
||||
{
|
||||
var query = GetQuery();
|
||||
|
||||
foreach (var item in request)
|
||||
Func<ProcessMap, bool>? p = null;
|
||||
foreach (var request in requests)
|
||||
{
|
||||
query.Where(w => w.IdWell == item.IdWell);
|
||||
var p2 = (ProcessMap map) => map.IdWell == request.IdWell;
|
||||
|
||||
if (item.IdWellSectionTypes is not null)
|
||||
query.Where(w => w.IdWellSectionType == item.IdWellSectionTypes);
|
||||
if (request.IdWellSectionType is not null)
|
||||
p2 = (ProcessMap map) => p2(map) && map.IdWellSectionType == request.IdWellSectionType;
|
||||
|
||||
if (item.UpdateFrom is not null)
|
||||
if (request.UpdateFrom is not null)
|
||||
{
|
||||
var timezone = wellService.GetTimezone(item.IdWell);
|
||||
var updateFromUtc = item.UpdateFrom?.ToUtcDateTimeOffset(timezone.Hours);
|
||||
query.Where(e => e.LastUpdate >= updateFromUtc);
|
||||
var timezone = wellService.GetTimezone(request.IdWell);
|
||||
var updateFromUtc = request.UpdateFrom?.ToUtcDateTimeOffset(timezone.Hours);
|
||||
p2 = (ProcessMap map) => p2(map) && map.LastUpdate >= updateFromUtc;
|
||||
}
|
||||
|
||||
p = p is null
|
||||
? p2
|
||||
: (ProcessMap map) => p(map) || p2(map);
|
||||
}
|
||||
|
||||
if(p is not null)
|
||||
query.Where(p);
|
||||
return query;
|
||||
}
|
||||
protected override ProcessMapDto Convert(ProcessMap entity)
|
||||
|
@ -50,18 +50,18 @@ namespace AsbCloudInfrastructure.Repository
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public async Task<IEnumerable<ProcessMapDto>?> GetCompositeProcessMap(int idWell, CancellationToken token)
|
||||
public async Task<IEnumerable<ProcessMapDto>> GetCompositeProcessMap(int idWell, CancellationToken token)
|
||||
{
|
||||
var dtos = await GetAsync(idWell, token);
|
||||
|
||||
var request = dtos.Select(x => new ProcessMapRequest {
|
||||
var requests = dtos.Select(x => new ProcessMapRequest {
|
||||
IdWell = x.IdWellSrc,
|
||||
IdWellSectionTypes = x.IdWellSectionType
|
||||
IdWellSectionType = x.IdWellSectionType
|
||||
});
|
||||
|
||||
var processMap = (await processMapRepository.GetProcessMaplAsync(request, token));
|
||||
var processMap = await processMapRepository.GetProcessMapAsync(requests, token);
|
||||
|
||||
var result = processMap?.Select(x => new ProcessMapDto
|
||||
var result = processMap.Select(x => new ProcessMapDto
|
||||
{
|
||||
IdWell = x.IdWell,
|
||||
IdWellSectionType = x.IdWellSectionType,
|
||||
|
Loading…
Reference in New Issue
Block a user