更新多个文件,添加新功能和修复bug

在 `CheckTest.cs` 文件中,添加了三个新的测试方法:`CheckWireErpNrTest`、`ChecImprintTest` 和 `CheckSizeTest`。
在 `AssemblyInfo.cs` 文件中,将程序集版本和文件版本从 `1.0.0.5` 更新为 `1.0.0.6`。
在 `StuffTest.cs` 文件中,添加了一个新的断言 `Assert.IsTrue(result.Where(it => it.Imprint == "EC5L3").First().WireColor == "BK");`。
在 `LectotypeWindow.xaml` 文件中,添加了一个新的 `Window` 定义,包括资源字典、按钮和 `TabControl` 控件。
在 `LectotypeWindow.xaml.cs` 文件中,添加了 `LectotypeWindow` 类的定义和相关的事件处理方法。
在 `MainWindow.xaml` 文件中,移除了旧的样式定义,添加了新的资源字典引用,并更新了 `GroupBox` 为 `hc:Card` 控件,调整了按钮样式和 `DataGrid` 的样式。
在 `MainWindow.xaml` 文件中,更新了 `DataGrid` 的 `RowStyle` 和 `CellStyle`,并添加了新的触发器和样式设置。
在 `MainWindow.xaml` 文件中,更新了检查配置项的布局,使用 `hc:Card` 控件替换了 `GroupBox`,并调整了文本块的样式和布局。
在 `MainWindow.xaml.cs` 文件中:
  * 在 `MainWindow` 类中添加了对 `model.IsError` 的检查,如果为 `true`,则将 `model.IsIgnore` 设置为 `true`。
  * 在 `Copy_Click` 方法中添加了 `try-catch` 块来捕获异常,并在捕获到异常时显示错误消息。
  * 在 `GoToSource_Click` 方法中添加了 `try-catch` 块来捕获异常,并在捕获到异常时显示错误消息。
  * 将 `Array.Empty<object>()` 替换为 `[]`。
在 `CheckedModel.cs` 文件中:
  * 注释掉了 `SetProperty` 方法中对 `Equals` 方法的检查。
在 `LectotypeModel.cs` 文件中:
  * 新增了 `LectotypeModel` 类,包含多个属性和相应的 `OnPropertyChanged` 调用。
在 `LineSegmentModel.cs` 文件中:
  * 新增了 `LineSegmentModel` 类,包含 `LineAxisNo`、`LineType` 和 `LineParagraph` 属性。
在 `AssemblyInfo.cs` 文件中:
  * 更新了程序集版本号,从 `1.0.0.5` 更新到 `1.0.0.6`。
在 `Sinvo.EplanHpD.Plugin.WPFUI.csproj` 文件中:
  * 添加了对 `EPLAN.Harness.MathLib` 的引用。
  * 添加了 `LectotypeWindow.xaml` 和 `TestWindow.xaml` 及其对应的代码文件。
  * 添加了 `HandyControl` 包的引用。
在 `TestWindow.xaml` 文件中:
  * 新增了 `TestWindow` 窗口的 XAML 定义,包含一个 `DataGrid` 控件。
在 `TestWindow.xaml.cs` 文件中:
  * 新增了 `TestWindow` 类,包含加载数据的方法。
在 `ExcelHelper.cs` 文件中:
  * 修改了 `GetWireTerminalMappingTable` 方法,使其在 `Prefix` 为 `null` 时也能匹配。
  * 新增了 `GetWireInfo` 方法,用于获取线材信息。
在 `LectotypeViewModel.cs` 文件中:
  * 新增了 `LectotypeViewModel` 类,包含加载数据的方法和多个辅助方法。
在 `MainViewModel.Check.cs` 文件中:
  * 在 `ValidateItem` 方法中添加了对 `CheckWireErpNr` 方法的调用。
  * 新增了 `CheckWireErpNr` 方法,用于检查线材料号。
  * 在 `CheckNumberTube` 方法中添加了对 `item.Imprint` 是否为空的检查。

将 `data.AsParallel().WithDegreeOfParallelism(8).ForAll(entry =>` 修改为 `data.Where(it => it.OrigOcc == "OccWire" && !(it?.Properties["WireName"]?.GetDisplayValue()?.StartsWith("导线") ?? false)).AsParallel().WithDegreeOfParallelism(1).ForAll(entry =>`,以过滤出 `OrigOcc` 为 "OccWire" 且 `WireName` 不以 "导线" 开头的数据,并将并行度设置为 1。
将 `data.FrontTerminalModel = item.ConnectorFrom.Contains(":") ? item.ConnectorFrom.Split(':')[0] : item.ConnectorFrom;` 修改为 `data.FrontTerminalModel = item.ConnectorFrom?.Contains(":") ?? false ? item.ConnectorFrom.Split(':')[0] : item.ConnectorFrom ?? "";`,以处理 `ConnectorFrom` 可能为 null 的情况。
将 `data.RearTerminalModel = item.ConnectorTo.Contains(":") ? item.ConnectorTo.Split(':')[0] : item.ConnectorTo;` 修改为 `data.RearTerminalModel = item.ConnectorTo?.Contains(":") ?? false ? item.ConnectorTo.Split(':')[0] : item.ConnectorTo ?? "";`,以处理 `ConnectorTo` 可能为 null 的情况。
删除了 `if (insulationModels.Any()) { data.Insulation = insulationModels.First(); }` 语句块,简化了代码逻辑。
更新了 `GetWireColorCode` 方法中的注释,将原来的注释替换为更简洁的版本。
This commit is contained in:
lihanbo 2024-11-07 12:14:44 +08:00
parent c620fda442
commit 65970751b3
18 changed files with 1033 additions and 218 deletions

View File

