Compare commits
4 Commits
46e547e3e2
...
aca468c015
Author | SHA1 | Date | |
---|---|---|---|
|
aca468c015 | ||
|
ade18e5e40 | ||
|
b06df453d2 | ||
|
786a5bfe26 |
@ -60,7 +60,10 @@ public class ExcelReader : IReader, IDisposable
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Product product = new(currentSku);
|
Product product = new(currentSku)
|
||||||
|
{
|
||||||
|
Name = $"Распознанный артикул"
|
||||||
|
};
|
||||||
|
|
||||||
if (readResult.ContainsKey(product))
|
if (readResult.ContainsKey(product))
|
||||||
{
|
{
|
||||||
@ -110,7 +113,7 @@ public class ExcelReader : IReader, IDisposable
|
|||||||
object name = worksheet.Cells[row, NameCell.Column].Value2;
|
object name = worksheet.Cells[row, NameCell.Column].Value2;
|
||||||
object sku = worksheet.Cells[row, SkuCell.Column].Value2;
|
object sku = worksheet.Cells[row, SkuCell.Column].Value2;
|
||||||
object measure = worksheet.Cells[row, MeasureCell.Column].Value2;
|
object measure = worksheet.Cells[row, MeasureCell.Column].Value2;
|
||||||
var productMeasure = measure.ToString() switch
|
var productMeasure = measure?.ToString() switch
|
||||||
{
|
{
|
||||||
"м" => Measure.M,
|
"м" => Measure.M,
|
||||||
"шт" => Measure.P,
|
"шт" => Measure.P,
|
||||||
|
@ -167,6 +167,7 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
int skuColumn = _skuCell.Column;
|
int skuColumn = _skuCell.Column;
|
||||||
int groupColumn = _programLineCell.Column;
|
int groupColumn = _programLineCell.Column;
|
||||||
int nameColumn = _nameCell.Column;
|
int nameColumn = _nameCell.Column;
|
||||||
|
Product product = positionAmount.Key;
|
||||||
|
|
||||||
int row = worksheetCells[worksheetRows.Count, skuColumn]
|
int row = worksheetCells[worksheetRows.Count, skuColumn]
|
||||||
.End[XlDirection.xlUp]
|
.End[XlDirection.xlUp]
|
||||||
@ -182,18 +183,13 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
previous.Copy(current);
|
previous.Copy(current);
|
||||||
current.ClearContents();
|
current.ClearContents();
|
||||||
|
|
||||||
worksheetCells[row, groupColumn].Value2 = positionAmount.Key.ProductLines.First();
|
worksheetCells[row, groupColumn].Value2 = product.ProductLines.FirstOrDefault() ?? string.Empty;
|
||||||
worksheetCells[row, nameColumn].Value2 = positionAmount.Key.Name;
|
worksheetCells[row, nameColumn].Value2 = $"{product.Name} не найден ({product.ProductSku})";
|
||||||
|
|
||||||
|
worksheetCells[row, skuColumn].Value2 = "???";
|
||||||
if (_oldSkuCell != null)
|
if (_oldSkuCell != null)
|
||||||
{
|
{
|
||||||
worksheetCells[row, skuColumn].Value2 = "Не найден";
|
worksheetCells[row, _oldSkuCell.Column].Value2 = product.ProductSku;
|
||||||
worksheetCells[row, _oldSkuCell.Column].Value2 = positionAmount.Key.ProductSku;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
worksheetCells[row, skuColumn].Value2 = positionAmount.Key.ProductSku;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int column in columns)
|
foreach (int column in columns)
|
||||||
|
@ -45,14 +45,17 @@ public class CanReadProducts : IDisposable
|
|||||||
Assert.Equal(3, products.Count());
|
Assert.Equal(3, products.Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcelFact(Workbook = @"TestWorkbooks\Specifications\HeatingFloor.xlsx")]
|
[ExcelFact(Workbook = @"TestWorkbooks\TestSpecificaion.xlsx")]
|
||||||
public void CanReadWorkbook()
|
public void CanReadWorkbook()
|
||||||
{
|
{
|
||||||
Worksheet worksheet = Util.Workbook.Worksheets[1];
|
Worksheet worksheet = Util.Workbook.Worksheets[1];
|
||||||
var products = _reader.ReadProducts(new[] { worksheet });
|
var result = _reader.ReadProducts(new[] { worksheet });
|
||||||
|
Assert.NotNull(result);
|
||||||
Assert.NotNull(products);
|
Assert.NotEmpty(result);
|
||||||
Assert.NotEmpty(products);
|
Assert.Equal("TestSpecificaion", result.First().Item1);
|
||||||
|
var products = result.First().Item2;
|
||||||
|
Assert.Equal(46, products.Count());
|
||||||
|
Assert.Equal(29266, products.Sum(p => p.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<None Update="TestWorkbooks\ExcelTableTest.xlsx">
|
<None Update="TestWorkbooks\ExcelTableTest.xlsx">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Update="TestWorkbooks\Specifications\HeatingFloor.xlsx">
|
<None Update="TestWorkbooks\TestSpecificaion.xlsx">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Binary file not shown.
BIN
RhSolutions.Tests/TestWorkbooks/TestSpecificaion.xlsx
Normal file
BIN
RhSolutions.Tests/TestWorkbooks/TestSpecificaion.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user