|
|
@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; |
|
|
|
using Omu.ValueInjecter; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Data; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
@ -37,16 +38,18 @@ public class UnplannedIssueJobAppService |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
|
private readonly IExpectOutAppService _expectOutAppService; |
|
|
|
private readonly IUnitOfWorkManager _unitOfWorkManager; |
|
|
|
|
|
|
|
public UnplannedIssueJobAppService( |
|
|
|
IUnplannedIssueJobRepository repository, IUnplannedIssueJobManager unplannedIssueJobManager, ILocationAppService locationAppService, IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService |
|
|
|
IUnplannedIssueJobRepository repository, IUnplannedIssueJobManager unplannedIssueJobManager, ILocationAppService locationAppService, |
|
|
|
IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService, IUnitOfWorkManager unitOfWorkManager |
|
|
|
) : base(repository, unplannedIssueJobManager ) |
|
|
|
{ |
|
|
|
_unplannedIssueJobManager = unplannedIssueJobManager; |
|
|
|
_locationAppService = locationAppService; |
|
|
|
_balanceAppService = balanceAppService; |
|
|
|
_expectOutAppService = expectOutAppService; |
|
|
|
|
|
|
|
_unitOfWorkManager = unitOfWorkManager; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
@ -97,14 +100,14 @@ public class UnplannedIssueJobAppService |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string[] GetAllFields(Type type) |
|
|
|
{ |
|
|
|
// 获取公共实例字段
|
|
|
|
var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); |
|
|
|
//public static string[] GetAllFields(Type type)
|
|
|
|
//{
|
|
|
|
// // 获取公共实例字段
|
|
|
|
// var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
|
|
|
|
|
|
|
|
// 返回字段名称
|
|
|
|
return fields.Select(f => f.Name).ToArray(); |
|
|
|
} |
|
|
|
// // 返回字段名称
|
|
|
|
// return fields.Select(f => f.Name).ToArray();
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -117,15 +120,16 @@ public class UnplannedIssueJobAppService |
|
|
|
decimal availableToDeduct = Math.Min(item.Qty, quantityToDeduct - totalDeducted); |
|
|
|
item.Qty -= availableToDeduct; |
|
|
|
totalDeducted += availableToDeduct; |
|
|
|
BalanceDTO dto = new BalanceDTO(); |
|
|
|
dto.InjectFrom(item); |
|
|
|
dto.Qty = availableToDeduct; |
|
|
|
balanceDTOs.Add(dto); |
|
|
|
|
|
|
|
// 如果已经扣减达到所需数量,退出循环
|
|
|
|
if (totalDeducted >= quantityToDeduct) |
|
|
|
{ |
|
|
|
break; |
|
|
|
} |
|
|
|
BalanceDTO dto = new BalanceDTO(); |
|
|
|
dto.InjectFrom(item); |
|
|
|
dto.Qty = availableToDeduct; |
|
|
|
balanceDTOs.Add(dto); |
|
|
|
} |
|
|
|
// 返回实际扣减的库存数量
|
|
|
|
return balanceDTOs; |
|
|
@ -344,21 +348,26 @@ public class UnplannedIssueJobAppService |
|
|
|
|
|
|
|
public override async Task<UnplannedIssueJobDTO> CompleteAsync(Guid id, UnplannedIssueJobDTO dto) |
|
|
|
{ |
|
|
|
|
|
|
|
//using (var _uow = new UnitOfWorkManager()) { }
|
|
|
|
|
|
|
|
var job = await _repository.GetAsync(id).ConfigureAwait(false); |
|
|
|
if (job.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None or EnumJobStatus.Done)//需要考虑下 多次提交的问题 所以不判断 进行中
|
|
|
|
var job = await _repository.GetAsync(id).ConfigureAwait(false); |
|
|
|
var handleDto = new UnplannedIssueJobDTO(); |
|
|
|
using (var uow = _unitOfWorkManager.Begin()) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"任务状态错误:编号为【{job.Number}】的任务已经【{job.JobStatus.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
var handleEntity = ObjectMapper.Map<UnplannedIssueJobDTO, UnplannedIssueJob>(dto); |
|
|
|
// 在工作单元中插入数据
|
|
|
|
|
|
|
|
if (job.JobStatus is EnumJobStatus.Closed or EnumJobStatus.Cancelled or EnumJobStatus.None or EnumJobStatus.Done)//需要考虑下 多次提交的问题 所以不判断 进行中
|
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"任务状态错误:编号为【{job.Number}】的任务已经【{job.JobStatus.GetDisplayName()}】"); |
|
|
|
} |
|
|
|
var handleEntity = ObjectMapper.Map<UnplannedIssueJobDTO, UnplannedIssueJob>(dto); |
|
|
|
|
|
|
|
handleEntity.JobStatus = EnumJobStatus.Done; |
|
|
|
var handleResult = await _unplannedIssueJobManager.CompleteAsync(handleEntity, CurrentUser).ConfigureAwait(false); |
|
|
|
var handleDto = ObjectMapper.Map<UnplannedIssueJob, UnplannedIssueJobDTO>(handleResult); |
|
|
|
handleEntity.JobStatus = EnumJobStatus.Done; |
|
|
|
var handleResult = await _unplannedIssueJobManager.CompleteAsync(handleEntity, CurrentUser).ConfigureAwait(false); |
|
|
|
handleDto = ObjectMapper.Map<UnplannedIssueJob, UnplannedIssueJobDTO>(handleResult); |
|
|
|
|
|
|
|
await _expectOutAppService.RemoveAsync(dto.Number).ConfigureAwait(false); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
await UpdateRequestStatusAsync(job.UnplannedIssueRequestNumber).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|