@ -165,6 +165,38 @@ namespace Sinvo.EplanHpD.Plugin.Test
}
[TestMethod]
public void CheckWireErpNrTest()
{
var vm = new MainViewModel();
var stuffedData = new StuffedDataModel
{
Imprint = "D-PE1231231",
WireModel = "黄绿色RV0.5-CE定制",
FrontTerminalModel = "C45-1.5-CE定制",
RearTerminalModel = "RNB2-5-CE定制",
};
vm.CheckWireErpNr(stuffedData);
Assert.IsFalse(!stuffedData.IsError);
}
[TestMethod]
public void ChecImprintTest()
{
var vm = new MainViewModel();
var stuffedData = new StuffedDataModel
{
Imprint = "",
WireModel = "黄绿色RV0.5-CE定制",
FrontTerminalModel = "C45-1.5-CE定制",
RearTerminalModel = "RNB2-5-CE定制",
};
vm.CheckAll(new List<StuffedDataModel>(){
stuffedData });
Assert.IsFalse(!stuffedData.IsError);
}
[TestMethod]
public void CheckSizeTest()
{

View File

@ -16,5 +16,5 @@ using System.Runtime.InteropServices;
[assembly: Guid("aec39474-528b-4da8-b650-99189acb7a2c")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.5")]
[assembly: AssemblyFileVersion("1.0.0.5")]
[assembly: AssemblyVersion("1.0.0.6")]
[assembly: AssemblyFileVersion("1.0.0.6")]

View File

@ -97,6 +97,7 @@ Project = "放卷2",
Assert.IsTrue(result.Where(it => it.Imprint == "EC5L1").First().WireColor == "LBU");
Assert.IsTrue(result.Where(it => it.Imprint == "EC5L2").First().WireColor == "BUWH");
Assert.IsTrue(result.Where(it => it.Imprint == "EC5L3").First().WireColor == "BK");
}
}
}

View File

@ -0,0 +1,113 @@
<Window
x:Class="Sinvo.EplanHpD.Plugin.WPFUI.LectotypeWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel"
Title="LectotypeWindow"
Width="800"
Height="450"
d:DataContext="{d:DesignInstance Type=viewmodel:LectotypeViewModel}"
Loaded="Window_Loaded"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
</ResourceDictionary.MergedDictionaries>
<CollectionViewSource x:Key="LettotypeData" Source="{Binding Wires}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="AxisNo" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button
Grid.Row="0"
Height="100"
Click="Button_Click"
Content="Reload" />
<hc:TabControl Grid.Row="1">
<hc:TabItem Header="整理后的数据">
<DataGrid
hc:DataGridAttach.ShowRowNumber="True"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
ClipboardCopyMode="IncludeHeader"
EnableColumnVirtualization="False"
EnableRowVirtualization="True"
IsReadOnly="True"
ItemsSource="{Binding Source={StaticResource LettotypeData}}"
ScrollViewer.CanContentScroll="True"
SelectionUnit="FullRow"
VirtualizingPanel.IsContainerVirtualizable="True"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling">
<DataGrid.GroupStyle>
<!-- Style for groups at top level. -->
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Margin" Value="0,0,0,5" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander
Background="#FF112255"
BorderBrush="#FF002255"
BorderThickness="1,1,1,5"
Foreground="#FFEEEEEE"
IsExpanded="True">
<Expander.Header>
<DockPanel>
<TextBlock
Width="100"
Margin="5,0,0,0"
FontWeight="Bold"
Text="{Binding Path=Name}" />
<TextBlock FontWeight="Bold" Text="{Binding Path=ItemCount}" />
</DockPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</DataGrid.GroupStyle>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Name}" Header="名称" />
<DataGridTextColumn Binding="{Binding CableName}" Header="线材名称" />
<DataGridTextColumn Binding="{Binding AxisNo}" Header="轴号" />
<DataGridTextColumn Binding="{Binding DrawingNo}" Header="图号" />
<DataGridTextColumn Binding="{Binding CurrentLine}" Header="当前段号" />
<DataGridTextColumn Binding="{Binding LineCount}" Header="总段数" />
<DataGridTextColumn Binding="{Binding Length}" Header="长度" />
<DataGridCheckBoxColumn Binding="{Binding IsFlexibility}" Header="是否高柔" />
<!--<DataGridTextColumn Binding="{Binding PowerLineLength}" Header="动力线长度" />
<DataGridTextColumn Binding="{Binding EncoderLineLength}" Header="编码器线长度" />-->
<!--<DataGridTextColumn Binding="{Binding CableFlag}" Header="线材标识" />-->
<DataGridTextColumn Binding="{Binding CableType}" Header="线材类型" />
<DataGridTextColumn Binding="{Binding CableConnectionClass}" Header="线材连接方式" />
<!--<DataGridCheckBoxColumn Binding="{Binding IsEncoderLine}" Header="是否编码器线" />
<DataGridCheckBoxColumn Binding="{Binding IsPowerLine}" Header="是否动力线" />-->
</DataGrid.Columns>
</DataGrid>
</hc:TabItem>
</hc:TabControl>
</Grid>
</Window>

View File

@ -0,0 +1,29 @@
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
using System.Windows;
namespace Sinvo.EplanHpD.Plugin.WPFUI
{
/// <summary>
/// LectotypeWindow.xaml 的交互逻辑
/// </summary>
public partial class LectotypeWindow : Window
{
private LectotypeViewModel ViewModel;
public LectotypeWindow(string docId)
{
InitializeComponent();
//_docId = docId;
this.DataContext = ViewModel = new LectotypeViewModel(docId);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
ViewModel.LoadData();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
ViewModel.LoadData();
}
}
}

View File

