Browse Source

修改 完工缴库 线边缴库

集成Redis
郑渤旭[Irelia] 2 years ago
parent
commit
6afde1379d
  1. 2
      be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql
  2. 4
      be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/EnumProductReceiptType.cs
  3. 226
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ProductReceiptRequests/ProductReceiptRequestAppService.cs
  4. 75
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/ProductReceiptNotes/ProductReceiptNoteManager.cs
  5. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ProductReceiptRequests/ProductReceiptRequestDbContextModelCreatingExtensions.cs
  6. 1
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestDbContextModelCreatingExtensions.cs
  7. 4
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/InspectRequestEventHandler.cs
  8. 18
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/Note/ProductReceiptNoteEventHandler.cs
  9. 50
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductReceiptRequestEventHandler.cs

2
be/Hosts/Wms.Host/Win_in.Sfs.Wms.Store.HttpApi.Host/scripts/db.Microsoft.EntityFrameworkCore.SqlServer.StoreDbContext.sql

@ -1281,7 +1281,7 @@ CREATE TABLE [Store_ProductReceiptRequest] (
[Shift] nvarchar(64) NULL, [Shift] nvarchar(64) NULL,
[Team] nvarchar(64) NULL, [Team] nvarchar(64) NULL,
[PlanDate] datetime2 NOT NULL, [PlanDate] datetime2 NOT NULL,
[Type] nvarchar(64) NULL, [Type] nvarchar(64) NOT NULL,
[ExtraProperties] nvarchar(max) NULL, [ExtraProperties] nvarchar(max) NULL,
[ConcurrencyStamp] nvarchar(40) NULL, [ConcurrencyStamp] nvarchar(40) NULL,
[CreationTime] datetime2 NOT NULL, [CreationTime] datetime2 NOT NULL,

4
be/Modules/Shared/src/Win_in.Sfs.Shared.Domain.Shared/Enums/Store/EnumProductReceiptType.cs

@ -5,9 +5,9 @@ namespace Win_in.Sfs.Shared.Domain.Shared;
public enum EnumProductReceiptType public enum EnumProductReceiptType
{ {
/// <summary> /// <summary>
/// 人工缴库 /// 人工缴库(完工缴库)
/// </summary> /// </summary>
[Display(Name = "人工缴库")] [Display(Name = "人工缴库(完工缴库)")]
ProductReceipt_Manual = 2101, ProductReceipt_Manual = 2101,
/// <summary> /// <summary>

226
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/ProductReceiptRequests/ProductReceiptRequestAppService.cs

@ -5,10 +5,13 @@ using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using DocumentFormat.OpenXml.Office.CustomUI;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Application.Contracts;
using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain;
@ -30,16 +33,20 @@ public class ProductReceiptRequestAppService :
SfsStoreRequestInputBase, ProductReceiptRequestImportInput> SfsStoreRequestInputBase, ProductReceiptRequestImportInput>
{ {
private readonly IProductReceiptRequestManager _productReceiptRequestManager; private readonly IProductReceiptRequestManager _productReceiptRequestManager;
private readonly IAreaAppService _areaApp; private readonly IAreaAppService _areaApp;
private readonly IItemBasicAppService _itemBasicAppService;
private readonly ILocationAppService _locationAppService;
public ProductReceiptRequestAppService( public ProductReceiptRequestAppService(
IProductReceiptRequestRepository repository IProductReceiptRequestRepository repository
, IProductReceiptRequestManager productReceiptRequestManager , IProductReceiptRequestManager productReceiptRequestManager
, IAreaAppService areaApp , IAreaAppService areaApp,
) : base(repository, productReceiptRequestManager) IItemBasicAppService itemBasicAppService,
ILocationAppService locationAppService) : base(repository, productReceiptRequestManager)
{ {
_areaApp = areaApp; _areaApp = areaApp;
_itemBasicAppService = itemBasicAppService;
_locationAppService = locationAppService;
_productReceiptRequestManager = productReceiptRequestManager; _productReceiptRequestManager = productReceiptRequestManager;
base.CreatePolicyName = ProductReceiptRequestPermissions.Create; base.CreatePolicyName = ProductReceiptRequestPermissions.Create;
base.UpdatePolicyName = ProductReceiptRequestPermissions.Update; base.UpdatePolicyName = ProductReceiptRequestPermissions.Update;
@ -48,6 +55,61 @@ public class ProductReceiptRequestAppService :
#region 东阳 #region 东阳
/// <summary>
/// 用来重写 导入数据时可以加工数据
/// </summary>
/// <param name="dictionary"></param>
/// <returns></returns>
protected override async Task<Dictionary<ProductReceiptRequest, EntityState>> ImportProcessingEntityAsync(
Dictionary<ProductReceiptRequest, EntityState> dictionary)
{
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key);
foreach (var productReceiptRequest in addList)
{
productReceiptRequest.Worker = CurrentUser.GetUserName();
productReceiptRequest.CreatorId = CurrentUser.Id;
await SetRequestAutoPropertiesAsync(productReceiptRequest).ConfigureAwait(false);
foreach (var detail in productReceiptRequest.Details)
{
await SetDetailPropertiesAsync(detail).ConfigureAwait(false);
}
}
return dictionary;
}
/// <summary>
/// 赋值详情
/// </summary>
/// <param name="detail"></param>
/// <param name="input"></param>
/// <returns></returns>
private async Task SetDetailPropertiesAsync(ProductReceiptRequestDetail detail)
{
var itemBasic = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false);
if (itemBasic != null)
{
detail.ItemName = itemBasic.Name;
detail.ItemDesc1 = itemBasic.Desc1;
detail.ItemDesc2 = itemBasic.Desc2;
detail.StdPackQty = itemBasic.StdPackQty;
detail.Uom = itemBasic.BasicUom;
}
var location = await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false);
if (location != null)
{
detail.LocationErpCode = location.ErpLocationCode;
detail.WarehouseCode = location.WarehouseCode;
detail.LocationArea = location.AreaCode;
detail.LocationGroup = location.LocationGroupCode;
}
}
/// <summary> /// <summary>
/// 设置事务类型 /// 设置事务类型
/// </summary> /// </summary>
@ -55,7 +117,7 @@ public class ProductReceiptRequestAppService :
/// <returns></returns> /// <returns></returns>
private async Task SetRequestAutoPropertiesAsync(ProductReceiptRequest entity) private async Task SetRequestAutoPropertiesAsync(ProductReceiptRequest entity)
{ {
var enumTransSubType=EnumTransSubType.None; var enumTransSubType = EnumTransSubType.None;
switch (entity.Type) switch (entity.Type)
{ {
case EnumProductReceiptType.ProductReceipt_Manual: case EnumProductReceiptType.ProductReceipt_Manual:
@ -214,121 +276,97 @@ public class ProductReceiptRequestAppService :
return transactionType; return transactionType;
} }
protected virtual async Task ImportDataAsync(List<ProductReceiptRequest> entites,
List<ProductReceiptRequest> deleteEntities)
{
await _productReceiptRequestManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false);
}
protected override Func<ProductReceiptRequestImportInput, object> GetEntityExpression() protected override Func<ProductReceiptRequestImportInput, object> GetEntityExpression()
{ {
return p => p.Type; return p => p.Type;
} }
protected virtual async Task<(List<ProductReceiptRequest> entites, List<ProductReceiptRequest> deleteEntities)> #endregion
BuildImportDataAsync(ImportResult<ProductReceiptRequestImportInput> importResult,
EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false)
{
if (importResult.Data.Any(t => t.ReportStatus == EnumImportReportStatus.Failed))
{
if (!isAllowPartImport)
{
return (null, null);
}
}
var entites = new List<ProductReceiptRequest>(); //protected virtual async Task ImportDataAsync(List<ProductReceiptRequest> entites,
// List<ProductReceiptRequest> deleteEntities)
//{
// await _productReceiptRequestManager.ImportDataAsync(entites, deleteEntities).ConfigureAwait(false);
//}
//protected virtual async Task<(List<ProductReceiptRequest> entites, List<ProductReceiptRequest> deleteEntities)>
// BuildImportDataAsync(ImportResult<ProductReceiptRequestImportInput> importResult,
// EnumImportMethod importMethod = EnumImportMethod.Update, bool isAllowPartImport = false)
//{
// if (importResult.Data.Any(t => t.ReportStatus == EnumImportReportStatus.Failed))
// {
// if (!isAllowPartImport)
// {
// return (null, null);
// }
// }
var details = new List<ProductReceiptRequestDetail>(); // var entites = new List<ProductReceiptRequest>();
var deleteEntites = new List<ProductReceiptRequest>(); // var details = new List<ProductReceiptRequestDetail>();
var entityExpression = GetEntityExpression(); // var deleteEntites = new List<ProductReceiptRequest>();
var groupList = importResult.Data.ToList().GroupBy(entityExpression).Distinct().ToList(); // var entityExpression = GetEntityExpression();
foreach (var group in groupList) // var groupList = importResult.Data.ToList().GroupBy(entityExpression).Distinct().ToList();
{
var input = group.FirstOrDefault();
var inputDetails = group.ToList(); // foreach (var group in groupList)
// {
// var input = group.FirstOrDefault();
if (!inputDetails.Any(t => t.ReportStatus == EnumImportReportStatus.Failed)) // var inputDetails = group.ToList();
{
var exist = await GetEntityAsync(input).ConfigureAwait(false);
var entity = ObjectMapper.Map<ProductReceiptRequestImportInput, ProductReceiptRequest>(input); // if (!inputDetails.Any(t => t.ReportStatus == EnumImportReportStatus.Failed))
// {
// var exist = await GetEntityAsync(input).ConfigureAwait(false);
await SetEntityPropertiesAsync(entity, input).ConfigureAwait(false); // var entity = ObjectMapper.Map<ProductReceiptRequestImportInput, ProductReceiptRequest>(input);
switch (importMethod) // await SetEntityPropertiesAsync(entity, input).ConfigureAwait(false);
{
case EnumImportMethod.Update:
entity.SetId(exist != null ? exist.Id : GuidGenerator.Create());
if (exist != null) // switch (importMethod)
{ // {
entity.SetId(exist.Id); // case EnumImportMethod.Update:
} // entity.SetId(exist != null ? exist.Id : GuidGenerator.Create());
break; // if (exist != null)
case EnumImportMethod.Replace: // {
if (exist != null) // entity.SetId(exist.Id);
{ // }
deleteEntites.Add(exist);
}
entity.SetId(GuidGenerator.Create()); // break;
break; // case EnumImportMethod.Replace:
} // if (exist != null)
// {
// deleteEntites.Add(exist);
// }
foreach (var inputDetail in inputDetails) // entity.SetId(GuidGenerator.Create());
{ // break;
var detail = // }
ObjectMapper.Map<ProductReceiptRequestImportInput, ProductReceiptRequestDetail>(inputDetail);
detail.SetIdAndNumber(GuidGenerator, entity.Id, entity.Number); // foreach (var inputDetail in inputDetails)
// {
// var detail =
// ObjectMapper.Map<ProductReceiptRequestImportInput, ProductReceiptRequestDetail>(inputDetail);
await SetDetailPropertiesAsync(detail, input).ConfigureAwait(false); // detail.SetIdAndNumber(GuidGenerator, entity.Id, entity.Number);
entity.AddDetail(detail);
}
entites.Add(entity); // await SetDetailPropertiesAsync(detail, input).ConfigureAwait(false);
} // entity.AddDetail(detail);
} // }
return (entites, deleteEntites); // entites.Add(entity);
} // }
// }
private async Task SetDetailPropertiesAsync(ProductReceiptRequestDetail detail, // return (entites, deleteEntites);
ProductReceiptRequestImportInput input) //}
{
var itemBasic = await ItemBasicAclService.GetByCodeAsync(input.ItemCode).ConfigureAwait(false);
if (itemBasic != null) //private async Task SetEntityPropertiesAsync(ProductReceiptRequest entity, ProductReceiptRequestImportInput input)
{ //{
detail.ItemName = itemBasic.Name; // entity.Worker = CurrentUser.GetUserName();
detail.ItemDesc1 = itemBasic.Desc1;
detail.ItemDesc2 = itemBasic.Desc2;
detail.Qty = input.Qty;
detail.StdPackQty = itemBasic.StdPackQty;
}
var location = await LocationAclService.GetByCodeAsync(input.LocationCode).ConfigureAwait(false);
if (location != null) // await SetRequestAutoPropertiesAsync(entity).ConfigureAwait(false);
{ //}
detail.LocationErpCode = location.ErpLocationCode;
detail.WarehouseCode = location.WarehouseCode;
}
}
private async Task SetEntityPropertiesAsync(ProductReceiptRequest entity, ProductReceiptRequestImportInput input)
{
entity.Worker = CurrentUser.GetUserName();
await SetRequestAutoPropertiesAsync(entity).ConfigureAwait(false);
}
#endregion
} }

75
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Domain/Notes/ProductReceiptNotes/ProductReceiptNoteManager.cs

@ -12,9 +12,12 @@ public class ProductReceiptNoteManager : SfsStoreManagerBase<ProductReceiptNote,
private readonly IOfflineSettlementNoteManager _offlineSettlementNoteManager; private readonly IOfflineSettlementNoteManager _offlineSettlementNoteManager;
private readonly IBackFlushNoteManager _backFlushNoteManager; private readonly IBackFlushNoteManager _backFlushNoteManager;
private readonly IBomAppService _bomAppService; private readonly IBomAppService _bomAppService;
private readonly IProductionPlanRepository _productionPlanRepository; private readonly IProductionPlanRepository _productionPlanRepository;
private bool isBackFlush = false;
private bool isOffLine = false;
public ProductReceiptNoteManager( public ProductReceiptNoteManager(
IProductReceiptNoteRepository repository, IProductReceiptNoteRepository repository,
IOfflineSettlementNoteManager offlineSettlementNoteManager, IOfflineSettlementNoteManager offlineSettlementNoteManager,
@ -91,55 +94,61 @@ public class ProductReceiptNoteManager : SfsStoreManagerBase<ProductReceiptNote,
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
private async Task BackFlushAsync(ProductReceiptNote productReceiptNote) private async Task BackFlushAsync(ProductReceiptNote productReceiptNote)
{ {
//生成【MES】回冲接口 TODO //生成【MES】回冲接口 TODO
#region 【判断】是否需要记录回冲记录 及下线结算接口 #region 【判断】是否需要记录回冲记录 及下线结算接口
//【判断】是否需要记录回冲记录 TODO //【判断】是否需要记录回冲记录 TODO
//【是】 完工收货时,创建回冲记录 //【是】 完工收货时,创建回冲记录
//var isBackFlush = await SettingManager.IsTrueAsync(StoreSettings.ProductionReceipt.AutoCreateBackFlush); ; //扣原材料 //var isBackFlush = await SettingManager.IsTrueAsync(StoreSettings.ProductionReceipt.AutoCreateBackFlush); ; //扣原材料
//var isOffLine = await _settingProvider.IsTrueAsync(StoreSettings.ProductionReceipt.AutoCreateOfflineSettlement); ; //下线结算 //var isOffLine = await _settingProvider.IsTrueAsync(StoreSettings.ProductionReceipt.AutoCreateOfflineSettlement); ; //下线结算
//是否需要下线结算 //是否需要下线结算
//获取所有成品的零件号 if (isBackFlush || isOffLine)
//一次性获得所有BOM信息避免每个明细都查询一遍;false 为bom不展开,便于测试 {
var totalBomList = await GetBomListAsync(productReceiptNote).ConfigureAwait(false); //获取所有成品的零件号
//一次性获得所有BOM信息避免每个明细都查询一遍;false 为bom不展开,便于测试
var totalBomList = await GetBomListAsync(productReceiptNote);
//取不到bom信息要报错,不能进行下去 //取不到bom信息要报错,不能进行下去
//根据回冲记录获取成品零件种类和数量,并获取相关要消耗的原材料库存
var productSumList = productReceiptNote.Details.GroupBy(p => new { p.ItemCode, p.RawLocationCode, p.Qty })
.Select(s => new BackFlushInventoryTotal
{
ItemCode = s.Key.ItemCode,
RawLocationCode = s.Key.RawLocationCode,
Qty = s.Key.Qty,
TotalQty = s.Sum(n => n.Qty),
}).ToList();
//根据父级零件汇总的数量,获取BOM子表明细原材料的数量 //根据回冲记录获取成品零件种类和数量,并获取相关要消耗的原材料库存
var subInventoryTotalList = new List<BackFlushInventoryTotal>(); var productSumList = productReceiptNote.Details.GroupBy(p => new { p.ItemCode, p.RawLocationCode, p.Qty })
.Select(s => new BackFlushInventoryTotal
{
ItemCode = s.Key.ItemCode,
RawLocationCode = s.Key.RawLocationCode,
Qty = s.Key.Qty,
TotalQty = s.Sum(n => n.Qty),
}).ToList();
foreach (var productSumItem in productSumList)
{
var subBomList = totalBomList.Where(p => p.Product == productSumItem.ItemCode).ToList();
//根据bom和父级零件总数获取子零件总数,然后将子零件总数汇总进 总零件数量 //根据父级零件汇总的数量,获取BOM子表明细原材料的数量
await GetSubBackFlushInventoryList(productSumItem, subBomList, subInventoryTotalList).ConfigureAwait(false); var subInventoryTotalList = new List<BackFlushInventoryTotal>();
}
await _backFlushNoteManager.CreateByProductReceiptNoteAsync(productReceiptNote, subInventoryTotalList) foreach (var productSumItem in productSumList)
.ConfigureAwait(false); {
var subBomList = totalBomList.Where(p => p.Product == productSumItem.ItemCode).ToList();
//【判断】是否需要下线结算 //根据bom和父级零件总数获取子零件总数,然后将子零件总数汇总进 总零件数量
if (subInventoryTotalList.Any(p => p.IsOffLine == true)) await GetSubBackFlushInventoryList(productSumItem, subBomList, subInventoryTotalList).ConfigureAwait(false);
{ }
//【是】 创建【下线结算记录】
await _offlineSettlementNoteManager if (isBackFlush)
.CreateByProductReceiptNoteAsync(productReceiptNote, subInventoryTotalList).ConfigureAwait(false); {
await _backFlushNoteManager.CreateByProductReceiptNoteAsync(productReceiptNote, subInventoryTotalList).ConfigureAwait(false);
}
//【判断】是否需要下线结算
if (isOffLine && subInventoryTotalList.Any(p => p.IsOffLine == true))
{
//【是】 创建【下线结算记录】
await _offlineSettlementNoteManager.CreateByProductReceiptNoteAsync(productReceiptNote, subInventoryTotalList).ConfigureAwait(false);
}
} }
#endregion #endregion

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/ProductReceiptRequests/ProductReceiptRequestDbContextModelCreatingExtensions.cs

@ -23,8 +23,8 @@ public static class ProductReceiptRequestDbContextModelCreatingExtensions
b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.NameLength); b.Property(q => q.ProdLine).HasMaxLength(SfsPropertyConst.NameLength);
b.Property(q => q.Shift).HasMaxLength(SfsPropertyConst.NameLength); b.Property(q => q.Shift).HasMaxLength(SfsPropertyConst.NameLength);
b.Property(q => q.Team).HasMaxLength(SfsPropertyConst.NameLength); b.Property(q => q.Team).HasMaxLength(SfsPropertyConst.NameLength);
b.Property(q => q.Type).HasMaxLength(SfsPropertyConst.NameLength);
b.Property(q => q.PlanDate); b.Property(q => q.PlanDate);
b.Property(q => q.Type).HasMaxLength(SfsPropertyConst.NameLength).HasConversion<string>();
b.Property(q => q.RequestStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion<string>(); b.Property(q => q.RequestStatus).HasMaxLength(SfsPropertyConst.NameLength).HasConversion<string>();
//Relations //Relations

1
be/Modules/Store/src/Win_in.Sfs.Wms.Store.EntityFrameworkCore/Requests/PurchaseReceiptRequests/PurchaseReceiptRequestDbContextModelCreatingExtensions.cs

@ -24,7 +24,6 @@ public static class PurchaseReceiptRequestDbContextModelCreatingExtensions
b.Property(q => q.PlanArriveDate).IsRequired(); b.Property(q => q.PlanArriveDate).IsRequired();
b.Property(q => q.Number).IsRequired(); b.Property(q => q.Number).IsRequired();
b.Property(q => q.TimeWindow).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.TimeWindow).IsRequired().HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.SupplierName).HasMaxLength(SfsPropertyConst.CodeLength); b.Property(q => q.SupplierName).HasMaxLength(SfsPropertyConst.CodeLength);
b.Property(q => q.AsnNumber).HasMaxLength(SfsPropertyConst.NameLength); b.Property(q => q.AsnNumber).HasMaxLength(SfsPropertyConst.NameLength);
b.Property(q => q.RpNumber).HasMaxLength(SfsPropertyConst.NameLength); b.Property(q => q.RpNumber).HasMaxLength(SfsPropertyConst.NameLength);

4
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/InspectRequestEventHandler.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.Uow;
using Win_in.Sfs.Shared.Event; using Win_in.Sfs.Shared.Event;
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;
@ -28,6 +29,7 @@ public class InspectRequestEventHandler : StoreEventHandlerBase
/// </summary> /// </summary>
/// <param name="eventData"></param> /// <param name="eventData"></param>
/// <returns></returns> /// <returns></returns>
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCancelledEntityEventData<InspectRequest> eventData) public virtual async Task HandleEventAsync(SfsCancelledEntityEventData<InspectRequest> eventData)
{ {
var entity = eventData.Entity; var entity = eventData.Entity;
@ -39,6 +41,7 @@ public class InspectRequestEventHandler : StoreEventHandlerBase
/// </summary> /// </summary>
/// <param name="eventData"></param> /// <param name="eventData"></param>
/// <returns></returns> /// <returns></returns>
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsAgreedEntityEventData<InspectRequest> eventData) public virtual async Task HandleEventAsync(SfsAgreedEntityEventData<InspectRequest> eventData)
{ {
await Task.CompletedTask.ConfigureAwait(false); await Task.CompletedTask.ConfigureAwait(false);
@ -50,6 +53,7 @@ public class InspectRequestEventHandler : StoreEventHandlerBase
/// <param name="eventData"></param> /// <param name="eventData"></param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="NotImplementedException"></exception> /// <exception cref="NotImplementedException"></exception>
[UnitOfWork]
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<InspectRequest> eventData) public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<InspectRequest> eventData)
{ {
var entity = eventData.Entity; var entity = eventData.Entity;

18
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductReceiptNoteEventHandler.cs → be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/Note/ProductReceiptNoteEventHandler.cs

@ -18,15 +18,17 @@ public class ProductReceiptNoteEventHandler
{ {
private readonly IPutawayJobAppService _putawayJobAppService; private readonly IPutawayJobAppService _putawayJobAppService;
private readonly IProductReceiptRequestAppService _productReceiptRequestApp; //private readonly IProductReceiptRequestAppService _productReceiptRequestApp;
private readonly IProductReceiptRequestManager _productReceiptRequestManager;
public ProductReceiptNoteEventHandler( public ProductReceiptNoteEventHandler(
IPutawayJobAppService putawayJobAppService IPutawayJobAppService putawayJobAppService
, IProductReceiptRequestAppService productReceiptRequestApp //, IProductReceiptRequestAppService productReceiptRequestApp
) , IProductReceiptRequestManager productReceiptRequestManager)
{ {
_putawayJobAppService = putawayJobAppService; _putawayJobAppService = putawayJobAppService;
_productReceiptRequestApp = productReceiptRequestApp; //_productReceiptRequestApp = productReceiptRequestApp;
_productReceiptRequestManager = productReceiptRequestManager;
} }
public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<ProductReceiptNote> eventData) public virtual async Task HandleEventAsync(SfsCreatedEntityEventData<ProductReceiptNote> eventData)
@ -41,7 +43,9 @@ public class ProductReceiptNoteEventHandler
if (!string.IsNullOrEmpty(entity.ProductReceiptRequestNumber)) if (!string.IsNullOrEmpty(entity.ProductReceiptRequestNumber))
{ {
await _productReceiptRequestApp.CompleteByNumberAsync(entity.ProductReceiptRequestNumber).ConfigureAwait(false); //await _productReceiptRequestApp.CompleteByNumberAsync(entity.ProductReceiptRequestNumber).ConfigureAwait(false);
var productReceiptRequest=await _productReceiptRequestManager.GetByNumberAsync(entity.ProductReceiptRequestNumber).ConfigureAwait(false);
await _productReceiptRequestManager.CompleteAsync(productReceiptRequest).ConfigureAwait(false);
} }
} }
@ -64,7 +68,9 @@ public class ProductReceiptNoteEventHandler
{ {
if (!string.IsNullOrEmpty(entity.ProductReceiptRequestNumber)) if (!string.IsNullOrEmpty(entity.ProductReceiptRequestNumber))
{ {
await _productReceiptRequestApp.CompleteByNumberAsync(entity.ProductReceiptRequestNumber).ConfigureAwait(false); //await _productReceiptRequestApp.CompleteByNumberAsync(entity.ProductReceiptRequestNumber).ConfigureAwait(false);
var productReceiptRequest = await _productReceiptRequestManager.GetByNumberAsync(entity.ProductReceiptRequestNumber).ConfigureAwait(false);
await _productReceiptRequestManager.CompleteAsync(productReceiptRequest).ConfigureAwait(false);
} }
} }
} }

50
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/ProductReceiptRequestEventHandler.cs

@ -19,22 +19,62 @@ public class ProductReceiptRequestEventHandler
: StoreEventHandlerBase : StoreEventHandlerBase
, ILocalEventHandler<SfsHandledEntityEventData<ProductReceiptRequest>> , ILocalEventHandler<SfsHandledEntityEventData<ProductReceiptRequest>>
, ILocalEventHandler<SfsCancelledEntityEventData<ProductReceiptRequest>> , ILocalEventHandler<SfsCancelledEntityEventData<ProductReceiptRequest>>
,ILocalEventHandler<SfsCreatedEntityEventData<ProductReceiptRequest>>
, ILocalEventHandler<SfsCreatedEntityEventData<List<ProductReceiptRequest>>>
{ {
private readonly IProductReceiveJobAppService _productReceiveJobAppService; private readonly IProductReceiveJobAppService _productReceiveJobAppService;
private readonly IProductionLineAppService _productionLineAppService; private readonly IProductionLineAppService _productionLineAppService;
private readonly IProductReceiptNoteAppService _productReceiptNoteApp; private readonly IProductReceiptNoteAppService _productReceiptNoteApp;
private readonly IProductReceiptRequestManager _productReceiptRequestManager;
public ProductReceiptRequestEventHandler( public ProductReceiptRequestEventHandler(
IProductReceiveJobAppService productReceiveJobAppService IProductReceiveJobAppService productReceiveJobAppService
, IProductionLineAppService productionLineAppService , IProductionLineAppService productionLineAppService
, IProductReceiptNoteAppService productReceiptNoteApp , IProductReceiptNoteAppService productReceiptNoteApp
) , IProductReceiptRequestManager productReceiptRequestManager)
{ {
_productReceiveJobAppService = productReceiveJobAppService; _productReceiveJobAppService = productReceiveJobAppService;
_productionLineAppService = productionLineAppService; _productionLineAppService = productionLineAppService;
this._productReceiptNoteApp = productReceiptNoteApp; this._productReceiptNoteApp = productReceiptNoteApp;
_productReceiptRequestManager = productReceiptRequestManager;
} }
/// <summary>
/// 创建后
/// </summary>
/// <param name="eventData">Event data</param>
[UnitOfWork]
public async Task HandleEventAsync(SfsCreatedEntityEventData<ProductReceiptRequest> eventData)
{
var entity = eventData.Entity;
if (entity.AutoSubmit)
{
await _productReceiptRequestManager.SubmitAsync(entity).ConfigureAwait(false);
}
}
/// <summary>
/// 批量创建后
/// </summary>
/// <param name="eventData">Event data</param>
[UnitOfWork]
public async Task HandleEventAsync(SfsCreatedEntityEventData<List<ProductReceiptRequest>> eventData)
{
var entitys = eventData.Entity;
foreach (var entity in entitys)
{
if (entity.AutoSubmit)
{
await _productReceiptRequestManager.SubmitAsync(entity).ConfigureAwait(false);
}
}
}
/// <summary>
/// 审批后
/// </summary>
/// <param name="eventData"></param>
/// <returns></returns>
[UnitOfWork] [UnitOfWork]
public virtual async Task HandleEventAsync(SfsHandledEntityEventData<ProductReceiptRequest> eventData) public virtual async Task HandleEventAsync(SfsHandledEntityEventData<ProductReceiptRequest> eventData)
{ {
@ -53,6 +93,11 @@ public class ProductReceiptRequestEventHandler
} }
} }
/// <summary>
/// 取消后
/// </summary>
/// <param name="eventData"></param>
/// <returns></returns>
[UnitOfWork] [UnitOfWork]
public virtual async Task HandleEventAsync(SfsCancelledEntityEventData<ProductReceiptRequest> eventData) public virtual async Task HandleEventAsync(SfsCancelledEntityEventData<ProductReceiptRequest> eventData)
{ {
@ -60,6 +105,7 @@ public class ProductReceiptRequestEventHandler
await _productReceiveJobAppService.CancelByProductionPlanAsync(entity.Number).ConfigureAwait(false); await _productReceiveJobAppService.CancelByProductionPlanAsync(entity.Number).ConfigureAwait(false);
} }
#region 私有
private async Task<List<ProductReceiveJobEditInput>> BuildProductReceiveJobsAsync( private async Task<List<ProductReceiveJobEditInput>> BuildProductReceiveJobsAsync(
ProductReceiptRequest productionPlan) ProductReceiptRequest productionPlan)
{ {
@ -160,4 +206,6 @@ public class ProductReceiptRequestEventHandler
return note; return note;
} }
#endregion
} }

Loading…
Cancel
Save