diff --git a/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapBomInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapBomInput.cs
index 36154d9..7d82a8c 100644
--- a/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapBomInput.cs
+++ b/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapBomInput.cs
@@ -120,4 +120,8 @@ public class ItemData
/// 研发模块
///
public string ZYFMK { get; set; }
+ ///
+ /// 子件guid
+ ///
+ public string? ChildGuid { get; set; }
}
diff --git a/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapPriceQueryInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapPriceQueryInput.cs
new file mode 100644
index 0000000..f378d83
--- /dev/null
+++ b/admin.net.pro/Admin.NET/Vistar.Application/SapService/Dto/SapPriceQueryInput.cs
@@ -0,0 +1,16 @@
+// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
+//
+// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
+//
+// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Vistar.Application.SapService.Dto;
+public class SapPriceQueryInput: SapEcnQueryInput
+{
+}
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 89e94c6..973a314 100644
--- a/admin.net.pro/Admin.NET/Vistar.Application/SapService/SapService.cs
+++ b/admin.net.pro/Admin.NET/Vistar.Application/SapService/SapService.cs
@@ -11,6 +11,7 @@ using DocumentFormat.OpenXml.Spreadsheet;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using MailKit;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using OnceMi.AspNetCore.OSS;
using System;
using System.Collections.Generic;
@@ -1218,4 +1219,128 @@ public class SapService : IDynamicApiController, ITransient
}
+ ///
+ /// SAP 成本查询服务
+ ///
+ ///
+ ///
+ public async Task SapPriceQueryApi(SapPriceQueryInput input)
+ {
+ // 创建命名空间
+ XNamespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/";
+ XNamespace urn = "urn:sap-com:document:sap:rfc:functions";
+ // 创建 SOAP XML 请求
+ var soapEnvelope = new XDocument(
+ new XDeclaration("1.0", "utf-8", "yes"),
+ new XElement(soapenv + "Envelope",
+ new XAttribute(XNamespace.Xmlns + "soapenv", soapenv.NamespaceName),
+ new XAttribute(XNamespace.Xmlns + "urn", urn.NamespaceName),
+ new XElement(soapenv + "Header"),
+ new XElement(soapenv + "Body",
+ new XElement(urn + "ZFIFM006",
+ new XElement("IS_DATA",
+ new XElement("IT_MATNR",
+ new XElement("item",
+ new XElement("SIGN", input.Sign),
+ new XElement("OPTION", input.Option),
+ new XElement("LOW", input.Low),
+ new XElement("HIGH", input.High)
+ )
+ )
+ ),
+ 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)
+ )
+ )
+ )
+ )
+ );
+ 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");
+ httpClient.DefaultRequestHeaders.Add("Accept-Language", "zh");
+ // 设置 SAP Web 服务的 URL
+ //sap正式地址
+ var url = "https://vhjqeps4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/ZFIFM006/800/ZFIFM006/ZFIFM006";
+
+ //sap测试地址
+ //var url = "https://vhjqeds4ci.sap.vistar-eq.com:44300/sap/bc/srt/rfc/sap/ZFIFM006/130/ZFIFM006/ZFIFM006";
+
+ // 发起 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 esRet = doc.Descendants("ES_RET").FirstOrDefault();
+ var code = esRet?.Element("CODE")?.Value;
+
+ var item = doc.Descendants("item").FirstOrDefault();
+ var bwkey = item?.Element("BWKEY")?.Value;
+ var matnr = item?.Element("MATNR")?.Value;
+ var verpr = item?.Element("VERPR")?.Value;
+
+
+ var output = new SapPriceQueryOutput()
+ {
+ Parameter = soapEnvelope.ToString(),
+ Code = code,
+ Matnr = matnr,
+ Bwkey = bwkey,
+ Verpr = verpr,
+ Result = result
+ };
+ return output;
+ }
+ else
+ {
+ var result = await response.Content.ReadAsStringAsync();
+ var output = new SapPriceQueryOutput()
+ {
+ Parameter = soapEnvelope.ToString(),
+ Code = "失败",
+ Result = result
+ };
+ return output;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+
+ // 记录错误日志
+ Console.WriteLine("发生错误: " + ex.Message);
+ var output = new SapPriceQueryOutput()
+ {
+ Code = "失败",
+ Result = "发生错误" + ex
+ };
+ return output;
+ }
+
+ }
+
}
\ No newline at end of file
diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Util/SapOutput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Util/SapOutput.cs
index f7664ff..6a95f52 100644
--- a/admin.net.pro/Admin.NET/Vistar.Application/Util/SapOutput.cs
+++ b/admin.net.pro/Admin.NET/Vistar.Application/Util/SapOutput.cs
@@ -79,7 +79,42 @@ public class SapEcnQueryOutput
/// 更新日期
///
public DateTime DateUpdated { get; set; }
-
-
-
+}
+
+public class SapPriceQueryOutput
+{
+ ///
+ /// sap入参
+ ///
+ public string Parameter { get; set; }
+
+ ///
+ /// 消息类型
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// 物料编码
+ ///
+ public string Matnr { get; set; }
+
+ ///
+ /// 工厂
+ ///
+ public string Bwkey { get; set; }
+
+ ///
+ /// 价格
+ ///
+ public string Verpr { get; set; }
+
+ ///
+ /// sap出参
+ ///
+ public string Result { get; set; }
+
+ ///
+ /// 更新日期
+ ///
+ public DateTime DateUpdated { get; set; }
}