From c7a637a7fee02bd8c4e9d60c27c6d06cd35f011b Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Tue, 9 Apr 2024 14:18:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bases/SfsBaseDataAppServiceBase.cs | 1 + .../ErpLocationItemAppService.cs | 27 +++++++++++++++++++ .../ErpLocationItemAutoMapperProfile.cs | 1 + 3 files changed, 29 insertions(+) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Bases/SfsBaseDataAppServiceBase.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Bases/SfsBaseDataAppServiceBase.cs index 128983391..e7183a1a2 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Bases/SfsBaseDataAppServiceBase.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/Bases/SfsBaseDataAppServiceBase.cs @@ -27,6 +27,7 @@ public abstract class SfsBaseDataAppServiceBase LazyServiceProvider.LazyGetRequiredService(); protected ILocationAppService LocationAppService => LazyServiceProvider.LazyGetRequiredService(); + protected IErpLocationAppService ErpLocationAppService => LazyServiceProvider.LazyGetRequiredService(); protected IWarehouseAppService WarehouseAppService => LazyServiceProvider.LazyGetRequiredService(); protected ISupplierAppService SupplierAppService => LazyServiceProvider.LazyGetRequiredService(); protected IAreaAppService AreaAppService => LazyServiceProvider.LazyGetRequiredService(); diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ErpLocationItems/ErpLocationItemAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ErpLocationItems/ErpLocationItemAppService.cs index cb027a477..1f81f0138 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ErpLocationItems/ErpLocationItemAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ErpLocationItems/ErpLocationItemAppService.cs @@ -10,6 +10,7 @@ using Volo.Abp; using Volo.Abp.Caching; using Volo.Abp.Domain.Repositories; using Volo.Abp.ObjectMapping; +using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Domain; using Win_in.Sfs.Basedata.Domain.Shared; @@ -40,6 +41,32 @@ public class ErpLocationItemAppService _manager = manager; } + /// + /// 用来重写 新增实体 + /// + /// + /// + /// + [HttpPost("")] + [UnitOfWork] + public override async Task CreateAsync(ErpLocationItemEditInput input) + { + var itemBasic = await ItemBasicAppService.GetByCodeAsync(input.ItemCode).ConfigureAwait(false); + Check.NotNull(itemBasic, "物品代码", $"物品 {input.ItemCode} 不存在"); + + var erpLocation = await ErpLocationAppService.GetByCodeAsync(input.ErpLocationCode).ConfigureAwait(false); + Check.NotNull(erpLocation, "储位代码", $"储位 {input.ErpLocationCode} 不存在"); + + var entity = await _repository.FirstOrDefaultAsync(p => p.ItemCode == input.ItemCode && p.ErpLocationCode == input.ErpLocationCode).ConfigureAwait(false); + + if(entity != null) + { + throw new UserFriendlyException($"物品{input.ItemCode}和储位{input.ErpLocationCode} 对应关系已存在"); + } + + return await base.CreateAsync(input).ConfigureAwait(false); + } + /// /// 检查物料和储位对应关系是否存在 /// diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ErpLocationItems/ErpLocationItemAutoMapperProfile.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ErpLocationItems/ErpLocationItemAutoMapperProfile.cs index a878e9cd4..1ec59b006 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ErpLocationItems/ErpLocationItemAutoMapperProfile.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/ErpLocationItems/ErpLocationItemAutoMapperProfile.cs @@ -14,6 +14,7 @@ public partial class BasedataApplicationAutoMapperProfile : Profile CreateMap() .IgnoreAuditedObjectProperties() + .Ignore(x => x.Remark) .Ignore(x => x.TenantId) .Ignore(x => x.ExtraProperties) .Ignore(x => x.ConcurrencyStamp)