Browse Source

修改 注塑发料

dev_DY_CC
郑勃旭 1 year ago
parent
commit
e177d9136e
  1. 58
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/IssueJobs/InjectionJobs/InjectionJobManager.cs
  2. 8
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Jobs/IssueJobs/InjectionJobs/InjectionJobDbContextModelCreatingExtensions.cs
  3. 38
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/InjectionNoteAutoMapperProfile.cs
  4. 28
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InjectionJobEventHandler.cs
  5. 88
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/InjectionNoteEventHandler.cs

58
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Jobs/IssueJobs/InjectionJobs/InjectionJobManager.cs

@ -33,33 +33,37 @@ public class InjectionJobManager : SfsJobManagerBase<InjectionJob, InjectionJobD
var inputDetail = input.Details.First(); var inputDetail = input.Details.First();
var detail = entity.Details.First(); var detail = entity.Details.First();
detail.HandledFromArriveDate = inputDetail.RecommendFromArriveDate; detail.HandledFromArriveDate = inputDetail.HandledFromArriveDate;
detail.HandledFromContainerCode = inputDetail.RecommendFromContainerCode; detail.HandledFromContainerCode = inputDetail.HandledFromContainerCode;
detail.HandledFromExpireDate = inputDetail.RecommendFromExpireDate; detail.HandledFromExpireDate = inputDetail.HandledFromExpireDate;
detail.HandledFromLocationArea = inputDetail.RecommendFromLocationArea; detail.HandledFromLocationArea = inputDetail.HandledFromLocationArea;
detail.HandledFromLocationCode = inputDetail.RecommendFromLocationCode; detail.HandledFromLocationCode = inputDetail.HandledFromLocationCode;
detail.HandledFromLocationErpCode = inputDetail.RecommendFromLocationErpCode; detail.HandledFromLocationErpCode = inputDetail.HandledFromLocationErpCode;
detail.HandledFromLocationGroup = inputDetail.RecommendFromLocationGroup; detail.HandledFromLocationGroup = inputDetail.HandledFromLocationGroup;
detail.HandledFromLot = inputDetail.RecommendFromLot; detail.HandledFromLot = inputDetail.HandledFromLot;
detail.HandledFromPackingCode = inputDetail.RecommendFromPackingCode; detail.HandledFromPackingCode = inputDetail.HandledFromPackingCode;
detail.HandledFromProduceDate = inputDetail.RecommendFromProduceDate; detail.HandledFromProduceDate = inputDetail.HandledFromProduceDate;
detail.HandledFromQty = inputDetail.RecommendFromQty; detail.HandledFromQty = inputDetail.HandledFromQty;
detail.HandledFromSupplierBatch = inputDetail.RecommendFromSupplierBatch; detail.HandledFromSupplierBatch = inputDetail.HandledFromSupplierBatch;
detail.HandledFromWarehouseCode = inputDetail.RecommendFromWarehouseCode; detail.HandledFromWarehouseCode = inputDetail.HandledFromWarehouseCode;
detail.HandledToArriveDate = inputDetail.RecommendToArriveDate; detail.HandledToArriveDate = inputDetail.HandledToArriveDate;
detail.HandledToContainerCode = inputDetail.RecommendToContainerCode; detail.HandledToContainerCode = inputDetail.HandledToContainerCode;
detail.HandledToExpireDate = inputDetail.RecommendToExpireDate; detail.HandledToExpireDate = inputDetail.HandledToExpireDate;
detail.HandledToLocationArea = inputDetail.RecommendToLocationArea; detail.HandledToLocationArea = inputDetail.HandledToLocationArea;
detail.HandledToLocationCode = inputDetail.RecommendToLocationCode; detail.HandledToLocationCode = inputDetail.HandledToLocationCode;
detail.HandledToLocationErpCode = inputDetail.RecommendToLocationErpCode; detail.HandledToLocationErpCode = inputDetail.HandledToLocationErpCode;
detail.HandledToLocationGroup = inputDetail.RecommendToLocationGroup; detail.HandledToLocationGroup = inputDetail.HandledToLocationGroup;
detail.HandledToLot = inputDetail.RecommendToLot; detail.HandledToLot = inputDetail.HandledToLot;
detail.HandledToPackingCode = inputDetail.RecommendToPackingCode; detail.HandledToPackingCode = inputDetail.HandledToPackingCode;
detail.HandledToProduceDate = inputDetail.RecommendToProduceDate; detail.HandledToProduceDate = inputDetail.HandledToProduceDate;
detail.HandledToQty = inputDetail.RecommendToQty; detail.HandledToQty = inputDetail.HandledToQty;
detail.HandledToSupplierBatch = inputDetail.RecommendToSupplierBatch; detail.HandledToSupplierBatch = inputDetail.HandledToSupplierBatch;
detail.HandledToWarehouseCode = inputDetail.RecommendToWarehouseCode; detail.HandledToWarehouseCode = inputDetail.HandledToWarehouseCode;
detail.HandledToPackingCode = string.Empty;
detail.HandledToLot = string.Empty;
detail.HandledToContainerCode = string.Empty;
return await base.CompleteAsync(entity, user).ConfigureAwait(false); return await base.CompleteAsync(entity, user).ConfigureAwait(false);
} }

