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 20f15edef..97de80e01 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 @@ -1703,7 +1703,7 @@ CREATE TABLE [Store_TransferNote] ( [Id] uniqueidentifier NOT NULL, [RequestNumber] nvarchar(max) NULL, [JobNumber] nvarchar(64) NULL, - [Type] nvarchar(64) NULL, + [Type] nvarchar(64) NOT NULL, [UseOnTheWayLocation] bit NOT NULL, [ConfirmTime] datetime2 NULL, [Confirmed] bit NOT NULL, diff --git a/be/Modules/Shared/src/Win_in.Sfs.Shared.Event/SfsCreatedEntityEventData.cs b/be/Modules/Shared/src/Win_in.Sfs.Shared.Event/SfsCreatedEntityEventData.cs index 25d322ea1..ef4518f07 100644 --- a/be/Modules/Shared/src/Win_in.Sfs.Shared.Event/SfsCreatedEntityEventData.cs +++ b/be/Modules/Shared/src/Win_in.Sfs.Shared.Event/SfsCreatedEntityEventData.cs @@ -6,5 +6,6 @@ public class SfsCreatedEntityEventData : EntityEventData { public SfsCreatedEntityEventData(TEntity entity) : base(entity) { + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/Inputs/TransferNoteImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/Inputs/TransferNoteImportInput.cs index 53c5f1e1c..de6b8186e 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/Inputs/TransferNoteImportInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Notes/TransferNotes/Inputs/TransferNoteImportInput.cs @@ -1,3 +1,4 @@ +using System; using System.ComponentModel.DataAnnotations; using DocumentFormat.OpenXml.Drawing; using Win_in.Sfs.Shared.Application.Contracts; @@ -12,10 +13,9 @@ public class TransferNoteImportInput : SfsStoreImportInputBase /// [Display(Name = "调拨类型")] [Required(ErrorMessage = "{0}是必填项")] - [ValueMapping("标准", "Normal")] - [ValueMapping("储位内移库", "enuimSameERPLoc")] - [ValueMapping("储位间移库", "DiffERPLoc")] - [ValueMapping("储位间移库", "ItemScrap")] + [ImporterHeader(Name = "调拨类型")] + [ExporterHeader(DisplayName = "调拨类型")] + [ValueMapping("区域内调拨(储位内移库)", EnumTransSubType.Transfer_Inside)] public string Type { get; set; } /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/TransferRequests/Inputs/TransferRequestImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/TransferRequests/Inputs/TransferRequestImportInput.cs index b93a1b923..4c096c02d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/TransferRequests/Inputs/TransferRequestImportInput.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/TransferRequests/Inputs/TransferRequestImportInput.cs @@ -12,6 +12,9 @@ public class TransferRequestImportInput : SfsStoreImportInputBase /// [Display(Name = "调拨类型")] [Required(ErrorMessage = "{0}是必填项")] + [ImporterHeader(Name = "调拨类型")] + [ExporterHeader(DisplayName = "调拨类型")] + [ValueMapping("客户库位调拨(客户储位调拨)", EnumTransSubType.Transfer_Customer)] public string Type { get; set; } /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs index 63187fec3..09de0cd4d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/TransferNotes/TransferNoteAppService.cs @@ -1,14 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; - using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Volo.Abp.Application.Dtos; -using Win_in.Sfs.Shared.Application.Contracts; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.Inventory.Application.Contracts; @@ -19,290 +18,279 @@ using Win_in.Sfs.Wms.Store.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application; /// -/// 调拨转移记录 +/// 调拨转移记录 /// [Authorize] [Route($"{StoreConsts.RootPath}transfer-note")] - public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase - , + , ITransferNoteAppService { private readonly ITransferNoteManager _transferNoteManager; - private readonly ILocationCapacityAppService _locationCapacityAppService; + private readonly IBalanceAppService _balanceAppService; + private readonly ILocationAppService _locationAppService; public TransferNoteAppService( - ITransferNoteRepository repository - , ITransferNoteManager transferNoteManager - , ILocationCapacityAppService locationCapacityAppService - ) : base(repository) + ITransferNoteRepository repository, + ITransferNoteManager transferNoteManager, + IBalanceAppService balanceAppService, + ILocationAppService locationAppService) : base(repository) { _transferNoteManager = transferNoteManager; - _locationCapacityAppService = locationCapacityAppService; + _balanceAppService = balanceAppService; + _locationAppService = locationAppService; } - /// - /// 库存转移 - /// - /// - /// - [HttpPost("")] - public override async Task CreateAsync(TransferNoteEditInput input) - { - var entity = ObjectMapper.Map(input); - - await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false); - - var dto = ObjectMapper.Map(entity); - - return dto; - } + #region 东阳使用 /// - /// 【批量】 库存转移 + /// 用来重写 导入数据时可以加工数据 /// - /// + /// /// - [HttpPost("create-many")] - public async Task> CreateManyAsync(List input) + protected override async Task> ImportProcessingEntityAsync( + Dictionary dictionary) { - var entitys = ObjectMapper.Map, List>(input); + var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); - var resultEntity = new List(); - - foreach (var entity in entitys) + foreach (var transferNote in addList) { - resultEntity.Add(await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false)); - _ = ObjectMapper.Map(entity); + if (transferNote.Type == EnumTransSubType.Transfer_Inside.GetDisplayName()) //储位内调拨 + { + transferNote.Type = EnumTransSubType.Transfer_Inside.ToString();//重点 需要转换 + foreach (var detail in transferNote.Details) + { + var balanceDto = await _balanceAppService.GetByItemLocationAndPackingAsync(detail.FromPackingCode, + detail.ItemCode, detail.FromLocationCode).ConfigureAwait(false); + var toLocationDto= await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); + + detail.OnTheWayLocationCode = bool.FalseString; + detail.ItemCode=balanceDto.ItemCode; + detail.ArriveDate=balanceDto.ArriveDate; + detail.ItemDesc1=balanceDto.ItemDesc1; + detail.ItemDesc2=balanceDto.ItemDesc2; + detail.ItemName=balanceDto.ItemName; + detail.ProduceDate=balanceDto.ProduceDate; + detail.Qty=balanceDto.Qty; + detail.Uom=balanceDto.Uom; + detail.ExpireDate=balanceDto.ExpireDate; + detail.StdPackQty=balanceDto.StdPackQty; + detail.SupplierBatch=balanceDto.SupplierBatch; + + detail.FromLocationArea = balanceDto.LocationArea; + detail.FromContainerCode = balanceDto.ContainerCode; + detail.FromLocationErpCode = balanceDto.LocationErpCode; + detail.FromLocationGroup = balanceDto.LocationGroup; + detail.FromPackingCode = balanceDto.PackingCode; + detail.FromLocationArea = balanceDto.LocationArea; + detail.FromStatus = balanceDto.Status; + detail.FromWarehouseCode = balanceDto.WarehouseCode; + detail.FromLot = balanceDto.Lot; + + detail.ToLocationArea = toLocationDto.AreaCode; + detail.ToLocationErpCode = toLocationDto.LocationGroupCode; + detail.ToLocationGroup = toLocationDto.LocationGroupCode; + detail.ToWarehouseCode = toLocationDto.WarehouseCode; + detail.ToContainerCode = balanceDto.ContainerCode; + detail.ToPackingCode = balanceDto.PackingCode; + detail.ToLocationArea = balanceDto.LocationArea; + detail.ToStatus = balanceDto.Status; + detail.ToLot = balanceDto.Lot; + } + } } - return ObjectMapper.Map, List>(resultEntity); + return dictionary; } /// - /// 确认对应的记录单 - /// - /// - /// - - [HttpPost("confirm/{id}")] - - public virtual async Task ConfirmAsync(Guid id) - { - var entity = await _transferNoteManager.ConfirmAsync(id).ConfigureAwait(false); - var dto = ObjectMapper.Map(entity); - return dto; - - } - - /// - /// 按条件获取线边调拨的分页列表 - /// request sample - /// { - /// "maxResultCount": 1000, - /// "skipCount": 0, - /// "sorting": "", - /// "condition": { "filters": []} - /// } + /// 按条件获取线边调拨的分页列表 + /// request sample + /// { + /// "maxResultCount": 1000, + /// "skipCount": 0, + /// "sorting": "", + /// "condition": { "filters": []} + /// } /// /// /// /// /// [HttpPost("get-wip-list")] - public virtual async Task> GetWipTransferListAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, + public virtual async Task> GetWipTransferListAsync( + SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, CancellationToken cancellationToken = default) { - return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_WIP, includeDetails, cancellationToken).ConfigureAwait(false); + return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_WIP, includeDetails, + cancellationToken).ConfigureAwait(false); } /// - /// 按条件获取储位间调拨的分页列表 - /// request sample - /// { - /// "maxResultCount": 1000, - /// "skipCount": 0, - /// "sorting": "", - /// "condition": { "filters": []} - /// } + /// 按条件获取储位间调拨的分页列表 + /// request sample + /// { + /// "maxResultCount": 1000, + /// "skipCount": 0, + /// "sorting": "", + /// "condition": { "filters": []} + /// } /// /// /// /// /// [HttpPost("get-erp-loc-list")] - public virtual async Task> GetAreaTransferListAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, + public virtual async Task> GetAreaTransferListAsync( + SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, CancellationToken cancellationToken = default) { - return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_Area, includeDetails, cancellationToken).ConfigureAwait(false); + return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_Area, includeDetails, + cancellationToken).ConfigureAwait(false); } /// - /// 按条件获取储位间调拨的分页列表 - /// request sample - /// { - /// "maxResultCount": 1000, - /// "skipCount": 0, - /// "sorting": "", - /// "condition": { "filters": []} - /// } + /// 按条件获取储位内移库的分页列表 + /// request sample + /// { + /// "maxResultCount": 1000, + /// "skipCount": 0, + /// "sorting": "", + /// "condition": { "filters": []} + /// } /// /// /// /// /// [HttpPost("get-inside-list")] - public virtual async Task> GetInsideTransferListAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, + public virtual async Task> GetInsideTransferListAsync( + SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, CancellationToken cancellationToken = default) { - return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_Inside, includeDetails, cancellationToken).ConfigureAwait(false); + return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_Inside, includeDetails, + cancellationToken).ConfigureAwait(false); } /// - /// 按条件获取客户储位间调拨的分页列表 - /// request sample - /// { - /// "maxResultCount": 1000, - /// "skipCount": 0, - /// "sorting": "", - /// "condition": { "filters": []} - /// } + /// 按条件获取客户储位间调拨的分页列表 + /// request sample + /// { + /// "maxResultCount": 1000, + /// "skipCount": 0, + /// "sorting": "", + /// "condition": { "filters": []} + /// } /// /// /// /// /// [HttpPost("get-custom-loc-list")] - public virtual async Task> GetCustomerTransferListAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, + public virtual async Task> GetCustomerTransferListAsync( + SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, CancellationToken cancellationToken = default) { - return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_Customer, includeDetails, cancellationToken).ConfigureAwait(false); + return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_Customer, includeDetails, + cancellationToken).ConfigureAwait(false); } /// - /// 按条件获取储位间调拨的分页列表 - /// request sample - /// { - /// "maxResultCount": 1000, - /// "skipCount": 0, - /// "sorting": "", - /// "condition": { "filters": []} - /// } + /// 按条件获取储位间调拨的分页列表 + /// request sample + /// { + /// "maxResultCount": 1000, + /// "skipCount": 0, + /// "sorting": "", + /// "condition": { "filters": []} + /// } /// /// /// /// /// [HttpPost("get-diff-erp-loc-list")] - public virtual async Task> GetListForDiffERPLocAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, + public virtual async Task> GetListForDiffERPLocAsync( + SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, CancellationToken cancellationToken = default) { - return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_Warehouse, includeDetails, cancellationToken).ConfigureAwait(false); + return await GetSubTypeListAsync(sfsRequestDTO, EnumTransSubType.Transfer_Warehouse, includeDetails, + cancellationToken).ConfigureAwait(false); } - private async Task> GetSubTypeListAsync(SfsStoreRequestInputBase sfsRequestDTO, EnumTransSubType type, bool includeDetails = false, - CancellationToken cancellationToken = default) + private async Task> GetSubTypeListAsync(SfsStoreRequestInputBase sfsRequestDTO, + EnumTransSubType type, bool includeDetails = false, + CancellationToken cancellationToken = default) { + sfsRequestDTO.Condition.Filters.Add(new Filter + { + Action = "==", + Column = "Type", + Logic = EnumFilterLogic.And.ToString(), + Value = type.ToString() + }); - sfsRequestDTO.Condition.Filters.Add(new Sfs.Shared.Domain.Filter() { Action = "==", Column = "Type", Logic = EnumFilterLogic.And.ToString(), Value = ((int)type).ToString(), }); - - Expression> expression = sfsRequestDTO.Condition.Filters?.Count > 0 + var expression = sfsRequestDTO.Condition.Filters?.Count > 0 ? sfsRequestDTO.Condition.Filters.ToLambda() : p => true; - return await GetPagedListAsync(expression, sfsRequestDTO.SkipCount, sfsRequestDTO.MaxResultCount, sfsRequestDTO.Sorting, includeDetails, cancellationToken).ConfigureAwait(false); + return await GetPagedListAsync(expression, sfsRequestDTO.SkipCount, sfsRequestDTO.MaxResultCount, + sfsRequestDTO.Sorting, includeDetails, cancellationToken).ConfigureAwait(false); } - protected virtual async Task ImportDataAsync(List entites, List deleteEntities) - { - await _transferNoteManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false); - } + #endregion - protected override Func GetEntityExpression() - { - return p => (1); - } - - protected virtual async Task<(List entites, List deleteEntities)> BuildImportDataAsync(ImportResult importResult, EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false) + /// + /// 库存转移 + /// + /// + /// + [HttpPost("")] + public override async Task CreateAsync(TransferNoteEditInput input) { - if (importResult.Data.Any(t => t.ReportStatus == EnumImportReportStatus.Failed)) - { - if (!isAllowPartImport) - { - return (null, null); - } - } + var entity = ObjectMapper.Map(input); - var entites = new List(); + await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false); - var details = new List(); + var dto = ObjectMapper.Map(entity); - var deleteEntites = new List(); + return dto; + } - var entityExpression = GetEntityExpression(); + /// + /// 【批量】 库存转移 + /// + /// + /// + [HttpPost("create-many")] + public async Task> CreateManyAsync(List input) + { + var entitys = ObjectMapper.Map, List>(input); - var groupList = importResult.Data.ToList().GroupBy(entityExpression).Distinct().ToList(); + var resultEntity = new List(); - foreach (var group in groupList) + foreach (var entity in entitys) { - var input = group.FirstOrDefault(); - - var inputDetails = group.ToList(); - - if (inputDetails.Any(t => t.ReportStatus == EnumImportReportStatus.Failed)) - { - continue; - } - - var exist = await GetEntityAsync(input).ConfigureAwait(false); - - var entity = ObjectMapper.Map(input); - - await SetEntityPropertiesAsync(entity, input).ConfigureAwait(false); - - switch (importMethod) - { - case EnumImportMethod.Update: - if (exist != null) - { - entity.SetId(exist.Id); - } - break; - case EnumImportMethod.Replace: - if (exist != null) - { - deleteEntites.Add(exist); - } - break; - } - - foreach (var inputDetail in inputDetails) - { - var detail = ObjectMapper.Map(inputDetail); - await SetDetailPropertiesAsync(detail, input).ConfigureAwait(false); - entity.AddDetail(detail); - } - - entites.Add(entity); + resultEntity.Add(await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false)); + _ = ObjectMapper.Map(entity); } - return (entites, deleteEntites); - } - - private static async Task SetDetailPropertiesAsync(TransferNoteDetail detail, TransferNoteImportInput input) - { - await Task.CompletedTask.ConfigureAwait(false); - + return ObjectMapper.Map, List>(resultEntity); } - private static async Task SetEntityPropertiesAsync(TransferNote entity, TransferNoteImportInput input) + /// + /// 确认对应的记录单 + /// + /// + /// + [HttpPost("confirm/{id}")] + public virtual async Task ConfirmAsync(Guid id) { - await Task.CompletedTask.ConfigureAwait(false); - - entity.UseOnTheWayLocation = false;//不需要中间库 - - entity.Confirmed = true;//自动确认 - + var entity = await _transferNoteManager.ConfirmAsync(id).ConfigureAwait(false); + var dto = ObjectMapper.Map(entity); + return dto; } + } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/TransferRequests/TransferRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/TransferRequests/TransferRequestAppService.cs index 7a713aa3a..c842b5b93 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/TransferRequests/TransferRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/TransferRequests/TransferRequestAppService.cs @@ -4,13 +4,15 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading; using System.Threading.Tasks; - using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Volo.Abp.Application.Dtos; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; +using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; @@ -23,43 +25,102 @@ namespace Win_in.Sfs.Wms.Store.Application; [Authorize] [Route($"{StoreConsts.RootPath}transfer-request")] public class TransferRequestAppService : SfsStoreRequestAppServiceBase - , + , ITransferRequestAppService { private readonly ITransferRequestManager _transferRequestManager; + private readonly IBalanceAppService _balanceAppService; + private readonly ILocationAppService _locationAppService; public TransferRequestAppService( - ITransferRequestRepository repository - , ITransferRequestManager transferRequestManager - ) : base(repository, transferRequestManager) + ITransferRequestRepository repository, + ITransferRequestManager transferRequestManager, + IBalanceAppService balanceAppService, + ILocationAppService locationAppService) : base(repository, transferRequestManager) { _transferRequestManager = transferRequestManager; + _balanceAppService = balanceAppService; + _locationAppService = locationAppService; } + #region 东阳使用 + /// - /// 【创建】库移请求 + /// 用来重写 导入数据时可以加工数据 /// - /// + /// /// - [HttpPost("")] - public override async Task CreateAsync(TransferRequestEditInput input) + protected override async Task> ImportProcessingEntityAsync( + Dictionary dictionary) { - var entity = ObjectMapper.Map(input); + var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); + + foreach (var transferRequest in addList) + { + if (transferRequest.Type == EnumTransSubType.Transfer_Customer.GetDisplayName()) //客户储位调拨 + { + transferRequest.Type = EnumTransSubType.Transfer_Customer.ToString(); //重点 需要转换 + transferRequest.UseOnTheWayLocation = true; + + foreach (var detail in transferRequest.Details) + { + var balanceDto = await _balanceAppService.GetByItemLocationAndPackingAsync(detail.FromPackingCode, + detail.ItemCode, detail.FromLocationCode).ConfigureAwait(false); + var toLocationDto = await _locationAppService.GetByCodeAsync(detail.ToLocationCode) + .ConfigureAwait(false); + + detail.ItemCode = balanceDto.ItemCode; + detail.ArriveDate = balanceDto.ArriveDate; + detail.ItemDesc1 = balanceDto.ItemDesc1; + detail.ItemDesc2 = balanceDto.ItemDesc2; + detail.ItemName = balanceDto.ItemName; + detail.ProduceDate = balanceDto.ProduceDate; + detail.Qty = balanceDto.Qty; + detail.Uom = balanceDto.Uom; + detail.ExpireDate = balanceDto.ExpireDate; + detail.StdPackQty = balanceDto.StdPackQty; + detail.SupplierBatch = balanceDto.SupplierBatch; + + detail.FromLocationArea = balanceDto.LocationArea; + detail.FromContainerCode = balanceDto.ContainerCode; + detail.FromLocationErpCode = balanceDto.LocationErpCode; + detail.FromLocationGroup = balanceDto.LocationGroup; + detail.FromPackingCode = balanceDto.PackingCode; + detail.FromLocationArea = balanceDto.LocationArea; + detail.FromStatus = balanceDto.Status; + detail.FromWarehouseCode = balanceDto.WarehouseCode; + detail.FromLot = balanceDto.Lot; + + detail.ToLocationArea = toLocationDto.AreaCode; + detail.ToLocationErpCode = toLocationDto.LocationGroupCode; + detail.ToLocationGroup = toLocationDto.LocationGroupCode; + detail.ToWarehouseCode = toLocationDto.WarehouseCode; + detail.ToContainerCode = balanceDto.ContainerCode; + detail.ToPackingCode = balanceDto.PackingCode; + detail.ToLocationArea = balanceDto.LocationArea; + detail.ToStatus = balanceDto.Status; + detail.ToLot = balanceDto.Lot; + } + + await SetEntityPropertiesAsync(transferRequest, EnumTransSubType.Transfer_Customer).ConfigureAwait(false); + } + } + + return dictionary; + } + + private async Task SetEntityPropertiesAsync(TransferRequest entity, EnumTransSubType subType) + { + var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Transfer, subType) + .ConfigureAwait(false); + entity.Worker = CurrentUser.GetUserName(); - var subType = Enum.Parse(input.Type); - var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Transfer, 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 _transferRequestManager.CreateAsync(entity).ConfigureAwait(false); - - var dto = ObjectMapper.Map(entity); - - return dto; } #region 查询相关 @@ -155,6 +216,7 @@ public class TransferRequestAppService : SfsStoreRequestAppServiceBase return await GetListForOtherBaseAsync(sfsRequestDTO, EnumTransSubType.Transfer_WIP, includeDetails, cancellationToken).ConfigureAwait(false); } + /// /// 按条件获取分页列表 /// @@ -168,7 +230,9 @@ public class TransferRequestAppService : SfsStoreRequestAppServiceBase CancellationToken cancellationToken = default) { sfsRequestDTO.Condition.Filters.Add(new Filter - { Action = "==", Column = "Type", Logic = EnumFilterLogic.And.ToString(), Value = ((int)type).ToString() }); + { + Action = "==", Column = "Type", Logic = EnumFilterLogic.And.ToString(), Value = type.ToString() + }); var expression = sfsRequestDTO.Condition.Filters?.Count > 0 ? sfsRequestDTO.Condition.Filters.ToLambda() @@ -178,84 +242,36 @@ public class TransferRequestAppService : SfsStoreRequestAppServiceBase sfsRequestDTO.Sorting, includeDetails, cancellationToken).ConfigureAwait(false); } - #endregion 查询相关 + #endregion + + #endregion + /// + /// 【创建】库移请求 /// - /// - /// - /// + /// /// - protected virtual async Task<(List entites, List deleteEntities)> - BuildImportDataAsync(ImportResult importResult, - EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false) + [HttpPost("")] + public override async Task CreateAsync(TransferRequestEditInput input) { - if (importResult.Data.Any(t => t.ReportStatus == EnumImportReportStatus.Failed)) - { - if (!isAllowPartImport) - { - return (null, null); - } - } - - var entites = new List(); - - var details = new List(); - - var deleteEntites = new List(); - - var entityExpression = GetEntityExpression(); - - var groupList = importResult.Data.ToList().GroupBy(entityExpression).Distinct().ToList(); - - foreach (var group in groupList) - { - var input = group.FirstOrDefault(); - - var inputDetails = group.ToList(); - - if (!inputDetails.Any(t => t.ReportStatus == EnumImportReportStatus.Failed)) - { - var exist = await GetEntityAsync(input).ConfigureAwait(false); - - var entity = ObjectMapper.Map(input); - - await SetEntityPropertiesAsync(entity, input.Type).ConfigureAwait(false); - - switch (importMethod) - { - case EnumImportMethod.Update: - if (exist != null) - { - entity.SetId(exist.Id); - } - - break; - - case EnumImportMethod.Replace: - if (exist != null) - { - deleteEntites.Add(exist); - } - - break; - } - - foreach (var inputDetail in inputDetails) - { - var detail = ObjectMapper.Map(inputDetail); + var entity = ObjectMapper.Map(input); - //detail.SetIdAndNumber(GuidGenerator, entity.Id, entity.Number); + var subType = Enum.Parse(input.Type); + var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Transfer, 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 SetDetailPropertiesAsync(detail, input).ConfigureAwait(false); - entity.AddDetail(detail); - } + await _transferRequestManager.CreateAsync(entity).ConfigureAwait(false); - entites.Add(entity); - } - } + var dto = ObjectMapper.Map(entity); - return (entites, deleteEntites); + return dto; } protected async Task CheckFromLocationAsync(string locationCode, List validationRresult) @@ -268,7 +284,7 @@ public class TransferRequestAppService : SfsStoreRequestAppServiceBase } protected virtual async Task CheckImportInputBusinessAsync(TransferRequestImportInput importInput, - EnumImportMethod importMethod, List validationRresult) + EnumImportMethod importMethod, List validationRresult) { ChecktQty(importInput, validationRresult); await CheckItemBasicAsync(importInput, validationRresult).ConfigureAwait(false); @@ -277,13 +293,15 @@ public class TransferRequestAppService : SfsStoreRequestAppServiceBase await CheckToLocationAsync(importInput.ToLocationCode, validationRresult).ConfigureAwait(false); } - protected async Task CheckItemBasicAsync(TransferRequestImportInput importInput, List validationRresult) + protected async Task CheckItemBasicAsync(TransferRequestImportInput importInput, + List validationRresult) { var item = await ItemBasicAclService.GetByCodeAsync(importInput.ItemCode).ConfigureAwait(false); if (item == null) { validationRresult.Add("物品代码", $"物品代码{importInput.ItemCode}不存在"); } + if (importInput.Qty <= 0) { validationRresult.Add("调整数量", $"调整数量{importInput.Qty}必须大于0"); @@ -302,103 +320,4 @@ public class TransferRequestAppService : SfsStoreRequestAppServiceBase protected void ChecktQty(TransferRequestImportInput importInput, List validationRresult) { } - - /// - /// 导入汇总 - /// - /// - protected override Func GetEntityExpression() - { - return p => 1; - } - - protected virtual async Task ImportDataAsync(List entites, List deleteEntities) - { - await _transferRequestManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false); - } - private static EnumTransSubType ConvertToTransSubType(string type) - { - switch (type) - { - case "线边仓调拨": - return EnumTransSubType.Transfer_WIP; - - case "客户储位调拨": - return EnumTransSubType.Transfer_Customer; - - case "区域内调拨": - return EnumTransSubType.Transfer_Inside; - - case "区域间调拨": - return EnumTransSubType.Transfer_Area; - - case "库间调拨": - return EnumTransSubType.Transfer_Warehouse; - } - - return EnumTransSubType.None; - } - - private static async Task SetDetailPropertiesAsync(TransferRequestDetail detail, TransferRequestImportInput input) - { - await Task.CompletedTask.ConfigureAwait(false); - //if (!string.IsNullOrEmpty(input.OnceBusiCode)) - //{ - // var dict = await _dictApp.GetByTypeAsync(nameof(input.OnceBusiCode)); - - // if (dict.Items != null && dict.Items.Count > 0) - // { - // var item = dict.Items.FirstOrDefault(t => t.Code == input.OnceBusiCode); - - // Check.NotNull(item, "次交易码", "次交易码不存在"); - - // detail.SetProperty("OnceBusiCode", item.Code); - // detail.SetProperty("OnceBusiName", item.Name); - // } - //} - - //if (!string.IsNullOrEmpty(input.CaseCode)) - //{ - // var dict = await _dictApp.GetByTypeAsync(nameof(input.CaseCode)); - - // if (dict.Items != null && dict.Items.Count > 0) - // { - // var item = dict.Items.FirstOrDefault(t => t.Code == input.CaseCode); - - // Check.NotNull(item, "专案代码", "专案代码不存在"); - - // detail.SetProperty("CaseCode", item.Code); - // detail.SetProperty("CaseName", item.Name); - // } - //} - - //if (!string.IsNullOrEmpty(input.ProjCapacityCode)) - //{ - // var dict = await _dictApp.GetByTypeAsync(nameof(input.ProjCapacityCode)); - - // if (dict.Items != null && dict.Items.Count > 0) - // { - // var item = dict.Items.FirstOrDefault(t => t.Code == input.ProjCapacityCode); - - // Check.NotNull(item, "项目分类代码", "项目分类代码不存在"); - - // detail.SetProperty("ProjCapacityCode", item.Code); - // detail.SetProperty("ProjCapacityName", item.Name); - // } - //} - } - - private async Task SetEntityPropertiesAsync(TransferRequest entity, string inputType) - { - var subType = ConvertToTransSubType(inputType); - var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Transfer, subType).ConfigureAwait(false); - entity.Type = ((int)subType).ToString(); - entity.Worker = CurrentUser.GetUserName(); - - entity.AutoCompleteJob = tranType.AutoCompleteJob; - entity.AutoSubmit = tranType.AutoSubmitRequest; - entity.AutoAgree = tranType.AutoAgreeRequest; - entity.AutoHandle = tranType.AutoHandleRequest; - entity.DirectCreateNote = tranType.DirectCreateNote; - } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/TransferNotes/TransferNote.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/TransferNotes/TransferNote.cs index a1ecf3d0a..b1cc3d1ce 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/TransferNotes/TransferNote.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/TransferNotes/TransferNote.cs @@ -28,14 +28,13 @@ public class TransferNote : SfsStoreAggregateRootBase, IHasJ /// 调拨类型 /// [Display(Name = "调拨类型")] - [IgnoreUpdate] + [Required(ErrorMessage = "调拨类型不能为空")] public string Type { get; set; } /// /// 使用中间库 /// [Display(Name = "使用中间库")] - [IgnoreUpdate] public bool UseOnTheWayLocation { get; set; } /// diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InspectJobEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InspectJobEventHandler.cs index c49520a36..3c1c4d7dd 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InspectJobEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InspectJobEventHandler.cs @@ -34,7 +34,9 @@ public class InspectJobEventHandler : [UnitOfWork] public virtual async Task HandleEventAsync(SfsCompletedEntityEventData eventData) { - var entity = eventData.Entity; + //var entity = eventData.Entity; + + await Task.CompletedTask.ConfigureAwait(false); } /// @@ -126,7 +128,7 @@ public class InspectJobEventHandler : //免检任务自动完成 并调用检验记录生成业务 if (summaryDetail?.InspectType != EnumInspectType.Exempt) { - await CompleteExemptInspectJobAsync(inspectJob, summaryDetail); + await CompleteExemptInspectJobAsync(inspectJob, summaryDetail).ConfigureAwait(false); } } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs index 2e663dca0..2fefa0657 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs @@ -1,8 +1,12 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; +using DocumentFormat.OpenXml.Bibliography; using Volo.Abp.EventBus; +using Volo.Abp.EventBus.Local; using Volo.Abp.SettingManagement; using Volo.Abp.Uow; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Store.Domain; @@ -12,18 +16,29 @@ namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest; public class TransferRequestEventHandler : StoreEventHandlerBase + , ILocalEventHandler> + , ILocalEventHandler>> , ILocalEventHandler> + //, ILocalEventHandler> + //, ILocalEventHandler> + { private readonly ITransferNoteManager _transferNoteManager; + private readonly ILocationAppService _locationAppService; + private readonly ITransferRequestManager _transferRequestManager; + protected ILocalEventBus LocalEventBus => LazyServiceProvider.LazyGetRequiredService(); public TransferRequestEventHandler( - ITransferNoteManager transferNoteManager) + ITransferNoteManager transferNoteManager, ILocationAppService locationAppService, ITransferRequestManager transferRequestManager) { _transferNoteManager = transferNoteManager; + _locationAppService = locationAppService; + _transferRequestManager = transferRequestManager; } + /// - /// 库存转移 审批通过 后 + /// 库存转移 审批通过 后 /// /// /// @@ -32,28 +47,29 @@ public class TransferRequestEventHandler public async Task HandleEventAsync(SfsHandledEntityEventData eventData) { var entity = eventData.Entity; - EnumTransSubType enumTransSubType = Enum.Parse(entity.Type); + var enumTransSubType = Enum.Parse(entity.Type); if (entity.DirectCreateNote) { var input = ObjectMapper.Map(entity); - var transferOnTheWayLocation = - await SettingManager.GetOrNullGlobalAsync(StoreSettings.Common.TransferOnTheWayLocation).ConfigureAwait(false); + //获取在途库 + var locationDto = await _locationAppService.GetFirstByTypeAsync(EnumLocationType.TRANSPORT) + .ConfigureAwait(false); - input.Details.ForEach(p => p.OnTheWayLocationCode = transferOnTheWayLocation); + var transferOnTheWayLocation = + await SettingManager.GetOrNullGlobalAsync(StoreSettings.Common.TransferOnTheWayLocation) + .ConfigureAwait(false); - // input. + input.Details.ForEach(p => { p.OnTheWayLocationCode = locationDto.Code; }); await _transferNoteManager.CreateAsync(input).ConfigureAwait(false); - } switch (enumTransSubType) { case EnumTransSubType.Transfer_Inside: case EnumTransSubType.Transfer_Area: - break; case EnumTransSubType.Transfer_Warehouse: case EnumTransSubType.Transfer_Customer: @@ -63,4 +79,67 @@ public class TransferRequestEventHandler break; } } + + /// + /// 库移创建后 + /// + /// Event data + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData eventData) + { + var entity = eventData.Entity; + if (entity.AutoSubmit) + { + await _transferRequestManager.SubmitAsync(entity).ConfigureAwait(false); + } + } + + /// + /// 库移批量创建后 + /// + /// Event data + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + var entitys = eventData.Entity; + foreach (var entity in entitys) + { + if (entity.AutoSubmit) + { + await _transferRequestManager.SubmitAsync(entity).ConfigureAwait(false); + } + } + } + + ///// + ///// 提交后 + ///// + ///// Event data + //[UnitOfWork] + //public virtual async Task HandleEventAsync(SfsSubmittedEntityEventData eventData) + //{ + // var entity = eventData.Entity; + // if (entity.AutoAgree) + // { + // entity.Agree(); + // await LocalEventBus.PublishAsync(new SfsAgreedEntityEventData(entity), false) + // .ConfigureAwait(false); + // } + //} + + ///// + ///// 审批后 + ///// + ///// Event data + //[UnitOfWork] + //public virtual async Task HandleEventAsync(SfsAgreedEntityEventData eventData) + //{ + // var entity = eventData.Entity; + // if (entity.AutoHandle) + // { + // entity.Handle(); + // await LocalEventBus.PublishAsync(new SfsHandledEntityEventData(entity), false) + // .ConfigureAwait(false); + // } + //} } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/TransferNoteEventHandler.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/TransferNoteEventHandler.cs index 581325a77..c221e9cb0 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/TransferNoteEventHandler.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/TransferNoteEventHandler.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.EventBus; using Volo.Abp.Uow; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Wms.Inventory.Application.Contracts; @@ -16,13 +17,16 @@ public class TransferNoteEventHandler : StoreInventoryEventHandlerBase , ILocalEventHandler> , ILocalEventHandler> + , ILocalEventHandler>> { private const EnumTransType TransType = EnumTransType.Transfer; - private readonly ITransferRequestAppService _transferRequestApp; + private readonly ILocationAppService _locationAppService; + private readonly ITransferLogAppService _transferLogAppService; - public TransferNoteEventHandler(ITransferRequestAppService transferRequestApp) + public TransferNoteEventHandler(ITransferRequestAppService transferRequestApp, ILocationAppService locationAppService, ITransferLogAppService transferLogAppService) { - _transferRequestApp = transferRequestApp; + _locationAppService = locationAppService; + _transferLogAppService = transferLogAppService; } /// @@ -43,6 +47,25 @@ public class TransferNoteEventHandler await AddTransferLogsAsync(inputList).ConfigureAwait(false); } + /// + /// 批量创建 后 + /// + /// + /// + [UnitOfWork] + public virtual async Task HandleEventAsync(SfsCreatedEntityEventData> eventData) + { + foreach (var entity in eventData.Entity) + { + var route = entity.UseOnTheWayLocation + ? EnumTransferRoute.SourceToOnTheWay + : EnumTransferRoute.SourceToDestination; + + var inputList = await BuildTransferLogsAsync(entity, route).ConfigureAwait(false); + await AddTransferLogsAsync(inputList).ConfigureAwait(false); + } + } + /// /// 确认 后 /// @@ -63,7 +86,7 @@ public class TransferNoteEventHandler transferLogs.AddRange(inputList); - await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); + await _transferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false); } @@ -83,9 +106,9 @@ public class TransferNoteEventHandler if (note.UseOnTheWayLocation) { - var fromLocation = await LocationAclService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); - var toLocation = await LocationAclService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); - var transferOnTheWay = await LocationAclService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); + var fromLocation = await _locationAppService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); + var toLocation = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); + var transferOnTheWay = await _locationAppService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false); switch (route) {