From 09b00b1f88c151b9d2d9fa9a5a113ab426faf2ae Mon Sep 17 00:00:00 2001 From: bairubing Date: Fri, 25 Oct 2024 10:45:17 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=E4=BF=AE=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=88=A4=E6=96=AD=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...AdministrativeMaterialManagementService.cs | 2 +- .../ProductManagementService.cs | 61 ++++++++++++++++--- .../ProductionMaterialsManagementService.cs | 2 +- .../ProjectManagementService.cs | 10 +-- 4 files changed, 58 insertions(+), 17 deletions(-) diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/AdministrativeMaterialManagement/AdministrativeMaterialManagementService.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/AdministrativeMaterialManagement/AdministrativeMaterialManagementService.cs index 9760355..25cb370 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/AdministrativeMaterialManagement/AdministrativeMaterialManagementService.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/AdministrativeMaterialManagement/AdministrativeMaterialManagementService.cs @@ -205,7 +205,7 @@ public class AdministrativeMaterialManagementService : IDynamicApiController, IT }); continue; } - if (input[i].fld004922 != "A" && input[i].fld004922 != "M") + if (input[i].fld004922 != "A"|| input[i].fld004922 != "M"|| input[i].fld004922==null) { SapOutputList.Add(new SapOutput() { diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/ProductManagementService.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/ProductManagementService.cs index c0dd454..66b8c68 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/ProductManagementService.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/ProductManagementService.cs @@ -182,10 +182,10 @@ public class ProductManagementService : IDynamicApiController, ITransient [DisplayName("获取BOM")] public async Task> GetBOM(BomPageProductManagementInput input) { - var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "mBOM").FirstAsync(); + 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).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 !="不包含") + .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().ToPagedListAsync(input.Page, input.PageSize); @@ -236,8 +236,8 @@ public class ProductManagementService : IDynamicApiController, ITransient if (!string.IsNullOrEmpty(ParentData.fld005288)) { - var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "mBOM").FirstAsync(); - var BomData = await _configurationDataRep.AsQueryable().Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input[0].ParentGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(ParentData.fld005288)&&x.fld005586!="不包含").ToListAsync(); + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigSystemName == "mBOM").FirstAsync(); + var BomData = await _configurationDataRep.AsQueryable().Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == input[0].ParentGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(ParentData.fld005288)&&(x.fld005586!="不包含"|| x.fld005586==null)).ToListAsync(); for (int i = 0; i < BomData.Count; i++) { @@ -300,7 +300,7 @@ public class ProductManagementService : IDynamicApiController, ITransient fld004315 = codeVal, fld004316 = "N", fld004317 = apiOutput.msg, - fld005288 = input[0].ParentVersion.ToString()////////////////////////////////////////////////////////////xinixnixn + fld005288 = input[0].ParentVersion.ToString() }) .Where(it => it.idRecord == ParentData.idRecord) .ExecuteCommandAsync(); @@ -356,7 +356,7 @@ public class ProductManagementService : IDynamicApiController, ITransient }); continue; } - if (input[i].fld004312 != "A" && input[i].fld004312 != "M") + if (input[i].fld004312 != "A" || input[i].fld004312 != "M" || input[i].fld004312==null) { SapOutputList.Add(new SapOutput() { @@ -554,7 +554,7 @@ public class ProductManagementService : IDynamicApiController, ITransient var sapOutputList = new List(); var sapUserName = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName); // 配置 - var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "mBOM").FirstAsync(); + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigSystemName == "mBOM").FirstAsync(); var materialData = await _obj110Rep.AsQueryable() .Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.fld005324 == "发布" && x.deleted == false && x.IsLatestVersion == true && x.fld004311 == "成功" && (x.fld004316 == "A" || x.fld004316 == "M")) @@ -565,17 +565,19 @@ public class ProductManagementService : IDynamicApiController, ITransient foreach (var item in groupedData) { + // 获取版本号 var versionIndex = item.VersionIndex; // 获取 ECN guid var ecnGuid = item.fld004944_Rec; // 查询 BOM var bomData = await _configurationDataRep.AsQueryable() - .Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex && x.fld005586 != "不包含").ToListAsync(); + .Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex && (x.fld005586 != "不包含" || x.fld005586 == null)).ToListAsync(); if (bomData.Count == 0) { continue; } + // 查询 ECN 编码 var ecnData = await _obj118Rep.AsQueryable().Where(x => x.RecordGuid == ecnGuid && x.deleted == false).OrderByDescending(x => x.VersionIndex).FirstAsync(); var ecn = ecnData != null ? ecnData._System_objNBS : ""; @@ -605,6 +607,45 @@ public class ProductManagementService : IDynamicApiController, ITransient itemDataList.Add(itemData); } + + var ParentData = await _obj110Rep.AsQueryable().Where(x => x.RecordGuid == bomData[0].ParentGuid && x.deleted == false && x.VersionIndex == bomData[0].ParentVersion).FirstAsync(); + + //对比上个版本 + if (!string.IsNullOrEmpty(ParentData.fld005288)) + { + var configidold = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigSystemName == "mBOM").FirstAsync(); + var BomDataold = await _configurationDataRep.AsQueryable().Where(x => x.ConfigId == configidold.ConfigID && x.ParentGuid == bomData[0].ParentGuid && x.isDeleted == false && x.ParentVersion == Convert.ToInt32(ParentData.fld005288) && (x.fld005586 != "不包含" || x.fld005586 == null)).ToListAsync(); + for (int i = 0; i < BomDataold.Count; i++) + { + + var itemList = itemDataList.Where(x => x.IDNRK == BomDataold[i].PartNumber).ToList(); + if (itemList.Count == 0) + { + var Verification = await _dataValidationService.VerificationMaterial(BomDataold[i].ChildObjID, BomDataold[i].PartNumber, BomDataold[i].ChildGuid); + if (Verification == "不存在") + { + continue; + } + //int sun = i + 1; + var itemData = new ItemData() + { + POSNR = "",//组件序号 sun.ToString() + IDNRK = BomDataold[i].PartNumber,//组件物料号 + MENGE = BomDataold[i].Quantity.ToString(),//组件数量 + SORTF = BomDataold[i].fld004936, + ITISOB = BomDataold[i].fld004937, + ALPGR = BomDataold[i].fld004938, + ALPRF = BomDataold[i].fld004939, + ZDELETE = "X", + POSTP = BomDataold[i].fld004492, + ZYFMK = BomDataold[i].fld004941 + }; + itemDataList.Add(itemData); + } + + } + } + // 获取时间戳精确到毫秒,sap 要求每次调用生成不重复 guid string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); var isreq = new IS_REQ @@ -668,7 +709,7 @@ public class ProductManagementService : IDynamicApiController, ITransient [DisplayName("获取工艺路线")] public async Task> GetProcessRoute(BomPageProductManagementInput input) { - var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "pBOM").FirstAsync(); + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigSystemName == "pBOM").FirstAsync(); var parent = await _obj110Rep.AsQueryable().Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false).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) @@ -785,7 +826,7 @@ public class ProductManagementService : IDynamicApiController, ITransient var sapOutputList = new List(); var sapUserName = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName); // 配置 - var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "pBOM").FirstAsync(); + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigSystemName == "pBOM").FirstAsync(); //查询需要同步的产品 var materialData = await _obj110Rep.AsQueryable() diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/ProductionMaterialsManagementService.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/ProductionMaterialsManagementService.cs index c3f2220..8e0266a 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/ProductionMaterialsManagementService.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/ProductionMaterialsManagementService.cs @@ -204,7 +204,7 @@ public class ProductionMaterialsManagementService : IDynamicApiController, ITran }); continue; } - if (input[i].fld004607 != "A"&& input[i].fld004607 != "M") + if (input[i].fld004607 != "A" || input[i].fld004607 != "M" || input[i].fld004607 == null) { SapOutputList.Add(new SapOutput() { diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/ProjectManagementService.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/ProjectManagementService.cs index 94fe3b3..b4fecdb 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/ProjectManagementService.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/ProjectManagementService.cs @@ -212,7 +212,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient }); continue; } - if (input[i].fld004510 != "A" && input[i].fld004510 != "M") + if (input[i].fld004510 != "A" || input[i].fld004510 != "M" || input[i].fld004510 == null) { SapOutputList.Add(new SapOutput() { @@ -300,7 +300,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient [DisplayName("获取BOM")] public async Task> GetBOM(BomProjectManagementInput input) { - var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigLabel == "mBOM").FirstAsync(); + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigSystemName == "mBOM").FirstAsync(); var parent = await _obj109Rep.AsQueryable().Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false).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) @@ -523,7 +523,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient var sapOutputList = new List(); var sapUserName = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName); // 配置 - var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigLabel == "mBOM").FirstAsync(); + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigSystemName == "mBOM").FirstAsync(); var materialData = await _obj109Rep.AsQueryable() .Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布" && x.fld004511 == "成功" && (x.fld004514 == "A" || x.fld004514 == "M")) @@ -637,7 +637,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient [DisplayName("获取工艺路线")] public async Task> GetProcessRoute(BomPageProductManagementInput input) { - var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigLabel == "pBOM").FirstAsync(); + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigSystemName == "pBOM").FirstAsync(); var parent = await _obj109Rep.AsQueryable().Where(x => x.RecordGuid == input.ParentGuid && x.deleted == false).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) @@ -752,7 +752,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient var sapOutputList = new List(); var sapUserName = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName); // 配置 - var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigLabel == "pBOM").FirstAsync(); + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigSystemName == "pBOM").FirstAsync(); //查询需要同步的产品 var materialData = await _obj109Rep.AsQueryable()