105040 Update 不再使用部件ID作为唯一标识
This commit is contained in:
parent
9d2d6ccb4d
commit
2870b5ea2a
|
@ -11,11 +11,10 @@ namespace Sinvo.EplanHpD.Plugin.Service.Model
|
|||
[SugarTable("T_MOTOR")]
|
||||
public class Motor
|
||||
{
|
||||
//public string MotorId { get; set; }
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
//public string MotorId { get; set; }
|
||||
public string OccPartId { get; set; }
|
||||
|
||||
[SugarColumn(IsNullable = true)]
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string MotorUniqueFlag { get; set; }
|
||||
|
||||
[SugarColumn(IsNullable = true)]
|
||||
|
|
|
@ -109,5 +109,18 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
|
|||
OnPropertyChanged(nameof(MotorUniqueFlag));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从其他对象复制属性
|
||||
/// </summary>
|
||||
public void CopyFrom(MotorModel motor)
|
||||
{
|
||||
this.MotorPower = motor.MotorPower;
|
||||
this.Brand = motor.Brand;
|
||||
this.MotorSerie = motor.MotorSerie;
|
||||
this.MotorModelStr = motor.MotorModelStr;
|
||||
this.AxisNo = motor.AxisNo;
|
||||
//this.OccPartId = motor.OccPartId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
|||
}
|
||||
}
|
||||
|
||||
public int SetLineDone(string motorId,string lineId)
|
||||
public int SetLineDone(string motorUniqueFlag,string lineId)
|
||||
{
|
||||
var db = DBHelper.DB;
|
||||
|
||||
|
@ -263,7 +263,7 @@ namespace Sinvo.EplanHpD.Plugin.Service
|
|||
db.BeginTran();
|
||||
|
||||
int changeCount = db.Updateable<LectotypeLine>()
|
||||
.Where(mt => mt.MotorId == motorId && mt.LectotypeLineId == lineId)
|
||||
.Where(mt => mt.MotorUniqueFlag == motorUniqueFlag && mt.LectotypeLineId == lineId)
|
||||
.SetColumns(it => it.IsChecked == true)
|
||||
.ExecuteCommand();
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
|||
if (data != null)
|
||||
{
|
||||
viewModel = data;
|
||||
// 更新电机ID数据,每次导入后可能会刷新这个ID,所以从抓取的数据中更新
|
||||
viewModel.Motor.OccPartId = motor.OccPartId;
|
||||
}
|
||||
|
||||
}).Wait();
|
||||
|
|
|
@ -11,6 +11,7 @@ using EPLAN.Harness.ProjectCore;
|
|||
using EPLAN.Harness.ProjectCore.Occurrences;
|
||||
using EPLAN.Harness.ProjectCore.Occurrences.Designer;
|
||||
using HandyControl.Controls;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.Utils;
|
||||
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
|
||||
using System;
|
||||
|
@ -37,10 +38,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
|
|||
{
|
||||
private FlexDesigner _currentFlexDesigner;
|
||||
private LayoutHelperViewModel viewModel;
|
||||
public LayoutHelperWindow(List<string> motorFlags)
|
||||
public LayoutHelperWindow(List<MotorModel> motors)
|
||||
{
|
||||
InitializeComponent();
|
||||
viewModel = new LayoutHelperViewModel(_currentFlexDesigner, motorFlags);
|
||||
viewModel = new LayoutHelperViewModel(_currentFlexDesigner, motors);
|
||||
|
||||
this.DataContext = viewModel;
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
public FlexDesigner _currentFlexDesigner;
|
||||
private string _selectMotorModel;
|
||||
private MotorLectotypeService service = new();
|
||||
private List<string> _motorFlags;
|
||||
private List<MotorModel> _motors;
|
||||
private MotorModel _motor;
|
||||
private CableLectotypeViewModel cableLectotypeViewModel;
|
||||
private HpdApi api;
|
||||
|
@ -47,10 +47,10 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
api = HpdApi.GetInstance();
|
||||
api.Init();
|
||||
}
|
||||
public LayoutHelperViewModel(FlexDesigner currentFlexDesigner, List<string> motorFlags)
|
||||
public LayoutHelperViewModel(FlexDesigner currentFlexDesigner, List<MotorModel> motorFlags)
|
||||
{
|
||||
_currentFlexDesigner = currentFlexDesigner;
|
||||
_motorFlags = motorFlags;
|
||||
_motors = motorFlags;
|
||||
|
||||
api = HpdApi.GetInstance();
|
||||
api.Init();
|
||||
|
@ -101,13 +101,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_motorFlags == null) return false;
|
||||
if (_motors == null) return false;
|
||||
if (SelectedLines == null) return false;
|
||||
if (CurrentMotorSelectLineIndex < SelectedLines.Count - 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (CurrentMotorIndex < _motorFlags.Count - 1)
|
||||
else if (CurrentMotorIndex < _motors.Count - 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -204,13 +204,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
|
||||
internal void GetMotorCables()
|
||||
{
|
||||
if (_motorFlags != null && _motorFlags.Any())
|
||||
if (_motors != null && _motors.Any())
|
||||
{
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
var service = new MotorLectotypeService();
|
||||
var data = service.GetMotorLectotypeData(_motorFlags[CurrentMotorIndex]);
|
||||
var data = service.GetMotorLectotypeData(_motors[CurrentMotorIndex]?.MotorUniqueFlag);
|
||||
if (data != null)
|
||||
{
|
||||
cableLectotypeViewModel = data;
|
||||
|
@ -219,13 +219,13 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
SelectedLines = cableLectotypeViewModel.SelectedLines.OrderBy(it => it.CableType).ThenBy(it => it.CurrentLine).ToList();
|
||||
SelectedLine = SelectedLines[CurrentMotorSelectLineIndex];
|
||||
ReSetSubLines();
|
||||
Motor = cableLectotypeViewModel.Motor;
|
||||
Motor = _motors[CurrentMotorIndex];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CurrentMotorIndex++;
|
||||
if (CurrentMotorIndex < _motorFlags.Count)
|
||||
if (CurrentMotorIndex < _motors.Count)
|
||||
{
|
||||
CurrentMotorSelectLineIndex = 0;
|
||||
GetMotorCables();
|
||||
|
@ -375,7 +375,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
internal void ToNextMotor()
|
||||
{
|
||||
if (CurrentMotorIndex < _motorFlags.Count)
|
||||
if (CurrentMotorIndex < _motors.Count)
|
||||
{
|
||||
CurrentMotorIndex++;
|
||||
CurrentMotorSelectLineIndex = 0;
|
||||
|
@ -388,9 +388,9 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
|||
}
|
||||
internal void SetSubLineAndSave(string lectotypeLineId)
|
||||
{
|
||||
var motorId = Motor.OccPartId;
|
||||
var motorUniqueFlag = Motor.MotorUniqueFlag;
|
||||
var service = new MotorLectotypeService();
|
||||
service.SetLineDone(motorId, lectotypeLineId);
|
||||
service.SetLineDone(motorUniqueFlag, lectotypeLineId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue