diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Common/DataValidationService.cs b/admin.net.pro/Admin.NET/Vistar.Application/Common/DataValidationService.cs index 8cf61f3..6584c44 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Common/DataValidationService.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Common/DataValidationService.cs @@ -23,17 +23,20 @@ public class DataValidationService : IDynamicApiController, ITransient public SqlSugarRepository _obj109Rep; public SqlSugarRepository _obj112Rep; public SqlSugarRepository _obj133Rep; + public SqlSugarRepository _obj122Rep; public DataValidationService( SqlSugarRepository obj110Rep, SqlSugarRepository obj109Rep, SqlSugarRepository obj112Rep, - SqlSugarRepository obj133Rep + SqlSugarRepository obj133Rep, + SqlSugarRepository obj122Rep ) { _obj110Rep = obj110Rep; _obj109Rep = obj109Rep; _obj112Rep = obj112Rep; _obj133Rep = obj133Rep; + _obj122Rep = obj122Rep; } /// /// 验证物料是否存在 @@ -60,6 +63,9 @@ public class DataValidationService : IDynamicApiController, ITransient case 133: tasks.Add(_obj133Rep.AsQueryable().Where(x => x._System_objNBS == materialCode && x.deleted == false && x.RecordGuid == recordGuid).CountAsync()); break; + case 122: + tasks.Add(_obj122Rep.AsQueryable().Where(x => x._System_objNBS == materialCode && x.deleted == false && x.RecordGuid == recordGuid).CountAsync()); + break; } if (tasks.Count > 0) { diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Entity/ConfigurationData.cs b/admin.net.pro/Admin.NET/Vistar.Application/Entity/ConfigurationData.cs index 6c314a7..f52d238 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Entity/ConfigurationData.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/ConfigurationData.cs @@ -545,5 +545,16 @@ public class ConfigurationData /// [SugarColumn(ColumnName = "fld005020", ColumnDescription = "", Length = -1)] public string? fld005020 { get; set; } - + /// + /// + /// + [SugarColumn(ColumnName = "fld005296", ColumnDescription = "", Length = -1)] + public long? fld005296 { get; set; } + + + /// + /// + /// + [SugarColumn(ColumnName = "fld005298", ColumnDescription = "", Length = -1)] + public long? fld005298 { get; set; } } diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj110.cs b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj110.cs index cf78aed..acedf65 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj110.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj110.cs @@ -745,4 +745,10 @@ public class Obj110 /// [SugarColumn(ColumnName = "fld004945", ColumnDescription = "", Length = -1)] public DateTime? fld004945 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld005288", ColumnDescription = "", Length = -1)] + public string? fld005288 { get; set; } } diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj121.cs b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj121.cs new file mode 100644 index 0000000..20cfdb6 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj121.cs @@ -0,0 +1,256 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using Admin.NET.Core; +using SqlSugar; +using System.ComponentModel.DataAnnotations; +namespace Vistar.Application.Entity; + +/// +/// +/// +[SugarTable("OBJ121","")] +[Tenant("启威星 1.94.4.74")] +public class Obj121 +{ + /// + /// + /// + [Required] + [SugarColumn(ColumnName = "idRecord", IsIdentity = true, ColumnDescription = "", IsPrimaryKey = true)] + public long idRecord { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CheckedStatus", ColumnDescription = "")] + public bool? CheckedStatus { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "VersionIndex", ColumnDescription = "")] + public int? VersionIndex { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "IsLatestVersion", ColumnDescription = "")] + public bool? IsLatestVersion { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreatedDate", ColumnDescription = "")] + public DateTime? CreatedDate { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "VersionCreatedDate", ColumnDescription = "")] + public DateTime? VersionCreatedDate { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "dateModified", ColumnDescription = "")] + public DateTime? dateModified { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "UserCreatedId", ColumnDescription = "")] + public long? UserCreatedId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "VersionUserCreatedId", ColumnDescription = "")] + public long? VersionUserCreatedId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "UserModifiedId", ColumnDescription = "")] + public long? UserModifiedId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "RecordGuid", ColumnDescription = "", Length = 40)] + public string? RecordGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "isVisibilityNormal", ColumnDescription = "")] + public bool? isVisibilityNormal { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "deleted", ColumnDescription = "")] + public bool? deleted { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "SubObjectGuid", ColumnDescription = "", Length = 40)] + public string? SubObjectGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "PreviousStatus", ColumnDescription = "")] + public bool? PreviousStatus { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "revision", ColumnDescription = "", Length = 10)] + public string? revision { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Record_image160_160", ColumnDescription = "")] + public byte[]? Record_image160_160 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Record_Image320_240", ColumnDescription = "")] + public byte[]? Record_Image320_240 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Record_ImageMax", ColumnDescription = "")] + public byte[]? Record_ImageMax { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_objNBS", ColumnDescription = "", Length = 100)] + public string? _System_objNBS { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_ObjDescription", ColumnDescription = "", Length = 200)] + public string? _System_ObjDescription { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_Effectivity_Begin", ColumnDescription = "")] + public DateTime? _System_Effectivity_Begin { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_Effectivity_End", ColumnDescription = "")] + public DateTime? _System_Effectivity_End { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CheckedOutPc", ColumnDescription = "", Length = 255)] + public string? CheckedOutPc { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "GroupObjId", ColumnDescription = "")] + public long? GroupObjId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_CheckOutInProgress", ColumnDescription = "")] + public bool? _CheckOutInProgress { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "EnableNotifications", ColumnDescription = "")] + public bool? EnableNotifications { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objConfigurationName", ColumnDescription = "", Length = 255)] + public string? _system_objConfigurationName { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objConfigurationType", ColumnDescription = "")] + public bool? _system_objConfigurationType { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objConfigurationGuid", ColumnDescription = "", Length = 40)] + public string? _system_objConfigurationGuid { get; set; } + + /// + /// + /// + [Required] + [SugarColumn(ColumnName = "ShowBomFromConfiguration", ColumnDescription = "", Length = 250)] + public string ShowBomFromConfiguration { get; set; } + + /// + /// + /// + [Required] + [SugarColumn(ColumnName = "_System_ObjNbsAuto", ColumnDescription = "", Length = 50)] + public string _System_ObjNbsAuto { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_DerivedFrom", ColumnDescription = "", Length = 50)] + public string? _System_DerivedFrom { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_DerivedFrom_RecordGuid", ColumnDescription = "", Length = 50)] + public string? _System_DerivedFrom_RecordGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objLinkedCompare", ColumnDescription = "")] + public bool? _system_objLinkedCompare { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "isReleasedVersion", ColumnDescription = "")] + public bool? isReleasedVersion { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_WebLink", ColumnDescription = "", Length = 500)] + public string? _System_WebLink { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LinkDrw", ColumnDescription = "")] + public bool? LinkDrw { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ParentRecordGuid", ColumnDescription = "", Length = 40)] + public string? ParentRecordGuid { get; set; } + +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj122.cs b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj122.cs new file mode 100644 index 0000000..780abd4 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj122.cs @@ -0,0 +1,274 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using Admin.NET.Core; +using SqlSugar; +using System.ComponentModel.DataAnnotations; +namespace Vistar.Application.Entity; + +/// +/// +/// +[SugarTable("OBJ122","")] +[Tenant("启威星 1.94.4.74")] +public class Obj122 +{ + /// + /// + /// + [Required] + [SugarColumn(ColumnName = "idRecord", IsIdentity = true, ColumnDescription = "", IsPrimaryKey = true)] + public long idRecord { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CheckedStatus", ColumnDescription = "")] + public bool? CheckedStatus { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "VersionIndex", ColumnDescription = "")] + public int? VersionIndex { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "IsLatestVersion", ColumnDescription = "")] + public bool? IsLatestVersion { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CreatedDate", ColumnDescription = "")] + public DateTime? CreatedDate { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "VersionCreatedDate", ColumnDescription = "")] + public DateTime? VersionCreatedDate { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "dateModified", ColumnDescription = "")] + public DateTime? dateModified { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "UserCreatedId", ColumnDescription = "")] + public long? UserCreatedId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "VersionUserCreatedId", ColumnDescription = "")] + public long? VersionUserCreatedId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "UserModifiedId", ColumnDescription = "")] + public long? UserModifiedId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "RecordGuid", ColumnDescription = "", Length = 40)] + public string? RecordGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "isVisibilityNormal", ColumnDescription = "")] + public bool? isVisibilityNormal { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "deleted", ColumnDescription = "")] + public bool? deleted { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "SubObjectGuid", ColumnDescription = "", Length = 40)] + public string? SubObjectGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "PreviousStatus", ColumnDescription = "")] + public bool? PreviousStatus { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "revision", ColumnDescription = "", Length = 10)] + public string? revision { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Record_image160_160", ColumnDescription = "")] + public byte[]? Record_image160_160 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Record_Image320_240", ColumnDescription = "")] + public byte[]? Record_Image320_240 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "Record_ImageMax", ColumnDescription = "")] + public byte[]? Record_ImageMax { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_objNBS", ColumnDescription = "", Length = 100)] + public string? _System_objNBS { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_ObjDescription", ColumnDescription = "", Length = 200)] + public string? _System_ObjDescription { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_Effectivity_Begin", ColumnDescription = "")] + public DateTime? _System_Effectivity_Begin { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_Effectivity_End", ColumnDescription = "")] + public DateTime? _System_Effectivity_End { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "CheckedOutPc", ColumnDescription = "", Length = 255)] + public string? CheckedOutPc { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "GroupObjId", ColumnDescription = "")] + public long? GroupObjId { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_CheckOutInProgress", ColumnDescription = "")] + public bool? _CheckOutInProgress { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "EnableNotifications", ColumnDescription = "")] + public bool? EnableNotifications { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objConfigurationName", ColumnDescription = "", Length = 255)] + public string? _system_objConfigurationName { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objConfigurationType", ColumnDescription = "")] + public bool? _system_objConfigurationType { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objConfigurationGuid", ColumnDescription = "", Length = 40)] + public string? _system_objConfigurationGuid { get; set; } + + /// + /// + /// + [Required] + [SugarColumn(ColumnName = "ShowBomFromConfiguration", ColumnDescription = "", Length = 250)] + public string ShowBomFromConfiguration { get; set; } + + /// + /// + /// + [Required] + [SugarColumn(ColumnName = "_System_ObjNbsAuto", ColumnDescription = "", Length = 50)] + public string _System_ObjNbsAuto { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_DerivedFrom", ColumnDescription = "", Length = 50)] + public string? _System_DerivedFrom { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_DerivedFrom_RecordGuid", ColumnDescription = "", Length = 50)] + public string? _System_DerivedFrom_RecordGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_system_objLinkedCompare", ColumnDescription = "")] + public bool? _system_objLinkedCompare { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "isReleasedVersion", ColumnDescription = "")] + public bool? isReleasedVersion { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "_System_WebLink", ColumnDescription = "", Length = 500)] + public string? _System_WebLink { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "LinkDrw", ColumnDescription = "")] + public bool? LinkDrw { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "ParentRecordGuid", ColumnDescription = "", Length = 40)] + public string? ParentRecordGuid { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld005058", ColumnDescription = "", Length = -1)] + public string? fld005058 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld005059", ColumnDescription = "")] + public long? fld005059 { get; set; } + + /// + /// + /// + [SugarColumn(ColumnName = "fld005059_Rec", ColumnDescription = "", Length = 40)] + public string? fld005059_Rec { get; set; } + +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapProcessRouteInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapProcessRouteInput.cs new file mode 100644 index 0000000..37b2a11 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapProcessRouteInput.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vistar.Application.SapService.Dto +{ + public class SapProcessRouteIS_REQ + { + public string ReqKeyId { get; set; } + public string BusinessId { get; set; } + public string MessageId { get; set; } + public string SndPrn { get; set; } + public string RcvPrn { get; set; } + public string ReqUser { get; set; } + public string Note1 { get; set; } + public string Note2 { get; set; } + public string Note3 { get; set; } + + /// + /// 外部唯一ID + /// + public string Zwbid { get; set; } + /// + /// 抬头物料 + /// + public string Matnr { get; set; } + /// + /// 工厂 + /// + public string Werks { get; set; } + /// + /// 有效日期 + /// + public string Datuv { get; set; } + /// + /// 组号 + /// + public string Plnal { get; set; } + + public List ItemList { get; set; } + } + + public class SapProcessRouteItemData + { + /// + /// 工序序号 + /// + public string? VORNR { get; set; } + /// + /// 工序描述 + /// + public string? LTXA1 { get; set; } + /// + /// 工作中心 + /// + public string? ARBPL { get; set; } + /// + /// 工时 + /// + public string? VGW01 { get; set; } + /// + /// 工时单位 + /// + public string? VGE01 { get; set; } + /// + /// 控制码 + /// + public string? STEUS { get; set; } + /// + /// 基本数量 + /// + public string? BMSCH { get; set; } + } +} + + + + + + diff --git a/admin.net.pro/Admin.NET/Vistar.Application/SapService/SapService.cs b/admin.net.pro/Admin.NET/Vistar.Application/SapService/SapService.cs index 389f09b..09f5c09 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/SapService/SapService.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/SapService/SapService.cs @@ -418,6 +418,159 @@ public class SapService : IDynamicApiController, ITransient return output; } } + + /// + /// SAP同步工艺路线 + /// + /// + /// + public async Task SapProcessRouteApi(SapProcessRouteIS_REQ input) + { + // 创建SOAP XML请求 + var soapEnvelope = new XDocument( + new XDeclaration("1.0", "utf-8", "yes"), + new XElement(XName.Get("Envelope", "http://schemas.xmlsoap.org/soap/envelope/"), + new XElement(XName.Get("Header", "http://schemas.xmlsoap.org/soap/envelope/")), + new XElement(XName.Get("Body", "http://schemas.xmlsoap.org/soap/envelope/"), + new XElement(XName.Get("ZPPFM004", "urn:sap-com:document:sap:rfc:functions"), + new XElement("IS_REQ", + new XElement("REQKEYID", input.ReqKeyId), + new XElement("BUSINESSID", input.BusinessId), + new XElement("MESSAGEID", input.MessageId), + new XElement("SNDPRN", input.SndPrn), + new XElement("RCVPRN", input.RcvPrn), + new XElement("REQUSER", input.ReqUser), + new XElement("NOTE1", input.Note1), + new XElement("NOTE2", input.Note2), + new XElement("NOTE3", input.Note3) + ), + new XElement("IT_DATA", + new XElement("item", + new XElement("ZWBID", input.Zwbid), + new XElement("MATNR", input.Matnr), + new XElement("WERKS", input.Werks), + new XElement("DATUV", input.Datuv), + new XElement("PLNAL", input.Plnal), + new XElement("ITEM", + // 使用循环生成 元素 + ProcessRouteGenerateItemElements(input.ItemList) + ) + ) + ) + ) + ) + ) + ); + var httpClientHandler = new HttpClientHandler + { + ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true, + ClientCertificateOptions = ClientCertificateOption.Manual + }; + try + { + using (var httpClient = new HttpClient(httpClientHandler)) + { + // 设置基本身份验证信息 + var username = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName); + var password = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapPassword); + var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}")); + httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials); + // 将 XML 内容转换为字符串并设置请求内容类型为 text/xml + var content = new StringContent(soapEnvelope.ToString(), Encoding.UTF8, "text/xml"); + content.Headers.ContentType = new MediaTypeHeaderValue("text/xml"); + // 设置 SAP Web 服务的 URL + var url = "https://vhjqeds4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/zppfm004/120/zppfm004/zppfm004"; + + // 发起 POST 请求到 SAP Web 服务 + var response = await httpClient.PostAsync(url, content); + + if (response.IsSuccessStatusCode) + { + var result = await response.Content.ReadAsStringAsync(); + XDocument doc = XDocument.Parse(result); + var item = doc.Descendants("item").FirstOrDefault(); + var code = item?.Element("CODE")?.Value; + var msg = item?.Element("MSG")?.Value; + if (item == null) + { + var ES_RETItem = doc.Descendants("ES_RET").FirstOrDefault(); + var ES_RETcode = ES_RETItem?.Element("CODE")?.Value; + var ES_RETmsg = ES_RETItem?.Element("MSG")?.Value; + var outputES_RET = new SapOutput() + { + parameter = soapEnvelope.ToString(), + code = ES_RETcode, + msg = ES_RETmsg, + result = result + }; + return outputES_RET; + } + var output = new SapOutput() + { + parameter = soapEnvelope.ToString(), + code = code, + msg = msg, + result = result + }; + return output; + } + else + { + var result = await response.Content.ReadAsStringAsync(); + var output = new SapOutput() + { + parameter = soapEnvelope.ToString(), + code = "失败", + msg = "调用失败,状态码: " + response.StatusCode, + result = result + }; + return output; + } + } + } + catch (Exception ex) + { + // 记录错误日志 + Console.WriteLine("发生错误: " + ex.Message); + var output = new SapOutput() + { + code = "失败", + msg = "发生错误" + ex.Message, + result = "发生错误" + ex + }; + return output; + } + } + + /// + /// 生成工艺路线 item 元素 + /// + /// + /// + public List ProcessRouteGenerateItemElements(List items) + { + var itemElements = new List(); + + foreach (var item in items) + { + var element = new XElement("item", + new XElement("VORNR", item.VORNR), + new XElement("LTXA1", item.LTXA1), + new XElement("ARBPL", item.ARBPL), + new XElement("VGW01", item.VGW01), + new XElement("VGE01", item.VGE01), + new XElement("STEUS", item.STEUS), + new XElement("BMSCH", item.BMSCH) + ); + + itemElements.Add(element); + } + + return itemElements; + } } + + + diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/BomPageProductManagementInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/BomPageProductManagementInput.cs index f5e5935..40b6d24 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/BomPageProductManagementInput.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/BomPageProductManagementInput.cs @@ -198,4 +198,8 @@ public class BomPageProductManagementInput : BasePageInput public string? fld005019 { get; set; } public string? fld005020 { get; set; } + public long? fld005296 { get; set; } + + + public long? fld005298 { get; set; } } diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/ProductManagementInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/ProductManagementInput.cs index 40bc6e4..7b03807 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/ProductManagementInput.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/ProductManagementInput.cs @@ -517,6 +517,8 @@ public class ProductManagementBaseInput /// public string? fld004699 { get; set; } public long idRecord { get; set; } + + public string? fld005288 { get; set; } } /// diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/ProductManagementOutput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/ProductManagementOutput.cs index 7bdfd20..4cda358 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/ProductManagementOutput.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/MaterialManagement/Dto/ProductManagementOutput.cs @@ -253,5 +253,6 @@ public class ProductManagementOutput public string? fld004944_Rec { get; set; } public DateTime? fld004945 { get; set; } + public string? fld005288 { get; set; } } 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 e8fe28b..8c04ab3 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 @@ -11,6 +11,8 @@ using Admin.NET.Core.Service; using Vistar.Application.Util; using Vistar.Application.SapService.Dto; using Vistar.Application.Common; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; +using static Elastic.Clients.Elasticsearch.JoinField; namespace Vistar.Application.Service.MaterialManagement; @@ -27,6 +29,8 @@ public class ProductManagementService : IDynamicApiController, ITransient public SapService.SapService _sapService; public SqlSugarRepository _obj118Rep; public Common.DataValidationService _dataValidationService; + public SqlSugarRepository _obj122Rep; + public SqlSugarRepository _obj121Rep; public ProductManagementService( SqlSugarRepository obj110Rep, @@ -35,7 +39,9 @@ public class ProductManagementService : IDynamicApiController, ITransient SqlSugarRepository configurationDataRep, SapService.SapService sapService, SqlSugarRepository obj118Rep, - DataValidationService dataValidationService + DataValidationService dataValidationService, + SqlSugarRepository obj122Rep, + SqlSugarRepository obj121Rep ) { @@ -46,6 +52,8 @@ public class ProductManagementService : IDynamicApiController, ITransient _sapService = sapService; _obj118Rep = obj118Rep; _dataValidationService = dataValidationService; + _obj122Rep= obj122Rep; + _obj121Rep= obj121Rep; } /// /// 分页查询产品管理 @@ -208,10 +216,10 @@ public class ProductManagementService : IDynamicApiController, ITransient { continue; } - int sun = i + 1; + //int sun = i + 1; var itemData = new ItemData() { - POSNR = sun.ToString(),//组件序号 + POSNR = "",//组件序号 sun.ToString() IDNRK = input[i].PartNumber,//组件物料号 MENGE = input[i].Quantity.ToString(),//组件数量 SORTF = input[i].fld004936, @@ -225,6 +233,39 @@ public class ProductManagementService : IDynamicApiController, ITransient itemDataList.Add(itemData); } + 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 Verification = await _dataValidationService.VerificationMaterial(BomData[i].ChildObjID, BomData[i].PartNumber, BomData[i].ChildGuid); + if (Verification == "不存在") + { + continue; + } + //int sun = i + 1; + var itemData = new ItemData() + { + POSNR = "",//组件序号 sun.ToString() + IDNRK = BomData[i].PartNumber,//组件物料号 + MENGE = BomData[i].Quantity.ToString(),//组件数量 + SORTF = BomData[i].fld004936, + ITISOB = BomData[i].fld004937, + ALPGR = BomData[i].fld004938, + ALPRF = BomData[i].fld004939, + ZDELETE = "X", + POSTP = BomData[i].fld004492, + ZYFMK = BomData[i].fld004941 + }; + itemDataList.Add(itemData); + } + + } + } + //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); @@ -255,7 +296,8 @@ public class ProductManagementService : IDynamicApiController, ITransient fld004631 = DateTime.Now, fld004315 = codeVal, fld004316 = "N", - fld004317 = apiOutput.msg + fld004317 = apiOutput.msg, + fld005288= input[0].ParentVersion.ToString()////////////////////////////////////////////////////////////xinixnixn }) .Where(it => it.idRecord == ParentData.idRecord) .ExecuteCommandAsync(); @@ -614,4 +656,117 @@ public class ProductManagementService : IDynamicApiController, ITransient return sapOutputList; } + /// + /// 产品管理-获取工艺路线 + /// + /// + /// + [ApiDescriptionSettings(Name = "GetProcessRoute", Description = "获取工艺路线", Order = 1000), HttpPost] + [DisplayName("获取工艺路线")] + public async Task> GetProcessRoute(BomPageProductManagementInput input) + { + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && x.ConfigLabel == "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) + .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); + return BomData; + } + + /// + /// 产品管理-工艺路线同步到SAP + /// + /// + /// + [ApiDescriptionSettings(Name = "SyncToSAPProcessRoute"), HttpPost] + [DisplayName("产品管理-工艺路线同步到SAP")] + public async Task SyncToSAPProcessRoute(List input) + { + var ParentData = await _obj110Rep.AsQueryable().Where(x => x.RecordGuid == input[0].ParentGuid && x.deleted == false && x.VersionIndex == input[0].ParentVersion).FirstAsync(); + + var itemDataList = new List(); + + for (int i = 0; i < input.Count; i++) + { + var Verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid); + if (Verification == "不存在") + { + continue; + } + + //获取工序描述 + var procedureDescription = await _obj122Rep.AsQueryable().Where(x => x.RecordGuid == input[i].ChildGuid).ToListAsync(); + //获取工作中心 + var workCenter = await _obj121Rep.AsQueryable().Where(x => x.RecordGuid == procedureDescription[0].fld005059_Rec).ToListAsync(); + //int sun = i + 1; + var itemData = new SapProcessRouteItemData() + { + VORNR = input[i].Marker, + LTXA1 = procedureDescription[0]._System_ObjDescription, + ARBPL = workCenter[0]._System_objNBS, + VGW01 = input[i].fld004994.ToString(), + VGE01 = input[i].fld004995, + STEUS = input[i].fld004996, + BMSCH = input[i].fld005296.ToString() + + }; + itemDataList.Add(itemData); + } + + //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid + string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); + + var Datuv = ParentData.fld004945.ToString(); + if (!string.IsNullOrEmpty(Datuv)) + { + Datuv = ParentData.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 = ParentData._System_objNBS, + Werks = ParentData.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 == ParentData.idRecord) + .ExecuteCommandAsync(); + var msg = apiOutput.msg; + if (apiOutput.msg == "") + { + msg = "同步成功"; + } + var output = new SapOutput() + { + parameter = apiOutput.parameter, + code = codeVal, + msg = msg, + result = apiOutput.result + }; + return output; + } } 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 7b0f57e..daf4648 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 @@ -14,6 +14,7 @@ using Vistar.Application.Common; using Vistar.Application.Const; using Vistar.Application.Entity; using Vistar.Application.SapService.Dto; +using Vistar.Application.Service.MaterialManagement.Dto; using Vistar.Application.Service.ProjectManagement.Dto; using Vistar.Application.Util; @@ -31,6 +32,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient private readonly SqlSugarRepository _configurationDataRep; public SqlSugarRepository _obj118Rep; public Common.DataValidationService _dataValidationService; + public SqlSugarRepository _obj122Rep; + public SqlSugarRepository _obj121Rep; public ProjectManagementService( SqlSugarRepository obj109Rep, @@ -39,7 +42,9 @@ public class ProjectManagementService : IDynamicApiController, ITransient SqlSugarRepository configurationsRep, SqlSugarRepository configurationDataRep, SqlSugarRepository obj118Rep, - DataValidationService dataValidationService + DataValidationService dataValidationService, + SqlSugarRepository obj122Rep, + SqlSugarRepository obj121Rep ) { _obj109Rep = obj109Rep; @@ -49,6 +54,8 @@ public class ProjectManagementService : IDynamicApiController, ITransient _configurationDataRep = configurationDataRep; _obj118Rep = obj118Rep; _dataValidationService = dataValidationService; + _obj122Rep = obj122Rep; + _obj121Rep = obj121Rep; } /// /// 分页查询项目管理 @@ -516,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 == 110 && x.ConfigLabel == "mBOM").FirstAsync(); + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigLabel == "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")) @@ -621,4 +628,116 @@ public class ProjectManagementService : IDynamicApiController, ITransient return sapOutputList; } + /// + /// 项目管理-获取工艺路线 + /// + /// + /// + [ApiDescriptionSettings(Name = "GetProcessRoute", Description = "获取工艺路线", Order = 1000), HttpPost] + [DisplayName("获取工艺路线")] + public async Task> GetProcessRoute(BomPageProductManagementInput input) + { + var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 109 && x.ConfigLabel == "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) + .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); + return BomData; + } + + /// + /// 项目管理-工艺路线同步到SAP + /// + /// + /// + [ApiDescriptionSettings(Name = "SyncToSAPProcessRoute"), HttpPost] + [DisplayName("项目管理-工艺路线同步到SAP")] + public async Task SyncToSAPProcessRoute(List input) + { + var ParentData = await _obj109Rep.AsQueryable().Where(x => x.RecordGuid == input[0].ParentGuid && x.deleted == false && x.VersionIndex == input[0].ParentVersion).FirstAsync(); + + var itemDataList = new List(); + + for (int i = 0; i < input.Count; i++) + { + var Verification = await _dataValidationService.VerificationMaterial(input[i].ChildObjID, input[i].PartNumber, input[i].ChildGuid); + if (Verification == "不存在") + { + continue; + } + + //获取工序描述 + var procedureDescription = await _obj122Rep.AsQueryable().Where(x => x.RecordGuid == input[i].ChildGuid).ToListAsync(); + //获取工作中心 + var workCenter = await _obj121Rep.AsQueryable().Where(x => x.RecordGuid == procedureDescription[0].fld005059_Rec).ToListAsync(); + //int sun = i + 1; + var itemData = new SapProcessRouteItemData() + { + VORNR = input[i].Marker, + LTXA1 = procedureDescription[0]._System_ObjDescription, + ARBPL = workCenter[0]._System_objNBS, + VGW01 = input[i].fld004994.ToString(), + VGE01 = input[i].fld004995, + STEUS = input[i].fld004996, + BMSCH = input[i].fld005298.ToString() + + }; + itemDataList.Add(itemData); + } + + //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid + string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); + var Datuv = ParentData.fld004949.ToString(); + if (!string.IsNullOrEmpty(Datuv)) + { + Datuv = ParentData.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 = ParentData._System_objNBS, + Werks = ParentData.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 == ParentData.idRecord) + .ExecuteCommandAsync(); + var msg = apiOutput.msg; + if (apiOutput.msg == "") + { + msg = "同步成功"; + } + var output = new SapOutput() + { + parameter = apiOutput.parameter, + code = codeVal, + msg = msg, + result = apiOutput.result + }; + return output; + } + } diff --git a/admin.net.pro/Web/src/api/materialManagement/productManagement.ts b/admin.net.pro/Web/src/api/materialManagement/productManagement.ts index 266275f..4a6f9e7 100644 --- a/admin.net.pro/Web/src/api/materialManagement/productManagement.ts +++ b/admin.net.pro/Web/src/api/materialManagement/productManagement.ts @@ -4,7 +4,10 @@ enum Api { SyncToSAPProductManagement = '/api/productManagement/SyncToSAP', GetetBOMProductManagement = '/api/productManagement/getBOM', SyncToSAPBomProductManagement = '/api/productManagement/syncToSAPBom', - BatchSyncToSAPProductManagement = '/api/productManagement/batchSyncToSAP' + BatchSyncToSAPProductManagement = '/api/productManagement/batchSyncToSAP', + GetetProcessRouteProductManagement = '/api/productManagement/getProcessRoute', + SyncToSAPProcessRouteProductManagement = '/api/productManagement/syncToSAPProcessRoute' + } // 分页查询产品管理 @@ -44,3 +47,18 @@ export const BatchSyncToSAPProductManagement = (params?: any) => method: 'post', data: params, }); + +// 分页查询产品管理工艺路线 +export const GetetProcessRouteProductManagement = (params?: any) => + request({ + url: Api.GetetProcessRouteProductManagement, + method: 'post', + data: params, + }); +// 工艺路线同步到sap +export const SyncToSAPProcessRouteProductManagement = (params?: any) => + request({ + url: Api.SyncToSAPProcessRouteProductManagement, + method: 'post', + data: params, + }); \ No newline at end of file diff --git a/admin.net.pro/Web/src/api/materialManagement/projectManagement.ts b/admin.net.pro/Web/src/api/materialManagement/projectManagement.ts index 04e8f8b..d22d45b 100644 --- a/admin.net.pro/Web/src/api/materialManagement/projectManagement.ts +++ b/admin.net.pro/Web/src/api/materialManagement/projectManagement.ts @@ -4,7 +4,9 @@ enum Api { SyncToSAPProjectManagement = '/api/projectManagement/SyncToSAP', GetBOMProjectManagement = '/api/projectManagement/getBOM', SyncToSAPBomProjectManagement = '/api/projectManagement/syncToSAPBom', - BatchSyncToSAPProjectManagement = '/api/projectManagement/batchSyncToSAP' + BatchSyncToSAPProjectManagement = '/api/projectManagement/batchSyncToSAP', + GetetProcessRouteProjectManagement = '/api/ProjectManagement/getProcessRoute', + SyncToSAPProcessRouteProjectManagement = '/api/ProjectManagement/syncToSAPProcessRoute' } // 分页查询产品管理 @@ -44,3 +46,18 @@ export const BatchSyncToSAPProjectManagement = (params?: any) => method: 'post', data: params, }); + +// 分页查询工艺路线 +export const GetetProcessRouteProjectManagement = (params?: any) => + request({ + url: Api.GetetProcessRouteProjectManagement, + method: 'post', + data: params, + }); +// 工艺路线同步到sap +export const SyncToSAPProcessRouteProjectManagement = (params?: any) => + request({ + url: Api.SyncToSAPProcessRouteProjectManagement, + method: 'post', + data: params, + }); \ No newline at end of file diff --git a/admin.net.pro/Web/src/views/materialManagement/productManagement/index.vue b/admin.net.pro/Web/src/views/materialManagement/productManagement/index.vue index 2a3ab1c..e32a4f9 100644 --- a/admin.net.pro/Web/src/views/materialManagement/productManagement/index.vue +++ b/admin.net.pro/Web/src/views/materialManagement/productManagement/index.vue @@ -53,8 +53,8 @@ 同步BOM - + 工艺路线 @@ -87,6 +87,25 @@ + + + + + + + + + + + + + + @@ -100,7 +119,7 @@ import { useVxeTable } from '/@/hooks/useVxeTableOptionsHook'; import { Local } from '/@/utils/storage'; import { formatDate } from '/@/utils/formatTime'; -import { PageProductManagement, SyncToSAPProductManagement, GetetBOMProductManagement, SyncToSAPBomProductManagement, BatchSyncToSAPProductManagement } from '/@/api/materialManagement/productManagement'; +import { PageProductManagement, SyncToSAPProductManagement, GetetBOMProductManagement, SyncToSAPBomProductManagement, BatchSyncToSAPProductManagement,GetetProcessRouteProductManagement,SyncToSAPProcessRouteProductManagement } from '/@/api/materialManagement/productManagement'; import { disable } from 'ol/rotationconstraint'; // 子窗口对象 @@ -266,6 +285,8 @@ const examineBom = async (row: any) => { const showBom = ref(false); + + // 变量 const stateBom = reactive({ showAdvanceQueryUI: false, @@ -379,6 +400,101 @@ const batchSyncToSAP = async () => { .catch(() => { }); options.loading = false; } + +// 工艺路线查询操作 +//父Guid +const processRoutexGrid = ref(); +// 查看BOM +const examineProcessRoute = async (row: any) => { + stateProcessRoute.queryParams.ParentGuid = row.recordGuid; + showProcessRoute.value = true; + await handleQueryProcessRoute(); +}; + +const showProcessRoute = ref(false); + +// 变量 +const stateProcessRoute = reactive({ + showAdvanceQueryUI: false, + queryParams: { + PartNumber: undefined, + Description: undefined, + ParentGuid: undefined + }, + localPageParam: { + pageSize: 50 as number, + defaultSort: { field: 'createTime', order: 'asc', descStr: 'desc' }, + }, + visible: false, + title: '', +}); + +// 本地存储参数 +const localPageParamKeyProcessRoute = 'localPageParam:productManagementProcessRoute'; + +// 表格参数配置 +const processRouteOptions = useVxeTable( + { + id: 'productManagementProcessRoute', + name: '产品管理', + columns: [ + { type: 'seq', title: '序号', width: 60 }, + { field: 'partNumber', title: '物料编码', minWidth: 100, showOverflow: 'tooltip', sortable: false }, + { field: 'description', title: '物料描述', minWidth: 100, showOverflow: 'tooltip', sortable: false }, + { field: 'quantity', title: '数量', minWidth: 100, showOverflow: 'tooltip', sortable: false }, + ], + }, + // vxeGrid配置参数(此处可覆写任何参数),参考vxe-table官方文档 + { + // 代理配置 + proxyConfig: { autoLoad: true, ajax: { query: ({ page, sort }) => handleProcessRouteQueryApi(page, sort) } }, + // 排序配置 + sortConfig: { defaultSort: Local.get(localPageParamKeyProcessRoute)?.defaultSort || stateBom.localPageParam.defaultSort }, + // 分页配置 + pagerConfig: { pageSize: Local.get(localPageParamKeyProcessRoute)?.pageSize || stateBom.localPageParam.pageSize }, + // 工具栏配置 + toolbarConfig: { export: false }, + // 行设置 + // rowConfig: { height: 80 }, + } +); + +// 工艺路线 查询 API +const handleProcessRouteQueryApi = async (page: VxeGridPropTypes.ProxyAjaxQueryPageParams, sort: VxeGridPropTypes.ProxyAjaxQuerySortCheckedParams) => { + const params = Object.assign(stateProcessRoute.queryParams, { page: page.currentPage, pageSize: page.pageSize, field: sort.field, order: sort.order, descStr: 'desc' }); + var data = GetetProcessRouteProductManagement(params); + return data; +}; + +const handleQueryProcessRoute = async (reset = false) => { + processRouteOptions.loading = true; + await processRoutexGrid.value?.commitProxy('query'); + processRouteOptions.loading = false; +}; + +//工艺路线同步到sap +const syncToSAPprocessRoute = async () => { + options.loading = true; + var data = processRoutexGrid.value?.getTableData().fullData; + ElMessageBox.confirm(`确定要同步工艺路线吗?`, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + .then(async () => { + var output = await SyncToSAPProcessRouteProductManagement(data); + await handleQuery(); + if (output.data.result.code == "成功") { + ElMessage.success("同步成功"); + } else { + ElMessage.error("同步失败"); + } + }) + .catch(() => { }); + options.loading = false; +} + +