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 8c04ab3..623891c 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 @@ -13,6 +13,7 @@ using Vistar.Application.SapService.Dto; using Vistar.Application.Common; using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; using static Elastic.Clients.Elasticsearch.JoinField; +using Qiniu.CDN; namespace Vistar.Application.Service.MaterialManagement; @@ -52,8 +53,8 @@ public class ProductManagementService : IDynamicApiController, ITransient _sapService = sapService; _obj118Rep = obj118Rep; _dataValidationService = dataValidationService; - _obj122Rep= obj122Rep; - _obj121Rep= obj121Rep; + _obj122Rep = obj122Rep; + _obj121Rep = obj121Rep; } /// /// 分页查询产品管理 @@ -94,7 +95,7 @@ public class ProductManagementService : IDynamicApiController, ITransient fld004629 = DateTime.Now, fld004312 = "N", fld004313 = lengthError, - fld004311="失败" + fld004311 = "失败" }) .Where(it => it.idRecord == input.idRecord) .ExecuteCommandAsync().ConfigureAwait(false); @@ -233,14 +234,16 @@ public class ProductManagementService : IDynamicApiController, ITransient itemDataList.Add(itemData); } - if (!string.IsNullOrEmpty(ParentData.fld005288)) { + 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)).ToListAsync(); for (int i = 0; i < BomData.Count; i++) { - - var itemList= itemDataList.Where(x=>x.IDNRK == BomData[i].PartNumber).ToList(); - if (itemList.Count == 0) { + + var itemList = itemDataList.Where(x => x.IDNRK == BomData[i].PartNumber).ToList(); + if (itemList.Count == 0) + { var Verification = await _dataValidationService.VerificationMaterial(BomData[i].ChildObjID, BomData[i].PartNumber, BomData[i].ChildGuid); if (Verification == "不存在") { @@ -262,7 +265,7 @@ public class ProductManagementService : IDynamicApiController, ITransient }; itemDataList.Add(itemData); } - + } } @@ -297,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()////////////////////////////////////////////////////////////xinixnixn }) .Where(it => it.idRecord == ParentData.idRecord) .ExecuteCommandAsync(); @@ -528,7 +531,7 @@ public class ProductManagementService : IDynamicApiController, ITransient .ExecuteCommandAsync(); var output = new SapOutput() { - parameter= sapOutput.parameter, + parameter = sapOutput.parameter, materialCode = input[0]._System_objNBS, code = codeVal, msg = msg, @@ -554,7 +557,7 @@ public class ProductManagementService : IDynamicApiController, ITransient var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "mBOM").FirstAsync(); var materialData = await _obj110Rep.AsQueryable() - .Where(x => x.CheckedStatus == false && x.deleted == false && x.IsLatestVersion == true &&x.fld004311=="成功" && (x.fld004316 == "A" || x.fld004316 == "M")) + .Where(x => x.CheckedStatus == false && x.deleted == false && x.IsLatestVersion == true && x.fld004311 == "成功" && (x.fld004316 == "A" || x.fld004316 == "M")) .ToListAsync(); var groupedData = materialData.GroupBy(item => item.RecordGuid) .Select(group => group.OrderByDescending(item => item.VersionIndex).First()) @@ -569,7 +572,7 @@ public class ProductManagementService : IDynamicApiController, ITransient // 查询 BOM var bomData = await _configurationDataRep.AsQueryable() .Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex).ToListAsync(); - if (bomData.Count==0) + if (bomData.Count == 0) { continue; } @@ -600,8 +603,8 @@ public class ProductManagementService : IDynamicApiController, ITransient ZYFMK = bomItem.fld004941 }; itemDataList.Add(itemData); - - } + + } // 获取时间戳精确到毫秒,sap 要求每次调用生成不重复 guid string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); var isreq = new IS_REQ @@ -645,7 +648,7 @@ public class ProductManagementService : IDynamicApiController, ITransient var output = new SapOutput { - parameter= apiOutput.parameter, + parameter = apiOutput.parameter, materialCode = item._System_objNBS, code = codeVal, msg = msg, @@ -769,4 +772,124 @@ public class ProductManagementService : IDynamicApiController, ITransient }; return output; } + + /// + /// 产品管理-定时同步工艺路线到SAP + /// + /// + [ApiDescriptionSettings(Name = "TimingSyncToSAPProcessRoute"), HttpGet] + [DisplayName("产品管理-定时同步工艺路线到SAP")] + [AllowAnonymous] + public async Task> TimingSyncToSAPProcessRoute() + { + 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 materialData = await _obj110Rep.AsQueryable() + .Where(x => x.CheckedStatus == false && x.deleted == false && x.IsLatestVersion == true && x.fld004311 == "成功" && (x.fld004320 == "A" || x.fld004320 == "M")) + .ToListAsync(); + //分组查询最大版本的物料 + var groupedData = materialData.GroupBy(item => item.RecordGuid) + .Select(group => group.OrderByDescending(item => item.VersionIndex).First()) + .ToList(); + + foreach (var item in groupedData) + { + // 获取版本号 + var versionIndex = item.VersionIndex; + // 查询 BOM + var processRouteData = await _configurationDataRep.AsQueryable() + .Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex).ToListAsync(); + if (processRouteData.Count == 0) + { + continue; + } + var itemDataList = new List(); + + foreach (var processRouteItem in processRouteData) + { + var verification = await _dataValidationService.VerificationMaterial(processRouteItem.ChildObjID, processRouteItem.PartNumber, processRouteItem.ChildGuid); + if (verification == "不存在") + { + continue; + } + //获取工序描述 + var procedureDescription = await _obj122Rep.AsQueryable().Where(x => x.RecordGuid == processRouteItem.ChildGuid).ToListAsync(); + //获取工作中心 + var workCenter = await _obj121Rep.AsQueryable().Where(x => x.RecordGuid == procedureDescription[0].fld005059_Rec).ToListAsync(); + var itemData = new SapProcessRouteItemData() + { + VORNR = processRouteItem.Marker, + LTXA1 = procedureDescription[0]._System_ObjDescription, + ARBPL = workCenter[0]._System_objNBS, + VGW01 = processRouteItem.fld004994.ToString(), + VGE01 = processRouteItem.fld004995, + STEUS = processRouteItem.fld004996, + BMSCH = processRouteItem.fld005296.ToString() + + }; + itemDataList.Add(itemData); + } + //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid + string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); + + var Datuv = item.fld004945.ToString(); + + if (!string.IsNullOrEmpty(Datuv)) + { + Datuv = item.fld004945.ToDateTime().ToString("yyyy-MM-dd"); + } + var isreq = new SapProcessRouteIS_REQ() + { + ReqKeyId = "", + BusinessId = "", + MessageId = "", + SndPrn = "PLM", + RcvPrn = "SAP", + ReqUser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName), + Note1 = "", + Note2 = "", + Note3 = "", + Zwbid = millisecondTimestamp, + Matnr = item._System_objNBS, + Werks = item.fld004325, + Datuv = Datuv, + Plnal = "", + + ItemList = itemDataList + }; + + var apiOutput = await _sapService.SapProcessRouteApi(isreq); + string codeVal = apiOutput.code == "S" ? "成功" : "失败"; + await _obj110Rep.AsUpdateable() + .SetColumns(it => new Obj110 + { + fld004632 = DateTime.Now, + fld004319 = codeVal, + fld004320 = "N", + fld004321 = apiOutput.msg + }) + .Where(it => it.idRecord == item.idRecord) + .ExecuteCommandAsync(); + var msg = apiOutput.msg; + if (apiOutput.msg == "") + { + msg = "同步成功"; + } + var output = new SapOutput() + { + parameter = apiOutput.parameter, + code = codeVal, + msg = msg, + result = apiOutput.result + }; + + sapOutputList.Add(output); + } + return sapOutputList; + } + } 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 daf4648..94fe3b3 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 @@ -158,8 +158,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient .SetColumns(it => new Obj109 { fld004508 = DateTime.Now, - fld004507=msg, - fld004509=codeVal, + fld004507 = msg, + fld004509 = codeVal, fld004510 = "N" }) .Where(it => it.idRecord == input.idRecord) @@ -740,4 +740,122 @@ public class ProjectManagementService : IDynamicApiController, ITransient return output; } + /// + /// 项目管理-定时同步工艺路线到SAP + /// + /// + [ApiDescriptionSettings(Name = "TimingSyncToSAPProcessRoute"), HttpGet] + [DisplayName("项目管理-定时同步工艺路线到SAP")] + [AllowAnonymous] + public async Task> TimingSyncToSAPProcessRoute() + { + 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 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")) + .ToListAsync(); + //分组查询最大版本的物料 + var groupedData = materialData.GroupBy(item => item.RecordGuid) + .Select(group => group.OrderByDescending(item => item.VersionIndex).First()) + .ToList(); + + foreach (var item in groupedData) + { + // 获取版本号 + var versionIndex = item.VersionIndex; + // 查询 BOM + var processRouteData = await _configurationDataRep.AsQueryable() + .Where(x => x.ConfigId == configid.ConfigID && x.ParentGuid == item.RecordGuid && x.isDeleted == false && x.ParentVersion == versionIndex).ToListAsync(); + if (processRouteData.Count == 0) + { + continue; + } + var itemDataList = new List(); + + foreach (var processRouteItem in processRouteData) + { + var verification = await _dataValidationService.VerificationMaterial(processRouteItem.ChildObjID, processRouteItem.PartNumber, processRouteItem.ChildGuid); + if (verification == "不存在") + { + continue; + } + //获取工序描述 + var procedureDescription = await _obj122Rep.AsQueryable().Where(x => x.RecordGuid == processRouteItem.ChildGuid).ToListAsync(); + //获取工作中心 + var workCenter = await _obj121Rep.AsQueryable().Where(x => x.RecordGuid == procedureDescription[0].fld005059_Rec).ToListAsync(); + var itemData = new SapProcessRouteItemData() + { + VORNR = processRouteItem.Marker, + LTXA1 = procedureDescription[0]._System_ObjDescription, + ARBPL = workCenter[0]._System_objNBS, + VGW01 = processRouteItem.fld004994.ToString(), + VGE01 = processRouteItem.fld004995, + STEUS = processRouteItem.fld004996, + BMSCH = processRouteItem.fld005296.ToString() + + }; + itemDataList.Add(itemData); + } + //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid + string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); + + var Datuv = item.fld004949.ToString(); + + if (!string.IsNullOrEmpty(Datuv)) + { + Datuv = item.fld004949.ToDateTime().ToString("yyyy-MM-dd"); + } + var isreq = new SapProcessRouteIS_REQ() + { + ReqKeyId = "", + BusinessId = "", + MessageId = "", + SndPrn = "PLM", + RcvPrn = "SAP", + ReqUser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName), + Note1 = "", + Note2 = "", + Note3 = "", + Zwbid = millisecondTimestamp, + Matnr = item._System_objNBS, + Werks = item.fld004522, + Datuv = Datuv, + Plnal = "", + + ItemList = itemDataList + }; + + var apiOutput = await _sapService.SapProcessRouteApi(isreq); + string codeVal = apiOutput.code == "S" ? "成功" : "失败"; + await _obj109Rep.AsUpdateable() + .SetColumns(it => new Obj109 + { + fld004518 = DateTime.Now, + fld004515 = codeVal, + fld004517 = "N", + fld004516 = apiOutput.msg + }) + .Where(it => it.idRecord == item.idRecord) + .ExecuteCommandAsync(); + var msg = apiOutput.msg; + if (apiOutput.msg == "") + { + msg = "同步成功"; + } + var output = new SapOutput() + { + parameter = apiOutput.parameter, + code = codeVal, + msg = msg, + result = apiOutput.result + }; + + sapOutputList.Add(output); + } + return sapOutputList; + } } diff --git a/admin.net.pro/Web/src/views/projectManagement/projectManagement/index.vue b/admin.net.pro/Web/src/views/projectManagement/projectManagement/index.vue new file mode 100644 index 0000000..70aea89 --- /dev/null +++ b/admin.net.pro/Web/src/views/projectManagement/projectManagement/index.vue @@ -0,0 +1,465 @@ + + \ No newline at end of file