update t_bd_snmainfile m set foccupybillid = fbillid 
where m.foccupybillid = 0
and m.fsnstatus = 'A'
and exists (select 1 from t_bd_snmovetrack t where t.fsnmainfileid = m.fid and t.fbillstatus = 'B')
and (select count(1) from t_bd_snmovetrack t where t.fsnmainfileid = m.fid) = 1;
--更新出库组织/仓库/货位更新领料出库单/销售出库单/其他出库单/分布调出单--
update t_bd_snmovetrack set fsrcinvorgid = fkeeporgid,fsrcwarehouseid = fwarehouseid,fsrclocationid = flocationid,fkeeporgid = 0,fwarehouseid = 0,flocationid = 0
where fbllentityid in('im_materialreqoutbill','im_saloutbill','im_otheroutbill','im_transoutbill')
and fsnmainfileid <> 0
and fkeeporgid <> 0;