|
@ -5,6 +5,7 @@ using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp; |
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
using Win_in.Sfs.Shared.Domain; |
|
|
using Win_in.Sfs.Shared.Domain; |
|
@ -17,6 +18,7 @@ namespace Win_in.Sfs.Wms.Store.Application; |
|
|
|
|
|
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
using System.ComponentModel.DataAnnotations; |
|
|
using Volo.Abp.Data; |
|
|
using Volo.Abp.Data; |
|
|
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Win_in.Sfs.Shared.Application.Contracts; |
|
|
using Win_in.Sfs.Shared.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
|
|
|
|
|
@ -27,23 +29,32 @@ using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
[Route($"{StoreConsts.RootPath}product-recycle-request")] |
|
|
[Route($"{StoreConsts.RootPath}product-recycle-request")] |
|
|
|
|
|
|
|
|
public class ProductRecycleRequestAppService : |
|
|
public class ProductRecycleRequestAppService : |
|
|
SfsStoreRequestAppServiceBase<ProductRecycleRequest, ProductRecycleRequestDTO, SfsStoreRequestInputBase, ProductRecycleRequestEditInput, ProductRecycleRequestDetail, ProductRecycleRequestDetailDTO, SfsStoreRequestInputBase, ProductRecycleRequestImportInput>, |
|
|
SfsStoreRequestAppServiceBase<ProductRecycleRequest, ProductRecycleRequestDTO, |
|
|
|
|
|
SfsStoreRequestInputBase, ProductRecycleRequestEditInput |
|
|
|
|
|
, ProductRecycleRequestDetail, ProductRecycleRequestDetailDTO, SfsStoreRequestInputBase, ProductRecycleRequestImportInput>, |
|
|
IProductRecycleRequestAppService |
|
|
IProductRecycleRequestAppService |
|
|
{ |
|
|
{ |
|
|
private readonly IProductRecycleRequestManager _productRecycleRequestManager; |
|
|
private readonly IProductRecycleRequestManager _productRecycleRequestManager; |
|
|
private readonly IBomAppService _bomApp; |
|
|
private readonly IBomAppService _bomApp; |
|
|
private readonly IItemStoreRelationAppService _itemStoreRelationApp; |
|
|
private readonly IItemStoreRelationAppService _itemStoreRelationApp; |
|
|
|
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
|
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
|
|
private readonly ITransactionTypeAppService _transactionTypeAppService; |
|
|
|
|
|
|
|
|
public ProductRecycleRequestAppService( |
|
|
public ProductRecycleRequestAppService( |
|
|
IProductRecycleRequestRepository repository, |
|
|
IProductRecycleRequestRepository repository, |
|
|
IProductRecycleRequestManager productRecycleRequestManager, |
|
|
IProductRecycleRequestManager productRecycleRequestManager, |
|
|
IBomAppService bomApp, |
|
|
IBomAppService bomApp, |
|
|
IItemStoreRelationAppService itemStoreRelationApp) |
|
|
IItemStoreRelationAppService itemStoreRelationApp, ILocationAppService locationAppService, IBalanceAppService balanceAppService, ITransactionTypeAppService transactionTypeAppService) |
|
|
: base(repository, productRecycleRequestManager) |
|
|
: base(repository, productRecycleRequestManager) |
|
|
{ |
|
|
{ |
|
|
_productRecycleRequestManager = productRecycleRequestManager; |
|
|
_productRecycleRequestManager = productRecycleRequestManager; |
|
|
_bomApp = bomApp; |
|
|
_bomApp = bomApp; |
|
|
_itemStoreRelationApp = itemStoreRelationApp; |
|
|
_itemStoreRelationApp = itemStoreRelationApp; |
|
|
|
|
|
_locationAppService = locationAppService; |
|
|
|
|
|
_balanceAppService = balanceAppService; |
|
|
|
|
|
_transactionTypeAppService = transactionTypeAppService; |
|
|
|
|
|
|
|
|
base.CreatePolicyName = ProductRecycleRequestPermissions.Create; |
|
|
base.CreatePolicyName = ProductRecycleRequestPermissions.Create; |
|
|
base.UpdatePolicyName = ProductRecycleRequestPermissions.Update; |
|
|
base.UpdatePolicyName = ProductRecycleRequestPermissions.Update; |
|
@ -75,6 +86,100 @@ public class ProductRecycleRequestAppService : |
|
|
throw new NotImplementedException(); |
|
|
throw new NotImplementedException(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 东阳
|
|
|
|
|
|
|
|
|
|
|
|
protected override async Task<Dictionary<ProductRecycleRequest, EntityState>> ImportProcessingEntityAsync(Dictionary<ProductRecycleRequest, EntityState> dictionary) |
|
|
|
|
|
{ |
|
|
|
|
|
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var productRecycleRequest in addList) |
|
|
|
|
|
{ |
|
|
|
|
|
await SetRequestAutoPropertiesAsync(productRecycleRequest) |
|
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
productRecycleRequest.Worker = CurrentUser.GetUserName(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (var detail in productRecycleRequest.Details) |
|
|
|
|
|
{ |
|
|
|
|
|
var balance = await _balanceAppService.GetByItemLocationAndPackingAsync( |
|
|
|
|
|
string.Empty, |
|
|
|
|
|
detail.ItemCode, |
|
|
|
|
|
detail.LocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (balance != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.Status = balance.Status; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var locationDto = await _locationAppService.GetByCodeAsync(detail.LocationCode) |
|
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
await SetDetailPropertiesAsync(detail).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return dictionary; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task SetRequestAutoPropertiesAsync(ProductRecycleRequest entity) |
|
|
|
|
|
{ |
|
|
|
|
|
var tranType = await _transactionTypeAppService.GetByTransTypeAsync(EnumTransType.ProductRecycle, EnumTransSubType.None).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
Check.NotNull(tranType, "事务类型", "事务类型不存在"); |
|
|
|
|
|
|
|
|
|
|
|
entity.AutoCompleteJob = tranType.AutoCompleteJob; |
|
|
|
|
|
entity.AutoSubmit = tranType.AutoSubmitRequest; |
|
|
|
|
|
entity.AutoAgree = tranType.AutoAgreeRequest; |
|
|
|
|
|
entity.AutoHandle = tranType.AutoHandleRequest; |
|
|
|
|
|
entity.DirectCreateNote = tranType.DirectCreateNote; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task SetDetailPropertiesAsync( |
|
|
|
|
|
ProductRecycleRequestDetail detail) |
|
|
|
|
|
{ |
|
|
|
|
|
var item = await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (item != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.ItemName = item.Name; |
|
|
|
|
|
detail.ItemDesc1 = item.Desc1; |
|
|
|
|
|
detail.ItemDesc2 = item.Desc2; |
|
|
|
|
|
detail.Uom = item.BasicUom; |
|
|
|
|
|
detail.Qty = detail.Qty; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var location = await LocationAclService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (location != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.LocationErpCode = location.ErpLocationCode; |
|
|
|
|
|
detail.WarehouseCode = location.WarehouseCode; |
|
|
|
|
|
detail.LocationGroup = location.LocationGroupCode; |
|
|
|
|
|
detail.LocationArea = location.AreaCode; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var rawLocation = await LocationAclService.GetByCodeAsync(detail.RawLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (rawLocation != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.RawLocationErpCode = rawLocation.ErpLocationCode; |
|
|
|
|
|
detail.RawWarehouseCode = rawLocation.WarehouseCode; |
|
|
|
|
|
detail.RawLocationArea = rawLocation.AreaCode; |
|
|
|
|
|
detail.RawLocationGroup = rawLocation.LocationGroupCode; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var balance = await BalanceAclService.GetByItemLocationAndPackingAsync( |
|
|
|
|
|
string.Empty, |
|
|
|
|
|
detail.ItemCode, |
|
|
|
|
|
detail.LocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (balance != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.Status = balance.Status; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region Import
|
|
|
#region Import
|
|
|
|
|
|
|
|
|
protected virtual async Task CheckImportInputBusinessAsync(ProductRecycleRequestImportInput importInput, EnumImportMethod importMethod, List<ValidationResult> validationRresult) |
|
|
protected virtual async Task CheckImportInputBusinessAsync(ProductRecycleRequestImportInput importInput, EnumImportMethod importMethod, List<ValidationResult> validationRresult) |
|
@ -202,147 +307,6 @@ public class ProductRecycleRequestAppService : |
|
|
return boms; |
|
|
return boms; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected virtual async Task ImportDataAsync(List<ProductRecycleRequest> entites, List<ProductRecycleRequest> deleteEntities) |
|
|
|
|
|
{ |
|
|
|
|
|
await _productRecycleRequestManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override Func<ProductRecycleRequestImportInput, object> GetEntityExpression() |
|
|
|
|
|
{ |
|
|
|
|
|
return p => 1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual async Task<(List<ProductRecycleRequest> entites, List<ProductRecycleRequest> deleteEntities)> BuildImportDataAsync(ImportResult<ProductRecycleRequestImportInput> importResult, EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false) |
|
|
|
|
|
{ |
|
|
|
|
|
if (importResult.Data.Any(t => t.ReportStatus == EnumImportReportStatus.Failed)) |
|
|
|
|
|
{ |
|
|
|
|
|
if (!isAllowPartImport) |
|
|
|
|
|
{ |
|
|
|
|
|
return (null, null); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entites = new List<ProductRecycleRequest>(); |
|
|
|
|
|
|
|
|
|
|
|
var details = new List<ProductRecycleRequestDetail>(); |
|
|
|
|
|
|
|
|
|
|
|
var deleteEntites = new List<ProductRecycleRequest>(); |
|
|
|
|
|
|
|
|
|
|
|
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<ProductRecycleRequestImportInput, ProductRecycleRequest>(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<ProductRecycleRequestImportInput, ProductRecycleRequestDetail>(inputDetail); |
|
|
|
|
|
|
|
|
|
|
|
detail.SetIdAndNumber(GuidGenerator, entity.Id, entity.Number); |
|
|
|
|
|
|
|
|
|
|
|
await SetDetailPropertiesAsync(detail, input).ConfigureAwait(false); |
|
|
|
|
|
entity.AddDetail(detail); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
entites.Add(entity); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return (entites, deleteEntites); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task SetDetailPropertiesAsync( |
|
|
|
|
|
ProductRecycleRequestDetail detail, |
|
|
|
|
|
ProductRecycleRequestImportInput input) |
|
|
|
|
|
{ |
|
|
|
|
|
var item = await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (item != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.ItemName = item.Name; |
|
|
|
|
|
detail.ItemDesc1 = item.Desc1; |
|
|
|
|
|
detail.ItemDesc2 = item.Desc2; |
|
|
|
|
|
detail.Qty = input.Qty; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var location = await LocationAclService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (location != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.LocationErpCode = location.ErpLocationCode; |
|
|
|
|
|
detail.WarehouseCode = location.WarehouseCode; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var rawLocation = await LocationAclService.GetByCodeAsync(detail.RawLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (rawLocation != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.RawLocationErpCode = rawLocation.ErpLocationCode; |
|
|
|
|
|
detail.RawWarehouseCode = rawLocation.WarehouseCode; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var balance = await BalanceAclService.GetByItemLocationAndPackingAsync( |
|
|
|
|
|
string.Empty, |
|
|
|
|
|
detail.ItemCode, |
|
|
|
|
|
input.LocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
if (balance != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detail.Status = balance.Status; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
detail.SetProperty(nameof(input.PreStartTime), input.PreStartTime); |
|
|
|
|
|
detail.SetProperty(nameof(input.WorkHour), input.WorkHour); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task SetEntityPropertiesAsync(ProductRecycleRequest entity, ProductRecycleRequestImportInput input) |
|
|
|
|
|
{ |
|
|
|
|
|
entity.Worker = CurrentUser.GetUserName(); |
|
|
|
|
|
|
|
|
|
|
|
await SetRequestAutoPropertiesAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task SetRequestAutoPropertiesAsync(ProductRecycleRequest entity) |
|
|
|
|
|
{ |
|
|
|
|
|
var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.ProductRecycle, EnumTransSubType.None).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
Check.NotNull(tranType, "事务类型", "事务类型不存在"); |
|
|
|
|
|
|
|
|
|
|
|
entity.AutoCompleteJob = tranType.AutoCompleteJob; |
|
|
|
|
|
entity.AutoSubmit = tranType.AutoSubmitRequest; |
|
|
|
|
|
entity.AutoAgree = tranType.AutoAgreeRequest; |
|
|
|
|
|
entity.AutoHandle = tranType.AutoHandleRequest; |
|
|
|
|
|
entity.DirectCreateNote = tranType.DirectCreateNote; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|