Merge branch 'dev' into feature/daily_report

This commit is contained in:
Никита Фролов 2023-07-25 17:39:31 +05:00
commit 8f95e12f22
6 changed files with 37 additions and 10 deletions

View File

@ -18,5 +18,5 @@ public class WellSectionTypeDto : IId
/// <summary> /// <summary>
/// Порядок /// Порядок
/// </summary> /// </summary>
public int Order { get; set; } public float Order { get; set; }
} }

View File

@ -9,12 +9,12 @@ using System.Threading.Tasks;
namespace AsbCloudApp.Repositories namespace AsbCloudApp.Repositories
{ {
/// <summary> /// <summary>
/// ÐÒÊ /// РТК-план
/// </summary> /// </summary>
public interface IProcessMapPlanRepository : IRepositoryWellRelated<ProcessMapPlanDto> public interface IProcessMapPlanRepository : IRepositoryWellRelated<ProcessMapPlanDto>
{ {
/// <summary> /// <summary>
/// Ïîëó÷èòü ïàðàìåòðû áóðåíèÿ íà÷èíàÿ ñ äàòû. /// Получить РТК-план начиная с даты.
/// </summary> /// </summary>
/// <param name="idWell"></param> /// <param name="idWell"></param>
/// <param name="updateFrom"></param> /// <param name="updateFrom"></param>
@ -24,11 +24,20 @@ namespace AsbCloudApp.Repositories
DateTime? updateFrom, CancellationToken token = default); DateTime? updateFrom, CancellationToken token = default);
/// <summary> /// <summary>
/// Ïîëó÷èòü ïàðàìåòðû áóðåíèÿ /// Получить РТК-план
/// </summary> /// </summary>
/// <param name="requests"></param> /// <param name="requests"></param>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
Task<IEnumerable<ProcessMapPlanDto>> GetProcessMapAsync(IEnumerable<ProcessMapRequest> requests, CancellationToken token); Task<IEnumerable<ProcessMapPlanDto>> GetProcessMapAsync(IEnumerable<ProcessMapRequest> requests,
CancellationToken token);
/// <summary>
/// Удалить РТК-план по скважине
/// </summary>
/// <param name="idWell"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
Task<int> RemoveByWellAsync(int idWell, CancellationToken cancellationToken);
} }
} }

View File

@ -14,10 +14,12 @@ public interface IProcessMapPlanImportService
/// </summary> /// </summary>
/// <param name="idWell"></param> /// <param name="idWell"></param>
/// <param name="idUser"></param> /// <param name="idUser"></param>
/// <param name="deleteProcessMapPlansBeforeImport"></param>
/// <param name="stream"></param> /// <param name="stream"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
Task ImportAsync(int idWell, int idUser, Stream stream, CancellationToken cancellationToken); Task ImportAsync(int idWell, int idUser, bool deleteProcessMapPlansBeforeImport, Stream stream,
CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Сформировать файл с данными /// Сформировать файл с данными

View File

@ -60,6 +60,15 @@ namespace AsbCloudInfrastructure.Repository
return dtos; return dtos;
} }
public Task<int> RemoveByWellAsync(int idWell, CancellationToken cancellationToken)
{
var query = dbContext.ProcessMap.Where(x => x.IdWell == idWell);
dbContext.ProcessMap.RemoveRange(query);
return dbContext.SaveChangesAsync(cancellationToken);
}
public override async Task<int> InsertAsync(ProcessMapPlanDto dto, public override async Task<int> InsertAsync(ProcessMapPlanDto dto,
CancellationToken token) CancellationToken token)
{ {

View File

@ -52,7 +52,8 @@ public class ProcessMapPlanImportService : IProcessMapPlanImportService
this.wellSectionTypeRepository = wellSectionTypeRepository; this.wellSectionTypeRepository = wellSectionTypeRepository;
} }
public async Task ImportAsync(int idWell, int idUser, Stream stream, CancellationToken cancellationToken) public async Task ImportAsync(int idWell, int idUser, bool deleteProcessMapPlansBeforeImport, Stream stream,
CancellationToken cancellationToken)
{ {
sections = (await wellSectionTypeRepository.GetAllAsync(cancellationToken)).ToArray(); sections = (await wellSectionTypeRepository.GetAllAsync(cancellationToken)).ToArray();
@ -60,6 +61,9 @@ public class ProcessMapPlanImportService : IProcessMapPlanImportService
var processPlanMaps = ParseWorkBook(workBook); var processPlanMaps = ParseWorkBook(workBook);
if (deleteProcessMapPlansBeforeImport)
await processMapPlanRepository.RemoveByWellAsync(idWell, cancellationToken);
foreach (var processPlanMap in processPlanMaps) foreach (var processPlanMap in processPlanMaps)
{ {
processPlanMap.IdWell = idWell; processPlanMap.IdWell = idWell;

View File

@ -183,12 +183,14 @@ namespace AsbCloudWebApi.Controllers
/// Импортирует плановой РТК из excel (xlsx) файла /// Импортирует плановой РТК из excel (xlsx) файла
/// </summary> /// </summary>
/// <param name="idWell">Id скважины</param> /// <param name="idWell">Id скважины</param>
/// <param name="options">Удалить РТК перед импортом = 1, если файл валидный</param>
/// <param name="file">Загружаемый файл</param> /// <param name="file">Загружаемый файл</param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("import")] [Route("import/{idWell}/{options}")]
public async Task<IActionResult> ImportAsync(int idWell, public async Task<IActionResult> ImportAsync(int idWell,
int options,
[Required] IFormFile file, [Required] IFormFile file,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
@ -204,6 +206,7 @@ namespace AsbCloudWebApi.Controllers
await processMapPlanImportService.ImportAsync(idWell, await processMapPlanImportService.ImportAsync(idWell,
idUser.Value, idUser.Value,
(options & 1) > 0,
stream, stream,
cancellationToken); cancellationToken);
@ -217,9 +220,9 @@ namespace AsbCloudWebApi.Controllers
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
[Route("export")] [Route("export/{idWell}")]
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)] [ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
public async Task<IActionResult> ExportAsync([FromQuery] int idWell, CancellationToken cancellationToken) public async Task<IActionResult> ExportAsync(int idWell, CancellationToken cancellationToken)
{ {
int? idUser = User.GetUserId(); int? idUser = User.GetUserId();