diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/ExcelModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/ExcelModel.cs index 7bcf9c4..cb56c06 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/ExcelModel.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/ExcelModel.cs @@ -17,6 +17,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models [ExcelColumn(Name = "规格型号")] public string SpecificationModel { get; set; } + /// + /// 规格型号 + /// + [ExcelColumn(Name = "印记前缀")] + public string Prefix { get; set; } + + /// + /// /// 线材型号规格 /// diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs index 1bbde1b..7908af4 100644 --- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs +++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs @@ -8,9 +8,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel { public partial class MainViewModel { - public void CheckAll() + public void CheckAll(IEnumerable datas) { - StuffedData.AsParallel().WithDegreeOfParallelism(4).ForAll(item => + datas.AsParallel().WithDegreeOfParallelism(4).ForAll(item => { if (item == null) return; item.IsError = false; @@ -125,10 +125,24 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel } } } - + /// + /// 检查引用的端子 + /// + /// private void CheckTerminals(StuffedDataModel item) { - var canUsedTerminals = GetCanUsedTerminal(item.WireModel); + var canUsedTerminals = new List(); + //if(item.) + if (item.Imprint.StartsWith("D-PE")) + { + canUsedTerminals = GetD_PECanUsedTerminal(item.WireModel); + } + else + { + + canUsedTerminals = GetCanUsedTerminal(item.WireModel); + + } if (canUsedTerminals != null && canUsedTerminals.Any()) { if (canUsedTerminals.All(it => it != item.FrontTerminalModel)) @@ -159,6 +173,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel var newModel = $"RV-{item.WireColor}-1x{item.CrossSection}-{item.WireLength + 5}-16×N2-{item.WireNumber}"; if (StuffedData.Any(it => it.Model == newModel)) { + SetItemError(item, $"{item.Model} 该型号存在重复!\r\n"); } else @@ -198,6 +213,39 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel } return terminals; } + /// + /// 检查地线可以用的端子 + /// + /// + /// + private List GetD_PECanUsedTerminal(string wireModel) + { + // 获取D-PE前缀的可用端子 + var resultWithPrefix = ExcelHelper.GetWireTerminalMappingTable(wireModel, "D-PE"); + // 获取不包含前缀的端子 + var resultWithoutPrefix = ExcelHelper.GetWireTerminalMappingTable(wireModel); + var terminals = new List(); + // 转换 + var withPrefixExcelModels = resultWithPrefix as List ?? resultWithPrefix.ToList(); + var withoutPrefixExcelModels = resultWithoutPrefix as List ?? resultWithoutPrefix.ToList(); + // 合并 + var excelModels = withPrefixExcelModels.Concat(withoutPrefixExcelModels); + if (!excelModels.Any()) return terminals; + foreach (var item in excelModels) + { + if (!string.IsNullOrEmpty(item.ForkTerminal)) + terminals.Add(item.ForkTerminal); + if (!string.IsNullOrEmpty(item.FlatTerminal)) + terminals.Add(item.FlatTerminal); + if (!string.IsNullOrEmpty(item.PinTerminal)) + terminals.Add(item.PinTerminal); + if (!string.IsNullOrEmpty(item.OTypeTerminal)) + terminals.Add(item.OTypeTerminal); + if (!string.IsNullOrEmpty(item.YTypeTerminal)) + terminals.Add(item.YTypeTerminal); + } + return terminals; + } private void CheckImprint(StuffedDataModel item) {