diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/Inputs/ItemTransformNoteEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/Inputs/ItemTransformNoteEditInput.cs index f510825a1..89b78e113 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/Inputs/ItemTransformNoteEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/ItemTransformNotes/Inputs/ItemTransformNoteEditInput.cs @@ -33,5 +33,10 @@ public class ItemTransformNoteEditInput : SfsStoreCreateOrUpdateInputBase /// [Display(Name = "明细列表")] public List Details { get; set; } = new List(); + /// + /// 混拌料入库数据 + /// + + public List RecDetails { get; set; } = new List(); #endregion } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/RecycledMaterialReceiptNotes/IRecycledMaterialReceiptNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/RecycledMaterialReceiptNotes/IRecycledMaterialReceiptNoteAppService.cs index 3b42f839c..d62a3746e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/RecycledMaterialReceiptNotes/IRecycledMaterialReceiptNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/RecycledMaterialReceiptNotes/IRecycledMaterialReceiptNoteAppService.cs @@ -6,4 +6,5 @@ public interface IRecycledMaterialReceiptNoteAppService : ISfsStoreMasterReadOnlyAppServiceBase { Task CreateAsync(RecycledMaterialReceiptNoteEditInput input); + Task NewCreateAsync(RecycledMaterialReceiptNoteEditInput input); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ItemTransformNotes/ItemTransformNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ItemTransformNotes/ItemTransformNoteAppService.cs index 0d361afa1..034634fd8 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ItemTransformNotes/ItemTransformNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ItemTransformNotes/ItemTransformNoteAppService.cs @@ -20,13 +20,16 @@ public class ItemTransformNoteAppService : { private readonly IItemTransformNoteManager _ItemTransformNoteManager; private readonly ILocationCapacityAppService _locationCapacityAppService; + private readonly IRecycledMaterialReceiptNoteAppService _recycledMaterialReceiptNoteAppService; public ItemTransformNoteAppService(IItemTransformNoteRepository repository, IItemTransformNoteManager ItemTransformNoteManager, - ILocationCapacityAppService locationCapacityAppService) : base(repository) + ILocationCapacityAppService locationCapacityAppService, + IRecycledMaterialReceiptNoteAppService recycledMaterialReceiptNoteAppService) : base(repository) { _ItemTransformNoteManager = ItemTransformNoteManager; _locationCapacityAppService = locationCapacityAppService; + _recycledMaterialReceiptNoteAppService = recycledMaterialReceiptNoteAppService; } [HttpPost("")] @@ -41,4 +44,18 @@ public class ItemTransformNoteAppService : return dto; } + + [HttpPost("new-create")] + //[Authorize(ItemTransformNotePermissions.Create)] + public async Task NewCreateAsync(ItemTransformNoteEditInput input) + { + var entity = ObjectMapper.Map(input); + await _ItemTransformNoteManager.CreateAsync(entity).ConfigureAwait(false); + var recInput = ObjectMapper.Map(input); + await _recycledMaterialReceiptNoteAppService.NewCreateAsync(recInput).ConfigureAwait(false); + var dto = ObjectMapper.Map(entity); + + return dto; + } + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ItemTransformNotes/ItemTransformNoteAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ItemTransformNotes/ItemTransformNoteAutoMapperProfile.cs index 341d1b2ac..dce86437e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ItemTransformNotes/ItemTransformNoteAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ItemTransformNotes/ItemTransformNoteAutoMapperProfile.cs @@ -30,7 +30,12 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.Number) .Ignore(x => x.Id) .Ignore(x=>x.ExtraProperties) - .Ignore(x => x.Remark) - ; + .Ignore(x => x.Remark); + CreateMap() + .ForMember(x => x.Details, y => y.MapFrom(d => d.RecDetails)) + .Ignore(x => x.TenantId) + .Ignore(x => x.Number) + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.Remark); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/RecycledMaterialReceiptNotes/RecycledMaterialReceiptNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/RecycledMaterialReceiptNotes/RecycledMaterialReceiptNoteAppService.cs index 3e09d396c..c66029c60 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/RecycledMaterialReceiptNotes/RecycledMaterialReceiptNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/RecycledMaterialReceiptNotes/RecycledMaterialReceiptNoteAppService.cs @@ -78,4 +78,38 @@ public class RecycledMaterialReceiptNoteAppService : return ObjectMapper.Map(entity); } + + /// + /// 新增实体 + /// + /// CreateInput + [HttpPost("new-create")] + public async Task NewCreateAsync(RecycledMaterialReceiptNoteEditInput input) + { + var entity = ObjectMapper.Map(input); + + entity.Number = string.IsNullOrEmpty(input.Number) + ? await GenerateNumberAsync(nameof(RecycledMaterialReceiptNote), input.ActiveDate) + .ConfigureAwait(false) + : input.Number; + entity.SetId(GuidGenerator.Create()); + + foreach (var detail in entity.Details) + { + var detailNumber = await GenerateNumberAsync(nameof(RecycledMaterialReceiptNote), input.ActiveDate) + .ConfigureAwait(false); + detail.SetIdAndNumber(GuidGenerator, entity.Id, detailNumber); + var locationDto = await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); + detail.LocationErpCode = locationDto.ErpLocationCode; + detail.LocationArea = locationDto.AreaCode; + detail.LocationGroup = locationDto.LocationGroupCode; + detail.WarehouseCode = locationDto.WarehouseCode; + var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); + detail.StdPackQty = itemBasicDto.StdPackQty; + detail.Uom = itemBasicDto.BasicUom; + } + + entity = await _repository.InsertAsync(entity).ConfigureAwait(false); + return ObjectMapper.Map(entity); + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ItemTransformNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ItemTransformNoteEventHandler.cs index c33adc601..601b86bbd 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ItemTransformNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/ItemTransformNoteEventHandler.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Volo.Abp.EventBus; using Volo.Abp.Uow; @@ -28,10 +29,11 @@ public class ItemTransformNoteEventHandler private async Task AddTransactionsAsync(ItemTransformNote note) { var inboundTransactions = new List(); - - inboundTransactions.AddRange(BuildTransactions(note)); - + var noTransactions = new List(); + inboundTransactions.AddRange(NewBuildTransactions(note));//原料+混拌料 + noTransactions.AddRange(BuildNoTransactions(note));//粉碎料 await TransactionAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); + await TransactionAppService.AddManyEmptyAsync(noTransactions).ConfigureAwait(false); } @@ -46,14 +48,16 @@ public class ItemTransformNoteEventHandler { var inboundTransactions = new List(); - + var noTransactions = new List(); //如果要做库存事务汇总,可以修改此处 foreach (var note in notes) { - inboundTransactions.AddRange(BuildTransactions(note)); + inboundTransactions.AddRange(NewBuildTransactions(note));//原料+混拌料 + noTransactions.AddRange(BuildNoTransactions(note));//粉碎料 } await TransactionAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); + await TransactionAppService.AddManyEmptyAsync(noTransactions).ConfigureAwait(false); } private static List BuildTransactions(ItemTransformNote note) @@ -131,4 +135,151 @@ public class ItemTransformNoteEventHandler return transactions; } + /// + /// 新回收料库存方法 + /// + /// + /// + + private static List NewBuildTransactions(ItemTransformNote note) + { + var transactions = new List(); + + //根据调整记录,构造库存转移记录(只添加原料得) + foreach (var detail in note.Details.Where(r => r.Remark == "原料")) + { + var transactionOut = new TransactionEditInput() + { + Worker = note.Worker, + JobNumber = note.JobNumber, + DocNumber = note.Number, + TransType = Type, + TransSubType = SubType, + TransInOut = EnumTransInOut.Out, + LocationArea = detail.FromLocationArea, + LocationGroup = detail.FromLocationGroup, + LocationErpCode = detail.FromLocationErpCode, + PackingCode = detail.FromPackingCode, + ItemCode = detail.ItemCode, + Lot = detail.FromLot, + Status = detail.FromStatus, + WarehouseCode = detail.FromWarehouseCode, + LocationCode = detail.FromLocationCode, + ContainerCode = detail.FromContainerCode, + SupplierBatch = detail.FromSupplierBatch, + ArriveDate = detail.FromArriveDate, + ProduceDate = detail.FromProduceDate, + ExpireDate = detail.FromExpireDate, + ItemName = detail.ItemName, + ItemDesc1 = detail.ItemDesc1, + ItemDesc2 = detail.ItemDesc2, + Uom = detail.Uom, + Qty = -detail.FromQty, + }; + + transactions.Add(transactionOut); + } + //混拌料添加事务 + var detailfirst = note.Details.First(r => r.Remark == "原料"); + var transactionIn = new TransactionEditInput() + { + Worker = note.Worker, + JobNumber = note.JobNumber, + DocNumber = note.Number, + TransType = Type, + TransSubType = SubType, + TransInOut = EnumTransInOut.In, + + PackingCode = detailfirst.ToPackingCode, + ItemCode = detailfirst.ToItemCode, + Lot = detailfirst.ToLot, + Status = detailfirst.ToStatus, + LocationArea = detailfirst.ToLocationArea, + LocationGroup = detailfirst.ToLocationGroup, + LocationErpCode = detailfirst.ToLocationErpCode, + WarehouseCode = detailfirst.ToWarehouseCode, + LocationCode = detailfirst.ToLocationCode, + ContainerCode = detailfirst.ToContainerCode, + SupplierBatch = detailfirst.ToSupplierBatch, + ArriveDate = detailfirst.ToArriveDate, + ProduceDate = detailfirst.ToProduceDate, + ExpireDate = detailfirst.ToExpireDate, + ItemName = detailfirst.ItemName, + ItemDesc1 = detailfirst.ItemDesc1, + ItemDesc2 = detailfirst.ItemDesc2, + Uom = detailfirst.Uom, + Qty = detailfirst.ToQty, + }; + transactions.Add(transactionIn); + + return transactions; + } + private static List BuildNoTransactions(ItemTransformNote note) + { + var transactions = new List(); + + //根据调整记录,构造库存转移记录(只添加原料得) + foreach (var detail in note.Details.Where(r => r.Remark != "原料")) + { + var transactionOut = new TransactionEditInput() + { + Worker = note.Worker, + JobNumber = note.JobNumber, + DocNumber = note.Number, + TransType = Type, + TransSubType = SubType, + TransInOut = EnumTransInOut.Out, + LocationArea = detail.FromLocationArea, + LocationGroup = detail.FromLocationGroup, + LocationErpCode = detail.FromLocationErpCode, + PackingCode = detail.FromPackingCode, + ItemCode = detail.ItemCode, + Lot = detail.FromLot, + Status = detail.FromStatus, + WarehouseCode = detail.FromWarehouseCode, + LocationCode = detail.FromLocationCode, + ContainerCode = detail.FromContainerCode, + SupplierBatch = detail.FromSupplierBatch, + ArriveDate = detail.FromArriveDate, + ProduceDate = detail.FromProduceDate, + ExpireDate = detail.FromExpireDate, + ItemName = detail.ItemName, + ItemDesc1 = detail.ItemDesc1, + ItemDesc2 = detail.ItemDesc2, + Uom = detail.Uom, + Qty = -detail.FromQty, + }; + transactions.Add(transactionOut); + var transactionIn = new TransactionEditInput() + { + Worker = note.Worker, + JobNumber = note.JobNumber, + DocNumber = note.Number, + TransType = Type, + TransSubType = SubType, + TransInOut = EnumTransInOut.In, + LocationArea = detail.FromLocationArea, + LocationGroup = detail.FromLocationGroup, + LocationErpCode = detail.FromLocationErpCode, + PackingCode = detail.FromPackingCode, + ItemCode = detail.ItemCode, + Lot = detail.FromLot, + Status = detail.FromStatus, + WarehouseCode = detail.FromWarehouseCode, + LocationCode = detail.FromLocationCode, + ContainerCode = detail.FromContainerCode, + SupplierBatch = detail.FromSupplierBatch, + ArriveDate = detail.FromArriveDate, + ProduceDate = detail.FromProduceDate, + ExpireDate = detail.FromExpireDate, + ItemName = detail.ItemName, + ItemDesc1 = detail.ItemDesc1, + ItemDesc2 = detail.ItemDesc2, + Uom = detail.Uom, + Qty = detail.FromQty, + }; + transactions.Add(transactionIn); + } + return transactions; + } }