采购管理-采购入库单
金蝶云社区-云小爱
云小爱
0人赞赏了该文章 1,251次浏览 未经作者许可,禁止转载编辑于2015年01月05日 10:29:44
委外类型的采购入库单审核半个多小时不提示成功 ,审核时执行比较长的sql
SELECT T0.FID as INSTOCKID,
T1.FENTRYID INSTOCKENTRYID,
T2.FENTRYID POENTRYID,
SUM(NVL((T1.FBASEUNITQTY + T0.FSampleDamageBaseQty), 0)) POQTY,
T4.FENTRYID REQENTRYID,
T5.FENTRYID PPBOMENTRYID,
MAX(TU.FPRECISION) BASEPRECISION,
MAX(TU.FROUNDTYPE) BASEROUNDTYPE,
SUM(NVL(T6.FBASEACTUALQTY, 0)) FLUSHQTY
FROM T_STK_INSTOCK T INNER JOIN T_STK_INSTOCKENTRY T0 ON T.FID = T0.FID
INNER JOIN (SELECT COLUMN_VALUE AS FID FROM TABLE(CAST(1111 AS udt_inttable))) tmpa ON T.FID = TMPA.FID
INNER JOIN T_STK_INSTOCKENTRY_LK T1 ON (T0.FENTRYID = T1.FENTRYID AND (T1.FSTABLENAME IN ('t_PUR_POOrderEntry', 'T_PUR_ReceiveEntry')))
LEFT OUTER JOIN T_PUR_RECEIVEENTRY_LK A2 ON ((T1.FSID = A2.FENTRYID AND A2.FSTABLENAME = 't_PUR_POOrderEntry') AND T1.FSTABLENAME = 'T_PUR_ReceiveEntry')
INNER JOIN T_PUR_POORDERENTRY T2 ON ((T1.FSID = T2.FENTRYID AND T1.FSTABLENAME = 't_PUR_POOrderEntry') OR (A2.FSID = T2.FENTRYID AND A2.FSTABLENAME = 't_PUR_POOrderEntry'))
INNER JOIN T_PUR_POORDERENTRY_LK T3 ON (T2.FENTRYID = T3.FENTRYID AND T3.FSTABLENAME = 'T_SUB_REQORDERENTRY')
INNER JOIN T_SUB_REQORDERENTRY T4 ON T3.FSID = T4.FENTRYID
INNER JOIN T_SUB_PPBOMENTRY T5 ON T4.FENTRYID = T5.FSUBREQENTRYID
INNER JOIN T_SUB_PPBOMENTRY_C T7 ON T5.FENTRYID = T7.FENTRYID
INNER JOIN T_BD_UNIT TU ON T5.FBASEUNITID = TU.FUNITID
LEFT OUTER JOIN (SELECT D1.FSRCBIZENTRYID,D0.FPPBOMENTRYID,SUM(D0.FBASEACTUALQTY) FBASEACTUALQTY FROM T_SUB_PICKMTRLDATA D0
INNER JOIN T_SUB_PICKMTRLDATA_A D1 ON D0.FENTRYID = D1.FENTRYID
GROUP BY D1.FSRCBIZENTRYID, D0.FPPBOMENTRYID
) T6
ON (T5.FENTRYID = T6.FPPBOMENTRYID AND T0.FENTRYID = T6.FSRCBIZENTRYID)
INNER JOIN (SELECT COLUMN_VALUE AS FID FROM TABLE(CAST(:FID_udt AS udt_inttable))) tmpa ON T.FID = TMPA.FID
WHERE ((((T.FDOCUMENTSTATUS = 'C' AND T7.FBACKFLUSHTYPE = '3') AND (T7.FISSUETYPE = '2' OR T7.FISSUETYPE = '4')) AND T4.FPRODUCTTYPE = '1') AND (T5.FBaseMustQty > 0))
GROUP BY T0.FID, T1.FENTRYID, T2.FENTRYID, T4.FENTRYID, T5.FENTRYID