|
|
@ -1,22 +1,14 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Data; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq.Expressions; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Castle.Components.DictionaryAdapter; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using SQLitePCL; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
using Win_in.Sfs.Basedata.Domain.Shared; |
|
|
|
using Win_in.Sfs.Shared.Domain; |
|
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
|
using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; |
|
|
|
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; |
|
|
@ -35,15 +27,22 @@ public class KittingIssueJobAppService |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
private readonly ITransferLibJobAppService _transferLibJobAppService; |
|
|
|
private readonly IKittingIssueNoteAppService _kittingIssueNoteAppService; |
|
|
|
private readonly IExpectOutAppService _expectOutAppService; |
|
|
|
|
|
|
|
protected IKittingIssueRequestAppService KittingIssueRequestAppService => |
|
|
|
LazyServiceProvider.LazyGetRequiredService<IKittingIssueRequestAppService>(); |
|
|
|
|
|
|
|
public KittingIssueJobAppService( |
|
|
|
IKittingIssueJobRepository repository, IKittingIssueJobManager kittingIssueJobManager, |
|
|
|
ILocationAppService locationAppService, ITransferLibJobAppService transferLibJobAppService, IKittingIssueNoteAppService kittingIssueNoteAppService) : base(repository, kittingIssueJobManager) |
|
|
|
ILocationAppService locationAppService, ITransferLibJobAppService transferLibJobAppService, |
|
|
|
IKittingIssueNoteAppService kittingIssueNoteAppService, IExpectOutAppService expectOutAppService) : base( |
|
|
|
repository, kittingIssueJobManager) |
|
|
|
{ |
|
|
|
_kittingIssueJobManager = kittingIssueJobManager; |
|
|
|
_locationAppService = locationAppService; |
|
|
|
_transferLibJobAppService = transferLibJobAppService; |
|
|
|
_kittingIssueNoteAppService = kittingIssueNoteAppService; |
|
|
|
_expectOutAppService = expectOutAppService; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("add-many")] |
|
|
@ -100,7 +99,7 @@ public class KittingIssueJobAppService |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 库移回调
|
|
|
|
/// 库移回调
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
/// <returns></returns>
|
|
|
@ -145,40 +144,36 @@ public class KittingIssueJobAppService |
|
|
|
jobDetail.TransferLibToWarehouseCode = transferLibNoteDetail.HandledToWarehouseCode; |
|
|
|
|
|
|
|
await _repository.UpdateAsync(job).ConfigureAwait(false); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 执行任务明细
|
|
|
|
/// 执行任务明细
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("ExecuteDetail/{masterId}")] |
|
|
|
public async Task ExecuteDetailAsync(Guid masterId,Guid detailId, KittingIssueJobDetailDTO issueJobDetailDto) |
|
|
|
public async Task ExecuteDetailAsync(Guid masterId, Guid detailId, KittingIssueJobDetailDTO issueJobDetailDto) |
|
|
|
{ |
|
|
|
var kittingIssueJob= await _repository.GetAsync(masterId).ConfigureAwait(false); |
|
|
|
var kittingIssueJob = await _repository.GetAsync(masterId).ConfigureAwait(false); |
|
|
|
|
|
|
|
var kittingIssueJobDto=ObjectMapper.Map<KittingIssueJob, KittingIssueJobDTO>(kittingIssueJob); |
|
|
|
kittingIssueJobDto.Details = new List<KittingIssueJobDetailDTO>() { issueJobDetailDto }; |
|
|
|
var kittingIssueNoteEditInput=await BuildKittingIssueNoteAsync(kittingIssueJobDto).ConfigureAwait(false); |
|
|
|
var kittingIssueJobDto = ObjectMapper.Map<KittingIssueJob, KittingIssueJobDTO>(kittingIssueJob); |
|
|
|
kittingIssueJobDto.Details = new List<KittingIssueJobDetailDTO> { issueJobDetailDto }; |
|
|
|
var kittingIssueNoteEditInput = await BuildKittingIssueNoteAsync(kittingIssueJobDto).ConfigureAwait(false); |
|
|
|
await _kittingIssueNoteAppService.CreateAsync(kittingIssueNoteEditInput).ConfigureAwait(false); |
|
|
|
|
|
|
|
kittingIssueJobDto = ObjectMapper.Map<KittingIssueJob, KittingIssueJobDTO>(kittingIssueJob); |
|
|
|
|
|
|
|
if (kittingIssueJob.EnumIssueSendType == EnumIssueSendType.QtyType)//按箱叫料 因为任务只有1箱 所以可以直接完成
|
|
|
|
if (kittingIssueJob.EnumIssueSendType == EnumIssueSendType.QtyType) //按箱叫料 因为任务只有1箱 所以可以直接完成
|
|
|
|
{ |
|
|
|
await CompleteAsync(masterId, kittingIssueJobDto).ConfigureAwait(false); |
|
|
|
await UpdateJobStatusDoneAsync(kittingIssueJob, issueJobDetailDto).ConfigureAwait(false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var detail = kittingIssueJob.Details.First(p=>p.Id==issueJobDetailDto.Id); |
|
|
|
var detail = kittingIssueJob.Details.First(p => p.Id == issueJobDetailDto.Id); |
|
|
|
if (issueJobDetailDto.HandledToQty >= detail.RequestQty) |
|
|
|
{ |
|
|
|
await CompleteAsync(masterId, kittingIssueJobDto).ConfigureAwait(false); |
|
|
|
await UpdateJobStatusDoneAsync(kittingIssueJob, issueJobDetailDto).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
await _kittingIssueNoteAppService.CreateAsync(kittingIssueNoteEditInput).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
#region 私有
|
|
|
@ -190,7 +185,8 @@ public class KittingIssueJobAppService |
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<KittingIssueNoteEditInput> BuildKittingIssueNoteAsync(KittingIssueJobDTO kittingIssueJobDto) |
|
|
|
{ |
|
|
|
var kittingIssueNoteCreateInput = ObjectMapper.Map<KittingIssueJobDTO, KittingIssueNoteEditInput>(kittingIssueJobDto); |
|
|
|
var kittingIssueNoteCreateInput = |
|
|
|
ObjectMapper.Map<KittingIssueJobDTO, KittingIssueNoteEditInput>(kittingIssueJobDto); |
|
|
|
kittingIssueNoteCreateInput.JobNumber = kittingIssueJobDto.Number; |
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
@ -245,7 +241,7 @@ public class KittingIssueJobAppService |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断是不是在立体库
|
|
|
|
/// 判断是不是在立体库
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
@ -264,5 +260,29 @@ public class KittingIssueJobAppService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task UpdateJobStatusDoneAsync(KittingIssueJob kittingIssueJob, |
|
|
|
KittingIssueJobDetailDTO kittingIssueJobDetailDto) |
|
|
|
{ |
|
|
|
if (kittingIssueJob.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None |
|
|
|
or EnumJobStatus.Done) //需要考虑下 多次提交的问题 所以不判断 进行中
|
|
|
|
{ |
|
|
|
throw new UserFriendlyException( |
|
|
|
$"任务状态错误:编号为【{kittingIssueJob.Number}】的任务已经【{kittingIssueJob.JobStatus.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
|
|
|
|
kittingIssueJob.JobStatus = EnumJobStatus.Done; |
|
|
|
|
|
|
|
await _expectOutAppService.RemoveByNumberAndInventoryAsync(kittingIssueJob.Number, |
|
|
|
kittingIssueJobDetailDto.ItemCode, |
|
|
|
kittingIssueJobDetailDto.HandledToLocationCode, kittingIssueJobDetailDto.HandledToPackingCode, |
|
|
|
kittingIssueJobDetailDto.Status, kittingIssueJobDetailDto.HandledToLot, |
|
|
|
kittingIssueJobDetailDto.HandledToQty).ConfigureAwait(false); |
|
|
|
|
|
|
|
await KittingIssueRequestAppService.UpdateStatusCompletedAsync(kittingIssueJob.KittingRequestNumber) |
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|