|
|
@ -1,12 +1,13 @@ |
|
|
|
using System; |
|
|
|
using System.Reflection; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
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; |
|
|
@ -16,19 +17,26 @@ namespace Win_in.Sfs.Wms.Store.Application; |
|
|
|
|
|
|
|
[Authorize] |
|
|
|
[Route($"{StoreConsts.RootPath}transfer-lib-job")] |
|
|
|
|
|
|
|
public class TransferLibJobAppService |
|
|
|
: SfsJobAppServiceBase<TransferLibJob, TransferLibJobDetail, TransferLibJobDTO, SfsJobRequestInputBase, TransferLibJobCheckInput, TransferLibJobEditInput>, |
|
|
|
: SfsJobAppServiceBase<TransferLibJob, TransferLibJobDetail, TransferLibJobDTO, SfsJobRequestInputBase, |
|
|
|
TransferLibJobCheckInput, TransferLibJobEditInput>, |
|
|
|
ITransferLibJobAppService |
|
|
|
{ |
|
|
|
private readonly IServiceProvider _serviceProvider; |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
private readonly IExpectOutAppService _expectOutAppService; |
|
|
|
|
|
|
|
protected ITransferLibRequestAppService TransferLibRequestAppService => |
|
|
|
LazyServiceProvider.LazyGetRequiredService<ITransferLibRequestAppService>(); |
|
|
|
|
|
|
|
public TransferLibJobAppService( |
|
|
|
ITransferLibJobRepository repository, ITransferLibJobManager TransferLibJobManager, IServiceProvider serviceProvider, ILocationAppService locationAppService) : base(repository, TransferLibJobManager) |
|
|
|
ITransferLibJobRepository repository, ITransferLibJobManager TransferLibJobManager, |
|
|
|
IServiceProvider serviceProvider, ILocationAppService locationAppService, IExpectOutAppService expectOutAppService) : base(repository, |
|
|
|
TransferLibJobManager) |
|
|
|
{ |
|
|
|
_serviceProvider = serviceProvider; |
|
|
|
_locationAppService = locationAppService; |
|
|
|
_expectOutAppService = expectOutAppService; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -41,32 +49,36 @@ public class TransferLibJobAppService |
|
|
|
[UnitOfWork] |
|
|
|
public override async Task<TransferLibJobDTO> CompleteAsync(Guid id, TransferLibJobDTO dto) |
|
|
|
{ |
|
|
|
string methodPrefix = "TransferLibJobAppService.CompleteAsync - "; |
|
|
|
var methodPrefix = "TransferLibJobAppService.CompleteAsync - "; |
|
|
|
if (dto.CallServerName.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{methodPrefix}CallServerName 不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (dto.CallBusinessType.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{methodPrefix}CallBusinessType 不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (dto.CallRequestNumber.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{methodPrefix}CallRequestNumber 不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
if (dto.CallJobNumber.IsNullOrEmpty()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{methodPrefix}CallJobNumber 不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
#region 校验
|
|
|
|
|
|
|
|
foreach (var detailObj in dto.Details) |
|
|
|
{ |
|
|
|
if (detailObj.IsPackingCodeFrom) |
|
|
|
{ |
|
|
|
if (detailObj.RecommendFromPackingCode != detailObj.HandledFromPackingCode) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐From箱码必须等于实际From箱码"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐From箱码必须等于实际From箱码"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -74,7 +86,7 @@ public class TransferLibJobAppService |
|
|
|
{ |
|
|
|
if (detailObj.RecommendToPackingCode != detailObj.HandledToPackingCode) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐To箱码必须等于实际To箱码"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐To箱码必须等于实际To箱码"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -82,7 +94,7 @@ public class TransferLibJobAppService |
|
|
|
{ |
|
|
|
if (detailObj.RecommendFromLot != detailObj.HandledFromLot) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐From批次必须等于实际From批次"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐From批次必须等于实际From批次"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -90,9 +102,10 @@ public class TransferLibJobAppService |
|
|
|
{ |
|
|
|
if (detailObj.RecommendToLot != detailObj.HandledToLot) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐To批次必须等于实际To批次"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐To批次必须等于实际To批次"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//if (detailObj.IsItemCodeFrom)
|
|
|
|
//if (detailObj.IsItemCodeTo)
|
|
|
|
//if (detailObj.IsStatusFrom)
|
|
|
@ -101,7 +114,7 @@ public class TransferLibJobAppService |
|
|
|
{ |
|
|
|
if (detailObj.RecommendFromLocationCode != detailObj.HandledFromLocationCode) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐From库位必须等于实际From库位"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐From库位必须等于实际From库位"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -109,7 +122,7 @@ public class TransferLibJobAppService |
|
|
|
{ |
|
|
|
if (detailObj.RecommendToLocationCode != detailObj.HandledToLocationCode) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐To库位必须等于实际To库位"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐To库位必须等于实际To库位"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -117,7 +130,7 @@ public class TransferLibJobAppService |
|
|
|
{ |
|
|
|
if (detailObj.RecommendFromLocationGroup != detailObj.HandledFromLocationGroup) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐From库位组必须等于实际From库位组"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐From库位组必须等于实际From库位组"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -125,14 +138,15 @@ public class TransferLibJobAppService |
|
|
|
{ |
|
|
|
if (detailObj.RecommendToLocationGroup != detailObj.HandledToLocationGroup) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐To库位组必须等于实际To库位组"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐To库位组必须等于实际To库位组"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (detailObj.IsLocationAreaFrom) |
|
|
|
{ |
|
|
|
if (detailObj.RecommendFromLocationArea != detailObj.HandledFromLocationArea) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐From库区必须等于实际From库区"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐From库区必须等于实际From库区"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -140,14 +154,15 @@ public class TransferLibJobAppService |
|
|
|
{ |
|
|
|
if (detailObj.RecommendToLocationArea != detailObj.HandledToLocationArea) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐To库区必须等于实际To库区"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐To库区必须等于实际To库区"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (detailObj.IsLocationErpCodeFrom) |
|
|
|
{ |
|
|
|
if (detailObj.RecommendFromLocationErpCode != detailObj.HandledFromLocationErpCode) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐From ERP库区必须等于实际From ERP库区"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐From ERP库区必须等于实际From ERP库区"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -155,24 +170,27 @@ public class TransferLibJobAppService |
|
|
|
{ |
|
|
|
if (detailObj.RecommendToLocationErpCode != detailObj.HandledToLocationErpCode) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐To ERP库区必须等于实际To ERP库区"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐To ERP库区必须等于实际To ERP库区"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (detailObj.IsQtyFrom) |
|
|
|
{ |
|
|
|
if (detailObj.RecommendFromQty != detailObj.HandledFromQty) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐From数量必须等于实际From数量"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐From数量必须等于实际From数量"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (detailObj.IsQtyTo) |
|
|
|
{ |
|
|
|
if (detailObj.RecommendToQty != detailObj.HandledToQty) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"触发校验:推荐To数量必须等于实际To数量"); |
|
|
|
throw new UserFriendlyException("触发校验:推荐To数量必须等于实际To数量"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
foreach (var detail in dto.Details) |
|
|
@ -180,8 +198,10 @@ public class TransferLibJobAppService |
|
|
|
detail.HandledFromContainerCode = string.Empty; |
|
|
|
detail.HandledToContainerCode = string.Empty; |
|
|
|
|
|
|
|
var fromLocationDto=await _locationAppService.GetByCodeAsync(detail.HandledFromLocationCode).ConfigureAwait(false); |
|
|
|
var toLocationDto=await _locationAppService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); |
|
|
|
var fromLocationDto = await _locationAppService.GetByCodeAsync(detail.HandledFromLocationCode) |
|
|
|
.ConfigureAwait(false); |
|
|
|
var toLocationDto = |
|
|
|
await _locationAppService.GetByCodeAsync(detail.HandledToLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
detail.HandledFromLocationArea = fromLocationDto.AreaCode; |
|
|
|
detail.HandledFromLocationCode = fromLocationDto.Code; |
|
|
@ -190,7 +210,7 @@ public class TransferLibJobAppService |
|
|
|
detail.HandledFromWarehouseCode = fromLocationDto.WarehouseCode; |
|
|
|
|
|
|
|
detail.HandledToLocationArea = toLocationDto.AreaCode; |
|
|
|
detail.HandledToLocationCode = toLocationDto.Code ; |
|
|
|
detail.HandledToLocationCode = toLocationDto.Code; |
|
|
|
detail.HandledToLocationErpCode = toLocationDto.ErpLocationCode; |
|
|
|
detail.HandledToLocationGroup = toLocationDto.LocationGroupCode; |
|
|
|
detail.HandledToWarehouseCode = toLocationDto.WarehouseCode; |
|
|
@ -199,23 +219,68 @@ public class TransferLibJobAppService |
|
|
|
var ret = await base.CompleteAsync(id, dto).ConfigureAwait(false); |
|
|
|
if (ret != null) |
|
|
|
{ |
|
|
|
Type ty = Type.GetType(dto.CallServerName); |
|
|
|
var ty = Type.GetType(dto.CallServerName); |
|
|
|
if (ty == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{methodPrefix}没有找到类型为{dto.CallServerName}的对象"); |
|
|
|
} |
|
|
|
|
|
|
|
var instance = _serviceProvider.GetService(ty); |
|
|
|
if (instance == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象创建失败"); |
|
|
|
} |
|
|
|
ITransferLibCallback transferLibCallback = (ITransferLibCallback)instance; |
|
|
|
|
|
|
|
var transferLibCallback = (ITransferLibCallback)instance; |
|
|
|
if (transferLibCallback == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{methodPrefix}类型为{dto.CallServerName}的对象没有实现ITransferLibCallback接口"); |
|
|
|
} |
|
|
|
|
|
|
|
await transferLibCallback.DoTransferLibCallbackAsync(dto).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
await TransferLibRequestAppService.CompleteByJobAsync(dto.RequestNumber).ConfigureAwait(false); |
|
|
|
|
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("get-by-request/{requestNumber}")] |
|
|
|
[UnitOfWork] |
|
|
|
public async Task<List<TransferLibJobDTO>> GetByRequestNumberAsync(string requestNumber) |
|
|
|
{ |
|
|
|
var list = await _repository.GetListAsync(p => p.RequestNumber == requestNumber).ConfigureAwait(false); |
|
|
|
|
|
|
|
return ObjectMapper.Map<List<TransferLibJob>, List<TransferLibJobDTO>>(list); |
|
|
|
} |
|
|
|
|
|
|
|
public override async Task CancelAcceptAsync(Guid id) |
|
|
|
{ |
|
|
|
var job = await _repository.FindAsync(p => p.Id == id).ConfigureAwait(false); |
|
|
|
|
|
|
|
if (job.JobStatus == EnumJobStatus.Open || job.JobStatus == EnumJobStatus.Partial || |
|
|
|
job.JobStatus == EnumJobStatus.Doing || job.JobStatus == EnumJobStatus.Wait) |
|
|
|
{ |
|
|
|
await _repository.UpdateAsync(job).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
await _expectOutAppService.RemoveByNumberAsync(job.Number).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("complete-by-request/{requestNumber}")] |
|
|
|
[UnitOfWork] |
|
|
|
public async Task CompleteByRequestAsync(string requestNumber) |
|
|
|
{ |
|
|
|
var list = await _repository.GetListAsync(p => p.RequestNumber == requestNumber).ConfigureAwait(false); |
|
|
|
|
|
|
|
foreach (var job in list) |
|
|
|
{ |
|
|
|
if (job.JobStatus == EnumJobStatus.Open || job.JobStatus == EnumJobStatus.Partial || |
|
|
|
job.JobStatus == EnumJobStatus.Doing || job.JobStatus == EnumJobStatus.Wait) |
|
|
|
{ |
|
|
|
await _repository.UpdateAsync(job).ConfigureAwait(false); |
|
|
|
await _expectOutAppService.RemoveByNumberAsync(job.Number).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|