Merge branch 'dev' into fix/daily_report

This commit is contained in:
Степанов Дмитрий 2023-12-11 11:00:24 +05:00
commit ed59cbbb62
2 changed files with 55 additions and 58 deletions

View File

@ -1,61 +1,60 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace AsbCloudApp.Data.User namespace AsbCloudApp.Data.User;
/// <summary>
/// Контакт
/// </summary>
public class ContactDto : IId
{ {
/// <inheritdoc/>
public int Id { get; set; }
/// <summary> /// <summary>
/// Контакт /// ключ типа компании
/// </summary> /// </summary>
[Required]
[Range(1, int.MaxValue)]
public int IdCompanyType { get; set; }
public class ContactDto : IId /// <summary>
{ /// ключ скважины
/// <inheritdoc/> /// </summary>
public int Id { get; set; } [Required]
[Range(1,int.MaxValue)]
public int IdWell { get; set; }
/// <summary> /// <summary>
/// ключ типа компании /// ФИО
/// </summary> /// </summary>
[Required] [Required]
public int IdCompanyType { get; set; } [StringLength(260, MinimumLength = 0, ErrorMessage = "Допустимая длина ФИО от 1 до 260 символов")]
public string FullName { get; set; } = null!;
/// <summary> /// <summary>
/// ключ скважины /// Email
/// </summary> /// </summary>
[Required] [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Некорректный email")]
public int IdWell { get; set; } public string? Email { get; set; }
/// <summary> /// <summary>
/// ФИО /// Phone
/// </summary> /// </summary>
[Required] [RegularExpression(@"^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$", ErrorMessage = "Некорректный номер телефона")]
[StringLength(260, MinimumLength = 0, ErrorMessage = "Допустимая длина ФИО от 1 до 260 символов")] public string? Phone { get; set; }
public string FullName { get; set; } = null!;
/// <summary> /// <summary>
/// Email /// Должность
/// </summary> /// </summary>
[RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "Некорректный email")] [Required]
public string? Email { get; set; } [StringLength(260, MinimumLength = 1, ErrorMessage = "Допустимая длина должности от 1 до 260 символов")]
public string Position { get; set; } = null!;
/// <summary> /// <summary>
/// Phone /// Компания
/// </summary> /// </summary>
[RegularExpression(@"^(?:\+7|8)\s?(?:\(\d{3}\)|\d{3})\s?\d{3}-?\d{2}-?\d{2}$", ErrorMessage = "Некорректный номер телефона")] [Required]
public string? Phone { get; set; } [StringLength(260, MinimumLength = 3, ErrorMessage = "Допустимая длина названия компании от 3 до 260 символов")]
public string Company { get; set; } = null!;
/// <summary>
/// Должность
/// </summary>
[Required]
[StringLength(260, MinimumLength = 1, ErrorMessage = "Допустимая длина должности от 1 до 260 символов")]
public string Position { get; set; } = null!;
/// <summary>
/// Компания
/// </summary>
[Required]
[StringLength(260, MinimumLength = 3, ErrorMessage = "Допустимая длина должности от 3 до 260 символов")]
public string Company { get; set; } = null!;
}
} }

View File

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