8
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Jobs/IssueJobs/InjectionJobs/InjectionJobDbContextModelCreatingExtensions.cs

@ -24,6 +24,8 @@ public static class InjectionJobDbContextModelCreatingExtensions
b.Property(q => q.RequestType).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.RequestType).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.InjectionRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.InjectionRequestNumber).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.JobType).HasConversion<string>();
b.Property(q => q.JobStatus).HasConversion<string>();
//Relations //Relations
b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired(); b.HasMany(q => q.Details).WithOne().HasForeignKey(d => d.MasterID).IsRequired();
//Indexes //Indexes
@ -46,8 +48,10 @@ public static class InjectionJobDbContextModelCreatingExtensions
b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.OnTheWayLocationCode).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.OnTheWayLocationCode).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.PositionCode).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.PositionCode).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.RecommendType).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.OnTheWayLocationCode).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.PositionCode).HasMaxLength(SfsPropertyConst.CodeLength).IsRequired(false);
b.Property(q => q.RecommendType).HasMaxLength(SfsPropertyConst.CodeLength).HasConversion<string>();
b.Property(q => q.Status).IsRequired().HasMaxLength(SfsPropertyConst.NameLength).HasConversion<string>();
//Relations //Relations
//None //None

38
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/AutoMapperProfiles/Notes/InjectionNoteAutoMapperProfile.cs

@ -9,7 +9,43 @@ public partial class StoreEventAutoMapperProfile : Profile
{ {
private void InjectionNoteAutoMapperProfile() private void InjectionNoteAutoMapperProfile()
{ {
CreateMap<InjectionNoteDetail, TransferLogEditInput>()
.Ignore(x => x.DocNumber)
.Ignore(x => x.JobNumber)
.Ignore(x => x.Worker)
.Ignore(x => x.TransType)
.Ignore(x => x.ExtraProperties)
.Ignore(x => x.TransSubType)
} .ForMember(x => x.Qty, y => y.MapFrom(t => t.HandledToQty))
.ForMember(x => x.SupplierBatch, y => y.MapFrom(t => t.HandledFromSupplierBatch))
.ForMember(x => x.ArriveDate, y => y.MapFrom(t => t.HandledFromArriveDate))
.ForMember(x => x.ProduceDate, y => y.MapFrom(t => t.HandledFromProduceDate))
.ForMember(x => x.ExpireDate, y => y.MapFrom(t => t.HandledFromExpireDate))
.ForMember(x => x.FromPackingCode, y => y.MapFrom(t => t.HandledFromPackingCode))
.ForMember(x => x.FromContainerCode, y => y.MapFrom(t => t.HandledFromContainerCode))
.ForMember(x => x.FromLot, y => y.MapFrom(t => t.HandledFromLot))
.ForMember(x => x.FromStatus, y => y.MapFrom(t => t.Status))
.ForMember(x => x.FromLocationCode, y => y.MapFrom(t => t.HandledFromLocationCode))
.ForMember(x => x.FromLocationGroup, y => y.MapFrom(t => t.HandledFromLocationGroup))
.ForMember(x => x.FromLocationArea, y => y.MapFrom(t => t.HandledFromLocationArea))
.ForMember(x => x.FromLocationErpCode, y => y.MapFrom(t => t.HandledFromLocationErpCode))
.ForMember(x => x.FromWarehouseCode, y => y.MapFrom(t => t.HandledFromWarehouseCode))
.ForMember(x => x.ToLot, y => y.MapFrom(t => t.HandledToLot))
.ForMember(x => x.ToStatus, y => y.MapFrom(t => t.Status))
.ForMember(x => x.ToPackingCode, y => y.MapFrom(t => t.HandledToPackingCode))
.ForMember(x => x.ToContainerCode, y => y.MapFrom(t => t.HandledToContainerCode))
.ForMember(x => x.ToLocationCode, y => y.MapFrom(t => t.HandledToLocationCode))
.ForMember(x => x.ToLocationGroup, y => y.MapFrom(t => t.HandledToLocationGroup))
.ForMember(x => x.ToLocationArea, y => y.MapFrom(t => t.HandledToLocationArea))
.ForMember(x => x.ToLocationErpCode, y => y.MapFrom(t => t.HandledToLocationErpCode))
.ForMember(x => x.ToWarehouseCode, y => y.MapFrom(t => t.HandledToWarehouseCode))
;
}
} }

