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 EPLAN.Harness.AppCore.AttributeEvents;
using Sinvo.EplanHpD.Plugin.WPFUI.Datas; using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
using Sinvo.EplanHpD.Plugin.WPFUI.Utils; using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
{ {
public class LectotypeLineModel : CheckedModel public class
LectotypeLineModel : CheckedModel
{ {
public string CableLectotypeId { get; set; } public string CableLectotypeId { get; set; }
@ -416,5 +418,92 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
CableType = it.Name CableType = it.Name
}).ToList(); }).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" Grid.ColumnSpan="2"
Panel.ZIndex="99" Panel.ZIndex="99"
ContentTemplate="{StaticResource LoadingMask}" ContentTemplate="{StaticResource LoadingMask}"
Visibility="Collapsed" /> Visibility="Hidden" />
<hc:Card <hc:Card
x:Name="InfoCard" x:Name="InfoCard"
Grid.Row="0" Grid.Row="0"
@ -401,6 +401,30 @@
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </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 Header="是否布线完成">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>

View File

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

View File

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

View File

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

View File

@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel; namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
@ -29,14 +30,13 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
/// </summary> /// </summary>
public void Cablerator() public void Cablerator()
{ {
SelectedLines?.Clear(); SelectedLines?.Clear();
if (string.IsNullOrEmpty(Motor.MotorPower)) if (string.IsNullOrEmpty(Motor.MotorPower))
{ {
ShowWarning("电机功率不能为空!"); ShowWarning("电机功率不能为空!");
return; return;
} }
if(IsEnableParagraph) if (IsEnableParagraph)
{ {
if (EncoderLineParagraph == 0 || PowerLineParagraph == 0) if (EncoderLineParagraph == 0 || PowerLineParagraph == 0)
{ {
@ -462,6 +462,18 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
OnPropertyChanged(nameof(IsEnableSecCableType)); OnPropertyChanged(nameof(IsEnableSecCableType));
} }
} }
private bool _loading;
public bool Loading
{
get => _loading;
set
{
_loading = value;
OnPropertyChanged(nameof(Loading));
}
}
public bool SaveToDb() public bool SaveToDb()
{ {
//var service = new MotorLectotypeService(); //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); 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_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); var wires = designer.GetOrganizerOccurrences(designer.ID);
@ -212,6 +212,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
return new LectotypeLineModel return new LectotypeLineModel
{ {
Name= GetLectotypeName(occCable.LibraryName), Name= GetLectotypeName(occCable.LibraryName),
CableModel = GetLectotypeName(occCable.LibraryName),
LibraryName = occCable.LibraryName, LibraryName = occCable.LibraryName,
CableName = occCable.Name, CableName = occCable.Name,
AxisNo = GetAxisNo(insulatorGraph.Imprint), AxisNo = GetAxisNo(insulatorGraph.Imprint),
@ -262,18 +263,18 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
} }
} }
public string GetDocName(FlexDesigner designer) //public string GetDocName(FlexDesigner designer)
{ //{
var docName = designer.Name; // var docName = designer.Name;
if (docName.Contains("+")) // if (docName.Contains("+"))
{ // {
return docName.Split('+').FirstOrDefault(); // return docName.Split('+').FirstOrDefault();
} // }
else // else
{ // {
return docName; // return docName;
} // }
} //}
public List<LectotypeLineModel> StuffData(List<LectotypeLineModel> cables) public List<LectotypeLineModel> StuffData(List<LectotypeLineModel> cables)
{ {
List<LectotypeLineModel> datas = []; List<LectotypeLineModel> datas = [];