From 9e3e71a4caea45158ffa561261cbc3bb50c7529b Mon Sep 17 00:00:00 2001 From: lihanbo Date: Fri, 14 Feb 2025 15:40:43 +0800 Subject: [PATCH] =?UTF-8?q?105040=20Update=20=E6=9B=B4=E6=96=B0=E5=AE=89?= =?UTF-8?q?=E5=B7=9D=E7=94=B5=E6=9C=BA=E9=80=BB=E8=BE=91=EF=BC=8C750W?= =?UTF-8?q?=E4=BB=A5=E4=B8=8B=E5=8A=9F=E7=8E=87=E4=B8=8D=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=89=8D=E6=AE=B5=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新程序集版本,添加新方法和类 更新了 `AssemblyInfo.cs` 文件中的程序集版本号至 `1.0.0.26`。 在 `MotorLectotypeService.cs` 文件中添加了 `SetLineDone` 方法。 在 `Sinvo.EplanHpD.Plugin.WPFUI.csproj` 文件中添加了 `MotorPowerModel.cs` 文件的编译包含项。 在 `MotorExcelHelper.cs` 文件中添加了 `GetMotorPower` 方法,用于获取电机功率。 在 `CableLectotypeViewModel.cs` 文件中进行了多处修改,包括修正逻辑、初始化 `LectotypeList`、根据电机功率决定前段线、排序并重新设置序号。 在 `Sinvo.EplanHpD.Plugin.csproj` 文件中更新了多个配置的输出路径。 添加了 `MotorPowerModel.cs` 文件,定义了 `MotorPowerModel` 类,用于表示电机功率。 --- .../Properties/AssemblyInfo.cs | 6 +- .../Models/MotorPowerModel.cs | 30 ++++ .../Properties/AssemblyInfo.cs | 6 +- .../Service/MotorLectotypeService.cs | 2 + .../Sinvo.EplanHpD.Plugin.WPFUI.csproj | 1 + .../Utils/MotorExcelHelper.cs | 18 +++ .../ViewModel/CableLectotypeViewModel.cs | 131 ++++++++++-------- .../Properties/AssemblyInfo.cs | 2 +- .../Sinvo.EplanHpD.Plugin.csproj | 6 +- 9 files changed, 138 insertions(+), 64 deletions(-) create mode 100644 Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorPowerModel.cs diff --git a/Sinvo.EplanHpD.Plugin.Service/Properties/AssemblyInfo.cs b/Sinvo.EplanHpD.Plugin.Service/Properties/AssemblyInfo.cs index 5eb3c84..a39478e 100644 --- a/Sinvo.EplanHpD.Plugin.Service/Properties/AssemblyInfo.cs +++ b/Sinvo.EplanHpD.Plugin.Service/Properties/AssemblyInfo.cs @@ -29,6 +29,6 @@ using System.Runtime.InteropServices; // 生成号 // 修订号 // -[assembly: AssemblyVersion("1.0.0.24")] -[assembly: AssemblyFileVersion("1.0.0.24")] -[assembly: AssemblyInformationalVersion("1.0.0.24")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.0.25")] +[assembly: AssemblyFileVersion("1.0.0.25")] +[assembly: AssemblyInformationalVersion("1.0.0.25")] \ No newline at end of file diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorPowerModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorPowerModel.cs new file mode 100644 index 0000000..1dc6a89 --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MotorPowerModel.cs @@ -0,0 +1,30 @@ +using MiniExcelLibs.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Models +{ + /// + /// 电机功率 + /// + public class MotorPowerModel + { + /* + 电机型号 功率 + */ + /// + /// 电机型号 + /// + [ExcelColumn(Name = "电机型号")] + public string MotorModel { get; set; } + + /// + /// 电机型号 + /// + [ExcelColumn(Name = "功率")] + public int MotorPower { get; set; } + } +} diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs index 75ff15e..24cdc6f 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs @@ -46,6 +46,6 @@ using System.Windows; // 生成号 // 修订号 // -[assembly: AssemblyVersion("1.0.0.24")] -[assembly: AssemblyFileVersion("1.0.0.24")] -[assembly: AssemblyInformationalVersion("1.0.0.24")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.0.25")] +[assembly: AssemblyFileVersion("1.0.0.26")] +[assembly: AssemblyInformationalVersion("1.0.0.26")] \ No newline at end of file diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs index 00d9665..f68a623 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs @@ -297,6 +297,8 @@ namespace Sinvo.EplanHpD.Plugin.Service } } + + public int SetLineDone(string motorUniqueFlag,string lineId) { var db = DBHelper.DB; diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj index 04ce29c..868b283 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj @@ -262,6 +262,7 @@ + diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs index 1af2351..000fa2f 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs @@ -132,6 +132,24 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils } return MiniExcel.Query(dataFileStream, sheetName: "直通线数量").Where(it => it.MotorModel == motorModel).ToList(); } + + /// + /// 获取电机功率 + /// + /// 电机型号 + /// + public int GetMotorPower(string motorModel) + { + if (dataFileStream == null || !dataFileStream.CanRead) + { + // 未初始化或是无法读取时,重试一次 + ReadDataToStream(); + } + return MiniExcel.Query(dataFileStream, sheetName: "电机功率") + .Where(it => it.MotorModel == motorModel) + .FirstOrDefault() + ?.MotorPower ?? 0; + } public List GetBomList(string drawNo) { //var filePath = "D:\\Desktop\\Data\\BOM表.xlsx"; diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs index c7a5a71..b923ace 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/CableLectotypeViewModel.cs @@ -59,16 +59,17 @@ public class CableLectotypeViewModel : INotifyPropertyChanged ShowWarning("请选择线材类型!"); return; } - if (CableTypePrimary.Equals(CableTypeSecond) || CableTypePrimary.Equals(CableTypeThree) || CableTypeThree.Equals(CableTypeSecond)) + if (CableTypePrimary.Equals(CableTypeSecond) || CableTypePrimary.Equals(CableTypeThree) || CableTypeSecond.Equals(CableTypeThree)) { ShowWarning("不能选择同样的线段类型!"); return; } int seqNo = 1; + var LectotypeList = new List(); var line = new LectotypeLineModel { - SeqNo = seqNo, + //SeqNo = seqNo, //MechanicalNo = MechanicalNo, //MechanicalName = MechanicalName, AxisNo = AxisNo, @@ -93,7 +94,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged }; line.DrawingNo = line.GetCableDrawNo(); line.SubLines = GetSubLines(line.DrawingNo); - + var startIndex = 0; if (CableConnectionType == ConnectionType.FullParagraph) { LectotypeList.Clear(); @@ -102,57 +103,73 @@ public class CableLectotypeViewModel : INotifyPropertyChanged // WPFUISession.Instance.snackbarService.Show("相同轴号已经添加过数据,禁止重复添加!", "请检查是否添加错误", appearance: ControlAppearance.Danger, timeout: TimeSpan.FromSeconds(3)); // return; //} - // 第一条线为所选线 - LectotypeList.Add(line); - // 安川第一条线不合并,所以需要再次添加另一个类型的线 if (Motor.Brand == Brands.ANCHUAN) { - //var index = CableTypeIndexs[CableTypePrimary]; - //var secLineCableType = ""; - //var flag = index.Keys.First() + index.Values.First(); - //if (CableTypePrimary.Contains("刹车") && flag != 1) - //{ - // // 动力线 or 动力刹车线 - // flag = 0; - //} - ////else - //secLineCableType = CableTypeIndexs.Keys.ToList()[flag]; - - var secLine = new LectotypeLineModel + var motorPower = MotorExcelHelper.Instance.GetMotorPower(Motor.MotorModelStr); + // 功率750W以下的电机,不需要前段线 + if (motorPower <= 750) { - SeqNo = seqNo, - //MechanicalNo = MechanicalNo, - //MechanicalName = MechanicalName, - AxisNo = AxisNo, - //MotorSerie = MotorSerie, - //MotorPower = Motor.MotorPower, - //DriverInterface = DriverInterface, - //DriverModel = DriverModel, - CableConnectionClass = CableConnectionType == ConnectionType.FullParagraph ? "前段" : "直通", - CableType = CableTypeSecond, - //IsFlexibility = IsFlexibility, - //PowerLineLength = PowerLineLength, - //EncoderLineLength = EncoderLineLength, - //PowerBrakeLineLength = PowerBrakeLineLength, - //DrawingNo = LineModelStr, - CableModelNo = CableModelStr, - //LineCount = Math.Max(PowerLineCount, EncoderLineCount), - //CurrentLineNumber = 1, - //BomList = GenBomListByCurrent(DrawingNo) - IsLectotype = true, - CurrentLine = 1, - Motor = Motor - }; - secLine.DrawingNo = secLine.GetCableDrawNo(); - secLine.SubLines = GetSubLines(secLine.DrawingNo); - LectotypeList.Add(secLine); + seqNo = 1; + startIndex = 1; + } + else + { + startIndex = 2; + // 第一条线为所选线 + LectotypeList.Add(line); + //var index = CableTypeIndexs[CableTypePrimary]; + //var secLineCableType = ""; + //var flag = index.Keys.First() + index.Values.First(); + //if (CableTypePrimary.Contains("刹车") && flag != 1) + //{ + // // 动力线 or 动力刹车线 + // flag = 0; + //} + ////else + //secLineCableType = CableTypeIndexs.Keys.ToList()[flag]; + + + var secLine = new LectotypeLineModel + { + //SeqNo = seqNo, + //MechanicalNo = MechanicalNo, + //MechanicalName = MechanicalName, + AxisNo = AxisNo, + //MotorSerie = MotorSerie, + //MotorPower = Motor.MotorPower, + //DriverInterface = DriverInterface, + //DriverModel = DriverModel, + CableConnectionClass = CableConnectionType == ConnectionType.FullParagraph ? "前段" : "直通", + CableType = CableTypeSecond, + //IsFlexibility = IsFlexibility, + //PowerLineLength = PowerLineLength, + //EncoderLineLength = EncoderLineLength, + //PowerBrakeLineLength = PowerBrakeLineLength, + //DrawingNo = LineModelStr, + CableModelNo = CableModelStr, + //LineCount = Math.Max(PowerLineCount, EncoderLineCount), + //CurrentLineNumber = 1, + //BomList = GenBomListByCurrent(DrawingNo) + IsLectotype = true, + CurrentLine = 1, + Motor = Motor + }; + secLine.DrawingNo = secLine.GetCableDrawNo(); + secLine.SubLines = GetSubLines(secLine.DrawingNo); + LectotypeList.Add(secLine); + } + } - - for (global::System.Int32 i = 2; i <= PowerLineParagraph; i++) + else { - seqNo++; + LectotypeList.Add(line); + } + + for (global::System.Int32 i = startIndex; i <= PowerLineParagraph; i++) + { + //seqNo++; var cableConnectionType = "中段"; if (i >= PowerLineParagraph) { @@ -160,7 +177,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged } var powerLine = new LectotypeLineModel { - SeqNo = seqNo, + //SeqNo = seqNo, //MechanicalNo = MechanicalNo, //MechanicalName = MechanicalName, AxisNo = AxisNo, @@ -185,9 +202,9 @@ public class CableLectotypeViewModel : INotifyPropertyChanged powerLine.SubLines = GetSubLines(powerLine.DrawingNo); LectotypeList.Add(powerLine); } - for (global::System.Int32 i = 2; i <= EncoderLineParagraph; i++) + for (global::System.Int32 i = startIndex; i <= EncoderLineParagraph; i++) { - seqNo++; + //seqNo++; var cableConnectionType = "中段"; if (i >= EncoderLineParagraph) { @@ -195,7 +212,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged } var encoderLine = new LectotypeLineModel { - SeqNo = seqNo, + //SeqNo = seqNo, //MechanicalNo = MechanicalNo, //MechanicalName = MechanicalName, AxisNo = AxisNo, @@ -231,7 +248,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged { var secLine = new LectotypeLineModel { - SeqNo = seqNo, + //SeqNo = seqNo, //MechanicalNo = MechanicalNo, //MechanicalName = MechanicalName, AxisNo = AxisNo, @@ -262,7 +279,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged { var secLine = new LectotypeLineModel { - SeqNo = seqNo, + //SeqNo = seqNo, //MechanicalNo = MechanicalNo, //MechanicalName = MechanicalName, AxisNo = AxisNo, @@ -292,7 +309,13 @@ public class CableLectotypeViewModel : INotifyPropertyChanged } } - SelectedLines = LectotypeList; + var sortedLines = LectotypeList.OrderBy(it => it.CableType).ThenBy(it => it.CurrentLine).ToList(); + sortedLines.ForEach(it => + { + it.SeqNo = seqNo; + seqNo++; + }); + SelectedLines = sortedLines; } private List GetSubLines(string drawingNo) diff --git a/Sinvo.EplanHpD.Plugin/Properties/AssemblyInfo.cs b/Sinvo.EplanHpD.Plugin/Properties/AssemblyInfo.cs index 6b1f0bd..650660d 100644 --- a/Sinvo.EplanHpD.Plugin/Properties/AssemblyInfo.cs +++ b/Sinvo.EplanHpD.Plugin/Properties/AssemblyInfo.cs @@ -28,6 +28,6 @@ using System.Runtime.InteropServices; // 生成号 // 修订号 // -[assembly: AssemblyVersion("1.0.0.24")] +[assembly: AssemblyVersion("1.0.0.26")] [assembly: AssemblyFileVersion("1.0.0.24")] [assembly: AssemblyInformationalVersion("1.0.0.24-rls")] \ No newline at end of file diff --git a/Sinvo.EplanHpD.Plugin/Sinvo.EplanHpD.Plugin.csproj b/Sinvo.EplanHpD.Plugin/Sinvo.EplanHpD.Plugin.csproj index 80d189f..a979cf1 100644 --- a/Sinvo.EplanHpD.Plugin/Sinvo.EplanHpD.Plugin.csproj +++ b/Sinvo.EplanHpD.Plugin/Sinvo.EplanHpD.Plugin.csproj @@ -33,7 +33,7 @@ true - bin\x64\Debug\ + ..\..\..\PLMCADI\Release_WireAndCable\ DEBUG;TRACE full x64 @@ -104,7 +104,7 @@ prompt - bin\x64\Release_WireAndCable\ + ..\..\..\PLMCADI\Release_WireAndCable\ TRACE;Release_WireAndCable true pdbonly @@ -131,7 +131,7 @@ prompt - bin\x64\Release_CableLayout\ + ..\..\..\PLMCADI\EPLANProDAddin\ TRACE;Release_CableLayout true pdbonly