Browse Source

SAP物料管理服务添加

HQ
lvzb 10 months ago
parent
commit
5176d63ddf
  1. 49
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/MaterialExtDto.cs
  2. 30
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Dto/QueryMaterialExtDto.cs
  3. 11
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/MsgBaseData/MaterialExt/Interfaces/IMaterialExtAppService.cs
  4. 45
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml
  5. 11
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/IMaterialExtAppService.cs
  6. 161
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/MsgBaseData/MaterialExt/MaterialExtAppService.cs
  7. 2
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/NewJitApplicationAutoMapperProfile.cs
  8. 31
      src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml

49
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<Guid>
{
/// <summary>
/// SAP物料号
/// </summary>
[ExporterHeader(DisplayName = "SAP物料号")]
[ImporterHeader(Name = "SAP物料号")]
public string MaterialNum { get; set; }
/// <summary>
/// 物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲)
/// </summary>
[ExporterHeader(DisplayName = "物料描述")]
[ImporterHeader(Name = "物料描述")]
public string MaterialDescription { get; set; }
/// <summary>
/// 大小量纲(大小量纲、物料描述字段值同时存在时,优先显示大小量纲)
/// </summary>
[ExporterHeader(DisplayName = "大小量纲")]
[ImporterHeader(Name = "大小量纲")]
public string MaterialDescription2 { get; set; }
/// <summary>
/// 补充备注(车型、门板代码)
/// </summary>
[ExporterHeader(DisplayName = "补充备注")]
[ImporterHeader(Name = "补充备注")]
public string MaterialMemo { get; set; }
/// <summary>
/// 物料组:例如 门板成品-C8
/// </summary>
[ExporterHeader(DisplayName = "物料组")]
[ImporterHeader(Name = "物料组")]
public string MaterialGroup { get; set; }
}
}

30
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
{
/// <summary>
/// SAP物料号
/// </summary>
public string MaterialNum { get; set; }
/// <summary>
/// 物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲)
/// </summary>
public string MaterialDescription { get; set; }
/// <summary>
/// 物料组:例如 门板成品-C8
/// </summary>
public string MaterialGroup { get; set; }
/// <summary>
/// 物料类型 0 空 1 控制件 2 柱护板 3 门板
/// </summary>
public string MaterialType { get; set; }
}
}

11
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<ObjectResultDto<string>> ExportAsync(QueryMaterialExtDto input);
Task<PagedResultDto<MaterialExtDto>> GetListAsync(QueryMaterialExtDto input);
}
}

45
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application.Contracts/WY.NewJit.Application.Contracts.xml

@ -1873,6 +1873,51 @@
<param name="id">主键</param>
<returns>执行成功返回真</returns>
</member>
<member name="P:WY.NewJit.MsgBaseData.MaterialExtDto.MaterialNum">
<summary>
SAP物料号
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.MaterialExtDto.MaterialDescription">
<summary>
物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲)
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.MaterialExtDto.MaterialDescription2">
<summary>
大小量纲(大小量纲、物料描述字段值同时存在时,优先显示大小量纲)
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.MaterialExtDto.MaterialMemo">
<summary>
补充备注(车型、门板代码)
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.MaterialExtDto.MaterialGroup">
<summary>
物料组:例如 门板成品-C8
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.QueryMaterialExtDto.MaterialNum">
<summary>
SAP物料号
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.QueryMaterialExtDto.MaterialDescription">
<summary>
物料描述(大小量纲、物料描述字段值同时存在时,优先显示大小量纲)
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.QueryMaterialExtDto.MaterialGroup">
<summary>
物料组:例如 门板成品-C8
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.QueryMaterialExtDto.MaterialType">
<summary>
物料类型 0 空 1 控制件 2 柱护板 3 门板
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.CreateUpdatePartCfgDto.PartCode">
<summary>
零件编码

11
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<ObjectResultDto<string>> ExportAsync(QueryMaterialExtDto input);
Task<PagedResultDto<MaterialExtDto>> GetListAsync(QueryMaterialExtDto input);
}
}

