--产品检验需求：已有的工单汇报单，【下推入库基本数量】需根据下游单据完工入库单进行更新。
UPDATE T_POM_MFTREPORTSUMMARY_A Y
   SET FPUSHDOWNWAREQTY =
       (SELECT A.FBASEQTY
          FROM (SELECT SUM(G.FBASEQTY) AS FBASEQTY, G.FSRCBILLENTRYID
                  FROM (SELECT T1.FBASEQTY, R1.FSRCBILLENTRYID
                          FROM T_IM_MDC_PRBLENTRY T1
                         INNER JOIN T_IM_MDC_PRBLENTRY_R R1
                            ON T1.FENTRYID = R1.FENTRYID
                        WHERE T1.FBASEQTY IS NOT NULL) G
                 GROUP BY G.FSRCBILLENTRYID) A
         WHERE Y.FENTRYID = A.FSRCBILLENTRYID) 
WHERE EXISTS (SELECT 1 FROM (SELECT SUM(G.FBASEQTY) AS FBASEQTY, G.FSRCBILLENTRYID
                  FROM (SELECT T1.FBASEQTY, R1.FSRCBILLENTRYID
                          FROM T_IM_MDC_PRBLENTRY T1
                         INNER JOIN T_IM_MDC_PRBLENTRY_R R1
                            ON T1.FENTRYID = R1.FENTRYID
                        WHERE T1.FBASEQTY IS NOT NULL) G
                 GROUP BY G.FSRCBILLENTRYID) B WHERE B.FSRCBILLENTRYID = Y.FENTRYID);
