select material_detail_id, organization_id, organization_name, top_organization_id, unique_id, shelf_order_number, material_base_info_id, material_code, material_name, bar_code, quantity, already_shelves_quantity, shelves_quantity, shelves_status, pack_id, pack_code, pack_name,
CASE
WHEN pack_detail_id IS NULL OR TRIM(pack_detail_id) = '' THEN NULL
ELSE CAST(pack_detail_id AS BIGINT)
END as pack_detail_id, unit_code, unit_name, unit_number, material_warehouse_control_id, serial_number_manage, quality_inspection_manage, quality_inspection_stage, quality_inspection_rule, quality_inspection_ratio, quality_inspection_term, quality_inspection_results, allow_overcharge, overcharge_ratio, batch_number, material_status_code, material_status_name, distribute_rule_id, distribute_rule_code, distribute_rule_name, container_id, container_code, container_type, container_type_name, warehouse_id, warehouse_code, warehouse_name, storage_section_id, storage_code, storage_name, storage_location_id, storage_location_code, storage_location_name, level, parent_unique_id, in_unique_id, receipt_unique_id, allow_modify, remark, batch_ref_no, sheet_ref_no, box_pallet_no, ext_attr_1, ext_attr_2, production_date, expiry_date, inventory_date, ext_attr_3, ext_attr_4, create_time, create_by, create_by_name, update_time, update_by, update_by_name, del_flag,total_net_weight,total_gross_weight,total_volume,total_area,in_order_number,lot_number from shelf_material_detail
and organization_id = #{organizationId}
and organization_name like concat('%', #{organizationName}, '%')
and top_organization_id = #{topOrganizationId}
and unique_id = #{uniqueId}
and shelf_order_number = #{shelfOrderNumber}
and material_base_info_id = #{materialBaseInfoId}
and material_code = #{materialCode}
and material_name like concat('%', #{materialName}, '%')
and bar_code = #{barCode}
and quantity = #{quantity}
and shelves_quantity = #{shelvesQuantity}
and already_shelves_quantity = #{alreadyShelvesQuantity}
and shelves_status = #{shelvesStatus}
and pack_id = #{packId}
and pack_code = #{packCode}
and pack_name like concat('%', #{packName}, '%')
and pack_detail_id = #{packDetailId}
and unit_code = #{unitCode}
and unit_name like concat('%', #{unitName}, '%')
and unit_number = #{unitNumber}
and material_warehouse_control_id = #{materialWarehouseControlId}
and serial_number_manage = #{serialNumberManage}
and quality_inspection_manage = #{qualityInspectionManage}
and quality_inspection_stage = #{qualityInspectionStage}
and quality_inspection_rule = #{qualityInspectionRule}
and quality_inspection_ratio = #{qualityInspectionRatio}
and quality_inspection_term = #{qualityInspectionTerm}
and quality_inspection_results = #{qualityInspectionResults}
and allow_overcharge = #{allowOvercharge}
and overcharge_ratio = #{overchargeRatio}
and batch_number = #{batchNumber}
and material_status_code = #{materialStatusCode}
and material_status_name like concat('%', #{materialStatusName}, '%')
and distribute_rule_id = #{distributeRuleId}
and distribute_rule_code = #{distributeRuleCode}
and distribute_rule_name like concat('%', #{distributeRuleName}, '%')
and container_id = #{containerId}
and container_code = #{containerCode}
and container_type = #{containerType}
and container_type_name like concat('%', #{containerTypeName}, '%')
and warehouse_id = #{warehouseId}
and warehouse_code = #{warehouseCode}
and warehouse_name like concat('%', #{warehouseName}, '%')
and storage_section_id = #{storageSectionId}
and storage_code = #{storageCode}
and storage_name like concat('%', #{storageName}, '%')
and storage_location_id = #{storageLocationId}
and storage_location_code = #{storageLocationCode}
and storage_location_name like concat('%', #{storageLocationName}, '%')
and level = #{level}
and parent_unique_id = #{parentUniqueId}
and create_by_name like concat('%', #{createByName}, '%')
and update_by_name like concat('%', #{updateByName}, '%')
and del_flag = #{delFlag} and del_flag = 1