6 changed files with 212 additions and 231 deletions
@ -1,78 +0,0 @@ |
|||
//using System.Collections.Generic;
|
|||
//using System.Linq;
|
|||
//using System.Threading.Tasks;
|
|||
//using Volo.Abp.EventBus;
|
|||
//using Volo.Abp.Uow;
|
|||
//using Win_in.Sfs.Shared.Event;
|
|||
//using Win_in.Sfs.Wms.Store.Domain;
|
|||
|
|||
//namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest;
|
|||
|
|||
//public class IssueNoteEventHandler
|
|||
// : StoreEventHandlerBase
|
|||
// , ILocalEventHandler<SfsCreatedEntityEventData<IssueNote>>
|
|||
// , ILocalEventHandler<SfsCreatedEntityEventData<List<IssueNote>>>
|
|||
// , ILocalEventHandler<SfsConfirmedEntityEventData<IssueNote>>
|
|||
//{
|
|||
// private readonly IMaterialRequestManager _materialRequestManager;
|
|||
|
|||
// public IssueNoteEventHandler(
|
|||
// IMaterialRequestManager materialRequestManager
|
|||
// )
|
|||
// {
|
|||
// _materialRequestManager = materialRequestManager;
|
|||
// }
|
|||
|
|||
// [UnitOfWork]
|
|||
// public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<IssueNote> eventData)
|
|||
// {
|
|||
// var entity = eventData.Entity;
|
|||
|
|||
// await UpdateReceivedQtyMaterialRequestAsync(entity).ConfigureAwait(false);
|
|||
// }
|
|||
|
|||
// private async Task UpdateReceivedQtyMaterialRequestAsync(IssueNote entity)
|
|||
// {
|
|||
// var receiveQtyGroup = entity.Details
|
|||
// .GroupBy(p => new { p.ItemCode, p.ToLocationCode })
|
|||
// .Select(p => new { p.Key.ItemCode, p.Key.ToLocationCode, Qty = p.Sum(d => d.Qty) })
|
|||
// .ToList();
|
|||
|
|||
// var materialRequest = await _materialRequestManager.GetByNumberAsync(entity.RequestNumber).ConfigureAwait(false);
|
|||
|
|||
// //更新叫料请求的已收数量
|
|||
// foreach (var materialRequestDetail in materialRequest.Details)
|
|||
// {
|
|||
// var receiveQty = receiveQtyGroup.FirstOrDefault(p =>
|
|||
// p.ItemCode == materialRequestDetail.ItemCode &&
|
|||
// p.ToLocationCode == materialRequestDetail.ToLocationCode)?.Qty;
|
|||
// if (receiveQty != null)
|
|||
// {
|
|||
// materialRequestDetail.ReceivedQty += receiveQty.Value;
|
|||
// }
|
|||
// }
|
|||
|
|||
// await _materialRequestManager.UpdateDetailsAsync(materialRequest).ConfigureAwait(false);
|
|||
// }
|
|||
|
|||
// [UnitOfWork]
|
|||
// public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<IssueNote> eventData)
|
|||
// {
|
|||
// var entity = eventData.Entity;
|
|||
// if (!entity.UseOnTheWayLocation)
|
|||
// {
|
|||
// await UpdateReceivedQtyMaterialRequestAsync(entity).ConfigureAwait(false);
|
|||
// }
|
|||
|
|||
// }
|
|||
|
|||
// [UnitOfWork]
|
|||
// public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<IssueNote>> eventData)
|
|||
// {
|
|||
// var entities = eventData.Entity;
|
|||
// foreach (var entity in entities.Where(entity => !entity.UseOnTheWayLocation))
|
|||
// {
|
|||
// await UpdateReceivedQtyMaterialRequestAsync(entity).ConfigureAwait(false);
|
|||
// }
|
|||
// }
|
|||
//}
|
@ -0,0 +1,82 @@ |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.EventBus; |
|||
using Volo.Abp.Uow; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
using Win_in.Sfs.Shared.Event; |
|||
using Win_in.Sfs.Wms.Store.Domain; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest; |
|||
|
|||
public class IssueNoteEventHandler |
|||
: StoreEventHandlerBase |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<IssueNote>> |
|||
, ILocalEventHandler<SfsCreatedEntityEventData<List<IssueNote>>> |
|||
, ILocalEventHandler<SfsConfirmedEntityEventData<IssueNote>> |
|||
{ |
|||
private readonly IMaterialRequestManager _materialRequestManager; |
|||
|
|||
public IssueNoteEventHandler( |
|||
IMaterialRequestManager materialRequestManager |
|||
) |
|||
{ |
|||
_materialRequestManager = materialRequestManager; |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<IssueNote> eventData) |
|||
{ |
|||
var entity = eventData.Entity; |
|||
|
|||
await UpdateReceivedQtyMaterialRequestAsync(entity).ConfigureAwait(false); |
|||
} |
|||
|
|||
private async Task UpdateReceivedQtyMaterialRequestAsync(IssueNote entity) |
|||
{ |
|||
var receiveQtyGroup = entity.Details |
|||
.GroupBy(p => new { p.ItemCode, p.ToLocationCode }) |
|||
.Select(p => new { p.Key.ItemCode, p.Key.ToLocationCode, Qty = p.Sum(d => d.Qty) }) |
|||
.ToList(); |
|||
|
|||
var materialRequest = await _materialRequestManager.GetByNumberAsync(entity.RequestNumber).ConfigureAwait(false); |
|||
|
|||
if (entity.RequestType != EnumMaterialRequestType.Direct_Issue.ToString()) |
|||
{ |
|||
//更新叫料请求的已收数量
|
|||
foreach (var materialRequestDetail in materialRequest.Details) |
|||
{ |
|||
var receiveQty = receiveQtyGroup.FirstOrDefault(p => |
|||
p.ItemCode == materialRequestDetail.ItemCode && |
|||
p.ToLocationCode == materialRequestDetail.ToLocationCode)?.Qty; |
|||
if (receiveQty != null) |
|||
{ |
|||
materialRequestDetail.ReceivedQty += receiveQty.Value; |
|||
} |
|||
} |
|||
|
|||
await _materialRequestManager.UpdateDetailsAsync(materialRequest).ConfigureAwait(false); |
|||
} |
|||
} |
|||
|
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<IssueNote> eventData) |
|||
{ |
|||
var entity = eventData.Entity; |
|||
if (!entity.UseOnTheWayLocation) |
|||
{ |
|||
await UpdateReceivedQtyMaterialRequestAsync(entity).ConfigureAwait(false); |
|||
} |
|||
} |
|||
|
|||
[UnitOfWork] |
|||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<IssueNote>> eventData) |
|||
{ |
|||
var entities = eventData.Entity; |
|||
foreach (var entity in entities.Where(entity => !entity.UseOnTheWayLocation)) |
|||
{ |
|||
await UpdateReceivedQtyMaterialRequestAsync(entity).ConfigureAwait(false); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue