Compare commits

..

12 Commits

12 changed files with 298 additions and 253 deletions

27
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,27 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE",
"args": [
"${workspaceFolder}\\RhSolutions.AddIn\\bin\\Debug\\net6.0-windows\\RhSolutions-AddIn64.xll"
],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"stopAtEntry": false,
"requireExactSource": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}

12
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,12 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "dotnet",
"task": "build ${workspaceFolder}\\RhSolutions.AddIn\\RhSolutions.AddIn.csproj",
"group": "build",
"problemMatcher": [],
"label": "build"
},
]
}

View File

@ -14,7 +14,7 @@
*Для работы функций "Экспорт", "Актуализация" и "Объединение" требуется указать путь к файлу пустого прайс-листа РЕХАУ* *Для работы функций "Экспорт", "Актуализация" и "Объединение" требуется указать путь к файлу пустого прайс-листа РЕХАУ*
## Реализованные формулы для работы с артикулами ## Реализованные формулы для работы с артикулами
- ```=RHSOLUTIONS()``` и ```=РЕХАУ()``` - поиск в удаленной базе данных - ```=РЕХАУ()``` - поиск артикула РЕХАУ по произвольному запросу в сервисе [RhSolutions-Api](https://gitea.cebotari.ru/chebser/RhSolutions-Api)
- ```=РЕХАУАРТИКУЛ()``` - экстракция артикула РЕХАУ из любой строки по регулярному выражению - ```=РЕХАУАРТИКУЛ()``` - экстракция артикула РЕХАУ из любой строки по регулярному выражению
- ```=РЕХАУИМЯ()``` - поиск названия артикула по номеру - ```=РЕХАУИМЯ()``` - поиск названия артикула по номеру
- ```=РЕХАУЦЕНА()``` - поиск цены в евро по номеру артикула - ```=РЕХАУЦЕНА()``` - поиск цены в евро по номеру артикула

View File

@ -8,8 +8,21 @@ public static class RhSolutionsFunctions
RhSolutionsAddIn.ServiceProvider.GetRequiredService<ICurrencyClient>(); RhSolutionsAddIn.ServiceProvider.GetRequiredService<ICurrencyClient>();
[ExcelFunction(Name = "РЕХАУ")] [ExcelFunction(Name = "РЕХАУ")]
public static object ProductSearch(string query) public static object ProductSearch(object[,] values)
{ {
List<string> strings = new();
int rows = values.GetLength(0);
int columns = values.GetLength(1);
for (int row = 0; row < rows; row++)
{
for (int column = 0; column < columns; column++)
{
object value = values[row, column];
strings.Add(value.ToString());
}
}
string query = string.Join(" ", strings.ToArray());
var functionName = nameof(ProductSearch); var functionName = nameof(ProductSearch);
var parameters = new object[] { query }; var parameters = new object[] { query };
if (ExcelAsyncUtil.RunTask(functionName, parameters, async () => if (ExcelAsyncUtil.RunTask(functionName, parameters, async () =>

View File

@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.9.5.0")] [assembly: AssemblyVersion("1.9.5.1")]
[assembly: AssemblyFileVersion("1.9.5.0")] [assembly: AssemblyFileVersion("1.9.5.1")]

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net472</TargetFrameworks> <TargetFrameworks>net472;net6.0-windows</TargetFrameworks>
<LangVersion>10</LangVersion> <LangVersion>10</LangVersion>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>RhSolutions</RootNamespace> <RootNamespace>RhSolutions</RootNamespace>
@ -17,8 +17,8 @@
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" /> <PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" /> <PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" /> <PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
<PackageReference Include="netDxf" Version="2022.11.2" /> <PackageReference Include="netDxf" Version="2022.11.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Buffers" Version="4.5.1" /> <PackageReference Include="System.Buffers" Version="4.5.1" />

View File

@ -42,7 +42,7 @@ public class CouplingsCalculator : IFittingsCalculator
"20" => new Product("11080121001"), "20" => new Product("11080121001"),
"25" => new Product("11080131001"), "25" => new Product("11080131001"),
"32" => new Product("11080141001"), "32" => new Product("11080141001"),
"40" => new Product("11600151001"), "40" => new Product("11080151001"),
"50" => new Product("14563021001"), "50" => new Product("14563021001"),
"63" => new Product("14563031001"), "63" => new Product("14563031001"),
_ => throw new Exception($"Неизвестный диаметр {kvp.Key}") _ => throw new Exception($"Неизвестный диаметр {kvp.Key}")

View File

@ -17,13 +17,14 @@ public class SleevesCalculator : IFittingsCalculator
["20"] = 0, ["20"] = 0,
["25"] = 0, ["25"] = 0,
["32"] = 0, ["32"] = 0,
["40"] = 0,
["50"] = 0,
["63"] = 0,
["16PX"] = 0, ["16PX"] = 0,
["20PX"] = 0, ["20PX"] = 0,
["25PX"] = 0, ["25PX"] = 0,
["32PX"] = 0, ["32PX"] = 0,
["40"] = 0, ["40PX"] = 0
["50"] = 0,
["63"] = 0,
}; };
var rautitanProducts = products.Where(kvp => kvp.Key.ProductLines.Contains("RAUTITAN")); var rautitanProducts = products.Where(kvp => kvp.Key.ProductLines.Contains("RAUTITAN"));
@ -35,7 +36,7 @@ public class SleevesCalculator : IFittingsCalculator
CaptureCollection collection = doubleCollection[0].Groups["Sleeve"].Captures; CaptureCollection collection = doubleCollection[0].Groups["Sleeve"].Captures;
foreach (Capture sleeve in collection) foreach (Capture sleeve in collection)
{ {
if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40") if (kvp.Key.Name.Contains("PX"))
{ {
result[$"{sleeve.Value}PX"] += kvp.Value * 2; result[$"{sleeve.Value}PX"] += kvp.Value * 2;
} }
@ -52,7 +53,7 @@ public class SleevesCalculator : IFittingsCalculator
CaptureCollection collection = singleCollection[0].Groups["Sleeve"].Captures; CaptureCollection collection = singleCollection[0].Groups["Sleeve"].Captures;
foreach (Capture sleeve in collection) foreach (Capture sleeve in collection)
{ {
if (kvp.Key.Name.Contains("PX") && sleeve.Value != "40") if (kvp.Key.Name.Contains("PX"))
{ {
result[$"{sleeve.Value}PX"] += kvp.Value; result[$"{sleeve.Value}PX"] += kvp.Value;
} }
@ -72,13 +73,14 @@ public class SleevesCalculator : IFittingsCalculator
"20" => new Product("11080021001"), "20" => new Product("11080021001"),
"25" => new Product("11080031001"), "25" => new Product("11080031001"),
"32" => new Product("11080041001"), "32" => new Product("11080041001"),
"40" => new Product("11080051001"),
"50" => new Product("11397713002"),
"63" => new Product("11397813002"),
"16PX" => new Product("11600011001"), "16PX" => new Product("11600011001"),
"20PX" => new Product("11600021001"), "20PX" => new Product("11600021001"),
"25PX" => new Product("11600031001"), "25PX" => new Product("11600031001"),
"32PX" => new Product("11600041001"), "32PX" => new Product("11600041001"),
"40" => new Product("11600051001"), "40PX" => new Product("11600051001"),
"50" => new Product("11397711002"),
"63" => new Product("11397811002"),
_ => throw new Exception($"Неизвестный диаметр {kvp.Key}") _ => throw new Exception($"Неизвестный диаметр {kvp.Key}")
}, kvp => kvp.Value); }, kvp => kvp.Value);
} }

View File

@ -28,11 +28,10 @@ public class CanFillCouplings : IDisposable
var products = _reader.ReadProducts(new[] { _worksheet }); var products = _reader.ReadProducts(new[] { _worksheet });
var couplings = _calculator.Calculate(products.First().Item2); var couplings = _calculator.Calculate(products.First().Item2);
_writer.WriteProducts(couplings); _writer.WriteProducts(couplings);
for (int i = 2; i < 14; i++)
Assert.Equal(7, _worksheet.Range["E2"].Value); {
Assert.Equal(1, _worksheet.Range["E3"].Value); Assert.Equal(_worksheet.Range[$"F{i}"].Value, _worksheet.Range[$"E{i}"].Value);
Assert.Equal(1, _worksheet.Range["E5"].Value); }
Assert.Equal(1, _worksheet.Range["E7"].Value);
} }
public void Dispose() public void Dispose()

View File

@ -28,18 +28,10 @@ public class CanFillSleeves : IDisposable
var products = _reader.ReadProducts(new[] { _worksheet }); var products = _reader.ReadProducts(new[] { _worksheet });
var sleeves = _calculator.Calculate(products.First().Item2); var sleeves = _calculator.Calculate(products.First().Item2);
_writer.WriteProducts(sleeves); _writer.WriteProducts(sleeves);
for (int i = 2; i < 14; i++)
Assert.Equal(22, _worksheet.Range["E2"].Value); {
Assert.Equal(12, _worksheet.Range["E3"].Value); Assert.Equal(_worksheet.Range[$"F{i}"].Value, _worksheet.Range[$"E{i}"].Value);
Assert.Equal(5, _worksheet.Range["E4"].Value); }
Assert.Equal(6, _worksheet.Range["E5"].Value);
Assert.Equal(3, _worksheet.Range["E6"].Value);
Assert.Equal(3, _worksheet.Range["E7"].Value);
Assert.Equal(2, _worksheet.Range["E8"].Value);
Assert.Equal(2, _worksheet.Range["E9"].Value);
Assert.Equal(1, _worksheet.Range["E10"].Value);
Assert.Equal(3, _worksheet.Range["E11"].Value);
Assert.Equal(4, _worksheet.Range["E12"].Value);
} }
public void Dispose() public void Dispose()