diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/MainWindow.xaml b/Sinvo.EplanHpD.Plugin.WPFUI/MainWindow.xaml
index 87a4814..d98c006 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/MainWindow.xaml
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/MainWindow.xaml
@@ -301,6 +301,14 @@
Binding="{Binding Quantity}"
Header="数量"
IsReadOnly="True" />
+
+
public string InsulationMaterialNo { get; set; }
+
+ ///
+ /// 下单日期
+ ///
+ public string OrderDate { get; set; }
}
}
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Models/StuffedDataModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Models/StuffedDataModel.cs
index ff105c2..dbf1e89 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Models/StuffedDataModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Models/StuffedDataModel.cs
@@ -45,6 +45,35 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
private string imprint;
+ private string numberTubeSpec;
+ private string numberTubeMaterialNo;
+ private string numberTubeContent;
+ ///
+ /// B号码管规格
+ ///
+ public string NumberTubeSpec
+ {
+ get => numberTubeSpec;
+ set => SetProperty(ref numberTubeSpec, value);
+ }
+
+ ///
+ /// B号码管物料编码
+ ///
+ public string NumberTubeMaterialNo
+ {
+ get => numberTubeMaterialNo;
+ set => SetProperty(ref numberTubeMaterialNo, value);
+ }
+
+ ///
+ /// B号码管内容
+ ///
+ public string NumberTubeContent
+ {
+ get => numberTubeContent;
+ set => SetProperty(ref numberTubeContent, value);
+ }
///
/// 导线名称
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs
index 46d79cf..6014e55 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/Utils/ExcelHelper.cs
@@ -66,11 +66,15 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
// .ToList();
//}
- public static string GetNumberTube(string numberTubeSpec)
+ public static dynamic GetNumberTube(string wireModel)
{
CheckAndGetCache();
- return _terminalMappingCache.Where(item => item.TubeModel == numberTubeSpec)
- .Select(item => item.TubeMaterialCode)
+ return _terminalMappingCache.Where(item => item.WireModelSpecification == wireModel)
+ .Select(item => new
+ {
+ item.TubeModel,
+ item.TubeMaterialCode,
+ })
.FirstOrDefault();
}
public static void SaveByTemplate(object data, string newFilePath)
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs
index d9d4054..1bbde1b 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.Check.cs
@@ -36,11 +36,21 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
{
CheckCeCompliance(item);
}
+ CheckNumberTube(item);
+
CheckInsulation(item);
CheckTerminals(item);
CheckDuplicateModel(item);
}
+ private void CheckNumberTube(StuffedDataModel item)
+ {
+ if (string.IsNullOrEmpty(item.NumberTubeSpec))
+ {
+ SetItemError(item, "未匹配到正确的号码管!\r\n");
+ }
+ }
+
private void CheckRequiredFields(StuffedDataModel item)
{
if (string.IsNullOrEmpty(item.RearTerminalMaterialCode))
@@ -92,7 +102,7 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
{
if (insMatch.Value != "RV1.5")
{
- SetItemError(item, "变色套大小与线径不匹配!");
+ SetItemError(item, "变色套(绝缘软套)大小与线径不匹配!");
}
}
else
@@ -100,18 +110,18 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
var insDiameter = double.Parse(insMatch.Value.Replace("V-", ""));
if (Math.Abs(insDiameter - itemWireDiameter) > 0)
{
- SetItemError(item, "变色套大小与线径不匹配!");
+ SetItemError(item, "变色套(绝缘软套)大小与线径不匹配!");
}
}
}
else
{
- SetItemError(item, "变色套未匹配到平方数!");
+ SetItemError(item, "变色套(绝缘软套)未匹配到大小!");
}
}
else
{
- SetItemError(item, "未匹配到线材平方数!");
+ SetItemError(item, "未匹配到线材大小!");
}
}
}
@@ -140,7 +150,23 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
{
if (StuffedData.Count(it => it != null && it.Model == item.Model) > 1)
{
- SetItemError(item, $"{item.Model} 该型号存在重复!\r\n");
+ if (string.IsNullOrEmpty(item.WireLength))
+ {
+ SetItemError(item, $"线长度获取异常!\r\n");
+ }
+ else
+ {
+ var newModel = $"RV-{item.WireColor}-1x{item.CrossSection}-{item.WireLength + 5}-16×N2-{item.WireNumber}";
+ if (StuffedData.Any(it => it.Model == newModel))
+ {
+ SetItemError(item, $"{item.Model} 该型号存在重复!\r\n");
+ }
+ else
+ {
+ item.WireLength += 5;
+ item.Model = newModel;
+ }
+ }
}
}
diff --git a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs
index 0efa194..946202e 100644
--- a/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs
+++ b/Sinvo.EplanHpD.Plugin.WPFUI/ViewModel/MainViewModel.cs
@@ -168,6 +168,7 @@ public partial class MainViewModel : INotifyPropertyChanged
{
FlagType = WireFlagType.Dual;
}
+
var reportDatas = new ConcurrentBag();
//foreach (var entry in data)
data.AsParallel().WithDegreeOfParallelism(8).ForAll(entry =>
@@ -177,11 +178,10 @@ public partial class MainViewModel : INotifyPropertyChanged
{
if (!entry.Properties.ContainsKey(column.ColumnID)) continue;
var value = entry.Properties[column.ColumnID].GetDisplayValue();
+
var property = typeof(ReportModel).GetProperty(column.ID);
- if (property != null)
- {
- property.SetValue(obj, value ?? "");
- }
+ property?.SetValue(obj, value ?? "");
+
}
reportDatas.Add(obj);
}
@@ -261,7 +261,12 @@ public partial class MainViewModel : INotifyPropertyChanged
//MID(输出报表!J2,1,FIND(" mm2",输出报表!J2)-1)
data.CrossSection = item.CoreDiameter.Replace(" mm2", "").Trim();
//=ROUND(MID(输出报表!H2,1,FIND(" mm",输出报表!H2)-1),0)+0
- data.WireLength = item.Length.Replace(" mm", "").Trim();
+ if (double.TryParse(item.Length.Replace(" mm", "").Trim(), out double wireLength))
+ data.WireLength = $"{Math.Round(wireLength, 0)}";
+ else
+ {
+ data.WireLength = string.Empty;
+ }
//data.WireNumber = item.Imprint;
data.Quantity = 1;
//"RV-"&A2&"-"&"1×"&J2&"-"&L2&"-"&"16×N2"&"-"&M2
@@ -281,6 +286,14 @@ public partial class MainViewModel : INotifyPropertyChanged
{
data.Insulation = new InsulationModel();
}
+ var numberTube = ExcelHelper.GetNumberTube(data.WireModel);
+ if (numberTube != null)
+ {
+
+ data.NumberTubeSpec = numberTube.TubeModel;
+ data.NumberTubeMaterialNo = numberTube.TubeMaterialCode;
+ }
+
//if (datas.Any(it => it.Model == data.Model))
@@ -352,43 +365,43 @@ public partial class MainViewModel : INotifyPropertyChanged
///
/// 获取号码管规格
///
- public string GetNumberTubeSpecification(string crossSection, string colorCode)
- {
- if (crossSection == "16")
- {
- if (colorCode == "YE") return "黄色热缩管φ12/定制";
- if (colorCode == "GN") return "绿色热缩管φ12/定制";
- if (colorCode == "RD") return "红色热缩管φ12/定制";
- if (colorCode == "BU") return "蓝色热缩管φ12/定制";
- if (colorCode == "GNYE") return "黄绿色热缩管φ12/定制";
- }
- else if (crossSection == "0.3" || crossSection == "0.5" || crossSection == "0.75" || crossSection == "1")
- {
- return "白色号码管φ2.5/定制";
- }
- else if (crossSection == "1.5")
- {
- return "白色号码管φ3/定制";
- }
- else if (crossSection == "2.5")
- {
- return "白色号码管φ4/定制";
- }
- else if (crossSection == "4")
- {
- return "白色号码管φ5/定制";
- }
- else if (crossSection == "6")
- {
- return "白色号码管φ6/定制";
- }
- else if (crossSection == "10")
- {
- return "白色号码管φ8/定制";
- }
+ //public string GetNumberTubeSpecification(string crossSection, string colorCode)
+ //{
+ // if (crossSection == "16")
+ // {
+ // if (colorCode == "YE") return "黄色热缩管φ12/定制";
+ // if (colorCode == "GN") return "绿色热缩管φ12/定制";
+ // if (colorCode == "RD") return "红色热缩管φ12/定制";
+ // if (colorCode == "BU") return "蓝色热缩管φ12/定制";
+ // if (colorCode == "GNYE") return "黄绿色热缩管φ12/定制";
+ // }
+ // else if (crossSection == "0.3" || crossSection == "0.5" || crossSection == "0.75" || crossSection == "1")
+ // {
+ // return "白色号码管φ2.5/定制";
+ // }
+ // else if (crossSection == "1.5")
+ // {
+ // return "白色号码管φ3/定制";
+ // }
+ // else if (crossSection == "2.5")
+ // {
+ // return "白色号码管φ4/定制";
+ // }
+ // else if (crossSection == "4")
+ // {
+ // return "白色号码管φ5/定制";
+ // }
+ // else if (crossSection == "6")
+ // {
+ // return "白色号码管φ6/定制";
+ // }
+ // else if (crossSection == "10")
+ // {
+ // return "白色号码管φ8/定制";
+ // }
- return string.Empty;
- }
+ // return string.Empty;
+ //}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
@@ -414,11 +427,12 @@ public partial class MainViewModel : INotifyPropertyChanged
ExportData = [];
int seqNo = 1;
var dataList = new List();
+ var nowDateStr = DateTime.Now.ToString("yyyy-MM-dd");
//foreach (var stuffedDataModel in StuffedData)
StuffedData.AsParallel().WithDegreeOfParallelism(1).ForAll(stuffedDataModel =>
{
- var numberTubeSpec = GetNumberTubeSpecification(stuffedDataModel.CrossSection, stuffedDataModel.WireColor);
+ //var numberTubeSpec = GetNumberTubeSpecification(stuffedDataModel.CrossSection, stuffedDataModel.WireColor);
var exportModel = new ExportModel
{
SeqNo = seqNo.ToString(),
@@ -429,8 +443,8 @@ public partial class MainViewModel : INotifyPropertyChanged
WireOrTubeSpec = stuffedDataModel.WireModel,
WireOrTubeMaterialNo = stuffedDataModel.WireCode,
WireOrTubeLength = Math.Round(double.Parse(stuffedDataModel.WireLength), 0),
- NumberTubeSpec = numberTubeSpec,
- NumberTubeMaterialNo = ExcelHelper.GetNumberTube(numberTubeSpec),
+ NumberTubeSpec = stuffedDataModel.NumberTubeSpec,
+ NumberTubeMaterialNo = stuffedDataModel.NumberTubeMaterialNo,
NumberTubeContent = stuffedDataModel.Imprint,
FrontTerminalModel = stuffedDataModel.FrontTerminalModel,
FrontTerminalMaterialNo = stuffedDataModel.FrontTerminalMaterialCode,
@@ -439,7 +453,8 @@ public partial class MainViewModel : INotifyPropertyChanged
RearTerminalMaterialNo = stuffedDataModel.RearTerminalMaterialCode,
RearTerminalStripLength = stuffedDataModel.RearStripLength,
InsulationModel = stuffedDataModel.Insulation?.Specification,
- InsulationMaterialNo = stuffedDataModel.Insulation?.MaterialCode
+ InsulationMaterialNo = stuffedDataModel.Insulation?.MaterialCode,
+ OrderDate = nowDateStr
};
seqNo++;
dataList.Add(exportModel);