diff --git a/Sinvo.EplanHpD.Plugin.Service/DBHelper.cs b/Sinvo.EplanHpD.Plugin.Service/DBHelper.cs index 0ad9552..57d0d3b 100644 --- a/Sinvo.EplanHpD.Plugin.Service/DBHelper.cs +++ b/Sinvo.EplanHpD.Plugin.Service/DBHelper.cs @@ -44,6 +44,7 @@ namespace Sinvo.EplanHpD.Plugin.Service DB.CodeFirst.InitTables(typeof(Model.Motor)); DB.CodeFirst.InitTables(typeof(Model.CableLectotype)); DB.CodeFirst.InitTables(typeof(Model.LectotypeLine)); + DB.CodeFirst.InitTables(typeof(Model.MultiCoreWireLecDBModel)); } } } diff --git a/Sinvo.EplanHpD.Plugin.Service/Model/MultiCoreWireLecDBModel.cs b/Sinvo.EplanHpD.Plugin.Service/Model/MultiCoreWireLecDBModel.cs new file mode 100644 index 0000000..a9f4017 --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.Service/Model/MultiCoreWireLecDBModel.cs @@ -0,0 +1,62 @@ +using SqlSugar; +using System.ComponentModel; + +namespace Sinvo.EplanHpD.Plugin.Service.Model +{ + [SugarTable("T_MCWIRE_LEC")] + public class MultiCoreWireLecDBModel + { + /* + * 应用场景 类型 线径规格(mm2) 是否高柔 线芯数 线材型号规格 插头型号 前端子型号 后端子型号 + */ + public string Id { get; set; } + public string UniqueKey { get; set; } + public string ProjectName { get; set; } + public string UserId { get; set; } + + public int SeqNo { get; set; } + + + /// + /// 应用场景 + /// + public string ApplicationScenario { get; set; } + + + /// + /// 线径规格(mm2) + /// + public string WireDiameterSpecification { get; set; } + + + + /// + /// 是否高柔 + /// + public string IsHighFlexibilityStr { get; set; } + + /// + /// 线芯数 + /// + public string WireCoreCount { get; set; } + + /// + /// 线材型号规格 + /// + public string WireModelSpecification { get; set; } + /// + /// 前连接 + /// + public string FrontConnectorModel { get; set; } + + /// + /// 后连接 + /// + public string BackConnectorModel { get; set; } + + /// + /// 是否已布线 + /// + public bool Layouted { get; set; } = false; + } +} diff --git a/Sinvo.EplanHpD.Plugin.Service/Properties/AssemblyInfo.cs b/Sinvo.EplanHpD.Plugin.Service/Properties/AssemblyInfo.cs index c495626..006ac82 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.1.2")] -[assembly: AssemblyFileVersion("1.0.1.2")] -[assembly: AssemblyInformationalVersion("1.0.1.2")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.1.3")] +[assembly: AssemblyFileVersion("1.0.1.3")] +[assembly: AssemblyInformationalVersion("1.0.1.3")] \ No newline at end of file diff --git a/Sinvo.EplanHpD.Plugin.Service/Sinvo.EplanHpD.Plugin.Service.csproj b/Sinvo.EplanHpD.Plugin.Service/Sinvo.EplanHpD.Plugin.Service.csproj index 0b43136..de6c2c4 100644 --- a/Sinvo.EplanHpD.Plugin.Service/Sinvo.EplanHpD.Plugin.Service.csproj +++ b/Sinvo.EplanHpD.Plugin.Service/Sinvo.EplanHpD.Plugin.Service.csproj @@ -73,6 +73,7 @@ + diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Converter/WireColorConverter.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Converter/WireColorConverter.cs new file mode 100644 index 0000000..3d8f45f --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Converter/WireColorConverter.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using System.Windows.Media; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Converter +{ + public class WireColorConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values.Length < 2 || values[0] == null || values[1] == null) + return Brushes.Transparent; + + string primaryColor = values[0].ToString(); + string secondaryColor = values[1].ToString(); + bool isMultiColor = false; + + if (values.Length > 2 && values[2] is bool v) + isMultiColor = v; + + if (!isMultiColor || string.IsNullOrEmpty(secondaryColor)) + return new SolidColorBrush((Color)ColorConverter.ConvertFromString(primaryColor)); + + // 创建线性渐变刷 + LinearGradientBrush gradientBrush = new LinearGradientBrush(); + gradientBrush.StartPoint = new System.Windows.Point(0, 0); + gradientBrush.EndPoint = new System.Windows.Point(1, 0); + + gradientBrush.GradientStops.Add( + new GradientStop((Color)ColorConverter.ConvertFromString(primaryColor), 0.0)); + gradientBrush.GradientStops.Add( + new GradientStop((Color)ColorConverter.ConvertFromString(secondaryColor), 1.0)); + + return gradientBrush; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs index b576dac..c25a734 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Datas/Brands.cs @@ -41,7 +41,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas 5. 数据表中Sheet名称: 安川 */ {ANCHUAN, - new BrandData{ + new BrandData { Name = ANCHUAN, ComplexLine = false, SheetName = ANCHUAN, @@ -61,7 +61,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas 5. 数据表中Sheet名称: 汇川 */ {HUICHUAN, - new BrandData{ + new BrandData { Name = HUICHUAN, ComplexLine = false, SheetName = HUICHUAN, @@ -81,7 +81,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas 5. 数据表中Sheet名称: HK_KT */ {SANLING_HK_KT, - new BrandData{ + new BrandData { Name = SANLING_HK_KT, ComplexLine = true, SheetName = SANLING_HK_KT, diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/CableLectotype/LectotypeLineModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/CableLectotype/LectotypeLineModel.cs index 5ff0b2a..b5e0d67 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/CableLectotype/LectotypeLineModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/CableLectotype/LectotypeLineModel.cs @@ -1,13 +1,15 @@ using EPLAN.Harness.AppCore.AttributeEvents; using Sinvo.EplanHpD.Plugin.WPFUI.Datas; using Sinvo.EplanHpD.Plugin.WPFUI.Utils; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; namespace Sinvo.EplanHpD.Plugin.WPFUI.Models { - public class LectotypeLineModel : CheckedModel + public class + LectotypeLineModel : CheckedModel { public string CableLectotypeId { get; set; } @@ -288,7 +290,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models } } - private string _cableModelNo; + //private string _cableModelNo; public string CableModelNo { get @@ -416,5 +418,92 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models CableType = it.Name }).ToList(); } + public bool SubLineNeedInsulation + { + get + { + return SubLines != null && SubLines.Any(it => it.NeedInsulation); + } + } + //private bool _needInsulation; + public bool NeedInsulation + { + get + { + return (CableType == "动力线" || CableType == "动力刹车线") && (CableModel?.Contains("黄绿色") ?? false); + } + } + + private string _insulationMCode; + /// + /// 绝缘软套物料编码 + /// + public string InsulationMCode + { + get + { + return _insulationMCode; + } + set + { + _insulationMCode = value; + OnPropertyChanged(nameof(InsulationMCode)); + } + } + /// + /// 绝缘软套物料编码 + /// + public int? InsulationCount + { + get + { + return NeedInsulation ? 1 : null; + } + set + { + OnPropertyChanged(nameof(InsulationCount)); + } + } + public string InsulationModel + { + get + { + return GetInsulation(); + } + set { + + } + } + + + private string GetInsulation() + { + if (string.IsNullOrEmpty(CableModel) || !NeedInsulation) + return ""; + // 线径 + var matchGroups = Consts.InsulationRegex.Match(CableModel).Groups; + var wireDiameter = matchGroups[1]?.Value; + var ceFlag = matchGroups[2]?.Value ?? ""; + if (string.IsNullOrEmpty(ceFlag) && CableModel.Contains("-CE")) + { + ceFlag = "-CE"; + } + if (double.Parse(wireDiameter) <= 1.5) + { + wireDiameter = "1.5"; + } + var insulationModel = $"V-{wireDiameter}{ceFlag}(绿色)/定制"; + var insData = ExcelHelper.GetInsulationSoftSleeveTable(insulationModel).FirstOrDefault(); + if (insData != null) + { + InsulationMCode = insData.MaterialCode; + OnPropertyChanged(nameof(NeedInsulation)); + return insData.Specification; + } + else + { + return " - "; + } + } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs index 5e8c035..283db85 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireDataModel.cs @@ -34,10 +34,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models /// 是否高柔 /// public bool IsHighFlexibility { get; set; } - /// - /// 插头型号 - /// - public string ConnectorModel { get; set; } + /// /// 前端子型号 /// diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireLecModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireLecModel.cs index e447d7d..ec59cd1 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireLecModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireLecModel.cs @@ -1,4 +1,5 @@ using MiniExcelLibs.Attributes; +using Sinvo.EplanHpD.Plugin.WPFUI.Models.MultiCoreWire; using System; using System.Collections.Generic; using System.ComponentModel; @@ -7,66 +8,466 @@ using System.Text; using System.Threading.Tasks; namespace Sinvo.EplanHpD.Plugin.WPFUI.Models -{ - public class MultiCoreWireLecModel +{ + public class MultiCoreWireLecModel : INotifyPropertyChanged { /* * 应用场景 类型 线径规格(mm2) 是否高柔 线芯数 线材型号规格 插头型号 前端子型号 后端子型号 */ + public string Id { get; set; } + public string UniqueKey { get; set; } + public string ProjectName { get; set; } + public string UserId { get; set; } + + + private int _seqNo; + [ExcelColumn(Ignore = true)] + public int SeqNo + { + get => _seqNo; + set + { + _seqNo = value; + OnPropertyChanged(nameof(SeqNo)); + } + } /// /// 应用场景 /// + private string _applicationScenario; [ExcelColumn(Name = "应用场合")] - public string ApplicationScenario { get; set; } + public string ApplicationScenario + { + get => _applicationScenario; + set + { + _applicationScenario = value; + OnPropertyChanged(nameof(ApplicationScenario)); + } + } + /// /// 线材类型 /// - [ExcelColumn(Ignore = true)] - public string WireType { get; set; } + //private string _wireType; + //[ExcelColumn(Ignore = true)] + //public string WireType + //{ + // get => _wireType; + // set + // { + // _wireType = value; + // OnPropertyChanged(nameof(WireType)); + // } + //} + /// /// 线径规格(mm2) /// + private string _wireDiameterSpecification; [ExcelColumn(IndexName = "F")] - public string WireDiameterSpecification { get; set; } - /// - /// 是否高柔 - /// - [ExcelColumn(Ignore = true)] - public bool IsHighFlexibility { get; set; } + public string WireDiameterSpecification + { + get => _wireDiameterSpecification; + set + { + _wireDiameterSpecification = value; + OnPropertyChanged(nameof(WireDiameterSpecification)); + } + } /// /// 是否高柔 /// + private bool _isHighFlexibility; + [ExcelColumn(Ignore = true)] + public bool IsHighFlexibility + { + get => _isHighFlexibility; + set + { + _isHighFlexibility = value; + OnPropertyChanged(nameof(IsHighFlexibility)); + } + } + + /// + /// 是否高柔 + /// + private string _isHighFlexibilityStr; [ExcelColumn(Name = "是否高柔")] - public string IsHighFlexibilityStr { get; set; } + public string IsHighFlexibilityStr + { + get => _isHighFlexibilityStr; + set + { + _isHighFlexibilityStr = value; + OnPropertyChanged(nameof(IsHighFlexibilityStr)); + } + } + /// /// 线芯数 /// + private string _wireCoreCount; [ExcelColumn(Name = "线芯数")] - public string WireCoreCount { get; set; } + public string WireCoreCount + { + get => _wireCoreCount; + set + { + _wireCoreCount = value; + OnPropertyChanged(nameof(WireCoreCount)); + } + } + /// /// 线材型号规格 /// + private string _wireModelSpecification; [ExcelColumn(Name = "线材型号规格")] - public string WireModelSpecification { get; set; } + public string WireModelSpecification + { + get => _wireModelSpecification; + set + { + _wireModelSpecification = value; + OnPropertyChanged(nameof(WireModelSpecification)); + } + } + /// /// 插头型号 /// + private string _connectorModel; [ExcelColumn(Name = "插头型号")] - public string ConnectorModel { get; set; } - /// - /// 前端子型号 - /// - [ExcelColumn(Ignore = true)] - public string FrontTerminalModel { get; set; } - /// - /// 后端子型号 - /// - [ExcelColumn(Ignore = true)] - public string BackTerminalModel { get; set; } + public string ConnectorModel + { + get => _connectorModel; + set + { + _connectorModel = value; + OnPropertyChanged(nameof(ConnectorModel)); + } + } - + /// + /// 叉耳端子 + /// + private string _forkTerminal; + [ExcelColumn(Name = "叉耳端子")] + public string ForkTerminal + { + get => _forkTerminal; + set + { + _forkTerminal = value; + OnPropertyChanged(nameof(ForkTerminal)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + /// + /// 叉耳端子剥线长度(mm) + /// + private double _forkTerminalStripLength; + [ExcelColumn(Name = "叉耳端子剥线长度(mm)")] + public double ForkTerminalStripLength + { + get => _forkTerminalStripLength; + set + { + _forkTerminalStripLength = value; + OnPropertyChanged(nameof(ForkTerminalStripLength)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// 叉耳端子物料编码 + /// + private string _forkTerminalMaterialCode; + [ExcelColumn(Name = "叉耳端子物料编码")] + public string ForkTerminalMaterialCode + { + get => _forkTerminalMaterialCode; + set + { + _forkTerminalMaterialCode = value; + OnPropertyChanged(nameof(ForkTerminalMaterialCode)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// 扁形端子 + /// + private string _flatTerminal; + [ExcelColumn(Name = "扁形端子")] + public string FlatTerminal + { + get => _flatTerminal; + set + { + _flatTerminal = value; + OnPropertyChanged(nameof(FlatTerminal)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// 扁形端子剥线长度(mm) + /// + private double _flatTerminalStripLength; + [ExcelColumn(Name = "扁形端子剥线长度(mm)")] + public double FlatTerminalStripLength + { + get => _flatTerminalStripLength; + set + { + _flatTerminalStripLength = value; + OnPropertyChanged(nameof(FlatTerminalStripLength)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// 扁形端子物料编码 + /// + private string _flatTerminalMaterialCode; + [ExcelColumn(Name = "扁形端子物料编码")] + public string FlatTerminalMaterialCode + { + get => _flatTerminalMaterialCode; + set + { + _flatTerminalMaterialCode = value; + OnPropertyChanged(nameof(FlatTerminalMaterialCode)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// O型端子 + /// + private string _oTypeTerminal; + [ExcelColumn(Name = "O型端子")] + public string OTypeTerminal + { + get => _oTypeTerminal; + set + { + _oTypeTerminal = value; + OnPropertyChanged(nameof(OTypeTerminal)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// O型端子剥线长度(mm) + /// + private double _oTypeTerminalStripLength; + [ExcelColumn(Name = "O型端子剥线长度(mm)")] + public double OTypeTerminalStripLength + { + get => _oTypeTerminalStripLength; + set + { + _oTypeTerminalStripLength = value; + OnPropertyChanged(nameof(OTypeTerminalStripLength)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// O型端子物料编码 + /// + private string _oTypeTerminalMaterialCode; + [ExcelColumn(Name = "O型端子物料编码")] + public string OTypeTerminalMaterialCode + { + get => _oTypeTerminalMaterialCode; + set + { + _oTypeTerminalMaterialCode = value; + OnPropertyChanged(nameof(OTypeTerminalMaterialCode)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// 针型端子 + /// + private string _pinTerminal; + [ExcelColumn(Name = "针型端子")] + public string PinTerminal + { + get => _pinTerminal; + set + { + _pinTerminal = value; + OnPropertyChanged(nameof(PinTerminal)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// 针型端子剥线长度(mm) + /// + private double _pinTerminalStripLength; + [ExcelColumn(Name = "针型端子剥线长度(mm)")] + public double PinTerminalStripLength + { + get => _pinTerminalStripLength; + set + { + _pinTerminalStripLength = value; + OnPropertyChanged(nameof(PinTerminalStripLength)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// 针型端子物料编码 + /// + private string _pinTerminalMaterialCode; + [ExcelColumn(Name = "针型端子物料编码")] + public string PinTerminalMaterialCode + { + get => _pinTerminalMaterialCode; + set + { + _pinTerminalMaterialCode = value; + OnPropertyChanged(nameof(PinTerminalMaterialCode)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// Y形端子 + /// + private string _yTypeTerminal; + [ExcelColumn(Name = "Y形端子")] + public string YTypeTerminal + { + get => _yTypeTerminal; + set + { + _yTypeTerminal = value; + OnPropertyChanged(nameof(YTypeTerminal)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// Y形端子剥线长度(mm) + /// + private double _yTypeTerminalStripLength; + [ExcelColumn(Name = "Y形端子剥线长度(mm)")] + public double YTypeTerminalStripLength + { + get => _yTypeTerminalStripLength; + set + { + _yTypeTerminalStripLength = value; + OnPropertyChanged(nameof(YTypeTerminalStripLength)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// Y形端子物料编码 + /// + private string _yTypeTerminalMaterialCode; + [ExcelColumn(Name = "Y形端子物料编码")] + public string YTypeTerminalMaterialCode + { + get => _yTypeTerminalMaterialCode; + set + { + _yTypeTerminalMaterialCode = value; + OnPropertyChanged(nameof(YTypeTerminalMaterialCode)); + OnPropertyChanged(nameof(TerminalModels)); + } + } + + /// + /// 前连接 + /// + private string _frontConnectorModel; + [ExcelColumn(Ignore = true)] + public string FrontConnectorModel + { + get => _frontConnectorModel; + set + { + _frontConnectorModel = value; + OnPropertyChanged(nameof(FrontConnectorModel)); + } + } + + /// + /// 后连接 + /// + private string _backConnectorModel; + [ExcelColumn(Ignore = true)] + public string BackConnectorModel + { + get => _backConnectorModel; + set + { + _backConnectorModel = value; + OnPropertyChanged(nameof(BackConnectorModel)); + } + } + + + [ExcelColumn(Ignore = true)] + public List TerminalModels + { + get + { + // 将所有类型的端子模型组合成一个列表 + return [ + new MultiCoreWireTerminalModel + { + TerminalModel = ForkTerminal, + TerminalStripLength = ForkTerminalStripLength, + TerminalMaterialCode = ForkTerminalMaterialCode + }, + new MultiCoreWireTerminalModel + { + TerminalModel = FlatTerminal, + TerminalStripLength = FlatTerminalStripLength, + TerminalMaterialCode = FlatTerminalMaterialCode + }, + new MultiCoreWireTerminalModel + { + TerminalModel = OTypeTerminal, + TerminalStripLength = OTypeTerminalStripLength, + TerminalMaterialCode = OTypeTerminalMaterialCode + }, + new MultiCoreWireTerminalModel + { + TerminalModel = PinTerminal, + TerminalStripLength = PinTerminalStripLength, + TerminalMaterialCode = PinTerminalMaterialCode + }, + new MultiCoreWireTerminalModel + { + TerminalModel = YTypeTerminal, + TerminalStripLength = YTypeTerminalStripLength, + TerminalMaterialCode = YTypeTerminalMaterialCode + } + ]; + } + } + + public event PropertyChangedEventHandler PropertyChanged; + public void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireTerminalModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireTerminalModel.cs new file mode 100644 index 0000000..0820bb7 --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/MultiCoreWire/MultiCoreWireTerminalModel.cs @@ -0,0 +1,27 @@ +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.MultiCoreWire +{ + public class MultiCoreWireTerminalModel + { + /// + /// 端子型号 + /// + public string TerminalModel { get; set; } + + /// + /// 端子剥线长度(mm) + public double TerminalStripLength { get; set; } + + /// + /// 端子物料编码 + /// + public string TerminalMaterialCode { get; set; } + + } +} diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Properties/AssemblyInfo.cs index 1ade4d4..20e68a1 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.1.2")] -[assembly: AssemblyFileVersion("1.0.1.2")] -[assembly: AssemblyInformationalVersion("1.0.1.2")] \ No newline at end of file +[assembly: AssemblyVersion("1.0.1.3")] +[assembly: AssemblyFileVersion("1.0.1.3")] +[assembly: AssemblyInformationalVersion("1.0.1.3")] \ 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 2bda638..cfd7145 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MotorLectotypeService.cs @@ -88,9 +88,10 @@ namespace Sinvo.EplanHpD.Plugin.Service // 查询关联的 LectotypeLine 数据 var selectedLines = DBHelper.DB.Queryable() - .Where(ll => ll.CableLectotypeId == cableLectotype.CableLectotypeId) - //.OrderBy(ll => ll.SeqNo) + .Where(line => line.CableLectotypeId == cableLectotype.CableLectotypeId) .ToList(); + //.OrderBy(ll => ll.SeqNo) + // 构建 CableLectotypeViewModel var viewModel = new CableLectotypeViewModel diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Service/MultiCoreWireService.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MultiCoreWireService.cs new file mode 100644 index 0000000..8cfe7de --- /dev/null +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Service/MultiCoreWireService.cs @@ -0,0 +1,100 @@ +using Newtonsoft.Json.Bson; +using Sinvo.EplanHpD.Plugin.Service; +using Sinvo.EplanHpD.Plugin.Service.Model; +using Sinvo.EplanHpD.Plugin.WPFUI.Models.MultiCoreWire; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Shapes; + +namespace Sinvo.EplanHpD.Plugin.WPFUI.Service +{ + public class MultiCoreWireService + { + public IEnumerable GetByUniqueKey(string uniqueKey) + { + + if (string.IsNullOrEmpty(uniqueKey)) + { + return []; + } + var db = DBHelper.DB; + try + { + var result = db.Queryable() + .Where(it => it.UniqueKey == uniqueKey) + .ToList(); + return result; + } + catch (Exception) + { + throw; + } + } + + // 保存 + public void SaveData(MultiCoreWireLecDBModel line) + { + if (string.IsNullOrEmpty(line.UniqueKey) + || string.IsNullOrEmpty(line.UserId) + || string.IsNullOrEmpty(line.ProjectName)) + { + return; + } + var db = DBHelper.DB; + try + { + db.BeginTran(); + db.Insertable(line).ExecuteCommand(); + db.CommitTran(); + } + catch (Exception) + { + db.RollbackTran(); + throw; + } + } + + internal void ClearSelf(string uniqueKey) + { + if (string.IsNullOrEmpty(uniqueKey)) + { + return; + } + var db = DBHelper.DB; + try + { + db.BeginTran(); + db.Deleteable().Where(it => it.UniqueKey == uniqueKey).ExecuteCommand(); + db.CommitTran(); + } + catch (Exception) + { + db.RollbackTran(); + throw; + } + } + + internal void DeleteById(string id) + { + if (string.IsNullOrEmpty(id)) + { + return; + } + var db = DBHelper.DB; + try + { + db.BeginTran(); + db.Deleteable().Where(it => it.Id == id).ExecuteCommand(); + db.CommitTran(); + } + catch (Exception) + { + db.RollbackTran(); + throw; + } + } + } +} diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj index bae9ae8..b7d1bb5 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Sinvo.EplanHpD.Plugin.WPFUI.csproj @@ -242,6 +242,7 @@ + @@ -253,6 +254,7 @@ + @@ -272,6 +274,7 @@ + TestWindow.xaml @@ -288,6 +291,7 @@ + @@ -308,6 +312,9 @@ LoginWindow.xaml + + MultiCoreWireLayoutHelperWindow.xaml + MultiCoreWireWindow.xaml @@ -348,6 +355,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/Consts.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/Consts.cs index dd0c145..0675864 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/Consts.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/Consts.cs @@ -40,6 +40,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils /// public static readonly Regex dRegex = new("V-[\\d]+\\.?[\\d]*", RegexOptions.Compiled); /// + /// 线径大小匹配(伺服电机线材选型) + /// + public static readonly Regex InsulationRegex = new("(?:[T]{0,}RVV\\d×)(\\d\\.{0,}\\d+)(?:-2000W)?(-CE)?", RegexOptions.Compiled); + /// /// 括号内容匹配 /// public static readonly Regex regexParenthesesContent = new(@"(?<=\()[^)]*(?=\))", RegexOptions.Compiled); diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs index 4332427..0253982 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs @@ -9,6 +9,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils { public class ExcelHelper { + private static IEnumerable _insulations; + private static IEnumerable _terminalMappingCache = []; /// /// 线材端子对照表 @@ -54,8 +56,16 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils /// public static IEnumerable GetInsulationSoftSleeveTable(string wireModel) { + if(_insulations != null) + { + return _insulations.Where(item => item.Specification == wireModel); + } var path = Path.Combine(Consts.DATA_FILE_PATH, Consts.DATA_FILE_PATH_INSULATION); var results = MiniExcel.Query(path); + if(_insulations == null) + { + _insulations = results; + } //.Where(item => item.Specification == wireModel) //.ToList(); return results.Where(item => item.Specification == wireModel); diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeManager.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeManager.cs index 00df2ba..39dcf73 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeManager.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/LectotypeManager.cs @@ -1,4 +1,5 @@ -using Sinvo.EplanHpD.Plugin.Service; +using EPLAN.Harness.ProjectCore; +using Sinvo.EplanHpD.Plugin.Service; using Sinvo.EplanHpD.Plugin.WPFUI.Extension; using Sinvo.EplanHpD.Plugin.WPFUI.Models; using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel; @@ -27,7 +28,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils /// /// /// - public static async Task CreateOrGetAsync(MotorModel motor) + public static CableLectotypeViewModel CreateOrGetAsync(MotorModel motor) { if (motor == null || string.IsNullOrEmpty(motor.AxisNo)) { @@ -67,5 +68,17 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils } } + public static string GetDocName(FlexDesigner designer) + { + var docName = designer.Name; + if (docName.Contains("+")) + { + return docName.Split('+').FirstOrDefault(); + } + else + { + return docName; + } + } } } \ No newline at end of file diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs index a8e5b5c..f13e3e5 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MotorExcelHelper.cs @@ -138,6 +138,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils line.CableType, line.AxisNo, line.DrawingNo, + line.InsulationMCode, + line.InsulationModel, + line.InsulationCount, EncoderLineLength = line.EncoderLineLength == 0 ? "" : line.EncoderLineLength.ToString(), PowerLineLength = line.PowerLineLength == 0 ? "" : line.PowerLineLength.ToString(), OrderDate = DateTime.Now.ToString("yyyy/M/d"), diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MultiCoreWireExcelHelper.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MultiCoreWireExcelHelper.cs index b6f04dd..27997bd 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MultiCoreWireExcelHelper.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/MultiCoreWireExcelHelper.cs @@ -39,6 +39,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils var data = MiniExcel.Query(dataFileStream,sheetName: "多芯线WPS数据配对"); //MiniExcel.Query() return data; - } + } + } } diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotype/CableLectotypeUserControl.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotype/CableLectotypeUserControl.xaml index dbc0e04..5a7c668 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotype/CableLectotypeUserControl.xaml +++ b/Sinvo.EplanHpD.Plugin.WPFUI/View/CableLectotype/CableLectotypeUserControl.xaml @@ -50,7 +50,7 @@ Grid.ColumnSpan="2" Panel.ZIndex="99" ContentTemplate="{StaticResource LoadingMask}" - Visibility="Collapsed" /> + Visibility="Hidden" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + +