From b6936afdd1dd7bc0b22f8da164cd7f47e77cb4ad Mon Sep 17 00:00:00 2001 From: zhouhongjun <565221961@qq.com> Date: Tue, 9 Apr 2024 13:27:07 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ErpLocationItems/DTOs/ErpLocationItemDTO.cs | 2 +- .../ErpLocationItems/Inputs/ErpLocationItemEditInput.cs | 2 +- .../ErpLocationItems/Inputs/ErpLocationItemImportInput.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/DTOs/ErpLocationItemDTO.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/DTOs/ErpLocationItemDTO.cs index eb3d09586..2876b32c7 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/DTOs/ErpLocationItemDTO.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/DTOs/ErpLocationItemDTO.cs @@ -21,5 +21,5 @@ public class ErpLocationItemDTO : SfsBaseDataDTOBase [Display(Name = "储位代码")] [Required(ErrorMessage = "{0}是必填项")] [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] - public string ErpLoactionCode { get; set; } + public string ErpLocationCode { get; set; } } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/Inputs/ErpLocationItemEditInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/Inputs/ErpLocationItemEditInput.cs index 44df4e604..b1146b608 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/Inputs/ErpLocationItemEditInput.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/Inputs/ErpLocationItemEditInput.cs @@ -19,7 +19,7 @@ public class ErpLocationItemEditInput : SfsBaseDataCreateOrUpdateInputBase [Display(Name = "储位代码")] [Required(ErrorMessage = "{0}是必填项")] [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] - public string ErpLoactionCode { get; set; } + public string ErpLocationCode { get; set; } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/Inputs/ErpLocationItemImportInput.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/Inputs/ErpLocationItemImportInput.cs index 9e545836d..90c39292e 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/Inputs/ErpLocationItemImportInput.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/ErpLocationItems/Inputs/ErpLocationItemImportInput.cs @@ -21,7 +21,7 @@ public class ErpLocationItemImportInput : SfsBaseDataImportInputBase /// [Display(Name = "储位代码")] [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] - public string ErpLoactionCode { get; set; } + public string ErpLocationCode { get; set; } } From 65f55cc2b095e47b9815f68fb298a4efac4c80bf Mon Sep 17 00:00:00 2001 From: liuyunfeng Date: Tue, 9 Apr 2024 13:36:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E9=80=80=E5=BA=93?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProductionReturnNoteAppService.cs | 43 ++++++- .../ProductionReturnRequestAppService.cs | 85 ++++++++++--- .../Jobs/ProductionReturnJobEventHandler.cs | 15 ++- .../ProductionReturnRequestEventHandler.cs | 116 +++++++++--------- .../settings/appsettings.Development.json | 3 +- 5 files changed, 184 insertions(+), 78 deletions(-) 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/" From 71ac49b66fff075cf85c8fc0caae3177ef055c34 Mon Sep 17 00:00:00 2001 From: zhaoxinyu <89237069@qq.com> Date: Tue, 9 Apr 2024 13:40:48 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProductionReturnRequestController .cs | 9 +- .../Stores/CustomerReturnNoteController.cs | 6 +- .../Boms/BomManager.cs | 5 ++ .../Caches/Cache.cs | 49 ++++++++++- .../CustomerProductionReturnNoteAppService.cs | 12 +++ ...erProductionReturnNoteAutoMapperProfile.cs | 31 ++++++- ...ustomerProductionReturnNoteEventHandler.cs | 86 ++++++++++--------- 7 files changed, 148 insertions(+), 50 deletions(-) diff --git a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/ProductionReturnRequestController .cs b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/ProductionReturnRequestController .cs index 62dda4056..0a665f45f 100644 --- a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/ProductionReturnRequestController .cs +++ b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Jobs/ProductionReturnRequestController .cs @@ -23,6 +23,7 @@ public class ProductionReturnRequestController : AbpController { private readonly IProductionReturnJobAppService _productionReturnJobAppService; private readonly IProductionReturnRequestAppService _productionReturnRequestAppService; + private readonly ICustomerProductionReturnNoteAppService _customerReturnAppService; private readonly IUserWorkGroupAppService _userWorkGroupAppService; @@ -38,9 +39,11 @@ public class ProductionReturnRequestController : AbpController IProductionReturnJobAppService productionReturnJobAppService , IUserWorkGroupAppService userWorkGroupAppService , ILocationAppService locationApp - , IProductionReturnRequestAppService productionReturnRequestAppService + , IProductionReturnRequestAppService productionReturnRequestAppService, + ICustomerProductionReturnNoteAppService customerReturnAppService ) { + _customerReturnAppService = customerReturnAppService; _productionReturnRequestAppService = productionReturnRequestAppService; _userWorkGroupAppService = userWorkGroupAppService; this._productionReturnJobAppService = productionReturnJobAppService; @@ -62,9 +65,9 @@ public class ProductionReturnRequestController : AbpController [HttpPost("")] - public virtual async Task CreateAsync(ProductionReturnRequestEditInput input) + public virtual async Task CreateAsync(CustomerProductionReturnNoteEditInput input) { - return await _productionReturnRequestAppService.CreateAsync(input).ConfigureAwait(false); + return await _customerReturnAppService.CreateAsync(input).ConfigureAwait(false); } diff --git a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/CustomerReturnNoteController.cs b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/CustomerReturnNoteController.cs index 6519ade22..a7ecf3b67 100644 --- a/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/CustomerReturnNoteController.cs +++ b/be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Stores/CustomerReturnNoteController.cs @@ -12,14 +12,14 @@ namespace Win_in.Sfs.Wms.Pda.Controllers.Stores; [Route($"{PdaHostConst.ROOT_ROUTE}store/return-from-customer")] public class CustomerReturnNoteController : AbpController { - private readonly ICustomerReturnNoteAppService _customerReturnNoteAppService; + private readonly ICustomerProductionReturnNoteAppService _customerReturnNoteAppService; /// /// /// /// public CustomerReturnNoteController( - ICustomerReturnNoteAppService customerReturnNoteAppService) + ICustomerProductionReturnNoteAppService customerReturnNoteAppService) { _customerReturnNoteAppService = customerReturnNoteAppService; } @@ -30,7 +30,7 @@ public class CustomerReturnNoteController : AbpController /// /// [HttpPost("")] - public virtual async Task CreateAsync(CustomerReturnNoteEditInput input) + public virtual async Task CreateAsync(CustomerProductionReturnNoteEditInput input) { return await _customerReturnNoteAppService.CreateAsync(input).ConfigureAwait(false); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs index a0f2f3978..c3f7120bd 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Boms/BomManager.cs @@ -324,6 +324,11 @@ public class BomManager : DomainService, IBomManager private async Task> GetComponentsByProduct(string product) { List list=new List(); + if (Cache.Boms.Count == 0) + { + InitBomComponent(); + } + list=Cache.Boms.Count > 0 ? Cache.Boms.Where(p => p.Product == product).ToList() : await _repository.GetListAsync(p => p.Product == product).ConfigureAwait(false); List components = new List(); diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs index 718bb501c..0d3bb63ea 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Domain/Caches/Cache.cs @@ -8,6 +8,53 @@ using Win_in.Sfs.Basedata.Domain; namespace Win_in.Sfs.Basedata.Caches; public static class Cache { - public static List Boms = new List(); + public static List Boms = new List(); + public static async void BomsLifeCycle(int lifetime) + { + var reassigner = new Reassigner(DateTime.Now,new TimeSpan(0,5,0)); + await reassigner.RunAsync(() => { + Boms.Clear(); + }).ConfigureAwait(false); + } } +public class Reassigner +{ + private readonly TimeSpan _interval; + private DateTime _lasttime; + public Reassigner(DateTime lasttime, TimeSpan interval) + { + _lasttime = lasttime; + _interval = interval; + } + + public async Task RunAsync(Action p_action) + { + while (true) + { + // 获取当前时间 + var currentTime = DateTime.Now; + // 计算上次重新赋值到现在的时间间隔 + var elapsed = currentTime - _lasttime; + // 检查时间间隔是否满足条件 + if (elapsed >= _interval) + { + p_action(); + // 重新赋值 + //_value = await GetValueAsync(); + // 更新最后更新时间 + _lasttime = currentTime; + } + + // 等待下一刻钟 + await Task.Delay(_interval); + } + } + +} + + + + + + diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs index 5a239fbf0..241a8f532 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +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; @@ -37,6 +38,17 @@ public class CustomerProductionReturnNoteAppService : public override async Task CreateAsync(CustomerProductionReturnNoteEditInput input) { var entity = ObjectMapper.Map(input); + foreach (var itm in entity.Details) + { + itm.FromLocationCode = "HOLD"; + itm.FromStatus = EnumInventoryStatus.OK; + itm.ToStatus=EnumInventoryStatus.OK; + + + } + + + await _CustomerProductionReturnNoteManager.CreateAsync(entity).ConfigureAwait(false); var dto = ObjectMapper.Map(entity); return dto; diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs index ae68caa23..eaa70bea5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/CustomerProductionReturnNoteAutoMapperProfile.cs @@ -1,6 +1,7 @@ using AutoMapper; using Volo.Abp.AutoMapper; using Win_in.Sfs.Wms.Inventory.Application.Contracts; +using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; namespace Win_in.Sfs.Wms.Store.Event; @@ -10,14 +11,38 @@ public partial class StoreEventAutoMapperProfile : Profile private void CustomerProductionReturnNoteAutoMapperProfile() { CreateMap() + .Ignore(x => x.Worker) + .Ignore(x => x.TransType) + .Ignore(x => x.DocNumber) + .Ignore(x => x.JobNumber) + .Ignore(x => x.ExtraProperties) + .Ignore(x => x.TransSubType) + ; - .ForMember(x => x.DocNumber, y => y.MapFrom(t => t.Number)) - .Ignore(x => x.JobNumber) + CreateMap() + .ForMember(x => x.PackingCode, y => y.MapFrom(d => d.ToPackingCode)) + .ForMember(x => x.ContainerCode, y => y.MapFrom(d => d.ToContainerCode)) + .ForMember(x => x.Lot, y => y.MapFrom(d => d.ToLot)) + .ForMember(x => x.Status, y => y.MapFrom(d => d.ToStatus)) + .ForMember(x => x.LocationCode, y => y.MapFrom(d => d.ToLocationCode)) + .ForMember(x => x.LocationArea, y => y.MapFrom(d => d.ToLocationArea)) + .ForMember(x => x.LocationGroup, y => y.MapFrom(d => d.ToLocationGroup)) + .ForMember(x => x.LocationErpCode, y => y.MapFrom(d => d.ToLocationErpCode)) + .ForMember(x => x.WarehouseCode, y => y.MapFrom(d => d.ToWarehouseCode)) .Ignore(x => x.Worker) - .Ignore(x => x.TransType) .Ignore(x => x.ExtraProperties) + .Ignore(x => x.DocNumber) + .Ignore(x => x.JobNumber) + .Ignore(x => x.ManageType) + .Ignore(x => x.TransType) .Ignore(x => x.TransSubType) + .Ignore(x => x.TransInOut) + ; + + CreateMap() + .ReverseMap(); + CreateMap(); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs index bc62f87a8..81bea4400 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/CustomerProductionReturnNoteEventHandler.cs @@ -8,6 +8,7 @@ using Win_in.Sfs.Shared.Event; 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 Win_in.Sfs.Wms.Store.Event.Transaction; namespace Win_in.Sfs.Wms.Store.Event.Transactions; @@ -17,78 +18,83 @@ public class CustomerProductionReturnNoteEventHandler , ILocalEventHandler> , ILocalEventHandler>> - - - { private const EnumTransType TransType = EnumTransType.CustomerReturn; - - private readonly IProductionReturnRequestAppService _productionReturnRequestApp; - - public CustomerProductionReturnNoteEventHandler(IProductionReturnRequestAppService productionReturnRequestApp) - { - this._productionReturnRequestApp = productionReturnRequestApp; - } + private const EnumTransInOut TransInOut = EnumTransInOut.In; [UnitOfWork] public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) { var entity = eventData.Entity; - await AddTransactionsAsync(entity).ConfigureAwait(false); - if (!string.IsNullOrEmpty(entity.ProductionReturnRequestNumber)) - { - await _productionReturnRequestApp.CompleteByNumberAsync(entity.ProductionReturnRequestNumber).ConfigureAwait(false); - } + await AddTransactionsAsync(entity).ConfigureAwait(false); } private async Task AddTransactionsAsync(CustomerProductionReturnNote CustomerProductionReturnNote) { - var inboundTransactions = new List(); + ////如果WMS管理客户寄售库,生成库存转移 + //if (await SettingManager.IsTrueAsync(StoreSettings.Common.EnableCustomerLocation).ConfigureAwait(false)) + //{ - inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote)); + // var transferLogs = BuildTransferLogs(CustomerProductionReturnNote); + // await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); - await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); + //} + //else //如果WMS不管理客户寄售库,生成入库 + //{ - } + var transactions = BuildTransactions(CustomerProductionReturnNote); + await TransactionAppService.AddManyAsync(transactions).ConfigureAwait(false); + //} - [UnitOfWork] - public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) - { - var entities = eventData.Entity; - await AddTransactionsAsync(entities).ConfigureAwait(false); } - private async Task AddTransactionsAsync(List CustomerProductionReturnNotes) + /// + /// 构造 库存转移日志实体 + /// + /// + /// + private List BuildTransferLogs(CustomerProductionReturnNote CustomerProductionReturnNote) { - var inboundTransactions = new List(); + var transferLogCreateInputs = new List(); - //如果要做库存事务汇总,可以修改此处 - foreach (var CustomerProductionReturnNote in CustomerProductionReturnNotes) + foreach (var detail in CustomerProductionReturnNote.Details.Where(detail => detail.Qty != 0)) { - inboundTransactions.AddRange(BuildTransferLogs(CustomerProductionReturnNote)); + var transferLog = ObjectMapper.Map(detail); + transferLog.TransType = TransType; + transferLog.Worker = CustomerProductionReturnNote.Worker; + transferLog.DocNumber = CustomerProductionReturnNote.Number; + transferLog.JobNumber = CustomerProductionReturnNote.JobNumber; + transferLogCreateInputs.Add(transferLog); } - await TransferLogAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); + return transferLogCreateInputs; } - private List BuildTransferLogs(CustomerProductionReturnNote CustomerProductionReturnNote) + private List BuildTransactions(CustomerProductionReturnNote CustomerProductionReturnNote) { - var transferLogs = new List(); - foreach (var detail in CustomerProductionReturnNote.Details.Where(detail => detail.Qty != 0)) + var transactions = new List(); + + foreach (var detail in CustomerProductionReturnNote.Details) { - var transferLog = ObjectMapper.Map(detail); + var transaction = ObjectMapper.Map(detail); - transferLog.TransType = TransType; + transaction.TransType = TransType; + transaction.TransInOut = TransInOut; - transferLog.Worker = CustomerProductionReturnNote.Worker; - transferLog.DocNumber = CustomerProductionReturnNote.Number; - transferLog.JobNumber = CustomerProductionReturnNote.JobNumber; + transaction.Worker = CustomerProductionReturnNote.Worker; + transaction.DocNumber = CustomerProductionReturnNote.Number; + transaction.JobNumber = CustomerProductionReturnNote.JobNumber; + transaction.Status = EnumInventoryStatus.OK; - transferLogs.Add(transferLog); + transactions.Add(transaction); } - return transferLogs; + return transactions; } + public Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + throw new System.NotImplementedException(); + } } 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 4/4] =?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)