😎修改同步bom时物料取值方式

This commit is contained in:
bairubing 2025-02-17 08:59:37 +08:00
parent 9d50065a75
commit e5f2374772
2 changed files with 114 additions and 88 deletions

View File

@ -298,11 +298,34 @@ public class ProductManagementService : IDynamicApiController, ITransient
var itemList = itemDataList.Where(x => x.ChildGuid == BomData[i].ChildGuid).ToList(); var itemList = itemDataList.Where(x => x.ChildGuid == BomData[i].ChildGuid).ToList();
if (itemList.Count == 0) if (itemList.Count == 0)
{ {
var Verification = await _dataValidationService.VerificationMaterial(BomData[i].ChildObjID, BomData[i].PartNumber, BomData[i].ChildGuid); //var Verification = await _dataValidationService.VerificationMaterial(BomData[i].ChildObjID, BomData[i].PartNumber, BomData[i].ChildGuid);
if (Verification == "不存在") //if (Verification == "不存在")
//{
// continue;
//}
if (BomData[i].ChildObjID == 137)
{ {
continue; var data137 = await _obj137Rep.AsQueryable().Where(x => x.deleted == false && x.RecordGuid == BomData[i].ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).FirstAsync();
if (data137 != null)
{
BomData[i].PartNumber = data137._System_objNBS;
}
else
{
continue;
}
} }
else
{
var Verification = await _dataValidationService.VerificationMaterial(BomData[i].ChildObjID, BomData[i].PartNumber, BomData[i].ChildGuid);
if (Verification == "不存在")
{
continue;
}
}
//int sun = i + 1; //int sun = i + 1;
var itemData = new ItemData() var itemData = new ItemData()
{ {
@ -838,7 +861,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
string verification = "不存在"; string verification = "不存在";
if (item.ChildObjID == 137) if (item.ChildObjID == 137)
{ {
var data137 = await db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == item.PartNumber && x.deleted == false && x.RecordGuid == item.ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x=>x.idRecord).FirstAsync(); var data137 = await db.CopyNew().Queryable<Obj137>().Where(x => x.deleted == false && x.RecordGuid == item.ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x=>x.idRecord).FirstAsync();
if (data137 == null) if (data137 == null)
{ {
verification = "不存在"; verification = "不存在";
@ -854,28 +877,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
if (verification == "不存在") if (verification == "不存在")
{ {
if (item.ChildObjID == 137)
{
string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ”
if (partNumber == item.PartNumber)//判断过滤后,物料编码是否和原料相同,相同的话跳出循环
{
continue;
}
var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == item.ChildGuid && x.deleted == false && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).First();
if (data137 != null)
{
item.PartNumber = data137._System_objNBS;
}
else
{
continue;
}
}
else
{
continue; continue;
}
} }
var itemData = new ItemData var itemData = new ItemData
{ {
@ -902,32 +905,55 @@ public class ProductManagementService : IDynamicApiController, ITransient
var itemList = itemDataList.Where(x => x.ChildGuid == item.ChildGuid).ToList(); var itemList = itemDataList.Where(x => x.ChildGuid == item.ChildGuid).ToList();
if (itemList.Count == 0) if (itemList.Count == 0)
{ {
var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid); if (item.ChildObjID == 137)
if (Verification == "不存在")
{ {
if (item.ChildObjID == 137) var data137 = await _obj137Rep.AsQueryable().Where(x => x.deleted == false && x.RecordGuid == item.ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).FirstAsync();
if (data137 != null)
{ {
string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ” item.PartNumber = data137._System_objNBS;
if (partNumber == item.PartNumber)//判断过滤后,物料编码是否和原料相同,相同的话跳出循环
{
continue;
}
var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == partNumber && x.deleted == false).OrderByDescending(x => x.idRecord).First();
if (data137 != null)
{
item.PartNumber = data137._System_objNBS;
}
else
{
continue;
}
} }
else else
{ {
continue; continue;
} }
} }
else
{
var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
if (Verification == "不存在")
{
continue;
}
}
//var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
//if (Verification == "不存在")
//{
// if (item.ChildObjID == 137)
// {
// string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ”
// if (partNumber == item.PartNumber)//判断过滤后,物料编码是否和原料相同,相同的话跳出循环
// {
// continue;
// }
// var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == partNumber && x.deleted == false).OrderByDescending(x => x.idRecord).First();
// if (data137 != null)
// {
// item.PartNumber = data137._System_objNBS;
// }
// else
// {
// continue;
// }
// }
// else
// {
// continue;
// }
//}
var itemData = new ItemData() var itemData = new ItemData()
{ {
POSNR = "",//组件序号 sun.ToString() POSNR = "",//组件序号 sun.ToString()

View File

@ -217,7 +217,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
.Select<ProductDesignLibraryBomOutput>().ToListAsync(); .Select<ProductDesignLibraryBomOutput>().ToListAsync();
foreach (var item in BomData) foreach (var item in BomData)
{ {
if (item.ChildObjID==137) if (item.ChildObjID == 137)
{ {
if (item.PartNumber != null && Regex.IsMatch(item.PartNumber, "默认")) if (item.PartNumber != null && Regex.IsMatch(item.PartNumber, "默认"))
{ {
@ -225,12 +225,12 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
if (data137 != null) if (data137 != null)
{ {
item.PartNumber = data137._System_objNBS; item.PartNumber = data137._System_objNBS;
item.Description=data137._System_ObjDescription; item.Description = data137._System_ObjDescription;
} }
} }
} }
} }
var data= BomData.ToPagedList(input.Page, input.PageSize); var data = BomData.ToPagedList(input.Page, input.PageSize);
//.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim())) //.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
//.WhereIF(!string.IsNullOrWhiteSpace(input.PartNumber), u => u.PartNumber.Contains(input.PartNumber.Trim())) //.WhereIF(!string.IsNullOrWhiteSpace(input.PartNumber), u => u.PartNumber.Contains(input.PartNumber.Trim()))
//.Select<ProductDesignLibraryBomOutput>().ToPagedListAsync(input.Page, input.PageSize); //.Select<ProductDesignLibraryBomOutput>().ToPagedListAsync(input.Page, input.PageSize);
@ -651,7 +651,7 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
string verification = "不存在"; string verification = "不存在";
if (item.ChildObjID == 137) if (item.ChildObjID == 137)
{ {
var data137 = await db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == item.PartNumber && x.deleted == false && x.RecordGuid == item.ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).FirstAsync(); var data137 = await db.CopyNew().Queryable<Obj137>().Where(x => x.deleted == false && x.deleted == false && x.RecordGuid == item.ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).FirstAsync();
if (data137 == null) if (data137 == null)
{ {
verification = "不存在"; verification = "不存在";
@ -668,28 +668,30 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
} }
if (verification == "不存在") if (verification == "不存在")
{ {
if (item.ChildObjID == 137)
{
string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ”
if (partNumber == item.PartNumber)//判断过滤后,物料编码是否和原料相同,相同的话跳出循环
{
continue;
}
var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == item.ChildGuid && x.deleted == false && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).First();
if (data137 != null) continue;
{ //if (item.ChildObjID == 137)
item.PartNumber = data137._System_objNBS; //{
} // string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ”
else // if (partNumber == item.PartNumber)//判断过滤后,物料编码是否和原料相同,相同的话跳出循环
{ // {
continue; // continue;
} // }
} // var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == item.ChildGuid && x.deleted == false && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).First();
else
{ // if (data137 != null)
continue; // {
} // item.PartNumber = data137._System_objNBS;
// }
// else
// {
// continue;
// }
//}
//else
//{
// continue;
//}
} }
var itemData = new ItemData var itemData = new ItemData
@ -703,7 +705,8 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
ALPRF = item.ALPRF, ALPRF = item.ALPRF,
ZDELETE = item.ZDELETE, ZDELETE = item.ZDELETE,
POSTP = item.POSTP, POSTP = item.POSTP,
ZYFMK = item.ZYFMK ZYFMK = item.ZYFMK,
ChildGuid = item.ChildGuid
}; };
itemDataList.Add(itemData); itemDataList.Add(itemData);
@ -717,35 +720,32 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
foreach (var item in BomData) foreach (var item in BomData)
{ {
var itemList = itemDataList.Where(x => x.IDNRK == item.PartNumber).ToList(); var itemList = itemDataList.Where(x => x.ChildGuid == item.ChildGuid).ToList();
if (itemList.Count == 0) if (itemList.Count == 0)
{ {
var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid); if (item.ChildObjID == 137)
if (Verification == "不存在")
{ {
if (item.ChildObjID == 137) var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x.RecordGuid == item.ChildGuid && x.deleted == false).OrderByDescending(x => x.idRecord).First();
if (data137 != null)
{ {
string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ” item.PartNumber = data137._System_objNBS;
if (partNumber == item.PartNumber)//判断过滤后,物料编码是否和原料相同,相同的话跳出循环
{
continue;
}
var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x._System_objNBS == partNumber && x.deleted == false).OrderByDescending(x => x.idRecord).First();
if (data137 != null)
{
item.PartNumber = data137._System_objNBS;
}
else
{
continue;
}
} }
else else
{ {
continue; continue;
} }
} }
else
{
var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
if (Verification == "不存在")
{
continue;
}
}
//int sun = i + 1; //int sun = i + 1;
var itemData = new ItemData() var itemData = new ItemData()
{ {