|
|
@ -1,4 +1,5 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp.EventBus; |
|
|
|
using Volo.Abp.Uow; |
|
|
@ -28,10 +29,11 @@ public class ItemTransformNoteEventHandler |
|
|
|
private async Task AddTransactionsAsync(ItemTransformNote note) |
|
|
|
{ |
|
|
|
var inboundTransactions = new List<TransactionEditInput>(); |
|
|
|
|
|
|
|
inboundTransactions.AddRange(BuildTransactions(note)); |
|
|
|
|
|
|
|
var noTransactions = new List<TransactionEditInput>(); |
|
|
|
inboundTransactions.AddRange(NewBuildTransactions(note));//原料+混拌料
|
|
|
|
noTransactions.AddRange(BuildNoTransactions(note));//粉碎料
|
|
|
|
await TransactionAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); |
|
|
|
await TransactionAppService.AddManyEmptyAsync(noTransactions).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -46,14 +48,16 @@ public class ItemTransformNoteEventHandler |
|
|
|
{ |
|
|
|
|
|
|
|
var inboundTransactions = new List<TransactionEditInput>(); |
|
|
|
|
|
|
|
var noTransactions = new List<TransactionEditInput>(); |
|
|
|
//如果要做库存事务汇总,可以修改此处
|
|
|
|
foreach (var note in notes) |
|
|
|
{ |
|
|
|
inboundTransactions.AddRange(BuildTransactions(note)); |
|
|
|
inboundTransactions.AddRange(NewBuildTransactions(note));//原料+混拌料
|
|
|
|
noTransactions.AddRange(BuildNoTransactions(note));//粉碎料
|
|
|
|
} |
|
|
|
|
|
|
|
await TransactionAppService.AddManyAsync(inboundTransactions).ConfigureAwait(false); |
|
|
|
await TransactionAppService.AddManyEmptyAsync(noTransactions).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
private static List<TransactionEditInput> BuildTransactions(ItemTransformNote note) |
|
|
@ -131,4 +135,151 @@ public class ItemTransformNoteEventHandler |
|
|
|
return transactions; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 新回收料库存方法
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="note"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
private static List<TransactionEditInput> NewBuildTransactions(ItemTransformNote note) |
|
|
|
{ |
|
|
|
var transactions = new List<TransactionEditInput>(); |
|
|
|
|
|
|
|
//根据调整记录,构造库存转移记录(只添加原料得)
|
|
|
|
foreach (var detail in note.Details.Where(r => r.Remark == "原料")) |
|
|
|
{ |
|
|
|
var transactionOut = new TransactionEditInput() |
|
|
|
{ |
|
|
|
Worker = note.Worker, |
|
|
|
JobNumber = note.JobNumber, |
|
|
|
DocNumber = note.Number, |
|
|
|
TransType = Type, |
|
|
|
TransSubType = SubType, |
|
|
|
TransInOut = EnumTransInOut.Out, |
|
|
|
LocationArea = detail.FromLocationArea, |
|
|
|
LocationGroup = detail.FromLocationGroup, |
|
|
|
LocationErpCode = detail.FromLocationErpCode, |
|
|
|
PackingCode = detail.FromPackingCode, |
|
|
|
ItemCode = detail.ItemCode, |
|
|
|
Lot = detail.FromLot, |
|
|
|
Status = detail.FromStatus, |
|
|
|
WarehouseCode = detail.FromWarehouseCode, |
|
|
|
LocationCode = detail.FromLocationCode, |
|
|
|
ContainerCode = detail.FromContainerCode, |
|
|
|
SupplierBatch = detail.FromSupplierBatch, |
|
|
|
ArriveDate = detail.FromArriveDate, |
|
|
|
ProduceDate = detail.FromProduceDate, |
|
|
|
ExpireDate = detail.FromExpireDate, |
|
|
|
ItemName = detail.ItemName, |
|
|
|
ItemDesc1 = detail.ItemDesc1, |
|
|
|
ItemDesc2 = detail.ItemDesc2, |
|
|
|
Uom = detail.Uom, |
|
|
|
Qty = -detail.FromQty, |
|
|
|
}; |
|
|
|
|
|
|
|
transactions.Add(transactionOut); |
|
|
|
} |
|
|
|
//混拌料添加事务
|
|
|
|
var detailfirst = note.Details.First(r => r.Remark == "原料"); |
|
|
|
var transactionIn = new TransactionEditInput() |
|
|
|
{ |
|
|
|
Worker = note.Worker, |
|
|
|
JobNumber = note.JobNumber, |
|
|
|
DocNumber = note.Number, |
|
|
|
TransType = Type, |
|
|
|
TransSubType = SubType, |
|
|
|
TransInOut = EnumTransInOut.In, |
|
|
|
|
|
|
|
PackingCode = detailfirst.ToPackingCode, |
|
|
|
ItemCode = detailfirst.ToItemCode, |
|
|
|
Lot = detailfirst.ToLot, |
|
|
|
Status = detailfirst.ToStatus, |
|
|
|
LocationArea = detailfirst.ToLocationArea, |
|
|
|
LocationGroup = detailfirst.ToLocationGroup, |
|
|
|
LocationErpCode = detailfirst.ToLocationErpCode, |
|
|
|
WarehouseCode = detailfirst.ToWarehouseCode, |
|
|
|
LocationCode = detailfirst.ToLocationCode, |
|
|
|
ContainerCode = detailfirst.ToContainerCode, |
|
|
|
SupplierBatch = detailfirst.ToSupplierBatch, |
|
|
|
ArriveDate = detailfirst.ToArriveDate, |
|
|
|
ProduceDate = detailfirst.ToProduceDate, |
|
|
|
ExpireDate = detailfirst.ToExpireDate, |
|
|
|
ItemName = detailfirst.ItemName, |
|
|
|
ItemDesc1 = detailfirst.ItemDesc1, |
|
|
|
ItemDesc2 = detailfirst.ItemDesc2, |
|
|
|
Uom = detailfirst.Uom, |
|
|
|
Qty = detailfirst.ToQty, |
|
|
|
}; |
|
|
|
transactions.Add(transactionIn); |
|
|
|
|
|
|
|
return transactions; |
|
|
|
} |
|
|
|
private static List<TransactionEditInput> BuildNoTransactions(ItemTransformNote note) |
|
|
|
{ |
|
|
|
var transactions = new List<TransactionEditInput>(); |
|
|
|
|
|
|
|
//根据调整记录,构造库存转移记录(只添加原料得)
|
|
|
|
foreach (var detail in note.Details.Where(r => r.Remark != "原料")) |
|
|
|
{ |
|
|
|
var transactionOut = new TransactionEditInput() |
|
|
|
{ |
|
|
|
Worker = note.Worker, |
|
|
|
JobNumber = note.JobNumber, |
|
|
|
DocNumber = note.Number, |
|
|
|
TransType = Type, |
|
|
|
TransSubType = SubType, |
|
|
|
TransInOut = EnumTransInOut.Out, |
|
|
|
LocationArea = detail.FromLocationArea, |
|
|
|
LocationGroup = detail.FromLocationGroup, |
|
|
|
LocationErpCode = detail.FromLocationErpCode, |
|
|
|
PackingCode = detail.FromPackingCode, |
|
|
|
ItemCode = detail.ItemCode, |
|
|
|
Lot = detail.FromLot, |
|
|
|
Status = detail.FromStatus, |
|
|
|
WarehouseCode = detail.FromWarehouseCode, |
|
|
|
LocationCode = detail.FromLocationCode, |
|
|
|
ContainerCode = detail.FromContainerCode, |
|
|
|
SupplierBatch = detail.FromSupplierBatch, |
|
|
|
ArriveDate = detail.FromArriveDate, |
|
|
|
ProduceDate = detail.FromProduceDate, |
|
|
|
ExpireDate = detail.FromExpireDate, |
|
|
|
ItemName = detail.ItemName, |
|
|
|
ItemDesc1 = detail.ItemDesc1, |
|
|
|
ItemDesc2 = detail.ItemDesc2, |
|
|
|
Uom = detail.Uom, |
|
|
|
Qty = -detail.FromQty, |
|
|
|
}; |
|
|
|
transactions.Add(transactionOut); |
|
|
|
var transactionIn = new TransactionEditInput() |
|
|
|
{ |
|
|
|
Worker = note.Worker, |
|
|
|
JobNumber = note.JobNumber, |
|
|
|
DocNumber = note.Number, |
|
|
|
TransType = Type, |
|
|
|
TransSubType = SubType, |
|
|
|
TransInOut = EnumTransInOut.In, |
|
|
|
LocationArea = detail.FromLocationArea, |
|
|
|
LocationGroup = detail.FromLocationGroup, |
|
|
|
LocationErpCode = detail.FromLocationErpCode, |
|
|
|
PackingCode = detail.FromPackingCode, |
|
|
|
ItemCode = detail.ItemCode, |
|
|
|
Lot = detail.FromLot, |
|
|
|
Status = detail.FromStatus, |
|
|
|
WarehouseCode = detail.FromWarehouseCode, |
|
|
|
LocationCode = detail.FromLocationCode, |
|
|
|
ContainerCode = detail.FromContainerCode, |
|
|
|
SupplierBatch = detail.FromSupplierBatch, |
|
|
|
ArriveDate = detail.FromArriveDate, |
|
|
|
ProduceDate = detail.FromProduceDate, |
|
|
|
ExpireDate = detail.FromExpireDate, |
|
|
|
ItemName = detail.ItemName, |
|
|
|
ItemDesc1 = detail.ItemDesc1, |
|
|
|
ItemDesc2 = detail.ItemDesc2, |
|
|
|
Uom = detail.Uom, |
|
|
|
Qty = detail.FromQty, |
|
|
|
}; |
|
|
|
transactions.Add(transactionIn); |
|
|
|
} |
|
|
|
return transactions; |
|
|
|
} |
|
|
|
} |
|
|
|