//
//  RescueController.swift
//  OrderScheduling
//
//  Created by 中道 on 2023/8/4.
//

import Foundation
import JXCategoryView
import SnapKit
import DDCategoryKit_Private
import DDAutoUIKit_Private
import DDControlsKit_Private
import RxSwift
import RxRelay
import MJRefresh
import DDWebImageKit_Private
import ESTabBarController_swift
import DDUtilsSwiftKit_Private
import DDAudioPlayerKit_Private
import TYCyclePagerView

// MARK: Action
extension RescueController {
    func addActions() {
        MCOUNT.messageCountRelay
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] count in
                if count > 0 {
                    self?.messageView.countLabel.isHidden = false
                    self?.messageView.countLabel.text = String(count)
                    self?.messageView.countLabel.snp.updateConstraints({ make in
                        make.width.equalTo(20)
                    })
                }else{
                    self?.messageView.countLabel.isHidden = true
                    self?.messageView.countLabel.snp.updateConstraints({ make in
                        make.width.equalTo(0)
                    })
                }
            })
            .disposed(by: disposeBag)
        
        MCOUNT.pendingCountRelay
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] count in
                if count > 0 {
                    self?.pendingView.countLabel.isHidden = false
                    self?.pendingView.countLabel.text = String(count)
                    self?.pendingView.countLabel.snp.updateConstraints({ make in
                        make.width.equalTo(20)
                    })
                }else{
                    self?.pendingView.countLabel.isHidden = true
                    self?.pendingView.countLabel.snp.updateConstraints({ make in
                        make.width.equalTo(0)
                    })
                }
            })
            .disposed(by: disposeBag)
        
        messageTapGes.rx.event
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                MESSAGETOOL.openMessageCenter(by: self?.navigationController)
            })
            .disposed(by: disposeBag)
        
        pendingTapGes.rx.event
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: { _ in
                WEBTOOL.open(name: .todoList,appending: nil)
            })
            .disposed(by: disposeBag)
        
        filterButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                if let containerView = self?.categoryView.listContainer as? JXCategoryListContainerView,let selectedIndex = self?.categoryView.selectedIndex {
                    let key = NSNumber(value: selectedIndex)
                    let vc = containerView.validListDict[key] as? ConditionalSearchParentController
                    vc?.conditionalSearchTool.showFilterView()
                }
            })
            .disposed(by: disposeBag)
        
        USER.refreshTokenSub
            .subscribe(onNext: {[weak self] _ in
                self?.excuseRelay()
            })
            .disposed(by: disposeBag)
        
        appPushRecordRelay
            .flatMapLatest { _ in
                return RQ.appPushRecordList()
            }
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] response in
                if response?.success == true {
                    var flag = false
                    if (response?.data?.count ?? 0) > 1 {
                        flag = true
                    }
                    if let model = response?.data?.first {
                        PushNotiCommonTool.default.open(model: model) {[weak self] in
                            if flag == true {
                                self?.appPushRecordRelay.accept(nil)
                            }
                        }
                    }
                }else{
                    self?.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        
        appBannerRelay
            .flatMapLatest { _ in
                return RQ.getConfigByCode(parameters: ConfigByCodeParameters(code: "supplierAppBannerConfig"))
            }
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] response in
                if response?.success == true {
                    let bannerConfig = response?.data?.bannerConfig ?? []
                    WEBTOOL.bannerInMineDataSources = bannerConfig
                    self?.bannerDataSources = bannerConfig
                    self?.pagerView.reloadData()
                    if let count = self?.bannerDataSources.count, count > 0 {
                        self?.pagerView.snp.updateConstraints({ make in
                            make.height.equalTo(auto(56))
                        })
                    }
                }else{
                    self?.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        
        WEBTOOL.supplierAppIsUserNewReportRelay
            .flatMapLatest { _ in
                return RQ.getConfigByCode(parameters: ConfigByCodeParameters(code: "AppIsUseNewReport"))
            }
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] response in
                if response?.success == true {
                    WEBTOOL.supplierAppIsUserNewReport = (response?.data?.supplierAppIsUserNewReport == true)
                }else{
                    self?.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        
        onlineReminderRelay
            .flatMapLatest { _ in
                return RQ.onlineReminder(parameters: OnlineReminderParameters(supplierId: UserData.default.supplierId))
            }
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: { [weak self] response in
                guard let self = self else { return }

                if response?.success == true, let data = response?.data, let content = data.content {
                    let entryView = OnlineVehiclesEntryView(content: content)
                    entryView.onConfirm = { [weak self] in
                        guard let self = self else { return }
                        Entry.default.dismiss(name: "onlineVehiclesEntryView")
                        if let id = response?.data?.id {
                            RQ.readMessageReminder(parameters: ReadMessageReminderParameters(id: id))
                                .observe(on: MainScheduler.instance)
                                .subscribe(onSuccess: {[weak self] readResponse in
                                    guard let self = self else { return }
                                    if readResponse?.success == true {
                                    } else {
                                        self.view.dd_makeToast(readResponse?.msg)
                                    }
                                })
                                .disposed(by: self.disposeBag)
                        }
                    }
                    Entry.default.showOnlineVehiclesEntry(view: entryView, name: "onlineVehiclesEntryView")
                    Tool.default.playVoiceWith(broadcast: content)
                } else {
                    self.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        
        judgeIfNeedConfirmEntryRelay
            .flatMapLatest { _ in
                return RQ.judgeIfNeedConfirm(prameters: JudgeIfNeedConfirmParameters(supplierId: UserData.default.supplierId))
            }
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] response in
                guard let self = self else { return }
                if response?.success == true {
                    if response?.data?.needConfirm == true {
                        let isLast = (response?.data?.isLast == true)
                        let entryName = "IdentityAlert"
                        let entryView = IdentityAlertView(times: response?.data?.count ?? 0,totalTimes: 3, isLast: isLast)
                        entryView.onLater = {
                            Entry.default.dismiss(name: entryName,completion: {
                                if isLast {
                                    RQ.giveUp(prameters: GiveUpParameters(supplierId: UserData.default.supplierId))
                                        .subscribe(onSuccess: { _ in
                                        })
                                        .disposed(by: self.disposeBag)
                                }
                            })
                        }
                        entryView.onConfirm = {
                            Entry.default.dismiss(name: entryName,completion: {
                                if let supplierId = UserData.default.supplierId {
                                    WEBTOOL.open(name: .managerPeople, appending: "&supplierId=\(supplierId)")
                                }
                            })
                        }
                        Entry.default.showIdentityAlert(view: entryView, name: entryName)
                    }
                }else{
                    self.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        
        // 点击tabBar 需要刷下下列
        preRefreshRelay
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.excuseRelay()
                MCOUNT.newestMessage()
                self?.categoryView.reloadData()
            })
            .disposed(by: disposeBag)
    }
    
    func excuseRelay() {
        NewTraining.default.newTrainingRelay.accept(nil)
        WEBTOOL.supplierAppIsUserNewReportRelay.accept(nil)
        appBannerRelay.accept(nil)
        appPushRecordRelay.accept(nil)
        onlineReminderRelay.accept(nil)
        judgeIfNeedConfirmEntryRelay.accept(nil)
    }
}

extension RescueController : TYCyclePagerViewDataSource, TYCyclePagerViewDelegate {
    func layout(for pageView: TYCyclePagerView) -> TYCyclePagerViewLayout {
        let layout = TYCyclePagerViewLayout()
        layout.itemSize = CGSize(width: pageView.width, height: pageView.height)
        layout.itemHorizontalCenter = true
        return layout
    }
    
    func numberOfItems(in pageView: TYCyclePagerView) -> Int {
        return bannerDataSources.count
    }
    
    func pagerView(_ pagerView: TYCyclePagerView, cellForItemAt index: Int) -> UICollectionViewCell {
        let cell = pagerView.dequeueReusableCell(withReuseIdentifier: "cell", for: index) as? TYCyclePagerViewCell
        let model = bannerDataSources[index]
        if let bannerIcon = model.bannerIcon {
            cell?.imageView.dd_setImage(with: URL(string: bannerIcon))
        }
        return cell!
    }
    
    func pagerView(_ pageView: TYCyclePagerView, didSelectedItemCell cell: UICollectionViewCell, at index: Int) {
        let model = bannerDataSources[index]
        if let linkUrl = model.linkUrl {
            let vc = WebViewController.init(showNavBar: false,title: nil,url: linkUrl+"?token=\((USER.token)!)")
            navigationController?.pushViewController(vc, animated: true)
        }
    }
}

