105040 增加下单日期字段,增加逻辑

This commit is contained in:
lihanbo 2024-10-26 10:27:03 +08:00
parent a8815b8f9a
commit ce014b95e0
6 changed files with 140 additions and 53 deletions

View File

@ -301,6 +301,14 @@
Binding="{Binding Quantity}"
Header="数量"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding NumberTubeSpec}"
Header="号码管型号"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding NumberTubeMaterialNo}"
Header="号码管料号"
IsReadOnly="True" />
<DataGridTextColumn
Binding="{Binding DiscolorationDesc}"
Header="变色套型号"

View File

@ -134,5 +134,10 @@
/// E绝缘软套型号物料编码
/// </summary>
public string InsulationMaterialNo { get; set; }
/// <summary>
/// 下单日期
/// </summary>
public string OrderDate { get; set; }
}
}

View File

@ -45,6 +45,35 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Models
private string imprint;
private string numberTubeSpec;
private string numberTubeMaterialNo;
private string numberTubeContent;
/// <summary>
/// B号码管规格
/// </summary>
public string NumberTubeSpec
{
get => numberTubeSpec;
set => SetProperty(ref numberTubeSpec, value);
}
/// <summary>
/// B号码管物料编码
/// </summary>
public string NumberTubeMaterialNo
{
get => numberTubeMaterialNo;
set => SetProperty(ref numberTubeMaterialNo, value);
}
/// <summary>
/// B号码管内容
/// </summary>
public string NumberTubeContent
{
get => numberTubeContent;
set => SetProperty(ref numberTubeContent, value);
}
/// <summary>
/// 导线名称

View File

@ -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)

View File

@ -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, "未匹配到线材大小");
}
}
}
@ -139,9 +149,25 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.ViewModel
private void CheckDuplicateModel(StuffedDataModel item)
{
if (StuffedData.Count(it => it != null && it.Model == item.Model) > 1)
{
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;
}
}
}
}
private void SetItemError(StuffedDataModel item, string errorMsg)

View File

@ -168,6 +168,7 @@ public partial class MainViewModel : INotifyPropertyChanged
{
FlagType = WireFlagType.Dual;
}
var reportDatas = new ConcurrentBag<ReportModel>();
//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
/// <summary>
/// 获取号码管规格
/// </summary>
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<ExportModel>();
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);