diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs index fef00ed7b..4a854e852 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inventory/EnumTransSubType.cs @@ -90,6 +90,12 @@ public enum EnumTransSubType [Display(Name = "拆箱")] Transfer_SplitPacking = 3109, + /// + /// 合箱 + /// + [Display(Name = "合箱")] + Transfer_Integration = 3109, + /// /// 线边报废 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs index 128825d74..e1d236b2a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/OperationPacking/IntegrationPackingNotes/IntegrationPackingNoteAppService.cs @@ -1,15 +1,19 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using IdentityModel; using IdentityServer4.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Volo.Abp; +using Volo.Abp.Domain.Entities; +using Volo.Abp.Guids; using Volo.Abp.ObjectMapping; using Win_in.Sfs.Basedata; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Domain.Shared; using Win_in.Sfs.Label.Application.Contracts; +using Win_in.Sfs.Shared.Application; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; @@ -67,109 +71,38 @@ public class IntegrationPackingNoteAppService : public override async Task CreateAsync(IntegrationPackingNoteEditInput input) { var transferLogEditInputs = new List(); - var outDtos=await _expectOutAppService.GetListByPackingCodeAsync(input.PackingCode).ConfigureAwait(false); + + var outDtos = await _expectOutAppService.GetListByPackingCodeAsync(input.PackingCode).ConfigureAwait(false); if (outDtos.Any()) { throw new UserFriendlyException($"此物料已经被【任务编号:{outDtos.First().JobNumber}】占用"); } - foreach (var detailInput in input.Details) + if (input.Details.Any(p=>p.Qty<=0)) { - //标签记录 - 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, - ProdLine = string.Empty, - AsnNumber = detailInput.PurchaseInfo_AsnNumber, - ContainerCode = detailInput.ContainerCode, - ExpireDate = detailInput.ExpireDate, - FullBarcodeString = string.Empty, - ItemDesc2 = detailInput.ItemDesc2, - ItemName = detailInput.ItemName, - SupplierName = detailInput.SupplierName, - Remark = detailInput.Remark, - LabelStatus = LabelStatus.Enable, - LabelType = detailInput.LabelType, - PlanArriveDate = detailInput.PlanArriveDate, - PoNumber = detailInput.PurchaseInfo_PoNumber, - ProduceDate = detailInput.ProduceDate, - QLevel = string.Empty, - QualityFile = string.Empty, - RecommendLocationCode = detailInput.RecommendLocationCode, - RpNumber = detailInput.RpNumber, - Shift = string.Empty, - Specifications = string.Empty, - SupplierBatch = detailInput.SupplierBatch, - SupplierItemCode = detailInput.ItemCode, - SupplierItemName = detailInput.SupplierItemName, - SupplierSimpleName = detailInput.SupplierSimpleName, - Team = string.Empty, - }; - var inventoryLabelDto=await _inventoryLabelAppService.GenerateAndCreateAsync(inventoryLabelWithoutCodeCreateInput).ConfigureAwait(false); - var splitPackingRecEditInputs = new List() - { - new SplitPackingRecEditInput() - { - ItemCode = inventoryLabelDto.ItemCode, - SupplierCode = inventoryLabelDto.SupplierCode, - ToPackingCode = inventoryLabelDto.Code, - FromPackingCode = input.PackingCode, - LocationErpCode = inventoryLabelDto.LocationErpCode, - ItemDesc1 = inventoryLabelDto.ItemDesc1, - FromLot = input.Lot, - ToLot = inventoryLabelDto.Lot, - ArriveDate = inventoryLabelDto.ArriveDate, - ItemName = inventoryLabelDto.ItemName, - ItemDesc2 = inventoryLabelDto.ItemDesc2, - PurchaseInfo_PoNumber = inventoryLabelDto.PoNumber, - LabelType = (EnumLabelType)inventoryLabelDto.LabelType, - RecommendLocationCode = inventoryLabelDto.RecommendLocationCode, - RpNumber = inventoryLabelDto.RpNumber, - SupplierName = inventoryLabelDto.SupplierName, - Remark = inventoryLabelDto.Remark, - FromQty = input.Qty, - ToQty = inventoryLabelDto.Qty, - PurchaseInfo_AsnNumber = inventoryLabelDto.AsnNumber, - ExpireDate = inventoryLabelDto.ExpireDate, - FullBarcodeString = inventoryLabelDto.FullBarcodeString, - SupplierBatch = inventoryLabelDto.SupplierBatch, - ProduceDate = inventoryLabelDto.ProduceDate, - LabelStatus = Basedata.LabelStatus.Enable, - SupplierSimpleName = inventoryLabelDto.SupplierSimpleName, - SupplierItemCode = inventoryLabelDto.SupplierItemCode, - SupplierItemName = inventoryLabelDto.SupplierItemName, - PlanArriveDate = inventoryLabelDto.PlanArriveDate, - FromStdPackQty = input.StdPackQty, - FromUom = input.Uom, - OprType = OprTypeEnum.SplitBox, - ReceiptRecNumber = inventoryLabelDto.RpNumber, - ToStdPackQty = inventoryLabelDto.StdPackQty, - ToUom = inventoryLabelDto.Uom, - TaskOrderNumber = detailInput.TaskOrderNumber, - ArrivalNoticNumber = detailInput.ArrivalNoticNumber, - PutOnShelfNumber = detailInput.PutOnShelfNumber, - } - }; - await _splitPackingRecAppService.BatchInsertAsync(splitPackingRecEditInputs).ConfigureAwait(false); + throw new UserFriendlyException($"数量必须大于0"); + } + + var entity = input.ToObject(); + var number = await GenerateNumberAsync(nameof(IntegrationPackingNote), Clock.Now).ConfigureAwait(false); + entity.Number = number; + entity.SetId(GuidGenerator.Create()); + entity.SetIdAndNumberWithDetails(GuidGenerator, entity.Number); + + entity = await _repository.InsertAsync(entity).ConfigureAwait(false); + var dto = entity.ToObject(); - //创建标签 - var dto= await base.CreateAsync(input).ConfigureAwait(false); + //var dto = await base.CreateAsync(input).ConfigureAwait(false); + foreach (var detailInput in input.Details) + { //库存移动 - var transferLogEditInput=await BuildTransferLogsAsync(dto, detailInput, splitPackingRecEditInputs.First()).ConfigureAwait(false); + var transferLogEditInput = await BuildTransferLogsAsync(dto, detailInput).ConfigureAwait(false); transferLogEditInputs.Add(transferLogEditInput); } await _transferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false); + return dto; } /// @@ -177,15 +110,13 @@ public class IntegrationPackingNoteAppService : /// /// /// - /// /// private async Task BuildTransferLogsAsync( IntegrationPackingNoteDTO dto, - IntegrationPackingNoteDetailInput detailInput, - SplitPackingRecEditInput splitPackingRecEditInput) + IntegrationPackingNoteDetailInput detailInput) { - var fromLocationDto = await _locationAppService.GetByCodeAsync(dto.LocationCode).ConfigureAwait(false); - var toLocationDto = await _locationAppService.GetByCodeAsync(detailInput.LocationCode).ConfigureAwait(false); + var fromLocationDto = await _locationAppService.GetByCodeAsync(detailInput.LocationCode).ConfigureAwait(false); + var toLocationDto = await _locationAppService.GetByCodeAsync(dto.LocationCode).ConfigureAwait(false); var transferLogEditInput = new TransferLogEditInput { @@ -202,35 +133,30 @@ public class IntegrationPackingNoteAppService : ToLocationArea = toLocationDto.AreaCode, ToLocationGroup = toLocationDto.LocationGroupCode, ToWarehouseCode = toLocationDto.WarehouseCode, - ToPackingCode = splitPackingRecEditInput.ToPackingCode, - Remark = splitPackingRecEditInput.Remark, - ArriveDate = splitPackingRecEditInput.ArriveDate, + ToPackingCode = dto.PackingCode, + Remark = dto.Remark, + ArriveDate = dto.ArriveDate, DocNumber = string.Empty, - ExpireDate = splitPackingRecEditInput.ExpireDate, + ExpireDate = dto.ExpireDate, FromContainerCode = detailInput.ContainerCode, - FromLot = splitPackingRecEditInput.FromLot, - FromPackingCode = dto.PackingCode, - Uom = splitPackingRecEditInput.FromUom, + FromLot = detailInput.Lot, + FromPackingCode = detailInput.PackingCode, + Uom = detailInput.Uom, FromStatus = EnumInventoryStatus.OK, JobNumber = string.Empty, - ItemDesc1 = splitPackingRecEditInput.ItemDesc1, - StdPackQty = splitPackingRecEditInput.FromStdPackQty, + ItemDesc1 = dto.ItemDesc1, + StdPackQty = dto.StdPackQty, TransType = EnumTransType.Transfer, - ToLot = splitPackingRecEditInput.ToLot, - ItemDesc2 = splitPackingRecEditInput.ItemDesc2, - ItemName = splitPackingRecEditInput.ItemName, - ProduceDate = splitPackingRecEditInput.ProduceDate, - SupplierBatch = splitPackingRecEditInput.SupplierBatch, + ToLot = dto.Lot, + ItemDesc2 = dto.ItemDesc2, + ItemName = dto.ItemName, + ProduceDate = dto.ProduceDate, + SupplierBatch = dto.SupplierBatch, ToContainerCode = detailInput.ContainerCode, ToStatus = EnumInventoryStatus.OK, - TransSubType = EnumTransSubType.Transfer_SplitPacking + TransSubType = EnumTransSubType.Transfer_Integration, }; return transferLogEditInput; } - - private async Task CreateLabelAsync() - { - var batchInsert=await _splitPackingRecAppService.BatchInsertAsync().ConfigureAwait(false); - } } 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 dc41caa3c..31f2bf534 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 @@ -1,8 +1,21 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Win_in.Sfs.Basedata; +using Win_in.Sfs.Basedata.Application; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Basedata.Domain.Shared; +using Win_in.Sfs.Label.Application.Contracts; +using Win_in.Sfs.Shared.Application; +using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; +using LabelStatus = Win_in.Sfs.Label.Domain.Shared.LabelStatus; namespace Win_in.Sfs.Wms.Store.Application; @@ -25,11 +38,210 @@ public class SeparationPackingNoteAppService : ISeparationPackingNoteAppService { private readonly ISeparationPackingNoteManager _separationPackingNoteManager; + private readonly IBalanceAppService _balanceAppService; + private readonly ILocationAppService _locationAppService; + private readonly ITransferLogAppService _transferLogAppService; + private readonly IExpectOutAppService _expectOutAppService; + private readonly ISplitPackingRecAppService _splitPackingRecAppService; + private readonly IInventoryLabelAppService _inventoryLabelAppService; public SeparationPackingNoteAppService( ISeparationPackingNoteRepository repository, - ISeparationPackingNoteManager separationPackingNoteManager) : base(repository) + ISeparationPackingNoteManager separationPackingNoteManager, IBalanceAppService balanceAppService, ILocationAppService locationAppService, ITransferLogAppService transferLogAppService, IExpectOutAppService expectOutAppService, ISplitPackingRecAppService splitPackingRecAppService, IInventoryLabelAppService inventoryLabelAppService) : base(repository) { _separationPackingNoteManager = separationPackingNoteManager; + _balanceAppService = balanceAppService; + _locationAppService = locationAppService; + _transferLogAppService = transferLogAppService; + _expectOutAppService = expectOutAppService; + _splitPackingRecAppService = splitPackingRecAppService; + _inventoryLabelAppService = inventoryLabelAppService; + } + + [HttpPost("")] + public override async Task CreateAsync(SeparationPackingNoteEditInput input) + { + var transferLogEditInputs = new List(); + + var outDtos = await _expectOutAppService.GetListByPackingCodeAsync(input.PackingCode).ConfigureAwait(false); + if (outDtos.Any()) + { + throw new UserFriendlyException($"此物料已经被【任务编号:{outDtos.First().JobNumber}】占用"); + } + + if (input.Details.Sum(p => p.Qty) > input.Qty) + { + throw new UserFriendlyException($"拆出数量大于原箱数量"); + } + + if (input.Qty <= 0) + { + throw new UserFriendlyException($"数量小于或等于0"); + } + + var entity = input.ToObject(); + var number = await GenerateNumberAsync(nameof(SeparationPackingNote), Clock.Now).ConfigureAwait(false); + entity.Number = number; + entity.SetId(GuidGenerator.Create()); + entity.SetIdAndNumberWithDetails(GuidGenerator, entity.Number); + + entity = await _repository.InsertAsync(entity).ConfigureAwait(false); + var dto = entity.ToObject(); + + //var dto = await base.CreateAsync(input).ConfigureAwait(false); + + foreach (var detailInput in input.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, + ProdLine = string.Empty, + AsnNumber = detailInput.PurchaseInfo_AsnNumber, + ContainerCode = detailInput.ContainerCode, + ExpireDate = detailInput.ExpireDate, + FullBarcodeString = string.Empty, + ItemDesc2 = detailInput.ItemDesc2, + ItemName = detailInput.ItemName, + SupplierName = detailInput.SupplierName, + Remark = detailInput.Remark, + LabelStatus = LabelStatus.Enable, + LabelType = detailInput.LabelType, + PlanArriveDate = detailInput.PlanArriveDate, + PoNumber = detailInput.PurchaseInfo_PoNumber, + ProduceDate = detailInput.ProduceDate, + QLevel = string.Empty, + QualityFile = string.Empty, + RecommendLocationCode = detailInput.RecommendLocationCode, + RpNumber = detailInput.RpNumber, + Shift = string.Empty, + Specifications = string.Empty, + SupplierBatch = detailInput.SupplierBatch, + SupplierItemCode = detailInput.ItemCode, + SupplierItemName = detailInput.SupplierItemName, + SupplierSimpleName = detailInput.SupplierSimpleName, + Team = string.Empty, + }; + var inventoryLabelDto = await _inventoryLabelAppService.GenerateAndCreateAsync(inventoryLabelWithoutCodeCreateInput).ConfigureAwait(false); + var splitPackingRecEditInputs = new List() + { + new SplitPackingRecEditInput() + { + ItemCode = inventoryLabelDto.ItemCode, + SupplierCode = inventoryLabelDto.SupplierCode, + ToPackingCode = inventoryLabelDto.Code, + FromPackingCode = input.PackingCode, + LocationErpCode = inventoryLabelDto.LocationErpCode, + ItemDesc1 = inventoryLabelDto.ItemDesc1, + FromLot = input.Lot, + ToLot = inventoryLabelDto.Lot, + ArriveDate = inventoryLabelDto.ArriveDate, + ItemName = inventoryLabelDto.ItemName, + ItemDesc2 = inventoryLabelDto.ItemDesc2, + PurchaseInfo_PoNumber = inventoryLabelDto.PoNumber, + LabelType = (EnumLabelType)inventoryLabelDto.LabelType, + RecommendLocationCode = inventoryLabelDto.RecommendLocationCode, + RpNumber = inventoryLabelDto.RpNumber, + SupplierName = inventoryLabelDto.SupplierName, + Remark = inventoryLabelDto.Remark, + FromQty = input.Qty, + ToQty = inventoryLabelDto.Qty, + PurchaseInfo_AsnNumber = inventoryLabelDto.AsnNumber, + ExpireDate = inventoryLabelDto.ExpireDate, + FullBarcodeString = inventoryLabelDto.FullBarcodeString, + SupplierBatch = inventoryLabelDto.SupplierBatch, + ProduceDate = inventoryLabelDto.ProduceDate, + LabelStatus = Basedata.LabelStatus.Enable, + SupplierSimpleName = inventoryLabelDto.SupplierSimpleName, + SupplierItemCode = inventoryLabelDto.SupplierItemCode, + SupplierItemName = inventoryLabelDto.SupplierItemName, + PlanArriveDate = inventoryLabelDto.PlanArriveDate, + FromStdPackQty = input.StdPackQty, + FromUom = input.Uom, + OprType = OprTypeEnum.SplitBox, + ReceiptRecNumber = inventoryLabelDto.RpNumber, + ToStdPackQty = inventoryLabelDto.StdPackQty, + ToUom = inventoryLabelDto.Uom, + TaskOrderNumber = detailInput.TaskOrderNumber, + ArrivalNoticNumber = detailInput.ArrivalNoticNumber, + PutOnShelfNumber = detailInput.PutOnShelfNumber, + } + }; + await _splitPackingRecAppService.BatchInsertAsync(splitPackingRecEditInputs).ConfigureAwait(false); + + //库存移动 + var transferLogEditInput = await BuildTransferLogsAsync(dto, detailInput, splitPackingRecEditInputs.First()).ConfigureAwait(false); + transferLogEditInputs.Add(transferLogEditInput); + } + + await _transferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false); + return dto; + } + + /// + /// 构造 库存转移日志实体 + /// + /// + /// + /// + /// + private async Task BuildTransferLogsAsync( + SeparationPackingNoteDTO dto, + SeparationPackingNoteDetailInput detailInput, + SplitPackingRecEditInput splitPackingRecEditInput) + { + var fromLocationDto = await _locationAppService.GetByCodeAsync(dto.LocationCode).ConfigureAwait(false); + var toLocationDto = await _locationAppService.GetByCodeAsync(detailInput.LocationCode).ConfigureAwait(false); + + var transferLogEditInput = new TransferLogEditInput + { + Worker = dto.Worker, + Qty = detailInput.Qty, + ItemCode = detailInput.ItemCode, + FromLocationCode = fromLocationDto.Code, + FromLocationErpCode = fromLocationDto.ErpLocationCode, + FromLocationArea = fromLocationDto.AreaCode, + FromLocationGroup = fromLocationDto.LocationGroupCode, + FromWarehouseCode = fromLocationDto.WarehouseCode, + ToLocationCode = toLocationDto.Code, + ToLocationErpCode = toLocationDto.ErpLocationCode, + ToLocationArea = toLocationDto.AreaCode, + ToLocationGroup = toLocationDto.LocationGroupCode, + ToWarehouseCode = toLocationDto.WarehouseCode, + ToPackingCode = splitPackingRecEditInput.ToPackingCode, + Remark = splitPackingRecEditInput.Remark, + ArriveDate = splitPackingRecEditInput.ArriveDate, + DocNumber = string.Empty, + ExpireDate = splitPackingRecEditInput.ExpireDate, + FromContainerCode = detailInput.ContainerCode, + FromLot = splitPackingRecEditInput.FromLot, + FromPackingCode = dto.PackingCode, + Uom = splitPackingRecEditInput.FromUom, + FromStatus = EnumInventoryStatus.OK, + JobNumber = string.Empty, + ItemDesc1 = splitPackingRecEditInput.ItemDesc1, + StdPackQty = splitPackingRecEditInput.FromStdPackQty, + TransType = EnumTransType.Transfer, + ToLot = splitPackingRecEditInput.ToLot, + ItemDesc2 = splitPackingRecEditInput.ItemDesc2, + ItemName = splitPackingRecEditInput.ItemName, + ProduceDate = splitPackingRecEditInput.ProduceDate, + SupplierBatch = splitPackingRecEditInput.SupplierBatch, + ToContainerCode = detailInput.ContainerCode, + ToStatus = EnumInventoryStatus.OK, + TransSubType = EnumTransSubType.Transfer_SplitPacking + }; + + return transferLogEditInput; } } diff --git a/build/src/docker/publish/conf/settings/appsettings.Development.json b/build/src/docker/publish/conf/settings/appsettings.Development.json index 8078b8487..c593fae20 100644 --- a/build/src/docker/publish/conf/settings/appsettings.Development.json +++ b/build/src/docker/publish/conf/settings/appsettings.Development.json @@ -148,8 +148,8 @@ //"BaseUrl": "http://localhost:59093/" }, "BaseData": { - "BaseUrl": "http://dev.ccwin-in.com:60084/" - //"BaseUrl": "http://localhost:59094/" + //"BaseUrl": "http://dev.ccwin-in.com:60084/" + "BaseUrl": "http://localhost:59094/" }, "Default": { "BaseUrl": "http://dev.ccwin-in.com:60083/"