105040 Update 增加动力线与动力编码器线绝缘软套信息匹配

This commit is contained in:
lihanbo 2025-04-24 14:21:42 +08:00
parent 4212086da1
commit 6630e4c877
7 changed files with 219 additions and 66 deletions

View File

@ -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; }
@ -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;
/// <summary>
/// 绝缘软套物料编码
/// </summary>
public string InsulationMCode
{
get
{
return _insulationMCode;
}
set
{
_insulationMCode = value;
OnPropertyChanged(nameof(InsulationMCode));
}
}
/// <summary>
/// 绝缘软套物料编码
/// </summary>
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 " - ";
}
}
}
}

View File

@ -50,7 +50,7 @@
Grid.ColumnSpan="2"
Panel.ZIndex="99"
ContentTemplate="{StaticResource LoadingMask}"
Visibility="Collapsed" />
Visibility="Hidden" />
<hc:Card
x:Name="InfoCard"
Grid.Row="0"
@ -401,6 +401,30 @@
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="150">
<GridViewColumnHeader Content="绝缘软套料号" Visibility="{Binding SubLineNeedInsulation, Converter={StaticResource Boolean2VisibilityConverter}}" />
<GridViewColumn.CellTemplate>
<DataTemplate>
<hc:TextBox
MinWidth="100"
IsReadOnly="True"
Text="{Binding InsulationMCode}"
Visibility="{Binding NeedInsulation, Converter={StaticResource Boolean2VisibilityConverter}}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="420">
<GridViewColumnHeader Content="绝缘软套型号" Visibility="{Binding SubLineNeedInsulation, Converter={StaticResource Boolean2VisibilityConverter}}" />
<GridViewColumn.CellTemplate>
<DataTemplate>
<hc:TextBox
MinWidth="400"
IsReadOnly="True"
Text="{Binding InsulationModel}"
Visibility="{Binding NeedInsulation, Converter={StaticResource Boolean2VisibilityConverter}}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<!--<GridViewColumn Header="是否布线完成">
<GridViewColumn.CellTemplate>
<DataTemplate>

View File

@ -8,6 +8,7 @@ using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@ -58,7 +59,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
try
{
LoadingContentMask.Visibility = Visibility.Visible;
var oldViewModel = LectotypeViewModelFactory.CreateOrGetAsync(_motor).Result;
var oldViewModel = LectotypeViewModelFactory.CreateOrGetAsync(_motor);
if (oldViewModel != null)
{
ViewModel.Apply(oldViewModel);
@ -76,9 +77,17 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
}
}
private void CableratorBtn_Click(object sender, RoutedEventArgs e)
{
LoadingContentMask.Visibility = Visibility.Visible;
Dispatcher.Invoke(() => { });
Task.Factory.StartNew(() =>
{
ViewModel.Cablerator();
//var motor = Motor as MotorModel;
}).ContinueWith(x =>
{
Dispatcher.BeginInvoke(() =>
{
if (Motor is CableLectotypeViewModel motor)
{
// 发送消息,用户生成了数据
@ -89,6 +98,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
}), "Lectotype"
);
}
LoadingContentMask.Visibility = Visibility.Collapsed;
});
});
}
private void ListView_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
@ -115,9 +128,24 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
private void SaveBtn_Click(object sender, RoutedEventArgs e)
{
LoadingContentMask.Visibility = Visibility.Visible;
bool saved = false;
Task.Factory.StartNew(() =>
{
try
{
if (ViewModel.SaveToDb())
saved = ViewModel.SaveToDb();
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
}).ContinueWith(x =>
{
Dispatcher.BeginInvoke(() =>
{
if (saved)
{
if (Motor is CableLectotypeViewModel motor)
{
@ -134,13 +162,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
{
Growl.Error("保存失败", "CableLectotypeMessage");
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
LoadingContentMask.Visibility = Visibility.Collapsed;
});
});
}
private void CloseBtn_Click(object sender, RoutedEventArgs e)
{

View File

@ -496,6 +496,8 @@
</DataGridTemplateColumn>
<DataGridTextColumn Binding="{Binding CableType}" Header="线材类型" />
<DataGridTextColumn Binding="{Binding CableConnectionClass}" Header="线材连接方式" />
<DataGridTextColumn Binding="{Binding InsulationModel}" Header="绝缘软套型号" />
<DataGridTextColumn Binding="{Binding InsulationMCode}" Header="绝缘软套料号" />
<DataGridTextColumn Binding="{Binding CheckedMsg}" Header="异常信息" />
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>

View File

@ -88,6 +88,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
{
//DrawPDFHelper.CacheAllPdfToMemory();
MotorExcelHelper.Instance.ReadDataToStream();
ExcelHelper.GetInsulationSoftSleeveTable("");
LoadData();
}
catch (System.Exception ex)

View File

@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
@ -29,7 +30,6 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
/// </summary>
public void Cablerator()
{
SelectedLines?.Clear();
if (string.IsNullOrEmpty(Motor.MotorPower))
{
@ -462,6 +462,18 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
OnPropertyChanged(nameof(IsEnableSecCableType));
}
}
private bool _loading;
public bool Loading
{
get => _loading;
set
{
_loading = value;
OnPropertyChanged(nameof(Loading));
}
}
public bool SaveToDb()
{
//var service = new MotorLectotypeService();

View File

@ -169,9 +169,9 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
// 当前的工作区
var designer = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
// 获取项目名
DocName = GetDocName(designer);
DocName = LectotypeManager.GetDocName(designer);
LectotypeManager.CURRENT_DOC_NAME = DocName;
LectotypeManager.CURRENT_DOC_CREATE_TIME = new DateTimeOffset(designer.CreatedDateDateTime).ToUnixTimeMilliseconds().ToString();
//LectotypeManager.CURRENT_DOC_CREATE_TIME = new DateTimeOffset(designer.CreatedDateDateTime).ToUnixTimeMilliseconds().ToString();
// 获取所有存在的
var wires = designer.GetOrganizerOccurrences(designer.ID);
@ -212,6 +212,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
return new LectotypeLineModel
{
Name= GetLectotypeName(occCable.LibraryName),
CableModel = GetLectotypeName(occCable.LibraryName),
LibraryName = occCable.LibraryName,
CableName = occCable.Name,
AxisNo = GetAxisNo(insulatorGraph.Imprint),
@ -262,18 +263,18 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
}
}
public string GetDocName(FlexDesigner designer)
{
var docName = designer.Name;
if (docName.Contains("+"))
{
return docName.Split('+').FirstOrDefault();
}
else
{
return docName;
}
}
//public string GetDocName(FlexDesigner designer)
//{
// var docName = designer.Name;
// if (docName.Contains("+"))
// {
// return docName.Split('+').FirstOrDefault();
// }
// else
// {
// return docName;
// }
//}
public List<LectotypeLineModel> StuffData(List<LectotypeLineModel> cables)
{
List<LectotypeLineModel> datas = [];