diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Common/OpenDrawMessage.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Common/OpenDrawMessage.cs new file mode 100644 index 0000000..c254a80 --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Common/OpenDrawMessage.cs @@ -0,0 +1,16 @@ +using CommunityToolkit.Mvvm.Messaging.Messages; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Common +{ + internal class OpenDrawMessage : ValueChangedMessage + { + public OpenDrawMessage(string value) : base(value) + { + } + } +} diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs new file mode 100644 index 0000000..e606fbf --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas +{ + public static class Brands + { + public const string UNKNOWN = "未知"; + public const string ANCHUAN = "安川"; + public const string SANLING = "三菱"; + public const string SANLING_HK_KT = "HK-KT"; + } +} diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/LectotypeLineModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/LectotypeLineModel.cs index 5d299c2..2e00b73 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/LectotypeLineModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/LectotypeLineModel.cs @@ -1,4 +1,5 @@ -using Sinvo.EplanHpD.Plugin.WPFUI.Utils; +using Sinvo.EplanHpD.Plugin.WPFUI.Datas; +using Sinvo.EplanHpD.Plugin.WPFUI.Utils; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -296,6 +297,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models return ""; } string ModelNo = "MR-"; + if(Motor.Brand == Brands.ANCHUAN) + { + ModelNo = "JZSP-"; + } var cableFlag = GetCableModelFlag(Motor?.MotorPower, CableType, CableConnectionClass, IsFlexibility); if (string.IsNullOrWhiteSpace(cableFlag)) { @@ -335,20 +340,27 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models } if (!string.IsNullOrEmpty(AxisNo)) { + if(Motor.Brand == Brands.SANLING_HK_KT) + { + ModelNo += "("; + } + if(Motor.Brand == Brands.ANCHUAN) + { + ModelNo += "-E("; + } ModelNo += $"{AxisNo}"; if (CableConnectionClass != "直通") //if (!(CableType is "编码器线+动力线" or "编码器线+动力刹车线")) ModelNo += $"-{CurrentLine} / {LineCount}"; - ModelNo += ")"; - - } + ModelNo += ")"; + } //if (isUpdateDrawNo) { DrawingNo = GetCableDrawNo(); } stopwatch.Stop(); - Debug.Print($"CableModelNo : {stopwatch.ElapsedMilliseconds}ms"); + Debug.Print($"CableModelNo {ModelNo} : {stopwatch.ElapsedMilliseconds}ms"); return ModelNo; } set @@ -363,8 +375,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models /// public string GetCableDrawNo() { - var data = MotorExcelHelper.Instance.GetCableDatas(); + var data = MotorExcelHelper.Instance.GetCableDatas(Motor.Brand); //var data = Core.CoreService.GetService().GetCableDatas(); + Trace.WriteLine($"{Motor.MotorPower} - {CableType} - {CableConnectionClass.Replace("全段", "前段")} - {(IsFlexibility ? "是" : "否")}"); var cableData = data.FirstOrDefault(it => it.MotorPower == Motor.MotorPower && it.LineType == CableType @@ -382,7 +395,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models } private string GetCableModelFlag(string motorPower, string cableType, string cableConnectionType, bool isFlexibility) { - var data = MotorExcelHelper.Instance.GetCableDatas(); + var data = MotorExcelHelper.Instance.GetCableDatas(Motor.Brand); //var data = Core.CoreService.GetService().GetCableDatas(); var cableData = data?.FirstOrDefault(it => it.MotorPower == motorPower diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj index d4f4514..f3743c7 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj @@ -152,9 +152,11 @@ + + diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs index cbb93c0..f95d054 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs @@ -1,4 +1,5 @@ using MiniExcelLibs; +using Sinvo.EplanHpD.Plugin.WPFUI.Datas; using Sinvo.EplanHpD.Plugin.WPFUI.Models; using System; using System.Collections.Generic; @@ -25,7 +26,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils dataFileStream = new MemoryStream(bytes); } } - public List GetCableDatas(string brand = "HK-KT") + public List GetCableDatas(string brand = Brands.SANLING_HK_KT) { if (dataFileStream == null || !dataFileStream.CanRead) { @@ -82,6 +83,37 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils )).ToList(); } + /// + /// 1.动力线, + /// 2.编码器线, + /// 3.动力刹车线, + /// 4.编码器线+动力线, + /// 5.编码器线+动力刹车线, + /// + /// + public List GetCableTypes() + { + //return new List + //{ + // new(){ ItemName = "动力线", ItemValue = "动力线,"}, + // new(){ ItemName = "编码器线", ItemValue = "编码器线"}, + // new(){ ItemName = "动力刹车线", ItemValue = "动力刹车线"}, + // new(){ ItemName = "编码器线+动力线", ItemValue = "编码器线+动力线"}, + // new(){ ItemName = "编码器线+动力刹车线", ItemValue = "编码器线+动力刹车线"}, + //}; + var data = MiniExcel.Query(dataFileStream, sheetName: "线材类型", useHeaderRow: true).Select(it => new ConfigItemModel + { + ItemName = it.线材类型, + ItemValue = it.线材类型, + ItemFlag = it.是否组合 + }).OrderBy(it => it.ItemName).ToList(); + + return data.Distinct(new LambdaComparer( + (a, b) => a.ItemName == b.ItemName && a.ItemValue == b.ItemValue, + obj => obj.ToString().GetHashCode() + )).OrderBy(it => it.ItemValue).ToList(); + } + public List GetBomList(string drawNo) { //var filePath = "D:\\Desktop\\Data\\BOM表.xlsx"; @@ -114,7 +146,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils line.DrawingNo, EncoderLineLength = line.EncoderLineLength == 0 ? "" : line.EncoderLineLength.ToString(), PowerLineLength = line.PowerLineLength == 0 ? "" : line.PowerLineLength.ToString(), - + OrderDate = DateTime.Now.ToString("yyyy/MM/dd"), + DeliveryDate = DateTime.Now.AddDays(7).ToString("yyyy/MM/dd"), // 交期默认一周 }).ToList(); MiniExcel.SaveAsByTemplate( $"{targetPath}\\线材下单_{DateTime.Now:yyyy_MM_dd}.xlsx", diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml index 82a9c33..4ab8f7b 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotypeUserControl.xaml @@ -102,7 +102,7 @@ Width="100" VerticalAlignment="Center" Text="线材链接方式:" /> - + @@ -147,7 +147,7 @@ Height="30" /> --> - + - + -