From 154ecf3d94edef23247796ea313d00b35314563a Mon Sep 17 00:00:00 2001 From: 南骏 池 <chiffly@163.com> Date: 星期四, 17 七月 2025 13:34:34 +0800 Subject: [PATCH] 1.来料检验优化 --- service/Warehouse/MesXkyShdManager.cs | 20 ++++++++++++++------ 1 files changed, 14 insertions(+), 6 deletions(-) diff --git a/service/Warehouse/MesXkyShdManager.cs b/service/Warehouse/MesXkyShdManager.cs index f86518d..cdb3113 100644 --- a/service/Warehouse/MesXkyShdManager.cs +++ b/service/Warehouse/MesXkyShdManager.cs @@ -23,22 +23,30 @@ if (shdh.Count < 1) throw new Exception($"閫佽揣鍗曞彿銆恵unity.shdh}銆戜笉瀛樺湪鎴栨湭鍚屾!"); + // var sql3 = @"SELECT ISNULL((SELECT SUM(delivery_qty) FROM DELIVERY_NOTICE_DETAIL WHERE delivery_no = @shdh), 0) - + //ISNULL((SELECT SUM(include_qty) FROM TBL_BARCODE_INFORMATION WHERE delivery_no = @shdh), 0) AS Diffnum "; + // var diffNum = Db.Ado.SqlQuery<dynamic>(sql3, sqlParams).First(); - var sql2 = @"select D.item_no, + // if (diffNum.Diffnum != 0) + // throw new Exception($"閫佽揣鍗曞彿銆恵unity.shdh}銆戞潯鐮佹湭鍏ㄩ儴鎵撳嵃鎴栨湭鍚屾锛屾棤娉曟敹璐э紒"); + + var sql2 = @"WITH dhmx AS( + SELECT E.line_k3id,B.paper_bill_no,B.guid,E.quantity FROM dbo.MES_INV_ITEM_ARN B LEFT JOIN MES_INV_ITEM_ARN_DETAIL E ON B.guid = E.parent_Guid +) +select DISTINCT D.item_no, D.item_name, D.item_model, A.delivery_qty AS shsl, - ISNULL(E.quantity, 0) as ysl, - A.delivery_qty - ISNULL(E.quantity, 0) as dssl, + ISNULL(dhmx.quantity, 0) as ysl, + A.delivery_qty - ISNULL(dhmx.quantity, 0) as dssl, A.po_erp_no, C.PURCHASE_ORDER_LINE_NUMBER, - B.GUID AS DDHID + dhmx.GUID AS DDHID from DELIVERY_NOTICE_DETAIL A - LEFT JOIN dbo.MES_INV_ITEM_ARN B on B.paper_bill_no = A.delivery_no LEFT JOIN MES_ROH_IN_DATA C ON A.po_line_no = C.EBELN_K3ID LEFT JOIN MES_ITEMS D ON C.ITEM_ID = D.item_id - LEFT JOIN dbo.MES_INV_ITEM_ARN_DETAIL E on E.parent_Guid = B.guid AND E.line_k3id = A.po_line_no + LEFT JOIN dhmx ON dhmx.line_k3id = A.po_line_no AND dhmx.paper_bill_no = A.delivery_no WHERE A.delivery_no = @shdh"; var XcslItem = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams); -- Gitblit v1.9.3