From 5176d63ddf903cfd7e3bb18a0dad31ca1646694f Mon Sep 17 00:00:00 2001 From: lvzb <35200379@qq.com> Date: Wed, 17 Jan 2024 16:23:19 +0800 Subject: [PATCH] =?UTF-8?q?SAP=E7=89=A9=E6=96=99=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MaterialExt/Dto/MaterialExtDto.cs | 49 ++++++ .../MaterialExt/Dto/QueryMaterialExtDto.cs | 30 ++++ .../Interfaces/IMaterialExtAppService.cs | 11 ++ .../WY.NewJit.Application.Contracts.xml | 45 +++++ .../MaterialExt/IMaterialExtAppService.cs | 11 ++ .../MaterialExt/MaterialExtAppService.cs | 161 ++++++++++++++++++ .../NewJitApplicationAutoMapperProfile.cs | 2 + .../WY.NewJit.Application.xml | 31 ++++ 8 files changed, 340 insertions(+) create mode 100644 src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/MaterialExtDto.cs create mode 100644 src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/QueryMaterialExtDto.cs create mode 100644 src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Interfaces/IMaterialExtAppService.cs create mode 100644 src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/IMaterialExtAppService.cs create mode 100644 src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/MaterialExtAppService.cs diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/MaterialExtDto.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/MaterialExtDto.cs new file mode 100644 index 0000000..5fcfa6d --- /dev/null +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/MaterialExtDto.cs @@ -0,0 +1,49 @@ +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using System; +using System.Collections.Generic; +using System.Text; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgBaseData +{ + [ExcelExporter(Name = "SAP物料信息", AutoFitAllColumn = true, MaxRowNumberOnASheet = 1000)] //一个Sheet最大允许的行数,设置了之后将输出多个Sheet + [Serializable] + public class MaterialExtDto : AuditedEntityDto + { + /// + /// SAP物料号 + /// + [ExporterHeader(DisplayName = "SAP物料号")] + [ImporterHeader(Name = "SAP物料号")] + public string MaterialNum { get; set; } + + /// + /// 物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲) + /// + [ExporterHeader(DisplayName = "物料描述")] + [ImporterHeader(Name = "物料描述")] + public string MaterialDescription { get; set; } + + /// + /// 大小量纲(大小量纲、物料描述字段值同时存在时,优先显示大小量纲) + /// + [ExporterHeader(DisplayName = "大小量纲")] + [ImporterHeader(Name = "大小量纲")] + public string MaterialDescription2 { get; set; } + + /// + /// 补充备注(车型、门板代码) + /// + [ExporterHeader(DisplayName = "补充备注")] + [ImporterHeader(Name = "补充备注")] + public string MaterialMemo { get; set; } + + /// + /// 物料组:例如 门板成品-C8 + /// + [ExporterHeader(DisplayName = "物料组")] + [ImporterHeader(Name = "物料组")] + public string MaterialGroup { get; set; } + } +} diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/QueryMaterialExtDto.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/QueryMaterialExtDto.cs new file mode 100644 index 0000000..f59df76 --- /dev/null +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/QueryMaterialExtDto.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; +using WY.NewJit.Common; + +namespace WY.NewJit.MsgBaseData +{ + [Serializable] + public class QueryMaterialExtDto : PagedAndSortedBase + { + /// + /// SAP物料号 + /// + public string MaterialNum { get; set; } + + /// + /// 物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲) + /// + public string MaterialDescription { get; set; } + + /// + /// 物料组:例如 门板成品-C8 + /// + public string MaterialGroup { get; set; } + /// + /// 物料类型 0 空 1 控制件 2 柱护板 3 门板 + /// + public string MaterialType { get; set; } + } +} diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Interfaces/IMaterialExtAppService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Interfaces/IMaterialExtAppService.cs new file mode 100644 index 0000000..2047d57 --- /dev/null +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Interfaces/IMaterialExtAppService.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgBaseData +{ + public interface IMaterialExtAppService + { + Task> ExportAsync(QueryMaterialExtDto input); + Task> GetListAsync(QueryMaterialExtDto input); + } +} \ No newline at end of file diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml index 40b2b93..8412411 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml @@ -1873,6 +1873,51 @@ 主键 执行成功返回真 + + + SAP物料号 + + + + + 物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲) + + + + + 大小量纲(大小量纲、物料描述字段值同时存在时,优先显示大小量纲) + + + + + 补充备注(车型、门板代码) + + + + + 物料组:例如 门板成品-C8 + + + + + SAP物料号 + + + + + 物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲) + + + + + 物料组:例如 门板成品-C8 + + + + + 物料类型 0 空 1 控制件 2 柱护板 3 门板 + + 零件编码 diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/IMaterialExtAppService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/IMaterialExtAppService.cs new file mode 100644 index 0000000..2047d57 --- /dev/null +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/IMaterialExtAppService.cs @@ -0,0 +1,11 @@ +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; + +namespace WY.NewJit.MsgBaseData +{ + public interface IMaterialExtAppService + { + Task> ExportAsync(QueryMaterialExtDto input); + Task> GetListAsync(QueryMaterialExtDto input); + } +} \ No newline at end of file diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/MaterialExtAppService.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/MaterialExtAppService.cs new file mode 100644 index 0000000..32ec098 --- /dev/null +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/MaterialExtAppService.cs @@ -0,0 +1,161 @@ +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Shouldly; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Dynamic.Core; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.BlobStoring; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Uow; +using WY.NewJit.Common; +using WY.NewJit.Extends.PaiGe; + +namespace WY.NewJit.MsgBaseData +{ + [Route("api/newjit/material")] + [ApiExplorerSettings(GroupName = SwaggerGroupConsts.基础数据)] + public class MaterialExtAppService : ApplicationService, IMaterialExtAppService + { + private readonly IRepository _materialExtRepository; + private ILogger _logger; + /// + /// BLOB存储 + /// + private readonly IBlobContainer _blobContainer; + + /// + /// 错误信息前缀 + /// + private string _errorMessagePrefix + { + get + { + return System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "."; + } + } + public MaterialExtAppService(IRepository materialExtRepository, ILogger logger, IBlobContainer blobContainer) + { + _materialExtRepository = materialExtRepository; + _logger = logger; + _blobContainer = blobContainer; + } + /// + /// 获取数据 + /// + /// + /// + [HttpGet] + [UnitOfWork(false)] + [Route("list")] + public virtual async Task> GetListAsync(QueryMaterialExtDto input) + { + _logger.LogDebug(_errorMessagePrefix + "GetListAsync 进入"); + try + { + var page = (PagedAndSortedBase)input; + IQueryable qry1 = QueryByCondition(input); + if (string.IsNullOrEmpty(page.Sorting)) + { + page.Sorting = "MaterialNum"; + } + + int totalCount = await qry1.CountAsync(); //返回总记录数而不是当前页记录数 + if (totalCount == 0) + { + return new PagedResultDto(0, new List()); + } + + var query = qry1 + .OrderBy(page.Sorting) + .Skip(page.SkipCount) + .Take(page.MaxResultCount); + + List lst = await query.ToListAsync(); + + List items = + ObjectMapper.Map, List>(lst); + + return new PagedResultDto(totalCount, items); + } + catch (Exception ex) + { + string errMsg = _errorMessagePrefix + "GetListAsync 执行出错:" + ex.Message; + _logger.LogError(errMsg); + return new PagedResultDto(0, new List()); + } + } + /// + /// 导出信息 + /// + /// 导出查询条件 + /// 执行成功返回真 + [UnitOfWork(false)] + [HttpPost] + [Route("export")] + public virtual async Task> ExportAsync(QueryMaterialExtDto input) + { + _logger.LogDebug(_errorMessagePrefix + "ExportAsync 进入"); + ObjectResultDto ret = new ObjectResultDto(); + try + { + IQueryable query = QueryByCondition(input); + List lst = await query.ToListAsync(); + List items = + ObjectMapper.Map, List>(lst); + //将实体列表转换成excel文件流 + IExporter exporter = new ExcelExporter(); + byte[] byteArr = await exporter.ExportAsByteArray(items); + byteArr.ShouldNotBeNull(); + //将excel文件流保存到服务器端文件系统 + string fileName = string.Format("SAP物料信息_{0}.xlsx", Guid.NewGuid().ToString()); + await _blobContainer.SaveAsync(fileName, byteArr); + + ret.Item = fileName; + return ret; + } + catch (Exception ex) + { + ret.Status = false; + ret.Message = _errorMessagePrefix + "ExportAsync 执行出错:" + ex.Message; + _logger.LogError(ret.Message); + return ret; + } + } + #region 私有方法 + /// + /// 根据筛选条件获取实体列表 + /// + /// + /// + private IQueryable QueryByCondition(QueryMaterialExtDto input) + { + IQueryable ret = _materialExtRepository.Where(itm => 1 == 1); + if (!string.IsNullOrEmpty(input.MaterialNum)) + { + ret = ret.Where(itm => itm.MaterialNum.Contains(input.MaterialNum)); + } + if (!string.IsNullOrEmpty(input.MaterialDescription)) + { + ret = ret.Where(itm => itm.MaterialDescription.Contains(input.MaterialDescription)); + } + if (!string.IsNullOrEmpty(input.MaterialGroup)) + { + ret = ret.Where(itm => itm.MaterialGroup == input.MaterialGroup); + } + if (!string.IsNullOrEmpty(input.MaterialType)) + { + ret = ret.Where(itm => itm.MaterialType == input.MaterialType); + } + return ret; + } + #endregion + } +} diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/NewJitApplicationAutoMapperProfile.cs b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/NewJitApplicationAutoMapperProfile.cs index b6aec95..e807c4c 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/NewJitApplicationAutoMapperProfile.cs +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/NewJitApplicationAutoMapperProfile.cs @@ -5,6 +5,7 @@ using WY.NewJit.Books; using WY.NewJit.EdiReceive.Dtos; using WY.NewJit.EdiReceive.Entitys; using WY.NewJit.Extends; +using WY.NewJit.Extends.PaiGe; using WY.NewJit.MsgBaseData; using WY.NewJit.MsgCheck; using WY.NewJit.MsgCheck.UnknownAssemblys; @@ -21,6 +22,7 @@ namespace WY.NewJit CreateMap(); #region 基础数据 + CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); diff --git a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml index 492904d..67dfb75 100644 --- a/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml +++ b/src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml @@ -849,6 +849,37 @@ 主键 执行成功返回真 + + + BLOB存储 + + + + + 错误信息前缀 + + + + + 获取数据 + + + + + + + 导出信息 + + 导出查询条件 + 执行成功返回真 + + + + 根据筛选条件获取实体列表 + + + + 零件管理应用服务实现