From b8f188b90f910c97183e73145fa93dd50ff46492 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 13 Sep 2024 19:59:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=96=99=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PrdMaterialReceiptService.cs | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index 05be114d..748e640c 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -206,6 +206,88 @@ namespace Tnb.ProductionMgr return result; } } + + [HttpPost] + public async Task GetInfoByQrCodeForBackMaterial(Dictionary dic) + { + string qrCode = dic["qrcode"]; + + ISqlSugarClient db = _repository.AsSugarClient(); + + WmsCarryH wmsCarryH = await db.Queryable().SingleAsync(x => x.carry_code == qrCode); + if (wmsCarryH == null) + { + throw Oops.Bah($"未找到该载具{qrCode}"); + } + + if (wmsCarryH.carrystd_id==WmsWareHouseConst.CARRY_ZYXCSTD_ID || wmsCarryH.carrystd_id==WmsWareHouseConst.CARRY_ZYLJSTD_ID) + { + List result = await db.Queryable() + .LeftJoin((a, b) => b.id==a.carry_id) + .Where((a,b) => b.carry_code == qrCode && a.is_all_feeding == 0 ) + .Select((a, b) => new FeedingDetailOutput + { + carry_id = b.id, + carry_name = b.carry_name, + children = SqlFunc.Subqueryable() + .LeftJoin((c, d) => c.material_id == d.id) + .Where((c, d) => a.carry_id == c.carry_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 + }) + }).ToListAsync(); + if (result.Count > 1) + { + throw Oops.Bah("找到多条签收记录"); + }else if (result.Count == 1) + { + return result[0]; + } + + } + else + { + List result = await db.Queryable() + .LeftJoin((a, b) => b.carry_code==a.member_carry_code) + .Where((a) => a.member_carry_code == qrCode && a.is_all_feeding == 0 ) + .Select((a, b) => new FeedingDetailOutput + { + carry_id = b.id, + carry_name = b.carry_name, + children = SqlFunc.Subqueryable() + .LeftJoin((c, d) => c.material_id == d.id) + .Where((c, d) => a.member_carry_code == c.member_carry_code && 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 + }) + }).ToListAsync(); + if (result.Count > 1) + { + throw Oops.Bah("找到多条签收记录"); + }else if (result.Count == 1) + { + return result[0]; + } + } + + return null; + } [HttpPost] public async Task SaveData(MaterialReceiptInput input)