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