105040 增加线材检查,段数按照已选择的电机选型数据获取
添加电机线段数获取及第三种线材类型支持 在 `MotorLectotypeService.cs` 文件中,添加了 `GetLineCount` 方法,用于获取电机对应的线段数。 在 `MotorExcelHelper.cs` 文件中,添加了 `#if DEBUG` 和 `#else` 预处理指令,以便在调试模式和发布模式下使用不同的文件路径。 在 `CableLectotypeUserControl.xaml` 文件中,添加了 `BooleanToVisibilityConverter` 资源,并在界面中添加了一个新的 `SimpleStackPanel`,用于显示第三种线材类型的选择。 在 `CableLectotypeViewModel.cs` 文件中,添加了 `CableTypeThree` 属性和 `IsShowThreeCableType` 属性,用于绑定第三种线材类型的选择和显示控制。 在 `LectotypeViewModel.cs` 文件中,添加了对 `MotorLectotypeService` 的引用,并在构造函数中实例化了 `MotorLectotypeService`。在处理电机和线材匹配时,增加了对电机信息的检查和线段数的获取逻辑。
This commit is contained in:
parent
c0f43b6ff7
commit
3d0606a619
|
@ -275,6 +275,26 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetLineCount(string motorUniqueFlag,string cableType)
|
||||||
|
{
|
||||||
|
var line = DBHelper.DB.Queryable<CableLectotype>("mt")
|
||||||
|
.Where(mt => mt.MotorUniqueFlag == motorUniqueFlag && (mt.CableTypePrimary == cableType || mt.CableTypeSecond == cableType))
|
||||||
|
.First();
|
||||||
|
// 除了编码器线,其他都取动力线
|
||||||
|
if(line == null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (cableType == "编码器线")
|
||||||
|
{
|
||||||
|
return line.EncoderLineParagraph;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return line.PowerLineParagraph;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int SetLineDone(string motorUniqueFlag,string lineId)
|
public int SetLineDone(string motorUniqueFlag,string lineId)
|
||||||
{
|
{
|
||||||
var db = DBHelper.DB;
|
var db = DBHelper.DB;
|
||||||
|
|
|
@ -13,7 +13,12 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
public static MotorExcelHelper Instance = new();
|
public static MotorExcelHelper Instance = new();
|
||||||
|
|
||||||
private Stream dataFileStream;
|
private Stream dataFileStream;
|
||||||
|
#if DEBUG
|
||||||
|
public const string DATA_FILE_PATH = @"D:\旧电脑文件\Desktop\EPlan\线材选型";
|
||||||
|
#else
|
||||||
|
|
||||||
public const string DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型\插件";//@"D:\旧电脑文件\Desktop\EPlan\线材选型";//
|
public const string DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型\插件";//@"D:\旧电脑文件\Desktop\EPlan\线材选型";//
|
||||||
|
#endif
|
||||||
private const string DATA_FILE_NAME = "线材选型数据表.xlsx";
|
private const string DATA_FILE_NAME = "线材选型数据表.xlsx";
|
||||||
private const string DATA_FILE_NAME_BOM = "BOM表.xlsx";
|
private const string DATA_FILE_NAME_BOM = "BOM表.xlsx";
|
||||||
private const string TEMPLATE_FILE_NAME = "下单定制线模板.xlsx";
|
private const string TEMPLATE_FILE_NAME = "下单定制线模板.xlsx";
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
<ResourceDictionary Source="pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/Sinvo.EplanHpD.Plugin.WPFUI;component/Themes/Theme.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
<converter:ConnectionTypeConverter x:Key="ConnectionTypeConverter" />
|
<converter:ConnectionTypeConverter x:Key="ConnectionTypeConverter" />
|
||||||
|
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||||
<DataTemplate x:Key="LoadingMask">
|
<DataTemplate x:Key="LoadingMask">
|
||||||
<Grid Background="#ccd7d7d7">
|
<Grid Background="#ccd7d7d7">
|
||||||
<!--<hc:WaveProgressBar HorizontalAlignment="Center" VerticalAlignment="Center" />-->
|
<!--<hc:WaveProgressBar HorizontalAlignment="Center" VerticalAlignment="Center" />-->
|
||||||
|
@ -192,6 +193,29 @@
|
||||||
IsReadOnly="False"
|
IsReadOnly="False"
|
||||||
Text="{Binding PowerLineParagraph, Mode=TwoWay}" />
|
Text="{Binding PowerLineParagraph, Mode=TwoWay}" />
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
|
<hc:SimpleStackPanel Orientation="Horizontal" Visibility="{Binding IsShowThreeCableType, Mode=OneWay, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||||
|
<hc:SimpleStackPanel
|
||||||
|
Width="200"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<hc:ComboBox
|
||||||
|
Width="153"
|
||||||
|
hc:InfoElement.ShowClearButton="True"
|
||||||
|
DisplayMemberPath="ItemName"
|
||||||
|
IsEnabled="{Binding IsEnableSecCableType}"
|
||||||
|
ItemsSource="{Binding CableTypes}"
|
||||||
|
SelectedIndex="0"
|
||||||
|
SelectedValue="{Binding CableTypeThree}"
|
||||||
|
SelectedValuePath="ItemValue" />
|
||||||
|
<TextBlock VerticalAlignment="Center" Text="段数:" />
|
||||||
|
</hc:SimpleStackPanel>
|
||||||
|
<hc:TextBox
|
||||||
|
Width="163"
|
||||||
|
Height="30"
|
||||||
|
IsEnabled="{Binding IsEnableParagraph}"
|
||||||
|
IsReadOnly="False"
|
||||||
|
Text="{Binding PowerLineParagraph, Mode=TwoWay}" />
|
||||||
|
</hc:SimpleStackPanel>
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
<hc:SimpleStackPanel
|
<hc:SimpleStackPanel
|
||||||
Margin="0,10"
|
Margin="0,10"
|
||||||
|
@ -369,7 +393,6 @@
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</GridViewColumn.CellTemplate>
|
</GridViewColumn.CellTemplate>
|
||||||
</GridViewColumn>
|
</GridViewColumn>
|
||||||
|
|
||||||
<!--<GridViewColumn Header="是否布线完成">
|
<!--<GridViewColumn Header="是否布线完成">
|
||||||
<GridViewColumn.CellTemplate>
|
<GridViewColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
|
|
|
@ -401,6 +401,17 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
||||||
OnPropertyChanged(nameof(CableTypeSecond));
|
OnPropertyChanged(nameof(CableTypeSecond));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string _cableTypeThree;
|
||||||
|
public string CableTypeThree
|
||||||
|
{
|
||||||
|
get { return _cableTypeThree; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_cableTypeThree = value;
|
||||||
|
OnPropertyChanged(nameof(CableTypeThree));
|
||||||
|
}
|
||||||
|
}
|
||||||
private int _encoderLineParagraph;
|
private int _encoderLineParagraph;
|
||||||
public int EncoderLineParagraph
|
public int EncoderLineParagraph
|
||||||
{
|
{
|
||||||
|
@ -453,7 +464,19 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
||||||
OnPropertyChanged(nameof(IsEnableSecCableType));
|
OnPropertyChanged(nameof(IsEnableSecCableType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示第三种线材类型
|
||||||
|
/// </summary>
|
||||||
|
private bool _isShowThreeCableType = false;
|
||||||
|
public bool IsShowThreeCableType
|
||||||
|
{
|
||||||
|
get => _isShowThreeCableType;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_isShowThreeCableType = value;
|
||||||
|
OnPropertyChanged(nameof(IsShowThreeCableType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool SaveToDb()
|
public bool SaveToDb()
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@ 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 HandyControl.Tools.Extension;
|
using HandyControl.Tools.Extension;
|
||||||
|
using Sinvo.EplanHpD.Plugin.Service;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Datas;
|
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;
|
||||||
|
@ -26,6 +27,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||||
|
|
||||||
public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
|
private MotorLectotypeService service = new();
|
||||||
|
|
||||||
|
|
||||||
private DataGridRowDetailsVisibilityMode _rowDetailsVisibility;//= DataGridRowDetailsVisibilityMode.Visible;
|
private DataGridRowDetailsVisibilityMode _rowDetailsVisibility;//= DataGridRowDetailsVisibilityMode.Visible;
|
||||||
public DataGridRowDetailsVisibilityMode RowDetailsVisibility
|
public DataGridRowDetailsVisibilityMode RowDetailsVisibility
|
||||||
|
@ -281,9 +284,33 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
var lineCount = 0;
|
var lineCount = 0;
|
||||||
var axisNo = it.AxisNo;
|
var axisNo = it.AxisNo;
|
||||||
var cabType = it.CableType;
|
var cabType = it.CableType;
|
||||||
|
if (Motors != null && Motors.Any())
|
||||||
|
{
|
||||||
|
var motor = Motors.FirstOrDefault(motor => motor.AxisNo == it.AxisNo);
|
||||||
|
if (motor != null)
|
||||||
|
{
|
||||||
|
it.Motor = motor;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it.IsError = true;
|
||||||
|
it.ErrorCount = 1;
|
||||||
|
it.CheckedMsg = "未匹配到电机";
|
||||||
|
}
|
||||||
|
}
|
||||||
if (axisNo != null && cabType != null)
|
if (axisNo != null && cabType != null)
|
||||||
{
|
{
|
||||||
lineCount = cables.Count(cable => cable.AxisNo == axisNo && cable.CableType == cabType);
|
//lineCount = cables.Count(cable => cable.AxisNo == axisNo && cable.CableType == cabType);
|
||||||
|
if(it.Motor != null)
|
||||||
|
{
|
||||||
|
// 有电机信息时,取电机型号对应的线数
|
||||||
|
lineCount = service.GetLineCount(it.Motor.MotorUniqueFlag, cabType);
|
||||||
|
}
|
||||||
|
if(lineCount == -1 || it.Motor == null)
|
||||||
|
{
|
||||||
|
// 无电机信息时,取轴号对应的线数
|
||||||
|
lineCount = cables.Count(cable => cable.AxisNo == axisNo && cable.CableType == cabType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
it.LineCount = lineCount;
|
it.LineCount = lineCount;
|
||||||
it.CableConnectionClass = "";
|
it.CableConnectionClass = "";
|
||||||
|
@ -308,7 +335,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
}
|
}
|
||||||
else if (it.CurrentLine == lineCount && lineCount > 1)
|
else if (it.CurrentLine == lineCount && lineCount > 1)
|
||||||
{
|
{
|
||||||
|
|
||||||
it.CableConnectionClass = "尾段";
|
it.CableConnectionClass = "尾段";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -316,7 +342,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
it.CableConnectionClass = "直通";
|
it.CableConnectionClass = "直通";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(axisNo))
|
if (string.IsNullOrEmpty(axisNo))
|
||||||
{
|
{
|
||||||
it.IsError = true;
|
it.IsError = true;
|
||||||
|
@ -329,21 +354,6 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
it.IsError = true;
|
it.IsError = true;
|
||||||
it.CheckedMsg = "线段重复!";
|
it.CheckedMsg = "线段重复!";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Motors != null && Motors.Any())
|
|
||||||
{
|
|
||||||
var motor = Motors.FirstOrDefault(motor => motor.AxisNo == it.AxisNo);
|
|
||||||
if (motor != null)
|
|
||||||
{
|
|
||||||
it.Motor = motor;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
it.IsError = true;
|
|
||||||
it.ErrorCount = 1;
|
|
||||||
it.CheckedMsg = "未匹配到电机";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (it.Name.StartsWith("T"))
|
if (it.Name.StartsWith("T"))
|
||||||
{
|
{
|
||||||
it.IsFlexibility = true;
|
it.IsFlexibility = true;
|
||||||
|
@ -440,7 +450,13 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
if (line.CableType == "未知类型")
|
if (line.CableType == "未知类型")
|
||||||
{
|
{
|
||||||
line.SetError("线材类型不正确,请检查印记内容!");
|
line.SetError("线材类型不正确,请检查印记内容!");
|
||||||
|
}
|
||||||
|
if(line.LineCount >0)
|
||||||
|
{
|
||||||
|
if(lines.Where(it => it.AxisNo == line.AxisNo && it.CableType == line.CableType).Count() < line.LineCount)
|
||||||
|
{
|
||||||
|
line.SetError("缺少线段,请检查是否布线完成!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue