105067 优化重复生成线材列表导致崩溃

This commit is contained in:
SINVO\yangshunli 2025-02-08 09:46:17 +08:00
parent ab5345b1b8
commit f0d4e614de
1 changed files with 21 additions and 13 deletions

View File

@ -261,7 +261,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
public string GetDocName(FlexDesigner designer) public string GetDocName(FlexDesigner designer)
{ {
var docName = designer.Name; var docName = designer.Name;
if(docName.Contains("+")) if (docName.Contains("+"))
{ {
return docName.Split('+').FirstOrDefault(); return docName.Split('+').FirstOrDefault();
} }
@ -345,7 +345,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
//2 合并同轴号的第一条数据 //2 合并同轴号的第一条数据
cables.Where(it => it.CurrentLine == 1).ForEach(it => cables.Where(it => it.CurrentLine == 1).ForEach(it =>
{ {
if(it.Motor?.Brand != Brands.ANCHUAN) if (it.Motor?.Brand != Brands.ANCHUAN)
{ {
var existLine = datas.FirstOrDefault(data => data.AxisNo == it.AxisNo && data.CurrentLine == 1); var existLine = datas.FirstOrDefault(data => data.AxisNo == it.AxisNo && data.CurrentLine == 1);
@ -597,19 +597,19 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
motor.SetError("未填写轴号信息!"); motor.SetError("未填写轴号信息!");
} }
bool canAdd = true; bool canAdd = true;
if(part.Parents != null && part.Parents.Any()) if (part.Parents != null && part.Parents.Any())
{ {
var parent = part.Parents.First(); var parent = part.Parents.First();
if (parent.Type == OCC_TYPE.wPART) if (parent.Type == OCC_TYPE.wPART)
{ {
if( (parent.Name?.StartsWith("HK-KT") ?? false) if ((parent.Name?.StartsWith("HK-KT") ?? false)
|| (parent.Name?.StartsWith("SGMX") ?? false)) || (parent.Name?.StartsWith("SGMX") ?? false))
{ {
canAdd = false; canAdd = false;
} }
} }
} }
if(canAdd) if (canAdd)
{ {
motorsData?.Add(motor); motorsData?.Add(motor);
} }
@ -725,9 +725,17 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
}); });
MotorExcelHelper.Instance.SaveLinesToExcel(targetPath, Wires); MotorExcelHelper.Instance.SaveLinesToExcel(targetPath, Wires);
} }
public void AddNotSavedLectotype(Dictionary<string,string> value) public void AddNotSavedLectotype(Dictionary<string, string> value)
{ {
value.ForEach(it => NotSavedLectotypeList.Add(it.Key, it.Value)); value.ForEach(it =>
{
if (NotSavedLectotypeList.Keys.Any((e) => string.Compare(e, it.Key) == 0) == false)
NotSavedLectotypeList.Add(it.Key, it.Value);
else NotSavedLectotypeList[it.Key]=it.Value;
}
);
} }
public void RemoveNotSavedLectotype(Dictionary<string, string> value) public void RemoveNotSavedLectotype(Dictionary<string, string> value)
{ {
@ -736,7 +744,7 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
internal async Task<bool> CheckSaved() internal async Task<bool> CheckSaved()
{ {
if(NotSavedLectotypeList != null && NotSavedLectotypeList.Any()) if (NotSavedLectotypeList != null && NotSavedLectotypeList.Any())
{ {
var isContinue = false; var isContinue = false;