-- 1.初始化:关联发货基本数量，累计发货基本数量，累计收货基本数量，累计入库基本数量，累计收货退货基本数量，累计入库退库基本数量
UPDATE
	T_PUR_ORDERENTRY_A t
SET
	t.frelateoutstockbaseqty = t.fsumoutstockqty,
	t.fsumoutstockbaseqty = t.fsumoutstockqty,
	t.fsumreceiptbaseqty = t.fsumreceiptqty,
	t.fsuminstockbaseqty = t.fsuminstockqty,
	t.fsumrecretbaseqty = t.fsumrecretqty,
	t.fsuminstockretbaseqty = fsuminstockretqty
WHERE
	EXISTS (
	SELECT
		1
	FROM
		T_PUR_ORDERENTRY a
	WHERE
		t.fentryid = a.fentryid
		AND a.FUnitId = t.FBasicUnitID);