105040 Update 增加动力线与动力编码器线绝缘软套信息匹配
This commit is contained in:
parent
4212086da1
commit
6630e4c877
|
@ -1,13 +1,15 @@
|
|||
using EPLAN.Harness.AppCore.AttributeEvents;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||
{
|
||||
public class LectotypeLineModel : CheckedModel
|
||||
public class
|
||||
LectotypeLineModel : CheckedModel
|
||||
{
|
||||
|
||||
public string CableLectotypeId { get; set; }
|
||||
|
@ -416,5 +418,92 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
CableType = it.Name
|
||||
}).ToList();
|
||||
}
|
||||
public bool SubLineNeedInsulation
|
||||
{
|
||||
get
|
||||
{
|
||||
return SubLines != null && SubLines.Any(it => it.NeedInsulation);
|
||||
}
|
||||
}
|
||||
//private bool _needInsulation;
|
||||
public bool NeedInsulation
|
||||
{
|
||||
get
|
||||
{
|
||||
return (CableType == "动力线" || CableType == "动力刹车线") && (CableModel?.Contains("黄绿色") ?? false);
|
||||
}
|
||||
}
|
||||
|
||||
private string _insulationMCode;
|
||||
/// <summary>
|
||||
/// 绝缘软套物料编码
|
||||
/// </summary>
|
||||
public string InsulationMCode
|
||||
{
|
||||
get
|
||||
{
|
||||
return _insulationMCode;
|
||||
}
|
||||
set
|
||||
{
|
||||
_insulationMCode = value;
|
||||
OnPropertyChanged(nameof(InsulationMCode));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 绝缘软套物料编码
|
||||
/// </summary>
|
||||
public int? InsulationCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return NeedInsulation ? 1 : null;
|
||||
}
|
||||
set
|
||||
{
|
||||
OnPropertyChanged(nameof(InsulationCount));
|
||||
}
|
||||
}
|
||||
public string InsulationModel
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetInsulation();
|
||||
}
|
||||
set {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string GetInsulation()
|
||||
{
|
||||
if (string.IsNullOrEmpty(CableModel) || !NeedInsulation)
|
||||
return "";
|
||||
// 线径
|
||||
var matchGroups = Consts.InsulationRegex.Match(CableModel).Groups;
|
||||
var wireDiameter = matchGroups[1]?.Value;
|
||||
var ceFlag = matchGroups[2]?.Value ?? "";
|
||||
if (string.IsNullOrEmpty(ceFlag) && CableModel.Contains("-CE"))
|
||||
{
|
||||
ceFlag = "-CE";
|
||||
}
|
||||
if (double.Parse(wireDiameter) <= 1.5)
|
||||
{
|
||||
wireDiameter = "1.5";
|
||||
}
|
||||
var insulationModel = $"V-{wireDiameter}{ceFlag}(绿色)/定制";
|
||||
var insData = ExcelHelper.GetInsulationSoftSleeveTable(insulationModel).FirstOrDefault();
|
||||
if (insData != null)
|
||||
{
|
||||
InsulationMCode = insData.MaterialCode;
|
||||
OnPropertyChanged(nameof(NeedInsulation));
|
||||
return insData.Specification;
|
||||
}
|
||||
else
|
||||
{
|
||||
return " - ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
Grid.ColumnSpan="2"
|
||||
Panel.ZIndex="99"
|
||||
ContentTemplate="{StaticResource LoadingMask}"
|
||||
Visibility="Collapsed" />
|
||||
Visibility="Hidden" />
|
||||
<hc:Card
|
||||
x:Name="InfoCard"
|
||||
Grid.Row="0"
|
||||
|
@ -401,6 +401,30 @@
|
|||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Width="150">
|
||||
<GridViewColumnHeader Content="绝缘软套料号" Visibility="{Binding SubLineNeedInsulation, Converter={StaticResource Boolean2VisibilityConverter}}" />
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<hc:TextBox
|
||||
MinWidth="100"
|
||||
IsReadOnly="True"
|
||||
Text="{Binding InsulationMCode}"
|
||||
Visibility="{Binding NeedInsulation, Converter={StaticResource Boolean2VisibilityConverter}}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Width="420">
|
||||
<GridViewColumnHeader Content="绝缘软套型号" Visibility="{Binding SubLineNeedInsulation, Converter={StaticResource Boolean2VisibilityConverter}}" />
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<hc:TextBox
|
||||
MinWidth="400"
|
||||
IsReadOnly="True"
|
||||
Text="{Binding InsulationModel}"
|
||||
Visibility="{Binding NeedInsulation, Converter={StaticResource Boolean2VisibilityConverter}}" />
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<!--<GridViewColumn Header="是否布线完成">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
|
|
|
@ -8,6 +8,7 @@ using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
@ -58,7 +59,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
try
|
||||
{
|
||||
LoadingContentMask.Visibility = Visibility.Visible;
|
||||
var oldViewModel = LectotypeViewModelFactory.CreateOrGetAsync(_motor).Result;
|
||||
var oldViewModel = LectotypeViewModelFactory.CreateOrGetAsync(_motor);
|
||||
if (oldViewModel != null)
|
||||
{
|
||||
ViewModel.Apply(oldViewModel);
|
||||
|
@ -77,18 +78,30 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
}
|
||||
private void CableratorBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ViewModel.Cablerator();
|
||||
//var motor = Motor as MotorModel;
|
||||
if(Motor is CableLectotypeViewModel motor)
|
||||
LoadingContentMask.Visibility = Visibility.Visible;
|
||||
Dispatcher.Invoke(() => { });
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
// 发送消息,用户生成了数据
|
||||
WeakReferenceMessenger.Default.Send<LectotypeMessage,string>(new LectotypeMessage
|
||||
(new System.Collections.Generic.Dictionary<string, string>
|
||||
ViewModel.Cablerator();
|
||||
|
||||
}).ContinueWith(x =>
|
||||
{
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (Motor is CableLectotypeViewModel motor)
|
||||
{
|
||||
// 发送消息,用户生成了数据
|
||||
WeakReferenceMessenger.Default.Send<LectotypeMessage, string>(new LectotypeMessage
|
||||
(new System.Collections.Generic.Dictionary<string, string>
|
||||
{
|
||||
{motor.Motor.MotorModelStr,motor.Motor.AxisNo}
|
||||
}), "Lectotype"
|
||||
);
|
||||
}
|
||||
}), "Lectotype"
|
||||
);
|
||||
}
|
||||
LoadingContentMask.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void ListView_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
|
||||
|
@ -115,32 +128,43 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
private void SaveBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
LoadingContentMask.Visibility = Visibility.Visible;
|
||||
try
|
||||
bool saved = false;
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
if (ViewModel.SaveToDb())
|
||||
try
|
||||
{
|
||||
if (Motor is CableLectotypeViewModel motor)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new LectotypeMessage
|
||||
(new System.Collections.Generic.Dictionary<string, string>
|
||||
{
|
||||
{motor.Motor.MotorModelStr,motor.Motor.AxisNo}
|
||||
}), "LectotypeSaved"
|
||||
);
|
||||
}
|
||||
Growl.Success("保存成功", "CableLectotypeMessage");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Error("保存失败", "CableLectotypeMessage");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
LoadingContentMask.Visibility = Visibility.Collapsed;
|
||||
|
||||
saved = ViewModel.SaveToDb();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
}).ContinueWith(x =>
|
||||
{
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (saved)
|
||||
{
|
||||
if (Motor is CableLectotypeViewModel motor)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send(new LectotypeMessage
|
||||
(new System.Collections.Generic.Dictionary<string, string>
|
||||
{
|
||||
{motor.Motor.MotorModelStr,motor.Motor.AxisNo}
|
||||
}), "LectotypeSaved"
|
||||
);
|
||||
}
|
||||
Growl.Success("保存成功", "CableLectotypeMessage");
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Error("保存失败", "CableLectotypeMessage");
|
||||
}
|
||||
LoadingContentMask.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
});
|
||||
}
|
||||
private void CloseBtn_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
|
|
@ -496,6 +496,8 @@
|
|||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Binding="{Binding CableType}" Header="线材类型" />
|
||||
<DataGridTextColumn Binding="{Binding CableConnectionClass}" Header="线材连接方式" />
|
||||
<DataGridTextColumn Binding="{Binding InsulationModel}" Header="绝缘软套型号" />
|
||||
<DataGridTextColumn Binding="{Binding InsulationMCode}" Header="绝缘软套料号" />
|
||||
<DataGridTextColumn Binding="{Binding CheckedMsg}" Header="异常信息" />
|
||||
<DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
|
|
|
@ -88,6 +88,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
|||
{
|
||||
//DrawPDFHelper.CacheAllPdfToMemory();
|
||||
MotorExcelHelper.Instance.ReadDataToStream();
|
||||
ExcelHelper.GetInsulationSoftSleeveTable("");
|
||||
LoadData();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
|
|
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||
|
||||
|
@ -29,14 +30,13 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
/// </summary>
|
||||
public void Cablerator()
|
||||
{
|
||||
|
||||
SelectedLines?.Clear();
|
||||
if (string.IsNullOrEmpty(Motor.MotorPower))
|
||||
{
|
||||
ShowWarning("电机功率不能为空!");
|
||||
return;
|
||||
}
|
||||
if(IsEnableParagraph)
|
||||
if (IsEnableParagraph)
|
||||
{
|
||||
if (EncoderLineParagraph == 0 || PowerLineParagraph == 0)
|
||||
{
|
||||
|
@ -67,7 +67,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
{
|
||||
AxisNo = AxisNo,
|
||||
CableConnectionClass = CableConnectionType == ConnectionType.FullParagraph ? "前段" : "直通",
|
||||
CableType = brandData.ComplexLine ? $"{CableTypePrimary}+{CableTypeSecond}" : CableTypePrimary,
|
||||
CableType = brandData.ComplexLine ? $"{CableTypePrimary}+{CableTypeSecond}" : CableTypePrimary,
|
||||
CableModelNo = CableModelStr,
|
||||
IsLectotype = true,
|
||||
CurrentLine = 1,
|
||||
|
@ -75,7 +75,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
};
|
||||
line.DrawingNo = line.GetCableDrawNo();
|
||||
line.SubLines = GetSubLines(line.DrawingNo);
|
||||
var startIndex = 1;
|
||||
var startIndex = 1;
|
||||
if (CableConnectionType == ConnectionType.FullParagraph)
|
||||
{
|
||||
LectotypeList.Clear();
|
||||
|
@ -95,11 +95,11 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
// 第一条线为所选线
|
||||
LectotypeList.Add(line);
|
||||
var secLine = new LectotypeLineModel
|
||||
{
|
||||
AxisNo = AxisNo,
|
||||
{
|
||||
AxisNo = AxisNo,
|
||||
CableConnectionClass = CableConnectionType == ConnectionType.FullParagraph ? "前段" : "直通",
|
||||
CableType = CableTypeSecond,
|
||||
CableModelNo = CableModelStr,
|
||||
CableType = CableTypeSecond,
|
||||
CableModelNo = CableModelStr,
|
||||
IsLectotype = true,
|
||||
CurrentLine = 1,
|
||||
Motor = Motor
|
||||
|
@ -169,11 +169,11 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
if (_passthroughCableCount >= 2 && !string.IsNullOrEmpty(CableTypeSecond))
|
||||
{
|
||||
var secLine = new LectotypeLineModel
|
||||
{
|
||||
AxisNo = AxisNo,
|
||||
{
|
||||
AxisNo = AxisNo,
|
||||
CableConnectionClass = "直通",
|
||||
CableType = CableTypeSecond,
|
||||
CableModelNo = CableModelStr,
|
||||
CableType = CableTypeSecond,
|
||||
CableModelNo = CableModelStr,
|
||||
IsLectotype = true,
|
||||
CurrentLine = 1,
|
||||
Motor = Motor
|
||||
|
@ -185,11 +185,11 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
if (_passthroughCableCount >= 3 && !string.IsNullOrEmpty(CableTypeThree))
|
||||
{
|
||||
var secLine = new LectotypeLineModel
|
||||
{
|
||||
AxisNo = AxisNo,
|
||||
{
|
||||
AxisNo = AxisNo,
|
||||
CableConnectionClass = "直通",
|
||||
CableType = CableTypeThree,
|
||||
CableModelNo = CableModelStr,
|
||||
CableType = CableTypeThree,
|
||||
CableModelNo = CableModelStr,
|
||||
IsLectotype = true,
|
||||
CurrentLine = 1,
|
||||
Motor = Motor
|
||||
|
@ -199,7 +199,7 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
LectotypeList.Add(secLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
var sortedLines = LectotypeList.OrderBy(it => it.CableType).ThenBy(it => it.CurrentLine).ToList();
|
||||
sortedLines.ForEach(it =>
|
||||
|
@ -462,6 +462,18 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
|||
OnPropertyChanged(nameof(IsEnableSecCableType));
|
||||
}
|
||||
}
|
||||
|
||||
private bool _loading;
|
||||
public bool Loading
|
||||
{
|
||||
get => _loading;
|
||||
set
|
||||
{
|
||||
_loading = value;
|
||||
OnPropertyChanged(nameof(Loading));
|
||||
}
|
||||
}
|
||||
|
||||
public bool SaveToDb()
|
||||
{
|
||||
//var service = new MotorLectotypeService();
|
||||
|
|
|
@ -169,9 +169,9 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
// 当前的工作区
|
||||
var designer = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
||||
// 获取项目名
|
||||
DocName = GetDocName(designer);
|
||||
DocName = LectotypeManager.GetDocName(designer);
|
||||
LectotypeManager.CURRENT_DOC_NAME = DocName;
|
||||
LectotypeManager.CURRENT_DOC_CREATE_TIME = new DateTimeOffset(designer.CreatedDateDateTime).ToUnixTimeMilliseconds().ToString();
|
||||
//LectotypeManager.CURRENT_DOC_CREATE_TIME = new DateTimeOffset(designer.CreatedDateDateTime).ToUnixTimeMilliseconds().ToString();
|
||||
|
||||
// 获取所有存在的
|
||||
var wires = designer.GetOrganizerOccurrences(designer.ID);
|
||||
|
@ -212,6 +212,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
return new LectotypeLineModel
|
||||
{
|
||||
Name= GetLectotypeName(occCable.LibraryName),
|
||||
CableModel = GetLectotypeName(occCable.LibraryName),
|
||||
LibraryName = occCable.LibraryName,
|
||||
CableName = occCable.Name,
|
||||
AxisNo = GetAxisNo(insulatorGraph.Imprint),
|
||||
|
@ -262,18 +263,18 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
|||
}
|
||||
}
|
||||
|
||||
public string GetDocName(FlexDesigner designer)
|
||||
{
|
||||
var docName = designer.Name;
|
||||
if (docName.Contains("+"))
|
||||
{
|
||||
return docName.Split('+').FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
return docName;
|
||||
}
|
||||
}
|
||||
//public string GetDocName(FlexDesigner designer)
|
||||
//{
|
||||
// var docName = designer.Name;
|
||||
// if (docName.Contains("+"))
|
||||
// {
|
||||
// return docName.Split('+').FirstOrDefault();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return docName;
|
||||
// }
|
||||
//}
|
||||
public List<LectotypeLineModel> StuffData(List<LectotypeLineModel> cables)
|
||||
{
|
||||
List<LectotypeLineModel> datas = [];
|
||||
|
|
Loading…
Reference in New Issue