diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs index d7aa5e023..72f851c3d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/SeparationPackingNotes/SeparationPackingNoteAppService.cs @@ -86,48 +86,47 @@ public class SeparationPackingNoteAppService : entity.SetIdAndNumberWithDetails(GuidGenerator, entity.Number); entity = await _repository.InsertAsync(entity).ConfigureAwait(false); - var dto = entity.ToObject(); - foreach (var detailInput in input.Details) + foreach (var detail in entity.Details) { //创建标签 var splitPackingRecDtos = await _splitPackingRecAppService.GetListByToPackingCode(new List { input.PackingCode }).ConfigureAwait(false); var splitPackingRecDto = splitPackingRecDtos.First(); var inventoryLabelWithoutCodeCreateInput = new InventoryLabelWithoutCodeCreateInput { - Qty = detailInput.Qty, - ItemCode = detailInput.ItemCode, - SupplierCode = detailInput.SupplierCode, - Lot = detailInput.Lot, - Uom = detailInput.Uom, - LocationErpCode = detailInput.LocationErpCode, - ItemDesc1 = detailInput.ItemDesc1, - ArriveDate = detailInput.ArriveDate, - StdPackQty = detailInput.StdPackQty, + Qty = detail.Qty, + ItemCode = detail.ItemCode, + SupplierCode = detail.SupplierCode, + Lot = detail.Lot, + Uom = detail.Uom, + LocationErpCode = detail.LocationErpCode, + ItemDesc1 = detail.ItemDesc1, + ArriveDate = detail.ArriveDate, + StdPackQty = detail.StdPackQty, ProdLine = string.Empty, - AsnNumber = detailInput.PurchaseInfo_AsnNumber, - ContainerCode = detailInput.ContainerCode, - ExpireDate = detailInput.ExpireDate, + AsnNumber = detail.PurchaseInfo_AsnNumber, + ContainerCode = detail.ContainerCode, + ExpireDate = detail.ExpireDate, FullBarcodeString = string.Empty, - ItemDesc2 = detailInput.ItemDesc2, - ItemName = detailInput.ItemName, - SupplierName = detailInput.SupplierName, - Remark = detailInput.Remark, + ItemDesc2 = detail.ItemDesc2, + ItemName = detail.ItemName, + SupplierName = detail.SupplierName, + Remark = detail.Remark, LabelStatus = LabelStatus.Enable, - LabelType = detailInput.LabelType, - PlanArriveDate = detailInput.PlanArriveDate, - PoNumber = detailInput.PurchaseInfo_PoNumber, - ProduceDate = detailInput.ProduceDate, + LabelType = detail.LabelType, + PlanArriveDate = detail.PlanArriveDate, + PoNumber = detail.PurchaseInfo_PoNumber, + ProduceDate = detail.ProduceDate, QLevel = string.Empty, QualityFile = string.Empty, - RecommendLocationCode = detailInput.RecommendLocationCode, - RpNumber = detailInput.RpNumber, + RecommendLocationCode = detail.RecommendLocationCode, + RpNumber = detail.RpNumber, Shift = string.Empty, Specifications = string.Empty, - SupplierBatch = detailInput.SupplierBatch, - SupplierItemCode = detailInput.ItemCode, - SupplierItemName = detailInput.SupplierItemName, - SupplierSimpleName = detailInput.SupplierSimpleName, + SupplierBatch = detail.SupplierBatch, + SupplierItemCode = detail.ItemCode, + SupplierItemName = detail.SupplierItemName, + SupplierSimpleName = detail.SupplierSimpleName, Team = string.Empty, }; var inventoryLabelDto = await _inventoryLabelAppService.GenerateAndCreateAsync(inventoryLabelWithoutCodeCreateInput).ConfigureAwait(false); @@ -170,18 +169,22 @@ public class SeparationPackingNoteAppService : ReceiptRecNumber = inventoryLabelDto.RpNumber, ToStdPackQty = inventoryLabelDto.StdPackQty, ToUom = inventoryLabelDto.Uom, - TaskOrderNumber = detailInput.TaskOrderNumber, - ArrivalNoticNumber = detailInput.ArrivalNoticNumber, - PutOnShelfNumber = detailInput.PutOnShelfNumber, + TaskOrderNumber = detail.TaskOrderNumber, + ArrivalNoticNumber = detail.ArrivalNoticNumber, + PutOnShelfNumber = detail.PutOnShelfNumber, } }; await _splitPackingRecAppService.BatchInsertAsync(splitPackingRecEditInputs).ConfigureAwait(false); + detail.PackingCode = inventoryLabelDto.Code; //库存移动 - var transferLogEditInput = await BuildTransferLogsAsync(dto, detailInput, splitPackingRecEditInputs.First()).ConfigureAwait(false); + var transferLogEditInput = await BuildTransferLogsAsync(entity, detail, splitPackingRecEditInputs.First()).ConfigureAwait(false); transferLogEditInputs.Add(transferLogEditInput); } + await _repository.UpdateAsync(entity).ConfigureAwait(false); + var dto = entity.ToObject(); + await _transferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false); return dto; } @@ -189,23 +192,23 @@ public class SeparationPackingNoteAppService : /// /// 构造 库存转移日志实体 /// - /// - /// + /// + /// /// /// private async Task BuildTransferLogsAsync( - SeparationPackingNoteDTO dto, - SeparationPackingNoteDetailInput detailInput, + SeparationPackingNote entity, + SeparationPackingNoteDetail detail, SplitPackingRecEditInput splitPackingRecEditInput) { - var fromLocationDto = await _locationAppService.GetByCodeAsync(dto.LocationCode).ConfigureAwait(false); - var toLocationDto = await _locationAppService.GetByCodeAsync(detailInput.LocationCode).ConfigureAwait(false); + var fromLocationDto = await _locationAppService.GetByCodeAsync(entity.LocationCode).ConfigureAwait(false); + var toLocationDto = await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); var transferLogEditInput = new TransferLogEditInput { - Worker = dto.Worker, - Qty = detailInput.Qty, - ItemCode = detailInput.ItemCode, + Worker = entity.Worker, + Qty = detail.Qty, + ItemCode = detail.ItemCode, FromLocationCode = fromLocationDto.Code, FromLocationErpCode = fromLocationDto.ErpLocationCode, FromLocationArea = fromLocationDto.AreaCode, @@ -221,9 +224,9 @@ public class SeparationPackingNoteAppService : ArriveDate = splitPackingRecEditInput.ArriveDate, DocNumber = string.Empty, ExpireDate = splitPackingRecEditInput.ExpireDate, - FromContainerCode = detailInput.ContainerCode, + FromContainerCode = detail.ContainerCode, FromLot = splitPackingRecEditInput.FromLot, - FromPackingCode = dto.PackingCode, + FromPackingCode = entity.PackingCode, Uom = splitPackingRecEditInput.FromUom, FromStatus = EnumInventoryStatus.OK, JobNumber = string.Empty, @@ -235,7 +238,7 @@ public class SeparationPackingNoteAppService : ItemName = splitPackingRecEditInput.ItemName, ProduceDate = splitPackingRecEditInput.ProduceDate, SupplierBatch = splitPackingRecEditInput.SupplierBatch, - ToContainerCode = detailInput.ContainerCode, + ToContainerCode = detail.ContainerCode, ToStatus = EnumInventoryStatus.OK, TransSubType = EnumTransSubType.Transfer_SplitPacking };