<iftest="receiveProvince != null and receiveProvince != ''"> and receive_province=#{receiveProvince}</if>
<iftest="receiveCity != null and receiveCity != ''"> and receive_city=#{receiveCity}</if>
<iftest="receiveCounty != null and receiveCounty != ''"> and receive_county=#{receiveCounty}</if>
<iftest="receiveTown != null and receiveTown != ''"> and receive_town=#{receiveTown}</if>
<iftest="receiveAddress != null and receiveAddress != ''"> and receive_address like concat('%', #{receiveAddress}, '%')</if>
<iftest="receivePostcode != null and receivePostcode != ''"> and receive_postcode like concat('%', #{receivePostcode}, '%')</if>
<iftest="receivePcd != null and receivePcd != ''"> and receive_pcd like concat('%', #{receivePcd}, '%')</if>
<iftest="sendName != null and sendName != ''"> and send_name like concat('%', #{sendName}, '%')</if>
<iftest="sendCompany != null and sendCompany != ''"> and send_company like concat('%', #{sendCompany}, '%')</if>
<iftest="sendMobile != null and sendMobile != ''"> and send_mobile like concat('%', #{sendMobile}, '%')</if>
<iftest="sendTel != null and sendTel != ''"> and send_tel like concat('%', #{sendTel}, '%')</if>
<iftest="sendCountry != null and sendCountry != ''"> and send_country=#{sendCountry}</if>
<iftest="sendProvince != null and sendProvince != ''"> and send_province=#{sendProvince}</if>
<iftest="sendCity != null and sendCity != ''"> and send_city=#{sendCity}</if>
<iftest="sendCounty != null and sendCounty != ''"> and send_county=#{sendCounty}</if>
<iftest="sendTown != null and sendTown != ''"> and send_town=#{sendTown}</if>
<iftest="sendAddress != null and sendAddress != ''"> and send_address like concat('%', #{sendAddress}, '%')</if>
<iftest="sendPostcode != null and sendPostcode != ''"> and send_postcode like concat('%', #{sendPostcode}, '%')</if>
<iftest="paymentType != null and paymentType != ''"> and payment_type=#{paymentType}</if>
<iftest="calcFeeType != null and calcFeeType != ''"> and calc_fee_type=#{calcFeeType}</if>
<iftest="custNo != null and custNo != ''"> and cust_no like concat('%', #{custNo}, '%')</if>
<iftest="custName != null and custName != ''"> and cust_name like concat('%', #{custName}, '%')</if>
<iftest="transLineType != null and transLineType != ''"> and trans_line_type=#{transLineType}</if>
<iftest="productType != null and productType != ''"> and product_type=#{productType}</if>
<iftest="timeType != null and timeType != ''"> and time_type like concat('%', #{timeType}, '%')</if>
<iftest="meterType != null and meterType != ''"> and meter_type like concat('%', #{meterType}, '%')</if>
<iftest="carryType != null and carryType != ''"> and carry_type like concat('%', #{carryType}, '%')</if>
<iftest="customsClear != null and customsClear != ''"> and customs_clear=#{customsClear}</if>
<iftest="customsEclaration != null and customsEclaration != ''"> and customs_eclaration=#{customsEclaration}</if>
<iftest="estimateDate != null "> and estimate_date = #{estimateDate}</if>
<iftest="packType != null and packType != ''"> and FIND_IN_SET(#{packType},pack_type)</if>
<iftest="dispatchMethod != null and dispatchMethod != ''"> and dispatch_method=#{dispatchMethod}</if>
<iftest="pickupMethod != null and pickupMethod != ''"> and pickup_method= #{pickupMethod}</if>
<iftest="pickStartDate != null "> and pick_start_date = #{pickStartDate}</if>
<iftest="pickFinishDate != null "> and pick_finish_date = #{pickFinishDate}</if>
<iftest="pickFailReason != null and pickFailReason != ''"> and pick_fail_reason like concat('%', #{pickFailReason}, '%')</if>
<iftest="intoWarehouseCode != null and intoWarehouseCode != ''"> and into_warehouse_code like concat('%', #{intoWarehouseCode}, '%')</if>
<iftest="intoWarehouseName != null and intoWarehouseName != ''"> and into_warehouse_name like concat('%', #{intoWarehouseName}, '%')</if>
<iftest="intoWarehouseAddress != null and intoWarehouseAddress != ''"> and into_warehouse_address like concat('%', #{intoWarehouseAddress}, '%')</if>
<iftest="intoWarehouseContact != null and intoWarehouseContact != ''"> and into_warehouse_contact like concat('%', #{intoWarehouseContact}, '%')</if>
<iftest="intoWarehousePhone != null and intoWarehousePhone != ''"> and into_warehouse_phone like concat('%', #{intoWarehousePhone}, '%')</if>
<iftest="intoWarehouseBillCode != null and intoWarehouseBillCode != ''"> and into_warehouse_bill_code like concat('%', #{intoWarehouseBillCode}, '%')</if>
<iftest="warehouseInNo != null and warehouseInNo != ''"> and warehouse_in_no like concat('%', #{warehouseInNo}, '%')</if>
<iftest="customerDeliveryBeginTime != null and customerDeliveryBeginTime != ''"> and customer_delivery_begin_time like concat('%', #{customerDeliveryBeginTime}, '%')</if>
<iftest="customerDeliveryEndTime != null and customerDeliveryEndTime != ''"> and customer_delivery_end_time like concat('%', #{customerDeliveryEndTime}, '%')</if>
<iftest="goodsInfo != null and goodsInfo != ''"> and goods_info like concat('%', #{goodsInfo}, '%')</if>
<iftest="blPrepareInFreight != null and blPrepareInFreight != ''"> and bl_prepare_in_freight=#{blPrepareInFreight}</if>
<iftest="prepareInEstFee != null "> and prepare_in_est_fee = #{prepareInEstFee}</if>
<iftest="prepareInRealFee != null "> and prepare_in_real_fee = #{prepareInRealFee}</if>
<iftest="prepareInExpress != null and prepareInExpress != ''"> and prepare_in_express like concat('%', #{prepareInExpress}, '%')</if>
<iftest="prepareInBillCode != null and prepareInBillCode != ''"> and prepare_in_bill_code like concat('%', #{prepareInBillCode}, '%')</if>
<iftest="prepareInRemark != null and prepareInRemark != ''"> and prepare_in_remark like concat('%', #{prepareInRemark}, '%')</if>
<iftest="prepareInSupplier != null and prepareInSupplier != ''"> and prepare_in_supplier like concat('%', #{prepareInSupplier}, '%')</if>
<iftest="totalWeight != null "> and total_weight = #{totalWeight}</if>
<iftest="totalVolume != null "> and total_volume = #{totalVolume}</if>
<iftest="parcelQty != null "> and parcel_qty = #{parcelQty}</if>
<iftest="billWeight != null "> and bill_weight = #{billWeight}</if>
<iftest="volumeWeight != null "> and volume_weight = #{volumeWeight}</if>
<iftest="currency != null and currency != ''"> and currency= #{currency}</if>
<iftest="settlementWeight != null "> and settlement_weight = #{settlementWeight}</if>
<iftest="scanWeight != null "> and scan_weight = #{scanWeight}</if>
<iftest="feeWeight != null "> and fee_weight = #{feeWeight}</if>
<iftest="freight != null "> and freight = #{freight}</if>
<iftest="realPaymentType != null and realPaymentType != ''"> and real_payment_type=#{realPaymentType}</if>
<iftest="realFee != null "> and real_fee = #{realFee}</if>
<iftest="blSpecialQuote != null and blSpecialQuote != ''"> and bl_special_quote=#{blSpecialQuote}</if>
<iftest="blOverLong != null and blOverLong != ''"> and bl_over_long=#{blOverLong}</if>
<iftest="blBill != null and blBill != ''"> and bl_bill=#{blBill}</if>
<iftest="blBillText != null and blBillText != ''"> and bl_bill_text like concat('%', #{blBillText}, '%')</if>
<iftest="blOverWeight != null and blOverWeight != ''"> and bl_over_weight like concat('%', #{blOverWeight}, '%')</if>
<iftest="overWeightNumber != null and overWeightNumber != ''"> and over_weight_number like concat('%', #{overWeightNumber}, '%')</if>
<iftest="feeRemark != null and feeRemark != ''"> and fee_remark like concat('%', #{feeRemark}, '%')</if>
<iftest="thirdCode != null and thirdCode != ''"> and third_code like concat('%', #{thirdCode}, '%')</if>
<iftest="realValue != null and realValue != ''"> and real_value like concat('%', #{realValue}, '%')</if>
<iftest="blInsure != null and blInsure != ''"> and bl_insure= #{blInsure}</if>
<iftest="insureValue != null and insureValue != ''"> and insure_value like concat('%', #{insureValue}, '%')</if>
<iftest="insureValueCurrency != null and insureValueCurrency != ''"> and insure_value_currency like concat('%', #{insureValueCurrency}, '%')</if>
<iftest="insureFeeCurrency != null and insureFeeCurrency != ''"> and insure_fee_currency like concat('%', #{insureFeeCurrency}, '%')</if>
<iftest="insureFee != null "> and insure_fee = #{insureFee}</if>
<iftest="insureRemark != null and insureRemark != ''"> and insure_remark like concat('%', #{insureRemark}, '%')</if>
<iftest="insureSiteCode != null and insureSiteCode != ''"> and insure_site_code=#{insureSiteCode}</if>
<iftest="blPrint != null and blPrint != ''"> and bl_print=#{blPrint}</if>
<iftest="printManCode != null and printManCode != ''"> and print_man_code like concat('%', #{printManCode}, '%')</if>
<iftest="printSite != null and printSite != ''"> and print_site=#{printSite},</if>
<iftest="printDate != null and printDate != ''"> and print_date like concat('%', #{printDate}, '%')</if>
<iftest="blDispFd != null and blDispFd != ''"> and bl_disp_fd=#{blDispFd}</if>
<iftest="transferCode != null and transferCode != ''"> and transfer_code like concat('%', #{transferCode}, '%')</if>
<iftest="transferBillcode != null and transferBillcode != ''"> and transfer_billcode like concat('%', #{transferBillcode}, '%')</if>
<iftest="dispFdDate != null "> and disp_fd_date = #{dispFdDate}</if>
<iftest="dispFdReason != null and dispFdReason != ''"> and disp_fd_reason like concat('%', #{dispFdReason}, '%')</if>
<iftest="currentSiteCode != null and currentSiteCode != ''"> and current_site_code=#{currentSiteCode}</if>
<iftest="nextSiteCode != null and nextSiteCode != ''"> and next_site_code= #{nextSiteCode}</if>
<iftest="lastSiteCode != null and lastSiteCode != ''"> and last_site_code=#{lastSiteCode}</if>
<iftest="registerSiteCode != null and registerSiteCode != ''"> and register_site_code=#{registerSiteCode}</if>
<iftest="registerDate != null "> and register_date = #{registerDate}</if>
<iftest="registerManCode != null and registerManCode != ''"> and register_man_code= #{registerManCode}</if>
<iftest="takePieceEmployeeCode != null and takePieceEmployeeCode != ''"> and take_piece_employee_code=#{takePieceEmployeeCode}</if>
<iftest="sendSiteCode != null and sendSiteCode != ''"> and send_site_code=#{sendSiteCode}</if>
<iftest="sendDate != null "> and send_date = #{sendDate}</if>
<iftest="dispatchManCode != null and dispatchManCode != ''"> and dispatch_man_code=#{dispatchManCode}</if>
<iftest="dispatchSiteCode != null and dispatchSiteCode != ''"> and dispatch_site_code=#{dispatchSiteCode}</if>
<iftest="produceBillDate != null "> and produce_bill_date = #{produceBillDate}</if>
<iftest="produceBillSiteCode != null and produceBillSiteCode != ''"> and produce_bill_site_code=#{produceBillSiteCode}</if>
<iftest="produceBillManCode != null and produceBillManCode != ''"> and produce_bill_man_code=#{produceBillManCode}</if>
<iftest="destinationCode != null and destinationCode != ''"> and destination_code =#{destinationCode}</if>
<iftest="destinationProvince != null and destinationProvince != ''"> and destination_province=#{destinationProvince}</if>
<iftest="destinationCity != null and destinationCity != ''"> and destination_city=#{destinationCity}</if>
<iftest="destinationCounty != null and destinationCounty != ''"> and destination_county=#{destinationCounty}</if>
<iftest="dispatchUnderlingSiteCode != null and dispatchUnderlingSiteCode != ''"> and dispatch_underling_site_code=#{dispatchUnderlingSiteCode}</if>
<iftest="destinationCenterCode != null and destinationCenterCode != ''"> and destination_center_code=#{destinationCenterCode}</if>
<iftest="marketManCode != null and marketManCode != ''"> and market_man_code = #{marketManCode}</if>
<iftest="payee != null and payee != ''"> and payee=#{payee}</if>
<iftest="salesmen != null and salesmen != ''"> and salesmen like concat('%', #{salesmen}, '%')</if>
<iftest="operateEmployeeCode != null and operateEmployeeCode != ''"> and operate_employee_code=#{operateEmployeeCode}</if>
<iftest="blIsQuestion != null and blIsQuestion != ''"> and bl_is_question=#{blIsQuestion}</if>
<iftest="problemType != null and problemType != ''"> and problem_type=#{problemType}</if>
<iftest="problemCause != null and problemCause != ''"> and problem_cause like concat('%', #{problemCause}, '%')</if>
<iftest="problemDelayDays != null "> and problem_delay_days = #{problemDelayDays}</if>
<iftest="blMessage != null and blMessage != ''"> and bl_message=#{blMessage}</if>
<iftest="blAcceptMessage != null and blAcceptMessage != ''"> and bl_accept_message=#{blAcceptMessage}</if>
<iftest="blGenSubbill != null and blGenSubbill != ''"> and bl_gen_subbill=#{blGenSubbill}</if>
<iftest="signMan != null and signMan != ''"> and sign_man like concat('%', #{signMan}, '%')</if>
<iftest="signManCode != null and signManCode != ''"> and sign_man_code=#{signManCode}</if>
<iftest="signSiteCode != null and signSiteCode != ''"> and sign_site_code=#{signSiteCode}</if>
<iftest="paymentStatus != null and paymentStatus != ''"> and payment_status =#{paymentStatus}</if>
<iftest="paymentDate != null "> and payment_date = #{paymentDate}</if>
<iftest="paymentRemark != null and paymentRemark != ''"> and payment_remark like concat('%', #{paymentRemark}, '%')</if>
<iftest="orderRemark != null and orderRemark != ''"> and order_remark like concat('%', #{orderRemark}, '%')</if>
<iftest="sendSiteCode != null and sendSiteCode != ''"> and a.send_site_code= #{sendSiteCode}</if>
<iftest="remark != null and remark != ''"> and a.remark like concat('%', #{remark}, '%')</if>
<iftest="createBy != null and createBy != ''"> and a.create_by= #{createBy}</if>
<iftest="updateBy != null and updateBy != ''"> and a.update_by=#{updateBy}</if>
<iftest="createSite != null and createSite != ''"> and a.create_site=#{createSite}</if>
<iftest="updateSite != null and updateSite != ''"> and a.update_site=#{updateSite}</if>
select 1 from emis_waybill_problem_info ewpi where a.bill_code=ewpi.bill_code and ewpi.del_flag='0' and ewpi.`problem_type` !=null and ewpi.`problem_type` in(173,170,151)
select 1 from emis_waybill_problem_info ewpi where a.bill_code=ewpi.bill_code and ewpi.del_flag='0' and ewpi.`problem_type` !=null and ewpi.`problem_type` in(173,170,151)
and exists (select 1 from emis_customer_user ecu where a.del_flag='0' and a.receive_mobile=ecu.phone and ecu.customer_code=#{customerCode} )
and not exists(
select 1 from emis_waybill_problem_info ewpi where a.bill_code=ewpi.bill_code and ewpi.del_flag='0' and ewpi.`problem_type` !=null and ewpi.`problem_type` in(173,170,151)