forked from ddrilling/AsbCloudServer
60 lines
2.3 KiB
C#
60 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using AsbCloudApp.Data;
|
|
using AsbCloudApp.Data.ProcessMaps;
|
|
using AsbCloudApp.Repositories;
|
|
using AsbCloudInfrastructure.Services.Parser;
|
|
|
|
namespace AsbCloudInfrastructure.Services.ProcessMapPlan.Parser;
|
|
|
|
public class ProcessMapPlanReamParser : ProcessMapPlanParser<ProcessMapPlanReamDto>
|
|
{
|
|
private readonly IEnumerable<WellSectionTypeDto> sections;
|
|
|
|
public ProcessMapPlanReamParser(IWellOperationRepository wellOperationRepository)
|
|
{
|
|
sections = wellOperationRepository.GetSectionTypes();
|
|
}
|
|
|
|
protected override string SheetName => "План";
|
|
protected override string TemplateFileName => "ProcessMapPlanReamTemplate.xlsx";
|
|
|
|
private const int ColumnSection = 1;
|
|
|
|
protected override IDictionary<string, Cell> Cells => new Dictionary<string, Cell>
|
|
{
|
|
{ nameof(ProcessMapPlanReamDto.Section), new Cell(ColumnSection, typeof(string)) },
|
|
{ nameof(ProcessMapPlanReamDto.DepthStart), new Cell(2, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.DepthEnd), new Cell(3, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.Repeats), new Cell(4, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.SpinUpward), new Cell(5, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.SpinUpward), new Cell(6, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.SpeedDownward), new Cell(7, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.SpeedUpward), new Cell(8, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.SetpointDrag), new Cell(9, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.SetpointTight), new Cell(10, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.Pressure), new Cell(11, typeof(double)) },
|
|
{ nameof(ProcessMapPlanReamDto.Torque), new Cell(12, typeof(double)) },
|
|
};
|
|
|
|
protected override ProcessMapPlanReamDto BuildDto(IDictionary<string, object?> row, int rowNumber)
|
|
{
|
|
var dto = base.BuildDto(row, rowNumber);
|
|
|
|
var section = sections.FirstOrDefault(s =>
|
|
string.Equals(s.Caption.Trim(), dto.Section?.Trim(), StringComparison.CurrentCultureIgnoreCase));
|
|
|
|
if (section is null)
|
|
{
|
|
var message = string.Format(XLExtentions.ProblemDetailsTemplate, SheetName, rowNumber, ColumnSection,
|
|
"Указана некорректная секция");
|
|
throw new FileFormatException(message);
|
|
}
|
|
|
|
dto.IdWellSectionType = section.Id;
|
|
|
|
return dto;
|
|
}
|
|
} |