@ -3,6 +3,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:util="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.Utils"
xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel"
@ -13,90 +14,38 @@
Loaded="Window_Loaded"
mc:Ignorable="d">
<Window.Resources>
<Style x:Key="DefaultDataGridRowStyle" TargetType="DataGridRow">
<Setter Property="Padding" Value="5" />
<Setter Property="MinHeight" Value="25" />
</Style>
<Style x:Key="DefaultDataGridCellStyle" TargetType="DataGridCell">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="MinHeight" Value="25" />
<Setter Property="FontSize" Value="13" />
<Setter Property="Padding" Value="2,0,0,0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="White" />
<Setter Property="Height" Value="30" />
<Setter Property="FontSize" Value="13" />
<Setter Property="BorderThickness" Value="1,0,0,0" />
<Setter Property="BorderBrush" Value="#aa424242" />
<Setter Property="Padding" Value="2,0,0,0" />
</Style>
<Style TargetType="TabControl">
<Setter Property="VerticalContentAlignment" Value="Bottom" />
</Style>
<Style TargetType="TabItem">
<Setter Property="Background" Value="#33424242" />
<Setter Property="FontSize" Value="13" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border
Padding="5"
Background="{TemplateBinding Background}"
BorderBrush="#66424242"
BorderThickness="1,1,1,0"
CornerRadius="5,5,0,0">
<TextBlock
x:Name="txt"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Header}"
TextTrimming="CharacterEllipsis"
ToolTip="{TemplateBinding Header}"
Visibility="Visible" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Background" Value="#33424242" />
</Trigger>
</Style.Triggers>
</Style>
<util:FlagEnumConverter x:Key="FlagEnumConverter" />
<DataTemplate x:Key="LoadingMask">
<Grid Background="#66424242">
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<TextBlock
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style
x:Key="DataGridCheckBoxCellStyle"
BasedOn="{StaticResource {x:Type DataGridCell}}"
TargetType="DataGridCell">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
</Style>
<util:FlagEnumConverter x:Key="FlagEnumConverter" />
<DataTemplate x:Key="LoadingMask">
<Grid Background="#66424242">
<StackPanel
HorizontalAlignment="Center"
FontSize="16"
Text="加载中..." />
<ProgressBar
Width="200"
Height="10"
IsIndeterminate="True" />
</StackPanel>
</Grid>
</DataTemplate>
VerticalAlignment="Center"
Orientation="Vertical">
<TextBlock
HorizontalAlignment="Center"
FontSize="16"
Text="加载中..." />
<ProgressBar
Width="200"
Height="10"
IsIndeterminate="True" />
</StackPanel>
</Grid>
</DataTemplate>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
@ -110,41 +59,67 @@
Panel.ZIndex="99"
Content="{Binding}"
ContentTemplate="{StaticResource LoadingMask}" />
<GroupBox Grid.Row="0" Header="操作">
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal">
<GroupBox MinWidth="200" Header="项目信息">
<StackPanel Orientation="Vertical">
<StackPanel
Margin="5"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock Text="项目号:" />
<hc:Card
MinWidth="200"
Margin="8"
BorderThickness="0"
Effect="{DynamicResource EffectShadow2}"
FontSize="14">
<StackPanel
Margin="8"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock VerticalAlignment="Center" Text="项目号:" />
<TextBox MinWidth="100" Text="{Binding ProjectNo}" />
</StackPanel>
<StackPanel Margin="5,0,0,0" Orientation="Vertical">
<CheckBox Content="是否全部CE认证" IsChecked="{Binding IsRequireCe}" />
<CheckBox Content="是否使用变色套" IsChecked="{Binding IsUseDiscoloration}" />
<CheckBox
Margin="2"
Content="是否全部CE认证"
FontSize="14"
IsChecked="{Binding IsRequireCe}" />
<CheckBox
Margin="2"
Content="是否使用变色套"
FontSize="14"
IsChecked="{Binding IsUseDiscoloration}" />
</StackPanel>
</StackPanel>
</GroupBox>
<GroupBox MinWidth="200" Header="机构信息">
<StackPanel Orientation="Vertical">
<StackPanel
Margin="5"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock Width="60" Text="机构号:" />
</hc:Card>
<hc:Card
MinWidth="200"
Margin="8"
BorderThickness="0"
Effect="{DynamicResource EffectShadow2}"
FontSize="14">
<StackPanel
Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock
Width="60"
VerticalAlignment="Center"
Text="机构号:" />
<TextBox MinWidth="100" Text="{Binding MechanismNo}" />
</StackPanel>
<StackPanel
Margin="5"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock Width="60" Text="机构名称:" />
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock
Width="60"
VerticalAlignment="Center"
Text="机构名称:" />
<TextBox MinWidth="100" Text="{Binding MechanismName}" />
</StackPanel>
</StackPanel>
</GroupBox>
</hc:Card>
<Button
Height="40"
@ -152,7 +127,8 @@
Padding="10"
Click="Button_Click"
Content="检查"
FontSize="14" />
FontSize="14"
Style="{StaticResource ButtonPrimary}" />
<Button
x:Name="GenTemplateBtn"
Height="40"
@ -160,9 +136,10 @@
Padding="10"
Click="GenTemplateBtn_Click"
Content="生成导入模板数据"
FontSize="14" />
FontSize="14"
Style="{StaticResource ButtonPrimary}" />
</StackPanel>
</GroupBox>
</Grid>
<TabControl x:Name="DataTabControl" Grid.Row="1">
<TabItem Header="报表数据">
<DataGrid
@ -176,15 +153,16 @@
VirtualizingPanel.IsContainerVirtualizable="True"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling">
<DataGrid.Resources>
<!--<DataGrid.Resources>
<Style BasedOn="{StaticResource DefaultDataGridRowStyle}" TargetType="DataGridRow" />
<Style BasedOn="{StaticResource DefaultDataGridCellStyle}" TargetType="DataGridCell" />
</DataGrid.Resources>
</DataGrid.Resources>-->
</DataGrid>
</TabItem>
<TabItem Header="型号生成" IsSelected="True">
<DataGrid
x:Name="ModelGenDataGrid"
hc:ScrollViewerAttach.AutoHide="False"
AutoGenerateColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
@ -223,24 +201,45 @@
</ContextMenu>
</DataGrid.ContextMenu>
<DataGrid.Resources>
<Style BasedOn="{StaticResource DefaultDataGridRowStyle}" TargetType="DataGridRow">
<DataGrid.RowStyle>
<Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
<Setter Property="MinHeight" Value="20" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsError}" Value="true">
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsError}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="#dc4d41" />
<Setter Property="Foreground" Value="White" />
</DataTrigger>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsError}" Value="false" />
<Condition Binding="{Binding IsChecked}" Value="true" />
</MultiDataTrigger.Conditions>
<Setter Property="Background" Value="#18a05d" />
<Setter Property="Foreground" Value="White" />
</MultiDataTrigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#326cf3" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.Resources>
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
<Setter Property="Height" Value="Auto" />
<Setter Property="MaxHeight" Value="9999" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#326cf3" />
<Setter Property="Foreground" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource DefaultDataGridCellStyle}" TargetType="DataGridCell" />
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn
@ -320,7 +319,7 @@
Header="变色套料号"
IsReadOnly="True" />
<DataGridCheckBoxColumn Header="忽略异常">
<!--<DataGridCheckBoxColumn Header="忽略异常">
<DataGridCheckBoxColumn.ElementStyle>
<Style TargetType="CheckBox">
<Setter Property="VerticalAlignment" Value="Center" />
@ -328,22 +327,36 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="CheckBox">
<Viewbox Height="20">
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
<CheckBox
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
IsChecked="{Binding IsIgnore, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Viewbox>
IsChecked="{Binding IsIgnore, UpdateSourceTrigger=PropertyChanged}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGridCheckBoxColumn.ElementStyle>
</DataGridCheckBoxColumn>-->
<DataGridCheckBoxColumn CellStyle="{StaticResource DataGridCheckBoxCellStyle}" Header="忽略异常">
<DataGridCheckBoxColumn.Binding>
<Binding Path="IsIgnore" />
</DataGridCheckBoxColumn.Binding>
</DataGridCheckBoxColumn>
<DataGridTextColumn
Binding="{Binding CheckedMsg}"
Header="检查信息"
IsReadOnly="True" />
<!--<DataGridTemplateColumn Header="异常信息">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Height="auto"
VerticalAlignment="Center"
Text="{Binding CheckedMsg}"
TextWrapping="Wrap" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>-->
<DataGridTextColumn Binding="{Binding CheckedMsg}" Header="异常信息" />
<DataGridTextColumn
Binding="{Binding ErrorCount}"
Header="异常数"
@ -359,15 +372,16 @@
</Grid.RowDefinitions>
<Button
Grid.Row="0"
Height="30"
Width="300"
Height="40"
Margin="5"
Click="ExportDataBtn_Click"
Content="导出下单数据" />
Content="导出下单数据"
FontSize="16"
Style="{StaticResource ButtonPrimary}" />
<DataGrid
x:Name="ImportDataGrid"
Grid.Row="1"
AlternatingRowBackground="#f5f5f5"
AlternationCount="2"
AutoGenerateColumns="False"
EnableColumnVirtualization="True"
EnableRowVirtualization="True"
@ -408,48 +422,99 @@
Header="检查配置项">
<Grid>
<StackPanel>
<GroupBox Header="变色套检查标识">
<StackPanel>
<hc:Card
Margin="8"
Effect="{DynamicResource EffectShadow2}"
FontSize="14">
<hc:Card.Header>
<TextBlock
Margin="10"
FontSize="16"
Text="变色套检查标识" />
</hc:Card.Header>
<StackPanel Margin="10" HorizontalAlignment="Left">
<RadioButton
HorizontalAlignment="Left"
Content="L1/L2/L3/PE"
FontSize="14"
GroupName="Insulation"
IsChecked="{Binding FlagType, Converter={StaticResource FlagEnumConverter}, ConverterParameter={x:Static util:WireFlagType.Dual}}" />
<RadioButton
HorizontalAlignment="Left"
Content="R/S/T/PE"
FontSize="14"
GroupName="Insulation"
IsChecked="{Binding FlagType, Converter={StaticResource FlagEnumConverter}, ConverterParameter={x:Static util:WireFlagType.Single}}" />
<RadioButton
HorizontalAlignment="Left"
Content="L1/R/L2/S/L3/T/PE"
FontSize="14"
GroupName="Insulation"
IsChecked="{Binding FlagType, Converter={StaticResource FlagEnumConverter}, ConverterParameter={x:Static util:WireFlagType.Mix}}" />
</StackPanel>
</GroupBox>
<GroupBox Header="检查规则说明">
<StackPanel>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
</hc:Card>
<hc:Card Margin="8" FontSize="14">
<hc:Card.Header>
<TextBlock
Margin="10"
FontSize="16"
Text="检查规则说明" />
</hc:Card.Header>
<StackPanel Margin="10">
<StackPanel
Margin="2"
VerticalAlignment="Center"
Orientation="Horizontal">
<Rectangle
Width="40"
Height="20"
Fill="#dc4d41" />
<TextBlock VerticalAlignment="Center" Text="红色表示该项存在异常" />
<TextBlock
Margin="2"
VerticalAlignment="Center"
Text="红色表示该项存在异常" />
</StackPanel>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
<StackPanel
Margin="2"
VerticalAlignment="Center"
Orientation="Horizontal">
<Rectangle
Width="40"
Height="20"
Fill="#18a05d" />
<TextBlock VerticalAlignment="Center" Text="绿色表示该项正常,检查通过" />
<TextBlock
Margin="2"
VerticalAlignment="Center"
Text="绿色表示该项正常,检查通过" />
</StackPanel>
<StackPanel VerticalAlignment="Center" Orientation="Vertical">
<TextBlock VerticalAlignment="Center" Text="检查线时,会根据型号配对表中的数据进行检查,当端子使用未与配对表中的信息匹配时,将会提示错误,具体错误请查看每一项的异常信息。" />
<StackPanel
Margin="2"
VerticalAlignment="Center"
Orientation="Vertical">
<TextBlock
Margin="2"
VerticalAlignment="Center"
Text="检查线时,会根据型号配对表中的数据进行检查,当端子使用未与配对表中的信息匹配时,将会提示错误,具体错误请查看每一项的异常信息。" />
<TextBlock VerticalAlignment="Center" Text="当线径为1.5或是1.5以下时变色套管绝缘软套应使用1.5平方,如未按此规则使用,将提示异常。" />
<TextBlock VerticalAlignment="Center" Text="当勾选全部CE认证时未使用CE认证的线或是端子将提示异常。" />
<TextBlock VerticalAlignment="Center" Text="当型号出现重复时将会自动增加5mm长度如果依旧出现重复将会再增加一次第二次增加长度后依旧重复则根据原有长度提示异常。增加长度如果未出现异常则会以增加后的长度进行生成(不会修改已有的数据,只会影响检查时的显示与导出报表)。" />
<TextBlock VerticalAlignment="Center" Text="当型号中出现:(冒号)时会自动去除冒号以及冒号后面的内容。例如“A000-CE / 定制:1” 将会被识别成 “A000-CE / 定制”" />
<TextBlock
Margin="2"
VerticalAlignment="Center"
Text="当线径为1.5或是1.5以下时变色套管绝缘软套应使用1.5平方,如未按此规则使用,将提示异常。" />
<TextBlock
Margin="2"
VerticalAlignment="Center"
Text="当勾选全部CE认证时未使用CE认证的线或是端子将提示异常。" />
<TextBlock
Margin="2"
VerticalAlignment="Center"
Text="当型号出现重复时将会自动增加5mm长度如果依旧出现重复将会再增加一次第二次增加长度后依旧重复则根据原有长度提示异常。增加长度如果未出现异常则会以增加后的长度进行生成(不会修改已有的数据,只会影响检查时的显示与导出报表)。" />
<TextBlock
Margin="2"
VerticalAlignment="Center"
Text="当型号中出现:(冒号)时会自动去除冒号以及冒号后面的内容。例如“A000-CE / 定制:1” 将会被识别成 “A000-CE / 定制”" />
</StackPanel>
</StackPanel>
</GroupBox>
</hc:Card>
</StackPanel>
</Grid>
</TabItem>