extension RescuePendingOrderController {
    func addActions() {
        pendingOrderView.tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
            self?.pageNum = 1
            self?.refreshRelay.accept(self?.pageNum ?? 1)
        })
        
        pendingOrderView.tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
            self?.pageNum+=1
            self?.refreshRelay.accept(self?.pageNum ?? 1)
        })

        refreshRelay
            .flatMapLatest {[weak self] pageNum in
                return Observable.zip(RQ.orderList(parameters:self?.conditionalSearchTool.getParameters(pageNum: pageNum, queryType: .TO_ACCEPT_DISPATCH) ?? OrderListParameters(pageNum: pageNum, queryType: .TO_ACCEPT_DISPATCH)).asObservable(), Observable.just(pageNum))
            }
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] (response, pageNum) in
                if response?.success == true {
                    if pageNum == 1 {
                        self?.resultArr.removeAll()
                        self?.pendingOrderView.tableView.mj_footer?.resetNoMoreData()
                        self?.pendingOrderView.tableView.mj_header?.endRefreshing()
                    }else{
                        if response?.data?.isEmpty == false {
                            self?.pendingOrderView.tableView.mj_footer?.endRefreshing()
                        }else{
                            self?.pendingOrderView.tableView.mj_footer?.endRefreshingWithNoMoreData()
                        }
                    }
                    
                    if let array = response?.data {
                        self?.resultArr.append(contentsOf: array)
                    }
                    
                    if self?.resultArr.isEmpty == false {
                        self?.emptyView.isHidden = true
                    }else{
                        self?.emptyView.isHidden = false
                    }
                    
                    self?.pendingOrderView.tableView.reloadData()
                }else{
                    if pageNum == 1 {
                        self?.pendingOrderView.tableView.mj_header?.endRefreshing()
                    }else{
                        self?.pendingOrderView.tableView.mj_footer?.endRefreshing()
                    }
                    self?.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
                
        refuseOrderConfirmView.cancelButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: { _ in
                ENTRY.dismiss(name: refuseOrderConfirmEntry)
            })
            .disposed(by: disposeBag)
        
        refuseOrderConfirmView.sureButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                ENTRY.dismiss(name: refuseOrderConfirmEntry) {[weak self] in
                    if let model = self?.refuseOrderModel {
                        self?.refuseRemarkIdRelay.accept(model)
                    }
                }
            })
            .disposed(by: disposeBag)
        
        refuseRemarkIdRelay
            .observe(on: MainScheduler.instance)
            .do(onNext: {[weak self] _ in
                self?.view.dd_showHUD()
            })
            .flatMapLatest { model in
                return Observable.zip(RQ.refuseDispatch(parameters: RefuseDispatchParameters(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId)).asObservable(), Observable.just(model))
            }
            .observe(on: MainScheduler.instance)
            .do(onNext: {[weak self] _ in
                self?.view.dd_hideHUD()
            })
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] (response,model) in
                if response?.success == true {
                    self?.entry(model: model,remarkId: response?.data)
                }else{
                    self?.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        
        acceptOrderRelay
            .flatMapLatest { model in
                return Observable.zip(RQ.acceptDispatch(parameters: AcceptDispatchParameters(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId)).asObservable(), Observable.just(model))
            }
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] (response,model) in
                if response?.success == true {
                    self?.resultArr.removeAll { _model in
                        _model.userOrderId == model.userOrderId
                    }
                    if self?.resultArr.isEmpty == false {
                        self?.emptyView.isHidden = true
                    }else{
                        self?.emptyView.isHidden = false
                    }
                    self?.pendingOrderView.tableView.reloadData()
                }else{
                    self?.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        
        conditionalSearchTool.searchSub
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.pendingOrderView.tableView.mj_header?.beginRefreshing()
            })
            .disposed(by: disposeBag)
        
        USER.refreshTokenSub
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.pendingOrderView.tableView.mj_header?.beginRefreshing()
            })
            .disposed(by: disposeBag)
        
        USERP.userPermissionRelay
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.pendingOrderView.tableView.reloadData()
            })
            .disposed(by: disposeBag)
    }
    
    func entry(model:OrderListDataModel,remarkId:String?) {
        let view = RefuseOrderEntryView()
        view.exitButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: { _ in
                ENTRY.dismiss(name: refuseOrderEntry)
            })
            .disposed(by: disposeBag)
        
        view.submitButton.rx.tap
            .flatMapLatest({[weak self] _ in
                return self?.getRefuseParameters(view:view,model: model,remarkId: remarkId) ?? Observable.just(RefuseDispatchParameters(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId))
             })
            .flatMapLatest({ parameters in
                return RQ.refuseDispatch(parameters: parameters)
            })
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] response in
                if response?.success == true {
                    self?.resultArr.removeAll { _model in
                        _model.userOrderId == model.userOrderId
                    }
                    if self?.resultArr.isEmpty == false {
                        self?.emptyView.isHidden = true
                    }else{
                        self?.emptyView.isHidden = false
                    }
                    self?.pendingOrderView.tableView.reloadData()
                    ENTRY.dismiss(name: refuseOrderEntry)
                }else{
                    UIApplication.shared.dd_keyWindow.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        ENTRY.showRefuseOrderEntry(view: view,name: refuseOrderEntry)
    }
    
    func getRefuseParameters(view:RefuseOrderEntryView,model:OrderListDataModel,remarkId:String?) -> Observable<RefuseDispatchParameters>{
        return Observable.create { ob in
            var refuseReasonItem : String?
            var refuseReasonDesc : String?
            if view.timeView.selectButton.isSelected == true {
                refuseReasonItem = RefuseDispatchParameters.RefuseReasonItemEnum.time.rawValue
                if view.timeTextFieldView.textFiled.text?.isEmpty == false {
                    refuseReasonDesc = (view.timeTextFieldView.textFiled.text)!+(view.timeTextFieldView.unitLabel.text)!
                }else{
                    refuseReasonDesc = nil
                }
            }
            if view.distanceView.selectButton.isSelected == true {
                refuseReasonItem = RefuseDispatchParameters.RefuseReasonItemEnum.disatance.rawValue
                if view.distanceTextFieldView.textFiled.text?.isEmpty == false {
                    refuseReasonDesc = (view.distanceTextFieldView.textFiled.text)!+(view.distanceTextFieldView.unitLabel.text)!
                }else{
                    refuseReasonDesc = nil
                }
            }
            if view.cannotDispatchView.selectButton.isSelected == true {
                refuseReasonItem = RefuseDispatchParameters.RefuseReasonItemEnum.cannotDispatch.rawValue
                refuseReasonDesc = view.cannotDispatchTextViewView.textView.text
            }
           let parameters = RefuseDispatchParameters(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId,remarkId: remarkId,refuseReasonItem: refuseReasonItem,refuseReasonDesc: refuseReasonDesc)
            ob.onNext(parameters)
            ob.onCompleted()
            return Disposables.create()
        }
    }
}

extension RescuePendingDispatchController {
    
    func addActions() {
        pendingDispatchView.tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
            self?.pageNum = 1
            self?.refreshRelay.accept(self?.pageNum ?? 1)
        })
        
        pendingDispatchView.tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
            self?.pageNum+=1
            self?.refreshRelay.accept(self?.pageNum ?? 1)
        })

        refreshRelay
            .flatMapLatest {[weak self] pageNum in
                return Observable.zip(RQ.orderList(parameters:self?.conditionalSearchTool.getParameters(pageNum: pageNum, queryType: .TO_DISPATCH_VEHICLE) ?? OrderListParameters(pageNum: pageNum, queryType: .TO_DISPATCH_VEHICLE)).asObservable(), Observable.just(pageNum))
            }
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] (response, pageNum) in
                if response?.success == true {
                    if pageNum == 1 {
                        self?.resultArr.removeAll()
                        self?.pendingDispatchView.tableView.mj_footer?.resetNoMoreData()
                        self?.pendingDispatchView.tableView.mj_header?.endRefreshing()
                    }else{
                        if response?.data?.isEmpty == false {
                            self?.pendingDispatchView.tableView.mj_footer?.endRefreshing()
                        }else{
                            self?.pendingDispatchView.tableView.mj_footer?.endRefreshingWithNoMoreData()
                        }
                    }
                    
                    if let array = response?.data {
                        self?.resultArr.append(contentsOf: array)
                    }
                    
                    if self?.resultArr.isEmpty == false {
                        self?.emptyView.isHidden = true
                    }else{
                        self?.emptyView.isHidden = false
                    }
                    
                    self?.pendingDispatchView.tableView.reloadData()
                }else{
                    if pageNum == 1 {
                        self?.pendingDispatchView.tableView.mj_header?.endRefreshing()
                    }else{
                        self?.pendingDispatchView.tableView.mj_footer?.endRefreshing()
                    }
                    self?.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        
        conditionalSearchTool.searchSub
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.pendingDispatchView.tableView.mj_header?.beginRefreshing()
            })
            .disposed(by: disposeBag)
        
        USER.refreshTokenSub
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.pendingDispatchView.tableView.mj_header?.beginRefreshing()
            })
            .disposed(by: disposeBag)
        
        USERP.userPermissionRelay
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.pendingDispatchView.tableView.reloadData()
            })
            .disposed(by: disposeBag)
    }
}

extension RescueIsIngController {
    func addActions() {
        pendingIsIngView.tableView.mj_header = MJRefreshNormalHeader(refreshingBlock: {[weak self] in
            self?.pageNum = 1
            self?.refreshRelay.accept(self?.pageNum ?? 1)
        })
        
        pendingIsIngView.tableView.mj_footer = MJRefreshBackNormalFooter(refreshingBlock: {[weak self] in
            self?.pageNum+=1
            self?.refreshRelay.accept(self?.pageNum ?? 1)
        })

        refreshRelay
            .flatMapLatest {[weak self] pageNum in
                return Observable.zip(RQ.orderList(parameters:self?.conditionalSearchTool.getParameters(pageNum: pageNum,queryType: .TO_RESCUE) ?? OrderListParameters(pageNum: pageNum, queryType: .TO_RESCUE)).asObservable(), Observable.just(pageNum))
            }
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] (response, pageNum) in
                if response?.success == true {
                    if pageNum == 1 {
                        self?.resultArr.removeAll()
                        self?.pendingIsIngView.tableView.mj_footer?.resetNoMoreData()
                        self?.pendingIsIngView.tableView.mj_header?.endRefreshing()
                    }else{
                        if response?.data?.isEmpty == false {
                            self?.pendingIsIngView.tableView.mj_footer?.endRefreshing()
                        }else{
                            self?.pendingIsIngView.tableView.mj_footer?.endRefreshingWithNoMoreData()
                        }
                    }
                    
                    if let array = response?.data {
                        self?.resultArr.append(contentsOf: array)
                    }
                    
                    if self?.resultArr.isEmpty == false {
                        self?.emptyView.isHidden = true
                    }else{
                        self?.emptyView.isHidden = false
                    }
                    
                    self?.pendingIsIngView.tableView.reloadData()
                }else{
                    if pageNum == 1 {
                        self?.pendingIsIngView.tableView.mj_header?.endRefreshing()
                    }else{
                        self?.pendingIsIngView.tableView.mj_footer?.endRefreshing()
                    }
                    self?.view.dd_makeToast(response?.msg)
                }
            })
            .disposed(by: disposeBag)
        
        conditionalSearchTool.searchSub
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.pendingIsIngView.tableView.mj_header?.beginRefreshing()
            })
            .disposed(by: disposeBag)
        
        USER.refreshTokenSub
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.pendingIsIngView.tableView.mj_header?.beginRefreshing()
            })
            .disposed(by: disposeBag)
        
        USERP.userPermissionRelay
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                self?.pendingIsIngView.tableView.reloadData()
            })
            .disposed(by: disposeBag)
    }
}

