采购/委外调整

This commit is contained in:
2024-10-18 13:42:03 +08:00
parent abe6bd70b3
commit 8ae060e8d6
17 changed files with 149 additions and 70 deletions

View File

@@ -41,6 +41,7 @@ using Tnb.BasicData.Interfaces;
using JNPF.Common.Enums;
using System.Reflection;
using Aop.Api.Domain;
using Tnb.EquipMgr.Entities;
namespace Tnb.WarehouseMgr
{
@@ -72,11 +73,10 @@ namespace Tnb.WarehouseMgr
_thirdApiRecordService = thirdApiRecordService;
_visualDevService = visualDevService;
OverideFuncs.CreateAsync += Create;
OverideFuncs.DeleteAsync = Delete;
}
/// <summary>
/// 保存工序工位关联表
/// </summary>
[HttpPost]
public async Task<dynamic> Create(VisualDevModelDataCrInput visualDevModelDataCrInput)
{
@@ -100,6 +100,31 @@ namespace Tnb.WarehouseMgr
return "保存成功";
}
// List<WmsDistaskH> wmsDistaskH = await _db.Queryable<WmsDistaskH>().Where(r => r.source_id == id).ToListAsync();
private async Task Delete(string id)
{
await _db.Ado.BeginTranAsync();
WmsPurchaseH wmsPurchaseH = await _db.Queryable<WmsPurchaseH>().Where(r => r.id == id).FirstAsync();
if (wmsPurchaseH != null)
{
_ = await _db.Deleteable(wmsPurchaseH).ExecuteCommandAsync();
List<WmsPurchaseD> wmsPurchaseDs = await _db.Queryable<WmsPurchaseD>().Where(r => r.bill_id == id).ToListAsync();
Logger.Information($"删除采购收货单{wmsPurchaseH.bill_code} 收货明细{wmsPurchaseDs.Count}条");
foreach (WmsPurchaseD wmsPurchaseD in wmsPurchaseDs)
{
WmsPurchaseOrderD wmsPurchaseOrderD = await _db.Queryable<WmsPurchaseOrderD>().Where(r => r.erp_line_pk == wmsPurchaseD.erp_purchase_order_d_pk).FirstAsync();
if (wmsPurchaseOrderD != null)
{
Logger.Information($"采购收货单{wmsPurchaseH.bill_code} 收货明细id{wmsPurchaseOrderD.id} 删除后回退采购订单明细id{wmsPurchaseOrderD.id}已到货数量 {wmsPurchaseOrderD.actual_quantity} -> {wmsPurchaseOrderD.actual_quantity - wmsPurchaseD.purchase_arriveqty}");
wmsPurchaseOrderD.actual_quantity -= wmsPurchaseD.purchase_prqty;
await _db.Updateable(wmsPurchaseOrderD).UpdateColumns(r => r.actual_quantity).ExecuteCommandAsync();
}
}
_ = await _db.Deleteable(wmsPurchaseDs).ExecuteCommandAsync();
}
await _db.Ado.CommitTranAsync();
}
private async Task<dynamic> xxx(VisualDevModelDataCrInput input)
{