COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 0 ) THEN `bis`.`stock_number` ELSE 0 END ), 0 ) AS `ck_stock_number`,
COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 0 ) THEN `bis`.`outbound_number` ELSE 0 END ), 0 ) AS `ck_outbound_number`,
COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 0 ) THEN `bis`.`destruction_number` ELSE 0 END ), 0 ) AS `destruction_number`,
COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 1 ) THEN `bis`.`stock_number` ELSE 0 END ), 0 ) AS `djg_stock_number`,
COALESCE ( sum( CASE WHEN ( `bis`.`location_type` = 1 ) THEN `bis`.`outbound_number` ELSE 0 END ), 0 ) AS `djg_outbound_number`
FROM `pub_org` `po`
LEFT JOIN `base_inventory_summary` `bis` ON `po`.`org_id` = `bis`.`org_id_int`
WHERE
`po`.`del_flag` = 1 and (po.org_id=#{orgId} or `po`.org_parent_id=#{orgId})
and (`po`.level_flag>(select level_flag FROM pub_org where org_id=#{orgId} )+#{levelNum} or `po`.level_flag=(select level_flag FROM pub_org where org_id=#{orgId} ))
<iftest="typeIdsList!=null and typeIdsList.size() > 0">