// MARK: JXCategoryViewDelegate,JXCategoryListContainerViewDelegate
extension RescueController : JXCategoryViewDelegate,JXCategoryListContainerViewDelegate {
    func categoryView(_ categoryView: JXCategoryBaseView!, didSelectedItemAt index: Int) {
        DispatchQueue.main.async { [weak self] in
            if index == 0 {
                self?.pendingTableView?.mj_header?.beginRefreshing()
            }else if index == 1 {
                self?.dispatchTableView?.mj_header?.beginRefreshing()
            }else if index == 2 {
                self?.isRescueTableView?.mj_header?.beginRefreshing()
            }
        }
    }

    func number(ofListsInlistContainerView listContainerView: JXCategoryListContainerView!) -> Int {
        return categoryView.titles.count
    }
    
    func listContainerView(_ listContainerView: JXCategoryListContainerView!, initListFor index: Int) -> JXCategoryListContentViewDelegate! {
        var vc : ConditionalSearchParentController
        if index == 0 {
            vc = RescuePendingOrderController.init()
            pendingTableView = (vc as? RescuePendingOrderController)?.pendingOrderView.tableView
        }else if index == 1 {
            vc = RescuePendingDispatchController.init()
            dispatchTableView = (vc as? RescuePendingDispatchController)?.pendingDispatchView.tableView
        }else{
            vc = RescueIsIngController.init()
            isRescueTableView = (vc as? RescueIsIngController)?.pendingIsIngView.tableView
        }

        vc.conditionalSearchTool.isFilterSub
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] isFilter in
                ConditionalSearchTool.resetFilterButton(self?.filterButton, filterState: isFilter, type: .rescue)
            })
            .disposed(by: disposeBag)
        
        return vc
    }
}

// MARK: UITableViewDelegate,UITableViewDataSource
extension RescuePendingOrderController : UITableViewDelegate,UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return resultArr.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? RescuePendingOrderCell
        if cell == nil {
            cell = RescuePendingOrderCell(style: .default, reuseIdentifier: "cell")
            cell?.line.backgroundColor = .hex("E9E9EA").alpha(0.6)
            cell?.merchantTitleLabel.text = "商户名称:"
            cell?.serviceTitleLabel.text = "服务地:"
            cell?.acceptButton.setTitle("接单", for: .normal)
            cell?.refuseButton.setTitle("拒单", for: .normal)
        }
//
        let model = resultArr[indexPath.row]
        cell?.typeLabel.text = model.taskServiceName
        cell?.orderNumLabel.text = model.orderCode
        cell?.merchantLabel.text = model.contractName
        if model.model?.isEmpty == false {
            cell?.carTypeTitleLabel.text = "车型:"
            cell?.carTypeLabel.text = model.model
            cell?.carTypeTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.merchantLabel.snp.bottom).offset(auto(8))
            })
        }else{
            cell?.carTypeTitleLabel.text = nil
            cell?.carTypeLabel.text = nil
            cell?.carTypeTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.merchantLabel.snp.bottom).offset(0)
            })
        }
        cell?.serviceLabel.text = model.vehiclePointAddress
        if model.destinationAddress?.isEmpty == false || (model.taskFlowId != 1) {
            cell?.destinationTitleLabel.text = "目的地:"
            cell?.destinationLabel.text = model.destinationAddress?.isEmpty == false ? model.destinationAddress : " "
            cell?.destinationTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(auto(8))
            })
        }else{
            cell?.destinationTitleLabel.text = nil
            cell?.destinationLabel.text = nil
            cell?.destinationTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(0)
            })
        }
        if model.appointTime?.isEmpty == false {
            cell?.reserveTitleLabel.text = "预约时间:"
            cell?.reserveLabel.text = model.appointTime
            cell?.reserveTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(auto(8))
            })
        }else{
            cell?.reserveTitleLabel.text = nil
            cell?.reserveLabel.text = nil
            cell?.reserveTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(0)
            })
        }
        
        cell?.refuseButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                if let refuseOrderConfirmView = self?.refuseOrderConfirmView {
                    self?.refuseOrderModel = model
                    ENTRY.showRefuseOrderConfirmEntry(view: refuseOrderConfirmView,name:refuseOrderConfirmEntry)
                }
            })
            .disposed(by: cell!.disposeBag)
        
        cell?.acceptButton.rx.tap
            .subscribe(onNext: {[weak self] _ in
                self?.acceptOrderRelay.accept(model)
            })
            .disposed(by: cell!.disposeBag)
        
        if USERP.canRejectDispatchHandle == true {
            cell?.refuseButton.isHidden = false
            cell?.refuseButton.snp.updateConstraints({ make in
                make.right.equalTo(cell!.acceptButton.snp.left).offset(-auto(5))
                make.width.equalTo(auto(80))
            })
        }else{
            cell?.refuseButton.isHidden = true
            cell?.refuseButton.snp.updateConstraints({ make in
                make.right.equalTo(cell!.acceptButton.snp.left).offset(0)
                make.width.equalTo(0)
            })
        }
        
        if USERP.canAcceptDispatchHandle == true {
            cell?.acceptButton.isHidden = false
            cell?.acceptButton.snp.updateConstraints({ make in
                make.width.equalTo(auto(80))
                make.right.equalTo(-auto(8))
            })
        }else{
            cell?.acceptButton.isHidden = true
            cell?.acceptButton.snp.updateConstraints({ make in
                make.width.equalTo(0)
                make.right.equalTo(0)
            })
        }
        
        if USERP.canRejectDispatchHandle == false && USERP.canAcceptDispatchHandle == false {
            cell?.acceptButton.snp.updateConstraints({ make in
                make.height.equalTo(0)
            })
        }else{
            cell?.acceptButton.snp.updateConstraints({ make in
                make.height.equalTo(auto(30))
            })
        }
        return cell!
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let model = resultArr[indexPath.item]
        WEBTOOL.open(name: .workOrderDetail, appending: "&queryType=\(OrderTypeEnum.TO_ACCEPT_DISPATCH.rawValue)&userOrderId=\(model.userOrderId)&orderCode=\(model.orderCode)&taskOrderId=\(model.taskOrderId)")
    }
}

extension RescuePendingDispatchController : UITableViewDelegate,UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return resultArr.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? RescuePendingDispatchCell
        if cell == nil {
            cell = RescuePendingDispatchCell(style: .default, reuseIdentifier: "cell")
            cell?.line.backgroundColor = .hex("E9E9EA").alpha(0.6)
            cell?.merchantTitleLabel.text = "客商:"
            cell?.serviceTitleLabel.text = "事发地:"
            cell?.reportButton.setTitle("报备", for: .normal)
            cell?.contactButton.setTitle("联系客户", for: .normal)
            cell?.dispatchButton.setTitle("指派车辆", for: .normal)
        }
        
        let model = resultArr[indexPath.row]
        cell?.typeLabel.text = model.taskServiceName
        cell?.orderNumLabel.text = model.orderCode
        cell?.merchantLabel.text = model.contractName
        if model.model?.isEmpty == false {
            cell?.carTypeTitleLabel.text = "车型:"
            cell?.carTypeLabel.text = model.model
            cell?.carTypeTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.merchantLabel.snp.bottom).offset(auto(8))
            })
        }else{
            cell?.carTypeTitleLabel.text = nil
            cell?.carTypeLabel.text = nil
            cell?.carTypeTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.merchantLabel.snp.bottom).offset(0)
            })
        }
        
        if model.positionEnvironment?.label.isEmpty == false {
            cell?.positionTitleLabel.text = "所处位置:"
            cell?.positionLabel.text = model.positionEnvironment?.label
            cell?.positionTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.carTypeLabel.snp.bottom).offset(auto(8))
            })
        }else{
            cell?.positionTitleLabel.text = nil
            cell?.positionLabel.text = nil
            cell?.positionTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.carTypeLabel.snp.bottom).offset(auto(0))
            })
        }
        
        if model.juheVehicleId != nil {
            cell?.juheTitleLabel.text = "聚合车辆:"
            cell?.juheButton.setTitle("\(model.juheVehcileName ?? "")-\(model.juheStaffPhone ?? "")", for: .normal)
            cell?.juheButton.setImage(UIImage(named: "rescue_orderDispatch_call"), for: .normal)
            cell?.juheButton.isHidden = false
            cell?.juheTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.positionLabel.snp.bottom).offset(auto(8))
            })
            
            cell?.juheButton.snp.updateConstraints({ make in
                make.height.equalTo(auto(17))
            })
        }else{
            cell?.juheTitleLabel.text = nil
            cell?.juheButton.setTitle(nil, for: .normal)
            cell?.juheButton.setImage(nil, for: .normal)
            cell?.juheButton.isHidden = true
            cell?.juheTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.positionLabel.snp.bottom).offset(0)
            })
            cell?.juheButton.snp.updateConstraints({ make in
                make.height.equalTo(0)
            })
        }
        
        cell?.serviceLabel.text = model.vehiclePointAddress
        
        if model.vehiclePointRemark?.isEmpty == false {
            cell?.serviceNoticeLabel.text = "备注:"+(model.vehiclePointRemark ?? "")
            cell?.serviceNoticeView.snp.updateConstraints({ make in
                make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(auto(4))
            })
            cell?.serviceNoticeLabel.snp.updateConstraints({ make in
                make.top.equalTo(auto(5))
                make.bottom.equalTo(-auto(5))
            })
            cell?.destinationTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.serviceNoticeView.snp.bottom).offset(auto(4))
            })
        }else{
            cell?.serviceNoticeLabel.text = nil
            cell?.serviceNoticeView.snp.updateConstraints({ make in
                make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(0)
            })
            cell?.serviceNoticeLabel.snp.updateConstraints({ make in
                make.top.equalTo(0)
                make.bottom.equalTo(0)
            })
            cell?.destinationTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.serviceNoticeView.snp.bottom).offset(auto(8))
            })
        }
        if model.destinationAddress?.isEmpty == false || (model.taskFlowId != 1) {
            cell?.destinationTitleLabel.text = "目的地:"
            cell?.destinationLabel.text = model.destinationAddress?.isEmpty == false ? model.destinationAddress : " "
        }else{
            cell?.destinationTitleLabel.text = nil
            cell?.destinationLabel.text = nil
            cell?.destinationTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.serviceNoticeView.snp.bottom).offset(0)
            })
        }