View File

@ -237,8 +237,13 @@ public partial class MainWindow : Window
{
if (item is StuffedDataModel model)
{
//var stuffedItem = ViewModel.StuffedData.Where(it => it.WireName == model.WireName).First();
if (model.IsError)
{
//stuffedItem.IsIgnore = true;
model.IsIgnore = true;
}
}
}
}
@ -246,31 +251,40 @@ public partial class MainWindow : Window
private void Copy_Click(object sender, RoutedEventArgs e)
{
if (sender is MenuItem item)
try
{
var selectItems = ModelGenDataGrid.SelectedItems;
if (item.Tag?.ToString() == "MNo")
if (sender is MenuItem item)
{
var str = string.Join("\n", selectItems.Cast<StuffedDataModel>().Select(item => item.WireCode));
Clipboard.SetText(str);
}
if (item.Tag?.ToString() == "ErrMsg")
{
var str = string.Join("\n", selectItems.Cast<StuffedDataModel>().Select(item => item.CheckedMsg));
Clipboard.SetText(str);
}
if (item.Tag?.ToString() == "MNoAndErrMsg")
{
var str = string.Join("\n", selectItems.Cast<StuffedDataModel>().Select(item => $"{item.WireCode}\t{item.CheckedMsg}"));
Clipboard.SetText(str);
}
if (item.Tag?.ToString() == "WireName")
{
var str = string.Join("\n", selectItems.Cast<StuffedDataModel>().Select(item => $"{item.WireName}"));
Clipboard.SetText(str);
var selectItems = ModelGenDataGrid.SelectedItems;
if (item.Tag?.ToString() == "MNo")
{
var str = string.Join("\n", selectItems.Cast<StuffedDataModel>().Select(item => item.WireCode));
Clipboard.SetText(str);
}
if (item.Tag?.ToString() == "ErrMsg")
{
var str = string.Join("\n", selectItems.Cast<StuffedDataModel>().Select(item => item.CheckedMsg));
Clipboard.SetText(str);
}
if (item.Tag?.ToString() == "MNoAndErrMsg")
{
var str = string.Join("\n", selectItems.Cast<StuffedDataModel>().Select(item => $"{item.WireCode}\t{item.CheckedMsg}"));
Clipboard.SetText(str);
}
if (item.Tag?.ToString() == "WireName")
{
var str = string.Join("\n", selectItems.Cast<StuffedDataModel>().Select(item => $"{item.WireName}"));
Clipboard.SetText(str);
}
}
e.Handled = true;
}
catch (Exception ex)
{
FlexMessageBox.Error(ex.Message);
}
e.Handled = true;
}
/// <summary>
/// 取消忽略异常
@ -327,23 +341,23 @@ public partial class MainWindow : Window
{
FlexDesigner flexDesigner;
if (text != string.Empty && (flexDesigner = (SelfControler<FlexBaseOrganizer>.FindInstance(text) as FlexDesigner)) != null && (!(flexDesigner is FlexWorkdesk) || Lamparna.Instance.IsWorkdeskAvailable()) && (!(flexDesigner is FlexWorkspace) || Lamparna.Instance.IsWorkspaceAvailable()))
if (text != string.Empty && (flexDesigner = (SelfControler<FlexBaseOrganizer>.FindInstance(text) as FlexDesigner)) != null && (flexDesigner is not FlexWorkdesk || Lamparna.Instance.IsWorkdeskAvailable()) && (flexDesigner is not FlexWorkspace || Lamparna.Instance.IsWorkspaceAvailable()))
{
Singleton<EventProvider>.Instance.Invoke(NamedEvents.Open_Studio_Document, this._report, new object[]
{
Singleton<EventProvider>.Instance.Invoke(NamedEvents.Open_Studio_Document, this._report,
[
flexDesigner
});
]);
if (flexDesigner.ReaderStatus != DataReaderStatus.Full)
{
break;
}
flexDesigner.SelectSet.Clear();
string origID = repoetEntry.OrigID;
List<BaseOccurrence> list = new List<BaseOccurrence>();
List<BaseOccurrence> list = [];
BaseOccurrence baseOccurrence = SelfControler<BaseOccurrence>.FindInstance(origID);
if (baseOccurrence != null && flexDesigner.IsOccRegistered(baseOccurrence))
{
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_BeginUpdate, this, Array.Empty<object>());
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_BeginUpdate, this, []);
if (_report.Reporter is AggregatedBOMReporter)
{
using (List<string>.Enumerator enumerator3 = flexDesigner.GetOccurrencesWithSameLibID(new GUIDVerClass(baseOccurrence.LibID, baseOccurrence.LibVersion), false).GetEnumerator())
@ -355,7 +369,7 @@ public partial class MainWindow : Window
}
}
this.AddToDesignerSelectSet(flexDesigner, list);
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, Array.Empty<object>());
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, []);
flexDesigner.FitToSelectSet();
continue;
}
@ -370,7 +384,7 @@ public partial class MainWindow : Window
}
}
this.AddToDesignerSelectSet(flexDesigner, list);
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, Array.Empty<object>());
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, []);
flexDesigner.FitToSelectSet();
continue;
}
@ -382,7 +396,7 @@ public partial class MainWindow : Window
//}
list.Add(baseOccurrence);
this.AddToDesignerSelectSet(flexDesigner, list);
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, Array.Empty<object>());
Singleton<EventProvider>.Instance.Invoke(NamedEvents.TreeView_EndUpdate, this, []);
flexDesigner.FitToSelectSet();
//flexDesigner.
flexDesigner.SelectSet.OnSelectionChanged();
@ -423,6 +437,13 @@ public partial class MainWindow : Window
private void GoToSource_Click(object sender, RoutedEventArgs e)
{
GoToSource();
try
{
GoToSource();
}
catch (Exception ex)
{
FlexMessageBox.Error(ex.Message);
}
}
}

