From d9845c16f03224b034b8bfdefa0179c902332996 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Fri, 28 Mar 2025 16:52:27 +0800 Subject: [PATCH] =?UTF-8?q?105040=20Update=20=E6=B5=8B=E8=AF=95=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/MotorLectotypeService.cs | 82 +++++++++++++++++-- Sinvo.EplanHpD.Plugin.WPFUI/Utils/Consts.cs | 4 +- .../View/CableLectotypeUserControl.xaml | 10 ++- .../View/CableLectotypeUserControl.xaml.cs | 20 ++++- 4 files changed, 104 insertions(+), 12 deletions(-) diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs index f68a623..40d7779 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs @@ -59,7 +59,11 @@ namespace Sinvo.EplanHpD.Plugin.Service // return ""; // } //} - + /// + /// 查询选型数据 直接转为ViewModel + /// + /// + /// public CableLectotypeViewModel GetMotorLectotypeData(string motorUniqueFlag) { // 查询 Motor 数据 @@ -136,7 +140,11 @@ namespace Sinvo.EplanHpD.Plugin.Service return viewModel; } - // 获取子线数据 + /// + /// 获取子线数据 + /// + /// + /// private List GetSubLines(string parentLineId) { var subLines = DBHelper.DB.Queryable() @@ -160,7 +168,12 @@ namespace Sinvo.EplanHpD.Plugin.Service // .ExecuteCommand(); // return changeCount > 0; //} - + /// + /// 保存电机选型的数据 + /// + /// + /// + /// public bool SaveMotorLectotypeData(string motorUniqueFlag, CableLectotypeViewModel data) { var db = DBHelper.DB; @@ -276,11 +289,16 @@ namespace Sinvo.EplanHpD.Plugin.Service return false; } } - + /// + /// 获取线总段数 + /// + /// + /// + /// public int GetLineCount(string motorUniqueFlag,string cableType) { var line = DBHelper.DB.Queryable("mt") - .Where(mt => mt.MotorUniqueFlag == motorUniqueFlag && (mt.CableTypePrimary == cableType || mt.CableTypeSecond == cableType)) + .Where(mt => mt.MotorUniqueFlag == motorUniqueFlag && (mt.CableTypePrimary == cableType || mt.CableTypeSecond == cableType || mt.CableTypeThree == cableType)) .First(); // 除了编码器线,其他都取动力线 if(line == null) @@ -296,9 +314,12 @@ namespace Sinvo.EplanHpD.Plugin.Service return line.PowerLineParagraph; } } - - - + /// + /// 将一根线设置为已布线 + /// + /// + /// + /// public int SetLineDone(string motorUniqueFlag,string lineId) { var db = DBHelper.DB; @@ -321,5 +342,50 @@ namespace Sinvo.EplanHpD.Plugin.Service return 0; } } + + public CableLectotype GetCableLectotypeData(string motorUniqueFlag) + { + // 查询关联的 CableLectotype 数据 + var cableLectotype = DBHelper.DB.Queryable() + .Where(cl => cl.MotorUniqueFlag == motorUniqueFlag) + .First(); + return cableLectotype; + } + + public List GetLectotypeLines(string cableLectotypeId) + { + // 查询关联的 LectotypeLine 数据 + var lectotypeLines = DBHelper.DB.Queryable() + .Where(ll => ll.CableLectotypeId == cableLectotypeId) + //.OrderBy(ll => ll.SeqNo) + .ToList(); + return lectotypeLines; + } + + public bool ClearMotorData(string motorUniqueFlag) + { + var cleared = false; + + var db = DBHelper.DB; + + try + { + db.BeginTran(); + + db.Deleteable().Where(it => it.MotorUniqueFlag == motorUniqueFlag).ExecuteCommand(); + db.Deleteable().Where(it => it.MotorUniqueFlag == motorUniqueFlag).ExecuteCommand(); + db.Deleteable().Where(it => it.MotorUniqueFlag == motorUniqueFlag).ExecuteCommand(); + db.CommitTran(); + cleared = true; + } + catch (Exception) + { + db.RollbackTran(); + cleared = false; + throw; + } + + return cleared; + } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/Consts.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/Consts.cs index b566237..539a5e3 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/Consts.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/Consts.cs @@ -22,7 +22,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils public static string TEMPLATE_FILE_NAME = @"下单模板.xlsx"; #if DEBUG - public static string PLUGIN_DATA_FILE_PATH = @"D:\Desktop\EPlan\线材选型"; + public static string PLUGIN_DATA_FILE_PATH = @"D:\Desktop\EPLAN\汇川"; #else public static string PLUGIN_DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型\插件";//@"D:\旧电脑文件\Desktop\EPlan\线材选型";// @@ -46,6 +46,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils public static void InitConfigs() { +#if !DEBUG var jsonObj = JsonConvert.DeserializeObject>(File.ReadAllText(Path.Combine(CONFIG_FILE_PATH, "config.json"))); if(jsonObj != null) { @@ -94,6 +95,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils } } +#endif } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml index 0f8db55..b11db3d 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml @@ -253,7 +253,7 @@ + Orientation="Vertical">