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.Diagnostics;
|
||||
using System.Linq;
|
||||
|
@ -296,6 +297,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
return "";
|
||||
}
|
||||
string ModelNo = "MR-";
|
||||
if(Motor.Brand == Brands.ANCHUAN)
|
||||
{
|
||||
ModelNo = "JZSP-";
|
||||
}
|
||||
var cableFlag = GetCableModelFlag(Motor?.MotorPower, CableType, CableConnectionClass, IsFlexibility);
|
||||
if (string.IsNullOrWhiteSpace(cableFlag))
|
||||
{
|
||||
|
@ -335,20 +340,27 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
}
|
||||
if (!string.IsNullOrEmpty(AxisNo))
|
||||
{
|
||||
if(Motor.Brand == Brands.SANLING_HK_KT)
|
||||
{
|
||||
|
||||
ModelNo += "(";
|
||||
}
|
||||
if(Motor.Brand == Brands.ANCHUAN)
|
||||
{
|
||||
ModelNo += "-E(";
|
||||
}
|
||||
ModelNo += $"{AxisNo}";
|
||||
if (CableConnectionClass != "直通")
|
||||
//if (!(CableType is "编码器线+动力线" or "编码器线+动力刹车线"))
|
||||
ModelNo += $"-{CurrentLine} / {LineCount}";
|
||||
ModelNo += ")";
|
||||
|
||||
}
|
||||
//if (isUpdateDrawNo)
|
||||
{
|
||||
DrawingNo = GetCableDrawNo();
|
||||
}
|
||||
stopwatch.Stop();
|
||||
Debug.Print($"CableModelNo : {stopwatch.ElapsedMilliseconds}ms");
|
||||
Debug.Print($"CableModelNo {ModelNo} : {stopwatch.ElapsedMilliseconds}ms");
|
||||
return ModelNo;
|
||||
}
|
||||
set
|
||||
|
@ -363,8 +375,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
/// <returns></returns>
|
||||
public string GetCableDrawNo()
|
||||
{
|
||||
var data = MotorExcelHelper.Instance.GetCableDatas();
|
||||
var data = MotorExcelHelper.Instance.GetCableDatas(Motor.Brand);
|
||||
//var data = Core.CoreService.GetService<LectotypeService>().GetCableDatas();
|
||||
Trace.WriteLine($"{Motor.MotorPower} - {CableType} - {CableConnectionClass.Replace("全段", "前段")} - {(IsFlexibility ? "是" : "否")}");
|
||||
var cableData = data.FirstOrDefault(it =>
|
||||
it.MotorPower == Motor.MotorPower
|
||||
&& it.LineType == CableType
|
||||
|
@ -382,7 +395,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
}
|
||||
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 cableData = data?.FirstOrDefault(it =>
|
||||
it.MotorPower == motorPower
|
||||
|
|
|
@ -152,9 +152,11 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Common\CommonMessage.cs" />
|
||||
<Compile Include="Common\OpenDrawMessage.cs" />
|
||||
<Compile Include="Converter\ConnectionTypeConverter.cs" />
|
||||
<Compile Include="Converter\FlagEnumConverter.cs" />
|
||||
<Compile Include="Converter\NameTypeConverter.cs" />
|
||||
<Compile Include="Datas\Brands.cs" />
|
||||
<Compile Include="Enum\ConnectionType.cs" />
|
||||
<Compile Include="Enum\DataGridType.cs" />
|
||||
<Compile Include="Enum\ExportFileNameType.cs" />
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using MiniExcelLibs;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -25,7 +26,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
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)
|
||||
{
|
||||
|
@ -82,6 +83,37 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
)).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)
|
||||
{
|
||||
//var filePath = "D:\\Desktop\\Data\\BOM表.xlsx";
|
||||
|
@ -114,7 +146,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
line.DrawingNo,
|
||||
EncoderLineLength = line.EncoderLineLength == 0 ? "" : line.EncoderLineLength.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();
|
||||
MiniExcel.SaveAsByTemplate(
|
||||
$"{targetPath}\\线材下单_{DateTime.Now:yyyy_MM_dd}.xlsx",
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
Height="30" />
|
||||
</hc:SimpleStackPanel>
|
||||
</hc:SimpleStackPanel>-->
|
||||
<hc:SimpleStackPanel Margin="0,10,0,0" Orientation="Vertical">
|
||||
<hc:SimpleStackPanel Margin="0,10" Orientation="Vertical">
|
||||
<hc:SimpleStackPanel Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Width="100"
|
||||
|
@ -173,7 +173,10 @@
|
|||
Text="{Binding PowerLineParagraph, Mode=TwoWay}" />
|
||||
</hc:SimpleStackPanel>
|
||||
</hc:SimpleStackPanel>
|
||||
<hc:SimpleStackPanel Margin="0,10" Orientation="Horizontal">
|
||||
<hc:SimpleStackPanel
|
||||
Margin="0,10"
|
||||
Orientation="Horizontal"
|
||||
Visibility="Collapsed">
|
||||
<TextBlock
|
||||
Width="100"
|
||||
VerticalAlignment="Center"
|
||||
|
@ -276,7 +279,10 @@
|
|||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel MinWidth="90" Orientation="Horizontal">
|
||||
<Button Content="查看图纸" />
|
||||
<Button
|
||||
Click="ShowDrawBtn_Click"
|
||||
Content="查看图纸"
|
||||
Tag="{Binding DrawingNo}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
|
|
|
@ -133,5 +133,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
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"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding AxisNo}" />
|
||||
|
||||
<!-- 异常信息 -->
|
||||
<TextBlock
|
||||
Grid.Column="3"
|
||||
|
@ -271,6 +272,7 @@
|
|||
Grid.Column="4"
|
||||
VerticalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<!--<TextBlock Text="{Binding Brand}" />-->
|
||||
<!-- Click="SelectedLectotype_Click" -->
|
||||
<ToggleButton Content="展开线材选型" IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=Expander}}" />
|
||||
<Button
|
||||
|
@ -312,6 +314,8 @@
|
|||
</TabItem>
|
||||
<TabItem Header="整理后的数据">
|
||||
<!--
|
||||
RowDetailsVisibilityChanged="LettotypeListView_RowDetailsVisibilityChanged"
|
||||
RowDetailsVisibilityMode="{Binding DetailsShowMode}"
|
||||
-->
|
||||
<DataGrid
|
||||
x:Name="LettotypeListView"
|
||||
|
@ -321,8 +325,6 @@
|
|||
EnableRowVirtualization="False"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding Source={StaticResource LettotypeData}, IsAsync=True}"
|
||||
RowDetailsVisibilityChanged="LettotypeListView_RowDetailsVisibilityChanged"
|
||||
RowDetailsVisibilityMode="{Binding DetailsShowMode}"
|
||||
RowHeight="NaN"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
SelectedItem="{Binding SelectedItem}"
|
||||
|
@ -520,7 +522,7 @@
|
|||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
<DataGrid.RowDetailsTemplate>
|
||||
<!--<DataGrid.RowDetailsTemplate>
|
||||
<DataTemplate>
|
||||
<ListView
|
||||
Width="Auto"
|
||||
|
@ -550,7 +552,7 @@
|
|||
</ListView.View>
|
||||
</ListView>
|
||||
</DataTemplate>
|
||||
</DataGrid.RowDetailsTemplate>
|
||||
</DataGrid.RowDetailsTemplate>-->
|
||||
</DataGrid>
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
|
|
|
@ -49,6 +49,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -59,7 +67,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
//DrawPDFHelper.CacheAllPdfToMemory();
|
||||
MotorExcelHelper.Instance.ReadDataToStream();
|
||||
LoadData();
|
||||
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
|
@ -87,14 +94,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
LoadingMask.Visibility = Visibility.Visible;
|
||||
ViewModel.GetMotors().ContinueWith(x =>
|
||||
{
|
||||
//ViewModel.LoadData()
|
||||
// .ContinueWith(x =>
|
||||
// {
|
||||
ViewModel.LoadData()
|
||||
.ContinueWith(x =>
|
||||
{
|
||||
this.Dispatcher.BeginInvoke(delegate ()
|
||||
{
|
||||
LoadingMask.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
//});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
@ -174,6 +181,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
{
|
||||
//DrawPDFHelper.ClearCache();
|
||||
WeakReferenceMessenger.Default.Unregister<CommonMessage>("RowDetailsVisibility");
|
||||
WeakReferenceMessenger.Default.Unregister<CommonMessage>("OpenDraw");
|
||||
MotorExcelHelper.Instance.CloseStream();
|
||||
}
|
||||
|
||||
|
@ -305,6 +313,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
FlexMessageBox.Warning("存在错误项,请检查!");
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(ViewModel.MechanismName) || string.IsNullOrEmpty(ViewModel.MechanismNo))
|
||||
{
|
||||
FlexMessageBox.Warning("请先输入机构号与机构名称!");
|
||||
return;
|
||||
}
|
||||
|
||||
var exportedPath = new CommonOpenFileDialog
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using HandyControl.Controls;
|
||||
using Sinvo.EplanHpD.Plugin.Service;
|
||||
using Sinvo.EplanHpD.Plugin.Service.Model;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Enum;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
|
@ -19,7 +20,14 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
|||
public class CableLectotypeViewModel : INotifyPropertyChanged
|
||||
{
|
||||
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>
|
||||
|
@ -86,6 +94,52 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
//}
|
||||
// 第一条线为所选线
|
||||
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++)
|
||||
{
|
||||
seqNo++;
|
||||
|
@ -191,16 +245,25 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
{
|
||||
get
|
||||
{
|
||||
return [
|
||||
new ConfigItemModel{
|
||||
ItemName = "编码器线+动力线",
|
||||
ItemValue = "编码器线+动力线"
|
||||
},
|
||||
new ConfigItemModel{
|
||||
ItemName = "编码器线+动力刹车线",
|
||||
ItemValue = "编码器线+动力刹车线"
|
||||
},
|
||||
];
|
||||
var isCombo = false;
|
||||
if (Motor.Brand == Brands.SANLING)
|
||||
{
|
||||
isCombo = true;
|
||||
}
|
||||
|
||||
if(Motor.Brand == Brands.ANCHUAN)
|
||||
{
|
||||
isCombo = false;
|
||||
}
|
||||
var types = motorExcelHelper.GetCableTypes();
|
||||
if(isCombo)
|
||||
{
|
||||
return types.Where(it => it.ItemFlag == "是").ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return types.Where(it => it.ItemFlag == "否").ToList();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
|
|
|
@ -224,16 +224,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
}
|
||||
|
||||
{
|
||||
CurrentMotorIndex++;
|
||||
if (CurrentMotorIndex < _motorIds.Count)
|
||||
{
|
||||
|
||||
CurrentMotorSelectLineIndex = 0;
|
||||
GetMotorCables();
|
||||
}
|
||||
}
|
||||
|
||||
}).Wait();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ using EPLAN.Harness.Core.Utils;
|
|||
using EPLAN.Harness.ProjectCore;
|
||||
using EPLAN.Harness.ProjectCore.Occurrences;
|
||||
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
|
@ -176,16 +177,17 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
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 =>
|
||||
{
|
||||
Trace.WriteLine(string.IsNullOrEmpty(GetAxisNo((it.Children.First() as OccCablesInsulatorGraph).Imprint)));
|
||||
var occCable = (it as OccCableForked);
|
||||
var insulatorGraph = occCable.Children.First() as OccCablesInsulatorGraph;
|
||||
|
||||
var isEncoderLine = GetLineType(insulatorGraph.LibraryName,"编码器线");
|
||||
var isPowerLine = GetLineType(insulatorGraph.LibraryName,"动力线");
|
||||
var isBrakePowerLine = GetLineType(insulatorGraph.LibraryName,"动力刹车线");
|
||||
var isEncoderLine = GetLineType(occCable.LibraryName,"编码器线");
|
||||
var isPowerLine = GetLineType(occCable.LibraryName,"动力线");
|
||||
var isBrakePowerLine = GetLineType(occCable.LibraryName,"动力刹车线");
|
||||
|
||||
var encoderLength = 0d;
|
||||
var powerLength = 0d;
|
||||
|
@ -257,7 +259,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
it.LineCount = lineCount;
|
||||
if (it.CurrentLine == 1)
|
||||
{
|
||||
|
||||
it.CableConnectionClass = "前段";
|
||||
}
|
||||
else if (it.CurrentLine > 1 && it.CurrentLine < lineCount)
|
||||
|
@ -270,6 +271,10 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
|
||||
it.CableConnectionClass = "尾段";
|
||||
}
|
||||
else
|
||||
{
|
||||
it.CableConnectionClass = "未知类型";
|
||||
}
|
||||
if (string.IsNullOrEmpty(axisNo))
|
||||
{
|
||||
it.IsError = true;
|
||||
|
@ -312,6 +317,9 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
//2 合并同轴号的第一条数据
|
||||
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);
|
||||
if (existLine != null)
|
||||
{
|
||||
|
@ -368,6 +376,11 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
it.IsComplexLine = true;
|
||||
datas.Add(it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
datas.Add(it);
|
||||
}
|
||||
|
||||
});
|
||||
CheckLines(datas);
|
||||
|
@ -418,7 +431,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
try
|
||||
{
|
||||
var vals = imprint.Split('-');
|
||||
if (int.TryParse(vals[2], out int line))
|
||||
if (int.TryParse(vals[1], out int line))
|
||||
{
|
||||
return line;
|
||||
}
|
||||
|
@ -500,7 +513,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
doc.SelectSet.Clear();
|
||||
var oriOcc = SelfControler<BaseOccurrence>.FindInstance(part.ID);
|
||||
oriOcc.SetVisibility(true, null);
|
||||
doc.SelectSet.Add(oriOcc.Children.First());
|
||||
doc.SelectSet.Add(oriOcc);
|
||||
if (!string.IsNullOrEmpty(cableName) && cable != null)
|
||||
{
|
||||
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 parts = doc.GetOrganizerOccurrences(docId)
|
||||
.Where(occ => occ.Type == OCC_TYPE.wPART)
|
||||
.Where(occ => occ.Name?.StartsWith("HK-KT") ?? false)
|
||||
//.Where(occ => occ.Properties?.IsContarins("轴号") ?? false)
|
||||
.Where(occ =>
|
||||
(occ.Name?.StartsWith("HK-KT") ?? false)
|
||||
|| (occ.Name?.StartsWith("SGMX") ?? false)
|
||||
)
|
||||
.ToList();
|
||||
var motorPowerDatas = MotorExcelHelper.Instance.GetMotorPowers();
|
||||
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 motor = new MotorModel
|
||||
{
|
||||
MotorModelStr = UnStuffMotorName(part.Name),
|
||||
AxisNo = axisNo,
|
||||
Brand = GetMotorBrand(part.Name),
|
||||
OccPartId = part.ID,
|
||||
IsError = string.IsNullOrEmpty(axisNo)
|
||||
};
|
||||
var motorPowerData = motorPowerDatas.FirstOrDefault(it => it.ItemFlag == motor.MotorModelStr);
|
||||
|
||||
|
||||
if (motorPowerData != null)
|
||||
{
|
||||
motor.MotorPower = motorPowerData.ItemValue;
|
||||
|
@ -551,11 +568,40 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
{
|
||||
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);
|
||||
}
|
||||
});
|
||||
Motors = motorsData;
|
||||
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)
|
||||
{
|
||||
if (motorName.Contains("&"))
|
||||
|
@ -646,8 +692,8 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
Wires.ForEach(it =>
|
||||
{
|
||||
it.ItemSeqNo = seq++;
|
||||
MechanismName ??= "";
|
||||
MechanismNo ??= "";
|
||||
it.MechanicalName = MechanismName;
|
||||
it.MechanicalNo = MechanismNo;
|
||||
});
|
||||
MotorExcelHelper.Instance.SaveLinesToExcel(targetPath, Wires);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue