summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RhSolutions.Api.Tests/RautitanFittingsTests.cs12
-rw-r--r--RhSolutions.Api/Services/ProductQueryModifierFactory.cs6
-rw-r--r--RhSolutions.Api/Services/ThreadTPieceExternal.cs20
-rw-r--r--RhSolutions.Api/Services/ThreadTPieceInternal.cs20
-rw-r--r--RhSolutions.Api/Services/ThreadTPieceWall.cs50
5 files changed, 108 insertions, 0 deletions
diff --git a/RhSolutions.Api.Tests/RautitanFittingsTests.cs b/RhSolutions.Api.Tests/RautitanFittingsTests.cs
index 840b98b..7833dc8 100644
--- a/RhSolutions.Api.Tests/RautitanFittingsTests.cs
+++ b/RhSolutions.Api.Tests/RautitanFittingsTests.cs
@@ -33,4 +33,16 @@ public class RautitanFittingsTests : ProductQueryModifierTests
[TestCase("Соединение угловое с накидной гайкой 16 х 1/2\", латунь", "Угольник-переходник с накидной гайкой 16 1/2")]
public void ScrewcapElbowTest(string query, string modified)
=> Execute(productType: "Угольник с накидной гайкой", query, modified);
+
+ [TestCase("Тройник настенный с внутренней резьбой 16-Rp1/2-16 RX+", "Тройник настенный с внутренней резьбой 16-Rp1/2-16")]
+ public void ThreadTPieceWallTest(string query, string modified)
+ => Execute(productType: "Тройник RAUTITAN резьбовой настенный", query, modified);
+
+ [TestCase("Тройник с внутр. резьбой на боков. проходе 25-Rp 1/2-25 RX+", "Тройник с внутр. резьбой на боков. проходе 25-Rp 1/2-25")]
+ public void ThreadTPieceInternalTest(string query, string modified)
+ => Execute(productType: "Тройник RAUTITAN резьбовой внутренний", query, modified);
+
+ [TestCase("Тройник RAUTITAN RX+ с наружной резьбой 20-20-R 3/4", "Тройник RAUTITAN с наружной резьбой 20-20-R 3/4")]
+ public void ThreadTPieceExternalTest(string query, string modified)
+ => Execute(productType: "Тройник RAUTITAN резьбовой наружный", query, modified);
} \ No newline at end of file
diff --git a/RhSolutions.Api/Services/ProductQueryModifierFactory.cs b/RhSolutions.Api/Services/ProductQueryModifierFactory.cs
index 7949682..dc03838 100644
--- a/RhSolutions.Api/Services/ProductQueryModifierFactory.cs
+++ b/RhSolutions.Api/Services/ProductQueryModifierFactory.cs
@@ -10,6 +10,12 @@ public class ProductQueryModifierFactory
return new SleeveQueryModifier();
case "Тройник RAUTITAN":
return new TPieceQueryModifier();
+ case "Тройник RAUTITAN резьбовой наружный":
+ return new ThreadTPieceExternal();
+ case "Тройник RAUTITAN резьбовой внутренний":
+ return new ThreadTPieceInternal();
+ case "Тройник RAUTITAN резьбовой настенный":
+ return new ThreadTPieceWall();
case "Переходник на наружную резьбу":
return new AdapterExternalModifier();
case "Переходник на внутреннюю резьбу":
diff --git a/RhSolutions.Api/Services/ThreadTPieceExternal.cs b/RhSolutions.Api/Services/ThreadTPieceExternal.cs
new file mode 100644
index 0000000..5515c6b
--- /dev/null
+++ b/RhSolutions.Api/Services/ThreadTPieceExternal.cs
@@ -0,0 +1,20 @@
+
+using System.Text.RegularExpressions;
+
+namespace RhSolutions.Api.Services;
+
+public class ThreadTPieceExternal : ThreadTPieceWall
+{
+ protected override string ConstructName(MatchCollection diameters, Match thread)
+ {
+ Capture t = thread.Groups["Thread"].Captures.First();
+ if (diameters.Count == 1)
+ {
+ return $"Тройник RAUTITAN с наружной резьбой {diameters[0]}-{diameters[0]}-R {t}";
+ }
+ else
+ {
+ return $"Тройник RAUTITAN с наружной резьбой {diameters[0]}-{diameters[1]}-R {t}";
+ }
+ }
+} \ No newline at end of file
diff --git a/RhSolutions.Api/Services/ThreadTPieceInternal.cs b/RhSolutions.Api/Services/ThreadTPieceInternal.cs
new file mode 100644
index 0000000..41672f1
--- /dev/null
+++ b/RhSolutions.Api/Services/ThreadTPieceInternal.cs
@@ -0,0 +1,20 @@
+
+using System.Text.RegularExpressions;
+
+namespace RhSolutions.Api.Services;
+
+public class ThreadTPieceInternal : ThreadTPieceWall
+{
+ protected override string ConstructName(MatchCollection diameters, Match thread)
+ {
+ Capture t = thread.Groups["Thread"].Captures.First();
+ if (diameters.Count == 1)
+ {
+ return $"Тройник с внутр. резьбой на боков. проходе {diameters[0]}-Rp {t}-{diameters[0]}";
+ }
+ else
+ {
+ return $"Тройник с внутр. резьбой на боков. проходе {diameters[0]}-Rp {t}-{diameters[1]}";
+ }
+ }
+}
diff --git a/RhSolutions.Api/Services/ThreadTPieceWall.cs b/RhSolutions.Api/Services/ThreadTPieceWall.cs
new file mode 100644
index 0000000..76f3b75
--- /dev/null
+++ b/RhSolutions.Api/Services/ThreadTPieceWall.cs
@@ -0,0 +1,50 @@
+
+using System.Text.RegularExpressions;
+using Microsoft.AspNetCore.Http.Extensions;
+
+namespace RhSolutions.Api.Services;
+
+public class ThreadTPieceWall : IProductQueryModifier
+{
+ private string diameterPattern = "16|20|25|32|40|50|63";
+ private string threadPattern = @"(\D|^)(?<Thread>1\s+1/4|1\s+1/2|1/2|3/4|2|1)(\D|$)";
+
+ public bool TryQueryModify(IQueryCollection collection, out QueryString queryString)
+ {
+ queryString = QueryString.Empty;
+ var query = collection["query"].ToString();
+ if (string.IsNullOrEmpty(query))
+ {
+ return false;
+ }
+ var diameters = Regex.Matches(query, diameterPattern);
+ if (diameters.Count == 0)
+ {
+ return false;
+ }
+ var thread = Regex.Match(query, threadPattern);
+ if (!thread.Success)
+ {
+ return false;
+ }
+ QueryBuilder qb = new()
+ {
+ {"query", ConstructName(diameters, thread)}
+ };
+ queryString = qb.ToQueryString();
+ return true;
+ }
+
+ protected virtual string ConstructName(MatchCollection diameters, Match thread)
+ {
+ Capture t = thread.Groups["Thread"].Captures.First();
+ if (diameters.Count == 1)
+ {
+ return $"Тройник настенный с внутренней резьбой {diameters[0]}-Rp{t}-{diameters[0]}";
+ }
+ else
+ {
+ return $"Тройник настенный с внутренней резьбой {diameters[0]}-Rp{t}-{diameters[1]}";
+ }
+ }
+}