105040 Update 伺服电机线材抓取增加安川逻辑
This commit is contained in:
parent
c25035284f
commit
3da2dd39bf
|
@ -0,0 +1,16 @@
|
||||||
|
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.Common
|
||||||
|
{
|
||||||
|
internal class OpenDrawMessage : ValueChangedMessage<string>
|
||||||
|
{
|
||||||
|
public OpenDrawMessage(string value) : base(value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.Datas
|
||||||
|
{
|
||||||
|
public static class Brands
|
||||||
|
{
|
||||||
|
public const string UNKNOWN = "未知";
|
||||||
|
public const string ANCHUAN = "安川";
|
||||||
|
public const string SANLING = "三菱";
|
||||||
|
public const string SANLING_HK_KT = "HK-KT";
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -296,6 +297,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
string ModelNo = "MR-";
|
string ModelNo = "MR-";
|
||||||
|
if(Motor.Brand == Brands.ANCHUAN)
|
||||||
|
{
|
||||||
|
ModelNo = "JZSP-";
|
||||||
|
}
|
||||||
var cableFlag = GetCableModelFlag(Motor?.MotorPower, CableType, CableConnectionClass, IsFlexibility);
|
var cableFlag = GetCableModelFlag(Motor?.MotorPower, CableType, CableConnectionClass, IsFlexibility);
|
||||||
if (string.IsNullOrWhiteSpace(cableFlag))
|
if (string.IsNullOrWhiteSpace(cableFlag))
|
||||||
{
|
{
|
||||||
|
@ -335,20 +340,27 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(AxisNo))
|
if (!string.IsNullOrEmpty(AxisNo))
|
||||||
{
|
{
|
||||||
|
if(Motor.Brand == Brands.SANLING_HK_KT)
|
||||||
|
{
|
||||||
|
|
||||||
ModelNo += "(";
|
ModelNo += "(";
|
||||||
|
}
|
||||||
|
if(Motor.Brand == Brands.ANCHUAN)
|
||||||
|
{
|
||||||
|
ModelNo += "-E(";
|
||||||
|
}
|
||||||
ModelNo += $"{AxisNo}";
|
ModelNo += $"{AxisNo}";
|
||||||
if (CableConnectionClass != "直通")
|
if (CableConnectionClass != "直通")
|
||||||
//if (!(CableType is "编码器线+动力线" or "编码器线+动力刹车线"))
|
//if (!(CableType is "编码器线+动力线" or "编码器线+动力刹车线"))
|
||||||
ModelNo += $"-{CurrentLine} / {LineCount}";
|
ModelNo += $"-{CurrentLine} / {LineCount}";
|
||||||
ModelNo += ")";
|
ModelNo += ")";
|
||||||
|
|
||||||
}
|
}
|
||||||
//if (isUpdateDrawNo)
|
//if (isUpdateDrawNo)
|
||||||
{
|
{
|
||||||
DrawingNo = GetCableDrawNo();
|
DrawingNo = GetCableDrawNo();
|
||||||
}
|
}
|
||||||
stopwatch.Stop();
|
stopwatch.Stop();
|
||||||
Debug.Print($"CableModelNo : {stopwatch.ElapsedMilliseconds}ms");
|
Debug.Print($"CableModelNo {ModelNo} : {stopwatch.ElapsedMilliseconds}ms");
|
||||||
return ModelNo;
|
return ModelNo;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
|
@ -363,8 +375,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string GetCableDrawNo()
|
public string GetCableDrawNo()
|
||||||
{
|
{
|
||||||
var data = MotorExcelHelper.Instance.GetCableDatas();
|
var data = MotorExcelHelper.Instance.GetCableDatas(Motor.Brand);
|
||||||
//var data = Core.CoreService.GetService<LectotypeService>().GetCableDatas();
|
//var data = Core.CoreService.GetService<LectotypeService>().GetCableDatas();
|
||||||
|
Trace.WriteLine($"{Motor.MotorPower} - {CableType} - {CableConnectionClass.Replace("全段", "前段")} - {(IsFlexibility ? "是" : "否")}");
|
||||||
var cableData = data.FirstOrDefault(it =>
|
var cableData = data.FirstOrDefault(it =>
|
||||||
it.MotorPower == Motor.MotorPower
|
it.MotorPower == Motor.MotorPower
|
||||||
&& it.LineType == CableType
|
&& it.LineType == CableType
|
||||||
|
@ -382,7 +395,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||||
}
|
}
|
||||||
private string GetCableModelFlag(string motorPower, string cableType, string cableConnectionType, bool isFlexibility)
|
private string GetCableModelFlag(string motorPower, string cableType, string cableConnectionType, bool isFlexibility)
|
||||||
{
|
{
|
||||||
var data = MotorExcelHelper.Instance.GetCableDatas();
|
var data = MotorExcelHelper.Instance.GetCableDatas(Motor.Brand);
|
||||||
//var data = Core.CoreService.GetService<LectotypeService>().GetCableDatas();
|
//var data = Core.CoreService.GetService<LectotypeService>().GetCableDatas();
|
||||||
var cableData = data?.FirstOrDefault(it =>
|
var cableData = data?.FirstOrDefault(it =>
|
||||||
it.MotorPower == motorPower
|
it.MotorPower == motorPower
|
||||||
|
|
|
@ -152,9 +152,11 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Common\CommonMessage.cs" />
|
<Compile Include="Common\CommonMessage.cs" />
|
||||||
|
<Compile Include="Common\OpenDrawMessage.cs" />
|
||||||
<Compile Include="Converter\ConnectionTypeConverter.cs" />
|
<Compile Include="Converter\ConnectionTypeConverter.cs" />
|
||||||
<Compile Include="Converter\FlagEnumConverter.cs" />
|
<Compile Include="Converter\FlagEnumConverter.cs" />
|
||||||
<Compile Include="Converter\NameTypeConverter.cs" />
|
<Compile Include="Converter\NameTypeConverter.cs" />
|
||||||
|
<Compile Include="Datas\Brands.cs" />
|
||||||
<Compile Include="Enum\ConnectionType.cs" />
|
<Compile Include="Enum\ConnectionType.cs" />
|
||||||
<Compile Include="Enum\DataGridType.cs" />
|
<Compile Include="Enum\DataGridType.cs" />
|
||||||
<Compile Include="Enum\ExportFileNameType.cs" />
|
<Compile Include="Enum\ExportFileNameType.cs" />
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using MiniExcelLibs;
|
using MiniExcelLibs;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -25,7 +26,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
dataFileStream = new MemoryStream(bytes);
|
dataFileStream = new MemoryStream(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public List<LectotypeModel> GetCableDatas(string brand = "HK-KT")
|
public List<LectotypeModel> GetCableDatas(string brand = Brands.SANLING_HK_KT)
|
||||||
{
|
{
|
||||||
if (dataFileStream == null || !dataFileStream.CanRead)
|
if (dataFileStream == null || !dataFileStream.CanRead)
|
||||||
{
|
{
|
||||||
|
@ -82,6 +83,37 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
)).ToList();
|
)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 1.动力线,
|
||||||
|
/// 2.编码器线,
|
||||||
|
/// 3.动力刹车线,
|
||||||
|
/// 4.编码器线+动力线,
|
||||||
|
/// 5.编码器线+动力刹车线,
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<ConfigItemModel> GetCableTypes()
|
||||||
|
{
|
||||||
|
//return new List<ConfigItemModel>
|
||||||
|
//{
|
||||||
|
// new(){ ItemName = "动力线", ItemValue = "动力线,"},
|
||||||
|
// new(){ ItemName = "编码器线", ItemValue = "编码器线"},
|
||||||
|
// new(){ ItemName = "动力刹车线", ItemValue = "动力刹车线"},
|
||||||
|
// new(){ ItemName = "编码器线+动力线", ItemValue = "编码器线+动力线"},
|
||||||
|
// new(){ ItemName = "编码器线+动力刹车线", ItemValue = "编码器线+动力刹车线"},
|
||||||
|
//};
|
||||||
|
var data = MiniExcel.Query(dataFileStream, sheetName: "线材类型", useHeaderRow: true).Select(it => new ConfigItemModel
|
||||||
|
{
|
||||||
|
ItemName = it.线材类型,
|
||||||
|
ItemValue = it.线材类型,
|
||||||
|
ItemFlag = it.是否组合
|
||||||
|
}).OrderBy(it => it.ItemName).ToList();
|
||||||
|
|
||||||
|
return data.Distinct(new LambdaComparer<ConfigItemModel>(
|
||||||
|
(a, b) => a.ItemName == b.ItemName && a.ItemValue == b.ItemValue,
|
||||||
|
obj => obj.ToString().GetHashCode()
|
||||||
|
)).OrderBy(it => it.ItemValue).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
public List<LineBomModel> GetBomList(string drawNo)
|
public List<LineBomModel> GetBomList(string drawNo)
|
||||||
{
|
{
|
||||||
//var filePath = "D:\\Desktop\\Data\\BOM表.xlsx";
|
//var filePath = "D:\\Desktop\\Data\\BOM表.xlsx";
|
||||||
|
@ -114,7 +146,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
line.DrawingNo,
|
line.DrawingNo,
|
||||||
EncoderLineLength = line.EncoderLineLength == 0 ? "" : line.EncoderLineLength.ToString(),
|
EncoderLineLength = line.EncoderLineLength == 0 ? "" : line.EncoderLineLength.ToString(),
|
||||||
PowerLineLength = line.PowerLineLength == 0 ? "" : line.PowerLineLength.ToString(),
|
PowerLineLength = line.PowerLineLength == 0 ? "" : line.PowerLineLength.ToString(),
|
||||||
|
OrderDate = DateTime.Now.ToString("yyyy/MM/dd"),
|
||||||
|
DeliveryDate = DateTime.Now.AddDays(7).ToString("yyyy/MM/dd"), // 交期默认一周
|
||||||
}).ToList();
|
}).ToList();
|
||||||
MiniExcel.SaveAsByTemplate(
|
MiniExcel.SaveAsByTemplate(
|
||||||
$"{targetPath}\\线材下单_{DateTime.Now:yyyy_MM_dd}.xlsx",
|
$"{targetPath}\\线材下单_{DateTime.Now:yyyy_MM_dd}.xlsx",
|
||||||
|
|
|
@ -147,7 +147,7 @@
|
||||||
Height="30" />
|
Height="30" />
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
</hc:SimpleStackPanel>-->
|
</hc:SimpleStackPanel>-->
|
||||||
<hc:SimpleStackPanel Margin="0,10,0,0" Orientation="Vertical">
|
<hc:SimpleStackPanel Margin="0,10" Orientation="Vertical">
|
||||||
<hc:SimpleStackPanel Orientation="Horizontal">
|
<hc:SimpleStackPanel Orientation="Horizontal">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Width="100"
|
Width="100"
|
||||||
|
@ -173,7 +173,10 @@
|
||||||
Text="{Binding PowerLineParagraph, Mode=TwoWay}" />
|
Text="{Binding PowerLineParagraph, Mode=TwoWay}" />
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
<hc:SimpleStackPanel Margin="0,10" Orientation="Horizontal">
|
<hc:SimpleStackPanel
|
||||||
|
Margin="0,10"
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Visibility="Collapsed">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Width="100"
|
Width="100"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
@ -276,7 +279,10 @@
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel MinWidth="90" Orientation="Horizontal">
|
<StackPanel MinWidth="90" Orientation="Horizontal">
|
||||||
<Button Content="查看图纸" />
|
<Button
|
||||||
|
Click="ShowDrawBtn_Click"
|
||||||
|
Content="查看图纸"
|
||||||
|
Tag="{Binding DrawingNo}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
|
|
@ -133,5 +133,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||||
private void CloseBtn_Click(object sender, RoutedEventArgs e)
|
private void CloseBtn_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShowDrawBtn_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if(sender is Button btn)
|
||||||
|
{
|
||||||
|
WeakReferenceMessenger.Default.Send<OpenDrawMessage>(new OpenDrawMessage(btn.Tag?.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,6 +261,7 @@
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="{Binding AxisNo}" />
|
Text="{Binding AxisNo}" />
|
||||||
|
|
||||||
<!-- 异常信息 -->
|
<!-- 异常信息 -->
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Column="3"
|
Grid.Column="3"
|
||||||
|
@ -271,6 +272,7 @@
|
||||||
Grid.Column="4"
|
Grid.Column="4"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
|
<!--<TextBlock Text="{Binding Brand}" />-->
|
||||||
<!-- Click="SelectedLectotype_Click" -->
|
<!-- Click="SelectedLectotype_Click" -->
|
||||||
<ToggleButton Content="展开线材选型" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=Expander}}" />
|
<ToggleButton Content="展开线材选型" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=Expander}}" />
|
||||||
<Button
|
<Button
|
||||||
|
@ -312,6 +314,8 @@
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="整理后的数据">
|
<TabItem Header="整理后的数据">
|
||||||
<!--
|
<!--
|
||||||
|
RowDetailsVisibilityChanged="LettotypeListView_RowDetailsVisibilityChanged"
|
||||||
|
RowDetailsVisibilityMode="{Binding DetailsShowMode}"
|
||||||
-->
|
-->
|
||||||
<DataGrid
|
<DataGrid
|
||||||
x:Name="LettotypeListView"
|
x:Name="LettotypeListView"
|
||||||
|
@ -321,8 +325,6 @@
|
||||||
EnableRowVirtualization="False"
|
EnableRowVirtualization="False"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
ItemsSource="{Binding Source={StaticResource LettotypeData}, IsAsync=True}"
|
ItemsSource="{Binding Source={StaticResource LettotypeData}, IsAsync=True}"
|
||||||
RowDetailsVisibilityChanged="LettotypeListView_RowDetailsVisibilityChanged"
|
|
||||||
RowDetailsVisibilityMode="{Binding DetailsShowMode}"
|
|
||||||
RowHeight="NaN"
|
RowHeight="NaN"
|
||||||
ScrollViewer.CanContentScroll="False"
|
ScrollViewer.CanContentScroll="False"
|
||||||
SelectedItem="{Binding SelectedItem}"
|
SelectedItem="{Binding SelectedItem}"
|
||||||
|
@ -520,7 +522,7 @@
|
||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridTemplateColumn>
|
</DataGridTemplateColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
<DataGrid.RowDetailsTemplate>
|
<!--<DataGrid.RowDetailsTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ListView
|
<ListView
|
||||||
Width="Auto"
|
Width="Auto"
|
||||||
|
@ -550,7 +552,7 @@
|
||||||
</ListView.View>
|
</ListView.View>
|
||||||
</ListView>
|
</ListView>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</DataGrid.RowDetailsTemplate>
|
</DataGrid.RowDetailsTemplate>-->
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
|
|
|
@ -49,6 +49,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
||||||
ViewModel.RowDetailsVisibility = (DataGridRowDetailsVisibilityMode)message.Value;
|
ViewModel.RowDetailsVisibility = (DataGridRowDetailsVisibilityMode)message.Value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
WeakReferenceMessenger.Default.Register<OpenDrawMessage>("OpenDraw", (sender, message) =>
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(message.Value))
|
||||||
|
{
|
||||||
|
DrawPDFDrawer.Tag = message.Value;
|
||||||
|
DrawPDFDrawer.IsOpen = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
Growl.Register("CableLectotypeMessage", GrowlParent);
|
Growl.Register("CableLectotypeMessage", GrowlParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +67,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
||||||
//DrawPDFHelper.CacheAllPdfToMemory();
|
//DrawPDFHelper.CacheAllPdfToMemory();
|
||||||
MotorExcelHelper.Instance.ReadDataToStream();
|
MotorExcelHelper.Instance.ReadDataToStream();
|
||||||
LoadData();
|
LoadData();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (System.Exception ex)
|
catch (System.Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -87,14 +94,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
||||||
LoadingMask.Visibility = Visibility.Visible;
|
LoadingMask.Visibility = Visibility.Visible;
|
||||||
ViewModel.GetMotors().ContinueWith(x =>
|
ViewModel.GetMotors().ContinueWith(x =>
|
||||||
{
|
{
|
||||||
//ViewModel.LoadData()
|
ViewModel.LoadData()
|
||||||
// .ContinueWith(x =>
|
.ContinueWith(x =>
|
||||||
// {
|
{
|
||||||
this.Dispatcher.BeginInvoke(delegate ()
|
this.Dispatcher.BeginInvoke(delegate ()
|
||||||
{
|
{
|
||||||
LoadingMask.Visibility = Visibility.Collapsed;
|
LoadingMask.Visibility = Visibility.Collapsed;
|
||||||
});
|
});
|
||||||
//});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -174,6 +181,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
||||||
{
|
{
|
||||||
//DrawPDFHelper.ClearCache();
|
//DrawPDFHelper.ClearCache();
|
||||||
WeakReferenceMessenger.Default.Unregister<CommonMessage>("RowDetailsVisibility");
|
WeakReferenceMessenger.Default.Unregister<CommonMessage>("RowDetailsVisibility");
|
||||||
|
WeakReferenceMessenger.Default.Unregister<CommonMessage>("OpenDraw");
|
||||||
MotorExcelHelper.Instance.CloseStream();
|
MotorExcelHelper.Instance.CloseStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,6 +313,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
||||||
FlexMessageBox.Warning("存在错误项,请检查!");
|
FlexMessageBox.Warning("存在错误项,请检查!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (string.IsNullOrEmpty(ViewModel.MechanismName) || string.IsNullOrEmpty(ViewModel.MechanismNo))
|
||||||
|
{
|
||||||
|
FlexMessageBox.Warning("请先输入机构号与机构名称!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var exportedPath = new CommonOpenFileDialog
|
var exportedPath = new CommonOpenFileDialog
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using HandyControl.Controls;
|
using HandyControl.Controls;
|
||||||
using Sinvo.EplanHpD.Plugin.Service;
|
using Sinvo.EplanHpD.Plugin.Service;
|
||||||
using Sinvo.EplanHpD.Plugin.Service.Model;
|
using Sinvo.EplanHpD.Plugin.Service.Model;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Enum;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Enum;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||||
|
@ -19,7 +20,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||||
public class CableLectotypeViewModel : INotifyPropertyChanged
|
public class CableLectotypeViewModel : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
private const string MESSAGE_KEY = "CableLectotypeMessage";
|
private const string MESSAGE_KEY = "CableLectotypeMessage";
|
||||||
|
private readonly MotorExcelHelper motorExcelHelper = MotorExcelHelper.Instance;
|
||||||
|
|
||||||
|
private Dictionary<string,Dictionary<int,int>> CableTypeIndexs = new Dictionary<string, Dictionary<int, int>>
|
||||||
|
{
|
||||||
|
{ "编码器线", new Dictionary<int,int>{ { 0, 1 } } },
|
||||||
|
{ "动力线", new Dictionary<int,int>{ { 1, -1 } } },
|
||||||
|
{ "动力刹车线", new Dictionary<int,int>{ { 2, -2 } } }
|
||||||
|
};
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成线列表
|
/// 生成线列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -86,6 +94,52 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
||||||
//}
|
//}
|
||||||
// 第一条线为所选线
|
// 第一条线为所选线
|
||||||
LectotypeList.Add(line);
|
LectotypeList.Add(line);
|
||||||
|
|
||||||
|
// 安川第一条线不合并,所以需要再次添加另一个类型的线
|
||||||
|
if (Motor.Brand == Brands.ANCHUAN)
|
||||||
|
{
|
||||||
|
var index = CableTypeIndexs[CableType];
|
||||||
|
var secLineCableType = "";
|
||||||
|
var flag = index.Keys.First() + index.Values.First();
|
||||||
|
if (CableType.Contains("刹车") && flag != 1)
|
||||||
|
{
|
||||||
|
// 动力线 or 动力刹车线
|
||||||
|
flag = 0;
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
secLineCableType = CableTypeIndexs.Keys.ToList()[flag];
|
||||||
|
|
||||||
|
var secLine = new LectotypeLineModel
|
||||||
|
{
|
||||||
|
SeqNo = seqNo,
|
||||||
|
//MechanicalNo = MechanicalNo,
|
||||||
|
//MechanicalName = MechanicalName,
|
||||||
|
AxisNo = AxisNo,
|
||||||
|
//MotorSerie = MotorSerie,
|
||||||
|
//MotorPower = Motor.MotorPower,
|
||||||
|
//DriverInterface = DriverInterface,
|
||||||
|
//DriverModel = DriverModel,
|
||||||
|
CableConnectionClass = CableConnectionType == ConnectionType.FullParagraph ? "前段" : "直通",
|
||||||
|
CableType = secLineCableType,
|
||||||
|
//IsFlexibility = IsFlexibility,
|
||||||
|
//PowerLineLength = PowerLineLength,
|
||||||
|
//EncoderLineLength = EncoderLineLength,
|
||||||
|
//PowerBrakeLineLength = PowerBrakeLineLength,
|
||||||
|
//DrawingNo = LineModelStr,
|
||||||
|
CableModelNo = CableModelStr,
|
||||||
|
//LineCount = Math.Max(PowerLineCount, EncoderLineCount),
|
||||||
|
//CurrentLineNumber = 1,
|
||||||
|
//BomList = GenBomListByCurrent(DrawingNo)
|
||||||
|
IsLectotype = true,
|
||||||
|
CurrentLine = 1,
|
||||||
|
Motor = Motor
|
||||||
|
};
|
||||||
|
secLine.DrawingNo = secLine.GetCableDrawNo();
|
||||||
|
secLine.SubLines = GetSubLines(secLine.DrawingNo);
|
||||||
|
LectotypeList.Add(secLine);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
for (global::System.Int32 i = 2; i <= PowerLineParagraph; i++)
|
for (global::System.Int32 i = 2; i <= PowerLineParagraph; i++)
|
||||||
{
|
{
|
||||||
seqNo++;
|
seqNo++;
|
||||||
|
@ -191,16 +245,25 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return [
|
var isCombo = false;
|
||||||
new ConfigItemModel{
|
if (Motor.Brand == Brands.SANLING)
|
||||||
ItemName = "编码器线+动力线",
|
{
|
||||||
ItemValue = "编码器线+动力线"
|
isCombo = true;
|
||||||
},
|
}
|
||||||
new ConfigItemModel{
|
|
||||||
ItemName = "编码器线+动力刹车线",
|
if(Motor.Brand == Brands.ANCHUAN)
|
||||||
ItemValue = "编码器线+动力刹车线"
|
{
|
||||||
},
|
isCombo = false;
|
||||||
];
|
}
|
||||||
|
var types = motorExcelHelper.GetCableTypes();
|
||||||
|
if(isCombo)
|
||||||
|
{
|
||||||
|
return types.Where(it => it.ItemFlag == "是").ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return types.Where(it => it.ItemFlag == "否").ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|
|
@ -224,16 +224,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
CurrentMotorIndex++;
|
CurrentMotorIndex++;
|
||||||
if (CurrentMotorIndex < _motorIds.Count)
|
if (CurrentMotorIndex < _motorIds.Count)
|
||||||
{
|
{
|
||||||
|
|
||||||
CurrentMotorSelectLineIndex = 0;
|
CurrentMotorSelectLineIndex = 0;
|
||||||
GetMotorCables();
|
GetMotorCables();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}).Wait();
|
}).Wait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ using EPLAN.Harness.Core.Utils;
|
||||||
using EPLAN.Harness.ProjectCore;
|
using EPLAN.Harness.ProjectCore;
|
||||||
using EPLAN.Harness.ProjectCore.Occurrences;
|
using EPLAN.Harness.ProjectCore.Occurrences;
|
||||||
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||||
|
@ -176,16 +177,17 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
it.GetType() == typeof(OccCableForked)
|
it.GetType() == typeof(OccCableForked)
|
||||||
//|| it.GetType() == typeof(OccWire)
|
//|| 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)
|
//.Where(it =>it.PartStatus == EPLAN.Harness.Core.LibEntities.Enums.PartStatus.Released)
|
||||||
.Select(it =>
|
.Select(it =>
|
||||||
{
|
{
|
||||||
|
Trace.WriteLine(string.IsNullOrEmpty(GetAxisNo((it.Children.First() as OccCablesInsulatorGraph).Imprint)));
|
||||||
var occCable = (it as OccCableForked);
|
var occCable = (it as OccCableForked);
|
||||||
var insulatorGraph = occCable.Children.First() as OccCablesInsulatorGraph;
|
var insulatorGraph = occCable.Children.First() as OccCablesInsulatorGraph;
|
||||||
|
|
||||||
var isEncoderLine = GetLineType(insulatorGraph.LibraryName,"编码器线");
|
var isEncoderLine = GetLineType(occCable.LibraryName,"编码器线");
|
||||||
var isPowerLine = GetLineType(insulatorGraph.LibraryName,"动力线");
|
var isPowerLine = GetLineType(occCable.LibraryName,"动力线");
|
||||||
var isBrakePowerLine = GetLineType(insulatorGraph.LibraryName,"动力刹车线");
|
var isBrakePowerLine = GetLineType(occCable.LibraryName,"动力刹车线");
|
||||||
|
|
||||||
var encoderLength = 0d;
|
var encoderLength = 0d;
|
||||||
var powerLength = 0d;
|
var powerLength = 0d;
|
||||||
|
@ -257,7 +259,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
it.LineCount = lineCount;
|
it.LineCount = lineCount;
|
||||||
if (it.CurrentLine == 1)
|
if (it.CurrentLine == 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
it.CableConnectionClass = "前段";
|
it.CableConnectionClass = "前段";
|
||||||
}
|
}
|
||||||
else if (it.CurrentLine > 1 && it.CurrentLine < lineCount)
|
else if (it.CurrentLine > 1 && it.CurrentLine < lineCount)
|
||||||
|
@ -270,6 +271,10 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
|
|
||||||
it.CableConnectionClass = "尾段";
|
it.CableConnectionClass = "尾段";
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it.CableConnectionClass = "未知类型";
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(axisNo))
|
if (string.IsNullOrEmpty(axisNo))
|
||||||
{
|
{
|
||||||
it.IsError = true;
|
it.IsError = true;
|
||||||
|
@ -312,6 +317,9 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
//2 合并同轴号的第一条数据
|
//2 合并同轴号的第一条数据
|
||||||
cables.Where(it => it.CurrentLine == 1).ForEach(it =>
|
cables.Where(it => it.CurrentLine == 1).ForEach(it =>
|
||||||
{
|
{
|
||||||
|
if(it.Motor?.Brand != Brands.ANCHUAN)
|
||||||
|
{
|
||||||
|
|
||||||
var existLine = datas.FirstOrDefault(data => data.AxisNo == it.AxisNo && data.CurrentLine == 1);
|
var existLine = datas.FirstOrDefault(data => data.AxisNo == it.AxisNo && data.CurrentLine == 1);
|
||||||
if (existLine != null)
|
if (existLine != null)
|
||||||
{
|
{
|
||||||
|
@ -368,6 +376,11 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
it.IsComplexLine = true;
|
it.IsComplexLine = true;
|
||||||
datas.Add(it);
|
datas.Add(it);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
datas.Add(it);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
CheckLines(datas);
|
CheckLines(datas);
|
||||||
|
@ -418,7 +431,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var vals = imprint.Split('-');
|
var vals = imprint.Split('-');
|
||||||
if (int.TryParse(vals[2], out int line))
|
if (int.TryParse(vals[1], out int line))
|
||||||
{
|
{
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
@ -500,7 +513,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
doc.SelectSet.Clear();
|
doc.SelectSet.Clear();
|
||||||
var oriOcc = SelfControler<BaseOccurrence>.FindInstance(part.ID);
|
var oriOcc = SelfControler<BaseOccurrence>.FindInstance(part.ID);
|
||||||
oriOcc.SetVisibility(true, null);
|
oriOcc.SetVisibility(true, null);
|
||||||
doc.SelectSet.Add(oriOcc.Children.First());
|
doc.SelectSet.Add(oriOcc);
|
||||||
if (!string.IsNullOrEmpty(cableName) && cable != null)
|
if (!string.IsNullOrEmpty(cableName) && cable != null)
|
||||||
{
|
{
|
||||||
var cableOcc = SelfControler<BaseOccurrence>.FindInstance(cable.ID);
|
var cableOcc = SelfControler<BaseOccurrence>.FindInstance(cable.ID);
|
||||||
|
@ -523,22 +536,26 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
var doc = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
||||||
var parts = doc.GetOrganizerOccurrences(docId)
|
var parts = doc.GetOrganizerOccurrences(docId)
|
||||||
.Where(occ => occ.Type == OCC_TYPE.wPART)
|
.Where(occ => occ.Type == OCC_TYPE.wPART)
|
||||||
.Where(occ => occ.Name?.StartsWith("HK-KT") ?? false)
|
.Where(occ =>
|
||||||
//.Where(occ => occ.Properties?.IsContarins("轴号") ?? false)
|
(occ.Name?.StartsWith("HK-KT") ?? false)
|
||||||
|
|| (occ.Name?.StartsWith("SGMX") ?? false)
|
||||||
|
)
|
||||||
.ToList();
|
.ToList();
|
||||||
var motorPowerDatas = MotorExcelHelper.Instance.GetMotorPowers();
|
var motorPowerDatas = MotorExcelHelper.Instance.GetMotorPowers();
|
||||||
parts.ForEach(part =>
|
parts.ForEach(part =>
|
||||||
{
|
{
|
||||||
var motorPowerData = motorPowerDatas.FirstOrDefault(it => it.ItemFlag == part.Name);
|
|
||||||
var axisNo = part.Properties.IsContarins("轴号") ? part.Properties.FirstOrDefault(it => it.PropertyName == "轴号").GetDisplayValue() : "";
|
var axisNo = part.Properties.IsContarins("轴号") ? part.Properties.FirstOrDefault(it => it.PropertyName == "轴号").GetDisplayValue() : "";
|
||||||
|
|
||||||
var motor = new MotorModel
|
var motor = new MotorModel
|
||||||
{
|
{
|
||||||
MotorModelStr = UnStuffMotorName(part.Name),
|
MotorModelStr = UnStuffMotorName(part.Name),
|
||||||
AxisNo = axisNo,
|
AxisNo = axisNo,
|
||||||
|
Brand = GetMotorBrand(part.Name),
|
||||||
OccPartId = part.ID,
|
OccPartId = part.ID,
|
||||||
IsError = string.IsNullOrEmpty(axisNo)
|
IsError = string.IsNullOrEmpty(axisNo)
|
||||||
};
|
};
|
||||||
|
var motorPowerData = motorPowerDatas.FirstOrDefault(it => it.ItemFlag == motor.MotorModelStr);
|
||||||
|
|
||||||
|
|
||||||
if (motorPowerData != null)
|
if (motorPowerData != null)
|
||||||
{
|
{
|
||||||
motor.MotorPower = motorPowerData.ItemValue;
|
motor.MotorPower = motorPowerData.ItemValue;
|
||||||
|
@ -551,11 +568,40 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
motor.SetError("未填写轴号信息!");
|
motor.SetError("未填写轴号信息!");
|
||||||
}
|
}
|
||||||
|
bool canAdd = true;
|
||||||
|
if(part.Parents != null && part.Parents.Any())
|
||||||
|
{
|
||||||
|
var parent = part.Parents.First();
|
||||||
|
if (parent.Type == OCC_TYPE.wPART)
|
||||||
|
{
|
||||||
|
if( (parent.Name?.StartsWith("HK-KT") ?? false)
|
||||||
|
|| (parent.Name?.StartsWith("SGMX") ?? false))
|
||||||
|
{
|
||||||
|
canAdd = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(canAdd)
|
||||||
|
{
|
||||||
motorsData?.Add(motor);
|
motorsData?.Add(motor);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Motors = motorsData;
|
Motors = motorsData;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetMotorBrand(string motorName)
|
||||||
|
{
|
||||||
|
switch (motorName)
|
||||||
|
{
|
||||||
|
case string name when name.StartsWith("HK-KT"):
|
||||||
|
return Brands.SANLING_HK_KT;
|
||||||
|
case string name when name.StartsWith("SGMX"):
|
||||||
|
return Brands.ANCHUAN;
|
||||||
|
default:
|
||||||
|
return Brands.UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
private string UnStuffMotorName(string motorName)
|
private string UnStuffMotorName(string motorName)
|
||||||
{
|
{
|
||||||
if (motorName.Contains("&"))
|
if (motorName.Contains("&"))
|
||||||
|
@ -646,8 +692,8 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
Wires.ForEach(it =>
|
Wires.ForEach(it =>
|
||||||
{
|
{
|
||||||
it.ItemSeqNo = seq++;
|
it.ItemSeqNo = seq++;
|
||||||
MechanismName ??= "";
|
it.MechanicalName = MechanismName;
|
||||||
MechanismNo ??= "";
|
it.MechanicalNo = MechanismNo;
|
||||||
});
|
});
|
||||||
MotorExcelHelper.Instance.SaveLinesToExcel(targetPath, Wires);
|
MotorExcelHelper.Instance.SaveLinesToExcel(targetPath, Wires);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue