<iftest="(list1 != null and list1.size() > 0 or list2 != null and list2.size() > 0 or list3 != null and list3.size() > 0) and list4 != null and list4.size() > 0">
location_state = 'in' AND state = 'normal' AND org_id_int = ${item[0]} AND location_id = '${item[1]}' AND type_id = ${item[3]} AND size_id = '${item[2]}' AND unit_price = ${item[4]}
SELECT type_id,max(type_name) as type_name,org_id_int as org_id,max(org_name) as org_name,
<iftest="sizeId !=null and sizeId != ''">
size_id,max(size_name) as size_name,
</if>
(sum((case when (`its`.`location_type` = 0) then `its`.`stock_number` else 0 end))+sum((case when (`its`.`location_type` = 0) then `its`.`outbound_number` else 0 end))+sum((case when (`its`.`location_type` = 0) then `its`.`destruction_number` else 0 end))) as number,
sum((case when (`its`.`location_type` = 0) then `its`.`stock_number` else 0 end)) AS `ck_stock_number`,
sum((case when (`its`.`location_type` = 0) then `its`.`outbound_number` else 0 end)) AS `ck_outbound_number`,
sum((case when (`its`.`location_type` = 0) then `its`.`destruction_number` else 0 end)) AS `destruction_number`,
sum((case when (`its`.`location_type` = 1) then `its`.`stock_number` else 0 end)) AS `djg_stock_number`,
sum((case when (`its`.`location_type` = 1) then `its`.`outbound_number` else 0 end)) AS `djg_outbound_number`
sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) +
sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) +
sum( CASE WHEN `base_inventory_summary`.`location_type` = 0 THEN `base_inventory_summary`.`destruction_number` ELSE 0 END )
) AS total_number,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) AS `ck_stock_number`,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) AS `ck_outbound_number`,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 0 ) THEN `base_inventory_summary`.`destruction_number` ELSE 0 END ) AS `destruction_number`,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 1 ) THEN `base_inventory_summary`.`stock_number` ELSE 0 END ) AS `djg_stock_number`,
sum( CASE WHEN ( `base_inventory_summary`.`location_type` = 1 ) THEN `base_inventory_summary`.`outbound_number` ELSE 0 END ) AS `djg_outbound_number`
FROM
base_inventory_summary
WHERE
org_id_int = #{orgId}
<iftest="typeIdsList!=null and !typeIdsList.size() > 0">