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>
public int Order { get; set; }
public float Order { get; set; }
}

View File

@ -9,12 +9,12 @@ using System.Threading.Tasks;
namespace AsbCloudApp.Repositories
{
/// <summary>
/// ÐÒÊ
/// РТК-план
/// </summary>
public interface IProcessMapPlanRepository : IRepositoryWellRelated<ProcessMapPlanDto>
{
/// <summary>
/// Ïîëó÷èòü ïàðàìåòðû áóðåíèÿ íà÷èíàÿ ñ äàòû.
/// Получить РТК-план начиная с даты.
/// </summary>
/// <param name="idWell"></param>
/// <param name="updateFrom"></param>
@ -24,11 +24,20 @@ namespace AsbCloudApp.Repositories
DateTime? updateFrom, CancellationToken token = default);
/// <summary>
/// Ïîëó÷èòü ïàðàìåòðû áóðåíèÿ
/// Получить РТК-план
/// </summary>
/// <param name="requests"></param>
/// <param name="token"></param>
/// <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>
/// <param name="idWell"></param>
/// <param name="idUser"></param>
/// <param name="deleteProcessMapPlansBeforeImport"></param>
/// <param name="stream"></param>
/// <param name="cancellationToken"></param>
/// <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>
/// Сформировать файл с данными

View File

@ -60,6 +60,15 @@ namespace AsbCloudInfrastructure.Repository
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,
CancellationToken token)
{

View File

@ -52,7 +52,8 @@ public class ProcessMapPlanImportService : IProcessMapPlanImportService
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();
@ -60,6 +61,9 @@ public class ProcessMapPlanImportService : IProcessMapPlanImportService
var processPlanMaps = ParseWorkBook(workBook);
if (deleteProcessMapPlansBeforeImport)
await processMapPlanRepository.RemoveByWellAsync(idWell, cancellationToken);
foreach (var processPlanMap in processPlanMaps)
{
processPlanMap.IdWell = idWell;

View File

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