View File

@ -61,7 +61,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
protected bool SetProperty<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (Equals(field, value)) return false;
//if (Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;

View File

@ -0,0 +1,225 @@
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
{
public class LectotypeModel : CheckedModel
{
private string _name;
public string Name
{
get => _name;
set
{
_name = value;
OnPropertyChanged(nameof(Name));
}
}
private string _cableName;
/// <summary>
/// 线材名称 -> eg:ca_000120
/// </summary>
public string CableName
{
get => _cableName;
set
{
_cableName = value;
OnPropertyChanged(nameof(CableName));
}
}
private string _axisNo;
/// <summary>
/// 轴号
/// </summary>
public string AxisNo
{
get => _axisNo;
set
{
_axisNo = value;
OnPropertyChanged(nameof(AxisNo));
}
}
private string _drawingNo;
/// <summary>
/// 图号
/// </summary>
public string DrawingNo
{
get => _drawingNo;
set
{
_drawingNo = value;
OnPropertyChanged(nameof(DrawingNo));
}
}
private int _currentLine;
/// <summary>
/// 当前段号
/// </summary>
public int CurrentLine
{
get => _currentLine;
set
{
_currentLine = value;
OnPropertyChanged(nameof(CurrentLine));
}
}
private int _lineCount;
/// <summary>
/// 总段数
/// </summary>
public int LineCount
{
get => _lineCount;
set
{
_lineCount = value;
OnPropertyChanged(nameof(LineCount));
}
}
private double _length;
/// <summary>
/// 长度
/// </summary>
public double Length
{
get
{
if (IsPowerLine)
{
return PowerLineLength;
}
else
{
return EncoderLineLength;
}
}
set
{
_length = value;
OnPropertyChanged(nameof(Length));
}
}
private bool _isFlexibility;
/// <summary>
/// 是否高柔
/// </summary>
public bool IsFlexibility
{
get => _isFlexibility;
set
{
_isFlexibility = value;
OnPropertyChanged(nameof(IsFlexibility));
}
}
private double _powerLineLength;
/// <summary>
/// 动力线长度
/// </summary>
public double PowerLineLength
{
get { return _powerLineLength; }
set
{
_powerLineLength = value;
OnPropertyChanged(nameof(PowerLineLength));
}
}
private double _encoderLineLength;
/// <summary>
/// 编码器线长度
/// </summary>
public double EncoderLineLength
{
get { return _encoderLineLength; }
set
{
_encoderLineLength = value;
OnPropertyChanged(nameof(EncoderLineLength));
}
}
private string _cableFlag;
/// <summary>
/// 线材标识
/// </summary>
public string CableFlag
{
get
{
return _cableFlag;
}
set
{
_cableFlag = value;
OnPropertyChanged(nameof(CableFlag));
}
}
private string _cableType;
/// <summary>
/// 线材类型
/// </summary>
public string CableType
{
get { return _cableType; }
set
{
_cableType = value;
OnPropertyChanged(nameof(CableType));
}
}
/// <summary>
/// 线材连接方式
/// </summary>
private string _cableConnectionClass;
/// <summary>
/// <inheritdoc cref="_cableConnectionClass"/>
/// </summary>
public string CableConnectionClass
{
get { return _cableConnectionClass; }
set
{
_cableConnectionClass = value;
OnPropertyChanged(nameof(CableConnectionClass));
}
}
private bool _isEncoderLine;
/// <summary>
/// 是否编码器线
/// </summary>
public bool IsEncoderLine
{
get => _isEncoderLine;
set
{
_isEncoderLine = value;
OnPropertyChanged();
}
}
private bool _isPowerLine;
/// <summary>
/// 是否动力线
/// </summary>
public bool IsPowerLine
{
get => _isPowerLine;
set
{
_isPowerLine = value;
OnPropertyChanged();
}
}
}
}

