30 changed files with 545 additions and 134 deletions
@ -0,0 +1,44 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Application.Contracts; |
||||
|
public class ProductRecycleJobMaterialDetailDto : EntityDto |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 零件代码
|
||||
|
/// </summary>
|
||||
|
public string ItemCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 数量
|
||||
|
/// </summary>
|
||||
|
public decimal Qty { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 库位代码
|
||||
|
/// </summary>
|
||||
|
public string LocationCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 库区
|
||||
|
/// </summary>
|
||||
|
public string LocationArea { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 库位组
|
||||
|
/// </summary>
|
||||
|
public string LocationGroup { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// ERP库位代码
|
||||
|
/// </summary>
|
||||
|
public string LocationErpCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 仓库代码
|
||||
|
/// </summary>
|
||||
|
public string WarehouseCode { get; set; } |
||||
|
} |
@ -1,10 +1,12 @@ |
|||||
using System; |
using System; |
||||
using System.Linq.Expressions; |
using System.Linq.Expressions; |
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
namespace Win_in.Sfs.Wms.Store.Domain; |
namespace Win_in.Sfs.Wms.Store.Domain; |
||||
|
|
||||
public interface IProductRecycleJobManager : IJobManager<ProductRecycleJob> |
public interface IProductRecycleJobManager : IJobManager<ProductRecycleJob> |
||||
{ |
{ |
||||
|
Task<ProductRecycleJob> CompleteAsync(ProductRecycleJob entityinput, ProductRecycleJob entity, ICurrentUser user); |
||||
Task<ProductRecycleJob> GetAsync(Expression<Func<ProductRecycleJob, bool>> expression); |
Task<ProductRecycleJob> GetAsync(Expression<Func<ProductRecycleJob, bool>> expression); |
||||
} |
} |
||||
|
@ -0,0 +1,45 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Jobs.ProductRecycleJobs; |
||||
|
public class ProductRecycleJobMaterialDetail |
||||
|
{ |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 零件代码
|
||||
|
/// </summary>
|
||||
|
public string ItemCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 数量
|
||||
|
/// </summary>
|
||||
|
public decimal Qty { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 库位代码
|
||||
|
/// </summary>
|
||||
|
public string LocationCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 库区
|
||||
|
/// </summary>
|
||||
|
public string LocationArea { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 库位组
|
||||
|
/// </summary>
|
||||
|
public string LocationGroup { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// ERP库位代码
|
||||
|
/// </summary>
|
||||
|
public string LocationErpCode { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 仓库代码
|
||||
|
/// </summary>
|
||||
|
public string WarehouseCode { get; set; } |
||||
|
|
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
using System; |
||||
|
using AutoMapper; |
||||
|
using Volo.Abp.AutoMapper; |
||||
|
using Win_in.Sfs.Shared.Application; |
||||
|
using Win_in.Sfs.Shared.Domain.Shared; |
||||
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
||||
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Event; |
||||
|
public partial class StoreEventAutoMapperProfile : Profile |
||||
|
{ |
||||
|
private void ProductRecycleJobAutoMapperProfile() |
||||
|
{ |
||||
|
CreateMap<ProductRecycleJob, ProductRecycleNoteEditInput>() |
||||
|
.ForMember(x => x.JobNumber, y => y.MapFrom(d => d.Number)) |
||||
|
.ForMember(x => x.RecycleTime, y => y.MapFrom(d => d.CompleteTime)) |
||||
|
.ForMember(x => x.ActiveDate, y => y.MapFrom(d => DateTime.Now)) |
||||
|
.Ignore(x => x.MaterialDetails) |
||||
|
; |
||||
|
|
||||
|
CreateMap<ProductRecycleJobDetail, ProductRecycleNoteDetailInput>() |
||||
|
.Ignore(x => x.StdPackQty) |
||||
|
.Ignore(x => x.ContainerCode) |
||||
|
.Ignore(x => x.PackingCode) |
||||
|
.Ignore(x => x.SupplierBatch) |
||||
|
.Ignore(x => x.ArriveDate) |
||||
|
.Ignore(x => x.ProduceDate) |
||||
|
.Ignore(x => x.ExpireDate) |
||||
|
.Ignore(x => x.Lot) |
||||
|
.Ignore(x => x.ReasonCode) |
||||
|
.AfterMap((x, y) => y.Lot = string.Empty) |
||||
|
.AfterMap((x, y) => y.PackingCode = string.Empty) |
||||
|
; |
||||
|
CreateMap<ProductRecycleJobDetail, ExpectOutEditInput>() |
||||
|
.MapExpectInOutTo() |
||||
|
.Ignore(x => x.SerialNumber) |
||||
|
.Ignore(x => x.Worker) |
||||
|
.Ignore(x => x.ExtraProperties) |
||||
|
; |
||||
|
CreateMap<ProductRecycleJobDetail, ExpectInEditInput>() |
||||
|
.MapExpectInOutTo() |
||||
|
.ForMember(x => x.LocationCode, y => y.MapFrom(d => d.RecommendToLocationCode)) |
||||
|
.ForMember(x => x.LocationArea, y => y.MapFrom(d => d.RecommendToLocationArea)) |
||||
|
.ForMember(x => x.LocationGroup, y => y.MapFrom(d => d.RecommendToLocationGroup)) |
||||
|
.ForMember(x => x.LocationErpCode, y => y.MapFrom(d => d.RecommendToLocationErpCode)) |
||||
|
.ForMember(x => x.WarehouseCode, y => y.MapFrom(d => d.RecommendToWarehouseCode)) |
||||
|
.Ignore(x => x.SerialNumber) |
||||
|
.Ignore(x => x.Worker) |
||||
|
.Ignore(x => x.ExtraProperties); |
||||
|
} |
||||
|
} |
@ -0,0 +1,80 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.EventBus; |
||||
|
using Volo.Abp.Uow; |
||||
|
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.Inventories; |
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Event.ExpectInOuts; |
||||
|
|
||||
|
public class ProductRecycleJobEventHandler : |
||||
|
StoreExpectInOutEventHandlerBase |
||||
|
, ILocalEventHandler<SfsCreatedEntityEventData<ProductRecycleJob>> |
||||
|
, ILocalEventHandler<SfsCreatedEntityEventData<List<ProductRecycleJob>>> |
||||
|
, ILocalEventHandler<SfsCompletedEntityEventData<ProductRecycleJob>> |
||||
|
, ILocalEventHandler<SfsCancelledEntityEventData<ProductRecycleJob>> |
||||
|
{ |
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<ProductRecycleJob> eventData) |
||||
|
{ |
||||
|
var entity = eventData.Entity; |
||||
|
|
||||
|
if (!entity.IsAutoComplete) |
||||
|
{ |
||||
|
await AddExpectOutsAsync(new List<ProductRecycleJob>() { entity }).ConfigureAwait(false); |
||||
|
} |
||||
|
} |
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<List<ProductRecycleJob>> eventData) |
||||
|
{ |
||||
|
var entities = eventData.Entity; |
||||
|
foreach (var entity in entities) |
||||
|
{ |
||||
|
await AddExpectOutsAsync(new List<ProductRecycleJob>() { entity }).ConfigureAwait(false); |
||||
|
} |
||||
|
} |
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCompletedEntityEventData<ProductRecycleJob> eventData) |
||||
|
{ |
||||
|
var entity = eventData.Entity; |
||||
|
|
||||
|
await ExpectOutAppService.RemoveAsync(entity.Number).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCancelledEntityEventData<ProductRecycleJob> eventData) |
||||
|
{ |
||||
|
var entity = eventData.Entity; |
||||
|
|
||||
|
await ExpectOutAppService.RemoveAsync(entity.Number).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
private async Task AddExpectOutsAsync(List<ProductRecycleJob> entities) |
||||
|
{ |
||||
|
var expectOuts = new List<ExpectOutEditInput>(); |
||||
|
foreach (var entity in entities) |
||||
|
{ |
||||
|
var entityExpectOuts = BuildExpectOutInventoryAsync(entity); |
||||
|
expectOuts.AddRange(entityExpectOuts); |
||||
|
} |
||||
|
await ExpectOutAppService.AddManyAsync(expectOuts).ConfigureAwait(false); |
||||
|
} |
||||
|
|
||||
|
private List<ExpectOutEditInput> BuildExpectOutInventoryAsync(ProductRecycleJob purchaseReturnJob) |
||||
|
{ |
||||
|
var inputs = ObjectMapper.Map<List<ProductRecycleJobDetail>, List<ExpectOutEditInput>>(purchaseReturnJob.Details); |
||||
|
foreach (var input in inputs) |
||||
|
{ |
||||
|
input.WarehouseCode = purchaseReturnJob.WarehouseCode; |
||||
|
input.Worker = purchaseReturnJob.Worker; |
||||
|
input.JobNumber = purchaseReturnJob.Number; |
||||
|
} |
||||
|
|
||||
|
return inputs; |
||||
|
} |
||||
|
} |
@ -0,0 +1,129 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
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.Shared; |
||||
|
using Win_in.Sfs.Shared.Event; |
||||
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
||||
|
using Win_in.Sfs.Wms.Store.Domain; |
||||
|
using Win_in.Sfs.Wms.Store.Jobs.ProductRecycleJobs; |
||||
|
|
||||
|
|
||||
|
namespace Win_in.Sfs.Wms.Store.Event.BusinessJob; |
||||
|
|
||||
|
|
||||
|
public class ProductRecycleJobEventHandler : |
||||
|
StoreEventHandlerBase |
||||
|
, ILocalEventHandler<SfsCreatedEntityEventData<ProductRecycleJob>> |
||||
|
, ILocalEventHandler<SfsCompletedEntityEventData<ProductRecycleJob>> |
||||
|
{ |
||||
|
private readonly IProductRecycleNoteAppService _productRecycleNoteAppService; |
||||
|
private readonly IBomAppService _bomApp; |
||||
|
public ProductRecycleJobEventHandler( |
||||
|
IProductRecycleNoteAppService productRecycleNoteAppService, |
||||
|
IBomAppService bomApp |
||||
|
) |
||||
|
{ |
||||
|
_productRecycleNoteAppService = productRecycleNoteAppService; |
||||
|
_bomApp=bomApp; |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<ProductRecycleJob> eventData) |
||||
|
{ |
||||
|
var entity = eventData.Entity; |
||||
|
|
||||
|
if (entity.IsAutoComplete) |
||||
|
{ |
||||
|
entity.CompleteTime = Clock.Now; |
||||
|
entity.JobStatus = EnumJobStatus.Done; |
||||
|
|
||||
|
foreach (var detail in eventData.Entity.Details) |
||||
|
{ |
||||
|
detail.SetHandledFromRecommend(); |
||||
|
} |
||||
|
|
||||
|
var note = await BuildProductRecycleNoteAsync(entity).ConfigureAwait(false); |
||||
|
await _productRecycleNoteAppService.CreateAsync(note).ConfigureAwait(false); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task HandleEventAsync(SfsCompletedEntityEventData<ProductRecycleJob> eventData) |
||||
|
{ |
||||
|
var entity = eventData.Entity; |
||||
|
|
||||
|
var ProductRecycleNote = await BuildProductRecycleNoteAsync(entity).ConfigureAwait(false); |
||||
|
var dto= await _productRecycleNoteAppService.CreateAsync(ProductRecycleNote).ConfigureAwait(false); |
||||
|
eventData.Entity.Remark = dto.Number;//返给前台记录用于下载记录excle
|
||||
|
} |
||||
|
private async Task<ProductRecycleNoteEditInput> BuildProductRecycleNoteAsync(ProductRecycleJob job) |
||||
|
{ |
||||
|
var createInput = ObjectMapper.Map<ProductRecycleJob, ProductRecycleNoteEditInput>(job); |
||||
|
|
||||
|
createInput.MaterialDetails = await BuildMaterialDetailsAsync(job).ConfigureAwait(false); |
||||
|
|
||||
|
return createInput; |
||||
|
} |
||||
|
|
||||
|
private async Task<List<ProductRecycleMaterialDetailInput>> BuildMaterialDetailsAsync(ProductRecycleJob request) |
||||
|
{ |
||||
|
var materialDetailInputs = new List<ProductRecycleMaterialDetailInput>(); |
||||
|
foreach (var detail in request.Details) |
||||
|
{ |
||||
|
var materialdetails = detail.MaterialDetails; |
||||
|
var componentItemCode = materialdetails.Select(p => p.ItemCode).Distinct().ToList(); |
||||
|
var items = await ItemBasicAclService.GetByCodesAsync(componentItemCode).ConfigureAwait(false); |
||||
|
|
||||
|
foreach (var materialdetail in materialdetails) |
||||
|
{ |
||||
|
var item = items.FirstOrDefault(p => p.Code == materialdetail.ItemCode); |
||||
|
var detailInput = BuildMaterialDetailInput(materialdetail, item, detail); |
||||
|
|
||||
|
materialDetailInputs.Add(detailInput); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return materialDetailInputs; |
||||
|
} |
||||
|
|
||||
|
private static ProductRecycleMaterialDetailInput BuildMaterialDetailInput(ProductRecycleJobMaterialDetail materialdetail, ItemBasicDTO item, |
||||
|
ProductRecycleJobDetail detail) |
||||
|
{ |
||||
|
var detailInput = new ProductRecycleMaterialDetailInput |
||||
|
{ |
||||
|
ProductPackingCode = string.Empty, |
||||
|
ProductItemCode = detail.ItemCode, |
||||
|
ProductItemName = detail.ItemName, |
||||
|
ProductItemDesc1 = detail.ItemDesc1, |
||||
|
ProductItemDesc2 = detail.ItemDesc2, |
||||
|
ProductLot = string.Empty, |
||||
|
PackingCode = string.Empty, |
||||
|
ItemCode = materialdetail.ItemCode, |
||||
|
Qty = materialdetail.Qty , |
||||
|
Uom = detail.Uom, |
||||
|
BomVersion = detail.BomVersion, |
||||
|
LocationCode = materialdetail.LocationCode, |
||||
|
LocationErpCode = materialdetail.LocationErpCode, |
||||
|
WarehouseCode = materialdetail.WarehouseCode, |
||||
|
Lot = string.Empty, |
||||
|
Status = EnumInventoryStatus.OK, |
||||
|
LocationArea = materialdetail.LocationArea, |
||||
|
LocationGroup = materialdetail.LocationGroup, |
||||
|
}; |
||||
|
|
||||
|
if (item != null) |
||||
|
{ |
||||
|
detailInput.ItemName = item.Name; |
||||
|
detailInput.ItemDesc1 = item.Desc1; |
||||
|
detailInput.ItemDesc2 = item.Desc2; |
||||
|
detailInput.StdPackQty = item.StdPackQty; |
||||
|
} |
||||
|
|
||||
|
return detailInput; |
||||
|
} |
||||
|
} |
@ -1,75 +0,0 @@ |
|||||
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.Store.Application.Contracts; |
|
||||
using Win_in.Sfs.Wms.Store.Domain; |
|
||||
|
|
||||
namespace Win_in.Sfs.Wms.Store.Event.BusinessJob; |
|
||||
|
|
||||
|
|
||||
public class ProductionRecycleJobEventHandler : |
|
||||
StoreEventHandlerBase |
|
||||
, ILocalEventHandler<SfsCreatedEntityEventData<ProductRecycleJob>> |
|
||||
, ILocalEventHandler<SfsCompletedEntityEventData<ProductRecycleJob>> |
|
||||
{ |
|
||||
private readonly IProductRecycleNoteAppService _productRecycleNoteAppService; |
|
||||
|
|
||||
public ProductionRecycleJobEventHandler( |
|
||||
IProductRecycleNoteAppService productRecycleNoteAppService |
|
||||
) |
|
||||
{ |
|
||||
_productRecycleNoteAppService = productRecycleNoteAppService; |
|
||||
} |
|
||||
|
|
||||
[UnitOfWork] |
|
||||
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<ProductRecycleJob> eventData) |
|
||||
{ |
|
||||
var entity = eventData.Entity; |
|
||||
|
|
||||
if (entity.IsAutoComplete) |
|
||||
{ |
|
||||
entity.CompleteTime = Clock.Now; |
|
||||
entity.JobStatus = EnumJobStatus.Done; |
|
||||
|
|
||||
foreach (var detail in eventData.Entity.Details) |
|
||||
{ |
|
||||
detail.SetHandledFromRecommend(); |
|
||||
} |
|
||||
|
|
||||
var note = BuildProductionReturnNote(entity); |
|
||||
await _productRecycleNoteAppService.CreateAsync(note).ConfigureAwait(false); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
[UnitOfWork] |
|
||||
public virtual async Task HandleEventAsync(SfsCompletedEntityEventData<ProductRecycleJob> eventData) |
|
||||
{ |
|
||||
var entity = eventData.Entity; |
|
||||
|
|
||||
var productRecycleNote = BuildProductionReturnNote(entity); |
|
||||
await _productRecycleNoteAppService.CreateAsync(productRecycleNote).ConfigureAwait(false); |
|
||||
|
|
||||
} |
|
||||
|
|
||||
private ProductRecycleNoteEditInput BuildProductionReturnNote(ProductRecycleJob entity) |
|
||||
{ |
|
||||
var input = ObjectMapper.Map<ProductRecycleJob, ProductRecycleNoteEditInput>(entity); |
|
||||
|
|
||||
|
|
||||
input.Details = new List<ProductRecycleNoteDetailInput>(); |
|
||||
|
|
||||
foreach (var detail in entity.Details.Where(detail => detail.HandledQty != 0)) |
|
||||
{ |
|
||||
var inputDetail = ObjectMapper.Map<ProductRecycleJobDetail, ProductRecycleNoteDetailInput>(detail); |
|
||||
|
|
||||
input.Details.Add(inputDetail); |
|
||||
} |
|
||||
|
|
||||
return input; |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue