|
|
@ -3,11 +3,11 @@ using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Volo.Abp; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
using Win_in.Sfs.Label.Application.Contracts; |
|
|
|
using Win_in.Sfs.Shared.Application.Contracts; |
|
|
|
using Win_in.Sfs.Shared.Domain; |
|
|
@ -20,12 +20,14 @@ using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
|
namespace Win_in.Sfs.Wms.Store.Application; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 回收料调整申请
|
|
|
|
/// 回收料调整申请
|
|
|
|
/// </summary>
|
|
|
|
[Authorize] |
|
|
|
[Route($"{StoreConsts.RootPath}item-transform-request")] |
|
|
|
public class ItemTransformRequestAppService : |
|
|
|
SfsStoreRequestAppServiceBase<ItemTransformRequest, ItemTransformRequestDTO, SfsStoreRequestInputBase, ItemTransformRequestEditInput, ItemTransformRequestDetail, ItemTransformRequestDetailDTO, SfsStoreRequestInputBase, ItemTransformRequestImportInput>, |
|
|
|
SfsStoreRequestAppServiceBase<ItemTransformRequest, ItemTransformRequestDTO, SfsStoreRequestInputBase, |
|
|
|
ItemTransformRequestEditInput, ItemTransformRequestDetail, ItemTransformRequestDetailDTO, |
|
|
|
SfsStoreRequestInputBase, ItemTransformRequestImportInput>, |
|
|
|
IItemTransformRequestAppService |
|
|
|
{ |
|
|
|
private const EnumTransSubType SubType = EnumTransSubType.Item_Transform; |
|
|
@ -45,25 +47,12 @@ public class ItemTransformRequestAppService : |
|
|
|
_balanceAppService = balanceAppService; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 新增方法
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("")] |
|
|
|
|
|
|
|
public override async Task<ItemTransformRequestDTO> CreateAsync(ItemTransformRequestEditInput input) |
|
|
|
{ |
|
|
|
var entity = ObjectMapper.Map<ItemTransformRequestEditInput, ItemTransformRequest>(input); |
|
|
|
|
|
|
|
await _manager.CreateAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dto = ObjectMapper.Map<ItemTransformRequest, ItemTransformRequestDTO>(entity); |
|
|
|
|
|
|
|
|
|
|
|
return dto; |
|
|
|
} |
|
|
|
#region 东阳
|
|
|
|
|
|
|
|
protected override async Task<Dictionary<ItemTransformRequest, EntityState>> ImportProcessingEntityAsync(Dictionary<ItemTransformRequest, EntityState> dictionary) |
|
|
|
protected override async Task<Dictionary<ItemTransformRequest, EntityState>> ImportProcessingEntityAsync( |
|
|
|
Dictionary<ItemTransformRequest, EntityState> dictionary) |
|
|
|
{ |
|
|
|
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); |
|
|
|
|
|
|
@ -73,13 +62,27 @@ public class ItemTransformRequestAppService : |
|
|
|
itemTransformRequest.CreatorId = CurrentUser.Id; |
|
|
|
foreach (var detail in itemTransformRequest.Details) |
|
|
|
{ |
|
|
|
var fromLocationDto= await LocationAclService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); |
|
|
|
var toLocationDto= await LocationAclService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); |
|
|
|
var fromItemBasicDto=await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
var fromLocationDto = |
|
|
|
await LocationAclService.GetByCodeAsync(detail.FromLocationCode).ConfigureAwait(false); |
|
|
|
CheckLocation(fromLocationDto, detail.FromLocationCode); |
|
|
|
|
|
|
|
var toLocationDto = |
|
|
|
await LocationAclService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); |
|
|
|
CheckLocation(toLocationDto, detail.ToLocationCode); |
|
|
|
|
|
|
|
var fromItemBasicDto = await ItemBasicAclService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
CheckItemBasic(fromItemBasicDto, detail.ItemCode); |
|
|
|
|
|
|
|
var toItemBasicDto = await ItemBasicAclService.GetByCodeAsync(detail.ToItemCode).ConfigureAwait(false); |
|
|
|
var balanceDto= await _balanceAppService.GetByItemLocationAndPackingAsync(detail.FromPackingCode, detail.ItemCode, |
|
|
|
CheckItemBasic(toItemBasicDto, detail.ToItemCode); |
|
|
|
|
|
|
|
var balanceDto = await _balanceAppService.GetByItemLocationAndPackingAsync(detail.FromPackingCode, |
|
|
|
detail.ItemCode, |
|
|
|
detail.FromLocationCode).ConfigureAwait(false); |
|
|
|
var inventoryLabelDto= await _inventoryLabelAppService.GetByCodeAsync(detail.ToPackingCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
var inventoryLabelDto = await _inventoryLabelAppService.GetByCodeAsync(detail.ToPackingCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
CheckLabel(inventoryLabelDto, detail); |
|
|
|
|
|
|
|
detail.FromLocationArea = fromLocationDto.AreaCode; |
|
|
|
detail.FromLocationErpCode = fromLocationDto.ErpLocationCode; |
|
|
@ -100,8 +103,8 @@ public class ItemTransformRequestAppService : |
|
|
|
detail.ToWarehouseCode = toLocationDto.WarehouseCode; |
|
|
|
|
|
|
|
detail.ItemDesc1 = fromItemBasicDto.Desc1; |
|
|
|
detail.ItemDesc2= fromItemBasicDto.Desc2; |
|
|
|
detail.ItemName= fromItemBasicDto.Name; |
|
|
|
detail.ItemDesc2 = fromItemBasicDto.Desc2; |
|
|
|
detail.ItemName = fromItemBasicDto.Name; |
|
|
|
detail.Uom = fromItemBasicDto.BasicUom; |
|
|
|
|
|
|
|
detail.ToItemCode = toItemBasicDto.Code; |
|
|
@ -112,11 +115,58 @@ public class ItemTransformRequestAppService : |
|
|
|
} |
|
|
|
|
|
|
|
return dictionary; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#region 校验
|
|
|
|
|
|
|
|
private void CheckLabel(InventoryLabelDto inventoryLabelDto, ItemTransformRequestDetail detail) |
|
|
|
{ |
|
|
|
if (inventoryLabelDto == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"标签箱码为【{detail.ToPackingCode}】不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void CheckItemBasic(ItemBasicDTO ItemBasicDto, string itemCode) |
|
|
|
{ |
|
|
|
if (ItemBasicDto == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"物品代码为【{itemCode}】不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void CheckLocation(LocationDTO LocationDto, string LocationCode) |
|
|
|
{ |
|
|
|
if (LocationDto == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"库位代码为【{LocationCode}】不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 新增方法
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("")] |
|
|
|
public override async Task<ItemTransformRequestDTO> CreateAsync(ItemTransformRequestEditInput input) |
|
|
|
{ |
|
|
|
var entity = ObjectMapper.Map<ItemTransformRequestEditInput, ItemTransformRequest>(input); |
|
|
|
|
|
|
|
await _manager.CreateAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dto = ObjectMapper.Map<ItemTransformRequest, ItemTransformRequestDTO>(entity); |
|
|
|
|
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task ImportDataAsync(List<ItemTransformRequest> entites, List<ItemTransformRequest> deleteEntities) |
|
|
|
protected virtual async Task ImportDataAsync(List<ItemTransformRequest> entites, |
|
|
|
List<ItemTransformRequest> deleteEntities) |
|
|
|
{ |
|
|
|
await _manager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false); |
|
|
|
} |
|
|
@ -126,7 +176,9 @@ public class ItemTransformRequestAppService : |
|
|
|
return t => t.Worker; |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task<(List<ItemTransformRequest> entites, List<ItemTransformRequest> deleteEntities)> BuildImportDataAsync(ImportResult<ItemTransformRequestImportInput> importResult, EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false) |
|
|
|
protected virtual async Task<(List<ItemTransformRequest> entites, List<ItemTransformRequest> deleteEntities)> |
|
|
|
BuildImportDataAsync(ImportResult<ItemTransformRequestImportInput> importResult, |
|
|
|
EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false) |
|
|
|
{ |
|
|
|
if (importResult.Data.Any(t => t.ReportStatus == EnumImportReportStatus.Failed)) |
|
|
|
{ |
|
|
@ -167,18 +219,21 @@ public class ItemTransformRequestAppService : |
|
|
|
{ |
|
|
|
entity.SetId(exist.Id); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
case EnumImportMethod.Replace: |
|
|
|
if (exist != null) |
|
|
|
{ |
|
|
|
deleteEntites.Add(exist); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var inputDetail in inputDetails) |
|
|
|
{ |
|
|
|
var detail = ObjectMapper.Map<ItemTransformRequestImportInput, ItemTransformRequestDetail>(inputDetail); |
|
|
|
var detail = |
|
|
|
ObjectMapper.Map<ItemTransformRequestImportInput, ItemTransformRequestDetail>(inputDetail); |
|
|
|
|
|
|
|
await SetDetailPropertiesAsync(detail, input).ConfigureAwait(false); |
|
|
|
entity.AddDetail(detail); |
|
|
@ -191,7 +246,8 @@ public class ItemTransformRequestAppService : |
|
|
|
return (entites, deleteEntites); |
|
|
|
} |
|
|
|
|
|
|
|
private async Task SetDetailPropertiesAsync(ItemTransformRequestDetail detail, ItemTransformRequestImportInput input) |
|
|
|
private async Task SetDetailPropertiesAsync(ItemTransformRequestDetail detail, |
|
|
|
ItemTransformRequestImportInput input) |
|
|
|
{ |
|
|
|
var balanceDTO = await BalanceAclService.GetByPackingCodeAsync(detail.FromPackingCode).ConfigureAwait(false); |
|
|
|
var toItemBasicDTO = await ItemBasicAclService.GetByCodeAsync(detail.ToItemCode).ConfigureAwait(false); |
|
|
@ -223,7 +279,8 @@ public class ItemTransformRequestAppService : |
|
|
|
|
|
|
|
private async Task SetEntityPropertiesAsync(ItemTransformRequest entity, ItemTransformRequestImportInput input) |
|
|
|
{ |
|
|
|
var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Adjust, SubType).ConfigureAwait(false); |
|
|
|
var tranType = await TransactionTypeAclService.GetByTransTypeAsync(EnumTransType.Adjust, SubType) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
Check.NotNull(tranType, "事务类型", "事务类型不存在"); |
|
|
|
|
|
|
@ -234,7 +291,8 @@ public class ItemTransformRequestAppService : |
|
|
|
entity.DirectCreateNote = tranType.DirectCreateNote; |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task CheckImportInputBusinessAsync(ItemTransformRequestImportInput importInput, EnumImportMethod importMethod, List<ValidationResult> validationRresult) |
|
|
|
protected virtual async Task CheckImportInputBusinessAsync(ItemTransformRequestImportInput importInput, |
|
|
|
EnumImportMethod importMethod, List<ValidationResult> validationRresult) |
|
|
|
{ |
|
|
|
//await base.CheckImportInputBusinessAsync(importInput, importMethod);
|
|
|
|
|
|
|
@ -298,15 +356,16 @@ public class ItemTransformRequestAppService : |
|
|
|
var label = await _inventoryLabelAppService.GetByCodeAsync(packingCode).ConfigureAwait(false); |
|
|
|
if (label != null) |
|
|
|
{ |
|
|
|
var inventory = await BalanceAclService.GetListByPackingCodesAsync(new List<string> { packingCode }).ConfigureAwait(false); |
|
|
|
var inventory = await BalanceAclService.GetListByPackingCodesAsync(new List<string> { packingCode }) |
|
|
|
.ConfigureAwait(false); |
|
|
|
if (inventory.Count > 0) |
|
|
|
{ |
|
|
|
validationRresult.Add("库存余额已存在", $"库存余额已存在,请重新打印标签并导入。"); |
|
|
|
validationRresult.Add("库存余额已存在", "库存余额已存在,请重新打印标签并导入。"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
validationRresult.Add("标签不存在", $"标签不存在,请重新打印标签并导入。"); |
|
|
|
validationRresult.Add("标签不存在", "标签不存在,请重新打印标签并导入。"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|