View File

@ -0,0 +1,21 @@
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
{
/// <summary>
/// 线段信息
/// </summary>
public class LineSegmentModel
{
/// <summary>
/// 轴号
/// </summary>
public string LineAxisNo { get; set; }
/// <summary>
/// 类型 -> [L -> 动力线] [N -> 编码器线]
/// </summary>
public string LineType { get; set; }
/// <summary>
/// 第几段
/// </summary>
public int LineParagraph { get; set; }
}
}

View File

@ -46,6 +46,6 @@ using System.Windows;
// 生成号
// 修订号
//
[assembly: AssemblyVersion("1.0.0.5")]
[assembly: AssemblyFileVersion("1.0.0.5")]
[assembly: AssemblyInformationalVersion("1.0.0.5")]
[assembly: AssemblyVersion("1.0.0.6")]
[assembly: AssemblyFileVersion("1.0.0.6")]
[assembly: AssemblyInformationalVersion("1.0.0.6")]

View File

@ -80,6 +80,9 @@
<Reference Include="EPLAN.Harness.IO">
<HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.IO.dll</HintPath>
</Reference>
<Reference Include="EPLAN.Harness.MathLib">
<HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.MathLib.dll</HintPath>
</Reference>
<Reference Include="EPLAN.Harness.PlatformCore">
<HintPath>..\Sinvo.EplanHpD.Plugin\RefDLL\EPLAN.Harness.PlatformCore.dll</HintPath>
</Reference>
@ -113,20 +116,33 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Commands\UICommand.cs" />
<Compile Include="LectotypeWindow.xaml.cs">
<DependentUpon>LectotypeWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Models\CheckedModel.cs" />
<Compile Include="Models\ExcelModel.cs" />
<Compile Include="Models\ExportModel.cs" />
<Compile Include="Models\InsulationModel.cs" />
<Compile Include="Models\LectotypeModel.cs" />
<Compile Include="Models\LineSegmentModel.cs" />
<Compile Include="Models\ReportModel.cs" />
<Compile Include="Models\StuffedDataModel.cs" />
<Compile Include="Models\TerminalModel.cs" />
<Compile Include="TestWindow.xaml.cs">
<DependentUpon>TestWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Utils\Consts.cs" />
<Compile Include="Utils\DataGridType.cs" />
<Compile Include="Utils\ExcelHelper.cs" />
<Compile Include="Utils\FlagEnumConverter.cs" />
<Compile Include="Utils\WireFlagType.cs" />
<Compile Include="ViewModel\LectotypeViewModel.cs" />
<Compile Include="ViewModel\MainViewModel.Check.cs" />
<Compile Include="ViewModel\MainViewModel.cs" />
<Page Include="LectotypeWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -135,6 +151,10 @@
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="TestWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@ -164,6 +184,9 @@
</ItemGroup>
<ItemGroup />
<ItemGroup>
<PackageReference Include="HandyControl">
<Version>3.2.0</Version>
</PackageReference>
<PackageReference Include="MiniExcel">
<Version>1.34.2</Version>
</PackageReference>

