diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ProductionReturnNotes/ProductionReturnNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ProductionReturnNotes/ProductionReturnNoteAppService.cs index 5202e5882..d7159cea3 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ProductionReturnNotes/ProductionReturnNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ProductionReturnNotes/ProductionReturnNoteAppService.cs @@ -1,6 +1,10 @@ +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Volo.Abp; +using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; @@ -18,13 +22,19 @@ public class ProductionReturnNoteAppService : IProductionReturnNoteAppService { private readonly IProductionReturnNoteManager _ProductionReturnNoteManager; + private readonly ILocationAppService _locationAppService; + private readonly IItemStoreRelationAppService _itemStoreRelationAppService; public ProductionReturnNoteAppService( IProductionReturnNoteRepository repository , IProductionReturnNoteManager ProductionReturnNoteManager - ) : base(repository) + , ILocationAppService locationAppService + , IItemStoreRelationAppService itemStoreRelationAppService + ) : base(repository) { _ProductionReturnNoteManager = ProductionReturnNoteManager; + _locationAppService = locationAppService; + _itemStoreRelationAppService = itemStoreRelationAppService; } /// @@ -42,6 +52,37 @@ public class ProductionReturnNoteAppService : return dto; } + /// + /// 新增实体(原材料生产退库) + /// + /// + /// + [HttpPost("create-yl")] + //[Authorize(ProductionReturnNotePermissions.Create)] + public async Task CreateYLAsync(ProductionReturnNoteEditInput input) + { + //校验目标库位 + var locCodeLst = input.Details.Select(itm => itm.ToLocationCode).ToList(); + var locLst = await _locationAppService.GetByCodesAsync(locCodeLst).ConfigureAwait(false); + bool allIsBCP = locLst.All(itm => itm.Type == EnumLocationType.RAW); + if (allIsBCP == false) + { + throw new UserFriendlyException("目标库位必须是原材料库位,不允许存在其它类型库位!"); + } + //校验物料和库存关系 + foreach (var item in input.Details) + { + var obj = await _itemStoreRelationAppService.GetFirstAsync(item.ItemCode, item.ToLocationCode).ConfigureAwait(false); + if (obj == null) + { + throw new UserFriendlyException($"物料{item.ItemCode}不能存在目标库位{item.ToLocationCode},物料库存关系表不存在!"); + } + } + var entity = ObjectMapper.Map(input); + await _ProductionReturnNoteManager.CreateAsync(entity).ConfigureAwait(false); + var dto = ObjectMapper.Map(entity); + return dto; + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ProductionReturnRequests/ProductionReturnRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ProductionReturnRequests/ProductionReturnRequestAppService.cs index c8756eb35..ffa0f0d7c 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ProductionReturnRequests/ProductionReturnRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ProductionReturnRequests/ProductionReturnRequestAppService.cs @@ -33,7 +33,7 @@ public class ProductionReturnRequestAppService : private readonly IItemBasicAppService _itemBasicAppService; private readonly ILocationAppService _locationAppService; private readonly IBalanceAppService _balanceAppservice; - + private readonly IItemStoreRelationAppService _itemStoreRelationAppService; @@ -45,8 +45,7 @@ public class ProductionReturnRequestAppService : IItemBasicAppService itemBasicAppService, ILocationAppService locationAppService, IBalanceAppService _balanceAppservice - - + ,IItemStoreRelationAppService itemStoreRelationAppService ) : base(repository, productionRequestReturnManager) { @@ -55,10 +54,13 @@ public class ProductionReturnRequestAppService : _purchaseOrderApp = purchaseOrderApp; _itemBasicAppService = itemBasicAppService; _locationAppService = locationAppService; + _itemStoreRelationAppService = itemStoreRelationAppService; } /// - /// 【创建】生成退料申请 + /// 【创建】生成退料申请(半成品生产退库) + /// 立库生产退库调用CreateLiKuAsync + /// 原材料生产退库调用ProductionReturnNote的CreateYLAsync /// /// /// @@ -66,22 +68,75 @@ public class ProductionReturnRequestAppService : //[Authorize(ProductionReturnRequestPermissions.Create)] public override async Task CreateAsync(ProductionReturnRequestEditInput input) { - - - - - - //SfsInventoryRequestInputBase sfsRequestInput = new SfsInventoryRequestInputBase(); - //sfsRequestInput.Condition - - + //校验目标库位 + var locCodeLst = input.Details.Select(itm => itm.ToLocationCode).ToList(); + var locLst = await _locationAppService.GetByCodesAsync(locCodeLst).ConfigureAwait(false); + bool allIsBCP = locLst.All(itm => itm.Type == EnumLocationType.SEMI); + if (allIsBCP == false) + { + throw new UserFriendlyException("目标库位必须是半成品库位,不允许存在其它类型库位!"); + } + //校验物料和库存关系 + foreach (var item in input.Details) + { + var obj = await _itemStoreRelationAppService.GetFirstAsync(item.ItemCode, item.ToLocationCode).ConfigureAwait(false); + if (obj == null) + { + throw new UserFriendlyException($"物料{item.ItemCode}不能存在目标库位{item.ToLocationCode},物料库存关系表不存在!"); + } + } + var entity = ObjectMapper.Map(input); + //var subType = Enum.Parse(input.Type); + //var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.TransferLib, subType).ConfigureAwait(false); + //entity.Type = ((int)subType).ToString(); + //entity.AutoCompleteJob = tranType.AutoCompleteJob; + //entity.AutoSubmit = tranType.AutoSubmitRequest; + //entity.AutoAgree = tranType.AutoAgreeRequest; + //entity.AutoHandle = tranType.AutoHandleRequest; + //entity.DirectCreateNote = tranType.DirectCreateNote; + await _productionReturnRequestManager.CreateAsync(entity).ConfigureAwait(false); + var dto = ObjectMapper.Map(entity); + return dto; + } + /// + /// 【创建】生成退料申请(立库生产退库) + /// + /// + /// + [HttpPost("create-liku")] + //[Authorize(ProductionReturnRequestPermissions.Create)] + public async Task CreateLiKuAsync(ProductionReturnRequestEditInput input) + { + //校验目标库位 //??没有立库类型 + //var locCodeLst = input.Details.Select(itm => itm.ToLocationCode).ToList(); + //var locLst = await _locationAppService.GetByCodesAsync(locCodeLst).ConfigureAwait(false); + //bool allIsBCP = locLst.All(itm => itm.Type == EnumLocationType.立库); + //if (allIsBCP == false) + //{ + // throw new UserFriendlyException("目标库位必须是立库,不允许存在其它类型库位!"); + //} + //校验物料和库存关系 + foreach (var item in input.Details) + { + var obj = await _itemStoreRelationAppService.GetFirstAsync(item.ItemCode, item.ToLocationCode).ConfigureAwait(false); + if (obj == null) + { + throw new UserFriendlyException($"物料{item.ItemCode}不能存在目标库位{item.ToLocationCode},物料库存关系表不存在!"); + } + } var entity = ObjectMapper.Map(input); - + //var subType = Enum.Parse(input.Type); + //var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.TransferLib, subType).ConfigureAwait(false); + //entity.Type = ((int)subType).ToString(); + //entity.AutoCompleteJob = tranType.AutoCompleteJob; + //entity.AutoSubmit = tranType.AutoSubmitRequest; + //entity.AutoAgree = tranType.AutoAgreeRequest; + //entity.AutoHandle = tranType.AutoHandleRequest; + //entity.DirectCreateNote = tranType.DirectCreateNote; await _productionReturnRequestManager.CreateAsync(entity).ConfigureAwait(false); - var dto = ObjectMapper.Map(entity); return dto; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ProductionReturnJobEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ProductionReturnJobEventHandler.cs index 4690c9f2d..656d006b3 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ProductionReturnJobEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/ProductionReturnJobEventHandler.cs @@ -62,12 +62,23 @@ public class ProductionReturnJobEventHandler : input.ReturnTime=DateTime.Now; input.Details = new List(); - - foreach (var detail in entity.Details.Where(detail => detail.HandledQty != 0)) + foreach (var detail in entity.Details) //.Where(detail => detail.HandledQty != 0) { var inputDetail = ObjectMapper.Map(detail); inputDetail.FromWarehouseCode = entity.WarehouseCode; inputDetail.ToWarehouseCode = entity.WarehouseCode; + + inputDetail.ToLocationArea = detail.HandledToLocationArea; + inputDetail.ToLocationCode = detail.HandledToLocationCode; + inputDetail.ToLocationErpCode = detail.HandledToLocationErpCode; + inputDetail.ToLocationGroup = detail.HandledToLocationGroup; + inputDetail.ToLot = detail.HandledLot; + inputDetail.ToPackingCode = detail.HandledPackingCode; + inputDetail.ToWarehouseCode = detail.HandledToWarehouseCode; + inputDetail.Qty = detail.HandledQty; + inputDetail.HandledQty = detail.HandledQty; + inputDetail.StdPackQty = detail.StdPackQty; + inputDetail.ToStatus = detail.Status; input.Details.Add(inputDetail); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductionReturnRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductionReturnRequestEventHandler.cs index b964e2940..12364bc6e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductionReturnRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductionReturnRequestEventHandler.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Components.Forms; using Omu.ValueInjecter; using Volo.Abp.EventBus; +using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; @@ -33,68 +34,65 @@ public class ProductionReturnRequestEventHandler { var entity = eventData.Entity; - //CreateMap() - // .ForMember(x => x.JobNumber, y => y.MapFrom(d => d.Number)) - // .ForMember(x => x.ReturnTime, y => y.MapFrom(d => d.CreationTime)) - // .ForMember(x => x.Worker, y => y.MapFrom(d => d.Worker)) - // .ForMember(x => x.ActiveDate, y => y.MapFrom(d => DateTime.Now)) - // .Ignore(x => x.Number); - //CreateMap() - // .ForMember(x => x.FromPackingCode, y => y.MapFrom(d => d.FromPackingCode)) - // .ForMember(x => x.ToPackingCode, y => y.MapFrom(d => d.ToPackingCode)) - // .ForMember(x => x.SupplierBatch, y => y.MapFrom(d => d.SupplierBatch)) - // .ForMember(x => x.ArriveDate, y => y.MapFrom(d => d.ArriveDate)) - // .ForMember(x => x.ProduceDate, y => y.MapFrom(d => d.ProduceDate)) - // .ForMember(x => x.ExpireDate, y => y.MapFrom(d => d.ExpireDate)) - // .ForMember(x => x.FromLot, y => y.MapFrom(d => string.Empty)) - // .ForMember(x => x.ToLot, y => y.MapFrom(d => d.ToLot)) - // .ForMember(x => x.ToContainerCode, y => y.MapFrom(d => d.ToContainerCode)) - // .ForMember(x => x.FromContainerCode, y => y.MapFrom(d => d.FromContainerCode)) - // .ForMember(x => x.FromStatus, y => y.MapFrom(d => d.FromStatus)) - // .ForMember(x => x.ToStatus, y => y.MapFrom(d => d.ToStatus)) - // .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty)) - // .ForMember(x => x.FromLocationCode, y => y.MapFrom(d => d.FromLocationCode)) - // .ForMember(x => x.FromLocationArea, y => y.MapFrom(d => d.ToLocationArea)) - // .ForMember(x => x.FromLocationGroup, y => y.MapFrom(d => d.ToLocationGroup)) - // .ForMember(x => x.FromLocationErpCode, y => y.MapFrom(d => d.ToLocationErpCode)) - // .ForMember(x => x.FromWarehouseCode, y => y.MapFrom(d => d.ToWarehouseCode)) - // .ForMember(x => x.Qty, y => y.MapFrom(d => d.Qty)) - // .Ignore(x => x.ArriveDate) - // .Ignore(x => x.ToLocationCode) - // .Ignore(x => x.ToLocationArea) - // .Ignore(x => x.ToLocationGroup) - // .Ignore(x => x.ToLocationErpCode) - // .Ignore(x => x.ToWarehouseCode) - // .Ignore(x => x.HandledContainerCode) - // .Ignore(x => x.HandledPackingCode) - // .Ignore(x => x.HandledToLocationCode) - // .Ignore(x => x.HandledToLocationArea) - // .Ignore(x => x.HandledToLocationGroup) - // .Ignore(x => x.HandledToLocationErpCode) - // .Ignore(x => x.HandledToWarehouseCode) - // .Ignore(x => x.HandledExpireDate) - // .Ignore(x => x.HandledLot) - // .Ignore(x => x.HandledArriveDate) - // .Ignore(x => x.HandledProduceDate) - // .Ignore(x => x.HandledQty) - // .Ignore(x => x.HandledSupplierBatch); - - - ProductionReturnNoteEditInput input = new ProductionReturnNoteEditInput(); - input.InjectFrom(entity); - input.ReturnTime = DateTime.Now; - input.ActiveDate=DateTime.Now; - input.JobNumber = input.Number; - List inputdetail = new List(); - foreach (var itm in entity.Details) + if (entity.DirectCreateNote) { - ProductionReturnNoteDetailInput detail=new ProductionReturnNoteDetailInput(); - detail.InjectFrom(itm); - inputdetail.Add(detail); + ProductionReturnNoteEditInput input = new ProductionReturnNoteEditInput(); + input.InjectFrom(entity); + input.ReturnTime = DateTime.Now; + input.ActiveDate = DateTime.Now; + input.JobNumber = input.Number; + List inputdetail = new List(); + foreach (var itm in entity.Details) + { + ProductionReturnNoteDetailInput detail = new ProductionReturnNoteDetailInput(); + detail.InjectFrom(itm); + inputdetail.Add(detail); + } + input.Details = inputdetail.ToList(); + //插入记录 + await _productionReturnNoteApp.CreateAsync(input).ConfigureAwait(false); } - input.Details = inputdetail.ToList(); + else + { + ProductionReturnJobEditInput input = new ProductionReturnJobEditInput(); + input.InjectFrom(entity); + input.ProductionReturnRequestNumber = entity.Number; + input.JobType = EnumJobType.ProductionReturnJob; + input.JobStatus = EnumJobStatus.Open; + input.IsAutoComplete = entity.AutoCompleteJob; + List inputdetail = new List(); + foreach (var itm in entity.Details) + { + ProductionReturnJobDetailInput detail = new ProductionReturnJobDetailInput(); + detail.InjectFrom(itm); - await _productionReturnNoteApp.CreateAsync(input).ConfigureAwait(false); + detail.RecommendToLocationArea = itm.ToLocationArea; + detail.RecommendToLocationCode = itm.ToLocationCode; + detail.RecommendToLocationErpCode = itm.ToLocationErpCode; + detail.RecommendToLocationGroup = itm.ToLocationGroup; + detail.RecommendToWarehouseCode = itm.ToWarehouseCode; + detail.RecommendLot = itm.ToLot; + detail.RecommendPackingCode = itm.ToPackingCode; + detail.RecommendQty = itm.Qty; + + detail.HandledToLocationArea = itm.ToLocationArea; + detail.HandledToLocationCode = itm.ToLocationCode; + detail.HandledToLocationErpCode = itm.ToLocationErpCode; + detail.HandledToLocationGroup = itm.ToLocationGroup; + detail.HandledToWarehouseCode = itm.ToWarehouseCode; + detail.HandledLot = itm.ToLot; + detail.HandledPackingCode = itm.ToPackingCode; + detail.HandledQty = itm.Qty; + detail.StdPackQty = itm.StdPackQty; + detail.Status = itm.ToStatus; + inputdetail.Add(detail); + } + input.Details = inputdetail.ToList(); + input.WarehouseCode = entity.Details.Count > 0 ? entity.Details[0].ToWarehouseCode : " "; + //插入任务 + await _productionReturnJobApp.CreateAsync(input).ConfigureAwait(false); + } + entity.Complete(); } public virtual async Task HandleEventAsync(SfsAbortedEntityEventData eventData) diff --git a/build/src/docker/publish/conf/settings/appsettings.Development.json b/build/src/docker/publish/conf/settings/appsettings.Development.json index 675ae449e..d575183e9 100644 --- a/build/src/docker/publish/conf/settings/appsettings.Development.json +++ b/build/src/docker/publish/conf/settings/appsettings.Development.json @@ -114,7 +114,8 @@ "BaseUrl": "http://dev.ccwin-in.com:60083/" }, "BaseData": { - "BaseUrl": "http://localhost:59094/" + //"BaseUrl": "http://localhost:59094/" + "BaseUrl": "http://dev.ccwin-in.com:60084/" }, "Default": { "BaseUrl": "http://dev.ccwin-in.com:60083/"