2024-02-09 11:32:31 +05:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using AsbCloudApp.Data;
|
|
|
|
using AsbCloudApp.Data.ProcessMapPlan;
|
|
|
|
using AsbCloudApp.Repositories;
|
2024-02-14 14:13:43 +05:00
|
|
|
using AsbCloudInfrastructure.Services.Parser;
|
2024-02-09 11:32:31 +05:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
|
|
|
|
|
|
|
|
public class ProcessMapPlanDrillingParser : ProcessMapPlanParser<ProcessMapPlanDrillingDto>
|
|
|
|
{
|
|
|
|
private readonly IEnumerable<WellSectionTypeDto> sections;
|
|
|
|
|
|
|
|
public ProcessMapPlanDrillingParser(IServiceProvider serviceProvider)
|
|
|
|
: base(serviceProvider)
|
|
|
|
{
|
|
|
|
var wellOperationRepository = serviceProvider.GetRequiredService<IWellOperationRepository>();
|
|
|
|
|
|
|
|
sections = wellOperationRepository.GetSectionTypes();
|
|
|
|
}
|
2024-02-13 16:05:16 +05:00
|
|
|
|
2024-02-09 11:32:31 +05:00
|
|
|
protected override string SheetName => "План";
|
2024-02-13 16:05:16 +05:00
|
|
|
protected override string TemplateFileName => "ProcessMapPlanDrillingTemplate.xlsx";
|
2024-02-09 11:32:31 +05:00
|
|
|
|
2024-02-13 16:05:16 +05:00
|
|
|
private const int ColumnSection = 1;
|
|
|
|
private const int ColumnMode = 2;
|
|
|
|
|
|
|
|
protected override IDictionary<string, Cell> Cells => new Dictionary<string, Cell>
|
2024-02-12 17:25:18 +05:00
|
|
|
{
|
2024-02-14 14:13:43 +05:00
|
|
|
{ nameof(ProcessMapPlanDrillingDto.Section), new Cell(ColumnSection, typeof(string)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.Mode), new Cell(ColumnMode, typeof(string)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.DepthStart), new Cell(3, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.DepthEnd), new Cell(4, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.DeltaPressurePlan), new Cell(5, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.DeltaPressureLimitMax), new Cell(6, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.AxialLoadPlan), new Cell(7, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.AxialLoadLimitMax), new Cell(8, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.TopDriveTorquePlan), new Cell(9, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.TopDriveTorqueLimitMax), new Cell(10, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.TopDriveSpeedPlan), new Cell(11, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.TopDriveSpeedLimitMax), new Cell(12, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.FlowPlan), new Cell(13, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.FlowLimitMax), new Cell(14, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.RopPlan), new Cell(15, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.UsageSaub), new Cell(16, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.UsageSpin), new Cell(17, typeof(double)) },
|
|
|
|
{ nameof(ProcessMapPlanDrillingDto.Comment), new Cell(18, typeof(string)) }
|
2024-02-12 17:25:18 +05:00
|
|
|
};
|
|
|
|
|
2024-02-14 14:13:43 +05:00
|
|
|
protected override ProcessMapPlanDrillingDto BuildDto(IDictionary<string, object?> row, int rowNumber)
|
2024-02-09 11:32:31 +05:00
|
|
|
{
|
2024-02-14 14:13:43 +05:00
|
|
|
var dto = base.BuildDto(row, rowNumber);
|
2024-02-09 11:32:31 +05:00
|
|
|
|
|
|
|
var section = sections.FirstOrDefault(s =>
|
2024-02-13 16:05:16 +05:00
|
|
|
string.Equals(s.Caption.Trim(), dto.Section?.Trim(), StringComparison.CurrentCultureIgnoreCase));
|
2024-02-09 11:32:31 +05:00
|
|
|
|
|
|
|
if (section is null)
|
|
|
|
{
|
2024-02-14 14:13:43 +05:00
|
|
|
var message = string.Format(XLExtentions.ProblemDetailsTemplate, SheetName, rowNumber, ColumnSection,
|
2024-02-09 11:32:31 +05:00
|
|
|
"Указана некорректная секция");
|
|
|
|
throw new FileFormatException(message);
|
|
|
|
}
|
|
|
|
|
2024-02-13 16:05:16 +05:00
|
|
|
var idMode = GetIdMode(dto.Mode);
|
2024-02-09 11:32:31 +05:00
|
|
|
|
|
|
|
if (idMode is null)
|
|
|
|
{
|
2024-02-14 14:13:43 +05:00
|
|
|
var message = string.Format(XLExtentions.ProblemDetailsTemplate, SheetName, rowNumber, ColumnSection,
|
2024-02-09 11:32:31 +05:00
|
|
|
"Указан некорректный режим бурения");
|
|
|
|
throw new FileFormatException(message);
|
|
|
|
}
|
|
|
|
|
2024-02-13 16:05:16 +05:00
|
|
|
dto.IdWellSectionType = section.Id;
|
|
|
|
dto.IdMode = idMode.Value;
|
2024-02-09 11:32:31 +05:00
|
|
|
|
2024-02-12 17:25:18 +05:00
|
|
|
return dto;
|
2024-02-09 11:32:31 +05:00
|
|
|
}
|
|
|
|
}
|