161
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<MaterialExt, Guid> _materialExtRepository;
private ILogger<MaterialExtAppService> _logger;
/// <summary>
/// BLOB存储
/// </summary>
private readonly IBlobContainer<OurFileContainer> _blobContainer;
/// <summary>
/// 错误信息前缀
/// </summary>
private string _errorMessagePrefix
{
get
{
return System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + ".";
}
}
public MaterialExtAppService(IRepository<MaterialExt, Guid> materialExtRepository, ILogger<MaterialExtAppService> logger, IBlobContainer<OurFileContainer> blobContainer)
{
_materialExtRepository = materialExtRepository;
_logger = logger;
_blobContainer = blobContainer;
}
/// <summary>
/// 获取数据
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[UnitOfWork(false)]
[Route("list")]
public virtual async Task<PagedResultDto<MaterialExtDto>> GetListAsync(QueryMaterialExtDto input)
{
_logger.LogDebug(_errorMessagePrefix + "GetListAsync 进入");
try
{
var page = (PagedAndSortedBase)input;
IQueryable<MaterialExt> qry1 = QueryByCondition(input);
if (string.IsNullOrEmpty(page.Sorting))
{
page.Sorting = "MaterialNum";
}
int totalCount = await qry1.CountAsync(); //返回总记录数而不是当前页记录数
if (totalCount == 0)
{
return new PagedResultDto<MaterialExtDto>(0, new List<MaterialExtDto>());
}
var query = qry1
.OrderBy(page.Sorting)
.Skip(page.SkipCount)
.Take(page.MaxResultCount);
List<MaterialExt> lst = await query.ToListAsync();
List<MaterialExtDto> items =
ObjectMapper.Map<List<MaterialExt>, List<MaterialExtDto>>(lst);
return new PagedResultDto<MaterialExtDto>(totalCount, items);
}
catch (Exception ex)
{
string errMsg = _errorMessagePrefix + "GetListAsync 执行出错:" + ex.Message;
_logger.LogError(errMsg);
return new PagedResultDto<MaterialExtDto>(0, new List<MaterialExtDto>());
}
}
/// <summary>
/// 导出信息
/// </summary>
/// <param name="input">导出查询条件</param>
/// <returns>执行成功返回真</returns>
[UnitOfWork(false)]
[HttpPost]
[Route("export")]
public virtual async Task<ObjectResultDto<string>> ExportAsync(QueryMaterialExtDto input)
{
_logger.LogDebug(_errorMessagePrefix + "ExportAsync 进入");
ObjectResultDto<string> ret = new ObjectResultDto<string>();
try
{
IQueryable<MaterialExt> query = QueryByCondition(input);
List<MaterialExt> lst = await query.ToListAsync();
List<MaterialExtDto> items =
ObjectMapper.Map<List<MaterialExt>, List<MaterialExtDto>>(lst);
//将实体列表转换成excel文件流
IExporter exporter = new ExcelExporter();
byte[] byteArr = await exporter.ExportAsByteArray<MaterialExtDto>(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 私有方法
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
private IQueryable<MaterialExt> QueryByCondition(QueryMaterialExtDto input)
{
IQueryable<MaterialExt> 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
}
}

2
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<CreateUpdateBookDto, Book>();
#region 基础数据
CreateMap<MaterialExt, MaterialExtDto>().ReverseMap();
CreateMap<PartCfg, PartCfgDto>().ReverseMap();
CreateMap<PartCfg, CreateUpdatePartCfgDto>().ReverseMap();

31
src/Modules/新版JIT或JIS系统服务端/src/WY.NewJit.Application/WY.NewJit.Application.xml

@ -849,6 +849,37 @@
<param name="id">主键</param>
<returns>执行成功返回真</returns>
</member>
<member name="F:WY.NewJit.MsgBaseData.MaterialExtAppService._blobContainer">
<summary>
BLOB存储
</summary>
</member>
<member name="P:WY.NewJit.MsgBaseData.MaterialExtAppService._errorMessagePrefix">
<summary>
错误信息前缀
</summary>
</member>
<member name="M:WY.NewJit.MsgBaseData.MaterialExtAppService.GetListAsync(WY.NewJit.MsgBaseData.QueryMaterialExtDto)">
<summary>
获取数据
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:WY.NewJit.MsgBaseData.MaterialExtAppService.ExportAsync(WY.NewJit.MsgBaseData.QueryMaterialExtDto)">
<summary>
导出信息
</summary>
<param name="input">导出查询条件</param>
<returns>执行成功返回真</returns>
</member>
<member name="M:WY.NewJit.MsgBaseData.MaterialExtAppService.QueryByCondition(WY.NewJit.MsgBaseData.QueryMaterialExtDto)">
<summary>
根据筛选条件获取实体列表
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="T:WY.NewJit.MsgBaseData.PartCfgAppService">
<summary>
零件管理应用服务实现

Loading…
Cancel
Save