|
|
@ -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; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 调拨转移记录
|
|
|
|
/// 调拨转移记录
|
|
|
|
/// </summary>
|
|
|
|
[Authorize] |
|
|
|
[Route($"{StoreConsts.RootPath}transfer-note")] |
|
|
|
|
|
|
|
public class TransferNoteAppService : SfsStoreWithDetailsAppServiceBase |
|
|
|
<TransferNote, TransferNoteDTO, SfsStoreRequestInputBase, TransferNoteEditInput, TransferNoteDetail, TransferNoteDetailDTO, SfsStoreRequestInputBase, TransferNoteImportInput>, |
|
|
|
<TransferNote, TransferNoteDTO, SfsStoreRequestInputBase, TransferNoteEditInput, TransferNoteDetail, |
|
|
|
TransferNoteDetailDTO, SfsStoreRequestInputBase, TransferNoteImportInput>, |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 库存转移
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("")] |
|
|
|
public override async Task<TransferNoteDTO> CreateAsync(TransferNoteEditInput input) |
|
|
|
{ |
|
|
|
var entity = ObjectMapper.Map<TransferNoteEditInput, TransferNote>(input); |
|
|
|
|
|
|
|
await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dto = ObjectMapper.Map<TransferNote, TransferNoteDTO>(entity); |
|
|
|
|
|
|
|
return dto; |
|
|
|
} |
|
|
|
#region 东阳使用
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 【批量】 库存转移
|
|
|
|
/// 用来重写 导入数据时可以加工数据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <param name="dictionary"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("create-many")] |
|
|
|
public async Task<List<TransferNoteDTO>> CreateManyAsync(List<TransferNoteEditInput> input) |
|
|
|
protected override async Task<Dictionary<TransferNote, EntityState>> ImportProcessingEntityAsync( |
|
|
|
Dictionary<TransferNote, EntityState> dictionary) |
|
|
|
{ |
|
|
|
var entitys = ObjectMapper.Map<List<TransferNoteEditInput>, List<TransferNote>>(input); |
|
|
|
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); |
|
|
|
|
|
|
|
var resultEntity = new List<TransferNote>(); |
|
|
|
|
|
|
|
foreach (var entity in entitys) |
|
|
|
foreach (var transferNote in addList) |
|
|
|
{ |
|
|
|
resultEntity.Add(await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false)); |
|
|
|
_ = ObjectMapper.Map<TransferNote, TransferNoteDTO>(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<TransferNote>, List<TransferNoteDTO>>(resultEntity); |
|
|
|
return dictionary; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 确认对应的记录单
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[HttpPost("confirm/{id}")] |
|
|
|
|
|
|
|
public virtual async Task<TransferNoteDTO> ConfirmAsync(Guid id) |
|
|
|
{ |
|
|
|
var entity = await _transferNoteManager.ConfirmAsync(id).ConfigureAwait(false); |
|
|
|
var dto = ObjectMapper.Map<TransferNote, TransferNoteDTO>(entity); |
|
|
|
return dto; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 按条件获取线边调拨的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// 按条件获取线边调拨的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sfsRequestDTO"></param>
|
|
|
|
/// <param name="includeDetails"></param>
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("get-wip-list")] |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> GetWipTransferListAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> 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); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 按条件获取储位间调拨的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// 按条件获取储位间调拨的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sfsRequestDTO"></param>
|
|
|
|
/// <param name="includeDetails"></param>
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("get-erp-loc-list")] |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> GetAreaTransferListAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> 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); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 按条件获取储位间调拨的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// 按条件获取储位内移库的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sfsRequestDTO"></param>
|
|
|
|
/// <param name="includeDetails"></param>
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("get-inside-list")] |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> GetInsideTransferListAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> 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); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 按条件获取客户储位间调拨的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// 按条件获取客户储位间调拨的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sfsRequestDTO"></param>
|
|
|
|
/// <param name="includeDetails"></param>
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("get-custom-loc-list")] |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> GetCustomerTransferListAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> 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); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 按条件获取储位间调拨的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// 按条件获取储位间调拨的分页列表
|
|
|
|
/// request sample
|
|
|
|
/// {
|
|
|
|
/// "maxResultCount": 1000,
|
|
|
|
/// "skipCount": 0,
|
|
|
|
/// "sorting": "",
|
|
|
|
/// "condition": { "filters": []}
|
|
|
|
/// }
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="sfsRequestDTO"></param>
|
|
|
|
/// <param name="includeDetails"></param>
|
|
|
|
/// <param name="cancellationToken"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("get-diff-erp-loc-list")] |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> GetListForDiffERPLocAsync(SfsStoreRequestInputBase sfsRequestDTO, bool includeDetails = false, |
|
|
|
public virtual async Task<PagedResultDto<TransferNoteDTO>> 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<PagedResultDto<TransferNoteDTO>> GetSubTypeListAsync(SfsStoreRequestInputBase sfsRequestDTO, EnumTransSubType type, bool includeDetails = false, |
|
|
|
CancellationToken cancellationToken = default) |
|
|
|
private async Task<PagedResultDto<TransferNoteDTO>> 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<Func<TransferNote, bool>> expression = sfsRequestDTO.Condition.Filters?.Count > 0 |
|
|
|
var expression = sfsRequestDTO.Condition.Filters?.Count > 0 |
|
|
|
? sfsRequestDTO.Condition.Filters.ToLambda<TransferNote>() |
|
|
|
: 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<TransferNote> entites, List<TransferNote> deleteEntities) |
|
|
|
{ |
|
|
|
await _transferNoteManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
protected override Func<TransferNoteImportInput, object> GetEntityExpression() |
|
|
|
{ |
|
|
|
return p => (1); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task<(List<TransferNote> entites, List<TransferNote> deleteEntities)> BuildImportDataAsync(ImportResult<TransferNoteImportInput> importResult, EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false) |
|
|
|
/// <summary>
|
|
|
|
/// 库存转移
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("")] |
|
|
|
public override async Task<TransferNoteDTO> CreateAsync(TransferNoteEditInput input) |
|
|
|
{ |
|
|
|
if (importResult.Data.Any(t => t.ReportStatus == EnumImportReportStatus.Failed)) |
|
|
|
{ |
|
|
|
if (!isAllowPartImport) |
|
|
|
{ |
|
|
|
return (null, null); |
|
|
|
} |
|
|
|
} |
|
|
|
var entity = ObjectMapper.Map<TransferNoteEditInput, TransferNote>(input); |
|
|
|
|
|
|
|
var entites = new List<TransferNote>(); |
|
|
|
entity=await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
var details = new List<TransferNoteDetail>(); |
|
|
|
var dto = ObjectMapper.Map<TransferNote, TransferNoteDTO>(entity); |
|
|
|
|
|
|
|
var deleteEntites = new List<TransferNote>(); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
var entityExpression = GetEntityExpression(); |
|
|
|
/// <summary>
|
|
|
|
/// 【批量】 库存转移
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("create-many")] |
|
|
|
public async Task<List<TransferNoteDTO>> CreateManyAsync(List<TransferNoteEditInput> input) |
|
|
|
{ |
|
|
|
var entitys = ObjectMapper.Map<List<TransferNoteEditInput>, List<TransferNote>>(input); |
|
|
|
|
|
|
|
var groupList = importResult.Data.ToList().GroupBy(entityExpression).Distinct().ToList(); |
|
|
|
var resultEntity = new List<TransferNote>(); |
|
|
|
|
|
|
|
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<TransferNoteImportInput, TransferNote>(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<TransferNoteImportInput, TransferNoteDetail>(inputDetail); |
|
|
|
await SetDetailPropertiesAsync(detail, input).ConfigureAwait(false); |
|
|
|
entity.AddDetail(detail); |
|
|
|
} |
|
|
|
|
|
|
|
entites.Add(entity); |
|
|
|
resultEntity.Add(await _transferNoteManager.CreateAsync(entity).ConfigureAwait(false)); |
|
|
|
_ = ObjectMapper.Map<TransferNote, TransferNoteDTO>(entity); |
|
|
|
} |
|
|
|
|
|
|
|
return (entites, deleteEntites); |
|
|
|
} |
|
|
|
|
|
|
|
private static async Task SetDetailPropertiesAsync(TransferNoteDetail detail, TransferNoteImportInput input) |
|
|
|
{ |
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
|
|
|
|
return ObjectMapper.Map<List<TransferNote>, List<TransferNoteDTO>>(resultEntity); |
|
|
|
} |
|
|
|
|
|
|
|
private static async Task SetEntityPropertiesAsync(TransferNote entity, TransferNoteImportInput input) |
|
|
|
/// <summary>
|
|
|
|
/// 确认对应的记录单
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("confirm/{id}")] |
|
|
|
public virtual async Task<TransferNoteDTO> 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<TransferNote, TransferNoteDTO>(entity); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|