//        if model.destinationRemark?.isEmpty == false {
//            cell?.destinationNoticeView.isHidden = false
//            cell?.destinationNoticeLabel.text = "备注:"+(model.destinationRemark ?? "")
//            cell?.destinationNoticeView.snp.updateConstraints({ make in
//                make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(auto(4))
//            })
//            cell?.destinationNoticeLabel.snp.updateConstraints({ make in
//                make.top.equalTo(auto(5))
//                make.bottom.equalTo(-auto(5))
//            })
//        }else{
//            cell?.destinationNoticeView.isHidden = true
//            cell?.destinationNoticeLabel.text = nil
//            cell?.destinationNoticeView.snp.updateConstraints({ make in
//                make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(auto(4))
//            })
//            cell?.destinationNoticeLabel.snp.updateConstraints({ make in
//                make.top.equalTo(0)
//                make.bottom.equalTo(0)
//            })
//        }
        if model.appointTime?.isEmpty == false {
            cell?.reserveTitleLabel.text = "预约时间:"
            cell?.reserveLabel.text = model.appointTime
            cell?.reserveTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(auto(8))
            })
        }else{
            cell?.reserveTitleLabel.text = nil
            cell?.reserveLabel.text = nil
            cell?.reserveTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.destinationLabel.snp.bottom).offset(0)
            })
        }
    
        cell?.photoCollectionView.tag = indexPath.row
        cell?.photoCollectionView.delegate = self
        cell?.photoCollectionView.dataSource = self
        cell?.photoCollectionView.register(RescuePendingDispatchPhotoCell.self, forCellWithReuseIdentifier: "cell")
        
        if model.environmentPic?.isEmpty == false {
            cell?.photoTitleLabel.text = "查看照片:"
            cell?.photoView.isHidden = false
            cell?.photoTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.reserveTitleLabel.snp.bottom).offset(auto(8))
            })
            cell?.photoView.snp.updateConstraints({ make in
                make.height.equalTo(auto(50))
            })
            cell?.photoCollectionView.reloadData()
        }else{
            cell?.photoTitleLabel.text = nil
            cell?.photoView.isHidden = true
            cell?.photoTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.reserveTitleLabel.snp.bottom).offset(0)
            })
            cell?.photoView.snp.updateConstraints({ make in
                make.height.equalTo(0)
            })
        }
        cell?.juheButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: { _ in
                if let phone = model.juheStaffPhone {
                    SC.userOrderId = model.userOrderId
                    SC.orderCode = model.orderCode
                    SC.taskOrderId = model.taskOrderId
                    URLLINKS.openUrl(type: .phone, appending: phone)
                }
            })
            .disposed(by: cell!.disposeBag)
        cell?.reportButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: { _ in
                if let supplierId = USER.supplierId {
                    WEBTOOL.openReportIndex(queryType: OrderTypeEnum.TO_DISPATCH_VEHICLE.rawValue, userOrderId: model.userOrderId, orderCode: model.orderCode, type: 1, userOrderCode: model.taskCode, supplierId: supplierId)
                }
            })
            .disposed(by: cell!.disposeBag)
        cell?.contactButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                if let userPhone = model.userPhone {
                    SC.userOrderId = model.userOrderId
                    SC.orderCode = model.orderCode
                    SC.taskOrderId = model.taskOrderId
                    URLLINKS.openUrl(type: .phone, appending: userPhone)
                }else{
                    self?.view.dd_makeToast("无联系电话")
                }
            })
            .disposed(by: cell!.disposeBag)
        cell?.dispatchButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                let vc = DispatchOrderController.init(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId,serviceAddressLat: model.vehiclePointLatitude,serviceAddressLon: model.vehiclePointLongitude)
                vc.dispatchCompletionHandler = {[weak self] _ in
                    self?.resultArr.removeAll(where: { _model in
                        _model.userOrderId == model.userOrderId
                    })
                    
                    self?.pendingDispatchView.tableView.reloadData()
                }
                self?.navigationController?.pushViewController(vc, animated: true)
            })
            .disposed(by: cell!.disposeBag)
        
        if USERP.canWaitdispatchBtn == true {
            cell?.dispatchButton.isHidden = false
            cell?.dispatchButton.snp.updateConstraints({ make in
                make.right.equalTo(-auto(8))
                make.width.equalTo(auto(80))
            })
        }else{
            cell?.dispatchButton.isHidden = true
            cell?.dispatchButton.snp.updateConstraints({ make in
                make.right.equalTo(0)
                make.width.equalTo(0)
            })
        }
        
        if USERP.canSupplierRemarkBtn == true {
            cell?.reportButton.isHidden = false
            cell?.reportButton.snp.updateConstraints({ make in
                make.right.equalTo(cell!.contactButton.snp.left).offset(-auto(5))
                make.width.equalTo(auto(80))
            })
        }else{
            cell?.reportButton.isHidden = true
            cell?.reportButton.snp.updateConstraints({ make in
                make.right.equalTo(cell!.contactButton.snp.left).offset(0)
                make.width.equalTo(0)
            })
        }
        return cell!
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let model = resultArr[indexPath.item]
        WEBTOOL.open(name: .workOrderDetail, appending: "&queryType=\(OrderTypeEnum.TO_DISPATCH_VEHICLE.rawValue)&userOrderId=\(model.userOrderId)&orderCode=\(model.orderCode)&taskOrderId=\(model.taskOrderId)")
    }
}

extension RescueIsIngController : UITableViewDelegate,UITableViewDataSource {
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return resultArr.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell") as? RescueIsIngCell
        if cell == nil {
            cell = RescueIsIngCell(style: .default, reuseIdentifier: "cell")
            cell?.line.backgroundColor = .hex("E9E9EA").alpha(0.6)
            cell?.orderStatusTitleLabel.text = "状态:"
            cell?.serviceTitleLabel.text = "故障地:"
            cell?.destinationTitleLabel.text = "目的地:"
            cell?.contactButton.setTitle("联系客户", for: .normal)
            cell?.reportButton.setTitle("报备", for: .normal)
            cell?.reportDetailButton.setTitle("报备查看", for: .normal)
            cell?.dispatchButton.setTitle("改派", for: .normal)
        }
        let model = resultArr[indexPath.row]
        
        cell?.typeLabel.text = model.taskServiceName
        cell?.orderStatusLabel.text = model.taskOrderStatusString
        cell?.orderNumLabel.text = model.orderCode
        cell?.orderDateLabel.text = model.createTime
        
        if model.driverName?.isEmpty == false && model.driverPhone?.isEmpty == false {
            cell?.driverLabel.text = "\(model.driverName!)/\(model.driverPhone!)"
        }else if model.driverName?.isEmpty == false {
            cell?.driverLabel.text = model.driverName!
        }else if model.driverPhone?.isEmpty == false {
            cell?.driverLabel.text = model.driverPhone!
        }else{
            cell?.driverLabel.text = nil
        }

        cell?.serviceLabel.text = model.vehiclePointAddress
        if model.destinationAddress?.isEmpty == false || (model.taskFlowId != 1) {
            cell?.destinationTitleLabel.text = "目的地:"
            cell?.destinationLabel.text = model.destinationAddress?.isEmpty == false ? model.destinationAddress : " "
            cell?.destinationTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(auto(8))
            })
        }else{
            cell?.destinationTitleLabel.text = nil
            cell?.destinationLabel.text = nil
            cell?.destinationTitleLabel.snp.updateConstraints({ make in
                make.top.equalTo(cell!.serviceLabel.snp.bottom).offset(0)
            })
        }
        cell?.contactButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                if let userPhone = model.userPhone {
                    SC.userOrderId = model.userOrderId
                    SC.orderCode = model.orderCode
                    SC.taskOrderId = model.taskOrderId
                    URLLINKS.openUrl(type: .phone, appending: userPhone)
                }else{
                    self?.view.dd_makeToast("无联系电话")
                }
            })
            .disposed(by: cell!.disposeBag)
        cell?.dispatchButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: {[weak self] _ in
                // 没有权限且已聚合成功不能改派
                if USERP.canWaitModifyDispatchBtn != true && model.schedulingFinalRule == 1 {
                    self?.view.dd_makeToast("上游聚合成功案件，不得改派，如有特殊需要，请联系中道")
                    return
                }
                
                let vc = DispatchOrderController.init(userOrderId: model.userOrderId, taskOrderId: model.taskOrderId,serviceAddressLat: model.vehiclePointLatitude,serviceAddressLon: model.vehiclePointLongitude)
                vc.dispatchCompletionHandler = {[weak self] _ in
                    self?.resultArr.removeAll(where: { _model in
                        _model.userOrderId == model.userOrderId
                    })
                    
                    DispatchQueue.main.async {[weak self] in
                        self?.pendingIsIngView.tableView.reloadData()
                    }
                }
                self?.navigationController?.pushViewController(vc, animated: true)
            })
            .disposed(by: cell!.disposeBag)
        
        cell?.reportButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: { _ in
                if let supplierId = USER.supplierId {
                    WEBTOOL.openReportIndex(queryType: OrderTypeEnum.TO_DISPATCH_VEHICLE.rawValue, userOrderId: model.userOrderId, orderCode: model.orderCode, type: 1, userOrderCode: model.taskCode, supplierId: supplierId)
                }
            })
            .disposed(by: cell!.disposeBag)
        
        cell?.reportDetailButton.rx.tap
            .observe(on: MainScheduler.instance)
            .subscribe(onNext: { _ in
                WEBTOOL.open(name: .reportingList,appending: "&queryType=\(OrderTypeEnum.TO_RESCUE.rawValue)&userOrderId=\(model.userOrderId)&orderCode=\(model.orderCode)&taskOrderId=\(model.taskOrderId)")
            })
            .disposed(by: cell!.disposeBag)
        
        if (model.taskOrderStatus ?? 0) >= 12001 {
            cell?.dispatchButton.isHidden = true
            cell?.dispatchButton.snp.updateConstraints({ make in
                make.right.equalTo(cell!.reportDetailButton.snp.left).offset(0)
                make.width.equalTo(0)
            })
        }else{
            cell?.dispatchButton.isHidden = false
            cell?.dispatchButton.snp.updateConstraints({ make in
                make.right.equalTo(cell!.reportDetailButton.snp.left).offset(-auto(5))
                make.width.equalTo(auto(80))
            })
        }
        
        if USERP.canSupplierRemarkBtn == true {
            cell?.reportButton.isHidden = false
            cell?.reportButton.snp.updateConstraints({ make in
                make.width.equalTo(auto(80))
                make.right.equalTo(-auto(8))
            })
        }else{
            cell?.reportButton.isHidden = true
            cell?.reportButton.snp.updateConstraints({ make in
                make.width.equalTo(0)
                make.right.equalTo(0)
            })
        }
        
        return cell!
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let model = resultArr[indexPath.item]
        WEBTOOL.open(name: .workOrderDetail, appending: "&queryType=\(OrderTypeEnum.TO_RESCUE.rawValue)&userOrderId=\(model.userOrderId)&orderCode=\(model.orderCode)&taskOrderId=\(model.taskOrderId)")
    }
}

