Merge branch 'dev' into feature/import

This commit is contained in:
Степанов Дмитрий 2024-02-01 16:37:38 +05:00
commit 02e1205947
6 changed files with 40 additions and 18 deletions

View File

@ -55,6 +55,7 @@
<PackageReference Include="CliWrap" Version="3.6.6" />
<PackageReference Include="ClosedXML" Version="0.97.0" />
<PackageReference Include="itext7" Version="8.0.2" />
<PackageReference Include="itext7.bouncy-castle-adapter" Version="8.0.2" />
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.1.21" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />

View File

@ -193,7 +193,8 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
dates = dates.Select(date => date.ToOffset(offset));
var datesOnly = dates
.Select(d => new DateOnly(d.Year, d.Month, d.Day))
.Distinct();
.Distinct()
.OrderBy(d => d);
return datesOnly;
}
@ -214,7 +215,11 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
query = createdQuery.Union(editedQuery);
}
var entities = await query.ToListAsync(token);
var entities = await query
.OrderBy(e => e.Creation)
.ThenBy(e => e.Obsolete)
.ThenBy(e => e.Id)
.ToListAsync(token);
var dtos = entities.Select(e => Convert(e, offset));
return dtos;
@ -223,7 +228,11 @@ public abstract class ChangeLogRepositoryAbstract<TDto, TEntity, TRequest> : ICh
public async Task<IEnumerable<TDto>> Get(TRequest request, CancellationToken token)
{
var query = BuildQuery(request);
var entities = await query.ToArrayAsync(token);
var entities = await query
.OrderBy(e => e.Creation)
.ThenBy(e => e.Obsolete)
.ThenBy(e => e.Id)
.ToArrayAsync(token);
TimeSpan offset = GetTimezoneOffset(request);
var dtos = entities.Select(e => Convert(e, offset));

View File

@ -383,12 +383,12 @@ public class WellOperationRepository : IWellOperationRepository
new[] { nameof(wellOperationDtos) });
}
if (previousDateEnd > currentDateStart)
{
yield return new ValidationResult(
"Предыдущая операция не завершена",
new[] { nameof(wellOperationDtos) });
}
//if (previousDateEnd > currentDateStart)
//{
// yield return new ValidationResult(
// "Предыдущая операция не завершена",
// new[] { nameof(wellOperationDtos) });
//}
previous = current;
}

View File

@ -299,7 +299,7 @@ namespace AsbCloudInfrastructure.Services.SAUB
if (request.LeDate.HasValue)
{
var leDate = request.LeDate.Value.ToRemoteDateTime(cacheItem.TimezoneHours);
data = data.Where(d => d.DateTime >= request.LeDate);
data = data.Where(d => d.DateTime <= request.LeDate);
}
if (request.Divider > 1)

View File

@ -2,6 +2,7 @@ using AsbCloudApp.Data;
using AsbCloudApp.Requests;
using AsbCloudDb.Model;
using AsbCloudWebApi.IntegrationTests.Clients;
using Microsoft.EntityFrameworkCore;
using Xunit;
namespace AsbCloudWebApi.IntegrationTests.Controllers;
@ -10,7 +11,7 @@ public class SlipsStatControllerTest : BaseIntegrationTest
{
private static readonly Schedule schedule = new()
{
Id = 1,
Id = 0,
IdDriller = Data.Defaults.Drillers[0].Id,
IdWell = Data.Defaults.Wells[0].Id,
ShiftStart = new TimeOnly(8, 0, 0),
@ -21,7 +22,7 @@ public class SlipsStatControllerTest : BaseIntegrationTest
private static readonly DetectedOperation detectedOperation = new()
{
Id = 1,
Id = 0,
IdTelemetry = Data.Defaults.Telemetries[0].Id,
IdCategory = WellOperationCategory.IdSlipsTime,
DateStart = new DateTimeOffset(new DateTime(2024, 1, 23, 15, 0, 0, 0, DateTimeKind.Utc)),
@ -34,7 +35,7 @@ public class SlipsStatControllerTest : BaseIntegrationTest
private static readonly WellOperation factWellOperation = new()
{
Id = 1,
Id = 0,
IdWell = Data.Defaults.Wells[0].Id,
IdWellSectionType = 1,
IdCategory = WellOperationCategory.IdRotor,
@ -51,9 +52,18 @@ public class SlipsStatControllerTest : BaseIntegrationTest
public SlipsStatControllerTest(WebAppFactoryFixture factory)
: base(factory)
{
dbContext.Schedule.Add(schedule);
dbContext.DetectedOperations.Add(detectedOperation);
dbContext.WellOperations.Add(factWellOperation);
var schedules = dbContext.Set<Schedule>();
var detectedOperations = dbContext.Set<DetectedOperation>();
var wellOperations = dbContext.Set<WellOperation>();
schedules.RemoveRange(schedules);
detectedOperations.RemoveRange(detectedOperations);
wellOperations.RemoveRange(wellOperations);
dbContext.SaveChanges();
schedules.Add(schedule);
detectedOperations.Add(detectedOperation);
wellOperations.Add(factWellOperation);
dbContext.SaveChanges();
client = factory.GetAuthorizedHttpClient<ISlipsTimeClient>();

View File

@ -76,8 +76,10 @@ namespace Microsoft.AspNetCore.Mvc
public static BadRequestObjectResult ValidationBadRequest(this ControllerBase controller, IEnumerable<ValidationResult> validationResults)
{
var errors = validationResults
.SelectMany(e => e.MemberNames.Select(name=> new { name, e.ErrorMessage }))
.ToDictionary(e => e.name, e => new[] { e.ErrorMessage ?? string.Empty });
.SelectMany(e => e.MemberNames.Select(name => new { name, e.ErrorMessage }))
.GroupBy(e => e.name)
.ToDictionary(e => e.Key, e => e.Select(el => el.ErrorMessage ?? string.Empty).ToArray());
var problem = new ValidationProblemDetails(errors);
return controller.BadRequest(problem);
}