105040 Update 不再使用Eplan内部的零件ID,改为使用当前文档的创建时间+轴号作为电机数据保存的唯一标识;
添加电机唯一标识及相关属性和方法 在多个文件中添加了 `MotorUniqueFlag` 属性,并将其设置为可为空。在 `MotorModel.cs` 文件中还添加了 `DocName` 属性。新增了 `GetUniqueFlag` 扩展方法,用于生成电机的唯一标识,并在相关文件中使用该方法。修改了界面显示和方法参数,将“电机ID”替换为“电机唯一标识”。在 `LectotypeManager.cs` 文件中添加了 `CURRENT_DOC_NAME` 和 `CURRENT_DOC_CREATE_TIME` 静态字段。
This commit is contained in:
parent
373e23ba08
commit
98df216fae
|
@ -16,6 +16,8 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model
|
||||||
|
|
||||||
[SugarColumn(IsNullable = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public string MotorId { get; set; }
|
public string MotorId { get; set; }
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string MotorUniqueFlag { get; set; }
|
||||||
|
|
||||||
[SugarColumn(IsNullable = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
public int CableConnectionType { get; set; }
|
public int CableConnectionType { get; set; }
|
||||||
|
|
|
@ -15,6 +15,8 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model
|
||||||
public string ParentLectotypeLineId { get; set; }
|
public string ParentLectotypeLineId { get; set; }
|
||||||
|
|
||||||
public string MotorId { get; set; }
|
public string MotorId { get; set; }
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string MotorUniqueFlag { get; set; }
|
||||||
|
|
||||||
public int SeqNo { get; set; }
|
public int SeqNo { get; set; }
|
||||||
[SugarColumn(IsNullable = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
|
|
|
@ -14,7 +14,12 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model
|
||||||
//public string MotorId { get; set; }
|
//public string MotorId { get; set; }
|
||||||
[SugarColumn(IsPrimaryKey = true)]
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
public string OccPartId { get; set; }
|
public string OccPartId { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string MotorUniqueFlag { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(IsNullable = true)]
|
||||||
|
public string DocName { get; set; }
|
||||||
public string MotorPower { get; set; }
|
public string MotorPower { get; set; }
|
||||||
|
|
||||||
[SugarColumn(IsNullable = true)]
|
[SugarColumn(IsNullable = true)]
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.Extension
|
||||||
|
{
|
||||||
|
public static class MotorModelUniqueFlagExt
|
||||||
|
{
|
||||||
|
public static string GetUniqueFlag(this MotorModel model)
|
||||||
|
{
|
||||||
|
// 调整唯一标识生成规则,项目名称+轴号
|
||||||
|
return $"{LectotypeManager.CURRENT_DOC_CREATE_TIME}_{model.AxisNo}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
|
||||||
|
|
||||||
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
||||||
{
|
{
|
||||||
public class MotorModel : CheckedModel
|
public class MotorModel : CheckedModel
|
||||||
{
|
{
|
||||||
|
@ -95,5 +97,17 @@
|
||||||
OnPropertyChanged(nameof(OccPartId));
|
OnPropertyChanged(nameof(OccPartId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 部件ID
|
||||||
|
/// </summary>
|
||||||
|
public string MotorUniqueFlag
|
||||||
|
{
|
||||||
|
get => this.GetUniqueFlag();
|
||||||
|
set
|
||||||
|
{
|
||||||
|
OnPropertyChanged(nameof(MotorUniqueFlag));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Sinvo.EplanHpD.Plugin.Service.Model;
|
using Sinvo.EplanHpD.Plugin.Service.Model;
|
||||||
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.ViewModel;
|
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -17,10 +18,10 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
DBHelper.DB.Insertable(motor).ExecuteCommand();
|
DBHelper.DB.Insertable(motor).ExecuteCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Motor GetMotorById(string occPartId)
|
public Motor GetMotorByFlag(string motorUniqueFlag)
|
||||||
{
|
{
|
||||||
var data = DBHelper.DB.Queryable<Motor>("mt")
|
var data = DBHelper.DB.Queryable<Motor>("mt")
|
||||||
.Where(mt => mt.OccPartId == occPartId)
|
.Where(mt => mt.MotorUniqueFlag == motorUniqueFlag)
|
||||||
.First();
|
.First();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -40,11 +41,11 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public CableLectotypeViewModel GetMotorLectotypeData(string motorOccId)
|
public CableLectotypeViewModel GetMotorLectotypeData(string motorUniqueFlag)
|
||||||
{
|
{
|
||||||
// 查询 Motor 数据
|
// 查询 Motor 数据
|
||||||
var motor = DBHelper.DB.Queryable<Motor>()
|
var motor = DBHelper.DB.Queryable<Motor>()
|
||||||
.Where(m => m.OccPartId == motorOccId)
|
.Where(m => m.MotorUniqueFlag == motorUniqueFlag)
|
||||||
.First();
|
.First();
|
||||||
|
|
||||||
if (motor == null)
|
if (motor == null)
|
||||||
|
@ -54,7 +55,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
|
|
||||||
// 查询关联的 CableLectotype 数据
|
// 查询关联的 CableLectotype 数据
|
||||||
var cableLectotype = DBHelper.DB.Queryable<CableLectotype>()
|
var cableLectotype = DBHelper.DB.Queryable<CableLectotype>()
|
||||||
.Where(cl => cl.MotorId == motor.OccPartId)
|
.Where(cl => cl.MotorUniqueFlag == motor.MotorUniqueFlag)
|
||||||
.First();
|
.First();
|
||||||
|
|
||||||
if (cableLectotype == null)
|
if (cableLectotype == null)
|
||||||
|
@ -78,7 +79,8 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
MotorSerie = motor.MotorSerie,
|
MotorSerie = motor.MotorSerie,
|
||||||
MotorModelStr = motor.MotorModelStr,
|
MotorModelStr = motor.MotorModelStr,
|
||||||
AxisNo = motor.AxisNo,
|
AxisNo = motor.AxisNo,
|
||||||
OccPartId = motor.OccPartId
|
MotorUniqueFlag = motor.MotorUniqueFlag,
|
||||||
|
//OccPartId = motor.OccPartId
|
||||||
},
|
},
|
||||||
CableConnectionType = (ConnectionType)Enum.Parse(typeof(ConnectionType), cableLectotype.CableConnectionType.ToString()),
|
CableConnectionType = (ConnectionType)Enum.Parse(typeof(ConnectionType), cableLectotype.CableConnectionType.ToString()),
|
||||||
AxisNo = cableLectotype.AxisNo,
|
AxisNo = cableLectotype.AxisNo,
|
||||||
|
@ -129,34 +131,35 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ClearSubLines(string motorOccId)
|
//public bool ClearSubLines(string motorUniqueFlag)
|
||||||
{
|
//{
|
||||||
var changeCount = DBHelper.DB.Deleteable<LectotypeLine>()
|
// var changeCount = DBHelper.DB.Deleteable<LectotypeLine>()
|
||||||
.Where(sl => sl.MotorId == motorOccId)
|
// .Where(sl => sl.MotorUniqueFlag == motorUniqueFlag)
|
||||||
.ExecuteCommand();
|
// .ExecuteCommand();
|
||||||
return changeCount > 0;
|
// return changeCount > 0;
|
||||||
}
|
//}
|
||||||
|
|
||||||
public bool SaveMotorLectotypeData(string motorOccId, CableLectotypeViewModel data)
|
public bool SaveMotorLectotypeData(string motorUniqueFlag, CableLectotypeViewModel data)
|
||||||
{
|
{
|
||||||
var db = DBHelper.DB;
|
var db = DBHelper.DB;
|
||||||
|
|
||||||
db.BeginTran();
|
db.BeginTran();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var motor = GetMotorById(data.Motor.OccPartId);//.FirstOrDefault(m => m.OccPartId == Motor.OccPartId);
|
var motor = GetMotorByFlag(motorUniqueFlag);//.FirstOrDefault(m => m.OccPartId == Motor.OccPartId);
|
||||||
if (motor == null)
|
if (motor == null)
|
||||||
{
|
{
|
||||||
motor = new Motor
|
motor = new Motor
|
||||||
{
|
{
|
||||||
//MotorId = Guid.NewGuid().ToString(),
|
//MotorId = Guid.NewGuid().ToString(),
|
||||||
//motorOccId
|
//OccPartId = Guid.NewGuid().ToString(),
|
||||||
MotorPower = data.Motor.MotorPower,
|
MotorPower = data.Motor.MotorPower,
|
||||||
Brand = data.Motor.Brand,
|
Brand = data.Motor.Brand,
|
||||||
MotorSerie = data.Motor.MotorSerie,
|
MotorSerie = data.Motor.MotorSerie,
|
||||||
MotorModelStr = data.Motor.MotorModelStr,
|
MotorModelStr = data.Motor.MotorModelStr,
|
||||||
AxisNo = data.Motor.AxisNo,
|
AxisNo = data.Motor.AxisNo,
|
||||||
OccPartId = data.Motor.OccPartId,
|
OccPartId = data.Motor.OccPartId,
|
||||||
|
MotorUniqueFlag = motorUniqueFlag,
|
||||||
CableLectotypeLines = []
|
CableLectotypeLines = []
|
||||||
};
|
};
|
||||||
AddMotor(motor);
|
AddMotor(motor);
|
||||||
|
@ -171,7 +174,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
{
|
{
|
||||||
//Motor = motor,
|
//Motor = motor,
|
||||||
CableLectotypeId = Guid.NewGuid().ToString(),
|
CableLectotypeId = Guid.NewGuid().ToString(),
|
||||||
MotorId = motor.OccPartId,
|
MotorUniqueFlag = motor.MotorUniqueFlag,
|
||||||
CableConnectionType = (int)data.CableConnectionType,
|
CableConnectionType = (int)data.CableConnectionType,
|
||||||
|
|
||||||
AxisNo = data.AxisNo,
|
AxisNo = data.AxisNo,
|
||||||
|
@ -190,6 +193,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
{
|
{
|
||||||
CableLectotypeId = cableLectotype.CableLectotypeId,
|
CableLectotypeId = cableLectotype.CableLectotypeId,
|
||||||
MotorId = motor.OccPartId,
|
MotorId = motor.OccPartId,
|
||||||
|
MotorUniqueFlag = motor.MotorUniqueFlag,
|
||||||
LectotypeLineId = Guid.NewGuid().ToString(),
|
LectotypeLineId = Guid.NewGuid().ToString(),
|
||||||
SeqNo = line.SeqNo,
|
SeqNo = line.SeqNo,
|
||||||
AxisNo = line.AxisNo,
|
AxisNo = line.AxisNo,
|
||||||
|
@ -217,6 +221,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
{
|
{
|
||||||
LectotypeLineId = Guid.NewGuid().ToString(),
|
LectotypeLineId = Guid.NewGuid().ToString(),
|
||||||
MotorId = motor.OccPartId,
|
MotorId = motor.OccPartId,
|
||||||
|
MotorUniqueFlag = motor.MotorUniqueFlag,
|
||||||
SeqNo = subLine.SeqNo,
|
SeqNo = subLine.SeqNo,
|
||||||
ParentLectotypeLineId = lectotypeLine.LectotypeLineId,
|
ParentLectotypeLineId = lectotypeLine.LectotypeLineId,
|
||||||
CableModel = subLine.CableModel,
|
CableModel = subLine.CableModel,
|
||||||
|
@ -230,10 +235,10 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
||||||
}
|
}
|
||||||
db.Storageable(motor).ExecuteCommand();
|
db.Storageable(motor).ExecuteCommand();
|
||||||
// 清空后再保存
|
// 清空后再保存
|
||||||
db.Deleteable<CableLectotype>().Where(it => it.MotorId == motor.OccPartId).ExecuteCommand();
|
db.Deleteable<CableLectotype>().Where(it => it.MotorUniqueFlag == motor.MotorUniqueFlag).ExecuteCommand();
|
||||||
db.Storageable(cableLectotype).ExecuteCommand();
|
db.Storageable(cableLectotype).ExecuteCommand();
|
||||||
|
|
||||||
db.Deleteable<LectotypeLine>().Where(it => it.MotorId == motor.OccPartId).ExecuteCommand();
|
db.Deleteable<LectotypeLine>().Where(it => it.MotorUniqueFlag == motor.MotorUniqueFlag).ExecuteCommand();
|
||||||
db.Storageable(motor.CableLectotypeLines.ToList()).ExecuteCommand();
|
db.Storageable(motor.CableLectotypeLines.ToList()).ExecuteCommand();
|
||||||
db.Storageable(motor.CableLectotypeLines.SelectMany(it => it.SubLines).ToList()).ExecuteCommand();
|
db.Storageable(motor.CableLectotypeLines.SelectMany(it => it.SubLines).ToList()).ExecuteCommand();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Sinvo.EplanHpD.Plugin.Service;
|
using Sinvo.EplanHpD.Plugin.Service;
|
||||||
|
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||||
using System;
|
using System;
|
||||||
|
@ -15,6 +16,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
public static class LectotypeManager
|
public static class LectotypeManager
|
||||||
{
|
{
|
||||||
public static string CURRENT_DOC_ID = "";
|
public static string CURRENT_DOC_ID = "";
|
||||||
|
public static string CURRENT_DOC_NAME = "";
|
||||||
|
public static string CURRENT_DOC_CREATE_TIME = "";
|
||||||
|
|
||||||
public class LectotypeViewModelFactory
|
public class LectotypeViewModelFactory
|
||||||
{
|
{
|
||||||
|
@ -22,9 +25,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
|
|
||||||
public static async Task<CableLectotypeViewModel> CreateOrGetAsync(MotorModel motor)
|
public static async Task<CableLectotypeViewModel> CreateOrGetAsync(MotorModel motor)
|
||||||
{
|
{
|
||||||
if (motor == null || string.IsNullOrEmpty(motor.OccPartId))
|
if (motor == null || string.IsNullOrEmpty(motor.AxisNo))
|
||||||
{
|
{
|
||||||
Debug.WriteLine($"CreateOrGet Create for null-> {motor?.MotorModelStr} => {motor?.OccPartId}");
|
Debug.WriteLine($"CreateOrGet Create for null-> {motor?.MotorModelStr} => {motor?.AxisNo}");
|
||||||
|
|
||||||
return new CableLectotypeViewModel(new MotorModel());
|
return new CableLectotypeViewModel(new MotorModel());
|
||||||
}
|
}
|
||||||
|
@ -33,7 +36,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
var service = new MotorLectotypeService();
|
var service = new MotorLectotypeService();
|
||||||
var data = service.GetMotorLectotypeData(motor.OccPartId);
|
var data = service.GetMotorLectotypeData(motor.GetUniqueFlag());
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
viewModel = data;
|
viewModel = data;
|
||||||
|
|
|
@ -36,7 +36,6 @@
|
||||||
<Grid Margin="0">
|
<Grid Margin="0">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
<RowDefinition Height="60" />
|
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="400" />
|
<ColumnDefinition Width="400" />
|
||||||
|
@ -67,12 +66,12 @@
|
||||||
Margin="0,10,0,0"
|
Margin="0,10,0,0"
|
||||||
DataContext="{Binding Motor}"
|
DataContext="{Binding Motor}"
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
<TextBlock VerticalAlignment="Center" Text="电机ID:" />
|
<TextBlock VerticalAlignment="Center" Text="电机唯一标识:" />
|
||||||
<hc:TextBox
|
<hc:TextBox
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
IsReadOnly="True"
|
IsReadOnly="True"
|
||||||
Style="{StaticResource TextBoxPlusBaseStyle}"
|
Style="{StaticResource TextBoxPlusBaseStyle}"
|
||||||
Text="{Binding OccPartId}" />
|
Text="{Binding MotorUniqueFlag}" />
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
<hc:SimpleStackPanel
|
<hc:SimpleStackPanel
|
||||||
Margin="0,10,0,0"
|
Margin="0,10,0,0"
|
||||||
|
@ -117,6 +116,7 @@
|
||||||
Height="30"
|
Height="30"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
hc:TitleElement.TitleWidth="120"
|
hc:TitleElement.TitleWidth="120"
|
||||||
|
IsReadOnly="True"
|
||||||
Text="{Binding AxisNo, Mode=TwoWay}" />
|
Text="{Binding AxisNo, Mode=TwoWay}" />
|
||||||
|
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
|
@ -225,7 +225,22 @@
|
||||||
Content="生成线材推荐列表"
|
Content="生成线材推荐列表"
|
||||||
Style="{StaticResource ButtonPrimary}" />
|
Style="{StaticResource ButtonPrimary}" />
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
|
<hc:SimpleStackPanel
|
||||||
|
Margin="0,150"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Margin="10,0,0,0"
|
||||||
|
hc:IconElement.Geometry="{StaticResource SaveGeometry}"
|
||||||
|
Click="SaveBtn_Click"
|
||||||
|
Content="保存"
|
||||||
|
FontSize="14"
|
||||||
|
Style="{StaticResource ButtonSuccess}" />
|
||||||
|
|
||||||
|
</hc:SimpleStackPanel>
|
||||||
</hc:SimpleStackPanel>
|
</hc:SimpleStackPanel>
|
||||||
|
|
||||||
</hc:Card>
|
</hc:Card>
|
||||||
<hc:Card
|
<hc:Card
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
|
@ -361,27 +376,6 @@
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
</hc:Card>
|
</hc:Card>
|
||||||
<hc:SimpleStackPanel
|
|
||||||
Grid.Row="1"
|
|
||||||
Grid.Column="0"
|
|
||||||
Grid.ColumnSpan="2"
|
|
||||||
HorizontalAlignment="Right"
|
|
||||||
Orientation="Horizontal">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Margin="10,0,0,0"
|
|
||||||
hc:IconElement.Geometry="{StaticResource SaveGeometry}"
|
|
||||||
Click="SaveBtn_Click"
|
|
||||||
Content="保存"
|
|
||||||
FontSize="14"
|
|
||||||
Style="{StaticResource ButtonSuccess}" />
|
|
||||||
<Button
|
|
||||||
Margin="10,0,10,0"
|
|
||||||
hc:IconElement.Geometry="{StaticResource CloseGeometry}"
|
|
||||||
Click="CloseBtn_Click"
|
|
||||||
Content="关闭"
|
|
||||||
FontSize="14"
|
|
||||||
Style="{StaticResource ButtonDanger}" />
|
|
||||||
</hc:SimpleStackPanel>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|
|
@ -37,10 +37,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
||||||
{
|
{
|
||||||
private FlexDesigner _currentFlexDesigner;
|
private FlexDesigner _currentFlexDesigner;
|
||||||
private LayoutHelperViewModel viewModel;
|
private LayoutHelperViewModel viewModel;
|
||||||
public LayoutHelperWindow(List<string> motorIds)
|
public LayoutHelperWindow(List<string> motorFlags)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
viewModel = new LayoutHelperViewModel(_currentFlexDesigner, motorIds);
|
viewModel = new LayoutHelperViewModel(_currentFlexDesigner, motorFlags);
|
||||||
|
|
||||||
this.DataContext = viewModel;
|
this.DataContext = viewModel;
|
||||||
|
|
||||||
|
|
|
@ -373,8 +373,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI
|
||||||
|
|
||||||
private void StartLayoutBtn_Click(object sender, RoutedEventArgs e)
|
private void StartLayoutBtn_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var motorIds = ViewModel.Motors.Where(motor => !motor.IsError).Select(motor => motor.OccPartId).ToList();
|
var motorFlags = ViewModel.Motors.Where(motor => !motor.IsError).Select(motor => motor.GetUniqueFlag()).ToList();
|
||||||
var window = new LayoutHelperWindow(motorIds);
|
var window = new LayoutHelperWindow(motorFlags);
|
||||||
//window.MotorIds = motorIds;
|
//window.MotorIds = motorIds;
|
||||||
ElementHost.EnableModelessKeyboardInterop(window);
|
ElementHost.EnableModelessKeyboardInterop(window);
|
||||||
var mainApp = BaseApp.ActiveApplication;
|
var mainApp = BaseApp.ActiveApplication;
|
||||||
|
|
|
@ -3,6 +3,7 @@ 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.Datas;
|
||||||
using Sinvo.EplanHpD.Plugin.WPFUI.Enum;
|
using Sinvo.EplanHpD.Plugin.WPFUI.Enum;
|
||||||
|
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;
|
||||||
using System;
|
using System;
|
||||||
|
@ -408,10 +409,11 @@ public class CableLectotypeViewModel : INotifyPropertyChanged
|
||||||
|
|
||||||
|
|
||||||
public bool SaveToDb()
|
public bool SaveToDb()
|
||||||
{
|
{
|
||||||
//var service = new MotorLectotypeService();
|
//var service = new MotorLectotypeService();
|
||||||
// 查找或添加 Motor
|
// 查找或添加 Motor
|
||||||
return motorService.SaveMotorLectotypeData(Motor.OccPartId, this);
|
var motorUniqueFlag = Motor.GetUniqueFlag();
|
||||||
|
return motorService.SaveMotorLectotypeData(motorUniqueFlag, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
public FlexDesigner _currentFlexDesigner;
|
public FlexDesigner _currentFlexDesigner;
|
||||||
private string _selectMotorModel;
|
private string _selectMotorModel;
|
||||||
private MotorLectotypeService service = new();
|
private MotorLectotypeService service = new();
|
||||||
private List<string> _motorIds;
|
private List<string> _motorFlags;
|
||||||
private MotorModel _motor;
|
private MotorModel _motor;
|
||||||
private CableLectotypeViewModel cableLectotypeViewModel;
|
private CableLectotypeViewModel cableLectotypeViewModel;
|
||||||
private HpdApi api;
|
private HpdApi api;
|
||||||
|
@ -47,10 +47,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
api = HpdApi.GetInstance();
|
api = HpdApi.GetInstance();
|
||||||
api.Init();
|
api.Init();
|
||||||
}
|
}
|
||||||
public LayoutHelperViewModel(FlexDesigner currentFlexDesigner, List<string> motorIds)
|
public LayoutHelperViewModel(FlexDesigner currentFlexDesigner, List<string> motorFlags)
|
||||||
{
|
{
|
||||||
_currentFlexDesigner = currentFlexDesigner;
|
_currentFlexDesigner = currentFlexDesigner;
|
||||||
_motorIds = motorIds;
|
_motorFlags = motorFlags;
|
||||||
|
|
||||||
api = HpdApi.GetInstance();
|
api = HpdApi.GetInstance();
|
||||||
api.Init();
|
api.Init();
|
||||||
|
@ -101,13 +101,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_motorIds == null) return false;
|
if (_motorFlags == null) return false;
|
||||||
if (SelectedLines == null) return false;
|
if (SelectedLines == null) return false;
|
||||||
if (CurrentMotorSelectLineIndex < SelectedLines.Count - 1)
|
if (CurrentMotorSelectLineIndex < SelectedLines.Count - 1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (CurrentMotorIndex < _motorIds.Count - 1)
|
else if (CurrentMotorIndex < _motorFlags.Count - 1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -204,13 +204,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
|
|
||||||
internal void GetMotorCables()
|
internal void GetMotorCables()
|
||||||
{
|
{
|
||||||
if (_motorIds != null && _motorIds.Any())
|
if (_motorFlags != null && _motorFlags.Any())
|
||||||
{
|
{
|
||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
var service = new MotorLectotypeService();
|
var service = new MotorLectotypeService();
|
||||||
var data = service.GetMotorLectotypeData(_motorIds[CurrentMotorIndex]);
|
var data = service.GetMotorLectotypeData(_motorFlags[CurrentMotorIndex]);
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
cableLectotypeViewModel = data;
|
cableLectotypeViewModel = data;
|
||||||
|
@ -225,7 +225,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentMotorIndex++;
|
CurrentMotorIndex++;
|
||||||
if (CurrentMotorIndex < _motorIds.Count)
|
if (CurrentMotorIndex < _motorFlags.Count)
|
||||||
{
|
{
|
||||||
CurrentMotorSelectLineIndex = 0;
|
CurrentMotorSelectLineIndex = 0;
|
||||||
GetMotorCables();
|
GetMotorCables();
|
||||||
|
@ -375,7 +375,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
}
|
}
|
||||||
internal void ToNextMotor()
|
internal void ToNextMotor()
|
||||||
{
|
{
|
||||||
if (CurrentMotorIndex < _motorIds.Count)
|
if (CurrentMotorIndex < _motorFlags.Count)
|
||||||
{
|
{
|
||||||
CurrentMotorIndex++;
|
CurrentMotorIndex++;
|
||||||
CurrentMotorSelectLineIndex = 0;
|
CurrentMotorSelectLineIndex = 0;
|
||||||
|
|
|
@ -125,7 +125,16 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private string _docName;
|
||||||
|
public string DocName
|
||||||
|
{
|
||||||
|
get => _docName;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_docName = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 机构号
|
/// 机构号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -166,6 +175,11 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
var designer = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
var designer = FlexProject.CurrentProject.GetDesigners().FirstOrDefault(designer => designer.ID == docId);
|
||||||
|
// 获取项目名
|
||||||
|
DocName = designer.Name.Split('+').FirstOrDefault();
|
||||||
|
LectotypeManager.CURRENT_DOC_NAME = DocName;
|
||||||
|
LectotypeManager.CURRENT_DOC_CREATE_TIME = new DateTimeOffset(designer.CreatedDateDateTime).ToUnixTimeMilliseconds().ToString();
|
||||||
|
|
||||||
// 获取所有存在的
|
// 获取所有存在的
|
||||||
var wires = designer.GetOrganizerOccurrences(designer.ID);
|
var wires = designer.GetOrganizerOccurrences(designer.ID);
|
||||||
//OriWires = wires.ToList();
|
//OriWires = wires.ToList();
|
||||||
|
|
Loading…
Reference in New Issue