😎同步bom时,子项如果是137表的数据,就通过137表取物料编码,
This commit is contained in:
parent
eca2138c6a
commit
ce1d126366
@ -16,6 +16,7 @@ using static Elastic.Clients.Elasticsearch.JoinField;
|
||||
using Qiniu.CDN;
|
||||
using SqlSugar;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Vistar.Application.Service.MaterialManagement;
|
||||
|
||||
@ -26,6 +27,7 @@ namespace Vistar.Application.Service.MaterialManagement;
|
||||
public class ProductManagementService : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly SqlSugarRepository<Obj110> _obj110Rep;
|
||||
private readonly SqlSugarRepository<Obj137> _obj137Rep;
|
||||
private readonly SqlSugarRepository<Configurations> _configurationsRep;
|
||||
private readonly SysConfigService _sysConfigService;
|
||||
private readonly SqlSugarRepository<ConfigurationData> _configurationDataRep;
|
||||
@ -38,6 +40,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
|
||||
public ProductManagementService(
|
||||
SqlSugarRepository<Obj110> obj110Rep,
|
||||
SqlSugarRepository<Obj137> obj137Rep,
|
||||
SqlSugarRepository<Configurations> configurationsRep,
|
||||
SysConfigService sysConfigService,
|
||||
SqlSugarRepository<ConfigurationData> configurationDataRep,
|
||||
@ -60,6 +63,7 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
_obj122Rep = obj122Rep;
|
||||
_obj121Rep = obj121Rep;
|
||||
_scopeFactory = scopeFactory;
|
||||
_obj137Rep = obj137Rep;
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页查询产品管理
|
||||
@ -190,11 +194,30 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigSystemName == "mBOM").FirstAsync();
|
||||
var parent = await _obj110Rep.AsQueryable().Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false && x.fld004311 == "成功" && x.fld004312 == "N").MaxAsync(x => x.VersionIndex);
|
||||
var BomData = await _configurationDataRep.AsQueryable()
|
||||
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input.ParentGuid && x.isDeleted == false && x.ParentVersion == parent && (x.fld005586 != "不包含" || x.fld005586 == null))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.PartNumber), u => u.PartNumber.Contains(input.PartNumber.Trim()))
|
||||
.Select<ProductManagementBomOutput>().ToPagedListAsync(input.Page, input.PageSize);
|
||||
return BomData;
|
||||
.Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input.ParentGuid && x.isDeleted == false && x.ParentVersion == parent && (x.fld005586 != "不包含" || x.fld005586 == null)).Select<ProductManagementBomOutput>().ToListAsync();
|
||||
//.WhereIF(!string.IsNullOrWhiteSpace(input.Description), u => u.Description.Contains(input.Description.Trim()))
|
||||
//.WhereIF(!string.IsNullOrWhiteSpace(input.PartNumber), u => u.PartNumber.Contains(input.PartNumber.Trim()))
|
||||
//.Select<ProductManagementBomOutput>().ToPagedListAsync(input.Page, input.PageSize);
|
||||
|
||||
foreach (var item in BomData)
|
||||
{
|
||||
if (item.ChildObjID == 137)
|
||||
{
|
||||
if (item.PartNumber != null && Regex.IsMatch(item.PartNumber, "默认"))
|
||||
{
|
||||
var data137 = await _obj137Rep.AsQueryable().Where(x => x.RecordGuid == item.ChildGuid && x.deleted == false && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).FirstAsync();
|
||||
if (data137 != null)
|
||||
{
|
||||
item.PartNumber = data137._System_objNBS;
|
||||
item.Description = data137._System_ObjDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var data = BomData.ToPagedList(input.Page, input.PageSize);
|
||||
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 产品管理-Bom同步到SAP
|
||||
@ -217,8 +240,28 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
|
||||
for (int i = 0; i < input.Count; i++)
|
||||
{
|
||||
var Verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid);
|
||||
if (Verification == "不存在")
|
||||
//var Verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid);
|
||||
|
||||
string verification = "不存在";
|
||||
if (input[i].ChildObjID == 137)
|
||||
{
|
||||
var data137 = await _obj137Rep.AsQueryable().Where(x => x._System_objNBS == input[i].PartNumber && x.deleted == false && x.RecordGuid == input[i].ChildGuid && x._system_objConfigurationName == "默认").OrderByDescending(x => x.idRecord).FirstAsync();
|
||||
if (data137 == null)
|
||||
{
|
||||
verification = "不存在";
|
||||
}
|
||||
else
|
||||
{
|
||||
input[i].PartNumber = data137._System_objNBS;
|
||||
verification = "存在";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid);
|
||||
}
|
||||
|
||||
if (verification == "不存在")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -234,7 +277,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
ALPRF = input[i].fld004939,
|
||||
ZDELETE = input[i].fld004940,
|
||||
POSTP = input[i].fld004492,
|
||||
ZYFMK = input[i].fld004941
|
||||
ZYFMK = input[i].fld004941,
|
||||
ChildGuid= input[i].ChildGuid
|
||||
};
|
||||
itemDataList.Add(itemData);
|
||||
}
|
||||
@ -246,7 +290,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
for (int i = 0; i < BomData.Count; i++)
|
||||
{
|
||||
|
||||
var itemList = itemDataList.Where(x => x.IDNRK == BomData[i].PartNumber).ToList();
|
||||
//var itemList = itemDataList.Where(x => x.IDNRK == BomData[i].PartNumber).ToList();
|
||||
var itemList = itemDataList.Where(x => x.ChildGuid == BomData[i].ChildGuid).ToList();
|
||||
if (itemList.Count == 0)
|
||||
{
|
||||
var Verification = await _dataValidationService.VerificationMaterial(BomData[i].ChildObjID, BomData[i].PartNumber, BomData[i].ChildGuid);
|
||||
@ -964,11 +1009,48 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
var itemDataList = new List<ItemData>();
|
||||
foreach (var item in data.Bom)
|
||||
{
|
||||
var verification = await _dataValidationService.VerificationMaterial(item.ChildObjID, item.PartNumber, item.ChildGuid);
|
||||
string verification = "不存在";
|
||||
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();
|
||||
if (data137 == null)
|
||||
{
|
||||
verification = "不存在";
|
||||
}
|
||||
else {
|
||||
item.PartNumber = data137._System_objNBS;
|
||||
verification = "存在";
|
||||
}
|
||||
}
|
||||
else {
|
||||
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 == 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
|
||||
{
|
||||
POSNR = (data.Bom.IndexOf(item) + 1).ToString(),
|
||||
@ -980,7 +1062,8 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
ALPRF = item.ALPRF,
|
||||
ZDELETE = item.ZDELETE,
|
||||
POSTP = item.POSTP,
|
||||
ZYFMK = item.ZYFMK
|
||||
ZYFMK = item.ZYFMK,
|
||||
ChildGuid=item.ChildGuid
|
||||
};
|
||||
itemDataList.Add(itemData);
|
||||
}
|
||||
@ -989,14 +1072,36 @@ public class ProductManagementService : IDynamicApiController, ITransient
|
||||
var BomData = db.CopyNew().Queryable<ConfigurationData>().Where(x => x.ConfigId == 1 && x.ParentGuid == data.RecordGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(data.SyncVersion) && (x.fld005586 != "不包含" || x.fld005586 == null)).ToList();
|
||||
foreach (var item in BomData)
|
||||
{
|
||||
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();
|
||||
if (itemList.Count == 0)
|
||||
{
|
||||
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()
|
||||
{
|
||||
POSNR = "",//组件序号 sun.ToString()
|
||||
|
Loading…
Reference in New Issue
Block a user