diff --git a/AsbCloudApp/Data/WellSectionTypeDto.cs b/AsbCloudApp/Data/WellSectionTypeDto.cs
index 88434e20..28e9ba68 100644
--- a/AsbCloudApp/Data/WellSectionTypeDto.cs
+++ b/AsbCloudApp/Data/WellSectionTypeDto.cs
@@ -18,5 +18,5 @@ public class WellSectionTypeDto : IId
///
/// Порядок
///
- public int Order { get; set; }
+ public float Order { get; set; }
}
\ No newline at end of file
diff --git a/AsbCloudApp/Repositories/IProcessMapRepository.cs b/AsbCloudApp/Repositories/IProcessMapRepository.cs
index b126e18a..f6dbe6b4 100644
--- a/AsbCloudApp/Repositories/IProcessMapRepository.cs
+++ b/AsbCloudApp/Repositories/IProcessMapRepository.cs
@@ -9,12 +9,12 @@ using System.Threading.Tasks;
namespace AsbCloudApp.Repositories
{
///
- ///
+ /// РТК-план
///
public interface IProcessMapPlanRepository : IRepositoryWellRelated
{
///
- /// .
+ /// Получить РТК-план начиная с даты.
///
///
///
@@ -24,11 +24,20 @@ namespace AsbCloudApp.Repositories
DateTime? updateFrom, CancellationToken token = default);
///
- ///
+ /// Получить РТК-план
///
///
///
///
- Task> GetProcessMapAsync(IEnumerable requests, CancellationToken token);
+ Task> GetProcessMapAsync(IEnumerable requests,
+ CancellationToken token);
+
+ ///
+ /// Удалить РТК-план по скважине
+ ///
+ ///
+ ///
+ ///
+ Task RemoveByWellAsync(int idWell, CancellationToken cancellationToken);
}
}
\ No newline at end of file
diff --git a/AsbCloudApp/Services/IProcessMapPlanImportService.cs b/AsbCloudApp/Services/IProcessMapPlanImportService.cs
index 84442df1..c5daa587 100644
--- a/AsbCloudApp/Services/IProcessMapPlanImportService.cs
+++ b/AsbCloudApp/Services/IProcessMapPlanImportService.cs
@@ -14,10 +14,12 @@ public interface IProcessMapPlanImportService
///
///
///
+ ///
///
///
///
- Task ImportAsync(int idWell, int idUser, Stream stream, CancellationToken cancellationToken);
+ Task ImportAsync(int idWell, int idUser, bool deleteProcessMapPlansBeforeImport, Stream stream,
+ CancellationToken cancellationToken);
///
/// Сформировать файл с данными
diff --git a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs
index b80fe6d9..6597210b 100644
--- a/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs
+++ b/AsbCloudInfrastructure/Repository/ProcessMapRepository.cs
@@ -60,6 +60,15 @@ namespace AsbCloudInfrastructure.Repository
return dtos;
}
+ public Task 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 InsertAsync(ProcessMapPlanDto dto,
CancellationToken token)
{
diff --git a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapPlanImportService.cs b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapPlanImportService.cs
index 60fbc9bd..2b4467af 100644
--- a/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapPlanImportService.cs
+++ b/AsbCloudInfrastructure/Services/ProcessMap/ProcessMapPlanImportService.cs
@@ -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;
diff --git a/AsbCloudWebApi/Controllers/ProcessMapController.cs b/AsbCloudWebApi/Controllers/ProcessMapController.cs
index 474c260c..95f41405 100644
--- a/AsbCloudWebApi/Controllers/ProcessMapController.cs
+++ b/AsbCloudWebApi/Controllers/ProcessMapController.cs
@@ -183,12 +183,14 @@ namespace AsbCloudWebApi.Controllers
/// Импортирует плановой РТК из excel (xlsx) файла
///
/// Id скважины
+ /// Удалить РТК перед импортом = 1, если файл валидный
/// Загружаемый файл
///
///
[HttpPost]
- [Route("import")]
+ [Route("import/{idWell}/{options}")]
public async Task 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
///
///
[HttpGet]
- [Route("export")]
+ [Route("export/{idWell}")]
[ProducesResponseType(typeof(PhysicalFileResult), (int)System.Net.HttpStatusCode.OK)]
- public async Task ExportAsync([FromQuery] int idWell, CancellationToken cancellationToken)
+ public async Task ExportAsync(int idWell, CancellationToken cancellationToken)
{
int? idUser = User.GetUserId();