From 914ac45b1e65411b10b0c7512c90d56b59657a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E6=B8=A4=E6=97=AD=5BIrelia=5D?= <366601522@qq.com> Date: Thu, 6 Apr 2023 01:09:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E6=94=B6=E8=B4=A7?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=20=E5=88=B0=E8=B4=A8=E6=A3=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...FrameworkCore.SqlServer.StoreDbContext.sql | 2 + .../TransactionAutoMapperProfile.cs | 9 + .../IInventoryLabelAppService.cs | 6 + .../InventoryLabelAppService.cs | 21 ++ .../SfsCrudWithDetailsAppServiceBase.cs | 12 +- .../EnumPurchaseReceiptInspectStatus.cs | 5 - .../SnowflakeIdGenerator.cs | 4 +- .../DTOs/PurchaseReceiptNoteDTO.cs | 6 + .../Inputs/PurchaseReceiptNoteEditInput.cs | 7 + .../SupplierAsns/ISupplierAsnAppService.cs | 3 + .../Inputs/SupplierAsnEditInput.cs | 2 +- .../InspectRequests/DTOs/InspectRequestDTO.cs | 7 + .../Inputs/InspectRequestEditInput.cs | 7 + .../InspectJobAutoMapperProfile.cs | 12 + .../PurchaseReceiptJobAppService.cs | 191 +++++++-------- .../PurchaseReceiptJobAutoMapperProfile.cs | 7 + .../InspectNoteAutoMapperProfile.cs | 9 + .../SupplierAsns/SupplierAsnAppService.cs | 20 +- .../InspectRequestAutoMapperProfile.cs | 28 +-- .../PurchaseReceiptRequestAppService.cs | 14 +- .../Jobs/SfsJobManagerBase.cs | 4 +- .../PurchaseReceiptNote.cs | 5 + .../InspectRequests/InspectRequest.cs | 6 + .../PurchaseReceiptJobAutoMapperProfile.cs | 3 +- .../PurchaseReceiptNoteAutoMapperProfile.cs | 21 ++ .../InspectRequestAutoMapperProfile.cs | 1 - .../Jobs/PurchaseReceiptJobEventHandler.cs | 14 +- .../Orders/PurchaseOrderEventHandler.cs | 231 ++++++++++++++---- .../PurchaseReceiptRequestEventHandler.cs | 26 +- .../StoreEventAutoMapperProfile.cs | 17 +- .../PurchaseReceiptNoteEventHandler.cs | 53 ++-- 31 files changed, 528 insertions(+), 225 deletions(-) delete mode 100644 be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inspect/EnumPurchaseReceiptInspectStatus.cs diff --git a/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql b/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql index b29689e54..20f15edef 100644 --- a/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql +++ b/be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql @@ -856,6 +856,7 @@ CREATE TABLE [Store_InspectRequest] ( [RpNumber] nvarchar(64) NULL, [PoNumber] nvarchar(64) NULL, [SupplierCode] nvarchar(64) NOT NULL, + [WarehouseCode] nvarchar(max) NULL, [ExtraProperties] nvarchar(max) NULL, [ConcurrencyStamp] nvarchar(40) NULL, [CreationTime] datetime2 NOT NULL, @@ -1388,6 +1389,7 @@ CREATE TABLE [Store_PurchaseReceiptNote] ( [SupplierAddress] nvarchar(max) NULL, [ReceiveTime] datetime2 NOT NULL, [JobNumber] nvarchar(64) NULL, + [WarehouseCode] nvarchar(max) NULL, [Type] nvarchar(64) NOT NULL, [Status] nvarchar(64) NOT NULL, [ExtraProperties] nvarchar(max) NULL, diff --git a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Transactions/TransactionAutoMapperProfile.cs b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Transactions/TransactionAutoMapperProfile.cs index 5511b090f..ff28fe494 100644 --- a/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Transactions/TransactionAutoMapperProfile.cs +++ b/be/Modules/Inventory/src/Win_in.Sfs.Wms.Inventory.Application/Transactions/TransactionAutoMapperProfile.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Volo.Abp.AutoMapper; using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Inventory.Domain; @@ -10,6 +11,14 @@ public partial class InventoryApplicationAutoMapperProfile : Profile { CreateMap() .ReverseMap(); + + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.TransNumber) + .Ignore(x => x.TransTime) + .Ignore(x => x.ActiveDate) + .Ignore(x => x.ConcurrencyStamp) + .Ignore(x => x.Id); } } diff --git a/be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/IInventoryLabelAppService.cs b/be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/IInventoryLabelAppService.cs index c93745653..406c140fa 100644 --- a/be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/IInventoryLabelAppService.cs +++ b/be/Modules/Label/src/Win_in.Sfs.Label.Application.Contracts/InventoryLabels/IInventoryLabelAppService.cs @@ -14,4 +14,10 @@ public interface IInventoryLabelAppService Task> GenerateAndCreateManyAsync(InventoryLabelWithoutCodeCreateInput input, int count); + /// + /// Code需要自己生成 传入 否则无法赋值 完整条码 + /// + /// + /// + Task> CreateManyByNoCodeAsync(List inputs); } diff --git a/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs b/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs index 13e0832f9..76770e7eb 100644 --- a/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs +++ b/be/Modules/Label/src/Win_in.Sfs.Label.Application/InventoryLabels/InventoryLabelAppService.cs @@ -8,6 +8,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Volo.Abp; using Volo.Abp.Domain.Repositories; +using Volo.Abp.ObjectMapping; +using Volo.Abp.Uow; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Label.Application.Contracts; using Win_in.Sfs.Label.Domain; @@ -47,6 +49,7 @@ public class InventoryLabelAppService } [HttpPost("")] + [UnitOfWork] public override async Task CreateAsync(InventoryLabelEditInput input) { var existEntity = await GetByCodeAsync(input.Code).ConfigureAwait(false); @@ -58,6 +61,7 @@ public class InventoryLabelAppService } [HttpPost("many")] + [UnitOfWork] public virtual async Task> CreateManyAsync(List inputs) { List inventoryLabelDtos = new List(); @@ -70,7 +74,22 @@ public class InventoryLabelAppService return inventoryLabelDtos; } + /// + /// Code需要自己生成 传入 否则无法赋值 完整条码 + /// + /// + /// + [HttpPost("create-many-no-code")] + [UnitOfWork] + public virtual async Task> CreateManyByNoCodeAsync(List inputs) + { + var entitys= ObjectMapper.Map, List>(inputs); + await _repository.InsertManyAsync(entitys).ConfigureAwait(false); + return ObjectMapper.Map, List>(entitys); + } + [HttpPost("generate-and-create")] + [UnitOfWork] public virtual async Task GenerateAndCreateAsync(InventoryLabelWithoutCodeCreateInput input) { var labelType = input.LabelType.ToString(); @@ -81,6 +100,7 @@ public class InventoryLabelAppService } [HttpPost("generate-and-create/many")] + [UnitOfWork] public virtual async Task> GenerateAndCreateManyAsync(List inputs) { var labelType = inputs.First().LabelType.ToString(); @@ -98,6 +118,7 @@ public class InventoryLabelAppService } [HttpPost("generate-and-create/many/{count}")] + [UnitOfWork] public virtual async Task> GenerateAndCreateManyAsync(InventoryLabelWithoutCodeCreateInput input, int count) { var labelType = input.LabelType.ToString(); diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs index 30991de35..fd024bfd3 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Application/SfsCrudWithDetailsAppServiceBase.cs @@ -565,8 +565,6 @@ public abstract class SfsCrudWithDetailsAppServiceBase p.Value == EntityState.Added).Select(p => p.Key).ToList(); - //一定要 先发布 在导入 否则没有事务性了 只针对于导入 - await PublishCreatedAsync(addList).ConfigureAwait(false); await SaveImportAsync(entityDict).ConfigureAwait(false); } } @@ -630,6 +628,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase /// /// + [UnitOfWork] private async Task PublishCreatedAsync(List entities) { try @@ -657,7 +656,7 @@ public abstract class SfsCrudWithDetailsAppServiceBase /// 导入保存到数据库,可重写 /// - + [UnitOfWork] protected virtual async Task SaveImportAsync(Dictionary dict) { var entityList = dict.Keys.ToList(); @@ -683,8 +682,13 @@ public abstract class SfsCrudWithDetailsAppServiceBase p.Value == EntityState.Added).Select(p => p.Key).ToList(); + await context.BulkInsertOrUpdateAsync(addList, bulkConfig).ConfigureAwait(false); await context.BulkInsertAsync(list).ConfigureAwait(false); + + //await _repository.InsertManyAsync(addList).ConfigureAwait(true); + //await _repository.UpdateManyAsync(dict.Where(p => p.Value == EntityState.Modified).Select(p => p.Key)).ConfigureAwait(false); + await PublishCreatedAsync(addList).ConfigureAwait(false); } } diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inspect/EnumPurchaseReceiptInspectStatus.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inspect/EnumPurchaseReceiptInspectStatus.cs deleted file mode 100644 index a8dec20e4..000000000 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Inspect/EnumPurchaseReceiptInspectStatus.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Win_in.Sfs.Shared.Domain.Shared.Enums.Inspect; - -public enum EnumPurchaseReceiptInspectStatus -{ -} diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Framework/NumberGenerator/SnowflakeIdGenerator/SnowflakeIdGenerator.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Framework/NumberGenerator/SnowflakeIdGenerator/SnowflakeIdGenerator.cs index 40e23ac34..9d99c8a47 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Framework/NumberGenerator/SnowflakeIdGenerator/SnowflakeIdGenerator.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Framework/NumberGenerator/SnowflakeIdGenerator/SnowflakeIdGenerator.cs @@ -57,14 +57,14 @@ public class SnowflakeIdGenerator : ISnowflakeIdGenerator { } - public SnowflakeIdGenerator(IOptions options, SnowflakeIdGeneratorOptions options1, SnowflakeIdGeneratorOptions options2) + public SnowflakeIdGenerator(IOptions options) { Options = options.Value; this.DatacenterId = options.Value.GetDefaultDatacenterId(); this.WorkerId = options.Value.GetDefaultWorkerId(); } - /// + ///// /// 获得下一个ID /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/PurchaseReceiptNotes/DTOs/PurchaseReceiptNoteDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/PurchaseReceiptNotes/DTOs/PurchaseReceiptNoteDTO.cs index f39bca7e8..19d29d735 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/PurchaseReceiptNotes/DTOs/PurchaseReceiptNoteDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/PurchaseReceiptNotes/DTOs/PurchaseReceiptNoteDTO.cs @@ -80,4 +80,10 @@ public class PurchaseReceiptNoteDTO : SfsStoreDTOBase + /// 仓库 + /// + [Display(Name = "仓库")] + [Required(ErrorMessage = "仓库不能为空", AllowEmptyStrings = true)] + public string WarehouseCode { get; set; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/PurchaseReceiptNotes/Inputs/PurchaseReceiptNoteEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/PurchaseReceiptNotes/Inputs/PurchaseReceiptNoteEditInput.cs index 1feea161f..d248f1fe4 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/PurchaseReceiptNotes/Inputs/PurchaseReceiptNoteEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/PurchaseReceiptNotes/Inputs/PurchaseReceiptNoteEditInput.cs @@ -99,5 +99,12 @@ public class PurchaseReceiptNoteEditInput : SfsStoreCreateOrUpdateInputBase [Display(Name = "任务ID")] //[Required(ErrorMessage = "{0}是必填项")] public string JobNumber { get; set; } + + /// + /// 仓库 + /// + [Display(Name = "仓库")] + [Required(ErrorMessage = "仓库不能为空", AllowEmptyStrings = true)] + public string WarehouseCode { get; set; } #endregion } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs index b18648ddb..2500f94f8 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/ISupplierAsnAppService.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using Win_in.Sfs.Shared.Application.Contracts; +using Win_in.Sfs.Shared.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application.Contracts; @@ -31,4 +32,6 @@ public interface ISupplierAsnAppService /// /// Task GenerateSupplierAsnNumberAsync(DateTime activeDate); + + Task UpdateStatusAsync(string asnNumber, EnumSupplierAsnStatus status); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/Inputs/SupplierAsnEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/Inputs/SupplierAsnEditInput.cs index e5b2cae89..c70541b34 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/Inputs/SupplierAsnEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Plans/SupplierAsns/Inputs/SupplierAsnEditInput.cs @@ -132,7 +132,7 @@ public class SupplierAsnEditInput : SfsStoreCreateOrUpdateInputBase /// 供应商地址 /// [DisplayName("供应商地址")] - public string SupplierAdress { get; set; } + public string SupplierAddress { get; set; } /// /// 明细列表 diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/InspectRequests/DTOs/InspectRequestDTO.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/InspectRequests/DTOs/InspectRequestDTO.cs index 31cc237cf..d28e752bc 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/InspectRequests/DTOs/InspectRequestDTO.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/InspectRequests/DTOs/InspectRequestDTO.cs @@ -52,6 +52,13 @@ public class InspectRequestDTO : SfsStoreRequestDTOBase [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] public string SupplierCode { get; set; } + /// + /// 仓库 + /// + [Display(Name = "仓库")] + [Required(ErrorMessage = "仓库不能为空", AllowEmptyStrings = true)] + public string WarehouseCode { get; set; } + /// /// 汇总明细 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/InspectRequests/Inputs/InspectRequestEditInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/InspectRequests/Inputs/InspectRequestEditInput.cs index 63071f346..fc35f613d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/InspectRequests/Inputs/InspectRequestEditInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/InspectRequests/Inputs/InspectRequestEditInput.cs @@ -63,6 +63,13 @@ public class InspectRequestEditInput : SfsStoreRequestCreateOrUpdateInputBase [StringLength(SfsEfCorePropertyConst.CodeLength, ErrorMessage = "{0}最多输入{1}个字符")] public string PoNumber { get; set; } + /// + /// 仓库 + /// + [Display(Name = "仓库")] + [Required(ErrorMessage = "仓库不能为空", AllowEmptyStrings = true)] + public string WarehouseCode { get; set; } + /// /// 明细列表 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/InspectJobs/InspectJobAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/InspectJobs/InspectJobAutoMapperProfile.cs index e8d6d99f5..b12f088ce 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/InspectJobs/InspectJobAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/InspectJobs/InspectJobAutoMapperProfile.cs @@ -114,5 +114,17 @@ public partial class StoreApplicationAutoMapperProfile : Profile CreateMap() ; + + CreateMap() + .IgnoreAuditedObjectProperties() + ; + + CreateMap() + .IgnoreAuditedObjectProperties() + ; + + CreateMap() + .IgnoreAuditedObjectProperties() + ; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAppService.cs index 75fe9974a..0b43b47f6 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAppService.cs @@ -48,17 +48,43 @@ public class PurchaseReceiptJobAppService : _inspectJobManager = inspectJobManager; } + #region 东阳使用 + /// + /// 【设置】所有 待检状态的 收货记录为 合格 /// - /// - [HttpPost("cancel-by-request/{purchaseReceiptRequestNumber}")] - public virtual async Task CancelByPurchaseReceiptRequestAsync(string purchaseReceiptRequestNumber) + /// + [HttpPost("set-inspect-status-ok-by-inspect/{id}")] + public virtual async Task> SetInspectWithNotInspectAsync(Guid id) { - var entities = await _repository.GetListAsync(p => p.PurchaseReceiptRequestNumber == purchaseReceiptRequestNumber).ConfigureAwait(false); - foreach (var entity in entities) + var purchaseReceiptJob = await _repository.FindAsync(id).ConfigureAwait(false); + + var list = purchaseReceiptJob.Details + .Where(p => p.PurchaseReceiptInspectStatus == EnumPurchaseReceiptInspect.INSP).ToList(); + + list.ForEach(p => { - await _purchaseReceiptJobManager.CancelAsync(entity).ConfigureAwait(false); - } + { + p.PurchaseReceiptInspectStatus = EnumPurchaseReceiptInspect.OK; + p.FailedReason = string.Empty; + p.MassDefect = string.Empty; + p.HandledLot = p.RecommendLot; + p.HandledSupplierBatch = p.RecommendSupplierBatch; + p.HandledArriveDate = p.RecommendArriveDate; + p.HandledProduceDate = p.RecommendProduceDate; + p.HandledExpireDate = p.RecommendExpireDate; + p.HandledContainerCode = p.RecommendContainerCode; + p.HandledToLocationCode = p.RecommendToLocationCode; + p.HandledToLocationErpCode = p.RecommendToLocationErpCode; + p.HandledToWarehouseCode = p.RecommendToWarehouseCode; + p.HandledPackingCode = p.RecommendPackingCode; + p.HandledQty = p.RecommendQty; + } + }); + + await _repository.UpdateAsync(purchaseReceiptJob).ConfigureAwait(false); + + return ObjectMapper.Map, List>(list); } /// @@ -74,12 +100,41 @@ public class PurchaseReceiptJobAppService : var detail = job.Details.FirstOrDefault(p => p.Id == detailId); if (detail != null) { - BulidResetDetail(detail); + detail.PurchaseReceiptInspectStatus = EnumPurchaseReceiptInspect.INSP; + detail.FailedReason = string.Empty; + detail.InspectPhotoJson = string.Empty; + detail.MassDefect = string.Empty; + detail.HandledLot = string.Empty; + detail.HandledSupplierBatch = string.Empty; + detail.HandledArriveDate = DateTime.Now; + detail.HandledProduceDate = DateTime.Now; + detail.HandledExpireDate = DateTime.Now; + detail.HandledContainerCode = string.Empty; + detail.HandledToLocationErpCode = string.Empty; + detail.HandledToWarehouseCode = string.Empty; + detail.HandledToLocationCode = string.Empty; + detail.HandledPackingCode = string.Empty; + detail.HandledQty = 0; } await _repository.UpdateAsync(job).ConfigureAwait(false); } + /// + /// 【重置】多个 目检 结果 + /// + /// + /// + /// + [HttpPost("reset-many-detail-inspect/{id}")] + public virtual async Task ResetManyDetailAsync(Guid id, List detailIdsGuids) + { + foreach (var detailId in detailIdsGuids) + { + await ResetDetailInspectAsync(id, detailId).ConfigureAwait(false); + } + } + /// /// 【保存】目检 结果 /// @@ -98,7 +153,22 @@ public class PurchaseReceiptJobAppService : if (detail != null) { - BuildDetail(input, detail); + detail.FailedReason = input.FailedReason; + detail.MassDefect = input.MassDefect; + detail.PurchaseReceiptInspectStatus = input.PurchaseReceiptInspectStatus; + detail.HandledLot = detail.RecommendLot; + detail.HandledSupplierBatch = detail.RecommendSupplierBatch; + detail.HandledArriveDate = detail.RecommendArriveDate; + detail.HandledProduceDate = detail.RecommendProduceDate; + detail.HandledExpireDate = detail.RecommendExpireDate; + detail.HandledToLocationArea=detail.RecommendToLocationArea; + detail.HandledToLocationGroup=detail.RecommendToLocationGroup; + detail.HandledContainerCode = detail.RecommendContainerCode; + detail.HandledToLocationCode = detail.RecommendToLocationCode; + detail.HandledToLocationErpCode = detail.RecommendToLocationErpCode; + detail.HandledToWarehouseCode = detail.RecommendToWarehouseCode; + detail.HandledPackingCode = detail.RecommendPackingCode; + detail.HandledQty = detail.RecommendQty; } var entity = await _repository.UpdateAsync(job).ConfigureAwait(false); @@ -107,105 +177,20 @@ public class PurchaseReceiptJobAppService : entity.Details.Find(p => p.Id == input.DetailId)); } - /// - /// 【重置】多个 目检 结果 - /// - /// - /// - /// - [HttpPost("reset-many-detail-inspect/{id}")] - public virtual async Task ResetManyDetailAsync(Guid id, List detailIdsGuids) - { - foreach (var detailId in detailIdsGuids) - { - await ResetDetailInspectAsync(id, detailId).ConfigureAwait(false); - } - } + #endregion /// - /// 【设置】所有 待检状态的 收货记录为 合格 /// - /// - [HttpPost("set-inspect-status-ok-by-inspect/{id}")] - public virtual async Task> SetInspectWithNotInspectAsync(Guid id) + /// + [HttpPost("cancel-by-request/{purchaseReceiptRequestNumber}")] + public virtual async Task CancelByPurchaseReceiptRequestAsync(string purchaseReceiptRequestNumber) { - var purchaseReceiptJob = await _repository.FindAsync(id).ConfigureAwait(false); - - var list = purchaseReceiptJob.Details - .Where(p => p.PurchaseReceiptInspectStatus == EnumPurchaseReceiptInspect.INSP).ToList(); - - list.ForEach(p => + var entities = await _repository + .GetListAsync(p => p.PurchaseReceiptRequestNumber == purchaseReceiptRequestNumber).ConfigureAwait(false); + foreach (var entity in entities) { - { - p.PurchaseReceiptInspectStatus = EnumPurchaseReceiptInspect.OK; - p.FailedReason = string.Empty; - p.MassDefect = string.Empty; - p.HandledLot = p.RecommendLot; - p.HandledSupplierBatch = p.RecommendSupplierBatch; - p.HandledArriveDate = p.RecommendArriveDate; - p.HandledProduceDate = p.RecommendProduceDate; - p.HandledExpireDate = p.RecommendExpireDate; - p.HandledContainerCode = p.RecommendContainerCode; - p.HandledToLocationCode = p.RecommendToLocationCode; - p.HandledToLocationErpCode = p.RecommendToLocationErpCode; - p.HandledToWarehouseCode = p.RecommendToWarehouseCode; - p.HandledPackingCode = p.RecommendPackingCode; - p.HandledQty = p.RecommendQty; - } - }); - - await _repository.UpdateAsync(purchaseReceiptJob).ConfigureAwait(false); - - return ObjectMapper.Map, List>(list); - } - - /// - /// 构造目检结果 - /// - /// - /// - private static PurchaseReceiptJobDetail BuildDetail(PurchaseReceiptJobDetailSaveInput input, PurchaseReceiptJobDetail detail) - { - detail.FailedReason = input.FailedReason; - detail.MassDefect = input.MassDefect; - detail.PurchaseReceiptInspectStatus = input.PurchaseReceiptInspectStatus; - detail.HandledLot = detail.RecommendLot; - detail.HandledSupplierBatch = detail.RecommendSupplierBatch; - detail.HandledArriveDate = detail.RecommendArriveDate; - detail.HandledProduceDate = detail.RecommendProduceDate; - detail.HandledExpireDate = detail.RecommendExpireDate; - detail.HandledContainerCode = detail.RecommendContainerCode; - detail.HandledToLocationCode = detail.RecommendToLocationCode; - detail.HandledToLocationErpCode = detail.RecommendToLocationErpCode; - detail.HandledToWarehouseCode = detail.RecommendToWarehouseCode; - detail.HandledPackingCode = detail.RecommendPackingCode; - detail.HandledQty = detail.RecommendQty; - - return detail; - } - - /// - /// 构造 并初始化 目检结果 - /// - /// - private static PurchaseReceiptJobDetail BulidResetDetail(PurchaseReceiptJobDetail detail) - { - detail.PurchaseReceiptInspectStatus = EnumPurchaseReceiptInspect.INSP; - detail.InspectPhotoJson = string.Empty; - detail.FailedReason = string.Empty; - detail.MassDefect = string.Empty; - detail.HandledLot = string.Empty; - detail.HandledSupplierBatch = string.Empty; - detail.HandledArriveDate = DateTime.Now; - detail.HandledProduceDate = DateTime.Now; - detail.HandledExpireDate = DateTime.Now; - detail.HandledContainerCode = string.Empty; - detail.HandledToLocationErpCode = string.Empty; - detail.HandledToWarehouseCode = string.Empty; - detail.HandledToLocationCode = string.Empty; - detail.HandledPackingCode = string.Empty; - - return detail; + await _purchaseReceiptJobManager.CancelAsync(entity).ConfigureAwait(false); + } } /* diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAutoMapperProfile.cs index aa4e8c7a2..963b4b5b3 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Jobs/PurchaseReceiptJobs/PurchaseReceiptJobAutoMapperProfile.cs @@ -29,5 +29,12 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.TenantId) .Ignore(x => x.Number) .Ignore(x => x.Id); + + CreateMap() + .IgnoreAuditedObjectProperties() + ; + CreateMap() + .IgnoreAuditedObjectProperties() + ; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InspectNotes/InspectNoteAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InspectNotes/InspectNoteAutoMapperProfile.cs index 75e071a19..9ba0232af 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InspectNotes/InspectNoteAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/InspectNotes/InspectNoteAutoMapperProfile.cs @@ -15,6 +15,14 @@ public partial class StoreApplicationAutoMapperProfile : Profile CreateMap() .ReverseMap(); + CreateMap() + .IgnoreAuditedObjectProperties() + ; + + CreateMap() + .IgnoreAuditedObjectProperties() + ; + CreateMap() .IgnoreAuditedObjectProperties() .Ignore(x => x.MasterID) @@ -31,5 +39,6 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.TenantId) .Ignore(x => x.Number) .Ignore(x => x.Id); + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs index ec4be9b99..f232b2a60 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Plans/SupplierAsns/SupplierAsnAppService.cs @@ -69,8 +69,6 @@ public class SupplierAsnAppService : return ObjectMapper.Map(resultEntity); } - #endregion - /// /// 生成ASN订单号 /// @@ -83,6 +81,24 @@ public class SupplierAsnAppService : .ConfigureAwait(false); } + /// + /// 更新发货单状态 + /// + /// + /// + /// + [HttpGet("update-status-async")] + public virtual async Task UpdateStatusAsync(string asnNumber, EnumSupplierAsnStatus status) + { + var supplierAsn = await _repository.FindAsync(p => p.Number == asnNumber).ConfigureAwait(false); + supplierAsn.Status = status; + await _repository.UpdateAsync(supplierAsn).ConfigureAwait(false); + } + + #endregion + + + private async Task CreateFromFileAsync(SupplierAsnEditInput input) { var entity = ObjectMapper.Map(input); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/InspectRequests/InspectRequestAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/InspectRequests/InspectRequestAutoMapperProfile.cs index 5933d017a..2e27bf9ac 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/InspectRequests/InspectRequestAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/InspectRequests/InspectRequestAutoMapperProfile.cs @@ -34,25 +34,13 @@ public partial class StoreApplicationAutoMapperProfile : Profile .Ignore(x => x.TenantId) .Ignore(x => x.Number); - CreateMap() - .ForMember(x => x.ReceiptNumber, y => y.MapFrom(d => d.Number)) - .Ignore(x => x.SummaryDetails) - .Ignore(x => x.AutoAgree) - .Ignore(x => x.AutoHandle) - .Ignore(x => x.AutoSubmit) - .Ignore(x => x.AutoCompleteJob) - .Ignore(x => x.DirectCreateNote) - .Ignore(x => x.RequestStatus); - - CreateMap() - .ForMember(x => x.ReceiveQty, y => y.MapFrom(d => d.Qty)) - .Ignore(x => x.DetailInspectStatus) - .Ignore(x => x.Uom) - .Ignore(x => x.InspectType) - .Ignore(x => x.SamplePercent) - .Ignore(x => x.Attributes) - .Ignore(x => x.InspectQty) - .Ignore(x => x.AbcClass) - .AfterMap((x, y) => y.DetailInspectStatus = EnumDetailInspectStatus.DefaultOK); + CreateMap() + .IgnoreAuditedObjectProperties() + .Ignore(x => x.RequestStatus) + .Ignore(x => x.ConcurrencyStamp).Ignore(x => x.Id); + + CreateMap() + .IgnoreAuditedObjectProperties() + ; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAppService.cs index 8684146be..e1b1a4477 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestAppService.cs @@ -23,24 +23,21 @@ public class PurchaseReceiptRequestAppService : IPurchaseReceiptRequestAppService { private readonly IPurchaseReceiptRequestManager _purchaseReceiptRequestManager; - private readonly IInventoryLabelAppService _inventoryLabelService; - private readonly ISupplierAppService _supplierAppService; public PurchaseReceiptRequestAppService( IPurchaseReceiptRequestRepository repository, - IPurchaseReceiptRequestManager purchaseReceiptRequestManager, - IInventoryLabelAppService inventoryLabelService, - ISupplierAppService supplierAppService) : base(repository, purchaseReceiptRequestManager) + IPurchaseReceiptRequestManager purchaseReceiptRequestManager + ) : base(repository, purchaseReceiptRequestManager) { _purchaseReceiptRequestManager = purchaseReceiptRequestManager; - _inventoryLabelService = inventoryLabelService; - _supplierAppService = supplierAppService; base.CreatePolicyName = PurchaseReceiptRequestPermissions.Create; base.UpdatePolicyName = PurchaseReceiptRequestPermissions.Update; base.DeletePolicyName = PurchaseReceiptRequestPermissions.Delete; } + #region 东阳使用 + /// /// 【创建】收货请求 (到货单、到货通知) /// @@ -57,6 +54,9 @@ public class PurchaseReceiptRequestAppService : return ObjectMapper.Map(resultEntity); } + #endregion + + /// /// 【批量创建】收货请求 (到货单、到货通知) /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs index 611416e0d..8c5528932 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/SfsJobManagerBase.cs @@ -118,7 +118,7 @@ public abstract class SfsJobManagerBase CheckJobStatus(entity, EnumJobStatus.Doing); - await entity.AcceptAsync(user.Id, user.GetUserName(), Clock.Now).ConfigureAwait(false); + await entity.AcceptAsync(user.Id, user.Name, Clock.Now).ConfigureAwait(false); await Repository.UpdateAsync(entity).ConfigureAwait(false); } @@ -141,7 +141,7 @@ public abstract class SfsJobManagerBase public virtual async Task CompleteAsync(TEntity entity, ICurrentUser user) { - await entity.CompleteAsync(user.Id, user.GetUserName(), Clock.Now).ConfigureAwait(false); + await entity.CompleteAsync(user.Id, user.Name, Clock.Now).ConfigureAwait(false); await PublishCompletedAsync(entity).ConfigureAwait(false); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNote.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNote.cs index f6d6fd941..5fbb2571a 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNote.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/PurchaseReceiptNotes/PurchaseReceiptNote.cs @@ -59,6 +59,11 @@ public class PurchaseReceiptNote : SfsStoreAggregateRootBase public string JobNumber { get; set; } + /// + /// 仓库代码 + /// + public string WarehouseCode { get; set; } + /// /// 明细列表 /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/InspectRequests/InspectRequest.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/InspectRequests/InspectRequest.cs index 83a3f4174..95b61ed23 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/InspectRequests/InspectRequest.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Requests/InspectRequests/InspectRequest.cs @@ -46,6 +46,12 @@ public class InspectRequest : SfsStoreRequestAggregateRootBase + /// 仓库 + /// + [IgnoreUpdate] + public string WarehouseCode { get; set; } + [IgnoreUpdate] public List SummaryDetails { get; set; } = new List(); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/PurchaseReceiptJobAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/PurchaseReceiptJobAutoMapperProfile.cs index 33cf08410..6145439ab 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/PurchaseReceiptJobAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Jobs/PurchaseReceiptJobAutoMapperProfile.cs @@ -20,7 +20,7 @@ public partial class StoreEventAutoMapperProfile : Profile ; CreateMap() - .ForMember(x => x.PackingCode, y => y.MapFrom(d => d.HandledPackingCode)) + .ForMember(x => x.PackingCode, y => y.MapFrom(d => d.RecommendPackingCode))//未收货的是没有扫到箱码的 所以要用推荐箱码 不能是 实际箱码 .ForMember(x => x.SupplierBatch, y => y.MapFrom(d => d.HandledSupplierBatch)) .ForMember(x => x.ProduceDate, y => y.MapFrom(d => d.HandledProduceDate)) .ForMember(x => x.ExpireDate, y => y.MapFrom(d => d.HandledExpireDate)) @@ -32,7 +32,6 @@ public partial class StoreEventAutoMapperProfile : Profile .ForMember(x => x.LocationGroup, y => y.MapFrom(d => d.HandledToLocationGroup)) .ForMember(x => x.LocationErpCode, y => y.MapFrom(d => d.HandledToLocationErpCode)) .ForMember(x => x.WarehouseCode, y => y.MapFrom(d => d.HandledToWarehouseCode)) - .Ignore(x => x.ArriveDate) ; } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/PurchaseReceiptNoteAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/PurchaseReceiptNoteAutoMapperProfile.cs index 1c12677bc..82a491705 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/PurchaseReceiptNoteAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/PurchaseReceiptNoteAutoMapperProfile.cs @@ -60,6 +60,27 @@ public partial class StoreEventAutoMapperProfile : Profile ; #endregion + + CreateMap() + .ForMember(x => x.ReceiptNumber, y => y.MapFrom(d => d.Number)) + .Ignore(x => x.SummaryDetails) + .Ignore(x => x.AutoAgree) + .Ignore(x => x.AutoHandle) + .Ignore(x => x.AutoSubmit) + .Ignore(x => x.AutoCompleteJob) + .Ignore(x => x.DirectCreateNote) + .Ignore(x => x.RequestStatus); + + CreateMap() + .ForMember(x => x.ReceiveQty, y => y.MapFrom(d => d.Qty)) + .Ignore(x => x.DetailInspectStatus) + .Ignore(x => x.Uom) + .Ignore(x => x.InspectType) + .Ignore(x => x.SamplePercent) + .Ignore(x => x.Attributes) + .Ignore(x => x.InspectQty) + .Ignore(x => x.AbcClass) + .AfterMap((x, y) => y.DetailInspectStatus = EnumDetailInspectStatus.DefaultOK); } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/InspectRequestAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/InspectRequestAutoMapperProfile.cs index 639ac91e5..061dbf4d5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/InspectRequestAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Requests/InspectRequestAutoMapperProfile.cs @@ -19,7 +19,6 @@ public partial class StoreEventAutoMapperProfile : Profile CreateMap() .ForMember(x => x.InspectNumber, y => y.MapFrom(d => d.Number)) .ForMember(x => x.IsAutoComplete, y => y.MapFrom(d => d.AutoCompleteJob)) - .Ignore(x => x.WarehouseCode) .Ignore(x => x.UpStreamJobNumber) .Ignore(x => x.NextAction) .Ignore(x => x.JobDescription) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/PurchaseReceiptJobEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/PurchaseReceiptJobEventHandler.cs index addf2a114..331faa759 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/PurchaseReceiptJobEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/PurchaseReceiptJobEventHandler.cs @@ -1,6 +1,8 @@ +using System.Linq; using System.Threading.Tasks; using Volo.Abp.EventBus; using Volo.Abp.Uow; +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; @@ -46,11 +48,17 @@ public class PurchaseReceiptJobEventHandler : { var createInput = ObjectMapper.Map(purchaseReceiptJob); - createInput.Details.RemoveAll(p => p.Qty == 0); + //未收货记录 + var noReceiptNoteList = createInput.Details.Where(p => p.Qty == 0); + foreach (var detailInput in noReceiptNoteList) + { + var jobDetail = + purchaseReceiptJob.Details.Find(p => p.RecommendPackingCode == detailInput.PackingCode); - await _purchaseReceiptNoteAppService.CreateAsync(createInput).ConfigureAwait(false); + detailInput.PurchaseReceiptInspectStatus = EnumPurchaseReceiptInspect.NORECEIPT; + } - await Task.CompletedTask.ConfigureAwait(false); + await _purchaseReceiptNoteAppService.CreateAsync(createInput).ConfigureAwait(false); } #endregion diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs index 50029a42b..ab126994f 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Orders/PurchaseOrderEventHandler.cs @@ -5,9 +5,12 @@ using System.Net.Http; using System.Threading.Tasks; using Castle.Components.DictionaryAdapter; using Volo.Abp; +using Volo.Abp.Data; using Volo.Abp.EventBus; +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.Label.Application.Contracts; using Win_in.Sfs.Label.Domain.Shared; using Win_in.Sfs.Shared.Domain; @@ -32,10 +35,9 @@ public class PurchaseOrderEventHandler private readonly IItemPackAppService _itemPackAppService; private readonly ISupplierItemAppService _supplierItemAppService; private readonly IDockAppService _dockAppService; + private readonly ISupplierTimeWindowAppService _supplierTimeWindowAppService; private readonly IInventoryLabelAppService _inventoryLabelAppService; private readonly ISupplierAppService _supplierAppService; - private readonly ISupplierTimeWindowAppService _supplierTimeWindowAppService; - public PurchaseOrderEventHandler(ISupplierAsnAppService supplierAsnAppService, ILabelDefinitionAppService labelDefinitionAppService, @@ -94,10 +96,41 @@ public class PurchaseOrderEventHandler private async Task BuildSupplierAsnAsync(PurchaseOrder purchaseOrder) { var supplierAsnEditInput= ObjectMapper.Map(purchaseOrder); + supplierAsnEditInput.Details = new EditableList();//导入的是采购订单 所以下面要根据标包计算 拆成多个发货单 - //收货口 //todo 处理有问题是否要和供应商关联 + //所有的物品Code + var itemCodes = purchaseOrder.Details.GroupBy(p =>new{ p.ItemCode,p.Lot}).Select(p => p.Key.ItemCode); + + //收货口 var dock = await _dockAppService.GetAllListByFilterAsync( - new SfsBaseDataRequestInputBase() { Condition = new Condition(){Filters = new List()}, MaxResultCount = 99, SkipCount = 0, Sorting = string.Empty }, true).ConfigureAwait(false); + new SfsBaseDataRequestInputBase() { Condition = new Condition() { Filters = new List() }, MaxResultCount = 99, SkipCount = 0, Sorting = string.Empty }, true).ConfigureAwait(false); + + //供应商窗口 + var supplierTimeWindowDtos = await _supplierTimeWindowAppService.GetListBySupplierCodeAsync(purchaseOrder.SupplierCode).ConfigureAwait(false); + + //一次性返回所有物品信息 + var itemBasicDtos = await _itemBasicAppService.GetByCodesAsync(itemCodes).ConfigureAwait(false); + var ItemPacks = new List();//一次性返回所有物品包装信息 + var supplierItemDtos = new List();//一次性返回所有供应商物品信息 + + //供应商信息 + var supplierDto =await _supplierAppService.GetByCodeAsync(purchaseOrder.SupplierCode).ConfigureAwait(false); + + //所有的标签 + List inventoryLabelEditInputs = new List(); + + foreach (var itemCode in itemCodes)//查询 + { + var itemPackDtos = await _itemPackAppService.GetListByItemCodeAsync(itemCode).ConfigureAwait(false); + var itemPackDto = itemPackDtos.First(); + var supplierItem = await _supplierItemAppService.GetBySupplierCodeAndItemCodeAsync(purchaseOrder.SupplierCode, itemCode).ConfigureAwait(false); + ItemPacks.Add(itemPackDto); + supplierItemDtos.Add(supplierItem); + } + + #region 主表赋值 + + //收货口 //todo 处理有问题是否要和供应商关联 supplierAsnEditInput.DockCode = dock.First().Code; //赋值采购订单编号 @@ -119,7 +152,6 @@ public class PurchaseOrderEventHandler supplierAsnEditInput.CreateType = EnumSupplierAsnCreateType.Import; //供应商时间窗口 - var supplierTimeWindowDtos=await _supplierTimeWindowAppService.GetListBySupplierCodeAsync(purchaseOrder.SupplierCode).ConfigureAwait(false); var dayOfWeek = new List() { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; var chineseWeek= dayOfWeek[Clock.Now.DayOfWeek.GetHashCode()]; //中文星期 var dateTimeWindowDto=supplierTimeWindowDtos.First(p => p.Week == chineseWeek); @@ -131,67 +163,162 @@ public class PurchaseOrderEventHandler //发货单号 supplierAsnEditInput.Number = await _supplierAsnAppService.GenerateSupplierAsnNumberAsync(supplierAsnEditInput.ActiveDate).ConfigureAwait(false); - //所有的物品Code - var itemCodes = purchaseOrder.Details.GroupBy(p => p.ItemCode).Select(p => p.Key); - - //一次性返回所有物品信息 - var itemBasicDtos=await _itemBasicAppService.GetByCodesAsync(itemCodes).ConfigureAwait(false); - var ItemPacks = new List();//一次性返回所有物品包装信息 - var supplierItemDtos = new List();//一次性返回所有供应商物品信息 - - //一次性返回所有箱码 - var generateManyAsync = await _labelDefinitionAppService - .GenerateManyAsync(EnumLabelType.PurchaseLabel.ToString(), Clock.Now.ToString(SharedConst.TimeFormat), - supplierAsnEditInput.Details.Count).ConfigureAwait(false); + #endregion - foreach (var itemCode in itemCodes)//查询 + //根据采购订单的数量拆分成多个 箱 + foreach (var purchaseOrderDetaildetail in purchaseOrder.Details) { - var itemPackDtos = await _itemPackAppService.GetListByItemCodeAsync(itemCode).ConfigureAwait(false); - var itemPackDto = itemPackDtos.First(); - var supplierItem = await _supplierItemAppService.GetBySupplierCodeAndItemCodeAsync(purchaseOrder.SupplierCode, itemCode).ConfigureAwait(false); - ItemPacks.Add(itemPackDto); - supplierItemDtos.Add(supplierItem); - } + //当前物品的总数 + var itemQty = purchaseOrderDetaildetail.Qty; - //赋值 详情表 - supplierAsnEditInput.Details.ForEach(detail => - { - var purchaseOrderDetail= purchaseOrder.Details.First(p => p.ItemCode == detail.ItemCode); + //todo 一个物品多个包装?怎么取值 + //标包数 + var itemPackDto=ItemPacks.First(p => p.ItemCode == purchaseOrderDetaildetail.ItemCode); - //添加箱码 - var pakcingCode = generateManyAsync.First(); - detail.PackingCode = pakcingCode; - generateManyAsync.Remove(pakcingCode); + //总箱数 + var itemPackQty = (int)(itemQty / itemPackDto.Qty); + if (itemQty % itemPackQty!= 0) + { + itemPackQty++; + } //添加物品信息 - var itemBasicDto= itemBasicDtos.First(p=>p.Code==detail.ItemCode); - detail.ItemName= itemBasicDto.Name; - detail.ItemDesc1 = itemBasicDto.Desc1; - detail.ItemDesc2= itemBasicDto.Desc2; + var itemBasicDto = itemBasicDtos.First(p => p.Code == purchaseOrderDetaildetail.ItemCode); + + //供应商物品 + var supplierItemDto = supplierItemDtos.First(p => + p.ItemCode == purchaseOrderDetaildetail.ItemCode && p.SupplierCode == purchaseOrder.SupplierCode); - //标包 - var itemPack = ItemPacks.First(p => p.ItemCode == detail.ItemCode); //todo 一个物品多个包装?怎么取值 - detail.StdPackQty = itemPack.Qty; + //一次性返回所有箱码 + var generateManyAsync = await _labelDefinitionAppService + .GenerateManyAsync(EnumLabelType.PurchaseLabel.ToString(), Clock.Now.ToString(SharedConst.TimeFormat), + itemPackQty).ConfigureAwait(false); - //供应商物品 - var supplierItemDto=supplierItemDtos.First(p => - p.ItemCode == detail.ItemCode && p.SupplierCode == supplierAsnEditInput.SupplierCode); - detail.SupplierPackQty = supplierItemDto.SupplierPackQty; - detail.SupplierPackUom= supplierItemDto.SupplierPackUom; - //todo 批次赋值有问题 - detail.SupplierBatch = purchaseOrderDetail.Lot; + for (var i = 0; i < itemPackQty; i++) + { + var supplierAsnDetailInput = ObjectMapper.Map(purchaseOrderDetaildetail); + //添加箱码 + var pakcingCode = generateManyAsync.First(); + supplierAsnDetailInput.PackingCode = pakcingCode; + generateManyAsync.Remove(pakcingCode); + + supplierAsnDetailInput.ItemName = itemBasicDto.Name; + supplierAsnDetailInput.ItemDesc1 = itemBasicDto.Desc1; + supplierAsnDetailInput.ItemDesc2 = itemBasicDto.Desc2; + + //标包 + supplierAsnDetailInput.StdPackQty = itemPackDto.Qty; - //订单行 - detail.PoLine = purchaseOrderDetail.PoLine; + supplierAsnDetailInput.SupplierPackQty = supplierItemDto.SupplierPackQty; + supplierAsnDetailInput.SupplierPackUom = supplierItemDto.SupplierPackUom; + //todo 批次赋值有问题 + supplierAsnDetailInput.SupplierBatch = purchaseOrderDetaildetail.Lot; - //推荐ERP库位 - detail.RecommendErpCode = purchaseOrderDetail.LocationErpCode; + //订单行 + supplierAsnDetailInput.PoLine = purchaseOrderDetaildetail.PoLine; - detail.PoNumber = purchaseOrder.Number; - }); + //推荐ERP库位 + supplierAsnDetailInput.RecommendErpCode = purchaseOrderDetaildetail.LocationErpCode; + supplierAsnDetailInput.PoNumber = purchaseOrder.Number; + supplierAsnDetailInput.Qty = itemQty>itemPackDto.Qty ? itemPackDto.Qty : itemQty; + + itemQty-=itemPackDto.Qty; + + var InventoryLabelEditInput = await BuildInventoryLabelEditInputAsync(supplierAsnEditInput, supplierAsnDetailInput, supplierDto, itemBasicDto, supplierItemDto, itemPackDto).ConfigureAwait(false); + inventoryLabelEditInputs.Add(InventoryLabelEditInput); + + supplierAsnEditInput.Details.Add(supplierAsnDetailInput); + } + } + + //插入所有的标签 + await _inventoryLabelAppService.CreateManyByNoCodeAsync(inventoryLabelEditInputs).ConfigureAwait(false); + + //赋值 详情表 return supplierAsnEditInput; } + /// + /// 创建 构造标签 + /// + /// + /// + /// + /// + /// + /// + /// + private Task BuildInventoryLabelEditInputAsync(SupplierAsnEditInput supplierAsn, + SupplierAsnDetailInput supplierAsnDetail, + SupplierDTO supplierDto, + ItemBasicDTO itemBasicDto, + SupplierItemDTO supplierItemDto, + ItemPackDTO itemPackDto) + { + if (itemBasicDto == null) + { + throw new UserFriendlyException($"{supplierAsnDetail.ItemCode}零件信息为空"); + } + + if (supplierDto == null) + { + throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商为空"); + } + + if (supplierItemDto == null) + { + throw new UserFriendlyException($"{supplierAsn.SupplierCode}供应商零件或{itemBasicDto.Code}零件信息为空"); + } + + var inputLabel = new InventoryLabelEditInput(); + inputLabel.LabelType = EnumLabelType.PurchaseLabel; + + inputLabel.SupplierCode = supplierAsn.SupplierCode; + inputLabel.RpNumber = supplierAsn.RpNumber; + inputLabel.AsnNumber = supplierAsn.Number; + + inputLabel.PoNumber = supplierAsnDetail.PoNumber; + inputLabel.SupplierBatch = supplierAsnDetail.SupplierBatch; + inputLabel.ProduceDate = supplierAsnDetail.ProduceDate; + inputLabel.ArriveDate = supplierAsnDetail.ArriveDate; + inputLabel.FullBarcodeString = supplierAsnDetail.PackingCode; + inputLabel.LocationErpCode = supplierAsnDetail.RecommendErpCode; + inputLabel.Lot = supplierAsnDetail.Lot; + inputLabel.RecommendLocationCode = supplierAsnDetail.RecommendErpCode; + inputLabel.Remark = supplierAsnDetail.Remark; + inputLabel.Code = supplierAsnDetail.PackingCode; + + inputLabel.Qty = supplierAsnDetail.Qty; + inputLabel.Uom = supplierAsnDetail.Uom; + + inputLabel.ItemCode = itemBasicDto.Code; + inputLabel.ItemName = itemBasicDto.Name; + inputLabel.ItemDesc1 = itemBasicDto.Desc1; + inputLabel.ItemDesc2 = itemBasicDto.Desc2; + + inputLabel.ExpireDate = DateTime.Now.AddDays(itemBasicDto.GetValidateDays()); + + inputLabel.ExtraProperties = new ExtraPropertyDictionary(); + inputLabel.LabelStatus = LabelStatus.Enable; + + inputLabel.Specifications = itemBasicDto.Color; + inputLabel.StdPackQty = itemPackDto.Qty; + + inputLabel.SupplierItemCode = supplierItemDto.SupplierItemCode; + inputLabel.SupplierItemName = supplierItemDto.ItemName; + inputLabel.SupplierName = supplierDto.Name; + inputLabel.SupplierSimpleName = supplierDto.ShortName; + inputLabel.Team = string.Empty; + inputLabel.ProdLine = string.Empty; + inputLabel.QLevel = string.Empty; + inputLabel.QualityFile = string.Empty; + + inputLabel.Shift = string.Empty; + inputLabel.ContainerCode = string.Empty; + + return Task.FromResult(inputLabel); + } + #endregion } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs index 0669292d5..b2d0d8dbd 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/PurchaseReceiptRequestEventHandler.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Castle.Components.DictionaryAdapter; using Volo.Abp; using Volo.Abp.EventBus; using Volo.Abp.SettingManagement; @@ -117,22 +118,35 @@ public class PurchaseReceiptRequestEventHandler job.JobStatus = EnumJobStatus.Open; job.Type = EnumPurchaseReceiptNoteType.GeneralReceipt; job.IsAutoComplete = false; - + job.WarehouseCode = location.WarehouseCode; job.WorkGroupCode = location.WorkGroupCode; job.Priority = PriorityHelper.GetPriority(Clock); job.PriorityIncrement = 1; - var jobDetails = ObjectMapper.Map, List>(details); - foreach (var jobDetail in jobDetails) + job.Details = new List(); + + foreach (var detail in details) { + var jobDetail = ObjectMapper.Map(detail); jobDetail.PurchaseReceiptInspectStatus = EnumPurchaseReceiptInspect.INSP; jobDetail.Status = EnumInventoryStatus.INSP; - jobDetail.RecommendToLocationErpCode = location.ErpLocationCode; + jobDetail.RecommendToLocationCode = location.Code; - } + jobDetail.RecommendToLocationErpCode = location.ErpLocationCode; + jobDetail.RecommendToWarehouseCode= location.WarehouseCode; + jobDetail.RecommendToLocationArea= location.AreaCode; + jobDetail.RecommendToLocationGroup = location.LocationGroupCode; - job.Details = jobDetails; + jobDetail.RecommendErpCode = detail.RecommendErpCode; + jobDetail.RecommendArriveDate = detail.ArriveDate; + jobDetail.RecommendContainerCode = detail.ContainerCode; + jobDetail.RecommendExpireDate= detail.ExpireDate; + jobDetail.RecommendLot= detail.Lot; + + job.Details.Add(jobDetail); + } + return job; } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs index 45026f517..72e46f880 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/StoreEventAutoMapperProfile.cs @@ -7,11 +7,26 @@ public partial class StoreEventAutoMapperProfile : Profile public StoreEventAutoMapperProfile() { #region Orders + //采购订单 PurchaseOrderAutoMapperProfile(); + + #endregion + + #region plan + + //发货单 + SupplierAsnAutoMapperProfile(); + #endregion + #region request + + //到货单 PurchaseReceiptRequestAutoMapperProfile(); + + #endregion + InspectRequestAutoMapperProfile(); BackFlushNoteAutoMapperProfile(); CountAdjustNoteAutoMapperProfile(); @@ -37,7 +52,7 @@ public partial class StoreEventAutoMapperProfile : Profile PutawayNoteAutoMapperProfile(); RecycledMaterialReceiptNoteAutoMapperProfile(); ScrapNoteAutoMapperProfile(); - SupplierAsnAutoMapperProfile(); + UnplannedIssueNoteAutoMapperProfile(); UnplannedIssueRequestAutoMapperProfile(); UnplannedReceiptNoteAutoMapperProfile(); diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/PurchaseReceiptNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/PurchaseReceiptNoteEventHandler.cs index 6be5d156d..47c5787d6 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/PurchaseReceiptNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/PurchaseReceiptNoteEventHandler.cs @@ -29,6 +29,7 @@ public class PurchaseReceiptNoteEventHandler private readonly IInspectRequestAppService _inspectRequestAppService; private readonly IPurchaseOrderAppService _purchaseOrderAppService; private readonly IItemQualityAppService _itemQualityAppService; + private readonly ISupplierAsnAppService _supplierAsnAppService; /// /// 收货记录 @@ -37,14 +38,15 @@ public class PurchaseReceiptNoteEventHandler /// /// public PurchaseReceiptNoteEventHandler( - IInspectRequestAppService inspectRequestAppService - , IPurchaseOrderAppService purchaseOrderAppService - , IItemQualityAppService itemQualityAppService - ) + IInspectRequestAppService inspectRequestAppService, + IPurchaseOrderAppService purchaseOrderAppService, + IItemQualityAppService itemQualityAppService, + ISupplierAsnAppService supplierAsnAppService) { _inspectRequestAppService = inspectRequestAppService; _purchaseOrderAppService = purchaseOrderAppService; _itemQualityAppService = itemQualityAppService; + _supplierAsnAppService = supplierAsnAppService; } /// @@ -67,24 +69,43 @@ public class PurchaseReceiptNoteEventHandler //更新订单已收货数量 await UpdatePurchaseOrderAsync(entity).ConfigureAwait(false); + + //更新发货单状态 + await UpdateSupplierAsnAsync(entity.AsnNumber).ConfigureAwait(false); } + /// + /// 更新采购订单 已收货数量 + /// + /// + /// private async Task UpdatePurchaseOrderAsync(PurchaseReceiptNote entity) { - var purchaseOrderDetailUpdateInputs = entity.Details - .Select(BuildPurchaseOrderDetailUpdateInput).ToList(); + var purchaseOrderDetailUpdateInputs = new List(); + + foreach (var detail in entity.Details) + { + var purchaseOrderDetailUpdateInput = new PurchaseOrderDetailUpdateInput() + { + PoLine = detail.PoLine, + ItemCode = detail.ItemCode, + ReceivedQty = detail.Qty, + }; + + purchaseOrderDetailUpdateInputs.Add(purchaseOrderDetailUpdateInput); + } await _purchaseOrderAppService.UpdateDetailsAsync(entity.PoNumber, purchaseOrderDetailUpdateInputs).ConfigureAwait(false); } - private static PurchaseOrderDetailUpdateInput BuildPurchaseOrderDetailUpdateInput(PurchaseReceiptNoteDetail purchaseReceiptNoteDetail) + /// + /// 更新 发货单状态 + /// + /// + /// + private async Task UpdateSupplierAsnAsync(string asnNumber) { - return new PurchaseOrderDetailUpdateInput() - { - PoLine = purchaseReceiptNoteDetail.PoLine, - ItemCode = purchaseReceiptNoteDetail.ItemCode, - ReceivedQty = purchaseReceiptNoteDetail.Qty, - }; + await _supplierAsnAppService.UpdateStatusAsync(asnNumber,EnumSupplierAsnStatus.Received).ConfigureAwait(false); } #region 私有 @@ -230,7 +251,7 @@ public class PurchaseReceiptNoteEventHandler /// private async Task BuildInspectRequestAsync(PurchaseReceiptNote entity, Dictionary dictionary) { - //过滤出去 其他装填 只保留目检合格的 因为只有 目检合格的 需要继续质检 + //过滤出去 其他状态 只保留目检合格的 因为只有 目检合格的 需要继续质检 var packingCodeList = entity.Details.Where(p => p.PurchaseReceiptInspectStatus == EnumPurchaseReceiptInspect.OK).Select(p => p.PackingCode); var createInput = ObjectMapper.Map(entity); @@ -284,6 +305,7 @@ public class PurchaseReceiptNoteEventHandler { p.LocationCode = inspectLocation.Code; p.LocationErpCode = inspectLocation.ErpLocationCode; + p.WarehouseCode = inspectLocation.WarehouseCode; }); } @@ -332,6 +354,9 @@ public class PurchaseReceiptNoteEventHandler CrackQty = 0, FailedQty = 0, NotPassedQty = 0, + WarehouseCode = template.WarehouseCode, + LocationArea = template.LocationArea, + LocationGroup = template.LocationGroup, }; return inspectRequestSummaryDetailInput; }