28
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Jobs/InjectionJobEventHandler.cs

@ -9,7 +9,6 @@ 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.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;
namespace Win_in.Sfs.Wms.Store.Event.BusinessJob; namespace Win_in.Sfs.Wms.Store.Event.BusinessJob;
@ -19,20 +18,16 @@ public class InjectionJobEventHandler :
, ILocalEventHandler<SfsCreatedEntityEventData<InjectionJob>> , ILocalEventHandler<SfsCreatedEntityEventData<InjectionJob>>
, ILocalEventHandler<SfsCreatedEntityEventData<List<InjectionJob>>> , ILocalEventHandler<SfsCreatedEntityEventData<List<InjectionJob>>>
{ {
private const EnumTransType TransType = EnumTransType.Issue;
private readonly IInjectionNoteAppService _injectionNoteAppService; private readonly IInjectionNoteAppService _injectionNoteAppService;
private readonly IBalanceAppService _balanceAppService;
private readonly IExpectOutAppService _expectOutAppService; private readonly IExpectOutAppService _expectOutAppService;
private readonly ILocationAppService _locationAppService; private readonly ILocationAppService _locationAppService;
private readonly ITransferLibRequestAppService _transferLibRequestAppService; private readonly ITransferLibRequestAppService _transferLibRequestAppService;
public InjectionJobEventHandler(IInjectionNoteAppService injectionNoteAppService, public InjectionJobEventHandler(IInjectionNoteAppService injectionNoteAppService,
IBalanceAppService balanceAppService, IExpectOutAppService expectOutAppService, IExpectOutAppService expectOutAppService,
ILocationAppService locationAppService, ITransferLibRequestAppService transferLibRequestAppService) ILocationAppService locationAppService, ITransferLibRequestAppService transferLibRequestAppService)
{ {
_injectionNoteAppService = injectionNoteAppService; _injectionNoteAppService = injectionNoteAppService;
_balanceAppService = balanceAppService;
_expectOutAppService = expectOutAppService; _expectOutAppService = expectOutAppService;
_locationAppService = locationAppService; _locationAppService = locationAppService;
_transferLibRequestAppService = transferLibRequestAppService; _transferLibRequestAppService = transferLibRequestAppService;
@ -99,7 +94,7 @@ public class InjectionJobEventHandler :
inputoExpectOutEditInput.ItemCode = detail.ItemCode; inputoExpectOutEditInput.ItemCode = detail.ItemCode;
inputoExpectOutEditInput.Qty = detail.RecommendFromQty; inputoExpectOutEditInput.Qty = detail.RecommendFromQty;
inputoExpectOutEditInput.LocationCode = detail.RecommendFromLocationCode; inputoExpectOutEditInput.LocationCode = detail.RecommendFromLocationCode;
inputoExpectOutEditInput.ArriveDate =detail.RecommendFromArriveDate; inputoExpectOutEditInput.ArriveDate = detail.RecommendFromArriveDate;
inputoExpectOutEditInput.ContainerCode = detail.RecommendFromContainerCode; inputoExpectOutEditInput.ContainerCode = detail.RecommendFromContainerCode;
inputoExpectOutEditInput.ExpireDate = detail.RecommendFromExpireDate; inputoExpectOutEditInput.ExpireDate = detail.RecommendFromExpireDate;
inputoExpectOutEditInput.ItemDesc1 = detail.ItemDesc1; inputoExpectOutEditInput.ItemDesc1 = detail.ItemDesc1;
@ -199,22 +194,9 @@ public class InjectionJobEventHandler :
private async Task<InjectionNoteEditInput> BuildInjectionNoteAsync(InjectionJob entity) private async Task<InjectionNoteEditInput> BuildInjectionNoteAsync(InjectionJob entity)
{ {
var injectionNoteCreateInput = ObjectMapper.Map<InjectionJob, InjectionNoteEditInput>(entity); var injectionNoteCreateInput = ObjectMapper.Map<InjectionJob, InjectionNoteEditInput>(entity);
//injectionNoteCreateInput.JobNumber = entity.Number; injectionNoteCreateInput.JobNumber = entity.Number;
//var locationCodes = injectionNoteCreateInput.Details.Select(p => p.ToLocationCode).Distinct().ToList();
//var locations = await _locationAppService.GetByCodesAsync(locationCodes).ConfigureAwait(false); await Task.CompletedTask.ConfigureAwait(false);
//injectionNoteCreateInput.Details.RemoveAll(p => p.Qty == 0);
//foreach (var detail in injectionNoteCreateInput.Details)
//{
// var location = locations.First(p => p.Code == detail.ToLocationCode);
// await RemovePackingCodeAndContainerCodeAndLotAsync(detail, location.Type).ConfigureAwait(false); //去箱 去托 去批
// detail.ToLocationArea = location.AreaCode;
// detail.ToLocationGroup = location.LocationGroupCode;
// detail.ToLocationErpCode = location.ErpLocationCode;
// detail.ToWarehouseCode = location.WarehouseCode;
//}
return injectionNoteCreateInput; return injectionNoteCreateInput;
} }

88
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Transactions/InjectionNoteEventHandler.cs

@ -0,0 +1,88 @@
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.Domain;
using Win_in.Sfs.Wms.Store.Event.Transaction;
namespace Win_in.Sfs.Wms.Store.Event.Transactions;
public class InjectionNoteEventHandler
: StoreInventoryEventHandlerBase
, ILocalEventHandler<SfsCreatedEntityEventData<InjectionNote>>
, ILocalEventHandler<SfsCreatedEntityEventData<List<InjectionNote>>>
, ILocalEventHandler<SfsConfirmedEntityEventData<InjectionNote>>
{
private const EnumTransType TransType = EnumTransType.Issue;
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<InjectionNote> eventData)
{
var entity = eventData.Entity;
var transferLogs = new List<TransferLogEditInput>();
var route = entity.UseOnTheWayLocation
? EnumTransferRoute.SourceToOnTheWay
: EnumTransferRoute.SourceToDestination;
transferLogs.AddRange(await BuildTransferLogsAsync(entity).ConfigureAwait(false));
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false);
}
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<InjectionNote>> eventData)
{
var entities = eventData.Entity;
var transferLogs = new List<TransferLogEditInput>();
//如果要做库存事务汇总,可以修改此处
foreach (var issueNote in entities)
{
transferLogs.AddRange(await BuildTransferLogsAsync(issueNote).ConfigureAwait(false));
}
await TransferLogAppService.AddManyAsync(transferLogs).ConfigureAwait(false);
}
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsConfirmedEntityEventData<InjectionNote> eventData)
{
var entity = eventData.Entity;
var inputList = await BuildTransferLogsAsync(entity)
.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(InjectionNote issueNote)
{
var transferLogs = new List<TransferLogEditInput>();
foreach (var detail in issueNote.Details.Where(detail => detail.HandledToQty != 0))
{
var transferLog = ObjectMapper.Map<InjectionNoteDetail, TransferLogEditInput>(detail);
transferLog.TransSubType = EnumTransSubType.Issue_WIP;
transferLog.TransType = TransType;
transferLog.DocNumber = issueNote.Number;
transferLog.JobNumber = issueNote.JobNumber;
transferLogs.Add(transferLog);
}
await Task.CompletedTask.ConfigureAwait(false);
return transferLogs;
}
}
Loading…
Cancel
Save