From e662390cfd27710f55a999dc3552b39147cfb0b3 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期二, 19 十一月 2024 12:44:07 +0800 Subject: [PATCH] 采购扫码入库 --- service/Warehouse/MesInvItemInCDetailsManager.cs | 158 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 146 insertions(+), 12 deletions(-) diff --git a/service/Warehouse/MesInvItemInCDetailsManager.cs b/service/Warehouse/MesInvItemInCDetailsManager.cs index 1cdfcbd..6f65aea 100644 --- a/service/Warehouse/MesInvItemInCDetailsManager.cs +++ b/service/Warehouse/MesInvItemInCDetailsManager.cs @@ -174,6 +174,10 @@ cSyQty = itemBarcodeDetails.Quantity.Value; + entity.id = cId.ToString(); + entity.PageIndex = 1; + entity.Limit = 1; + itemBarcodeDetails.Hbdy ??= 0; if (itemBarcodeDetails.Hbdy == 1) { @@ -638,10 +642,15 @@ } var mesItems = db.Queryable<MesItems>() - .Where(s=>s.Id == itemBarcodeDetails.ItemId).First(); + .Where(s => s.Id == itemBarcodeDetails.ItemId).First(); result.Message = $"鏉$爜鏁伴噺 {itemBarcodeDetails.Quantity},閲囪喘璁㈠崟 {itemBarcodeDetails.WorkNo} 椤规 {itemBarcodeDetails.WorkLine} 鐗╂枡 {mesItems.ItemNo} 鏈鍏ュ簱鎬绘暟锛歿totalCDetailsQuantity} 鎬诲埌 {comeQty} 宸插叆 {invQty} 娆� {diffQty}"; + + + result.ItemNo = mesItems.ItemNo; + result.SumQuantity = Convert.ToDecimal(totalCDetailsQuantity); + return 1; } else @@ -694,31 +703,156 @@ var diffQty = comeQty - invQty; var mesItems = db.Queryable<MesItems>() - .Where(s=>s.Id == itemBarcodeDetails.ItemId).First(); + .Where(s => s.Id == itemBarcodeDetails.ItemId).First(); // Step 5: Combine final result result.Message = $" 鏉$爜鏁伴噺:{itemBarcodeDetails.Quantity},鐗╂枡 {mesItems.ItemNo} 鏈鍏ュ簱鎬绘暟锛歿totalCDetailsQuantity} 鎬诲埌 {comeQty} 宸插叆 {invQty} 娆� {diffQty}"; - } + + result.ItemNo = mesItems.ItemNo; + result.SumQuantity = Convert.ToDecimal(totalCDetailsQuantity); + } var mesInvItemInCDetails = base.GetSingle(it => it.ItemBarcode == entity.barcode); if (mesInvItemInCDetails == null) throw new Exception("鐗╂枡鍏ュ簱鏉$爜鏄庣粏涓嶅瓨鍦�"); // 鎶涘嚭寮傚父浠ヤ緵鍓嶅彴澶勭悊 - // - // var itemInId = mesInvItemInCDetails.ItemInId; - // entity.id = itemInId; - // entity.PageIndex = 1; - // entity.Limit = 1; - //var inventory = getPurchaseInventory(entity); - // inventory.ItemNo = parts[0]; - // inventory.SumQuantity = Convert.ToDecimal(parts[1]); - //return inventory; return 1; }); + + var purchaseInventory = getPurchaseInventory(entity); + + result.ItemIns = purchaseInventory.ItemIns; + result.ItemInDetails = purchaseInventory.ItemInDetails; + result.InvItemInCDetails = purchaseInventory.InvItemInCDetails; + + return result; + } + + public PurchaseInventory getPurchaseInventory(WarehouseQuery query) + { + return new PurchaseInventory + { + ItemIns = GetInvItemInsList(query).Items[0], + ItemInDetails = GetItemInDetails(query.id), + InvItemInCDetails = GetInvItemInCDetails(query.id) + }; + } + + public (List<MesInvItemIns> Items, int TotalCount) GetInvItemInsList( + WarehouseQuery query) + { + var parsedGuid = Guid.Empty; + if (string.IsNullOrEmpty(query.id)) + { + return ([], 0); + } + + bool isValid = Guid.TryParse(query.id, out parsedGuid); + if (!isValid) + throw new ApplicationException("GUID杞崲閿欒"); + + var totalCount = 0; + var result = Db.Queryable<MesInvItemIns, MesDepots, MesSupplier>( + (a, b, c) => + new JoinQueryInfos(JoinType.Left, + a.DepotsCode == b.DepotCode, + JoinType.Left, a.SuppNo == c.SuppNo)) + .WhereIF(UtilityHelper.CheckGuid(parsedGuid), + (a, b, c) => a.Guid == parsedGuid) + .Select((a, b, c) => new MesInvItemIns + { + Guid = a.Guid, + SuppNo = a.SuppNo, + InsDate = a.InsDate, + PaperBillNo = a.PaperBillNo, + Remark = a.Remark, + DepotsCode = a.DepotsCode, + CbillNo = a.CbillNo, + Status = a.Status, + BillNo = a.BillNo, + CreateDate = a.CreateDate, + CreateBy = a.CreateBy, + DepotName = b.DepotName, + SuppName = c.SuppName + }).ToPageList(query.PageIndex, query.Limit, ref totalCount); + return (result, totalCount); + } + + public List<MesInvItemInCItems> GetItemInDetails(string? pid) + { + //string杞琯uid + var parsedGuid = Guid.Empty; + if (string.IsNullOrEmpty(pid)) + { + return ( []); + } + + bool isValid = Guid.TryParse(pid, out parsedGuid); + if (!isValid) + throw new ApplicationException("GUID杞崲閿欒"); + + var result = Db.Queryable<MesInvItemInCDetails, MesItems, MesUnit>( + (g, c,d) => new JoinQueryInfos( + JoinType.Left,g.ItemId == c.Id, + JoinType.Inner,d.Id == Convert.ToDecimal(g.Unit) + ) + ).WhereIF(UtilityHelper.CheckGuid(parsedGuid), + (g, c,d) => g.ItemInId == parsedGuid) + .Select((g, c,d)=> new MesInvItemInCItems + { + Guid = g.Guid, + WorkNo = g.WorkNo, + ItemNo = c.ItemNo, + ItemSname = g.ItemSname, + Quantity = g.Quantity, + Unit = d.Fname, + }) + .ToList(); + + return result; + } + + public List<MesInvItemInCDetails> GetInvItemInCDetails(string? pid) + { + //string杞琯uid + var parsedGuid = Guid.Empty; + if (string.IsNullOrEmpty(pid)) + { + return ( []); + } + + bool isValid = Guid.TryParse(pid, out parsedGuid); + if (!isValid) + throw new ApplicationException("GUID杞崲閿欒"); + + var result = Db.Queryable<MesInvItemInCDetails, MesItems, MesUnit>( + (g, c, d) => new JoinQueryInfos( + JoinType.Left, + g.ItemId == c.Id, JoinType.Inner, + d.Id == Convert.ToDecimal(c.ItemUnit) + ) + ).WhereIF(UtilityHelper.CheckGuid(parsedGuid), + (g, c, d) => g.ItemInId == parsedGuid) + .Select((g, c, d) => new MesInvItemInCDetails + { + Guid = g.Guid, + ItemName = c.ItemName, + ItemModel = c.ItemModel, + ItemUnit = d.Fname, + DepotSectionCode = g.DepotSectionCode, + CbillNo = g.CbillNo, + ItemBarcode = g.ItemBarcode, + UrgentFlag = g.UrgentFlag, + ItemNo = c.ItemNo, + WorkNo = g.WorkNo, + Quantity = g.Quantity + }) + .ToList(); + return result; } -- Gitblit v1.9.3