From 3c52ad0d272004d0934e259228a4c6ba783d9889 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Sat, 29 Jun 2024 12:26:12 +0800 Subject: [PATCH] bug --- .../Tnb.ProductionMgr/PrdFeedingService.cs | 68 +++++++++++-------- .../PrdMaterialReceiptService.cs | 61 +++++++++-------- 2 files changed, 70 insertions(+), 59 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index 9b35dae7..81f464bb 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -20,6 +20,7 @@ using Tnb.WarehouseMgr; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Interfaces; +using Tnb.WarehouseMgr.Entities.Enums; namespace Tnb.ProductionMgr { @@ -496,35 +497,6 @@ namespace Tnb.ProductionMgr } - if (prdMaterialReceiptH.first_feed) - { - List dList = await db.Queryable() - .Where(x => x.material_receipt_id == prdMaterialReceiptH.id).ToListAsync(); - - // foreach (var item in dList) - // { - Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsCarryUnbindService.CarryUnbind(new CarryBindInput() - { - org = prdFeedingH.org_id, - create_id = prdFeedingH.create_id, - carry_id = prdMaterialReceiptH.carry_id, - carry_code = prdMaterialReceiptH.carry_code, - carrystd_id = carry.carrystd_id, - membercarry_code = "", - membercarry_id = "", - }); - - if (result2.code != JNPF.Common.Enums.HttpStatusCode.OK) - { - throw Oops.Bah(result2.msg); - } - // } - - await db.Updateable() - .SetColumns(x => x.first_feed == true) - .Where(x => x.id == prdMaterialReceiptH.id) - .ExecuteCommandAsync(); - } } else { @@ -535,6 +507,44 @@ namespace Tnb.ProductionMgr _ = await db.Insertable(prdFeedingH).ExecuteCommandAsync(); _ = await db.Insertable(list).ExecuteCommandAsync(); + if (prdMaterialReceiptH.first_feed) + { + await db.Updateable() + .SetColumns(x => x.first_feed == true) + .Where(x => x.id == prdMaterialReceiptH.id) + .ExecuteCommandAsync(); + + List dList = await db.Queryable() + .Where(x => x.material_receipt_id == prdMaterialReceiptH.id).ToListAsync(); + + List carryIds = dList.Select(x => x.member_carry_id).ToList(); + carryIds.Add(prdMaterialReceiptH.carry_id); + // foreach (var item in dList) + // { + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsCarryUnbindService.CarryUnbind(new CarryBindInput() + { + org = prdFeedingH.org_id, + create_id = prdFeedingH.create_id, + carry_id = prdMaterialReceiptH.carry_id, + carry_code = prdMaterialReceiptH.carry_code, + carrystd_id = carry.carrystd_id, + membercarry_code = "", + membercarry_id = "", + }); + + await db.Updateable() + .SetColumns(x => x.carry_status == ((int)EnumCarryStatus.空闲).ToString()) + .Where(x => carryIds.Contains(x.id)) + .ExecuteCommandAsync(); + + if (result2.code != JNPF.Common.Enums.HttpStatusCode.OK) + { + throw Oops.Bah(result2.msg); + } + // } + + } + await db.Ado.CommitTranAsync(); } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index 2269b635..c2d9e2f2 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -103,11 +103,11 @@ namespace Tnb.ProductionMgr .Where(x => x.mo_task_id == prdMoTask.id).Select(x=>x.id).ToListAsync(); - if (await db.Queryable() - .AnyAsync(x => x.member_carry_code == qrCode && x.is_all_feeding == 0 && ids.Contains(x.material_receipt_id))) - { + // if (await db.Queryable() + // .AnyAsync(x => x.member_carry_code == qrCode && x.is_all_feeding == 0 && ids.Contains(x.material_receipt_id))) + // { FeedingDetailOutput result = await db.Queryable() - .LeftJoin((a, b) => b.carry_code==qrCode) + .LeftJoin((a, b) => b.carry_code==a.member_carry_code) .Where((a) => a.member_carry_code == qrCode && a.is_all_feeding == 0 && ids.Contains(a.material_receipt_id)) .Select((a, b) => new FeedingDetailOutput { @@ -129,32 +129,33 @@ namespace Tnb.ProductionMgr }) }).FirstAsync(); return result; - } - else - { - FeedingDetailOutput result = await db.Queryable() - .LeftJoin((a, b) => b.carry_code==qrCode) - .Where((a) => a.carry_code == qrCode && ids.Contains(a.id)) - .Select((a, b) => new FeedingDetailOutput - { - carry_id = a.carry_id, - carry_name = b.carry_name, - children = SqlFunc.Subqueryable() - .LeftJoin((c, d) => c.material_id == d.id) - .Where((c, d) => a.id == c.material_receipt_id && c.is_all_feeding == 0).ToList((c, d) => new CarryCodeDetailOutput() - { - unit_id = d.unit_id, - // barcode = c.barcode, - // code_batch = c.code_batch, - code_batch = c.batch, - codeqty = c.num - SqlFunc.IsNull(c.feeding_num,0), - material_id = c.material_id, - material_code = d.code, - material_name = d.name - }) - }).FirstAsync(); - return result; - } + // } + // else + // { + // FeedingDetailOutput result = await db.Queryable() + // .LeftJoin((a, b) => b.carry_code==qrCode) + // .LeftJoin() + // .Where((a) => a.carry_code == qrCode && ids.Contains(a.id)) + // .Select((a, b) => new FeedingDetailOutput + // { + // carry_id = a.carry_id, + // carry_name = b.carry_name, + // children = SqlFunc.Subqueryable() + // .LeftJoin((c, d) => c.material_id == d.id) + // .Where((c, d) => a.id == c.material_receipt_id && c.is_all_feeding == 0).ToList((c, d) => new CarryCodeDetailOutput() + // { + // unit_id = d.unit_id, + // // barcode = c.barcode, + // // code_batch = c.code_batch, + // code_batch = c.batch, + // codeqty = c.num - SqlFunc.IsNull(c.feeding_num,0), + // material_id = c.material_id, + // material_code = d.code, + // material_name = d.name + // }) + // }).FirstAsync(); + // return result; + // } } [HttpPost]