diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj112.cs b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj112.cs
index 165eed0..552e90a 100644
--- a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj112.cs
+++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj112.cs
@@ -522,5 +522,35 @@ public class Obj112
///
[SugarColumn(ColumnName = "fld005323", ColumnDescription = "", Length = -1)]
public string? fld005323 { get; set; }
-
+
+ ///
+ /// 预留
+ ///
+ public string? fld006750 { get; set; }
+
+ ///
+ /// 库存
+ ///
+ public string? fld006751 { get; set; }
+
+ ///
+ /// 未清采购订单数量
+ ///
+ public string? fld006752 { get; set; }
+
+ ///
+ /// 未清采购申请数量
+ ///
+ public string? fld006753 { get; set; }
+
+ ///
+ /// 成本
+ ///
+ public string? fld006754 { get; set; }
+
+ ///
+ /// 库存更新日期
+ ///
+ public DateTime fld006755 { get; set; }
+
}
diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj137.cs b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj137.cs
index 878ed71..de5e85a 100644
--- a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj137.cs
+++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj137.cs
@@ -1378,4 +1378,33 @@ public class Obj137
public string? fld005679_Rec { get; set; }
public DateTime? fld005680 { get; set; }
public string? fld005686 { get; set; }
+ ///
+ /// 预留
+ ///
+ public string? fld006530 { get; set; }
+
+ ///
+ /// 库存
+ ///
+ public string? fld005623 { get; set; }
+
+ ///
+ /// 未清采购订单数量
+ ///
+ public string? fld006531 { get; set; }
+
+ ///
+ /// 未清采购申请数量
+ ///
+ public string? fld006532 { get; set; }
+
+ ///
+ /// 成本
+ ///
+ public string? fld005625 { get; set; }
+
+ ///
+ /// 库存更新日期
+ ///
+ public DateTime fld005624 { get; set; }
}
diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/Dto/BomStockInquiryOutput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/Dto/BomStockInquiryOutput.cs
new file mode 100644
index 0000000..45b0629
--- /dev/null
+++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/Dto/BomStockInquiryOutput.cs
@@ -0,0 +1,112 @@
+// 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.Service.StockInquiry.Dto;
+public class BomStockInquiryOutput
+{
+ ///
+ /// 物料编码
+ ///
+ public string materialCode { get; set; }
+
+ ///
+ /// 物料描述
+ ///
+ public string materialName { get; set; }
+
+ ///
+ /// sap入参
+ ///
+ public string Parameter { get; set; }
+
+ ///
+ /// 消息类型
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// 物料编码
+ ///
+ public string Matnr { get; set; }
+
+ ///
+ /// 工厂
+ ///
+ public string Werks { get; set; }
+
+ ///
+ /// 预留需求数量
+ ///
+ public string Bdmng { get; set; }
+
+ ///
+ /// 库存
+ ///
+ public string Labst { get; set; }
+
+ ///
+ /// 未清采购申请数量
+ ///
+ public string ZwqslPr { get; set; }
+
+ ///
+ /// 未清采购订单数量
+ ///
+ public string ZwqslPo { get; set; }
+ ///
+ /// 基本计量单位
+ ///
+ public string Meins { get; set; }
+
+ ///
+ /// sap出参
+ ///
+ public string Result { get; set; }
+
+ ///
+ /// 更新日期
+ ///
+ public DateTime DateUpdated { get; set; }
+
+ ///
+ /// 查询状态
+ ///
+ public string State { get; set; }
+}
+
+
+public class BomStockInquiryUpdateable
+{
+ public long Objectid { get; set; }
+ public string RecordGuid { get; set; }
+ public string Code { get; set; }
+ ///
+ /// 预留需求数量
+ ///
+ public string Bdmng { get; set; }
+
+ ///
+ /// 库存
+ ///
+ public string Labst { get; set; }
+
+ ///
+ /// 未清采购申请数量
+ ///
+ public string ZwqslPr { get; set; }
+
+ ///
+ /// 未清采购订单数量
+ ///
+ public string ZwqslPo { get; set; }
+ public DateTime DateUpdated { get; set; }
+}
diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/Dto/RawMaterialInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/Dto/RawMaterialInput.cs
new file mode 100644
index 0000000..bfa4608
--- /dev/null
+++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/Dto/RawMaterialInput.cs
@@ -0,0 +1,17 @@
+// 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.Service.StockInquiry.Dto;
+public class RawMaterialInput
+{
+ public string? materialCode { get; set; }
+}
diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/Dto/RawMaterialOutput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/Dto/RawMaterialOutput.cs
new file mode 100644
index 0000000..695b343
--- /dev/null
+++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/Dto/RawMaterialOutput.cs
@@ -0,0 +1,19 @@
+// 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.Service.StockInquiry.Dto;
+public class RawMaterialOutput
+{
+ public long? idRecord { get; set; }
+ public string _System_objNBS { get; set; }
+ public string _System_objDescription { get; set; }
+}
diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/StockInquiryService.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/StockInquiryService.cs
new file mode 100644
index 0000000..5b30521
--- /dev/null
+++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/StockInquiry/StockInquiryService.cs
@@ -0,0 +1,378 @@
+// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
+//
+// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
+//
+// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
+
+using Admin.NET.Core;
+using Admin.NET.Core.Service;
+using Furion.DependencyInjection;
+using Furion.DynamicApiController;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Vistar.Application.Common;
+using Vistar.Application.Const;
+using Vistar.Application.Entity;
+using Vistar.Application.SapService.Dto;
+using Vistar.Application.Service.StockInquiry.Dto;
+using Vistar.Application.Util;
+
+namespace Vistar.Application.Service.StockInquiry;
+
+[ApiDescriptionSettings(ApplicationConst.GroupName, Name = "StockInquiry", Order = 100)]
+public class StockInquiryService : IDynamicApiController, ITransient
+{
+ public Common.DataValidationService _dataValidationService;
+ public SqlSugarRepository _obj137Rep;
+ public SqlSugarRepository _obj112Rep;
+ public SqlSugarRepository _configurationDataRep;
+ public SolidWorksManageService.SolidWorksManageService _solidWorksManageService;
+ private readonly SysConfigService _sysConfigService;
+ public SapService.SapService _sapService;
+ public StockInquiryService
+ (
+ DataValidationService dataValidationService,
+ SqlSugarRepository obj137Rep,
+ SqlSugarRepository obj112Rep,
+ SqlSugarRepository configurationDataRep,
+ SolidWorksManageService.SolidWorksManageService solidWorksManageService,
+ SysConfigService sysConfigService,
+ SapService.SapService sapService
+ )
+ {
+ _obj137Rep = obj137Rep;
+ _obj112Rep = obj112Rep;
+ _configurationDataRep = configurationDataRep;
+ _solidWorksManageService = solidWorksManageService;
+ _sysConfigService = sysConfigService;
+ _sapService = sapService;
+ _dataValidationService = dataValidationService;
+ }
+
+ ///
+ /// 产品管理库-库存查询
+ ///
+ ///
+ ///
+ [ApiDescriptionSettings(Name = "GetProductInventory", Description = "产品管理库-库存查询", Order = 1000), HttpGet]
+ [DisplayName("产品管理库-库存查询")]
+ [AllowAnonymous]
+ public async Task GetProductInventory(string materialCode)
+ {
+ var Requser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName);
+
+ var SapEcnQueryData = new SapEcnQueryInput
+ {
+ Reqkeyid = "",
+ Businessid = "",
+ Messageid = "",
+ Sndprn = "PLM",
+ Rcvprn = "SAP",
+ Requser = Requser,
+ Note1 = "",
+ Note2 = "",
+ Note3 = "",
+ Sign = "I",
+ Option = "EQ",
+ Low = materialCode,
+ High = ""
+ };
+
+ var apiOutput = await _sapService.SapEcnQueryApi(SapEcnQueryData);
+
+ if (apiOutput.Code == "S")
+ {
+ var data = await _obj137Rep.AsQueryable().Where(x => x._System_objNBS == materialCode && x.deleted == false).OrderByDescending(x => x.idRecord).FirstAsync();
+ if (data != null)
+ {
+ apiOutput.DateUpdated = DateTime.Now;
+ await _obj137Rep.AsUpdateable().SetColumns(it => new Obj137
+ {
+ fld006530 = apiOutput.Bdmng,
+ fld005623 = apiOutput.Labst,
+ fld006531 = apiOutput.ZwqslPo,
+ fld006532 = apiOutput.ZwqslPr,
+ fld005624 = apiOutput.DateUpdated
+ })
+ .Where(it => it.idRecord == data.idRecord)
+ .ExecuteCommandAsync();
+ return apiOutput;
+ }
+ var RawMaterialData = await _obj112Rep.AsQueryable().Where(x => x._System_objNBS == materialCode && x.deleted == false).FirstAsync();
+ if (RawMaterialData != null)
+ {
+ apiOutput.DateUpdated = DateTime.Now;
+ await _obj112Rep.AsUpdateable().SetColumns(it => new Obj112
+ {
+ fld006750 = apiOutput.Bdmng,
+ fld006751 = apiOutput.Labst,
+ fld006752 = apiOutput.ZwqslPo,
+ fld006753 = apiOutput.ZwqslPr,
+ fld006755 = apiOutput.DateUpdated
+ })
+ .Where(it => it.idRecord == RawMaterialData.idRecord)
+ .ExecuteCommandAsync();
+ return apiOutput;
+ }
+ }
+
+ return apiOutput;
+ }
+
+ ///
+ /// 产品管理库-Bom库存查询
+ ///
+ ///
+ ///
+ [ApiDescriptionSettings(Name = "GetBomProductInventory", Description = "产品管理库-Bom库存查询", Order = 1000), HttpGet]
+ [DisplayName("产品管理库-库存查询")]
+ [AllowAnonymous]
+ public async Task> GetBomProductInventory(string materialCode)
+ {
+ var Requser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName);
+
+ var materialData = await _obj137Rep.AsQueryable()
+ .Where(x => x._System_objNBS == materialCode && x.deleted == false)
+ .OrderByDescending(x => x.idRecord)
+ .FirstAsync();
+
+ var bomList = await _configurationDataRep.AsQueryable()
+ .Where(x => x.ParentGuid == materialData.RecordGuid && x.isDeleted == false
+ && x.ParentVersion == materialData.VersionIndex
+ && (x.fld005577 != "不包含" || x.fld005577 == null)
+ && x.isSuppressed == false && x.inContext == false)
+ .ToListAsync();
+
+ var UpdateableList = new List();
+
+ var tasks = bomList.Select(async item =>
+ {
+ var code = item.PartNumber;
+ var name = item.Description;
+ var objectid = item.ChildObjID;
+ var childGuid = item.ChildGuid;
+
+ var SapEcnQueryData = new SapEcnQueryInput
+ {
+ Reqkeyid = "",
+ Businessid = "",
+ Messageid = "",
+ Sndprn = "PLM",
+ Rcvprn = "SAP",
+ Requser = Requser,
+ Note1 = "",
+ Note2 = "",
+ Note3 = "",
+ Sign = "I",
+ Option = "EQ",
+ Low = code,
+ High = ""
+ };
+
+ var apiOutput = await _sapService.SapEcnQueryApi(SapEcnQueryData);
+ var dateUpdated = DateTime.Now;
+ if (apiOutput.Code == "S")
+ {
+ var UpdateableData = new BomStockInquiryUpdateable
+ {
+ Objectid = objectid,
+ Code = apiOutput.Code,
+ RecordGuid = childGuid,
+ Bdmng = apiOutput.Bdmng,
+ Labst = apiOutput.Labst,
+ ZwqslPo = apiOutput.ZwqslPo,
+ ZwqslPr = apiOutput.ZwqslPr,
+ DateUpdated = dateUpdated
+ };
+ UpdateableList.Add(UpdateableData);
+ }
+ else
+ {
+ var UpdateableData = new BomStockInquiryUpdateable
+ {
+ Code = "",
+ RecordGuid = "",
+ Bdmng = "",
+ Labst = "",
+ ZwqslPo = "",
+ ZwqslPr = "",
+ DateUpdated = dateUpdated
+ };
+ UpdateableList.Add(UpdateableData);
+ }
+ if (apiOutput.Code == "S")
+ {
+ return new BomStockInquiryOutput
+ {
+ materialCode = code,
+ materialName = name,
+ Labst = apiOutput.Labst,
+ Bdmng = apiOutput.Bdmng,
+ ZwqslPr = apiOutput.ZwqslPr,
+ ZwqslPo = apiOutput.ZwqslPo,
+ DateUpdated = dateUpdated,
+ State = "查询成功"
+ };
+ }
+ else
+ {
+ return new BomStockInquiryOutput
+ {
+ materialCode = code,
+ materialName = name,
+ State = "SAP未查询库存信息"
+ };
+ }
+ });
+
+ var bomStockInquiryOutput = await Task.WhenAll(tasks);
+
+ foreach (var item in UpdateableList)
+ {
+ await _dataValidationService.ModifyInventoryInformation(item.RecordGuid, item.Code, item.Objectid, item.Bdmng, item.Labst, item.ZwqslPo, item.ZwqslPr, item.DateUpdated);
+ }
+
+ return bomStockInquiryOutput.ToList();
+ }
+
+ ///
+ /// 获取原材料
+ ///
+ ///
+ ///
+ [ApiDescriptionSettings(Name = "GetRawMaterial", Description = "获取原材料", Order = 1000), HttpPost]
+ [DisplayName("获取原材料")]
+ [AllowAnonymous]
+ public async Task> GetRawMaterial(RawMaterialInput input)
+ {
+ var data = await _obj112Rep.AsQueryable()
+ .Where(x => x.deleted == false)
+ .WhereIF(!string.IsNullOrWhiteSpace(input.materialCode), u => u._System_objNBS.Contains(input.materialCode.Trim()))
+ .Select()
+ .ToListAsync();
+ return data;
+ }
+
+ ///
+ /// 原材料库存查询
+ ///
+ ///
+ [ApiDescriptionSettings(Name = "RawMaterialStockInquiry", Description = "原材料库存查询", Order = 1000), HttpGet]
+ [DisplayName("原材料库存查询")]
+ [AllowAnonymous]
+ public async Task> RawMaterialStockInquiry()
+ {
+ var Requser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName);
+ var data = await _obj112Rep.AsQueryable()
+ .Where(x => x.deleted == false)
+ .Select()
+ .ToListAsync();
+ var UpdateableList = new List();
+
+ var tasks = data.Select(async item =>
+ {
+ var code = item._System_objNBS;
+ var name = item._System_objDescription;
+ var objectid = 112;
+ var id = item.idRecord;
+ var SapEcnQueryData = new SapEcnQueryInput
+ {
+ Reqkeyid = "",
+ Businessid = "",
+ Messageid = "",
+ Sndprn = "PLM",
+ Rcvprn = "SAP",
+ Requser = Requser,
+ Note1 = "",
+ Note2 = "",
+ Note3 = "",
+ Sign = "I",
+ Option = "EQ",
+ Low = code,
+ High = ""
+ };
+
+ var apiOutput = await _sapService.SapEcnQueryApi(SapEcnQueryData);
+ var dateUpdated = DateTime.Now;
+ if (apiOutput.Code == "S")
+ {
+ var UpdateableData = new BomStockInquiryUpdateable
+ {
+ Objectid = objectid,
+ Code = apiOutput.Code,
+ RecordGuid = id.ToString(),
+ Bdmng = apiOutput.Bdmng,
+ Labst = apiOutput.Labst,
+ ZwqslPo = apiOutput.ZwqslPo,
+ ZwqslPr = apiOutput.ZwqslPr,
+ DateUpdated = dateUpdated
+ };
+ UpdateableList.Add(UpdateableData);
+ }
+ else
+ {
+ var UpdateableData = new BomStockInquiryUpdateable
+ {
+ Code = "",
+ RecordGuid = "",
+ Bdmng = "",
+ Labst = "",
+ ZwqslPo = "",
+ ZwqslPr = "",
+ DateUpdated = dateUpdated
+ };
+ UpdateableList.Add(UpdateableData);
+ }
+ if (apiOutput.Code == "S")
+ {
+ return new BomStockInquiryOutput
+ {
+ materialCode = code,
+ materialName = name,
+ Labst = apiOutput.Labst,
+ Bdmng = apiOutput.Bdmng,
+ ZwqslPr = apiOutput.ZwqslPr,
+ ZwqslPo = apiOutput.ZwqslPo,
+ DateUpdated = dateUpdated,
+ State = "查询成功"
+ };
+ }
+ else
+ {
+ return new BomStockInquiryOutput
+ {
+ materialCode = code,
+ materialName = name,
+ State = "SAP未查询库存信息"
+ };
+ }
+ });
+
+ var bomStockInquiryOutput = await Task.WhenAll(tasks);
+ foreach (var item in UpdateableList)
+ {
+ var dateUpdated = DateTime.Now;
+ await _obj112Rep.AsUpdateable().SetColumns(it => new Obj112
+ {
+ fld006750 = item.Bdmng,
+ fld006751 = item.Labst,
+ fld006752 = item.ZwqslPo,
+ fld006753 = item.ZwqslPr,
+ fld006755 = dateUpdated
+ })
+ .Where(it => it.idRecord == Convert.ToInt32(item.RecordGuid))
+ .ExecuteCommandAsync();
+ }
+
+ return bomStockInquiryOutput.ToList();
+ }
+
+}
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 aea7200..5bef659 100644
--- a/admin.net.pro/Admin.NET/Vistar.Application/Util/SapOutput.cs
+++ b/admin.net.pro/Admin.NET/Vistar.Application/Util/SapOutput.cs
@@ -23,3 +23,63 @@ public class SapOutput
public string result { get; set; }
public string? banfn { get; set; }
}
+
+public class SapEcnQueryOutput
+{
+ ///
+ /// sap入参
+ ///
+ public string Parameter { get; set; }
+
+ ///
+ /// 消息类型
+ ///
+ public string Code { get; set; }
+
+ ///
+ /// 物料编码
+ ///
+ public string Matnr { get; set; }
+
+ ///
+ /// 工厂
+ ///
+ public string Werks { get; set; }
+
+ ///
+ /// 预留需求数量
+ ///
+ public string Bdmng { get; set; }
+
+ ///
+ /// 库存
+ ///
+ public string Labst { get; set; }
+
+ ///
+ /// 未清采购申请数量
+ ///
+ public string ZwqslPr { get; set; }
+
+ ///
+ /// 未清采购订单数量
+ ///
+ public string ZwqslPo { get; set; }
+ ///
+ /// 基本计量单位
+ ///
+ public string Meins { get; set; }
+
+ ///
+ /// sap出参
+ ///
+ public string Result { get; set; }
+
+ ///
+ /// 更新日期
+ ///
+ public DateTime DateUpdated { get; set; }
+
+
+
+}