Browse Source

修改 发料

集成Redis
郑勃旭 2 years ago
parent
commit
ddc03472ff
  1. 8
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ProductionReturnNotes/ProductionReturnNoteAutoMapperProfile.cs
  2. 78
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/IssueNoteEventHandler.cs
  3. 5
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/MaterialRequestEventHandler.cs
  4. 82
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/Note/IssueNoteEventHandler.cs
  5. 6
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/Note/ScrapNoteEventHandler.cs
  6. 264
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/IssueNoteEventHandler.cs

8
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/ProductionReturnNotes/ProductionReturnNoteAutoMapperProfile.cs

@ -20,5 +20,13 @@ public partial class StoreApplicationAutoMapperProfile : Profile
.Ignore(x => x.TenantId)
.Ignore(x => x.Number)
.Ignore(x => x.Id);
CreateMap<ProductionReturnNoteEditInput, ProductionReturnNote>()
.IgnoreAuditedObjectProperties()
.Ignore(x => x.TenantId)
.Ignore(x => x.Number)
.Ignore(x => x.Id)
.Ignore(x=>x.Remark)
.Ignore(x=>x.ExtraProperties)
;
}
}

78
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/IssueNoteEventHandler.cs

@ -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);
// }
// }
//}

5
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/MaterialRequestEventHandler.cs

@ -110,7 +110,8 @@ public class MaterialRequestEventHandler
await Task.CompletedTask.ConfigureAwait(false);
}
private async Task<List<IssueJobEditInput>> BuildIssueJobAsync(MaterialRequest materialRequest)
private async Task<List<IssueJobEditInput>> BuildIssueJobAsync
(MaterialRequest materialRequest)
{
var jobs = new List<IssueJobEditInput>();
@ -239,6 +240,8 @@ public class MaterialRequestEventHandler
detail.RecommendFromLocationErpCode= balance.LocationErpCode;
detail.RecommendFromLocationGroup= balance.LocationGroup;
detail.RecommendFromWarehouseCode= balance.WarehouseCode;
detail.RecommendQty = balance.Qty;
detail.Uom = balance.Uom;
detail.ToLocationCode = materialRequestDetail.ToLocationCode;
detail.ToLocationErpCode = materialRequestDetail.ToLocationErpCode;

82
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/Note/IssueNoteEventHandler.cs

@ -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);
}
}
}

6
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/Note/ScrapNoteEventHandler.cs

@ -1,15 +1,9 @@
using System;
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.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;
using Win_in.Sfs.Wms.Store.Event.Transaction;
namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest;

264
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/IssueNoteEventHandler.cs

