a.in_order_id, a.organization_id, a.organization_name, a.top_organization_id, a.notice_number, a.in_order_number, a.status,
a.audit_status, a.audit_remark, a.audit_by, a.audit_by_name, a.audit_time, a.warehouse_id, a.warehouse_code, a.warehouse_name, a.shipper_id, a.shipper_code,
a.shipper_name, a.order_type_code, a.order_type_name, a.supplier_id, a.supplier_code, a.supplier_name, a.expect_time, a.supply_chain_number,
a.priority_level_code, a.priority_level_name, a.direct_warehouse, a.annex_url, a.material_quantity, a.quantity,a.billing_json,a.SETTLEMENT_CURRENCY,
a.SALESMAN_ID,a.SALESMAN_NAME,a.PICTURE_URL,a.PUSH_TIME,a.PUSH_BY,a.PUSH_BY_NAME,a.PUSH_STATUS,
-- 计划入库数量:入库明细表 in_material_detail 的 quantity 汇总
(select ifnull(sum(imd.quantity), 0)
from in_material_detail imd
where imd.in_order_number = a.in_order_number
and imd.del_flag = 1
and (imd.level is null or imd.level = 1)
) as plan_in_quantity,
-- 收货数量:收货单表 stock_receipt_order 的 receipt_quantity 汇总
(select ifnull(sum(sro.receipt_quantity), 0)
from stock_receipt_order sro
where sro.in_order_number = a.in_order_number
and sro.del_flag = 1
) as receipt_quantity,
-- 上架数量:上架单表 stock_shelf_order 的 shelves_quantity 汇总
(select ifnull(sum(sso.shelves_quantity), 0)
from stock_shelf_order sso
where sso.in_order_number = a.in_order_number
and sso.del_flag = 1
) as shelves_quantity,
a.weight_limit, a.volume_limit, a.cancel_order, a.cancel_remark, a.cancel_by,
a.cancel_by_name, a.cancel_time, a.close_order, a.close_remark, a.close_by, a.close_by_name, a.close_time, 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."TO", a.CONTACT_PERSON, a.VEHICLE_INFO, a.CONSIGNMENT_NO, a.TEL, a.DRIVER_SIGNATURE, a.FAX, a.DECLARATION_AREA, a.MANUFACTURER,
a.CUSTOMS_BROKER_INFO, a.DELIVERY_ADDRESS, a.ENTRY_EXIT_CUSTOMS, a.ORIGIN_DESTINATION_COUNTRY, a.CARRIER, a.CONTAINER_NO,
a.TRANSPORT_METHOD, a.SUPERVISION_METHOD, a.CUSTOMS_INSPECTION, a.NEED_CUSTOMS_DECLARATION, a.NEED_TRANSPORT,
a.WAREHOUSE_DATE, a.COMPLETION_TIME, a.ORDER_DATE,a.stock_in_order,a.business_order_no,a.WORK_USER_ID,a.WORK_TASK_RECEIVE_STATUS,a.TASK_ISSUE_USER_ID,a.WORK_USER_NAME
,b.notice_number, b.warehouse_id, b.warehouse_code, b.warehouse_name, b.shipper_id, b.shipper_code, b.shipper_name,
b.order_type_code, b.order_type_name, b.supplier_id, b.supplier_code, b.supplier_name, b.expect_time, b.supply_chain_number, b.priority_level_code,
b.priority_level_name, b.direct_warehouse, b.annex_url, b.material_quantity as in_order_material_quantity, b.quantity as in_order_quantity
,b.NEED_CUSTOMS_DECLARATION,b.completion_time
and b.notice_number = #{noticeNumber}
and b.in_order_number like concat('%', #{inOrderNumber}, '%')
and b.warehouse_id = #{warehouseId}
and b.warehouse_code = #{warehouseCode}
and b.warehouse_name like concat('%', #{warehouseName}, '%')
and b.shipper_id = #{shipperId}
and b.shipper_name like concat('%', #{shipperName}, '%')
and b.order_type_code = #{orderTypeCode}
and b.order_type_name like concat('%', #{orderTypeName}, '%')
and b.supplier_id = #{supplierId}
and b.supplier_name like concat('%', #{supplierName}, '%')
and b.expect_time = #{expectTime}
and b.supply_chain_number = #{supplyChainNumber}
and b.priority_level_code = #{priorityLevelCode}
and b.priority_level_name like concat('%', #{priorityLevelName}, '%')
and b.direct_warehouse = #{directWarehouse}
and b.annex_url = #{annexUrl}
and b.quantity = #{quantity}
and b.need_customs_declaration = #{needCustomsDeclaration}
and a.organization_id = #{organizationId}
and a.organization_name like concat('%', #{organizationName}, '%')
and a.top_organization_id = #{topOrganizationId}
and a.notice_number = #{noticeNumber}
and a.in_order_number = #{inOrderNumber}
and a.status = #{status}
and a.status < #{ltStatus}
and a.status > #{gtStatus}
and a.audit_status = #{auditStatus}
and a.audit_status < #{ltAuditStatus}
and a.audit_status > #{gtAuditStatus}
and a.audit_remark = #{auditRemark}
and a.audit_by = #{auditBy}
and a.audit_by_name like concat('%', #{auditByName}, '%')
and a.audit_time = #{auditTime}
and a.warehouse_id = #{warehouseId}
and a.warehouse_code = #{warehouseCode}
and a.warehouse_name like concat('%', #{warehouseName}, '%')
and a.shipper_id = #{shipperId}
and a.shipper_name like concat('%', #{shipperName}, '%')
and a.order_type_code = #{orderTypeCode}
and a.order_type_name like concat('%', #{orderTypeName}, '%')
and a.supplier_id = #{supplierId}
and a.supplier_name like concat('%', #{supplierName}, '%')
and a.expect_time = #{expectTime}
and a.supply_chain_number = #{supplyChainNumber}
and a.priority_level_code = #{priorityLevelCode}
and a.priority_level_name like concat('%', #{priorityLevelName}, '%')
and a.direct_warehouse = #{directWarehouse}
and a.annex_url = #{annexUrl}
and a.quantity = #{quantity}
and a.cancel_order = #{cancelOrder}
and a.cancel_remark = #{cancelRemark}
and a.cancel_by = #{cancelBy}
and a.cancel_by_name like concat('%', #{cancelByName}, '%')
and a.cancel_time = #{cancelTime}
and a.close_order = #{closeOrder}
and a.close_remark = #{closeRemark}
and a.close_by = #{closeBy}
and a.close_by_name like concat('%', #{closeByName}, '%')
and a.close_time = #{closeTime}
and a.create_by_name like concat('%', #{createByName}, '%')
and a.update_by_name like concat('%', #{updateByName}, '%')
and a.in_order_id in
#{item}
and a.status in
#{item}
and a.TASK_ISSUE_USER_ID like concat('%', #{queryUserId}, '%')
and a."TO" like concat('%', #{to}, '%')
and a.CONTACT_PERSON like concat('%', #{contactPerson}, '%')
and a.VEHICLE_INFO like concat('%', #{vehicleInfo}, '%')
and a.CONSIGNMENT_NO like concat('%', #{consignmentNo}, '%')
and a.TEL like concat('%', #{tel}, '%')
and a.DRIVER_SIGNATURE like concat('%', #{driverSignature}, '%')
and a.FAX like concat('%', #{fax}, '%')
and a.DECLARATION_AREA like concat('%', #{declarationArea}, '%')
and a.MANUFACTURER like concat('%', #{manufacturer}, '%')
and a.CUSTOMS_BROKER_INFO like concat('%', #{customsBrokerInfo}, '%')
and a.DELIVERY_ADDRESS like concat('%', #{deliveryAddress}, '%')
and a.ENTRY_EXIT_CUSTOMS like concat('%', #{entryExitCustoms}, '%')
and a.ORIGIN_DESTINATION_COUNTRY like concat('%', #{originDestinationCountry}, '%')
and a.CARRIER like concat('%', #{carrier}, '%')
and a.CONTAINER_NO = #{containerNo}
and a.TRANSPORT_METHOD = #{transportMethod}
and a.SUPERVISION_METHOD = #{supervisionMethod}
and a.CUSTOMS_INSPECTION = #{customsInspection}
and a.NEED_CUSTOMS_DECLARATION = #{needCustomsDeclaration}
and a.NEED_TRANSPORT = #{needTransport}
and a.WAREHOUSE_DATE = #{warehouseDate}
and a.COMPLETION_TIME = #{completionTime}
and a.ORDER_DATE = #{orderDate}
and date_format(a.create_time,'%Y-%m-%d') >= #{createTimeStart}
and date_format(a.create_time,'%Y-%m-%d') <= #{createTimeEnd}
and a.PUSH_TIME =]]> #{pushTimeFrom}
and a.PUSH_TIME #{pushTimeTo}
and a.create_time =]]> #{createTimeFrom}
and a.create_time #{createTimeTo}
and a.PUSH_STATUS = #{pushStatus}
and exists (
select 1 from in_material_detail imd
left join material_base_info mb on imd.material_base_info_id = mb.material_base_info_id and mb.del_flag = 1
where imd.in_order_number = a.in_order_number
and imd.del_flag = 1
and (imd.level is null or imd.level = 1)
and (
imd.material_name like concat('%', #{materialName}, '%')
or mb.material_name like concat('%', #{materialName}, '%')
)
and (
imd.material_code like concat('%', #{materialCode}, '%')
or mb.material_code like concat('%', #{materialCode}, '%')
)
)
and a.del_flag = #{delFlag} and a.del_flag = 1