From aa508e9cfa11c2bf1b2144844628c77ae2c70bcf Mon Sep 17 00:00:00 2001 From: bairubing Date: Thu, 26 Sep 2024 11:23:07 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8E=E7=94=9F=E4=BA=A7=E7=89=A9?= =?UTF-8?q?=E6=96=99=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Vistar.Application/Entity/Obj109.cs | 3 +- .../Vistar.Application/Entity/Obj112.cs | 2 +- .../ProductManagementService.cs | 2 +- .../Dto/ProductionMaterialsManagementInput.cs | 347 +++++++++++++++ .../ProductionMaterialsManagementOutput.cs | 315 ++++++++++++++ .../ProductionMaterialsManagementService.cs | 394 ++++++++++++++++++ .../Dto/ProjectManagementInput.cs | 3 +- .../Dto/ProjectManagementOutput.cs | 1 + .../ProjectManagementService.cs | 22 +- .../Vistar.Application.csproj | 6 + .../productionMaterialsManagement.ts | 30 ++ .../ProductionMaterialsManagement/index.vue | 226 ++++++++++ 12 files changed, 1335 insertions(+), 16 deletions(-) create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/Dto/ProductionMaterialsManagementInput.cs create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/Dto/ProductionMaterialsManagementOutput.cs create mode 100644 admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/ProductionMaterialsManagementService.cs create mode 100644 admin.net.pro/Web/src/api/materialManagement/productionMaterialsManagement.ts create mode 100644 admin.net.pro/Web/src/views/materialManagement/ProductionMaterialsManagement/index.vue diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj109.cs b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj109.cs index 0a79c64..95a40be 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj109.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj109.cs @@ -812,5 +812,6 @@ public class Obj109 /// [SugarColumn(ColumnName = "fld005040", ColumnDescription = "", Length = -1)] public string? fld005040 { get; set; } - + public string fld005281 { get; set; } + } 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 90b2b9d..c382780 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj112.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Entity/Obj112.cs @@ -27,7 +27,7 @@ public class Obj112 /// /// [SugarColumn(ColumnName = "CheckedStatus", ColumnDescription = "")] - public bool? CheckedStatus { get; set; } + public int? CheckedStatus { 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 fc9276b..a9c194d 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 @@ -311,7 +311,7 @@ public class ProductManagementService : IDynamicApiController, ITransient }); continue; } - if (input[i].fld004312 == "N") + if (input[i].fld004312 != "A" || input[i].fld004312 != "M") { SapOutputList.Add(new SapOutput() { diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/Dto/ProductionMaterialsManagementInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/Dto/ProductionMaterialsManagementInput.cs new file mode 100644 index 0000000..6e1ab2e --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/Dto/ProductionMaterialsManagementInput.cs @@ -0,0 +1,347 @@ +// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 +// +// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 +// +// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! + +using Admin.NET.Core; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Vistar.Application.Service.ProductionMaterialsManagement.Dto; +/// +/// 生产物料管理输入参数 +/// +public class ProductionMaterialsManagementInput +{ + /// + /// + /// + public long idRecord { get; set; } + + public int? CheckedStatus { get; set; } + + public int? VersionIndex { get; set; } + + public bool? IsLatestVersion { get; set; } + + public DateTime? CreatedDate { get; set; } + + public DateTime? VersionCreatedDate { get; set; } + + public DateTime? dateModified { get; set; } + + public long? UserCreatedId { get; set; } + + public long? VersionUserCreatedId { get; set; } + + public long? UserModifiedId { get; set; } + + public string? RecordGuid { get; set; } + + public bool? isVisibilityNormal { get; set; } + + public bool? deleted { get; set; } + + public string? SubObjectGuid { get; set; } + + public bool? PreviousStatus { get; set; } + + public string? revision { get; set; } + + public byte[]? Record_image160_160 { get; set; } + + public byte[]? Record_Image320_240 { get; set; } + + public byte[]? Record_ImageMax { get; set; } + + public string? _System_objNBS { get; set; } + + public string? _System_ObjDescription { get; set; } + + public DateTime? _System_Effectivity_Begin { get; set; } + + public DateTime? _System_Effectivity_End { get; set; } + + public string? CheckedOutPc { get; set; } + + public long? GroupObjId { get; set; } + + public bool? _CheckOutInProgress { get; set; } + + public bool? EnableNotifications { get; set; } + + /// + /// + /// + public string? _system_objConfigurationName { get; set; } + + /// + /// + /// + public bool? _system_objConfigurationType { get; set; } + + /// + /// + /// + public string? _system_objConfigurationGuid { get; set; } + + /// + /// + /// + public string ShowBomFromConfiguration { get; set; } + + /// + /// + /// + public string _System_ObjNbsAuto { get; set; } + + /// + /// + /// + public string? _System_DerivedFrom { get; set; } + + /// + /// + /// + public string? _System_DerivedFrom_RecordGuid { get; set; } + + /// + /// + /// + public bool? _system_objLinkedCompare { get; set; } + + /// + /// + /// + public bool? isReleasedVersion { get; set; } + + /// + /// + /// + public string? _System_WebLink { get; set; } + + /// + /// + /// + public bool? LinkDrw { get; set; } + + /// + /// + /// + public string? ParentRecordGuid { get; set; } + + /// + /// 品牌 + /// + public string? fld004592 { get; set; } + + /// + /// 材料 + /// + public string? fld004593 { get; set; } + + /// + /// 单位 + /// + public string? fld004594 { get; set; } + + /// + /// 行业领域 + /// + public string? fld004595 { get; set; } + + /// + /// 物料类型 + /// + public string? fld004596 { get; set; } + + /// + /// 工厂 + /// + public string? fld004597 { get; set; } + + /// + /// 物料描述 + /// + public string? fld004598 { get; set; } + + /// + /// 物料组 + /// + public string? fld004599 { get; set; } + + /// + /// 采购类型 + /// + public string? fld004600 { get; set; } + + /// + /// 特殊采购 + /// + public string? fld004601 { get; set; } + + /// + /// 散装物料 + /// + public string? fld004602 { get; set; } + + /// + /// 反冲 + /// + public string? fld004603 { get; set; } + + /// + /// 物料同步状态 + /// + public string? fld004604 { get; set; } + + /// + /// 物料同步信息 + /// + public string? fld004605 { get; set; } + + /// + /// 物料同步时间 + /// + public DateTime? fld004606 { get; set; } + + /// + /// 物料同步标识 A:新增 M:修改 D:停用 N:已处理 + /// + public string? fld004607 { get; set; } + + /// + /// 创建人员 + /// + public long? fld004608 { get; set; } + + /// + /// 创建人员ID + /// + public string? fld004608_Rec { get; set; } + + /// + /// 创建日期 + /// + public DateTime? fld004609 { get; set; } + + /// + /// 审核人员 + /// + public long? fld004610 { get; set; } + + /// + /// 审核人员ID + /// + public string? fld004610_Rec { get; set; } + + /// + /// 审核日期 + /// + public DateTime? fld004611 { get; set; } + + /// + /// 物料状态 + /// + public string? fld004612 { get; set; } + + /// + /// 一级分类代号 + /// + public string? fld004613 { get; set; } + + /// + /// 二级分类代号 + /// + public string? fld004614 { get; set; } + + /// + /// 三级分类代号 + /// + public string? fld004615 { get; set; } + + /// + /// 四级分类代号 + /// + public string? fld004616 { get; set; } + + /// + /// 一级分类 + /// + public string? fld004617 { get; set; } + + /// + /// 二级分类 + /// + public string? fld004618 { get; set; } + + /// + /// 三级分类 + /// + public string? fld004619 { get; set; } + + /// + /// 四级分类 + /// + public string? fld004620 { get; set; } + + public string? fld004695 { get; set; } + + public string? fld004696 { get; set; } + + public string? fld004697 { get; set; } + + public string? fld004901 { get; set; } + + public string? fld004902 { get; set; } + + public string? fld004903 { get; set; } + + public string? fld004904 { get; set; } + + public double? fld004905 { get; set; } + + public double? fld004907 { get; set; } + + public string? fld004908 { get; set; } + + public string? fld004909 { get; set; } + + public string? fld004910 { get; set; } + + public string? fld004911 { get; set; } + + public string? fld004973 { get; set; } +} + +/// +/// 生产物料管理查询输入参数 +/// +public class PageProductionMaterialsManagementInput : BasePageInput +{ + /// + /// 物料编码 + /// + public string? _System_objNBS { get; set; } + + /// + /// 物料描述 + /// + public string? fld004598 { get; set; } + + /// + /// 创建时间 + /// + public DateTime? fld004609 { get; set; } + + /// + /// 创建时间范围 + /// + public DateTime?[] fld004609Range { get; set; } +} \ No newline at end of file diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/Dto/ProductionMaterialsManagementOutput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/Dto/ProductionMaterialsManagementOutput.cs new file mode 100644 index 0000000..ac93250 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/Dto/ProductionMaterialsManagementOutput.cs @@ -0,0 +1,315 @@ +// 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.ProductionMaterialsManagement.Dto; +/// +/// 生产物料管理输出参数 +/// +public class ProductionMaterialsManagementOutput +{ + public long idRecord { get; set; } + + public int? CheckedStatus { get; set; } + + public int? VersionIndex { get; set; } + + public bool? IsLatestVersion { get; set; } + + public DateTime? CreatedDate { get; set; } + + public DateTime? VersionCreatedDate { get; set; } + + public DateTime? dateModified { get; set; } + + public long? UserCreatedId { get; set; } + + public long? VersionUserCreatedId { get; set; } + + public long? UserModifiedId { get; set; } + + public string? RecordGuid { get; set; } + + public bool? isVisibilityNormal { get; set; } + + public bool? deleted { get; set; } + + public string? SubObjectGuid { get; set; } + + public bool? PreviousStatus { get; set; } + + public string? revision { get; set; } + + public byte[]? Record_image160_160 { get; set; } + + public byte[]? Record_Image320_240 { get; set; } + + public byte[]? Record_ImageMax { get; set; } + + public string? _System_objNBS { get; set; } + + public string? _System_ObjDescription { get; set; } + + public DateTime? _System_Effectivity_Begin { get; set; } + + public DateTime? _System_Effectivity_End { get; set; } + + public string? CheckedOutPc { get; set; } + + public long? GroupObjId { get; set; } + + public bool? _CheckOutInProgress { get; set; } + + public bool? EnableNotifications { get; set; } + + /// + /// + /// + public string? _system_objConfigurationName { get; set; } + + /// + /// + /// + public bool? _system_objConfigurationType { get; set; } + + /// + /// + /// + public string? _system_objConfigurationGuid { get; set; } + + /// + /// + /// + public string ShowBomFromConfiguration { get; set; } + + /// + /// + /// + public string _System_ObjNbsAuto { get; set; } + + /// + /// + /// + public string? _System_DerivedFrom { get; set; } + + /// + /// + /// + public string? _System_DerivedFrom_RecordGuid { get; set; } + + /// + /// + /// + public bool? _system_objLinkedCompare { get; set; } + + /// + /// + /// + public bool? isReleasedVersion { get; set; } + + /// + /// + /// + public string? _System_WebLink { get; set; } + + /// + /// + /// + public bool? LinkDrw { get; set; } + + /// + /// + /// + public string? ParentRecordGuid { get; set; } + + /// + /// 品牌 + /// + public string? fld004592 { get; set; } + + /// + /// 材料 + /// + public string? fld004593 { get; set; } + + /// + /// 单位 + /// + public string? fld004594 { get; set; } + + /// + /// 行业领域 + /// + public string? fld004595 { get; set; } + + /// + /// 物料类型 + /// + public string? fld004596 { get; set; } + + /// + /// 工厂 + /// + public string? fld004597 { get; set; } + + /// + /// 物料描述 + /// + public string? fld004598 { get; set; } + + /// + /// 物料组 + /// + public string? fld004599 { get; set; } + + /// + /// 采购类型 + /// + public string? fld004600 { get; set; } + + /// + /// 特殊采购 + /// + public string? fld004601 { get; set; } + + /// + /// 散装物料 + /// + public string? fld004602 { get; set; } + + /// + /// 反冲 + /// + public string? fld004603 { get; set; } + + /// + /// 物料同步状态 + /// + public string? fld004604 { get; set; } + + /// + /// 物料同步信息 + /// + public string? fld004605 { get; set; } + + /// + /// 物料同步时间 + /// + public DateTime? fld004606 { get; set; } + + /// + /// 物料同步标识 A:新增 M:修改 D:停用 N:已处理 + /// + public string? fld004607 { get; set; } + + /// + /// 创建人员 + /// + public long? fld004608 { get; set; } + + /// + /// 创建人员ID + /// + public string? fld004608_Rec { get; set; } + + /// + /// 创建日期 + /// + public DateTime? fld004609 { get; set; } + + /// + /// 审核人员 + /// + public long? fld004610 { get; set; } + + /// + /// 审核人员ID + /// + public string? fld004610_Rec { get; set; } + + /// + /// 审核日期 + /// + public DateTime? fld004611 { get; set; } + + /// + /// 物料状态 + /// + public string? fld004612 { get; set; } + + /// + /// 一级分类代号 + /// + public string? fld004613 { get; set; } + + /// + /// 二级分类代号 + /// + public string? fld004614 { get; set; } + + /// + /// 三级分类代号 + /// + public string? fld004615 { get; set; } + + /// + /// 四级分类代号 + /// + public string? fld004616 { get; set; } + + /// + /// 一级分类 + /// + public string? fld004617 { get; set; } + + /// + /// 二级分类 + /// + public string? fld004618 { get; set; } + + /// + /// 三级分类 + /// + public string? fld004619 { get; set; } + + /// + /// 四级分类 + /// + public string? fld004620 { get; set; } + + public string? fld004695 { get; set; } + + public string? fld004696 { get; set; } + + public string? fld004697 { get; set; } + + public string? fld004901 { get; set; } + + public string? fld004902 { get; set; } + + public string? fld004903 { get; set; } + + public string? fld004904 { get; set; } + + public double? fld004905 { get; set; } + + public double? fld004907 { get; set; } + + public string? fld004908 { get; set; } + + public string? fld004909 { get; set; } + + public string? fld004910 { get; set; } + + public string? fld004911 { get; set; } + + public string? fld004973 { get; set; } +} 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 new file mode 100644 index 0000000..d5fbdd1 --- /dev/null +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProductionMaterialsManagement/ProductionMaterialsManagementService.cs @@ -0,0 +1,394 @@ +// 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 System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Vistar.Application.Const; +using Vistar.Application.Entity; +using Vistar.Application.SapService.Dto; +using Vistar.Application.Service.ProductionMaterialsManagement.Dto; +using Vistar.Application.Util; + +namespace Vistar.Application.Service.ProductionMaterialsManagement; +/// +/// 生产物料管理服务 +/// +[ApiDescriptionSettings(ApplicationConst.GroupName, Name = "ProductionMaterialsManagement", Order = 100)] +public class ProductionMaterialsManagementService : IDynamicApiController, ITransient +{ + private readonly SqlSugarRepository _obj112Rep; + private readonly SysConfigService _sysConfigService; + public SapService.SapService _sapService; + private readonly SqlSugarRepository _configurationsRep; + private readonly SqlSugarRepository _configurationDataRep; + + public ProductionMaterialsManagementService( + SqlSugarRepository obj112Rep, + SysConfigService sysConfigService, + SapService.SapService sapService, + SqlSugarRepository configurationsRep, + SqlSugarRepository configurationDataRep + ) + { + _obj112Rep = obj112Rep; + _sysConfigService = sysConfigService; + _sapService = sapService; + _configurationsRep = configurationsRep; + _configurationDataRep = configurationDataRep; + } + /// + /// 分页查询生产物料管理 + /// + /// + /// + [ApiDescriptionSettings(Name = "page", Description = "分页查询生产物料管理", Order = 1000), HttpPost] + [DisplayName("分页查询生产物料管理")] + public async Task> Page(PageProductionMaterialsManagementInput input) + { + var query = await _obj112Rep.AsQueryable() + .Where(x => x.CheckedStatus == 7 && x.deleted == false && x.IsLatestVersion == true) + .WhereIF(!string.IsNullOrWhiteSpace(input._System_objNBS), u => u._System_objNBS.Contains(input._System_objNBS.Trim())) + .WhereIF(!string.IsNullOrWhiteSpace(input.fld004598), u => u.fld004598.Contains(input.fld004598.Trim())) + .WhereIF(input.fld004609Range != null && input.fld004609Range.Length == 2, u => u.fld004609 >= input.fld004609Range[0] && u.fld004609 <= input.fld004609Range[1]) + .Select() + .ToPagedListAsync(input.Page, input.PageSize); + return query; + } + + /// + /// 生产物料管理-同步到 SAP + /// + /// + [ApiDescriptionSettings(Name = "syncToSAP"), HttpPost] + [DisplayName("生产物料管理-同步到 SAP")] + public async Task SyncToSAP(ProductionMaterialsManagementInput input) + { + const string lengthError = "项目描述长度大于40,请检查!"; + + // 验证物料描述长度 + if (input.fld004598.Length > 40) + { + await _obj112Rep.AsUpdateable() + .SetColumns(it => new Obj112 + { + fld004606 = DateTime.Now, + fld004607 = "N", + fld004605 = lengthError, + fld004604 = "失败" + }) + .Where(it => it.idRecord == input.idRecord) + .ExecuteCommandAsync().ConfigureAwait(false); + + return new SapOutput + { + code = "失败", + msg = lengthError, + result = lengthError + }; + } + + //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid + string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); + + var sapMaterialInput = new SapMaterialInput() + { + Reqkeyid = "", + Businessid = "", + Messageid = "", + Sndprn = "PLM", + Rcvprn = "SAP", + Requser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName), + Note1 = "", + Note2 = "", + Note3 = "", + Zwbid = millisecondTimestamp, + Matnr = input._System_objNBS, + Mbrsh = input.fld004595, + Mtart = input.fld004596, + Maktx = input.fld004598, + Meins = input.fld004594, + Matkl = input.fld004599, + Bismt = input.fld004902, + Groes = input.fld004901, + Normt = input.fld004592, + Ferth = input.fld004593, + Zeinr = input.fld004903, + Mstae = input.fld004696, + Raube = input.fld004904, + Mhdrz = input.fld004905.ToString(), + Mhdhb = input.fld004907.ToString(), + Werks = input.fld004597, + Beskz = input.fld004600, + Sobsl = input.fld004601, + Schgt = input.fld004602, + Rgekz = input.fld004603, + Zbom = input.fld004695 + }; + + var apiOutput = await _sapService.SapMaterialApi(sapMaterialInput); + string codeVal = apiOutput.code == "S" ? "成功" : "失败"; + var msg = apiOutput.msg; + if (apiOutput.msg == "") + { + msg = "同步成功"; + } + + await _obj112Rep.AsUpdateable() + .SetColumns(it => new Obj112 + { + fld004606 = DateTime.Now, + fld004604 = codeVal, + fld004607 = "N", + fld004605 = msg + }) + .Where(it => it.idRecord == input.idRecord) + .ExecuteCommandAsync(); + var output = new SapOutput() + { + parameter = apiOutput.parameter, + code = codeVal, + msg = msg, + result = apiOutput.result + }; + return output; + } + + /// + /// 生产物料管理-批量同步到SAP + /// + /// + /// + [ApiDescriptionSettings(Name = "BatchSyncToSAP"), HttpPost] + [DisplayName("生产物料管理-批量同步到SAP")] + public async Task> BatchSyncToSAP(List input) + { + const string lengthError = "物料描述长度大于40,请检查!"; + const string synchronized = "该项目编号已同步!"; + var SapOutputList = new List(); + var Requser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName); + for (int i = 0; i < input.Count; i++) + { + // 验证物料描述长度 + if (input[i].fld004598.Length > 40) + { + await _obj112Rep.AsUpdateable() + .SetColumns(it => new Obj112 + { + fld004606 = DateTime.Now, + fld004607 = "N", + fld004605 = lengthError, + fld004604 = "失败" + }) + .Where(it => it.idRecord == input[i].idRecord) + .ExecuteCommandAsync().ConfigureAwait(false); + + SapOutputList.Add(new SapOutput() + { + materialCode = input[i]._System_objNBS, + code = "失败", + msg = lengthError, + result = lengthError + }); + continue; + } + if (input[i].fld004607 != "A"|| input[i].fld004607 != "M") + { + SapOutputList.Add(new SapOutput() + { + materialCode = input[i]._System_objNBS, + code = "失败", + msg = synchronized, + result = synchronized + }); + continue; + } + //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid + string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); + var sapMaterialInput = new SapMaterialInput() + { + Reqkeyid = "", + Businessid = "", + Messageid = "", + Sndprn = "PLM", + Rcvprn = "SAP", + Requser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName), + Note1 = "", + Note2 = "", + Note3 = "", + Zwbid = millisecondTimestamp, + Matnr = input[i]._System_objNBS, + Mbrsh = input[i].fld004595, + Mtart = input[i].fld004596, + Maktx = input[i].fld004598, + Meins = input[i].fld004594, + Matkl = input[i].fld004599, + Bismt = input[i].fld004902, + Groes = input[i].fld004901, + Normt = input[i].fld004592, + Ferth = input[i].fld004593, + Zeinr = input[i].fld004903, + Mstae = input[i].fld004696, + Raube = input[i].fld004904, + Mhdrz = input[i].fld004905.ToString(), + Mhdhb = input[i].fld004907.ToString(), + Werks = input[i].fld004597, + Beskz = input[i].fld004600, + Sobsl = input[i].fld004601, + Schgt = input[i].fld004602, + Rgekz = input[i].fld004603, + Zbom = input[i].fld004695 + }; + var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput); + string codeVal = sapOutput.code == "S" ? "成功" : "失败"; + string msg = sapOutput.msg; + + if (sapOutput.msg == "") + { + msg = "同步成功"; + } + await _obj112Rep.AsUpdateable() + .SetColumns(it => new Obj112 + { + fld004606 = DateTime.Now, + fld004604 = codeVal, + fld004607 = "N", + fld004605 = msg + }) + .Where(it => it.idRecord == input[i].idRecord) + .ExecuteCommandAsync(); + var output = new SapOutput() + { + parameter = sapOutput.parameter, + materialCode = input[0]._System_objNBS, + code = codeVal, + msg = msg, + result = sapOutput.result + }; + SapOutputList.Add(output); + } + return SapOutputList; + } + + /// + /// 生产物料管理-定时同步到SAP + /// + /// + [ApiDescriptionSettings(Name = "TimingSyncToSAP"), HttpGet] + [DisplayName("生产物料管理-定时同步到SAP")] + [AllowAnonymous] + public async Task> TimingSyncToSAP() + { + var input = await _obj112Rep.AsQueryable() + .Where(x => x.CheckedStatus == 7 && x.deleted == false && x.IsLatestVersion == true&&(x.fld004607=="A"||x.fld004607 == "M")) + .ToListAsync(); + const string lengthError = "物料描述长度大于40,请检查!"; + var SapOutputList = new List(); + var Requser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName); + for (int i = 0; i < input.Count; i++) + { + // 验证物料描述长度 + if (input[i].fld004598.Length > 40) + { + await _obj112Rep.AsUpdateable() + .SetColumns(it => new Obj112 + { + fld004606 = DateTime.Now, + fld004607 = "N", + fld004605 = lengthError, + fld004604 = "失败" + }) + .Where(it => it.idRecord == input[i].idRecord) + .ExecuteCommandAsync().ConfigureAwait(false); + + SapOutputList.Add(new SapOutput() + { + materialCode = input[i]._System_objNBS, + code = "失败", + msg = lengthError, + result = lengthError + }); + continue; + } + + //获取时间戳精确到毫秒,sap要求每次调用生成不重复guid + string millisecondTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); + var sapMaterialInput = new SapMaterialInput() + { + Reqkeyid = "", + Businessid = "", + Messageid = "", + Sndprn = "PLM", + Rcvprn = "SAP", + Requser = await _sysConfigService.GetConfigValueByCode(ConfigConst.SapUserName), + Note1 = "", + Note2 = "", + Note3 = "", + Zwbid = millisecondTimestamp, + Matnr = input[i]._System_objNBS, + Mbrsh = input[i].fld004595, + Mtart = input[i].fld004596, + Maktx = input[i].fld004598, + Meins = input[i].fld004594, + Matkl = input[i].fld004599, + Bismt = input[i].fld004902, + Groes = input[i].fld004901, + Normt = input[i].fld004592, + Ferth = input[i].fld004593, + Zeinr = input[i].fld004903, + Mstae = input[i].fld004696, + Raube = input[i].fld004904, + Mhdrz = input[i].fld004905.ToString(), + Mhdhb = input[i].fld004907.ToString(), + Werks = input[i].fld004597, + Beskz = input[i].fld004600, + Sobsl = input[i].fld004601, + Schgt = input[i].fld004602, + Rgekz = input[i].fld004603, + Zbom = input[i].fld004695 + }; + var sapOutput = await _sapService.SapMaterialApi(sapMaterialInput); + string codeVal = sapOutput.code == "S" ? "成功" : "失败"; + string msg = sapOutput.msg; + + if (sapOutput.msg == "") + { + msg = "同步成功"; + } + await _obj112Rep.AsUpdateable() + .SetColumns(it => new Obj112 + { + fld004606 = DateTime.Now, + fld004604 = codeVal, + fld004607 = "N", + fld004605 = msg + }) + .Where(it => it.idRecord == input[i].idRecord) + .ExecuteCommandAsync(); + var output = new SapOutput() + { + parameter = sapOutput.parameter, + materialCode = input[0]._System_objNBS, + code = codeVal, + msg = msg, + result = sapOutput.result + }; + SapOutputList.Add(output); + } + + return SapOutputList; + } + +} diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/Dto/ProjectManagementInput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/Dto/ProjectManagementInput.cs index 1b25015..2277125 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/Dto/ProjectManagementInput.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/Dto/ProjectManagementInput.cs @@ -368,6 +368,7 @@ public class ProjectManagementInput public DateTime? fld004949 { get; set; } public string? fld005040 { get; set; } + public string fld005281 { get; set; } } /// @@ -394,6 +395,4 @@ public class PageProjectManagementInput : BasePageInput /// 创建时间范围 /// public DateTime?[] fld004683Range { get; set; } - - } diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/Dto/ProjectManagementOutput.cs b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/Dto/ProjectManagementOutput.cs index f3c79a4..674339d 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/Dto/ProjectManagementOutput.cs +++ b/admin.net.pro/Admin.NET/Vistar.Application/Service/ProjectManagement/Dto/ProjectManagementOutput.cs @@ -370,4 +370,5 @@ public class ProjectManagementOutput public DateTime? fld004949 { get; set; } public string? fld005040 { get; set; } + public string fld005281 { get; set; } } 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 42c3310..86fc1d5 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 @@ -60,7 +60,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient public async Task> Page(PageProjectManagementInput input) { var query = await _obj109Rep.AsQueryable() - .Where(x => (x.CheckedStatus == 0||x.CheckedStatus==1) && x.deleted == false && x.IsLatestVersion == true&&x.fld005040=="发布") + .Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布") .WhereIF(!string.IsNullOrWhiteSpace(input._System_objNBS), u => u._System_objNBS.Contains(input._System_objNBS.Trim())) .WhereIF(!string.IsNullOrWhiteSpace(input.fld004502), u => u.fld004502.Contains(input.fld004502.Trim())) .WhereIF(input.fld004683Range != null && input.fld004683Range.Length == 2, u => u.fld004683 >= input.fld004683Range[0] && u.fld004683 <= input.fld004683Range[1]) @@ -88,7 +88,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient fld004508 = DateTime.Now, fld004510 = "N", fld004507 = lengthError, - fld004509="失败" + fld004509 = "失败" }) .Where(it => it.idRecord == input.idRecord) .ExecuteCommandAsync().ConfigureAwait(false); @@ -120,14 +120,14 @@ public class ProjectManagementService : IDynamicApiController, ITransient Mbrsh = input.fld004521, Mtart = input.fld004519, Maktx = input.fld004502, - Meins = "",//sssssssss基本计量单位 + Meins = input.fld005281, Matkl = input.fld004520, Bismt = input.fld004684, Groes = input.fld004685, Normt = input.fld004924, Ferth = input.fld004925, Zeinr = input.fld004926, - Mstae = "",//sssssssssss跨工厂物料状态 + Mstae = input.fld004927, Raube = input.fld004932, Mhdrz = input.fld004933.ToString(), Mhdhb = input.fld004934.ToString(), @@ -205,7 +205,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient }); continue; } - if (input[i].fld004510 == "N") + if (input[i].fld004510 != "A" || input[i].fld004510 != "M") { SapOutputList.Add(new SapOutput() { @@ -234,14 +234,14 @@ public class ProjectManagementService : IDynamicApiController, ITransient Mbrsh = input[i].fld004521, Mtart = input[i].fld004519, Maktx = input[i].fld004502, - Meins = "",//sssssssss基本计量单位 + Meins = input[i].fld005281, Matkl = input[i].fld004520, Bismt = input[i].fld004684, Groes = input[i].fld004685, Normt = input[i].fld004924, Ferth = input[i].fld004925, Zeinr = input[i].fld004926, - Mstae = "",//sssssssssss跨工厂物料状态 + Mstae = input[i].fld004927, Raube = input[i].fld004932, Mhdrz = input[i].fld004933.ToString(), Mhdhb = input[i].fld004934.ToString(), @@ -405,7 +405,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient public async Task> TimingSyncToSAP() { var input = await _obj109Rep.AsQueryable() - .Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布") + .Where(x => (x.CheckedStatus == 0 || x.CheckedStatus == 1) && x.deleted == false && x.IsLatestVersion == true && x.fld005040 == "发布" && (x.fld004510 == "A" || x.fld004510 == "M")) .ToListAsync(); const string lengthError = "物料描述长度大于40,请检查!"; var SapOutputList = new List(); @@ -454,14 +454,14 @@ public class ProjectManagementService : IDynamicApiController, ITransient Mbrsh = input[i].fld004521, Mtart = input[i].fld004519, Maktx = input[i].fld004502, - Meins = "",//sssssssss基本计量单位 + Meins = input[i].fld005281, Matkl = input[i].fld004520, Bismt = input[i].fld004684, Groes = input[i].fld004685, Normt = input[i].fld004924, Ferth = input[i].fld004925, Zeinr = input[i].fld004926, - Mstae = "",//sssssssssss跨工厂物料状态 + Mstae = input[i].fld004927, Raube = input[i].fld004932, Mhdrz = input[i].fld004933.ToString(), Mhdhb = input[i].fld004934.ToString(), @@ -519,7 +519,7 @@ public class ProjectManagementService : IDynamicApiController, ITransient var configid = await _configurationsRep.AsQueryable().Where(x => x.ObjectId == 110 && 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")) + .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()) diff --git a/admin.net.pro/Admin.NET/Vistar.Application/Vistar.Application.csproj b/admin.net.pro/Admin.NET/Vistar.Application/Vistar.Application.csproj index 820f864..e5a5b5e 100644 --- a/admin.net.pro/Admin.NET/Vistar.Application/Vistar.Application.csproj +++ b/admin.net.pro/Admin.NET/Vistar.Application/Vistar.Application.csproj @@ -24,6 +24,12 @@ + + + + + + diff --git a/admin.net.pro/Web/src/api/materialManagement/productionMaterialsManagement.ts b/admin.net.pro/Web/src/api/materialManagement/productionMaterialsManagement.ts new file mode 100644 index 0000000..9c3943b --- /dev/null +++ b/admin.net.pro/Web/src/api/materialManagement/productionMaterialsManagement.ts @@ -0,0 +1,30 @@ +import request from '/@/utils/request'; +enum Api { + PageProductionMaterialsManagement = '/api/productionMaterialsManagement/page', + SyncToSAPProductionMaterialsManagement = '/api/productionMaterialsManagement/SyncToSAP', + BatchSyncToSAPProductionMaterialsManagement = '/api/productionMaterialsManagement/batchSyncToSAP' +} + +// 分页查询产品管理 +export const PageProductionMaterialsManagement = (params?: any) => + request({ + url: Api.PageProductionMaterialsManagement, + method: 'post', + data: params, + }); + +// 同步到SAP +export const SyncToSAPProductionMaterialsManagement = (params?: any) => + request({ + url: Api.SyncToSAPProductionMaterialsManagement, + method: 'post', + data: params, + }); + +// 批量同步到SAP +export const BatchSyncToSAPProductionMaterialsManagement = (params?: any) => + request({ + url: Api.BatchSyncToSAPProductionMaterialsManagement, + method: 'post', + data: params, + }); diff --git a/admin.net.pro/Web/src/views/materialManagement/ProductionMaterialsManagement/index.vue b/admin.net.pro/Web/src/views/materialManagement/ProductionMaterialsManagement/index.vue new file mode 100644 index 0000000..46a6a1c --- /dev/null +++ b/admin.net.pro/Web/src/views/materialManagement/ProductionMaterialsManagement/index.vue @@ -0,0 +1,226 @@ + + + \ No newline at end of file