// MARK: UICollectionViewDelegate, UICollectionViewDataSource
extension RescuePendingDispatchController : UICollectionViewDelegate, UICollectionViewDataSource {
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        let model = resultArr[collectionView.tag]
        let environmentPics = model.environmentPic?.components(separatedBy: ",") ?? []
        return environmentPics.count > 4 ? 4 : environmentPics.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as? RescuePendingDispatchPhotoCell
        let model = resultArr[collectionView.tag]
        let environmentPics = model.environmentPic?.components(separatedBy: ",") ?? []
        let imageUrlStr = environmentPics[indexPath.item]
        cell!.imageView.image = nil
        if imageUrlStr.contains(".mp4?") == true {
            if let url = URL(string: imageUrlStr) {
                DispatchQueue.global().async {
                    DDImage.dd_thumbnailImage(forVideo: url) { (thumbnailImage, _, _) in
                        let image = thumbnailImage?.dd_compress(withQulitySize: 5 * 1024)
                        DispatchQueue.main.async {
                            cell!.imageView.image = image
                        }
                    }
                }

                DispatchQueue.global().async {
                    let cmTime = TOOL.getDuration(url: url)
                    DispatchQueue.main.async {
                        cell!.dateLabel.text = TOOL.getVideoDateString(duration: Int(cmTime.seconds))
                    }
                }
            }
        }else{
            cell!.imageView.sd_setImage(with: URL(string: imageUrlStr))
            cell!.dateLabel.text = nil
        }
        return cell!
    }
    
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let model = resultArr[collectionView.tag]
        let environmentPics = model.environmentPic?.components(separatedBy: ",") ?? []
        let vc = RescuePhotoController(environmentPics: environmentPics)
        navigationController?.pushViewController(vc, animated: true)
    }
}

// MARK: 救援中
class RescueController : ZDViewController {
    public let pagerView = TYCyclePagerView()
    public let categoryView = JXCategoryTitleView()
    private let filterButton = DDButton.dd_initCustom()
    private lazy var categoryContainerView = JXCategoryListContainerView(type: .scrollView, delegate: self)
    private let messageTapGes = UITapGestureRecognizer()
    private let messageView = MessageView()
    private let pendingTapGes = UITapGestureRecognizer()
    private let pendingView = MessageView()
    private let disposeBag = DisposeBag()
    private let h5Relay = ReplayRelay<Any?>.create(bufferSize: 1)
    
    private var pendingTableView : DDTableView?
    private var dispatchTableView : DDTableView?
    private var isRescueTableView : DDTableView?
    
    private var preRefreshRelay = ReplayRelay<Any?>.create(bufferSize: 1)
    private var appPushRecordRelay = ReplayRelay<Any?>.create(bufferSize: 1)
    
    private var appBannerRelay = ReplayRelay<Any?>.create(bufferSize: 1)
    private var bannerDataSources : [ConfigByCodeDataModel.ConfigByCodeBannerModel] = []
    
    private var onlineReminderRelay = ReplayRelay<Any?>.create(bufferSize: 1)
    
    private var judgeIfNeedConfirmEntryRelay = ReplayRelay<Any?>.create(bufferSize: 1)
    
    override func viewDidLoad() {
        super.viewDidLoad()
        dd_navigationBarBackgroundColor = .hex("354683")
        dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(auto(15))]
        dd_navigationBarBarButtonItemAttributes = [.foregroundColor : UIColor.white]
        dd_navigationItemTitle = "救援工单"
        navigationItem.leftBarButtonItems = nil
        addSubviews()
        addActions()
    }
    
    func addSubviews() {
        pagerView.register(TYCyclePagerViewCell.self, forCellWithReuseIdentifier: "cell")
        pagerView.isInfiniteLoop = true
        pagerView.autoScrollInterval = 3.0
        pagerView.delegate = self
        pagerView.dataSource = self
        
        categoryView.titles = ["待接单","待派车","救援中"]
        categoryView.titleColor = .hex("737373").alpha(0.55)
        categoryView.titleSelectedColor = .hex("3678FF")
        categoryView.backgroundColor = .hex("FAFAFA")
        categoryView.delegate = self
        view.addSubview(categoryView)
        
        // 指示器
        let indicator = JXCategoryIndicatorLineView()
        indicator.indicatorColor = .hex("3678FF")
        indicator.indicatorWidth = JXCategoryViewAutomaticDimension
        indicator.verticalMargin = 7
        indicator.indicatorWidth = auto(18)
        categoryView.indicators = [indicator]
        
        if let categoryContainerView {
            view.addSubview(categoryContainerView)
            categoryView.listContainer = categoryContainerView
        }
        
        /// 筛选
        ConditionalSearchTool.configFilterButton(filterButton, type: .rescue)
        view.addSubview(filterButton)
        filterButton.snp.makeConstraints { make in
            make.left.equalTo(categoryView.snp.right)
            make.right.equalToSuperview()
            make.top.equalTo(categoryView)
            make.bottom.equalTo(categoryView)
        }
        
        messageView.titleLabel.text = "消息"
        messageView.addGestureRecognizer(messageTapGes)
        navigationItem.leftBarButtonItem = UIBarButtonItem(customView: messageView)
        messageView.snp.makeConstraints { make in
            make.height.equalTo(40)
            make.width.greaterThanOrEqualTo(40)
        }

        pendingView.titleLabel.text = "待办"
        pendingView.addGestureRecognizer(pendingTapGes)
        navigationItem.rightBarButtonItem = UIBarButtonItem(customView: pendingView)
        pendingView.snp.makeConstraints { make in
            make.height.equalTo(40)
            make.width.greaterThanOrEqualTo(40)
        }
    }
    
    override func viewSafeAreaInsetsDidChange() {
        super.viewSafeAreaInsetsDidChange()
        if pagerView.superview == nil {
            view.addSubview(pagerView)
            pagerView.snp.makeConstraints { make in
                make.top.equalTo(view.safeAreaInsets.top)
                make.left.right.equalToSuperview()
                make.height.equalTo(0)
            }
        }
        
        categoryView.snp.remakeConstraints { make in
            make.left.equalToSuperview()
            make.right.equalToSuperview().offset(-auto(60))
            make.top.equalTo(pagerView.snp.bottom)
            make.height.equalTo(auto(44))
        }
        
        // view.safeAreaInsets.bottom为0的时候是hiddenBottomBar的时候，此时不必约束，由于是首页所以view.safeAreaInsets.bottom一定是大于0的
        if view.safeAreaInsets.bottom == 0 {
        }else{
            categoryContainerView?.snp.remakeConstraints({ make in
                make.top.equalTo(categoryView.snp.bottom)
                make.left.right.equalToSuperview()
                make.bottom.equalTo(-view.safeAreaInsets.bottom)
            })
        }
    }
    
    override func reloadData() {
        super.reloadData()
        preRefreshRelay.accept(nil)
    }
}

// MARK: 待派单
class RescuePendingOrderController : ConditionalSearchParentController {
    private let disposeBag = DisposeBag()
    public let pendingOrderView = RescuePendingOrderView()
    public let refuseOrderConfirmView = RefuseOrderConfirmView()
    public var refuseOrderModel : OrderListDataModel?
    private var resultArr : [OrderListDataModel] = []
    private var refreshRelay = ReplayRelay<Int>.create(bufferSize: 1)
    private var pageNum : Int = 1
    private var refuseRemarkIdRelay = ReplayRelay<OrderListDataModel>.create(bufferSize: 1)
    private var refuseSubmitRelay = ReplayRelay<Any?>.create(bufferSize: 1)
    private var acceptOrderRelay = ReplayRelay<OrderListDataModel>.create(bufferSize: 1)
    private var emptyView = EmptyView()

    override func viewDidLoad() {
        super.viewDidLoad()
        dd_navigationBarBackgroundColor = .hex("354683")
        dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(17)]
        dd_navigationBarBarButtonItemAttributes = [.foregroundColor : UIColor.white]
        addSubviews()
        addActions()
    }
    
    func addSubviews() {
        view.addSubview(pendingOrderView)
        pendingOrderView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    
        pendingOrderView.tableView.addSubview(emptyView)
        emptyView.snp.makeConstraints { make in
            make.centerX.centerY.equalToSuperview()
            make.width.equalTo(auto(303))
            make.height.equalTo(auto(94))
        }
        
        pendingOrderView.tableView.backgroundColor = .hex("FAFAFA")
        pendingOrderView.tableView.delegate = self
        pendingOrderView.tableView.dataSource = self
        
    }

}

