😎修改同步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)
{
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; 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 = "不存在";
@ -853,29 +876,9 @@ 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; 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;
}
} }
var itemData = new ItemData var itemData = new ItemData
{ {
@ -901,19 +904,10 @@ public class ProductManagementService : IDynamicApiController, ITransient
//var itemList = itemDataList.Where(x => x.IDNRK == item.PartNumber).ToList(); //var itemList = itemDataList.Where(x => x.IDNRK == item.PartNumber).ToList();
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 (Verification == "不存在")
{ {
if (item.ChildObjID == 137) if (item.ChildObjID == 137)
{ {
string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ” var data137 = await _obj137Rep.AsQueryable().Where(x => x.deleted == false && x.RecordGuid == item.ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).FirstAsync();
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) if (data137 != null)
{ {
item.PartNumber = data137._System_objNBS; item.PartNumber = data137._System_objNBS;
@ -925,9 +919,41 @@ public class ProductManagementService : IDynamicApiController, ITransient
} }
else else
{ {
var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
if (Verification == "不存在")
{
continue; 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

@ -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)
{
item.PartNumber = data137._System_objNBS;
}
else
{
continue; continue;
} //if (item.ChildObjID == 137)
} //{
else // string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ”
{ // 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();
// if (data137 != null)
// {
// 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,21 +720,12 @@ 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 (Verification == "不存在")
{ {
if (item.ChildObjID == 137) if (item.ChildObjID == 137)
{ {
string partNumber = item.PartNumber.Replace("默认 ", "");//过滤BOM表PartNumber字段存在“默认 ” var data137 = db.CopyNew().Queryable<Obj137>().Where(x => x.RecordGuid == item.ChildGuid && x.deleted == false).OrderByDescending(x => x.idRecord).First();
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) if (data137 != null)
{ {
item.PartNumber = data137._System_objNBS; item.PartNumber = data137._System_objNBS;
@ -743,9 +737,15 @@ public class ProductDesignLibraryService : IDynamicApiController, ITransient
} }
else else
{ {
var Verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
if (Verification == "不存在")
{
continue; continue;
} }
} }
//int sun = i + 1; //int sun = i + 1;
var itemData = new ItemData() var itemData = new ItemData()
{ {