forked from ddrilling/AsbCloudServer
Фикс
This commit is contained in:
parent
f325accca1
commit
a2da2c912f
@ -17,6 +17,7 @@ using AsbCloudApp.Services.WellOperationImport;
|
||||
using AsbCloudApp.Data.WellOperationImport.Options;
|
||||
using AsbCloudApp.Exceptions;
|
||||
using AsbCloudDb.Model;
|
||||
using AsbCloudInfrastructure;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers
|
||||
{
|
||||
@ -267,7 +268,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (!await CanUserEditWellOperationsAsync(idWell, cancellationToken))
|
||||
return Forbid();
|
||||
|
||||
if (deleteBeforeInsert && wellOperations.Any())
|
||||
if (deleteBeforeInsert)
|
||||
{
|
||||
var existingOperations = await operationRepository.GetAsync(new WellOperationRequest
|
||||
{
|
||||
@ -356,7 +357,6 @@ namespace AsbCloudWebApi.Controllers
|
||||
[HttpPost("import/fact/default/{deleteBeforeInsert:bool}")]
|
||||
[ProducesResponseType(typeof(IEnumerable<WellOperationDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[Permission]
|
||||
public Task<IActionResult> ImportFactDefaultExcelFileAsync(int idWell,
|
||||
[FromForm] IFormFileCollection files,
|
||||
@ -384,7 +384,6 @@ namespace AsbCloudWebApi.Controllers
|
||||
[HttpPost("import/plan/default")]
|
||||
[ProducesResponseType(typeof(IEnumerable<WellOperationDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[Permission]
|
||||
public Task<IActionResult> ImportPlanDefaultExcelFileAsync(int idWell,
|
||||
[FromForm] IFormFileCollection files,
|
||||
@ -411,7 +410,6 @@ namespace AsbCloudWebApi.Controllers
|
||||
[HttpPost("import/plan/gazpromKhantos")]
|
||||
[ProducesResponseType(typeof(IEnumerable<WellOperationDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[Permission]
|
||||
public Task<IActionResult> ImportPlanGazpromKhantosExcelFileAsync(int idWell,
|
||||
[FromForm] IFormFileCollection files,
|
||||
@ -533,13 +531,13 @@ namespace AsbCloudWebApi.Controllers
|
||||
var wellOperations = wellOperationImportService.Import(idWell, idUser.Value, options.IdType, sheet)
|
||||
.OrderBy(w => w.DateStart);
|
||||
|
||||
var dateStart = wellOperations.Min(w => w.DateStart);
|
||||
var dateStart = wellOperations.MinOrDefault(w => w.DateStart);
|
||||
|
||||
foreach (var wellOperation in wellOperations)
|
||||
wellOperation.Day = (wellOperation.DateStart - dateStart).TotalDays;
|
||||
|
||||
if (!wellOperations.Any())
|
||||
return NoContent();
|
||||
{
|
||||
if (dateStart.HasValue)
|
||||
wellOperation.Day = (wellOperation.DateStart - dateStart.Value).TotalDays;
|
||||
}
|
||||
|
||||
//TODO: очень быстрый костыль
|
||||
if (deleteBeforeInsert is not null && options.IdType == WellOperation.IdOperationTypeFact)
|
||||
|
Loading…
Reference in New Issue
Block a user