// MARK: 待派车
class RescuePendingDispatchController : ConditionalSearchParentController {
    private let disposeBag = DisposeBag()
    public let pendingDispatchView = RescuePendingDispatchView()
    private var resultArr : [OrderListDataModel] = []
    private var refreshRelay = ReplayRelay<Int>.create(bufferSize: 1)
    private var pageNum : Int = 1
    private var emptyView = EmptyView()

    override func viewDidLoad() {
        super.viewDidLoad()
        dd_navigationBarBackgroundColor = .hex("354683")
        dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(17)]
        dd_navigationBarBarButtonItemAttributes = [.foregroundColor : UIColor.white]
        addSubviews()
        addActions()
    }
    
    func addSubviews() {
        view.addSubview(pendingDispatchView)
        pendingDispatchView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        pendingDispatchView.tableView.addSubview(emptyView)
        emptyView.snp.makeConstraints { make in
            make.centerX.centerY.equalToSuperview()
            make.width.equalTo(auto(303))
            make.height.equalTo(auto(94))
        }
        
        pendingDispatchView.tableView.backgroundColor = .hex("FAFAFA")
        pendingDispatchView.tableView.delegate = self
        pendingDispatchView.tableView.dataSource = self
    }

}

// MARK: 救援中
class RescueIsIngController : ConditionalSearchParentController {
    private let disposeBag = DisposeBag()
    public let pendingIsIngView = RescueIsIngView()
    private var resultArr : [OrderListDataModel] = []
    private var refreshRelay = ReplayRelay<Int>.create(bufferSize: 1)
    private var pageNum : Int = 1
    private var emptyView = EmptyView()

    override func viewDidLoad() {
        super.viewDidLoad()
        dd_navigationBarBackgroundColor = .hex("354683")
        dd_navigationBarTitleTextAttributes = [.foregroundColor : UIColor.white(alpha: 0.7),.font:UIFont.mediumFont(17)]
        dd_navigationBarBarButtonItemAttributes = [.foregroundColor : UIColor.white]
        addSubviews()
        addActions()
    }
    
    func addSubviews() {
        view.addSubview(pendingIsIngView)
        pendingIsIngView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        pendingIsIngView.tableView.addSubview(emptyView)
        emptyView.snp.makeConstraints { make in
            make.centerX.centerY.equalToSuperview()
            make.width.equalTo(auto(303))
            make.height.equalTo(auto(94))
        }
        
        pendingIsIngView.tableView.backgroundColor = .hex("FAFAFA")
        pendingIsIngView.tableView.delegate = self
        pendingIsIngView.tableView.dataSource = self

    }
}


// MARK: SUPER
class ConditionalSearchParentController : ZDViewController, JXCategoryListContentViewDelegate  {
    public lazy var conditionalSearchTool = ConditionalSearchTool()

    func listView() -> UIView! {
        return view
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        conditionalSearchTool.isFilterSub.accept(conditionalSearchTool.isFiltered())
    }
    
    override func viewSafeAreaInsetsDidChange() {
        super.viewSafeAreaInsetsDidChange()
        if parent?.view.safeAreaInsets.bottom != 0 {
            conditionalSearchTool.bottomSafeArea = (parent?.view.safeAreaInsets.bottom ?? 0) - 49
        }
    }
}

// MARK: Cell
class RescuePendingOrderCell : DDTableViewCell {
    public let radiusView : DDView
    public let typeLabel : DDLabel
    public let orderNumLabel : DDLabel
    public let line : DDView
    public let merchantTitleLabel : DDLabel
    public let merchantLabel : DDLabel
    public let carTypeTitleLabel : DDLabel
    public let carTypeLabel : DDLabel
    public let serviceTitleLabel : DDLabel
    public let serviceLabel : DDLabel
    public let destinationTitleLabel : DDLabel
    public let destinationLabel : DDLabel
    public let reserveTitleLabel : DDLabel
    public let reserveLabel : DDLabel
    public let refuseButton : DDButton
    public let acceptButton : DDButton
    public var acceptLayer : CAGradientLayer = {
        var layer = CAGradientLayer.init()
        layer.startPoint = CGPoint(x: 0, y: 0)
        layer.endPoint = CGPoint(x: 1, y: 1)
        layer.locations = [0.0,1.0]
        layer.colors = [UIColor.hex("FF5A2C").cgColor,UIColor.hex("FE9D4D").cgColor]
        layer.cornerRadius = auto(4)
        layer.masksToBounds = true
        return layer
    }()
    public var disposeBag : DisposeBag
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        radiusView = DDView.init()
        typeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("000000").alpha(0.85))
        orderNumLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("000000").alpha(0.55))
        line = DDView.init()
        merchantTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        merchantLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        carTypeTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        carTypeLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        serviceTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        serviceLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        destinationTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        destinationLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        reserveTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        reserveLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        refuseButton = DDButton.dd_initCustom()
        refuseButton.titleLabel?.font = .mediumFont(auto(13))
        refuseButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal)
        acceptButton = DDButton.dd_initCustom()
        acceptButton.titleLabel?.font = .mediumFont(auto(13))
        acceptButton.setTitleColor(.hex("FFFFFF"), for: .normal)
        disposeBag = DisposeBag()
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        contentView.backgroundColor = .hex("F4F5F7")
        radiusView.layer.cornerRadius = auto(6)
        radiusView.layer.shadowColor = UIColor.black(alpha: 0.1).cgColor
        radiusView.layer.shadowOpacity = 1.0
        radiusView.layer.shadowRadius = 3
        radiusView.layer.shadowOffset = CGSize(width: 0, height: 3)
        radiusView.backgroundColor = .white
        contentView.addSubview(radiusView)
        radiusView.addSubview(typeLabel)
        radiusView.addSubview(orderNumLabel)
        radiusView.addSubview(line)
        radiusView.addSubview(merchantTitleLabel)
        radiusView.addSubview(merchantLabel)
        carTypeLabel.numberOfLines = 0
        radiusView.addSubview(carTypeLabel)
        radiusView.addSubview(carTypeTitleLabel)
        radiusView.addSubview(serviceTitleLabel)
        serviceLabel.numberOfLines = 0
        radiusView.addSubview(serviceLabel)
        radiusView.addSubview(destinationTitleLabel)
        destinationLabel.numberOfLines = 0
        radiusView.addSubview(destinationLabel)
        radiusView.addSubview(reserveTitleLabel)
        radiusView.addSubview(reserveLabel)
        refuseButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor
        refuseButton.layer.borderWidth = 1
        refuseButton.layer.cornerRadius = auto(4)
        refuseButton.setImage(UIImage(named: "rescue_orderPending_refuse"), for: .normal)
        radiusView.addSubview(refuseButton)
        acceptButton.layer.cornerRadius = auto(4)
        acceptButton.layer.masksToBounds = true
        acceptButton.backgroundColor = .hex("FF5A2C")
        acceptButton.layer.insertSublayer(acceptLayer, at: 0)
        radiusView.addSubview(acceptButton)
        
        radiusView.snp.makeConstraints { make in
            make.left.equalTo(auto(12))
            make.right.equalTo(-auto(12))
            make.top.equalTo(0)
            make.bottom.equalTo(-auto(12))
        }
        typeLabel.snp.makeConstraints { make in
            make.left.equalTo(auto(18))
            make.top.equalTo(auto(13))
        }
        
        orderNumLabel.snp.makeConstraints { make in
            make.centerY.equalTo(typeLabel)
            make.left.equalTo(typeLabel.snp.right).offset(auto(10))
        }
        
        line.snp.makeConstraints { make in
            make.top.equalTo(typeLabel.snp.bottom).offset(auto(7))
            make.left.right.equalTo(0)
            make.height.equalTo(0.5)
        }
        
        merchantTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(line.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(auto(60))
        }
        
        merchantLabel.snp.makeConstraints { make in
            make.centerY.equalTo(merchantTitleLabel)
            make.left.equalTo(merchantTitleLabel.snp.right)
            make.right.equalTo(-auto(20))
        }
        
        carTypeTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(merchantLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        carTypeLabel.snp.makeConstraints { make in
            make.top.equalTo(carTypeTitleLabel)
            make.left.equalTo(carTypeTitleLabel.snp.right)
            make.right.equalTo(-auto(20))
        }
        
        serviceTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(carTypeLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        serviceLabel.snp.makeConstraints { make in
            make.top.equalTo(serviceTitleLabel)
            make.left.equalTo(serviceTitleLabel.snp.right)
            make.height.greaterThanOrEqualTo(serviceTitleLabel)
            make.right.equalTo(-auto(20))
        }
        
        destinationTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(serviceLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        destinationLabel.snp.makeConstraints { make in
            make.top.equalTo(destinationTitleLabel)
            make.left.equalTo(destinationTitleLabel.snp.right)
            make.height.greaterThanOrEqualTo(destinationTitleLabel)
            make.right.equalTo(-auto(20))
        }
        
        reserveTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(destinationLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        reserveLabel.snp.makeConstraints { make in
            make.centerY.equalTo(reserveTitleLabel)
            make.left.equalTo(reserveTitleLabel.snp.right)
        }
        
        acceptButton.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-auto(8))
            make.top.equalTo(reserveTitleLabel.snp.bottom).offset(auto(10))
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
            make.bottom.equalToSuperview().offset(-auto(10))
        }

        refuseButton.snp.makeConstraints { make in
            make.right.equalTo(acceptButton.snp.left).offset(-auto(5))
            make.top.equalTo(acceptButton)
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
        }

    }
    
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        acceptLayer.frame = CGRectMake(0, 0, auto(80), auto(30))
        refuseButton.dd_customize(with: .ImageLeftPaddingTitleRightWithWholeCenter, padding: 5)
    }

    override func prepareForReuse() {
        super.prepareForReuse()
        disposeBag = DisposeBag()
    }
}