View File

@ -0,0 +1,29 @@
<Window
x:Class="Sinvo.EplanHpD.Plugin.WPFUI.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="TestWindow"
Width="800"
Height="450"
Loaded="Window_Loaded"
mc:Ignorable="d">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<DataGrid
x:Name="testDataGrid"
AutoGenerateColumns="True"
IsReadOnly="True" />
</Grid>
</Window>

View File

@ -0,0 +1,38 @@
using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
using System.Linq;
using System.Windows;
namespace Sinvo.EplanHpD.Plugin.WPFUI
{
/// <summary>
/// TestWindow.xaml 的交互逻辑
/// </summary>
public partial class TestWindow : Window
{
private string _docId;
public TestWindow(string docID)
{
InitializeComponent();
_docId = docID;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
LoadData();
}
public void LoadData()
{
if (string.IsNullOrEmpty(_docId))
{
return;
}
var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == _docId);
//var data = doc.GetOccurrencesByName("w_00901");
var wires = doc.GetOrganizerOccurrences(doc.ID, typeof(OccWire));
testDataGrid.ItemsSource = wires;
}
}
}

View File

@ -16,9 +16,16 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
public static IEnumerable<ExcelModel> GetWireTerminalMappingTable(string wireModel, string prefix = "")
{
CheckAndGetCache();
return _terminalMappingCache.Where(item => item.WireModelSpecification == wireModel && (item.Prefix == prefix || prefix == ""));
return _terminalMappingCache.Where(item => item.WireModelSpecification == wireModel && (item.Prefix == prefix || item.Prefix == null));
}
/// <summary>
/// 获取线材信息
/// </summary>
public static IEnumerable<ExcelModel> GetWireInfo(string wireModel, string prefix = "")
{
CheckAndGetCache();
return _terminalMappingCache.Where(item => item.WireModelSpecification == wireModel && (item.Prefix == prefix || item.Prefix == null));
}
private static void CheckAndGetCache()
{
lock (_terminalMappingCache)

View File

@ -0,0 +1,181 @@
using EPLAN.Harness.Common.Extensions;
using EPLAN.Harness.ProjectCore;
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
{
public class LectotypeViewModel(string docId) : INotifyPropertyChanged
{
private List<LectotypeModel> _wires;
public List<LectotypeModel> Wires
{
get => _wires;
set
{
_wires = value;
OnPropertyChanged();
}
}
public void LoadData()
{
if (string.IsNullOrEmpty(docId))
{
return;
}
var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
// 获取所有存在的
var wires = doc.GetOrganizerOccurrences(doc.ID);
//OriWires = wires.ToList();
// 所有的线材
// OccCableForked 多芯线? 对应设计器中Cables(电缆)下的内容
// OccWire 导线 对应设计器中Wires(导线)下的内容
List<LectotypeModel> cables = [.. wires
.Where(it =>
it.GetType() == typeof(OccCableForked)
//|| it.GetType() == typeof(OccWire)
)
//.Where(it =>it.PartStatus == EPLAN.Harness.Core.LibEntities.Enums.PartStatus.Released)
.Select(it =>
{
var occCable = (it as OccCableForked);
var insulatorGraph = occCable.Children.First() as OccCablesInsulatorGraph;
var isEncoderLine = GetLineType(insulatorGraph.Imprint,"L");
var isPowerLine = GetLineType(insulatorGraph.Imprint,"N");
var encoderLength = 0d;
var powerLength = 0d;
if(double.TryParse(insulatorGraph.CableLength_VH?.StrVal ?? "0",out double length)){
if(isEncoderLine){
encoderLength = length;
}else{
powerLength = length;
}
}
return new LectotypeModel
{
Name= occCable.LibraryName,
CableName = occCable.Name,
AxisNo = GetAxisNo(insulatorGraph.Imprint),
CurrentLine = GetCableLine(insulatorGraph.Imprint),
IsEncoderLine = isEncoderLine,
IsPowerLine = isPowerLine,
PowerLineLength = powerLength,
EncoderLineLength = encoderLength,
CableType = isEncoderLine ? "编码器线" : isPowerLine ? "动力线" : "位置类型",
};
})
.Where(it => it != null)
.OrderBy(it => it?.CableName ?? "")];
cables.ForEach(it =>
{
var lineCount = 0;
var axisNo = it.AxisNo;
var cabType = it.CableType;
if (axisNo != null && cabType != null)
{
lineCount = cables.Count(cable => cable.AxisNo == axisNo && cable.CableType == cabType);
}
it.LineCount = lineCount;
if (it.CurrentLine == 1)
{
it.CableConnectionClass = "前段";
}
else if (it.CurrentLine > 1 && it.CurrentLine < lineCount)
{
it.CableConnectionClass = "中段";
}
else if (it.CurrentLine == lineCount)
{
it.CableConnectionClass = "尾段";
}
});
Wires = cables;
}
/// <summary>
/// L -> 动力线 N -> 编码器线
/// </summary>
/// <param name="imprint"></param>
/// <returns></returns>
public bool GetLineType(string imprint, string lineFlag)
{
if (imprint != null && imprint.Contains("-"))
{
var vals = imprint.Split('-');
var val = vals[1];
Trace.WriteLine($"{vals[1]},{lineFlag},{val.ToUpper() == lineFlag.ToUpper()}");
return val.ToUpper() == lineFlag.ToUpper();
}
else
{
return false;
}
}
public string GetAxisNo(string imprint)
{
if (imprint != null && imprint.Contains("-"))
{
var vals = imprint.Split('-');
return vals[0] ?? null;
}
else
{
return null;
}
}
public int GetCableLine(string imprint)
{
if (imprint != null && imprint.Contains("-"))
{
var vals = imprint.Split('-');
if (int.TryParse(vals[2], out int line))
{
return line;
}
else
{
return 0;
}
}
else
{
return 0;
}
}
//public string GetWireImprint(OccWire wire)
//{
// return wire.Imprint;
//}
//public OccConnector GetOccEndPin(OccPin pin)
//{
// if (pin == null || pin.Connector == null)
// {
// return null;
// }
// OccConnector connector = pin.Connector;
// if (connector != null)
// {
// return connector;
// }
// else
// {
// return null;
// }
//}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View File

@ -28,6 +28,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
private void ValidateItem(StuffedDataModel item)
{
CheckWireErpNr(item);
CheckRequiredFields(item);
if (IsUseDiscoloration)
{
@ -44,6 +45,32 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
CheckDuplicateModel(item);
}
public void CheckWireErpNr(StuffedDataModel item)
{
var wireInfos = ExcelHelper.GetWireInfo(item.WireModel);
if (wireInfos != null && wireInfos.Count() == 1)
{
var wireInfo = wireInfos.First();
if (wireInfo != null)
{
if (wireInfo.WireMaterialCode != item.WireCode)
{
SetItemError(item, "线材料号错误!\r\n");
}
}
}
else if (wireInfos.Count() > 1)
{
SetItemError(item, "该型号线材存在重复编码!\r\n");
}
else
{
SetItemError(item, "该型号线材不存在配对表中!\r\n");
}
}
private void CheckNumberTube(StuffedDataModel item)
{
if (string.IsNullOrEmpty(item.NumberTubeSpec))
@ -70,6 +97,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
{
SetItemError(item, "线材编码为空\r\n");
}
if (string.IsNullOrEmpty(item.Imprint))
{
SetItemError(item, "印记(线号)内容为空\r\n");
}
}
private void CheckCeCompliance(StuffedDataModel item)

View File

@ -171,7 +171,7 @@ public partial class MainViewModel : INotifyPropertyChanged
var reportDatas = new ConcurrentBag<ReportModel>();
//foreach (var entry in data)
data.AsParallel().WithDegreeOfParallelism(8).ForAll(entry =>
data.Where(it => it.OrigOcc == "OccWire" && !(it?.Properties["WireName"]?.GetDisplayValue()?.StartsWith("导线") ?? false)).AsParallel().WithDegreeOfParallelism(1).ForAll(entry =>
{
var obj = new ReportModel();
foreach (var column in columns)
@ -233,12 +233,12 @@ public partial class MainViewModel : INotifyPropertyChanged
data.WireCode = item.ERPNr;
data.WireName = item.WireName;
data.FrontTerminalModel = item.ConnectorFrom.Contains(":") ? item.ConnectorFrom.Split(':')[0] : item.ConnectorFrom;
data.FrontTerminalModel = item.ConnectorFrom?.Contains(":") ?? false ? item.ConnectorFrom.Split(':')[0] : item.ConnectorFrom ?? "";
data.FrontTerminalMaterialCode = item.ConnectorFromERPNr;
data.FrontStripLength = item.StripLengthFrom;
data.RearTerminalModel = item.ConnectorTo.Contains(":") ? item.ConnectorTo.Split(':')[0] : item.ConnectorTo;
data.RearTerminalModel = item.ConnectorTo?.Contains(":") ?? false ? item.ConnectorTo.Split(':')[0] : item.ConnectorTo ?? "";
data.RearTerminalMaterialCode = item.ConnectorToERPNr;
@ -265,7 +265,6 @@ public partial class MainViewModel : INotifyPropertyChanged
if (insulationModels.Any())
{
data.Insulation = insulationModels.First();
}
}
else
@ -309,36 +308,36 @@ public partial class MainViewModel : INotifyPropertyChanged
{
/*
=IF(AND(!L3="黄色"
!M3="绿色")
"GNYE"
IF(AND(!L3="蓝色"
!M3="白色")
"BUWH"
IF(!L3="红色"
"RD"
IF(!L3="黄色"
"YE"
IF(!L3="蓝色"
"BU"
IF(!L3="绿色"
"GN"
IF(!L3="黑色"
"BK"
IF(!L3="灰色"
"GR"
IF(!L3="白色"
"WH"
IF(!L3="棕色"
"BN"
IF(!L3="橙色"
"OG"
IF(!L3="紫色"
"VT"
IF(!L3="绿/黄双色"
"GNYE"
IF(!L3="浅蓝色"
"LBU"
))))))))))))))
!M3="绿色")
"GNYE"
IF(AND(!L3="蓝色"
!M3="白色")
"BUWH"
IF(!L3="红色"
"RD"
IF(!L3="黄色"
"YE"
IF(!L3="蓝色"
"BU"
IF(!L3="绿色"
"GN"
IF(!L3="黑色"
"BK"
IF(!L3="灰色"
"GR"
IF(!L3="白色"
"WH"
IF(!L3="棕色"
"BN"
IF(!L3="橙色"
"OG"
IF(!L3="紫色"
"VT"
IF(!L3="绿/黄双色"
"GNYE"
IF(!L3="浅蓝色"
"LBU"
))))))))))))))
*/
string colorCode;