From 3d0606a619997f55498f40805c2576ef2bd479c0 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Thu, 13 Feb 2025 08:55:12 +0800 Subject: [PATCH] =?UTF-8?q?105040=20=E5=A2=9E=E5=8A=A0=E7=BA=BF=E6=9D=90?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=EF=BC=8C=E6=AE=B5=E6=95=B0=E6=8C=89=E7=85=A7?= =?UTF-8?q?=E5=B7=B2=E9=80=89=E6=8B=A9=E7=9A=84=E7=94=B5=E6=9C=BA=E9=80=89?= =?UTF-8?q?=E5=9E=8B=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加电机线段数获取及第三种线材类型支持 在 `MotorLectotypeService.cs` 文件中,添加了 `GetLineCount` 方法,用于获取电机对应的线段数。 在 `MotorExcelHelper.cs` 文件中,添加了 `#if DEBUG` 和 `#else` 预处理指令,以便在调试模式和发布模式下使用不同的文件路径。 在 `CableLectotypeUserControl.xaml` 文件中,添加了 `BooleanToVisibilityConverter` 资源,并在界面中添加了一个新的 `SimpleStackPanel`,用于显示第三种线材类型的选择。 在 `CableLectotypeViewModel.cs` 文件中,添加了 `CableTypeThree` 属性和 `IsShowThreeCableType` 属性,用于绑定第三种线材类型的选择和显示控制。 在 `LectotypeViewModel.cs` 文件中,添加了对 `MotorLectotypeService` 的引用,并在构造函数中实例化了 `MotorLectotypeService`。在处理电机和线材匹配时,增加了对电机信息的检查和线段数的获取逻辑。 --- .../Service/MotorLectotypeService.cs | 20 +++++++ .../Utils/MotorExcelHelper.cs | 5 ++ .../View/CableLectotypeUserControl.xaml | 25 ++++++++- .../ViewModel/CableLectotypeViewModel.cs | 25 ++++++++- .../ViewModel/LectotypeViewModel.cs | 54 ++++++++++++------- 5 files changed, 108 insertions(+), 21 deletions(-) diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs index 98d6bec..aa53f2e 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs @@ -275,6 +275,26 @@ namespace Sinvo.EplanHpD.Plugin.Service } } + public int GetLineCount(string motorUniqueFlag,string cableType) + { + var line = DBHelper.DB.Queryable("mt") + .Where(mt => mt.MotorUniqueFlag == motorUniqueFlag && (mt.CableTypePrimary == cableType || mt.CableTypeSecond == cableType)) + .First(); + // 除了编码器线,其他都取动力线 + if(line == null) + { + return -1; + } + if (cableType == "编码器线") + { + return line.EncoderLineParagraph; + } + else + { + return line.PowerLineParagraph; + } + } + public int SetLineDone(string motorUniqueFlag,string lineId) { var db = DBHelper.DB; diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs index f95d054..ac893ba 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs @@ -13,7 +13,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils public static MotorExcelHelper Instance = new(); private Stream dataFileStream; +#if DEBUG + public const string DATA_FILE_PATH = @"D:\旧电脑文件\Desktop\EPlan\线材选型"; +#else + public const string DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型\插件";//@"D:\旧电脑文件\Desktop\EPlan\线材选型";// +#endif private const string DATA_FILE_NAME = "线材选型数据表.xlsx"; private const string DATA_FILE_NAME_BOM = "BOM表.xlsx"; private const string TEMPLATE_FILE_NAME = "下单定制线模板.xlsx"; diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml index 0637e19..0ca9e56 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml @@ -21,6 +21,7 @@ + @@ -192,6 +193,29 @@ IsReadOnly="False" Text="{Binding PowerLineParagraph, Mode=TwoWay}" /> + + + + + + + -