105040 增加地线前缀处理

This commit is contained in:
lihanbo 2024-10-26 13:59:13 +08:00
parent ce014b95e0
commit 5574ddbd0e
2 changed files with 60 additions and 4 deletions

View File

@ -17,6 +17,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
[ExcelColumn(Name = "规格型号")] [ExcelColumn(Name = "规格型号")]
public string SpecificationModel { get; set; } public string SpecificationModel { get; set; }
/// <summary>
/// 规格型号
/// </summary>
[ExcelColumn(Name = "印记前缀")]
public string Prefix { get; set; }
///
/// <summary> /// <summary>
/// 线材型号规格 /// 线材型号规格
/// </summary> /// </summary>

View File

@ -8,9 +8,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
{ {
public partial class MainViewModel public partial class MainViewModel
{ {
public void CheckAll() public void CheckAll(IEnumerable<StuffedDataModel> datas)
{ {
StuffedData.AsParallel().WithDegreeOfParallelism(4).ForAll(item => datas.AsParallel().WithDegreeOfParallelism(4).ForAll(item =>
{ {
if (item == null) return; if (item == null) return;
item.IsError = false; item.IsError = false;
@ -125,10 +125,24 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
} }
} }
} }
/// <summary>
/// 检查引用的端子
/// </summary>
/// <param name="item"></param>
private void CheckTerminals(StuffedDataModel item) private void CheckTerminals(StuffedDataModel item)
{ {
var canUsedTerminals = GetCanUsedTerminal(item.WireModel); var canUsedTerminals = new List<string>();
//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 != null && canUsedTerminals.Any())
{ {
if (canUsedTerminals.All(it => it != item.FrontTerminalModel)) 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}"; var newModel = $"RV-{item.WireColor}-1x{item.CrossSection}-{item.WireLength + 5}-16×N2-{item.WireNumber}";
if (StuffedData.Any(it => it.Model == newModel)) if (StuffedData.Any(it => it.Model == newModel))
{ {
SetItemError(item, $"{item.Model} 该型号存在重复!\r\n"); SetItemError(item, $"{item.Model} 该型号存在重复!\r\n");
} }
else else
@ -198,6 +213,39 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
} }
return terminals; return terminals;
} }
/// <summary>
/// 检查地线可以用的端子
/// </summary>
/// <param name="wireModel"></param>
/// <returns></returns>
private List<string> GetD_PECanUsedTerminal(string wireModel)
{
// 获取D-PE前缀的可用端子
var resultWithPrefix = ExcelHelper.GetWireTerminalMappingTable(wireModel, "D-PE");
// 获取不包含前缀的端子
var resultWithoutPrefix = ExcelHelper.GetWireTerminalMappingTable(wireModel);
var terminals = new List<string>();
// 转换
var withPrefixExcelModels = resultWithPrefix as List<ExcelModel> ?? resultWithPrefix.ToList();
var withoutPrefixExcelModels = resultWithoutPrefix as List<ExcelModel> ?? 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) private void CheckImprint(StuffedDataModel item)
{ {