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.TenantId)
.Ignore(x => x.Number) .Ignore(x => x.Number)
.Ignore(x => x.Id); .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); 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>(); var jobs = new List<IssueJobEditInput>();
@ -239,6 +240,8 @@ public class MaterialRequestEventHandler
detail.RecommendFromLocationErpCode= balance.LocationErpCode; detail.RecommendFromLocationErpCode= balance.LocationErpCode;
detail.RecommendFromLocationGroup= balance.LocationGroup; detail.RecommendFromLocationGroup= balance.LocationGroup;
detail.RecommendFromWarehouseCode= balance.WarehouseCode; detail.RecommendFromWarehouseCode= balance.WarehouseCode;
detail.RecommendQty = balance.Qty;
detail.Uom = balance.Uom;
detail.ToLocationCode = materialRequestDetail.ToLocationCode; detail.ToLocationCode = materialRequestDetail.ToLocationCode;
detail.ToLocationErpCode = materialRequestDetail.ToLocationErpCode; 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.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.Uow; using Volo.Abp.Uow;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Shared.Event; 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;
using Win_in.Sfs.Wms.Store.Domain.Shared;
using Win_in.Sfs.Wms.Store.Event.Transaction; using Win_in.Sfs.Wms.Store.Event.Transaction;
namespace Win_in.Sfs.Wms.Store.Event.BusinessRequest; 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 System.Threading.Tasks;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.Uow; 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.Domain.Shared;
using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Shared.Event;
using Win_in.Sfs.Wms.Inventory.Application.Contracts; using Win_in.Sfs.Wms.Inventory.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain; 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>>
{
private const EnumTransType TransType = EnumTransType.Issue;
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<IssueNote> eventData)
{ {
//public class IssueNoteEventHandler var entity = eventData.Entity;
// : StoreEventHandlerBase var transferLogs = new List<TransferLogEditInput>();
// , ILocalEventHandler<SfsCreatedEntityEventData<IssueNote>> var route = entity.UseOnTheWayLocation
// , ILocalEventHandler<SfsCreatedEntityEventData<List<IssueNote>>> ? EnumTransferRoute.SourceToOnTheWay
// , ILocalEventHandler<SfsConfirmedEntityEventData<IssueNote>> : EnumTransferRoute.SourceToDestination;
//{ transferLogs.AddRange(await BuildTransferLogsAsync(entity, route).ConfigureAwait(false));
// private const EnumTransType TransType = EnumTransType.Issue;
// private readonly Itranlog //如果是mes拉动 先发到在途
if (entity.RequestType == EnumMaterialRequestType.Issue_WIP.ToString())
{
// [UnitOfWork] route = EnumTransferRoute.SourceToOnTheWay;
// public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<IssueNote> eventData) }
// {
// var entity = eventData.Entity; await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false);
// var transferLogs = new List<TransferLogEditInput>(); }
// var route = entity.UseOnTheWayLocation
// ? EnumTransferRoute.SourceToOnTheWay [UnitOfWork]
// : EnumTransferRoute.SourceToDestination; public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<IssueNote>> eventData)
{
// //如果是mes拉动 先发到在途 var entities = eventData.Entity;
// if (entity.RequestType == EnumMaterialRequestType.Issue_WIP.ToString()) var transferLogs = new List<TransferLogEditInput>();
// { //如果要做库存事务汇总,可以修改此处
// route = EnumTransferRoute.SourceToOnTheWay; foreach (var issueNote in entities)
// } {
var route = issueNote.UseOnTheWayLocation
// transferLogs.AddRange(await BuildTransferLogsAsync(entity, route)); ? EnumTransferRoute.SourceToOnTheWay
: EnumTransferRoute.SourceToDestination;
// await TransferLogAppService.AddManyAsync(transferLogs); transferLogs.AddRange(await BuildTransferLogsAsync(issueNote, route).ConfigureAwait(false));
// } }
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false);
// [UnitOfWork] }
// public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<IssueNote>> eventData)
// { [UnitOfWork]
// var entities = eventData.Entity;
// var transferLogs = new List<TransferLogCreateInput>(); public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<IssueNote> eventData)
// //如果要做库存事务汇总,可以修改此处 {
// foreach (var issueNote in entities) var entity = eventData.Entity;
// {
// var route = issueNote.UseOnTheWayLocation var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination).ConfigureAwait(false);
// ? EnumTransferRoute.SourceToOnTheWay await AddTransferLogsAsync(inputList).ConfigureAwait(false);
// : EnumTransferRoute.SourceToDestination; }
// transferLogs.AddRange(await BuildTransferLogsAsync(issueNote, route));
// } private async Task AddTransferLogsAsync(List<TransferLogEditInput> inputList)
{
// await TransferLogAppService.AddManyAsync(transferLogs); var transferLogs = new List<TransferLogEditInput>();
// }
transferLogs.AddRange(inputList);
// [UnitOfWork] await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false);
// public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<IssueNote> eventData) }
// {
// var entity = eventData.Entity; private async Task<List<TransferLogEditInput>> BuildTransferLogsAsync(IssueNote issueNote, EnumTransferRoute route)
{
// var inputList = await BuildTransferLogsAsync(entity, EnumTransferRoute.OnTheWayToDestination); var transferLogs = new List<TransferLogEditInput>();
// await AddTransferLogsAsync(inputList); foreach (var detail in issueNote.Details.Where(detail => detail.Qty != 0))
// } {
var transferLog = ObjectMapper.Map<IssueNoteDetail, TransferLogEditInput>(detail);
// private async Task AddTransferLogsAsync(List<TransferLogCreateInput> inputList)
// { if (issueNote.UseOnTheWayLocation)
// var transferLogs = new List<TransferLogCreateInput>(); {
var location = await LocationAclService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false);
// transferLogs.AddRange(inputList); switch (route)
{
// await TransferLogAppService.AddManyAsync(transferLogs); case EnumTransferRoute.SourceToOnTheWay:
detail.ToLocationCode = detail.OnTheWayLocationCode;
// } detail.ToLocationErpCode = location.ErpLocationCode;
detail.ToWarehouseCode = location.WarehouseCode;
// private async Task<List<TransferLogCreateInput>> BuildTransferLogsAsync(IssueNote issueNote, EnumTransferRoute route) detail.ToLocationArea = location.AreaCode;
// { break;
// var transferLogs = new List<TransferLogCreateInput>(); case EnumTransferRoute.OnTheWayToDestination:
// foreach (var detail in issueNote.Details.Where(detail => detail.Qty.Qty != 0)) detail.FromLocationCode = detail.OnTheWayLocationCode;
// { detail.FromLocationErpCode = location.ErpLocationCode;
// var transferLog = ObjectMapper.Map<IssueNoteDetail, TransferLogCreateInput>(detail); detail.FromWarehouseCode = location.WarehouseCode;
detail.FromLocationArea = location.AreaCode;
// LocationDTO fromLocationDTO = null; break;
// LocationDTO toLocationDTO = null; case EnumTransferRoute.SourceToDestination:
default:
// if (issueNote.UseOnTheWayLocation) throw new ArgumentOutOfRangeException(nameof(route), route, null);
// { }
// var location = await LocationAppService.GetByCodeAsync(detail.OnTheWayLocationCode); }
// switch (route)
// { if (issueNote.UseOnTheWayLocation)
// case EnumTransferRoute.SourceToOnTheWay: {
// fromLocationDTO = await LocationAppService.GetByCodeAsync(detail.FromLocationCode); transferLog.FromLocationCode = detail.OnTheWayLocationCode;
var location = await LocationAclService.GetByCodeAsync(detail.OnTheWayLocationCode).ConfigureAwait(false);
// toLocationDTO = await LocationAppService.GetByCodeAsync(detail.OnTheWayLocationCode); transferLog.FromLocationGroup = location.LocationGroupCode;
// break; transferLog.FromLocationArea = location.AreaCode;
// case EnumTransferRoute.OnTheWayToDestination: transferLog.FromLocationErpCode = location.ErpLocationCode;
// fromLocationDTO = await LocationAppService.GetByCodeAsync(detail.OnTheWayLocationCode); transferLog.FromWarehouseCode=location.WarehouseCode;
}
// toLocationDTO = await LocationAppService.GetByCodeAsync(detail.ToLocationCode);
transferLog.TransType = TransType;
// await RemovePackingCodeAndContainerCodeAndLotAsync(transferLog); transferLog.TransSubType = Enum.Parse<EnumTransSubType>(issueNote.RequestType);
// break; transferLog.Worker = issueNote.Worker;
// case EnumTransferRoute.SourceToDestination: transferLog.DocNumber = issueNote.Number;
// default: transferLog.JobNumber = issueNote.JobNumber;
// throw new ArgumentOutOfRangeException(nameof(route), route, null);
// } transferLogs.Add(transferLog);
// } }
// else
// { return transferLogs;
// 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 = "";
// }
//}
} }

Loading…
Cancel
Save