a.contract_fee ,
a.monthly_warehouse_fee ,
a.half_month_wh_fee ,
a.discount_rate ,
a.single_volume ,
a.single_gross_weight ,
a.lot_no ,a.reserve_quantity,a.reserve_gross_weight,a.reserve_net_weight,a.reserve_volume,a.reserve_area,a.reserve_price,a.reserve_unit_price,a.shelf_life,
a.material_detail_id, a.organization_id, a.organization_name, a.top_organization_id, a.unique_id, a.in_order_number, a.material_base_info_id,
a.material_code, a.material_name, a.bar_code, a.quantity, a.receipt_quantity, a.shelves_quantity,
a.receipt_status, a.shelves_status, a.pack_id, a.pack_code, a.pack_name,a.RESERVE_MATERIAL_NAME,
CASE
WHEN a.pack_detail_id IS NULL OR TRIM(a.pack_detail_id) = '' THEN NULL
ELSE CAST(a.pack_detail_id AS BIGINT)
END as pack_detail_id, a.unit_code, a.unit_name, a.material_warehouse_control_id, a.serial_number_manage, a.quality_inspection_manage,
a.quality_inspection_stage, a.quality_inspection_rule, a.quality_inspection_ratio, a.quality_inspection_term, a.quality_inspection_results, a.allow_overcharge,
a.overcharge_ratio, a.batch_number, a.material_status_code, a.material_status_name, a.distribute_rule_id, a.distribute_rule_code,
a.distribute_rule_name, a.container_id, a.container_code, a.container_type, a.container_type_name,
a.warehouse_id, a.warehouse_code, a.warehouse_name, a.storage_section_id, a.storage_code, a.storage_name, a.storage_location_id, a.storage_location_code, a.storage_location_name,
a.level, a.parent_unique_id, a.remark, a.create_time, a.create_by,a.create_by_name, a.update_time, a.update_by, a.update_by_name, a.del_flag, a.over_stock_id, a.over_stock_status, a.over_stock_type,
a.SPECIFICATION_MODEL, a.SKU_CODE, a.INVOICE_NO, a.LITER, a.DIMENSIONS, a.DECLARATION_UNIT, a.BATCH_REF_NO, a.SHEET_REF_NO,
a.ORIGIN_COUNTRY, a.BOX_PALLET_NO, a.CURRENCY, a.UNIT, a.DECLARED_QUANTITY, a.BOX_COUNT, a.PIECE_COUNT, a.INBOUND_QUANTITY,
a.TOTAL_NET_WEIGHT, a.TOTAL_GROSS_WEIGHT, a.TOTAL_VOLUME, a.TOTAL_AREA, a.TOTAL_PRICE,
a.PRODUCTION_DATE, a.EXPIRY_DATE, a.INVENTORY_DATE, a.EXT_ATTR_1, a.EXT_ATTR_2, a.EXT_ATTR_3, a.EXT_ATTR_4
,CASE
WHEN (a.quantity - a.receipt_quantity) < 0 THEN 0
ELSE (a.quantity - a.receipt_quantity)
END AS wait_receipt_quantity,
CASE
WHEN (a.receipt_quantity - a.shelves_quantity) < 0 THEN 0
ELSE (a.receipt_quantity - a.shelves_quantity)
END AS wait_shelves_quantity
and a.organization_id = #{organizationId}
and a.organization_name like concat('%', #{organizationName}, '%')
and a.top_organization_id = #{topOrganizationId}
and a.in_order_number = #{inOrderNumber}
and a.material_base_info_id = #{materialBaseInfoId}
and a.material_code = #{materialCode}
and a.material_name like concat('%', #{materialName}, '%')
and a.bar_code = #{barCode}
and a.quantity = #{quantity}
and a.receipt_quantity = #{receiptQuantity}
and a.shelves_quantity = #{shelvesQuantity}
and a.pack_id = #{packId}
and a.pack_code = #{packCode}
and a.pack_name like concat('%', #{packName}, '%')
and a.pack_detail_id = #{packDetailId}
and a.unit_code = #{unitCode}
and a.unit_name like concat('%', #{unitName}, '%')
and a.material_warehouse_control_id = #{materialWarehouseControlId}
and a.serial_number_manage = #{serialNumberManage}
and a.quality_inspection_manage = #{qualityInspectionManage}
and a.quality_inspection_stage = #{qualityInspectionStage}
and a.quality_inspection_rule = #{qualityInspectionRule}
and a.quality_inspection_term = #{qualityInspectionTerm}
and a.quality_inspection_results = #{qualityInspectionResults}
and a.allow_overcharge = #{allowOvercharge}
and a.overcharge_ratio = #{overchargeRatio}
and a.batch_number = #{batchNumber}
and a.material_status_code = #{materialStatusCode}
and a.material_status_name like concat('%', #{materialStatusName}, '%')
and a.distribute_rule_id = #{distributeRuleId}
and a.distribute_rule_code = #{distributeRuleCode}
and a.distribute_rule_name like concat('%', #{distributeRuleName}, '%')
and a.container_id = #{containerId}
and a.container_code = #{containerCode}
and a.container_type = #{containerType}
and a.container_type_name like concat('%', #{containerTypeName}, '%')
and a.create_by_name like concat('%', #{createByName}, '%')
and a.update_by_name like concat('%', #{updateByName}, '%')
and a.in_order_number in
#{item}
and a.del_flag = #{delFlag} and a.del_flag = 1
and a.organization_id = #{organizationId}
and a.organization_name like concat('%', #{organizationName}, '%')
and a.top_organization_id = #{topOrganizationId}
and a.over_stock_status = #{overStockStatus}
and a.material_base_info_id = #{materialBaseInfoId}
and a.material_base_info_id in
#{item}
and a.del_flag = #{delFlag} and a.del_flag = 1
and b.out_order_number = #{outOrderNumber}
and b.warehouse_id = #{warehouseId}
and b.shipper_id = #{shipperId}
and b.shipper_id in
#{item}
and date_format(b.expect_time,'%y%m%d') >= date_format(#{inOrderExpectStartTime},'%y%m%d')
and date_format(b.expect_time,'%y%m%d') <= date_format(#{inOrderExpectEndTime},'%y%m%d')
and b.order_type_code = #{outOrderTypeCode}
and b.status = #{inStatus}
and b.del_flag = #{delFlag} and b.del_flag = 1