class RescuePendingDispatchCell : DDTableViewCell {
    public let radiusView : DDView
    public let typeLabel : DDLabel
    public let orderNumLabel : DDLabel
    public let line : DDView
    public let merchantTitleLabel : DDLabel
    public let merchantLabel : DDLabel
    public let carTypeTitleLabel : DDLabel
    public let carTypeLabel : DDLabel
    public let positionTitleLabel : DDLabel
    public let positionLabel : DDLabel
    public let juheTitleLabel : DDLabel
    public let juheButton : DDButton
    public let serviceTitleLabel : DDLabel
    public let serviceLabel : DDLabel
    public let serviceNoticeView : DDView
    public let serviceNoticeLabel : DDLabel
    public let destinationTitleLabel : DDLabel
    public let destinationLabel : DDLabel
//    public let destinationNoticeView : DDView
//    public let destinationNoticeLabel : DDLabel
    public let reserveTitleLabel : DDLabel
    public let reserveLabel : DDLabel
    public let photoTitleLabel : DDLabel
    public let photoView : DDView
    public let photoCollectionView : DDCollectionView
    public let reportButton : DDButton
    public let contactButton : DDButton
    public let dispatchButton : DDButton
    public var dispatchLayer : CAGradientLayer = {
        var layer = CAGradientLayer.init()
        layer.startPoint = CGPoint(x: 0, y: 0)
        layer.endPoint = CGPoint(x: 1, y: 1)
        layer.locations = [0.0,1.0]
        layer.colors = [UIColor.hex("FF5A2C").cgColor,UIColor.hex("FE9D4D").cgColor]
        layer.cornerRadius = auto(4)
        layer.masksToBounds = true
        return layer
    }()
    public var disposeBag : DisposeBag

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        radiusView = DDView.init()
        typeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("000000").alpha(0.85))
        orderNumLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("000000").alpha(0.55))
        line = DDView.init()
        merchantTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        merchantLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        carTypeTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        carTypeLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        positionTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        positionLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        juheTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("ff0000").alpha(0.7))
        juheButton = DDButton.dd_initCustom()
        serviceTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        serviceLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        serviceNoticeView = DDView.init()
        serviceNoticeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("FF8F37"))
        destinationTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        destinationLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
//        destinationNoticeView = DDView.init()
//        destinationNoticeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("FF8F37"))
        reserveTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        reserveLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        photoTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        photoView = DDView.init()
        let flowLayout = UICollectionViewFlowLayout.init()
        flowLayout.itemSize = CGSize(width: auto(60), height: auto(45))
        flowLayout.scrollDirection = .vertical
        flowLayout.minimumInteritemSpacing = auto(5)
        photoCollectionView = DDCollectionView(frame: CGRectZero, collectionViewLayout: flowLayout)
        reportButton = DDButton.dd_initCustom()
        reportButton.titleLabel?.font = .mediumFont(auto(13))
        reportButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal)
        contactButton = DDButton.dd_initCustom()
        contactButton.titleLabel?.font = .mediumFont(auto(13))
        contactButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal)
        contactButton.setImage(UIImage(named: "rescue_orderDispatch_call"), for: .normal)
        dispatchButton = DDButton.dd_initCustom()
        dispatchButton.setTitleColor(.hex("FFFFFF"), for: .normal)
        dispatchButton.titleLabel?.font = .mediumFont(auto(13))
        disposeBag = DisposeBag()
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        contentView.backgroundColor = .hex("F4F5F7")
        radiusView.layer.cornerRadius = auto(6)
        radiusView.layer.shadowColor = UIColor.black(alpha: 0.1).cgColor
        radiusView.layer.shadowOpacity = 1.0
        radiusView.layer.shadowRadius = 3
        radiusView.layer.shadowOffset = CGSize(width: 0, height: 3)
        radiusView.backgroundColor = .white
        contentView.addSubview(radiusView)
        radiusView.addSubview(typeLabel)
        radiusView.addSubview(orderNumLabel)
        radiusView.addSubview(line)
        radiusView.addSubview(merchantTitleLabel)
        radiusView.addSubview(merchantLabel)
        radiusView.addSubview(positionTitleLabel)
        radiusView.addSubview(positionLabel)
        radiusView.addSubview(juheTitleLabel)
        juheButton.setTitleColor(.hex("ff0000"), for: .normal)
        juheButton.titleLabel?.font = .mediumFont(auto(13))
        juheButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 3, bottom: 0, right: 3)
        radiusView.addSubview(juheButton)
        carTypeLabel.numberOfLines = 0
        radiusView.addSubview(carTypeLabel)
        radiusView.addSubview(carTypeTitleLabel)
        radiusView.addSubview(serviceTitleLabel)
        serviceLabel.numberOfLines = 0
        radiusView.addSubview(serviceLabel)
        serviceNoticeView.backgroundColor = .hex("FFF7EE")
        radiusView.addSubview(serviceNoticeView)
        serviceNoticeLabel.numberOfLines = 0
        serviceNoticeView.addSubview(serviceNoticeLabel)
        radiusView.addSubview(destinationTitleLabel)
        destinationLabel.numberOfLines = 0
        radiusView.addSubview(destinationLabel)
//        destinationNoticeView.backgroundColor = .hex("FFF7EE")
//        radiusView.addSubview(destinationNoticeView)
//        destinationNoticeLabel.numberOfLines = 0
//        destinationNoticeView.addSubview(destinationNoticeLabel)
        radiusView.addSubview(reserveTitleLabel)
        radiusView.addSubview(reserveLabel)
        radiusView.addSubview(photoTitleLabel)
        radiusView.addSubview(photoView)
        photoCollectionView.backgroundColor = .white
        photoView.addSubview(photoCollectionView)
        reportButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor
        reportButton.layer.borderWidth = 1
        reportButton.layer.cornerRadius = auto(4)
        radiusView.addSubview(reportButton)
        contactButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor
        contactButton.layer.borderWidth = 1
        contactButton.layer.cornerRadius = auto(4)
        radiusView.addSubview(contactButton)
        dispatchButton.layer.cornerRadius = auto(4)
        dispatchButton.layer.masksToBounds = true
        dispatchButton.backgroundColor = .hex("FF5A2C")
        dispatchButton.layer.insertSublayer(dispatchLayer, at: 0)
        radiusView.addSubview(dispatchButton)
        
        radiusView.snp.makeConstraints { make in
            make.left.equalTo(auto(12))
            make.right.equalTo(-auto(12))
            make.top.equalTo(0)
            make.bottom.equalTo(-auto(12))
        }
        typeLabel.snp.makeConstraints { make in
            make.left.equalTo(auto(18))
            make.top.equalTo(auto(13))
        }
        
        orderNumLabel.snp.makeConstraints { make in
            make.centerY.equalTo(typeLabel)
            make.left.equalTo(typeLabel.snp.right).offset(auto(10))
        }
        
        line.snp.makeConstraints { make in
            make.top.equalTo(typeLabel.snp.bottom).offset(auto(7))
            make.left.right.equalTo(0)
            make.height.equalTo(0.5)
        }
        
        merchantTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(line.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(auto(60))
        }
        
        merchantLabel.snp.makeConstraints { make in
            make.centerY.equalTo(merchantTitleLabel)
            make.left.equalTo(merchantTitleLabel.snp.right)
            make.right.equalTo(-auto(20))
        }
        
        carTypeTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(merchantLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        carTypeLabel.snp.makeConstraints { make in
            make.top.equalTo(carTypeTitleLabel)
            make.left.equalTo(carTypeTitleLabel.snp.right)
            make.right.equalTo(-auto(20))
        }
        
        positionTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(carTypeLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        positionLabel.snp.makeConstraints { make in
            make.top.equalTo(positionTitleLabel)
            make.left.equalTo(positionTitleLabel.snp.right)
            make.right.equalTo(-auto(20))
        }
        
        juheTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(positionLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        juheButton.snp.makeConstraints { make in
            make.centerY.equalTo(juheTitleLabel)
            make.left.equalTo(juheTitleLabel.snp.right)
            make.right.lessThanOrEqualTo(-auto(20))
            make.height.equalTo(auto(17))
        }
        
        serviceTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(juheButton.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        serviceLabel.snp.makeConstraints { make in
            make.top.equalTo(serviceTitleLabel)
            make.left.equalTo(serviceTitleLabel.snp.right)
            make.height.greaterThanOrEqualTo(serviceTitleLabel)
            make.right.equalTo(-auto(20))
        }
        
        serviceNoticeView.snp.makeConstraints { make in
            make.top.equalTo(serviceLabel.snp.bottom).offset(auto(4))
            make.left.equalTo(auto(10))
            make.right.equalTo(-auto(10))
        }
        
        serviceNoticeLabel.snp.makeConstraints { make in
            make.top.left.equalToSuperview().offset(auto(5))
            make.bottom.right.equalToSuperview().offset(-auto(5))
        }
        
        destinationTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(serviceNoticeView.snp.bottom).offset(auto(4))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        destinationLabel.snp.makeConstraints { make in
            make.top.equalTo(destinationTitleLabel)
            make.left.equalTo(destinationTitleLabel.snp.right)
            make.height.greaterThanOrEqualTo(destinationTitleLabel)
            make.right.equalTo(-auto(20))
        }
        
//        destinationNoticeView.snp.makeConstraints { make in
//            make.top.equalTo(destinationLabel.snp.bottom).offset(auto(4))
//            make.left.equalTo(auto(10))
//            make.right.equalTo(-auto(10))
//        }
//
//        destinationNoticeLabel.snp.makeConstraints { make in
//            make.top.left.equalToSuperview().offset(auto(5))
//            make.bottom.right.equalToSuperview().offset(-auto(5))
//        }
        
        reserveTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(destinationLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(merchantTitleLabel)
        }
        
        reserveLabel.snp.makeConstraints { make in
            make.centerY.equalTo(reserveTitleLabel)
            make.left.equalTo(reserveTitleLabel.snp.right)
        }
        
        photoTitleLabel.snp.makeConstraints { make in
            make.left.equalTo(typeLabel)
            make.top.equalTo(reserveTitleLabel.snp.bottom).offset(auto(8))
            make.width.equalTo(merchantTitleLabel)
        }
        
        photoView.snp.makeConstraints { make in
            make.left.equalTo(photoTitleLabel.snp.right)
            make.top.equalTo(photoTitleLabel)
            make.right.equalToSuperview().offset(-auto(5))
            make.height.equalTo(auto(50))
        }
        
        photoCollectionView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        
        dispatchButton.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-auto(8))
            make.top.equalTo(contactButton)
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
        }

        contactButton.snp.makeConstraints { make in
            make.right.equalTo(dispatchButton.snp.left).offset(-auto(5))
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
            make.top.equalTo(photoView.snp.bottom).offset(auto(10))
            make.bottom.equalToSuperview().offset(-auto(10))
        }
        
        reportButton.snp.makeConstraints { make in
            make.right.equalTo(contactButton.snp.left).offset(-auto(5))
            make.top.equalTo(contactButton)
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
        }

    }
    
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        dispatchLayer.frame = CGRectMake(0, 0, auto(80), auto(30))
        contactButton.dd_customize(with: .ImageLeftPaddingTitleRightWithWholeCenter, padding: 3)
        juheButton.dd_customize(with: .ImageRightPaddingTitleLeftWithWholeCenter, padding: 3)
    }
    
    override func prepareForReuse() {
        super.prepareForReuse()
        disposeBag = DisposeBag()
    }
}