@ -4,156 +4,128 @@ using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.EventBus;
using Volo.Abp.Uow;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Shared.Event;
using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain;
using Win_in.Sfs.Wms.Store.Event.Transactions;
using Win_in.Sfs.Wms.Store.Event.Transaction;
namespace Win_in.Sfs.Wms.Store.Event.BusinessNote
namespace Win_in.Sfs.Wms.Store.Event.Transactions;
public class IssueNoteEventHandler
: StoreInventoryEventHandlerBase
, ILocalEventHandler<SfsCreatedEntityEventData<IssueNote>>
, ILocalEventHandler<SfsCreatedEntityEventData<List<IssueNote>>>
, ILocalEventHandler<SfsConfirmedEntityEventData<IssueNote>>
{
//public class IssueNoteEventHandler
// : StoreEventHandlerBase
// , ILocalEventHandler<SfsCreatedEntityEventData<IssueNote>>
// , ILocalEventHandler<SfsCreatedEntityEventData<List<IssueNote>>>
// , ILocalEventHandler<SfsConfirmedEntityEventData<IssueNote>>
//{
// private const EnumTransType TransType = EnumTransType.Issue;
// private readonly Itranlog
// [UnitOfWork]
// public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<IssueNote> eventData)
// {
// var entity = eventData.Entity;
// var transferLogs = new List<TransferLogEditInput>();
// var route = entity.UseOnTheWayLocation
// ? EnumTransferRoute.SourceToOnTheWay
// : EnumTransferRoute.SourceToDestination;
// //如果是mes拉动 先发到在途
// if (entity.RequestType == EnumMaterialRequestType.Issue_WIP.ToString())
// {
// route = EnumTransferRoute.SourceToOnTheWay;
// }
// transferLogs.AddRange(await BuildTransferLogsAsync(entity, route));
// await TransferLogAppService.AddManyAsync(transferLogs);
// }
// [UnitOfWork]
// public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<IssueNote>> eventData)
// {
// var entities = eventData.Entity;
// var transferLogs = new List<TransferLogCreateInput>();
// //如果要做库存事务汇总,可以修改此处
// foreach (var issueNote in entities)
// {
// var route = issueNote.UseOnTheWayLocation
// ? EnumTransferRoute.SourceToOnTheWay
// : EnumTransferRoute.SourceToDestination;
// transferLogs.AddRange(await BuildTransferLogsAsync(issueNote, route));
// }
// await TransferLogAppService.AddManyAsync(transferLogs);
// }
// [UnitOfWork]
// public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<IssueNote> eventData)
// {
// var entity = eventData.Entity;
// var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination);
// await AddTransferLogsAsync(inputList);
// }
// private async Task AddTransferLogsAsync(List<TransferLogCreateInput> inputList)
// {
// var transferLogs = new List<TransferLogCreateInput>();
// transferLogs.AddRange(inputList);
// await TransferLogAppService.AddManyAsync(transferLogs);
// }
// private async Task<List<TransferLogCreateInput>> BuildTransferLogsAsync(IssueNote issueNote, EnumTransferRoute route)
// {
// var transferLogs = new List<TransferLogCreateInput>();
// foreach (var detail in issueNote.Details.Where(detail => detail.Qty.Qty != 0))
// {
// var transferLog = ObjectMapper.Map<IssueNoteDetail, TransferLogCreateInput>(detail);
// LocationDTO fromLocationDTO = null;
// LocationDTO toLocationDTO = null;
// if (issueNote.UseOnTheWayLocation)
// {
// var location = await LocationAppService.GetByCodeAsync(detail.OnTheWayLocationCode);
// switch (route)
// {
// case EnumTransferRoute.SourceToOnTheWay:
// fromLocationDTO = await LocationAppService.GetByCodeAsync(detail.FromLocationCode);
// toLocationDTO = await LocationAppService.GetByCodeAsync(detail.OnTheWayLocationCode);
// break;
// case EnumTransferRoute.OnTheWayToDestination:
// fromLocationDTO = await LocationAppService.GetByCodeAsync(detail.OnTheWayLocationCode);
// toLocationDTO = await LocationAppService.GetByCodeAsync(detail.ToLocationCode);
// await RemovePackingCodeAndContainerCodeAndLotAsync(transferLog);
// break;
// case EnumTransferRoute.SourceToDestination:
// default:
// throw new ArgumentOutOfRangeException(nameof(route), route, null);
// }
// }
// else
// {
// fromLocationDTO = await LocationAppService.GetByCodeAsync(detail.FromLocationCode);
// toLocationDTO = await LocationAppService.GetByCodeAsync(detail.ToLocationCode);
// }
// transferLog.FromLocationCode = fromLocationDTO.Code;
// transferLog.FromLocationArea = fromLocationDTO.AreaCode;
// transferLog.FromLocationErpCode = fromLocationDTO.ErpLocationCode;
// transferLog.FromLocationGroup = fromLocationDTO.LocationGroupCode;
// transferLog.ToLocationCode = toLocationDTO.Code;
// transferLog.ToLocationArea = toLocationDTO.AreaCode;
// transferLog.ToLocationErpCode = toLocationDTO.ErpLocationCode;
// transferLog.ToLocationGroup = toLocationDTO.LocationGroupCode;
// transferLog.TransType = TransType;
// transferLog.TransSubType = Enum.Parse<EnumTransSubType>(issueNote.RequestType);
// transferLog.Company = issueNote.Company;
// transferLog.Worker = issueNote.Worker;
// transferLog.DocNumber = issueNote.Number;
// transferLog.JobNumber = issueNote.JobNumber;
// transferLogs.Add(transferLog);
// }
// return transferLogs;
// }
// private async Task RemovePackingCodeAndContainerCodeAndLotAsync(TransferLogCreateInput transferLogCreateInput)
// {
// transferLogCreateInput.ToPackingCode = "";
// transferLogCreateInput.ToLot = "";
// transferLogCreateInput.ToContainerCode = "";
// transferLogCreateInput.FromPackingCode = "";
// transferLogCreateInput.FromLot = "";
// transferLogCreateInput.FromContainerCode = "";
// }
//}
private const EnumTransType TransType = EnumTransType.Issue;
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<IssueNote> eventData)
{
var entity = eventData.Entity;
var transferLogs = new List<TransferLogEditInput>();
var route = entity.UseOnTheWayLocation
? EnumTransferRoute.SourceToOnTheWay
: EnumTransferRoute.SourceToDestination;
transferLogs.AddRange(await BuildTransferLogsAsync(entity, route).ConfigureAwait(false));
//如果是mes拉动 先发到在途
if (entity.RequestType == EnumMaterialRequestType.Issue_WIP.ToString())
{
route = EnumTransferRoute.SourceToOnTheWay;
}
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false);
}
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<IssueNote>> eventData)
{
var entities = eventData.Entity;
var transferLogs = new List<TransferLogEditInput>();
//如果要做库存事务汇总,可以修改此处
foreach (var issueNote in entities)
{
var route = issueNote.UseOnTheWayLocation
? EnumTransferRoute.SourceToOnTheWay
: EnumTransferRoute.SourceToDestination;
transferLogs.AddRange(await BuildTransferLogsAsync(issueNote, route).ConfigureAwait(false));
}
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false);
}
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<IssueNote> eventData)
{
var entity = eventData.Entity;
var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination).ConfigureAwait(false);
await AddTransferLogsAsync(inputList).ConfigureAwait(false);
}
private async Task AddTransferLogsAsync(List<TransferLogEditInput> inputList)
{
var transferLogs = new List<TransferLogEditInput>();
transferLogs.AddRange(inputList);
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false);
}
private async Task<List<TransferLogEditInput>> BuildTransferLogsAsync(IssueNote issueNote, EnumTransferRoute route)
{
var transferLogs = new List<TransferLogEditInput>();
foreach (var detail in issueNote.Details.Where(detail => detail.Qty != 0))
{
var transferLog = ObjectMapper.Map<IssueNoteDetail, TransferLogEditInput>(detail);
if (issueNote.UseOnTheWayLocation)
{
var location = await LocationAclService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false);
switch (route)
{
case EnumTransferRoute.SourceToOnTheWay:
detail.ToLocationCode = detail.OnTheWayLocationCode;
detail.ToLocationErpCode = location.ErpLocationCode;
detail.ToWarehouseCode = location.WarehouseCode;
detail.ToLocationArea = location.AreaCode;
break;
case EnumTransferRoute.OnTheWayToDestination:
detail.FromLocationCode = detail.OnTheWayLocationCode;
detail.FromLocationErpCode = location.ErpLocationCode;
detail.FromWarehouseCode = location.WarehouseCode;
detail.FromLocationArea = location.AreaCode;
break;
case EnumTransferRoute.SourceToDestination:
default:
throw new ArgumentOutOfRangeException(nameof(route), route, null);
}
}
if (issueNote.UseOnTheWayLocation)
{
transferLog.FromLocationCode = detail.OnTheWayLocationCode;
var location = await LocationAclService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false);
transferLog.FromLocationGroup = location.LocationGroupCode;
transferLog.FromLocationArea = location.AreaCode;
transferLog.FromLocationErpCode = location.ErpLocationCode;
transferLog.FromWarehouseCode=location.WarehouseCode;
}
transferLog.TransType = TransType;
transferLog.TransSubType = Enum.Parse<EnumTransSubType>(issueNote.RequestType);
transferLog.Worker = issueNote.Worker;
transferLog.DocNumber = issueNote.Number;
transferLog.JobNumber = issueNote.JobNumber;
transferLogs.Add(transferLog);
}
return transferLogs;
}
}

Loading…
Cancel
Save