From c2dca12e9942fef04d3bd1acc4f65c0b57b81949 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Fri, 8 Nov 2024 17:13:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E7=94=9F=E6=88=90=E7=BA=BF?= =?UTF-8?q?=E7=BC=86=E5=9E=8B=E5=8F=B7=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 对生成线缆型号的逻辑进行了重构和优化: - 在 `MainViewModel.Check.cs` 文件中: - 注释掉了原有的直接拼接字符串生成线缆型号的代码。 - 新增了调用 `GenWireModel` 方法来生成线缆型号的代码,并在调用时对线缆长度进行了处理。 - 在 `MainViewModel.cs` 文件中: - 注释掉了原有的直接拼接字符串生成线缆型号的代码。 - 新增了调用 `GenWireModel` 方法来生成线缆型号的代码。 - 新增了 `GenWireModel` 方法,该方法接收线缆颜色、截面积、线缆长度和线缆编号作为参数,并返回生成的线缆型号字符串。 --- .../ViewModel/MainViewModel.Check.cs | 6 ++++-- Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs index b86c04c..f2f9cdb 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs @@ -250,10 +250,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel } else { - var newModel = $"RV-{item.WireColor}-1x{item.CrossSection}-{item.WireLength + 5}-16×N2-{item.WireNumber}"; + //var newModel = $"RV-{item.WireColor}-1x{item.CrossSection}-{item.WireLength + 5}-16×N2-{item.WireNumber}"; + var newModel = GenWireModel(item.WireColor, item.CrossSection, $"{double.Parse(item.WireLength) + 5}_add_5", item.WireNumber); if (StuffedData.Any(it => it.Model == newModel)) { - var newModel2 = $"RV-{item.WireColor}-1x{item.CrossSection}-{item.WireLength + 10}-16×N2-{item.WireNumber}"; + //var newModel2 = $"RV-{item.WireColor}-1x{item.CrossSection}-{item.WireLength + 10}-16×N2-{item.WireNumber}"; + var newModel2 = GenWireModel(item.WireColor, item.CrossSection, $"{double.Parse(item.WireLength) + 10}_add_10", item.WireNumber); if (StuffedData.Any(it => it.Model == newModel2)) SetItemError(item, $"{item.Model} 该型号存在重复!\r\n"); else diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs index 71e5b16..6ea87ab 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs @@ -288,7 +288,9 @@ public partial class MainViewModel : INotifyPropertyChanged //data.WireNumber = item.Imprint; data.Quantity = 1; //"RV-"&A2&"-"&"1×"&J2&"-"&L2&"-"&"16×N2"&"-"&M2 - data.Model = $"RV-{data.WireColor}-1×{data.CrossSection}-{data.WireLength}-16×N2-{data.WireNumber}"; + //data.Model = $@"RV-{data.WireColor}-1×【Replace】{data.CrossSection}-{data.WireLength}-16×N2-{data.WireNumber}"; + //data.Model = string.Format("RV-{0}-1{4}{1}-{2}-16×N2-{3}", data.WireColor, data.CrossSection, data.WireLength, data.WireNumber, "×"); + data.Model = GenWireModel(data.WireColor, data.CrossSection, data.WireLength, data.WireNumber); //data.IsChecked = true; if (!string.IsNullOrEmpty(data.DiscolorationDesc)) { @@ -543,4 +545,9 @@ public partial class MainViewModel : INotifyPropertyChanged } } + private string GenWireModel(string wireColor, string crossSection, string wireLength, string wireNumber) + { + return $@"RV-{wireColor}-1×{crossSection}-{wireLength}-16×N2-{wireNumber}"; + } + } \ No newline at end of file