105040 更新版本信息并重构配置管理
在 `AssemblyInfo.cs` 中更新版本号至 `1.0.0.29` 和 `1.0.0.30`。 在 `Consts.cs` 中添加对 `Newtonsoft.Json` 的引用,重构常量为静态字段,并实现 `InitConfigs` 方法以支持从 JSON 配置文件读取路径。 在 `MotorExcelHelper.cs` 中更新数据文件路径引用,修改 `SaveLinesToExcel` 方法以接受新的参数。 在 `LayoutHelperViewModel.cs` 和 `LectotypeViewModel.cs` 中更新电机电缆获取逻辑和保存线材的方法签名。 在 `DesignPluginEntry.cs` 和 `PluginEntry.cs` 中调用 `Consts.InitConfigs()` 初始化配置。
This commit is contained in:
parent
9f2b30979a
commit
5bd68a7fba
|
@ -29,6 +29,6 @@ using System.Runtime.InteropServices;
|
||||||
// 生成号
|
// 生成号
|
||||||
// 修订号
|
// 修订号
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("1.0.0.28")]
|
[assembly: AssemblyVersion("1.0.0.29")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.28")]
|
[assembly: AssemblyFileVersion("1.0.0.30")]
|
||||||
[assembly: AssemblyInformationalVersion("1.0.0.28")]
|
[assembly: AssemblyInformationalVersion("1.0.0.30")]
|
|
@ -46,6 +46,6 @@ using System.Windows;
|
||||||
// 生成号
|
// 生成号
|
||||||
// 修订号
|
// 修订号
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("1.0.0.28")]
|
[assembly: AssemblyVersion("1.0.0.29")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.28")]
|
[assembly: AssemblyFileVersion("1.0.0.30")]
|
||||||
[assembly: AssemblyInformationalVersion("1.0.0.28")]
|
[assembly: AssemblyInformationalVersion("1.0.0.30")]
|
|
@ -1,19 +1,36 @@
|
||||||
using System.Text.RegularExpressions;
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
{
|
{
|
||||||
internal class Consts
|
public class Consts
|
||||||
{
|
{
|
||||||
public const string DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材资料检查";
|
private const string CONFIG_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材资料检查";
|
||||||
|
|
||||||
|
public static string DATA_FILE_PATH = @"\\192.168.1.160\plm系统文档\线材资料检查";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 线材端子号码管配对表(配CE端子).xlsm
|
/// 线材端子号码管配对表(配CE端子).xlsm
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string DATA_FILE_PATH_WIRE_TERMINAL = @"线材端子号码管配对表(配CE端子).xlsm";
|
public static string DATA_FILE_PATH_WIRE_TERMINAL = @"线材端子号码管配对表(配CE端子).xlsm";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 绝缘软套
|
/// 绝缘软套
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string DATA_FILE_PATH_INSULATION = @"绝缘软套规格.xlsx";
|
public static string DATA_FILE_PATH_INSULATION = @"绝缘软套规格.xlsx";
|
||||||
public const string TEMPLATE_FILE_NAME = @"下单模板.xlsx";
|
public static string TEMPLATE_FILE_NAME = @"下单模板.xlsx";
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
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\线材选型";//
|
||||||
|
#endif
|
||||||
|
public static string PLUGIN_DATA_FILE_NAME = "线材选型数据表.xlsx";
|
||||||
|
public static string PLUGIN_DATA_FILE_NAME_BOM = "BOM表.xlsx";
|
||||||
|
public static string PLUGIN_TEMPLATE_FILE_NAME = "下单定制线模板.xlsx";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 线径平方规格匹配
|
/// 线径平方规格匹配
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -22,7 +39,61 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
/// 变色套平方规格匹配
|
/// 变色套平方规格匹配
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly Regex dRegex = new("V-[\\d]+\\.?[\\d]*", RegexOptions.Compiled);
|
public static readonly Regex dRegex = new("V-[\\d]+\\.?[\\d]*", RegexOptions.Compiled);
|
||||||
|
/// <summary>
|
||||||
|
/// 括号内容匹配
|
||||||
|
/// </summary>
|
||||||
public static readonly Regex regexParenthesesContent = new(@"(?<=\()[^)]*(?=\))", RegexOptions.Compiled);
|
public static readonly Regex regexParenthesesContent = new(@"(?<=\()[^)]*(?=\))", RegexOptions.Compiled);
|
||||||
|
|
||||||
|
public static void InitConfigs()
|
||||||
|
{
|
||||||
|
var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(Path.Combine(CONFIG_FILE_PATH, "config.json")));
|
||||||
|
if(jsonObj != null)
|
||||||
|
{
|
||||||
|
if (jsonObj.ContainsKey("DATA_FILE_PATH"))
|
||||||
|
{
|
||||||
|
DATA_FILE_PATH = jsonObj["DATA_FILE_PATH"];
|
||||||
|
Debug.WriteLine(DATA_FILE_PATH);
|
||||||
|
}
|
||||||
|
if (jsonObj.ContainsKey("DATA_FILE_PATH_WIRE_TERMINAL"))
|
||||||
|
{
|
||||||
|
DATA_FILE_PATH_WIRE_TERMINAL = jsonObj["DATA_FILE_PATH_WIRE_TERMINAL"];
|
||||||
|
Debug.WriteLine(DATA_FILE_PATH_WIRE_TERMINAL);
|
||||||
|
}
|
||||||
|
if (jsonObj.ContainsKey("DATA_FILE_PATH_INSULATION"))
|
||||||
|
{
|
||||||
|
DATA_FILE_PATH_INSULATION = jsonObj["DATA_FILE_PATH_INSULATION"];
|
||||||
|
Debug.WriteLine(DATA_FILE_PATH_INSULATION);
|
||||||
|
}
|
||||||
|
if (jsonObj.ContainsKey("TEMPLATE_FILE_NAME"))
|
||||||
|
{
|
||||||
|
TEMPLATE_FILE_NAME = jsonObj["TEMPLATE_FILE_NAME"];
|
||||||
|
Debug.WriteLine(TEMPLATE_FILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插件
|
||||||
|
if (jsonObj.ContainsKey("PLUGIN_DATA_FILE_PATH"))
|
||||||
|
{
|
||||||
|
PLUGIN_DATA_FILE_PATH = jsonObj["PLUGIN_DATA_FILE_PATH"];
|
||||||
|
Debug.WriteLine(PLUGIN_DATA_FILE_PATH);
|
||||||
|
}
|
||||||
|
if (jsonObj.ContainsKey("PLUGIN_DATA_FILE_NAME"))
|
||||||
|
{
|
||||||
|
PLUGIN_DATA_FILE_NAME = jsonObj["PLUGIN_DATA_FILE_NAME"];
|
||||||
|
Debug.WriteLine(PLUGIN_DATA_FILE_NAME);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (jsonObj.ContainsKey("PLUGIN_DATA_FILE_NAME_BOM"))
|
||||||
|
{
|
||||||
|
PLUGIN_DATA_FILE_NAME_BOM = jsonObj["PLUGIN_DATA_FILE_NAME_BOM"];
|
||||||
|
Debug.WriteLine(PLUGIN_DATA_FILE_NAME_BOM);
|
||||||
|
}
|
||||||
|
if (jsonObj.ContainsKey("PLUGIN_TEMPLATE_FILE_NAME"))
|
||||||
|
{
|
||||||
|
PLUGIN_TEMPLATE_FILE_NAME = jsonObj["PLUGIN_TEMPLATE_FILE_NAME"];
|
||||||
|
Debug.WriteLine(PLUGIN_TEMPLATE_FILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,18 +13,9 @@ 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\线材选型";//
|
|
||||||
#endif
|
|
||||||
private const string DATA_FILE_NAME = "线材选型数据表.xlsx";
|
|
||||||
private const string DATA_FILE_NAME_BOM = "BOM表.xlsx";
|
|
||||||
private const string TEMPLATE_FILE_NAME = "下单定制线模板.xlsx";
|
|
||||||
public void ReadDataToStream()
|
public void ReadDataToStream()
|
||||||
{
|
{
|
||||||
var file = Path.Combine(DATA_FILE_PATH, DATA_FILE_NAME);
|
var file = Path.Combine(Consts.PLUGIN_DATA_FILE_PATH, Consts.PLUGIN_DATA_FILE_NAME);
|
||||||
if (File.Exists(file))
|
if (File.Exists(file))
|
||||||
{
|
{
|
||||||
var bytes = File.ReadAllBytes(file);
|
var bytes = File.ReadAllBytes(file);
|
||||||
|
@ -153,7 +144,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
public List<LineBomModel> GetBomList(string drawNo)
|
public List<LineBomModel> GetBomList(string drawNo)
|
||||||
{
|
{
|
||||||
//var filePath = "D:\\Desktop\\Data\\BOM表.xlsx";
|
//var filePath = "D:\\Desktop\\Data\\BOM表.xlsx";
|
||||||
var filePath = Path.Combine(DATA_FILE_PATH, DATA_FILE_NAME_BOM);
|
var filePath = Path.Combine(Consts.PLUGIN_DATA_FILE_PATH, Consts.PLUGIN_DATA_FILE_NAME_BOM);
|
||||||
var data = MiniExcel.Query<LineBomModel>(filePath).Where(it => it.DrawingNo == drawNo).ToList();
|
var data = MiniExcel.Query<LineBomModel>(filePath).Where(it => it.DrawingNo == drawNo).ToList();
|
||||||
//MiniExcel.Query<>()
|
//MiniExcel.Query<>()
|
||||||
return data;
|
return data;
|
||||||
|
@ -165,11 +156,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
bomList
|
bomList
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
public bool SaveLinesToExcel(string targetPath, List<LectotypeLineModel> lines)
|
public bool SaveLinesToExcel(string targetPath,string mechanismNo, List<LectotypeLineModel> lines)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var templatePath = Path.Combine(DATA_FILE_PATH, TEMPLATE_FILE_NAME);
|
var templatePath = Path.Combine(Consts.PLUGIN_DATA_FILE_PATH, Consts.PLUGIN_TEMPLATE_FILE_NAME);
|
||||||
var data = lines.Select(line => new
|
var data = lines.Select(line => new
|
||||||
{
|
{
|
||||||
line.ItemSeqNo,
|
line.ItemSeqNo,
|
||||||
|
@ -182,11 +173,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
line.DrawingNo,
|
line.DrawingNo,
|
||||||
EncoderLineLength = line.EncoderLineLength == 0 ? "" : line.EncoderLineLength.ToString(),
|
EncoderLineLength = line.EncoderLineLength == 0 ? "" : line.EncoderLineLength.ToString(),
|
||||||
PowerLineLength = line.PowerLineLength == 0 ? "" : line.PowerLineLength.ToString(),
|
PowerLineLength = line.PowerLineLength == 0 ? "" : line.PowerLineLength.ToString(),
|
||||||
OrderDate = DateTime.Now.ToString("yyyy/MM/dd"),
|
OrderDate = DateTime.Now.ToString("yyyy/M/d"),
|
||||||
DeliveryDate = DateTime.Now.AddDays(7).ToString("yyyy/MM/dd"), // 交期默认一周
|
DeliveryDate = DateTime.Now.AddDays(7).ToString("yyyy/M/d"), // 交期默认一周
|
||||||
}).ToList();
|
}).ToList();
|
||||||
MiniExcel.SaveAsByTemplate(
|
MiniExcel.SaveAsByTemplate(
|
||||||
$"{targetPath}\\线材下单_{DateTime.Now:yyyy_MM_dd}.xlsx",
|
$"{targetPath}\\{mechanismNo}线材下单_{DateTime.Now:yyyy_MM_dd}_{DateTime.Now.Ticks}.xlsx",
|
||||||
templatePath,
|
templatePath,
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
|
@ -207,7 +198,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
|
||||||
|
|
||||||
public void CloseStream()
|
public void CloseStream()
|
||||||
{
|
{
|
||||||
dataFileStream.Close();
|
dataFileStream?.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
{
|
{
|
||||||
SelectMotorModel = part.Parents?.First()?.Name ?? "";
|
SelectMotorModel = part.Parents?.First()?.Name ?? "";
|
||||||
Debug.WriteLine($"Select part parent -> {part.Parents?.First()?.Name} / {part.Parents?.First()?.ID}");
|
Debug.WriteLine($"Select part parent -> {part.Parents?.First()?.Name} / {part.Parents?.First()?.ID}");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (item != null)
|
else if (item != null)
|
||||||
|
@ -206,7 +205,6 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
{
|
{
|
||||||
if (_motors != null && _motors.Any())
|
if (_motors != null && _motors.Any())
|
||||||
{
|
{
|
||||||
|
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
var service = new MotorLectotypeService();
|
var service = new MotorLectotypeService();
|
||||||
|
|
|
@ -179,6 +179,7 @@ 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 = GetDocName(designer);
|
DocName = GetDocName(designer);
|
||||||
|
@ -786,7 +787,15 @@ public class LectotypeViewModel(string docId) : INotifyPropertyChanged
|
||||||
it.MechanicalName = MechanismName;
|
it.MechanicalName = MechanismName;
|
||||||
it.MechanicalNo = MechanismNo;
|
it.MechanicalNo = MechanismNo;
|
||||||
});
|
});
|
||||||
MotorExcelHelper.Instance.SaveLinesToExcel(targetPath, Wires);
|
try
|
||||||
|
{
|
||||||
|
MotorExcelHelper.Instance.SaveLinesToExcel(targetPath, MechanismNo, Wires);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FlexMessageBox.Error(ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void AddNotSavedLectotype(Dictionary<string, string> value)
|
public void AddNotSavedLectotype(Dictionary<string, string> value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -458,7 +458,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// 获取变色管颜色
|
||||||
var discolorationDesc = Consts.regexParenthesesContent.Match(item.DiscolorationDesc).Value;
|
var discolorationDesc = Consts.regexParenthesesContent.Match(item.DiscolorationDesc).Value;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(discolorationDesc))
|
if (string.IsNullOrEmpty(discolorationDesc))
|
||||||
|
|
|
@ -87,6 +87,7 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
{
|
{
|
||||||
AppDomainDllLoader.SetLaoder();
|
AppDomainDllLoader.SetLaoder();
|
||||||
ApplicationExt.InitApplication();
|
ApplicationExt.InitApplication();
|
||||||
|
Consts.InitConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,7 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
//throw new NotImplementedException();
|
//throw new NotImplementedException();
|
||||||
AppDomainDllLoader.SetLaoder();
|
AppDomainDllLoader.SetLaoder();
|
||||||
ApplicationExt.InitApplication();
|
ApplicationExt.InitApplication();
|
||||||
|
Consts.InitConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Terminate()
|
public void Terminate()
|
||||||
|
|
|
@ -28,6 +28,6 @@ using System.Runtime.InteropServices;
|
||||||
// 生成号
|
// 生成号
|
||||||
// 修订号
|
// 修订号
|
||||||
//
|
//
|
||||||
[assembly: AssemblyVersion("1.0.0.28")]
|
[assembly: AssemblyVersion("1.0.0.29")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.28")]
|
[assembly: AssemblyFileVersion("1.0.0.30")]
|
||||||
[assembly: AssemblyInformationalVersion("1.0.0.28")]
|
[assembly: AssemblyInformationalVersion("1.0.0.30")]
|
|
@ -82,6 +82,7 @@ namespace Sinvo.EplanHpD.Plugin
|
||||||
{
|
{
|
||||||
AppDomainDllLoader.SetLaoder();
|
AppDomainDllLoader.SetLaoder();
|
||||||
ApplicationExt.InitApplication();
|
ApplicationExt.InitApplication();
|
||||||
|
Consts.InitConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Terminate()
|
public void Terminate()
|
||||||
|
|
Loading…
Reference in New Issue