|
|
@ -752,18 +752,18 @@ SELECT top 1 v.Id |
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 插入数据
|
|
|
|
List<AssemblyCfgGroup> assemblyCfgGroups = new List<AssemblyCfgGroup>(); |
|
|
|
List<AssemblyCfgGroup> deleteAssemblyCfgGroups = new List<AssemblyCfgGroup>(); |
|
|
|
List<AssemblyCfgErp> assemblyCfgErps = new List<AssemblyCfgErp>(); |
|
|
|
List<AssemblyCfgGroup> addAssemblyGroupLst = new List<AssemblyCfgGroup>(); //要添加的总成组列表
|
|
|
|
List<AssemblyCfgGroup> deleteAssemblyGroupLst = new List<AssemblyCfgGroup>(); //要删除(禁用)的总成组列表
|
|
|
|
List<AssemblyCfgErp> addErpAssemblyLst = new List<AssemblyCfgErp>(); //要添加的ERP总成列表
|
|
|
|
var groups = srcLst.GroupBy(r => new { r.SpecExplain, r.ColorExplain }).ToList(); |
|
|
|
foreach (var group in groups) |
|
|
|
{ |
|
|
|
|
|
|
|
var olditem= await _assemblyCfgGroupRepository.FirstOrDefaultAsync(r=>r.IsDisable==false&&r.SpecExplain== group.Key.SpecExplain.Trim()&& r.ColorExplain == group.Key.ColorExplain.Trim()); |
|
|
|
if (olditem != null) |
|
|
|
var oldAssemblyGroup= await _assemblyCfgGroupRepository.FirstOrDefaultAsync(r=>r.IsDisable==false && r.SpecExplain== group.Key.SpecExplain.Trim() && r.ColorExplain == group.Key.ColorExplain.Trim()); |
|
|
|
if (oldAssemblyGroup != null) |
|
|
|
{ |
|
|
|
olditem.IsDisable = true; |
|
|
|
deleteAssemblyCfgGroups.Add(olditem); |
|
|
|
oldAssemblyGroup.IsDisable = true; |
|
|
|
deleteAssemblyGroupLst.Add(oldAssemblyGroup); |
|
|
|
} |
|
|
|
string groupCode = group.Key.SpecExplain + group.Key.ColorExplain; |
|
|
|
AssemblyCfgGroup assemblyCfgGroup = new AssemblyCfgGroup(GuidGenerator.Create() , groupCode,"",true); |
|
|
@ -781,15 +781,15 @@ SELECT top 1 v.Id |
|
|
|
assemblyCfgErp.GroupId = assemblyCfgGroup.Id; |
|
|
|
assemblyCfgErp.SpecExplain = item.SpecExplain.Trim(); |
|
|
|
assemblyCfgErp.ColorExplain = item.ColorExplain.Trim(); |
|
|
|
assemblyCfgErps.Add(assemblyCfgErp); |
|
|
|
addErpAssemblyLst.Add(assemblyCfgErp); |
|
|
|
} |
|
|
|
assemblyCfgGroups.Add(assemblyCfgGroup); |
|
|
|
addAssemblyGroupLst.Add(assemblyCfgGroup); |
|
|
|
} |
|
|
|
|
|
|
|
//插入“导入记录表”
|
|
|
|
await _assemblyCfgGroupRepository.UpdateManyAsync(deleteAssemblyCfgGroups);//更新总成组
|
|
|
|
await _assemblyCfgGroupRepository.InsertManyAsync(assemblyCfgGroups); |
|
|
|
await _assemblyCfgErpRepository.InsertManyAsync(assemblyCfgErps); |
|
|
|
await _assemblyCfgGroupRepository.UpdateManyAsync(deleteAssemblyGroupLst);//更新总成组
|
|
|
|
await _assemblyCfgGroupRepository.InsertManyAsync(addAssemblyGroupLst); |
|
|
|
await _assemblyCfgErpRepository.InsertManyAsync(addErpAssemblyLst); |
|
|
|
#endregion
|
|
|
|
ret.Status = true; |
|
|
|
return ret; |
|
|
@ -815,7 +815,7 @@ SELECT top 1 v.Id |
|
|
|
if (!string.IsNullOrEmpty(error)) return error; |
|
|
|
|
|
|
|
|
|
|
|
#region 验证分组是否符合分组规
|
|
|
|
#region 验证分组是否符合分组规定:必须是4个门板
|
|
|
|
|
|
|
|
var checkGroups = srcLst.GroupBy(r => new { r.SpecExplain, r.ColorExplain }).Select(r => new { SpecExplain = r.Key.SpecExplain, ColorExplain = r.Key.ColorExplain, Count = r.Count() }); |
|
|
|
var errorgroups = checkGroups.Where(r => r.Count != 4).ToList(); |
|
|
@ -827,9 +827,9 @@ SELECT top 1 v.Id |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 验证零件是否存在(门板)
|
|
|
|
#region 验证零件(门板)在物料表是否存在
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var partdists = srcLst.Select(r => r.MaterialNum).Distinct(); |
|
|
|
foreach (var sapMaterial in partdists) |
|
|
|
{ |
|
|
@ -856,7 +856,7 @@ SELECT top 1 v.Id |
|
|
|
string[] arr = new string[4] { "1001", "1002", "1003", "1004" }; |
|
|
|
string arrStr = string.Join(',', arr); |
|
|
|
|
|
|
|
var qry = from item in srcLst |
|
|
|
var bomGroupLst = from item in srcLst |
|
|
|
group item by new { item.SpecExplain, item.ColorExplain } into g |
|
|
|
select new |
|
|
|
{ |
|
|
@ -864,30 +864,36 @@ SELECT top 1 v.Id |
|
|
|
ColorExplain = g.Key.ColorExplain, |
|
|
|
Details = g.Select(itm => itm.MaterialNum).ToList() |
|
|
|
}; |
|
|
|
foreach (var item in qry) |
|
|
|
foreach (var bomGroup in bomGroupLst) |
|
|
|
{ |
|
|
|
if (item.Details.Count != 4) |
|
|
|
if (bomGroup.Details.Count != 4) |
|
|
|
{ |
|
|
|
strBuild.AppendLine($"规格说明{item.SpecExplain}、颜色说明{item.ColorExplain}包含的物料号不是4个"); |
|
|
|
strBuild.AppendLine($"规格说明{bomGroup.SpecExplain}、颜色说明{bomGroup.ColorExplain}包含的物料号不是4个"); |
|
|
|
} |
|
|
|
//遍历物料号
|
|
|
|
List<string> strLst = new List<string>(); |
|
|
|
foreach (string sapMaterialNum in item.Details) |
|
|
|
foreach (string sapMaterialNum in bomGroup.Details) //遍历4个门板物料号
|
|
|
|
{ |
|
|
|
var materialObj = material3Lst.FirstOrDefault(itm => itm.MaterialNum == sapMaterialNum); |
|
|
|
if (materialObj == null) |
|
|
|
{ |
|
|
|
strBuild.AppendLine($"规格说明{item.SpecExplain}:物料号{sapMaterialNum}在物料表不存在!"); |
|
|
|
strBuild.AppendLine($"规格说明{bomGroup.SpecExplain}:物料号{sapMaterialNum}在物料表不存在!"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (arr.Contains(materialObj.MaterialType2) == true) |
|
|
|
{ |
|
|
|
strLst.Add(materialObj.MaterialType2); |
|
|
|
} |
|
|
|
else |
|
|
|
if (materialObj.MaterialDescription.HasValue() |
|
|
|
&& materialObj.MaterialDescription.Length >=4 |
|
|
|
&& materialObj.MaterialDescription.Substring(0,4).ToUpper() == "E001") |
|
|
|
{ |
|
|
|
strBuild.AppendLine($"规格说明{item.SpecExplain}:物料号{sapMaterialNum}的MaterialType2不是【{arrStr}】其中之一!"); |
|
|
|
if (arr.Contains(materialObj.MaterialType2) == true) |
|
|
|
{ |
|
|
|
strLst.Add(materialObj.MaterialType2); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
strBuild.AppendLine($"规格说明{bomGroup.SpecExplain}:物料号{sapMaterialNum}的MaterialType2不是【{arrStr}】其中之一!"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -896,7 +902,7 @@ SELECT top 1 v.Id |
|
|
|
if (strLst.Count != strLst.Distinct().Count()) |
|
|
|
{ |
|
|
|
string repeatLst = string.Join(',', strLst); |
|
|
|
strBuild.AppendLine($"规格说明{item.SpecExplain}包含的配置号重复{repeatLst}"); |
|
|
|
strBuild.AppendLine($"规格说明{bomGroup.SpecExplain}包含的配置号重复{repeatLst}"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|