class RescuePendingDispatchPhotoCell : DDCollectionViewCell {
    public let imageView : DDImageView
    public let dateLabel : DDLabel

    override init(frame: CGRect) {
        imageView = DDImageView.init()
        dateLabel = DDLabel.dd_init(withText: "", font: .regularFont(12), textColor: .white)
        super.init(frame: frame)
        contentView.backgroundColor = .hex("F4F5F7")
        imageView.contentMode = .scaleAspectFill
        imageView.layer.masksToBounds = true
        addSubview(imageView)
        addSubview(dateLabel)
        imageView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        dateLabel.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-auto(2))
            make.bottom.equalToSuperview().offset(-auto(2))
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class RescueIsIngCell : DDTableViewCell {
    public let radiusView : DDView
    public let typeLabel : DDLabel
    public let orderNumLabel : DDLabel
    public let orderStatusTitleLabel : DDLabel
    public let orderStatusLabel : DDLabel
    public let line : DDView
    public let orderDateLabel : DDLabel
    public let driverLabel : DDLabel
    public let serviceTitleLabel : DDLabel
    public let serviceLabel : DDLabel
    public let destinationTitleLabel : DDLabel
    public let destinationLabel : DDLabel
    public let contactButton : DDButton
    public let dispatchButton : DDButton
    public let reportButton : DDButton
    public let reportDetailButton : DDButton
    public var disposeBag : DisposeBag

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        radiusView = DDView.init()
        typeLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(13)), textColor: .hex("000000").alpha(0.85))
        orderNumLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(11)), textColor: .hex("000000").alpha(0.55))
        orderStatusTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        orderStatusLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("E69B0B"))
        line = DDView.init()
        orderDateLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("252525"))
        driverLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("252525"))
        serviceTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        serviceLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        destinationTitleLabel = DDLabel.dd_init(withText: "", font: .mediumFont(auto(12)), textColor: .hex("000000").alpha(0.5))
        destinationLabel = DDLabel.dd_init(withText: "", font: .regularFont(auto(12)), textColor: .hex("000000"))
        contactButton = DDButton.dd_initCustom()
        contactButton.titleLabel?.font = .mediumFont(13)
        contactButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal)
        dispatchButton = DDButton.dd_initCustom()
        dispatchButton.titleLabel?.font = .mediumFont(13)
        dispatchButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal)
        reportButton = DDButton.dd_initCustom()
        reportButton.titleLabel?.font = .mediumFont(13)
        reportButton.setTitleColor(.hex("FFFFFF"), for: .normal)
        reportDetailButton = DDButton.dd_initCustom()
        reportDetailButton.titleLabel?.font = .mediumFont(13)
        reportDetailButton.setTitleColor(.hex("000000").alpha(0.7), for: .normal)
        disposeBag = DisposeBag()
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        contentView.backgroundColor = .hex("F4F5F7")
        radiusView.layer.cornerRadius = auto(6)
        radiusView.layer.shadowColor = UIColor.black(alpha: 0.1).cgColor
        radiusView.layer.shadowOpacity = 1.0
        radiusView.layer.shadowRadius = 3
        radiusView.layer.shadowOffset = CGSize(width: 0, height: 3)
        radiusView.backgroundColor = .white
        contentView.addSubview(radiusView)
        radiusView.addSubview(typeLabel)
        radiusView.addSubview(orderNumLabel)
        radiusView.addSubview(orderStatusTitleLabel)
        orderStatusLabel.numberOfLines = 0
        radiusView.addSubview(orderStatusLabel)
        radiusView.addSubview(line)
        radiusView.addSubview(orderDateLabel)
        radiusView.addSubview(driverLabel)
        radiusView.addSubview(serviceTitleLabel)
        serviceLabel.numberOfLines = 0
        radiusView.addSubview(serviceLabel)
        radiusView.addSubview(destinationTitleLabel)
        destinationLabel.numberOfLines = 0
        radiusView.addSubview(destinationLabel)
        contactButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor
        contactButton.layer.borderWidth = 1
        contactButton.layer.cornerRadius = auto(4)
        contactButton.setImage(UIImage(named: "rescue_orderDispatch_call"), for: .normal)
        radiusView.addSubview(contactButton)
        dispatchButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor
        dispatchButton.layer.borderWidth = 1
        dispatchButton.layer.cornerRadius = auto(4)
        radiusView.addSubview(dispatchButton)
        reportButton.layer.cornerRadius = auto(4)
        reportButton.layer.masksToBounds = true
        reportButton.backgroundColor = .hex("2A5094")
        radiusView.addSubview(reportButton)
        reportDetailButton.layer.borderColor = UIColor.hex("DDDDDD").cgColor
        reportDetailButton.layer.borderWidth = 1
        reportDetailButton.layer.cornerRadius = auto(4)
        radiusView.addSubview(reportDetailButton)
        
        radiusView.snp.makeConstraints { make in
            make.left.equalTo(auto(12))
            make.right.equalTo(-auto(12))
            make.top.equalTo(0)
            make.bottom.equalTo(-auto(12))
        }
        typeLabel.snp.makeConstraints { make in
            make.left.equalTo(auto(18))
            make.top.equalTo(auto(13))
        }

        orderNumLabel.snp.makeConstraints { make in
            make.centerY.equalTo(typeLabel)
            make.left.equalTo(typeLabel.snp.right).offset(auto(10))
        }
        
        line.snp.makeConstraints { make in
            make.top.equalTo(typeLabel.snp.bottom).offset(auto(7))
            make.left.right.equalTo(0)
            make.height.equalTo(0.5)
        }
        
        orderDateLabel.snp.makeConstraints { make in
            make.left.equalTo(typeLabel)
            make.top.equalTo(line.snp.bottom).offset(auto(5))
        }
        
        driverLabel.snp.makeConstraints { make in
            make.left.equalTo(orderDateLabel.snp.right).offset(auto(10))
            make.centerY.equalTo(orderDateLabel)
        }

        orderStatusTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(orderDateLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(auto(60))
        }
        
        orderStatusLabel.snp.makeConstraints { make in
            make.right.equalTo(-auto(20))
            make.top.equalTo(orderStatusTitleLabel)
            make.left.equalTo(orderStatusTitleLabel.snp.right)
        }

        serviceTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(orderStatusLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(orderStatusTitleLabel)
        }
        
        serviceLabel.snp.makeConstraints { make in
            make.top.equalTo(serviceTitleLabel)
            make.left.equalTo(serviceTitleLabel.snp.right)
            make.height.greaterThanOrEqualTo(serviceTitleLabel)
            make.right.equalTo(-auto(20))
        }
        
        destinationTitleLabel.snp.makeConstraints { make in
            make.top.equalTo(serviceLabel.snp.bottom).offset(auto(8))
            make.left.equalTo(typeLabel)
            make.width.equalTo(serviceTitleLabel)
        }
        
        destinationLabel.snp.makeConstraints { make in
            make.top.equalTo(destinationTitleLabel)
            make.left.equalTo(destinationTitleLabel.snp.right)
            make.height.greaterThanOrEqualTo(destinationTitleLabel)
            make.right.equalTo(-auto(20))
        }

        reportButton.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-auto(8))
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
            make.top.equalTo(contactButton)
        }

        reportDetailButton.snp.makeConstraints { make in
            make.right.equalTo(reportButton.snp.left).offset(-auto(5))
            make.top.equalTo(contactButton)
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
        }
        
        dispatchButton.snp.makeConstraints { make in
            make.right.equalTo(reportDetailButton.snp.left).offset(-auto(5))
            make.top.equalTo(contactButton)
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
        }

        contactButton.snp.makeConstraints { make in
            make.right.equalTo(dispatchButton.snp.left).offset(-auto(5))
            make.width.equalTo(auto(80))
            make.height.equalTo(auto(30))
            make.top.equalTo(destinationLabel.snp.bottom).offset(auto(10))
            make.bottom.equalToSuperview().offset(-auto(10))
        }
    }
    
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func prepareForReuse() {
        super.prepareForReuse()
        disposeBag = DisposeBag()
    }
}
// MARK: View
class RescuePendingOrderView : DDView {
    public let tableView = DDTableView.init(frame: CGRectZero)
    override init(frame: CGRect) {
        super.init(frame: frame)
        tableView.separatorStyle = .none
        addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class RescuePendingDispatchView : DDView {
    public let tableView = DDTableView.init(frame: CGRectZero)
    override init(frame: CGRect) {
        super.init(frame: frame)
        tableView.separatorStyle = .none
        addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class RescueIsIngView : DDView {
    public let tableView = DDTableView.init(frame: CGRectZero)
    override init(frame: CGRect) {
        super.init(frame: frame)
        tableView.separatorStyle = .none
        addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    required public init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class TYCyclePagerViewCell : UICollectionViewCell {
    var imageView : UIImageView
    override init(frame: CGRect) {
        imageView = UIImageView()
        super.init(frame: frame)
        addSubview(imageView)
        imageView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
