105040 多芯线数据抓取优化,导出、右键跳转、图纸与BOM查看
This commit is contained in:
parent
1d394780a7
commit
a0f401aad6
|
|
@ -6,6 +6,7 @@
|
|||
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:pdf="clr-namespace:PdfiumViewer;assembly=PdfiumViewer"
|
||||
xmlns:util="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.Utils"
|
||||
xmlns:viewmodel="clr-namespace:Sinvo.EplanHpD.Plugin.WPFUI.ViewModel"
|
||||
Title="多芯线数据抓取"
|
||||
|
|
@ -105,6 +106,7 @@
|
|||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<hc:DrawerContainer>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80" />
|
||||
|
|
@ -116,17 +118,37 @@
|
|||
Grid.RowSpan="2"
|
||||
Panel.ZIndex="99"
|
||||
Content="{Binding}"
|
||||
ContentTemplate="{StaticResource LoadingMask}" />
|
||||
ContentTemplate="{StaticResource LoadingMask}"
|
||||
Visibility="Collapsed" />
|
||||
<hc:Card Grid.Row="0">
|
||||
<hc:SimpleStackPanel Orientation="Horizontal">
|
||||
|
||||
<hc:SimpleStackPanel
|
||||
Margin="10,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Vertical">
|
||||
<hc:TextBox
|
||||
Width="150"
|
||||
hc:InfoElement.Title="机构号:"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
Style="{StaticResource TextBoxPlusBaseStyle}"
|
||||
Text="{Binding MechanismNo}" />
|
||||
<hc:TextBox
|
||||
Width="150"
|
||||
hc:InfoElement.Title="机构名:"
|
||||
hc:InfoElement.TitlePlacement="Left"
|
||||
Style="{StaticResource TextBoxPlusBaseStyle}"
|
||||
Text="{Binding MechanismName}" />
|
||||
</hc:SimpleStackPanel>
|
||||
<Button
|
||||
Margin="5"
|
||||
Click="Button_Click"
|
||||
Content="刷新数据"
|
||||
Style="{StaticResource ButtonPrimary}" />
|
||||
<Button
|
||||
x:Name="ExportExcelBtn"
|
||||
Margin="5"
|
||||
Click="Button_Click"
|
||||
Click="ExportExcelBtn_Click"
|
||||
Content="导出下单表"
|
||||
Style="{StaticResource ButtonPrimary}" />
|
||||
</hc:SimpleStackPanel>
|
||||
|
|
@ -136,15 +158,19 @@
|
|||
<DataGrid
|
||||
x:Name="LettotypeListView"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserSortColumns="False"
|
||||
EnableColumnVirtualization="True"
|
||||
EnableRowVirtualization="True"
|
||||
ItemsSource="{Binding Source={StaticResource LettotypeData}, IsAsync=True}"
|
||||
RowDetailsVisibilityChanged="LettotypeListView_RowDetailsVisibilityChanged"
|
||||
RowDetailsVisibilityMode="{Binding DetailsShowMode}"
|
||||
RowHeight="NaN"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
SelectedItem="{Binding SelectedItem}"
|
||||
SelectionMode="Single"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.ScrollUnit="Pixel"
|
||||
VirtualizingPanel.ScrollUnit="Item"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling">
|
||||
<DataGrid.Resources>
|
||||
<Style BasedOn="{StaticResource DataGridCellStyle}" TargetType="DataGridCell">
|
||||
|
|
@ -160,7 +186,8 @@
|
|||
</DataGrid.Resources>
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Click="ToSourceMenuItem_Click" Header="在3D中查看(转至源)" />
|
||||
<MenuItem Click="ToSourceMenuItem_Click" Header="在3D中查看(转至线缆)" />
|
||||
<MenuItem Click="ToMotorSourceMenuItem_Click" Header="在3D中查看(转至电机)" />
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.RowStyle>
|
||||
|
|
@ -281,10 +308,13 @@
|
|||
</Style>
|
||||
</DataGridComboBoxColumn.EditingElementStyle>
|
||||
</DataGridComboBoxColumn>-->
|
||||
<DataGridTextColumn Binding="{Binding CableModelNo}" Header="图号" />
|
||||
<DataGridTextColumn
|
||||
MaxWidth="60"
|
||||
Binding="{Binding DrawingNo}"
|
||||
Header="图号" />
|
||||
<DataGridTextColumn
|
||||
MinWidth="200"
|
||||
Binding="{Binding DrawingNo}"
|
||||
Binding="{Binding CableModelNo}"
|
||||
Header="线材型号" />
|
||||
<DataGridTextColumn Binding="{Binding CurrentLine}" Header="当前段号" />
|
||||
<DataGridTextColumn Binding="{Binding LineCount}" Header="总段数" />
|
||||
|
|
@ -311,15 +341,19 @@
|
|||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button
|
||||
Margin="10"
|
||||
x:Name="ViewDrawingButton"
|
||||
Margin="10,0,0,0"
|
||||
Click="ViewDrawingButton_Click"
|
||||
Content="查看图纸"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Tag="{Binding DrawingNo}" />
|
||||
<Button
|
||||
Margin="10"
|
||||
x:Name="ViewBOMButton"
|
||||
Margin="10,0,0,0"
|
||||
Click="ViewBOMButton_Click"
|
||||
Content="查看BOM"
|
||||
Style="{StaticResource ButtonPrimary}"
|
||||
Tag="{Binding DrawingNo}" />
|
||||
Tag="{Binding CableModelNo}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
|
|
@ -327,7 +361,7 @@
|
|||
</DataGrid.Columns>
|
||||
<DataGrid.RowDetailsTemplate>
|
||||
<DataTemplate>
|
||||
<DataGrid
|
||||
<!--<DataGrid
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
MinHeight="100"
|
||||
|
|
@ -335,11 +369,19 @@
|
|||
AutoGenerateColumns="False"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="2,0,0,0"
|
||||
CanUserSortColumns="False"
|
||||
EnableColumnVirtualization="True"
|
||||
EnableRowVirtualization="True"
|
||||
HeadersVisibility="Column"
|
||||
IsReadOnly="True"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
SelectionChanged="SubDetailsDataGrid_SelectionChanged"
|
||||
SelectionUnit="FullRow">
|
||||
SelectionMode="Single"
|
||||
SelectionUnit="FullRow"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.ScrollUnit="Item"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling">
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Click="SubToSourceMenuItem_Click" Header="在3D中查看(转至源)" />
|
||||
|
|
@ -380,7 +422,99 @@
|
|||
<DataGridTextColumn Binding="{Binding CableConnectionClass}" Header="线材连接方式" />
|
||||
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<ListView
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
MinHeight="100"
|
||||
Margin="40,0,0,0"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="2,0,0,0"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
SelectionChanged="SubDetailsDataGrid_SelectionChanged"
|
||||
SelectionMode="Single"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling">
|
||||
<ListView.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Click="SubToSourceMenuItem_Click" Header="在3D中查看(转至源)" />
|
||||
</ContextMenu>
|
||||
</ListView.ContextMenu>
|
||||
<ListView.Resources>
|
||||
<Style
|
||||
x:Key="ListViewItemStyle"
|
||||
BasedOn="{StaticResource {x:Type ListViewItem}}"
|
||||
TargetType="ListViewItem">
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="MaxHeight" Value="9999" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#aa326cf3" />
|
||||
<Setter Property="Foreground" Value="Black" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListView.Resources>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ListViewItemStyle}" TargetType="ListViewItem" />
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="名称" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CableName}" Header="线材名称" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding AxisNo}" Header="轴号" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Length}" Header="长度" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CableType}" Header="线材类型" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CableConnectionClass}" Header="线材连接方式" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</DataGrid>-->
|
||||
<ListView
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
MinHeight="100"
|
||||
Margin="40,0,0,0"
|
||||
BorderBrush="Gray"
|
||||
BorderThickness="2,0,0,0"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
SelectionChanged="SubDetailsDataGrid_SelectionChanged"
|
||||
SelectionMode="Single"
|
||||
VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling">
|
||||
<ListView.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Click="SubToSourceMenuItem_Click" Header="在3D中查看(转至源)" />
|
||||
</ContextMenu>
|
||||
</ListView.ContextMenu>
|
||||
<!--<ListView.Resources>
|
||||
<Style
|
||||
x:Key="ListViewItemStyle"
|
||||
BasedOn="{StaticResource {x:Type ListViewItem}}"
|
||||
TargetType="ListViewItem">
|
||||
<Setter Property="Height" Value="Auto" />
|
||||
<Setter Property="MaxHeight" Value="9999" />
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#aa326cf3" />
|
||||
<Setter Property="Foreground" Value="Black" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListView.Resources>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style BasedOn="{StaticResource ListViewItemStyle}" TargetType="ListViewItem" />
|
||||
</ListView.ItemContainerStyle>-->
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="名称" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CableName}" Header="线材名称" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding AxisNo}" Header="轴号" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Length}" Header="长度" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CableType}" Header="线材类型" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding CableConnectionClass}" Header="线材连接方式" />
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</DataTemplate>
|
||||
</DataGrid.RowDetailsTemplate>
|
||||
</DataGrid>
|
||||
|
|
@ -436,5 +570,176 @@
|
|||
</TabItem>
|
||||
</TabControl>
|
||||
|
||||
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
VerticalAlignment="Center">
|
||||
<hc:Drawer
|
||||
x:Name="DrawPDFDrawer"
|
||||
Closed="DrawPDFDrawer_Closed"
|
||||
Dock="Right"
|
||||
Opened="DrawPDFDrawer_Opened"
|
||||
ShowMode="Push">
|
||||
<Border
|
||||
Width="1200"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
BorderBrush="{DynamicResource BorderBrush}"
|
||||
BorderThickness="0,1,0,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
Margin="10,0,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{StaticResource TextBlockTitle}"
|
||||
Text="预览PDF" />
|
||||
<Button
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"
|
||||
Command="hc:ControlCommands.Close"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}"
|
||||
Style="{StaticResource ButtonIcon}" />
|
||||
<hc:CircleProgressBar
|
||||
x:Name="PdfCircleProgressBar"
|
||||
Grid.Row="1"
|
||||
IsIndeterminate="True" />
|
||||
<AdornerDecorator Grid.Row="1">
|
||||
<pdf:PdfRenderer x:Name="PdfRenderer" Margin="10" />
|
||||
</AdornerDecorator>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</hc:Drawer>
|
||||
<hc:Drawer
|
||||
x:Name="BomDrawer"
|
||||
Dock="Bottom"
|
||||
ShowMode="Cover">
|
||||
<Border
|
||||
Height="500"
|
||||
Background="{DynamicResource RegionBrush}"
|
||||
BorderBrush="{DynamicResource BorderBrush}"
|
||||
BorderThickness="0,1,0,0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel
|
||||
Grid.Row="0"
|
||||
Width="Auto"
|
||||
Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Margin="10,10,0,10"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{StaticResource TextBlockTitle}"
|
||||
Text="预览BOM -> " />
|
||||
<TextBlock
|
||||
x:Name="CableModelLab"
|
||||
MinWidth="200"
|
||||
HorizontalAlignment="Left"
|
||||
Style="{StaticResource TextBlockTitle}"
|
||||
Text="" />
|
||||
</StackPanel>
|
||||
<Button
|
||||
x:Name="ExportBomBtn"
|
||||
Grid.Row="0"
|
||||
Margin="0,0,80,0"
|
||||
HorizontalAlignment="Right"
|
||||
hc:IconElement.Geometry="{StaticResource DownloadGeometry}"
|
||||
Click="ExportBomBtn_Click"
|
||||
Content="导出BOM"
|
||||
Style="{StaticResource ButtonPrimary}" />
|
||||
<Button
|
||||
Grid.Row="0"
|
||||
HorizontalAlignment="Right"
|
||||
hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"
|
||||
Command="hc:ControlCommands.Close"
|
||||
Foreground="{DynamicResource PrimaryTextBrush}"
|
||||
Style="{StaticResource ButtonIcon}" />
|
||||
<ListView
|
||||
Grid.Row="1"
|
||||
BorderThickness="0"
|
||||
ItemsSource="{Binding LineBoms}">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Width="120" DisplayMemberBinding="{Binding MechanicalNo}">
|
||||
<GridViewColumn.Header>
|
||||
<GridViewColumnHeader HorizontalContentAlignment="Center">
|
||||
<TextBlock Text="机构号" />
|
||||
</GridViewColumnHeader>
|
||||
</GridViewColumn.Header>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="120" DisplayMemberBinding="{Binding MechanicalName}">
|
||||
<GridViewColumn.Header>
|
||||
<GridViewColumnHeader HorizontalContentAlignment="Center">
|
||||
<TextBlock Text="机构名" />
|
||||
</GridViewColumnHeader>
|
||||
</GridViewColumn.Header>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="120" DisplayMemberBinding="{Binding DrawingNo}">
|
||||
<GridViewColumn.Header>
|
||||
<GridViewColumnHeader HorizontalContentAlignment="Center">
|
||||
<TextBlock Text="图纸编号" />
|
||||
</GridViewColumnHeader>
|
||||
</GridViewColumn.Header>
|
||||
</GridViewColumn>
|
||||
|
||||
<GridViewColumn Width="60" DisplayMemberBinding="{Binding SeqNo}">
|
||||
<GridViewColumn.Header>
|
||||
<GridViewColumnHeader HorizontalContentAlignment="Center">
|
||||
<TextBlock Text="项次" />
|
||||
</GridViewColumnHeader>
|
||||
</GridViewColumn.Header>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn
|
||||
Width="60"
|
||||
DisplayMemberBinding="{Binding Type}"
|
||||
Header="类型" />
|
||||
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="品名" />
|
||||
<GridViewColumn Width="Auto" Header="规格">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Spec}" ToolTip="{Binding Spec}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn
|
||||
Width="80"
|
||||
DisplayMemberBinding="{Binding Qty}"
|
||||
Header="用量" />
|
||||
<GridViewColumn
|
||||
Width="140"
|
||||
DisplayMemberBinding="{Binding MaterialNo}"
|
||||
Header="料号" />
|
||||
<GridViewColumn
|
||||
Width="100"
|
||||
DisplayMemberBinding="{Binding IsLength}"
|
||||
Header="长度" />
|
||||
<GridViewColumn
|
||||
Width="100"
|
||||
DisplayMemberBinding="{Binding IsFlexibility}"
|
||||
Header="高柔度" />
|
||||
<GridViewColumn Width="200" Header="备注">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Remark}" ToolTip="{Binding Remark}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
</ListView>
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</hc:Drawer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</hc:DrawerContainer>
|
||||
</Window>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
using EPLAN.Harness.Core.Controls;
|
||||
using HandyControl.Controls;
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
|
|
@ -11,7 +18,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
/// <summary>
|
||||
/// LectotypeWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class LectotypeWindow : Window
|
||||
public partial class LectotypeWindow : System.Windows.Window
|
||||
{
|
||||
private LectotypeViewModel ViewModel;
|
||||
public LectotypeWindow(string docId)
|
||||
|
|
@ -25,12 +32,15 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
{
|
||||
try
|
||||
{
|
||||
//DrawPDFHelper.CacheAllPdfToMemory();
|
||||
MotorExcelHelper.Instance.ReadDataToStream();
|
||||
LoadData();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
FlexMessageBox.Error(ex.Message);
|
||||
MotorExcelHelper.Instance.CloseStream();
|
||||
//DrawPDFHelper.ClearCache();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -99,15 +109,19 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
|
||||
private void LettotypeListView_RowDetailsVisibilityChanged(object sender, System.Windows.Controls.DataGridRowDetailsEventArgs e)
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
var datagrid = sender as DataGrid;
|
||||
if (datagrid != null)
|
||||
{
|
||||
var DetailsDataGrid = e.DetailsElement as DataGrid;
|
||||
var DetailsDataGrid = e.DetailsElement as ListView;
|
||||
if (DetailsDataGrid != null)
|
||||
{
|
||||
DetailsDataGrid.ItemsSource = ViewModel.SelectedSubItem;
|
||||
}
|
||||
}
|
||||
stopwatch.Stop();
|
||||
Debug.Print($"LettotypeListView_RowDetailsVisibilityChanged :{stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
|
||||
private void SubToSourceMenuItem_Click(object sender, RoutedEventArgs e)
|
||||
|
|
@ -124,15 +138,16 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
private object SubDetailsDataGridSelectedItem;
|
||||
private void SubDetailsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
DataGrid dataGrid = sender as DataGrid;
|
||||
if (dataGrid != null && dataGrid.SelectedItem != null)
|
||||
var view = sender as ListView;
|
||||
if (view != null && view.SelectedItem != null)
|
||||
{
|
||||
SubDetailsDataGridSelectedItem = dataGrid.SelectedItem;
|
||||
SubDetailsDataGridSelectedItem = view.SelectedItem;
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closed(object sender, System.EventArgs e)
|
||||
{
|
||||
//DrawPDFHelper.ClearCache();
|
||||
MotorExcelHelper.Instance.CloseStream();
|
||||
}
|
||||
|
||||
|
|
@ -149,5 +164,159 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
private void ViewDrawingButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button btn && btn.Tag != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
//LoadingMask.Visibility = Visibility.Visible;
|
||||
var drawId = btn.Tag.ToString();
|
||||
if (string.IsNullOrEmpty(drawId))
|
||||
{
|
||||
DrawPDFDrawer.Tag = "";
|
||||
FlexMessageBox.Error("没有图号!");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
DrawPDFDrawer.Tag = drawId;
|
||||
PdfCircleProgressBar.Visibility = Visibility.Visible;
|
||||
DrawPDFDrawer.IsOpen = true;
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LoadingMask.Visibility = Visibility.Collapsed;
|
||||
FlexMessageBox.Warning(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPDFDrawer_Opened(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Drawer drawer)
|
||||
{
|
||||
string drawId = drawer.Tag as string;
|
||||
Task.Run(() =>
|
||||
{
|
||||
Task.Delay(10);
|
||||
var padPath = @"\\192.168.1.160\plm系统文档\线材选型\图纸\";
|
||||
// 在后台线程中获取PDF流
|
||||
var pdfStream = new FileStream(Path.Combine(padPath, $"{drawId}.pdf"), FileMode.Open, FileAccess.Read);//DrawPDFHelper.GetPDFStream(drawId);
|
||||
|
||||
// 切换到主线程更新UI
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (pdfStream != null)
|
||||
{
|
||||
PdfRenderer.OpenPdf(pdfStream);
|
||||
PdfCircleProgressBar.Visibility = Visibility.Collapsed;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
FlexMessageBox.Warning("图纸不存在!");
|
||||
DrawPDFDrawer.IsOpen = false;
|
||||
}
|
||||
LoadingMask.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPDFDrawer_Closed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
PdfRenderer.UnLoad();
|
||||
});
|
||||
}
|
||||
|
||||
private void ViewBOMButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button btn)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ViewModel.MechanismNo) || string.IsNullOrEmpty(ViewModel.MechanismName))
|
||||
{
|
||||
FlexMessageBox.Warning("请完善机构信息!");
|
||||
return;
|
||||
}
|
||||
|
||||
var cableModel = btn.Tag as string;
|
||||
if (string.IsNullOrEmpty(cableModel))
|
||||
{
|
||||
ExportBomBtn.Tag = "";
|
||||
FlexMessageBox.Error("没有型号!");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (ViewModel.GetBom(cableModel))
|
||||
{
|
||||
ExportBomBtn.Tag = cableModel;
|
||||
CableModelLab.Text = cableModel;
|
||||
BomDrawer.IsOpen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ExportBomBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender is Button btn)
|
||||
{
|
||||
var cableModel = btn.Tag as string;
|
||||
// 选择一个文件夹
|
||||
var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "Excel文件|*.xlsx",
|
||||
FileName = $"线材BOM_{cableModel.Replace('\\', '_').Replace('/', '_')}_{DateTime.Now:yyyy_MM_dd}.xlsx"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
ViewModel.ExportBomList(dialog.FileName, cableModel);
|
||||
}
|
||||
FlexMessageBox.Info("导出完成");
|
||||
}
|
||||
}
|
||||
|
||||
private void ExportExcelBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var exportedPath = new CommonOpenFileDialog
|
||||
{
|
||||
IsFolderPicker = true,
|
||||
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
|
||||
};
|
||||
if (exportedPath.ShowDialog() == CommonFileDialogResult.Ok)
|
||||
{
|
||||
ViewModel.ExportLines(exportedPath.FileName);
|
||||
FlexMessageBox.Info("导出完成");
|
||||
}
|
||||
}
|
||||
|
||||
private void ToMotorSourceMenuItem_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectItem = LettotypeListView.SelectedItem;
|
||||
if (selectItem is LectotypeLineModel model)
|
||||
{
|
||||
var motorModelStr = model.Motor?.MotorModelStr;
|
||||
|
||||
var cableName = model.IsComplexLine ? model.CableName.Split('/')[1] : model.CableName;
|
||||
if (string.IsNullOrEmpty(motorModelStr))
|
||||
{
|
||||
FlexMessageBox.ShowText(FlexMessageBox.Type.INFO, "未获取到电机名称");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
ViewModel.ToMotorSource(motorModelStr, cableName);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
<util:FlagEnumConverter x:Key="FlagEnumConverter" />
|
||||
<DataTemplate x:Key="LoadingMask">
|
||||
<Grid Background="#66424242">
|
||||
|
|
@ -145,8 +146,7 @@
|
|||
hc:InfoElement.Placeholder="W_00961"
|
||||
hc:TitleElement.Title="线名称"
|
||||
IsRealTime="True"
|
||||
SearchStarted="SearchBar_SearchStarted"
|
||||
ShowClearButton="True" />
|
||||
SearchStarted="SearchBar_SearchStarted" />
|
||||
<ToggleButton
|
||||
Width="200"
|
||||
Content="只搜索异常项"
|
||||
|
|
@ -177,6 +177,8 @@
|
|||
<TabItem Header="型号生成" IsSelected="True">
|
||||
<DataGrid
|
||||
x:Name="ModelGenDataGrid"
|
||||
hc:DataGridAttach.EditingComboBoxColumnStyle="{StaticResource ComboBoxBaseStyle}"
|
||||
hc:DataGridAttach.EditingTextColumnStyle="{StaticResource TextBoxBaseStyle}"
|
||||
hc:ScrollViewerAttach.AutoHide="False"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
|
|
@ -185,6 +187,7 @@
|
|||
EnableColumnVirtualization="False"
|
||||
EnableRowVirtualization="True"
|
||||
ItemsSource="{Binding SearchedData, IsAsync=True}"
|
||||
RowHeight="NaN"
|
||||
ScrollViewer.CanContentScroll="True"
|
||||
SelectionUnit="FullRow"
|
||||
VirtualizingPanel.IsContainerVirtualizable="True"
|
||||
|
|
|
|||
|
|
@ -1,10 +1,30 @@
|
|||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class LectotypeLineModel : CheckedModel
|
||||
{
|
||||
/// 机械机构号
|
||||
/// </summary>
|
||||
public string MechanicalNo { get; set; }
|
||||
/// <summary>
|
||||
/// 机械机构名称
|
||||
/// </summary>
|
||||
public string MechanicalName { get; set; }
|
||||
|
||||
private int _itemSeqNo;
|
||||
public int ItemSeqNo
|
||||
{
|
||||
get { return _itemSeqNo; }
|
||||
set
|
||||
{
|
||||
_itemSeqNo = value;
|
||||
OnPropertyChanged(nameof(ItemSeqNo));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int SeqNo;
|
||||
|
||||
|
|
@ -249,59 +269,67 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
{
|
||||
get
|
||||
{
|
||||
if (Motor == null) return "";
|
||||
string drawNo = "MR-";
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
if (Motor == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
string ModelNo = "MR-";
|
||||
var cableFlag = GetCableModelFlag(Motor?.MotorPower, CableType, CableConnectionClass, IsFlexibility);
|
||||
if (string.IsNullOrWhiteSpace(cableFlag))
|
||||
{
|
||||
DrawingNo = "";
|
||||
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
drawNo += cableFlag + "-";
|
||||
ModelNo += cableFlag + "-";
|
||||
}
|
||||
//编码器线+动力线 编码器线+动力刹车线
|
||||
if (CableType is "编码器线+动力线" or "编码器线+动力刹车线") // 组合线
|
||||
drawNo += "A1-";
|
||||
ModelNo += "A1-";
|
||||
|
||||
if (IsFlexibility)
|
||||
{
|
||||
drawNo += "H-";
|
||||
ModelNo += "H-";
|
||||
}
|
||||
else
|
||||
{
|
||||
drawNo += "L-";
|
||||
ModelNo += "L-";
|
||||
|
||||
}
|
||||
if (IsComplexLine)
|
||||
{
|
||||
drawNo += $"{EncoderLineLength}-{PowerLineLength}";
|
||||
ModelNo += $"{EncoderLineLength}-{PowerLineLength}";
|
||||
}
|
||||
else if (IsEncoderLine)
|
||||
{
|
||||
drawNo += $"{EncoderLineLength}";
|
||||
ModelNo += $"{EncoderLineLength}";
|
||||
}
|
||||
else if (IsPowerLine)
|
||||
{
|
||||
drawNo += $"{PowerLineLength}";
|
||||
ModelNo += $"{PowerLineLength}";
|
||||
|
||||
}
|
||||
if (!string.IsNullOrEmpty(AxisNo))
|
||||
{
|
||||
drawNo += "(";
|
||||
drawNo += $"{AxisNo}";
|
||||
ModelNo += "(";
|
||||
ModelNo += $"{AxisNo}";
|
||||
if (CableConnectionClass != "直通")
|
||||
//if (!(CableType is "编码器线+动力线" or "编码器线+动力刹车线"))
|
||||
drawNo += $"-{CurrentLine} / {LineCount}";
|
||||
drawNo += ")";
|
||||
ModelNo += $"-{CurrentLine} / {LineCount}";
|
||||
ModelNo += ")";
|
||||
|
||||
}
|
||||
//if (isUpdateDrawNo)
|
||||
{
|
||||
DrawingNo = GetCableDrawNo();
|
||||
}
|
||||
return drawNo;
|
||||
stopwatch.Stop();
|
||||
Debug.Print($"CableModelNo : {stopwatch.ElapsedMilliseconds}ms");
|
||||
return ModelNo;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
using MiniExcelLibs.Attributes;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class LineBomItemModel : LineBomModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 机械机构号
|
||||
/// </summary>
|
||||
[ExcelColumnName("机构号")]
|
||||
public string MechanicalNo { get; set; }
|
||||
/// <summary>
|
||||
/// 机械机构名称
|
||||
/// </summary>
|
||||
[ExcelColumnName("机构名称")]
|
||||
public string MechanicalName { get; set; }
|
||||
|
||||
|
||||
public void Assign(LineBomModel lineBomModel)
|
||||
{
|
||||
DrawingNo = lineBomModel.DrawingNo;
|
||||
SeqNo = lineBomModel.SeqNo;
|
||||
MaterialNo = lineBomModel.MaterialNo;
|
||||
Type = lineBomModel.Type;
|
||||
Name = lineBomModel.Name;
|
||||
Spec = lineBomModel.Spec;
|
||||
Qty = lineBomModel.Qty;
|
||||
Unit = lineBomModel.Unit;
|
||||
IsLength = lineBomModel.IsLength;
|
||||
IsFlexibility = lineBomModel.IsFlexibility;
|
||||
|
||||
Remark = lineBomModel.Remark;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,233 @@
|
|||
using MiniExcelLibs.Attributes;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class LineBomModel : INotifyPropertyChanged
|
||||
{
|
||||
/*
|
||||
线材图纸编号
|
||||
项次
|
||||
料号
|
||||
类型
|
||||
品名
|
||||
规格
|
||||
用量
|
||||
单位
|
||||
长度否(Y/N)
|
||||
高柔度(Y/N)
|
||||
备注
|
||||
*/
|
||||
/// <summary>
|
||||
/// 线材图纸编号
|
||||
/// </summary>
|
||||
private string _drawingNo;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_drawingNo"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("线材图纸编号")]
|
||||
public string DrawingNo
|
||||
{
|
||||
get { return _drawingNo; }
|
||||
set
|
||||
{
|
||||
_drawingNo = value;
|
||||
OnPropertyChanged(nameof(DrawingNo));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 项次
|
||||
/// </summary>
|
||||
private string _seqNo;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_seqNo"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("项次")]
|
||||
public string SeqNo
|
||||
{
|
||||
get { return _seqNo; }
|
||||
set
|
||||
{
|
||||
_seqNo = value;
|
||||
OnPropertyChanged(nameof(SeqNo));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 料号
|
||||
/// </summary>
|
||||
private string _materialNo;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_materialNo"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("料号")]
|
||||
public string MaterialNo
|
||||
|
||||
{
|
||||
get { return _materialNo; }
|
||||
set
|
||||
{
|
||||
_materialNo = value;
|
||||
OnPropertyChanged(nameof(MaterialNo));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
private string _type;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_type"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("类型")]
|
||||
public string Type
|
||||
{
|
||||
get { return _type; }
|
||||
set
|
||||
{
|
||||
_type = value;
|
||||
OnPropertyChanged(nameof(Type));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 品名
|
||||
/// </summary>
|
||||
private string _name;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_name"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("品名")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set
|
||||
{
|
||||
_name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 规格
|
||||
/// </summary>
|
||||
private string _spec;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_spec"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("规格")]
|
||||
public string Spec
|
||||
{
|
||||
get { return _spec; }
|
||||
set
|
||||
{
|
||||
_spec = value;
|
||||
OnPropertyChanged(nameof(Spec));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 用量
|
||||
/// </summary>
|
||||
private double _qty;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_qty"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("用量")]
|
||||
public double Qty
|
||||
{
|
||||
get { return _qty; }
|
||||
set
|
||||
{
|
||||
_qty = value;
|
||||
OnPropertyChanged(nameof(Qty));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
private string _unit;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_unit"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("单位")]
|
||||
public string Unit
|
||||
{
|
||||
get { return _unit; }
|
||||
set
|
||||
{
|
||||
_unit = value;
|
||||
OnPropertyChanged(nameof(Unit));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 长度否(Y/N)
|
||||
/// </summary>
|
||||
private string _isLength;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_isLength"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("长度否(Y/N)")]
|
||||
public string IsLength
|
||||
{
|
||||
get { return _isLength; }
|
||||
set
|
||||
{
|
||||
_isLength = value;
|
||||
OnPropertyChanged(nameof(IsLength));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 高柔度(Y/N)
|
||||
/// </summary>
|
||||
private string _isFlexibility;
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_isFlexibility"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("高柔度(Y/N)")]
|
||||
public string IsFlexibility
|
||||
{
|
||||
get { return _isFlexibility; }
|
||||
set
|
||||
{
|
||||
_isFlexibility = value;
|
||||
OnPropertyChanged(nameof(IsFlexibility));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
private string _remark;
|
||||
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="_remark"/>
|
||||
/// </summary>
|
||||
[ExcelColumnName("备注")]
|
||||
public string Remark
|
||||
{
|
||||
get { return _remark; }
|
||||
set
|
||||
{
|
||||
_remark = value;
|
||||
OnPropertyChanged(nameof(Remark));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
protected bool SetProperty<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
|
||||
{
|
||||
//if (Equals(field, value)) return false;
|
||||
field = value;
|
||||
OnPropertyChanged(propertyName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -126,7 +126,8 @@
|
|||
<Compile Include="Models\InsulationModel.cs" />
|
||||
<Compile Include="Models\LectotypeLineModel.cs" />
|
||||
<Compile Include="Models\LectotypeModel.cs" />
|
||||
<Compile Include="Models\LineSegmentModel.cs" />
|
||||
<Compile Include="Models\LineBomItemModel.cs" />
|
||||
<Compile Include="Models\LineBomModel.cs" />
|
||||
<Compile Include="Models\MotorModel.cs" />
|
||||
<Compile Include="Models\ReportModel.cs" />
|
||||
<Compile Include="Models\StuffedDataModel.cs" />
|
||||
|
|
@ -137,6 +138,7 @@
|
|||
<Compile Include="Utils\CheckedModelExt.cs" />
|
||||
<Compile Include="Utils\Consts.cs" />
|
||||
<Compile Include="Utils\DataGridType.cs" />
|
||||
<Compile Include="Utils\DrawPDFHelper.cs" />
|
||||
<Compile Include="Utils\ExcelHelper.cs" />
|
||||
<Compile Include="Utils\FlagEnumConverter.cs" />
|
||||
<Compile Include="Utils\LambdaComparer.cs" />
|
||||
|
|
@ -190,10 +192,15 @@
|
|||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\PdfiumViewer\PdfiumViewer.csproj">
|
||||
<Project>{60d3c75c-e71d-4116-bd7e-cac68c4dd96b}</Project>
|
||||
<Name>PdfiumViewer</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="HandyControl">
|
||||
<Version>3.2.0</Version>
|
||||
<Version>3.5.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MiniExcel">
|
||||
<Version>1.34.2</Version>
|
||||
|
|
@ -203,6 +210,9 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="WindowsAPICodePack">
|
||||
<Version>8.0.6</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||
{
|
||||
public class DrawPDFHelper
|
||||
{
|
||||
private static string PDF_PATH = @"\\192.168.1.160\plm系统文档\线材选型\图纸\";
|
||||
private static Dictionary<string, byte[]> _pdfDataDict = new Dictionary<string, byte[]>();
|
||||
|
||||
public static void CacheAllPdfToMemory()
|
||||
{
|
||||
var path = PDF_PATH;
|
||||
var files = Directory.GetFiles(path, "*.pdf");
|
||||
foreach (var file in files)
|
||||
{
|
||||
var drawId = Path.GetFileNameWithoutExtension(file);
|
||||
var data = File.ReadAllBytes(file);
|
||||
_pdfDataDict.Add(drawId, data);
|
||||
}
|
||||
}
|
||||
|
||||
public static MemoryStream GetPDFStream(string drawId)
|
||||
{
|
||||
if (_pdfDataDict.ContainsKey(drawId))
|
||||
{
|
||||
var data = _pdfDataDict[drawId];
|
||||
return new MemoryStream(data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
_pdfDataDict.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using MiniExcelLibs;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
|
@ -77,6 +78,59 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
)).ToList();
|
||||
}
|
||||
|
||||
public List<LineBomModel> GetBomList(string drawNo)
|
||||
{
|
||||
//var filePath = "D:\\Desktop\\Data\\BOM表.xlsx";
|
||||
var filePath = Path.Combine(DATA_FILE_PATH, DATA_FILE_NAME_BOM);
|
||||
var data = MiniExcel.Query<LineBomModel>(filePath).Where(it => it.DrawingNo == drawNo).ToList();
|
||||
//MiniExcel.Query<>()
|
||||
return data;
|
||||
}
|
||||
public void SaveBomListToExcel(string targetPath, List<LineBomItemModel> bomList, string cableModelNo)
|
||||
{
|
||||
MiniExcel.SaveAs(
|
||||
targetPath,
|
||||
bomList
|
||||
);
|
||||
}
|
||||
public bool SaveLinesToExcel(string targetPath, List<LectotypeLineModel> lines)
|
||||
{
|
||||
try
|
||||
{
|
||||
var templatePath = Path.Combine(DATA_FILE_PATH, TEMPLATE_FILE_NAME);
|
||||
var data = lines.Select(line => new
|
||||
{
|
||||
line.ItemSeqNo,
|
||||
line.SeqNo,
|
||||
line.MechanicalNo,
|
||||
line.MechanicalName,
|
||||
line.CableModelNo,
|
||||
line.CableType,
|
||||
line.AxisNo,
|
||||
line.DrawingNo,
|
||||
EncoderLineLength = line.EncoderLineLength == 0 ? "" : line.EncoderLineLength.ToString(),
|
||||
PowerLineLength = line.PowerLineLength == 0 ? "" : line.PowerLineLength.ToString(),
|
||||
|
||||
}).ToList();
|
||||
MiniExcel.SaveAsByTemplate(
|
||||
$"{targetPath}\\线材下单_{DateTime.Now:yyyy_MM_dd}.xlsx",
|
||||
templatePath,
|
||||
new
|
||||
{
|
||||
data
|
||||
},
|
||||
new MiniExcelLibs.OpenXml.OpenXmlConfiguration
|
||||
{
|
||||
FastMode = true
|
||||
}
|
||||
);
|
||||
return true;
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseStream()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,9 +47,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
get => _selectedItem;
|
||||
set
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
_selectedItem = value;
|
||||
OnPropertyChanged();
|
||||
OnSelectedItemChange();
|
||||
stopwatch.Stop();
|
||||
Debug.Print($"OnSelectedItemChange :{stopwatch.ElapsedMilliseconds}ms");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +100,43 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
private List<LineBomItemModel> _lineBoms;
|
||||
public List<LineBomItemModel> LineBoms
|
||||
{
|
||||
get => _lineBoms;
|
||||
set
|
||||
{
|
||||
_lineBoms = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 机构号
|
||||
/// </summary>
|
||||
private string _mechanismNo;
|
||||
public string MechanismNo
|
||||
{
|
||||
get => _mechanismNo;
|
||||
set
|
||||
{
|
||||
_mechanismNo = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 机构名
|
||||
/// </summary>
|
||||
private string _mechanismName;
|
||||
public string MechanismName
|
||||
{
|
||||
get => _mechanismName;
|
||||
set
|
||||
{
|
||||
_mechanismName = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
public List<string> Drivers { get; set; } = [
|
||||
"脉冲型驱动器",
|
||||
"总线型驱动器(CCLINK IE TSN)",
|
||||
|
|
@ -122,7 +162,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
it.GetType() == typeof(OccCableForked)
|
||||
//|| it.GetType() == typeof(OccWire)
|
||||
)
|
||||
.Where(it => !string.IsNullOrEmpty(GetAxisNo((it.Children.First() as OccCablesInsulatorGraph).Imprint)) )
|
||||
//.Where(it => !string.IsNullOrEmpty(GetAxisNo((it.Children.First() as OccCablesInsulatorGraph).Imprint)) )
|
||||
//.Where(it =>it.PartStatus == EPLAN.Harness.Core.LibEntities.Enums.PartStatus.Released)
|
||||
.Select(it =>
|
||||
{
|
||||
|
|
@ -166,7 +206,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
if (libraryName.Contains("&"))
|
||||
{
|
||||
return libraryName.Split('&')[1];
|
||||
return libraryName.Split('&')[1]?.Trim() ?? libraryName;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -294,16 +334,34 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
existLine.SetError("请检查是否使用正确的高柔线");
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
it.IsComplexLine = true;
|
||||
datas.Add(it);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
CheckLines(datas);
|
||||
return [.. datas.OrderByDescending(it => it.SeqNo)];
|
||||
}
|
||||
|
||||
private void CheckLines(List<LectotypeLineModel> lines)
|
||||
{
|
||||
lines?.ForEach(line =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(line.CableModelNo))
|
||||
{
|
||||
line.SetError("未正确取得型号!请检查线材是否使用错误!");
|
||||
}
|
||||
if (line.CableType == "未知类型")
|
||||
{
|
||||
line.SetError("线材类型不正确,请检查印记内容!");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// L -> 动力线 N -> 编码器线
|
||||
/// </summary>
|
||||
|
|
@ -403,6 +461,35 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
FlexMessageBox.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
public void ToMotorSource(string motorName, string cableName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
||||
var part = doc.GetOccurrenceByName(motorName, typeof(OccSubPart));
|
||||
var cable = doc.GetOccurrenceByName(cableName, typeof(OccCableForked));
|
||||
if (part != null)
|
||||
{
|
||||
doc.SelectSet.Clear();
|
||||
var oriOcc = SelfControler<BaseOccurrence>.FindInstance(part.ID);
|
||||
oriOcc.SetVisibility(true, null);
|
||||
doc.SelectSet.Add(oriOcc.Children.First());
|
||||
if (cable != null)
|
||||
{
|
||||
var cableOcc = SelfControler<BaseOccurrence>.FindInstance(cable.ID);
|
||||
cableOcc.SetVisibility(true, null);
|
||||
doc.SelectSet.Add(cableOcc.Children.First());
|
||||
}
|
||||
doc.FitToSelectSet();
|
||||
doc.SelectSet.OnSelectionChanged();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FlexMessageBox.Error(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public Task GetMotors()
|
||||
{
|
||||
var motorsData = new List<MotorModel>();
|
||||
|
|
@ -466,5 +553,56 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
DetailsShowMode = DataGridRowDetailsVisibilityMode.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetBom(string cableModel)
|
||||
{
|
||||
var line = Wires.FirstOrDefault(it => it.CableModelNo == cableModel);
|
||||
if (line != null)
|
||||
{
|
||||
var drawId = line.DrawingNo;
|
||||
var bomList = MotorExcelHelper.Instance.GetBomList(drawId);
|
||||
var genedBomList = new List<LineBomItemModel>();
|
||||
bomList.ForEach(it =>
|
||||
{
|
||||
if (it.Name is "动力线" or "动力刹车线")
|
||||
{
|
||||
it.Qty = line.PowerLineLength;
|
||||
}
|
||||
if (it.Name == "编码器线")
|
||||
{
|
||||
it.Qty = line.EncoderLineLength;
|
||||
}
|
||||
var item = new LineBomItemModel
|
||||
{
|
||||
MechanicalNo = MechanismNo,
|
||||
MechanicalName = MechanismName,
|
||||
};
|
||||
item.Assign(it);
|
||||
genedBomList.Add(item);
|
||||
});
|
||||
LineBoms = genedBomList;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public void ExportBomList(string targetPath, string cableModel)
|
||||
{
|
||||
MotorExcelHelper.Instance.SaveBomListToExcel(targetPath, LineBoms, cableModel);
|
||||
}
|
||||
|
||||
public void ExportLines(string targetPath)
|
||||
{
|
||||
int seq = 1;
|
||||
Wires.ForEach(it =>
|
||||
{
|
||||
it.ItemSeqNo = seq++;
|
||||
MechanismName ??= "";
|
||||
MechanismNo ??= "";
|
||||
});
|
||||
MotorExcelHelper.Instance.SaveLinesToExcel(targetPath, Wires);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sinvo.EplanHpD.Plugin.WPFUI
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sinvo.EplanHpD.Plugin.Test", "Sinvo.EplanHpD.Plugin.Test\Sinvo.EplanHpD.Plugin.Test.csproj", "{AEC39474-528B-4DA8-B650-99189ACB7A2C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfiumViewer", "..\PdfiumViewer\PdfiumViewer.csproj", "{60D3C75C-E71D-4116-BD7E-CAC68C4DD96B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -41,6 +43,14 @@ Global
|
|||
{AEC39474-528B-4DA8-B650-99189ACB7A2C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AEC39474-528B-4DA8-B650-99189ACB7A2C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AEC39474-528B-4DA8-B650-99189ACB7A2C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{60D3C75C-E71D-4116-BD7E-CAC68C4DD96B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{60D3C75C-E71D-4116-BD7E-CAC68C4DD96B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{60D3C75C-E71D-4116-BD7E-CAC68C4DD96B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{60D3C75C-E71D-4116-BD7E-CAC68C4DD96B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{60D3C75C-E71D-4116-BD7E-CAC68C4DD96B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{60D3C75C-E71D-4116-BD7E-CAC68C4DD96B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{60D3C75C-E71D-4116-BD7E-CAC68C4DD96B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{60D3C75C-E71D-4116-BD7E-CAC68C4DD96B}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms.Integration;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin
|
||||
{
|
||||
|
|
@ -14,7 +15,7 @@ namespace Sinvo.EplanHpD.Plugin
|
|||
|
||||
public string Author => "Sinvo";
|
||||
|
||||
public string Description => "兴禾EPLAN Harness proD 2.9 Studio插件,提供线材数据抓取功能";
|
||||
public string Description => "兴禾EPLAN Harness proD 2.9 Studio插件,提供伺服电机线缆抓取功能";
|
||||
|
||||
/// <summary>
|
||||
/// 获取DLL版本
|
||||
|
|
@ -37,16 +38,18 @@ namespace Sinvo.EplanHpD.Plugin
|
|||
}
|
||||
}
|
||||
|
||||
public string ToolbarText => "抓取线材数据";
|
||||
public string ToolbarText => "伺服电机线缆抓取";
|
||||
|
||||
public string ToolbarTooltip => "抓取线材数据";
|
||||
public string ToolbarTooltip => "伺服电机线缆抓取";
|
||||
|
||||
public HpDModule Module => HpDModule.WorkSpace;
|
||||
|
||||
public void Execute(HpdApi api)
|
||||
{
|
||||
var doc = api.CurrentProject.GetActiveDocument();
|
||||
new LectotypeWindow(doc.ID).Show();
|
||||
var window = new LectotypeWindow(doc.ID);
|
||||
ElementHost.EnableModelessKeyboardInterop(window);
|
||||
window.Show();
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
|
|
|
|||
|
|
@ -68,8 +68,8 @@
|
|||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>RefDLL\EPLAN.Harness.ProjectCore.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandyControl, Version=3.2.0.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HandyControl.3.2.0\lib\net48\HandyControl.dll</HintPath>
|
||||
<Reference Include="HandyControl, Version=3.5.1.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HandyControl.3.5.1\lib\net481\HandyControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="HandyControl" version="3.2.0" targetFramework="net481" />
|
||||
<package id="HandyControl" version="3.5.1" targetFramework="net481" />
|
||||
</packages>
|
||||
Loading…
Reference in New Issue