105040 Update 测试方式调整

This commit is contained in:
lihanbo 2025-03-28 16:52:27 +08:00
parent be5a470e90
commit d9845c16f0
4 changed files with 104 additions and 12 deletions

View File

@ -59,7 +59,11 @@ namespace Sinvo.EplanHpD.Plugin.Service
// return "";
// }
//}
/// <summary>
/// 查询选型数据 直接转为ViewModel
/// </summary>
/// <param name="motorUniqueFlag"></param>
/// <returns></returns>
public CableLectotypeViewModel GetMotorLectotypeData(string motorUniqueFlag)
{
// 查询 Motor 数据
@ -136,7 +140,11 @@ namespace Sinvo.EplanHpD.Plugin.Service
return viewModel;
}
// 获取子线数据
/// <summary>
/// 获取子线数据
/// </summary>
/// <param name="parentLineId"></param>
/// <returns></returns>
private List<LectotypeLineModel> GetSubLines(string parentLineId)
{
var subLines = DBHelper.DB.Queryable<LectotypeLine>()
@ -160,7 +168,12 @@ namespace Sinvo.EplanHpD.Plugin.Service
// .ExecuteCommand();
// return changeCount > 0;
//}
/// <summary>
/// 保存电机选型的数据
/// </summary>
/// <param name="motorUniqueFlag"></param>
/// <param name="data"></param>
/// <returns></returns>
public bool SaveMotorLectotypeData(string motorUniqueFlag, CableLectotypeViewModel data)
{
var db = DBHelper.DB;
@ -276,11 +289,16 @@ namespace Sinvo.EplanHpD.Plugin.Service
return false;
}
}
/// <summary>
/// 获取线总段数
/// </summary>
/// <param name="motorUniqueFlag"></param>
/// <param name="cableType"></param>
/// <returns></returns>
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))
.Where(mt => mt.MotorUniqueFlag == motorUniqueFlag && (mt.CableTypePrimary == cableType || mt.CableTypeSecond == cableType || mt.CableTypeThree == cableType))
.First();
// 除了编码器线,其他都取动力线
if(line == null)
@ -296,9 +314,12 @@ namespace Sinvo.EplanHpD.Plugin.Service
return line.PowerLineParagraph;
}
}
/// <summary>
/// 将一根线设置为已布线
/// </summary>
/// <param name="motorUniqueFlag"></param>
/// <param name="lineId"></param>
/// <returns></returns>
public int SetLineDone(string motorUniqueFlag,string lineId)
{
var db = DBHelper.DB;
@ -321,5 +342,50 @@ namespace Sinvo.EplanHpD.Plugin.Service
return 0;
}
}
public CableLectotype GetCableLectotypeData(string motorUniqueFlag)
{
// 查询关联的 CableLectotype 数据
var cableLectotype = DBHelper.DB.Queryable<CableLectotype>()
.Where(cl => cl.MotorUniqueFlag == motorUniqueFlag)
.First();
return cableLectotype;
}
public List<LectotypeLine> GetLectotypeLines(string cableLectotypeId)
{
// 查询关联的 LectotypeLine 数据
var lectotypeLines = DBHelper.DB.Queryable<LectotypeLine>()
.Where(ll => ll.CableLectotypeId == cableLectotypeId)
//.OrderBy(ll => ll.SeqNo)
.ToList();
return lectotypeLines;
}
public bool ClearMotorData(string motorUniqueFlag)
{
var cleared = false;
var db = DBHelper.DB;
try
{
db.BeginTran();
db.Deleteable<Motor>().Where(it => it.MotorUniqueFlag == motorUniqueFlag).ExecuteCommand();
db.Deleteable<CableLectotype>().Where(it => it.MotorUniqueFlag == motorUniqueFlag).ExecuteCommand();
db.Deleteable<LectotypeLine>().Where(it => it.MotorUniqueFlag == motorUniqueFlag).ExecuteCommand();
db.CommitTran();
cleared = true;
}
catch (Exception)
{
db.RollbackTran();
cleared = false;
throw;
}
return cleared;
}
}
}

View File

@ -22,7 +22,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
public static string TEMPLATE_FILE_NAME = @"下单模板.xlsx";
#if DEBUG
public static string PLUGIN_DATA_FILE_PATH = @"D:\Desktop\EPlan\线材选型";
public static string PLUGIN_DATA_FILE_PATH = @"D:\Desktop\EPLAN\汇川";
#else
public static string PLUGIN_DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材选型\插件";//@"D:\旧电脑文件\Desktop\EPlan\线材选型";//
@ -46,6 +46,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
public static void InitConfigs()
{
#if !DEBUG
var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(Path.Combine(CONFIG_FILE_PATH, "config.json")));
if(jsonObj != null)
{
@ -94,6 +95,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
}
}
#endif
}
}
}

View File

@ -253,7 +253,7 @@
<hc:SimpleStackPanel
Margin="0,150"
HorizontalAlignment="Center"
Orientation="Horizontal">
Orientation="Vertical">
<Button
Margin="10,0,0,0"
@ -262,6 +262,14 @@
Content="保存"
FontSize="14"
Style="{StaticResource ButtonSuccess}" />
<Button
Margin="10,10,0,0"
hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"
Click="ClearBtn_Click"
Content="清除选择的线"
FontSize="14"
Style="{StaticResource ButtonDanger}"
Visibility="Collapsed" />
</hc:SimpleStackPanel>
</hc:SimpleStackPanel>

View File

@ -1,6 +1,8 @@
using CommunityToolkit.Mvvm.Messaging;
using HandyControl.Controls;
using Sinvo.EplanHpD.Plugin.Service;
using Sinvo.EplanHpD.Plugin.WPFUI.Common;
using Sinvo.EplanHpD.Plugin.WPFUI.Extension;
using Sinvo.EplanHpD.Plugin.WPFUI.Models;
using Sinvo.EplanHpD.Plugin.WPFUI.ViewModel;
using System;
@ -71,7 +73,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
finally
{
LoadingContentMask.Visibility = Visibility.Collapsed;
}
}
}
private void CableratorBtn_Click(object sender, RoutedEventArgs e)
{
@ -152,6 +154,20 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.View
}
}
private void ClearBtn_Click(object sender, RoutedEventArgs e)
{
try
{
var service = new MotorLectotypeService();
service.ClearMotorData(_motor.GetUniqueFlag());
HandyControl.Controls.MessageBox.Show("清除完成");
}
catch (Exception ex)
{
HandyControl.Controls.MessageBox.Show(ex.ToString());
}
}
}
}