diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/CommonSlideView.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/CommonSlideView.kt index 69e257067f..1b4ea64f73 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/CommonSlideView.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/CommonSlideView.kt @@ -130,7 +130,7 @@ class CommonSlideView @JvmOverloads constructor( if(isVisible){ lottie_bg.setAnimation("slide.json") lottie_bg.playAnimation() - draggableButton.setTextColor(ResourcesUtils.getColor(R.color.white)) + draggableButton.setTextColor(context.getColor(R.color.white)) ObjectAnimator.ofFloat( draggableButton, "translationX", draggableButton.translationX, 0f diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/autopilot/AutopilotState.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/autopilot/AutopilotState.kt index 762db267ba..1ae3d57c97 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/autopilot/AutopilotState.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/autopilot/AutopilotState.kt @@ -50,11 +50,11 @@ class AutopilotState @JvmOverloads constructor( autopilotLoadingAnimator = ObjectAnimator.ofFloat(aciv_autopilot_state, "rotation", 0f, 360f); autopilotLoadingAnimator.interpolator = LinearInterpolator() autopilotLoadingAnimator.repeatCount = -1 //无限循环 - autopilotLoadingAnimator.duration = 1000 //无限循环 + autopilotLoadingAnimator.duration = 2000 //无限循环 autopilotChangeStateAnimator = ObjectAnimator.ofFloat(aciv_autopilot_state, "alpha", 1f, 0f,1f); autopilotChangeStateAnimator.interpolator = LinearInterpolator() - autopilotChangeStateAnimator.duration = 200 + autopilotChangeStateAnimator.duration = 300 onClick { startAutopilot() } @@ -127,7 +127,7 @@ class AutopilotState @JvmOverloads constructor( override fun inAutopilot() { CallerLogger.d(TAG,"展示自驾中UI") - updateImageInAnimator(R.drawable.common_autopilot_starting_new) + updateImageInAnimator(R.drawable.common_autopilot_running) actv_pxjs_state.visibility = GONE actv_autopilot_head.visibility = VISIBLE @@ -225,7 +225,7 @@ class AutopilotState @JvmOverloads constructor( actv_pxjs_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB)) AutopilotState@this.isEnabled = false - aciv_autopilot_running_ani.visibility = VISIBLE + aciv_autopilot_running_ani.visibility = GONE autopilotStateAnimator?.stop() autopilotLoadingAnimator.cancel() autopilotChangeStateAnimator.start() @@ -234,7 +234,7 @@ class AutopilotState @JvmOverloads constructor( private fun updateImageInAnimator(@DrawableRes resource:Int){ UiThreadHandler.postDelayed({ aciv_autopilot_state.setImageResource(resource) - },100,UiThreadHandler.MODE.QUEUE) + },150,UiThreadHandler.MODE.QUEUE) } } \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/autopilot/AutopilotStateModel.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/autopilot/AutopilotStateModel.kt index 79b15bf807..f23f021a51 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/autopilot/AutopilotStateModel.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/autopilot/AutopilotStateModel.kt @@ -12,6 +12,7 @@ import com.mogo.och.common.module.manager.autopilot.line.ILineCallback import com.mogo.och.common.module.manager.autopilot.line.LineManager import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager import com.mogo.och.common.module.manager.loop.BizLoopManager +import com.mogo.och.common.module.utils.RxUtils import java.util.concurrent.atomic.AtomicBoolean /** @@ -126,6 +127,9 @@ class AutopilotStateModel : ViewModel(), IOchAutopilotStatusListener, ILineCall OchChainLogManager.writeChainLog("自驾信息","启动自驾") if(AutopilotStateDebug.debugStatus){ startAutopilotSuccess() + RxUtils.createSubscribe(5_000) { + startAutopilotFail() + } }else { LineManager.startAutopilot() } @@ -159,7 +163,7 @@ class AutopilotStateModel : ViewModel(), IOchAutopilotStatusListener, ILineCall this.isPalyStartAni.set(false) UiThreadHandler.postDelayed({ autopilotStateChange() - },1000,UiThreadHandler.MODE.QUEUE) + },3000,UiThreadHandler.MODE.QUEUE) } } diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/commonview/EmptyView.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/commonview/EmptyView.kt new file mode 100644 index 0000000000..66252b9b03 --- /dev/null +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/commonview/EmptyView.kt @@ -0,0 +1,55 @@ +package com.mogo.och.common.module.wigets.commonview + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.map.listener.IMogoMapListener +import com.mogo.och.common.module.R +import com.mogo.och.common.module.utils.ResourcesUtils +import kotlinx.android.synthetic.main.common_empty_view.view.no_order_data_tv + +class EmptyView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr),IMogoMapListener { + companion object { + const val TAG = "LoadingMapStatusView" + } + + private var emptyTitle:String = "" + + + init { + LayoutInflater.from(context).inflate(R.layout.common_empty_view, this, true) + try { + val typedArray = context.obtainStyledAttributes(attrs, R.styleable.EmptyView) + emptyTitle = typedArray.getString(R.styleable.EmptyView_empty_title)?:ResourcesUtils.getString(R.string.common_empty_data) + typedArray.recycle() + } catch (e: Exception) { + e.printStackTrace() + } + no_order_data_tv.text = emptyTitle + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + CallerLogger.d(TAG,"onAttachedToWindow") + + } + + override fun onVisibilityAggregated(isVisible: Boolean) { + super.onVisibilityAggregated(isVisible) + + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + CallerLogger.d(TAG,"onDetachedFromWindow") + } + + + +} \ No newline at end of file diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/map/orderstatus/OrderStatusView.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/map/orderstatus/OrderStatusView.kt index a7e1eb3083..9b2258896e 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/map/orderstatus/OrderStatusView.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/map/orderstatus/OrderStatusView.kt @@ -54,16 +54,18 @@ class OrderStatusView : RelativeLayout, OrderStatusViewModel.IVisualCallback { override fun setImageViewResource(name: Int,ordering:Boolean) { iv_order_status.setImageResource(name) - if (iv_order_status.layoutParams is RelativeLayout.LayoutParams) { - val temp = iv_order_status.layoutParams as RelativeLayout.LayoutParams - temp.removeRule(RelativeLayout.ALIGN_PARENT_START) - temp.addRule(ALIGN_PARENT_END) - iv_order_status.layoutParams = temp - }else{ - val temp = iv_order_status.layoutParams as RelativeLayout.LayoutParams - temp.removeRule(RelativeLayout.ALIGN_PARENT_END) - temp.addRule(ALIGN_PARENT_START) - iv_order_status.layoutParams = temp + if (iv_order_status.layoutParams is LayoutParams) { + if(ordering){ + val temp = iv_order_status.layoutParams as LayoutParams + temp.removeRule(ALIGN_PARENT_START) + temp.addRule(ALIGN_PARENT_END) + iv_order_status.layoutParams = temp + }else{ + val temp = iv_order_status.layoutParams as LayoutParams + temp.removeRule(ALIGN_PARENT_END) + temp.addRule(ALIGN_PARENT_START) + iv_order_status.layoutParams = temp + } } } diff --git a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/map/orderstatus/OrderStatusViewModel.kt b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/map/orderstatus/OrderStatusViewModel.kt index 82f4b26dfe..ae2f82b5fd 100644 --- a/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/map/orderstatus/OrderStatusViewModel.kt +++ b/OCH/common/common/src/main/java/com/mogo/och/common/module/wigets/map/orderstatus/OrderStatusViewModel.kt @@ -2,6 +2,7 @@ package com.mogo.och.common.module.wigets.map.orderstatus import androidx.annotation.DrawableRes import androidx.lifecycle.ViewModel +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.util.UiThreadHandler import com.mogo.och.common.module.R import com.mogo.och.common.module.biz.login.ILoginCallback @@ -30,6 +31,7 @@ class OrderStatusViewModel : ViewModel(), ILoginCallback { } override fun onOpenOrderStatusEnumChange(businessEnum: OpenOrderStatusEnum?) { + CallerLogger.d(TAG,"新的接单状态${businessEnum}") UiThreadHandler.post({ if (LoginStatusManager.isOpenOrderType()) { this.viewCallback?.setImageViewResource(R.drawable.common_order_status,true) diff --git a/OCH/common/common/src/main/res/values/attrs.xml b/OCH/common/common/src/main/res/values/attrs.xml index 31323f4270..ab122895b6 100644 --- a/OCH/common/common/src/main/res/values/attrs.xml +++ b/OCH/common/common/src/main/res/values/attrs.xml @@ -14,6 +14,10 @@ + + + + diff --git a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/repository/impl/ShuttleSaasRepository.kt b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/repository/impl/ShuttleSaasRepository.kt index b4e1c233ef..cc61dfaf56 100644 --- a/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/repository/impl/ShuttleSaasRepository.kt +++ b/OCH/shuttle/driver_weaknet/src/main/java/com/mogo/och/weaknet/repository/impl/ShuttleSaasRepository.kt @@ -219,8 +219,8 @@ class ShuttleSaasRepository : IRepository { EventDb.saveEventTaskArriveSite( task.taskId!!, task.lineId!!, - start.siteId.toLong(), - start.seq, + end.siteId.toLong(), + end.seq, task.taskStartTime, lineInfo.lineName ) diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/base/TaxiFragment.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/base/TaxiFragment.kt index 980ff8fb45..dbca0cc86f 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/base/TaxiFragment.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/base/TaxiFragment.kt @@ -40,8 +40,8 @@ import com.mogo.och.unmanned.taxi.ui.task.TaxiTaskTabFragment import com.mogo.och.unmanned.taxi.utils.TPRouteDataTestUtils import kotlinx.android.synthetic.main.unmanned_taxi_base_fragment.unmannedMapCL import kotlinx.android.synthetic.main.unmanned_taxi_base_fragment.module_mogo_och_navi_panel_container +import kotlinx.android.synthetic.main.unmanned_taxi_base_fragment.orderDebugView import kotlinx.android.synthetic.main.unmanned_taxi_base_fragment.taxi_close_navi_icon -import kotlinx.android.synthetic.main.unmanned_taxi_panel.orderDebugView import java.lang.ref.WeakReference /** @@ -64,8 +64,6 @@ class TaxiFragment :MvpFragment(), private val lineView = "LINEVIEW" private var personalDialogFragment: WeakReference? = null - private var taskTabFragment: WeakReference? = null - private fun updateOperationBtnStatusOnModeChange(isRoutingVerifyMode: Boolean) { if (MogoStatusManager.getInstance().isTaxiUnmanedDriverTakingOrders) { @@ -175,11 +173,6 @@ class TaxiFragment :MvpFragment(), unmannedMapCL.onPause() } - fun onChangeOperationStatus() { - if (null == taskTabFragment || taskTabFragment!!.get() == null) return - taskTabFragment!!.get()!!.onCarTakeOrderStatusChanged() - } - override fun onLowMemory() { super.onLowMemory() unmannedMapCL.onLowMemory() @@ -273,15 +266,6 @@ class TaxiFragment :MvpFragment(), } - /** - * 获取站点面板view,在[.initViews]时候添加到container中 - * - * @return 站点面板view - */ - fun getStationPanelViewId(): Int { - return R.layout.unmanned_taxi_panel - } - /** * 重新开启自动驾驶 */ @@ -419,8 +403,9 @@ class TaxiFragment :MvpFragment(), if (MogoStatusManager.getInstance().isTaxiUnmanedDriverLineRoutingVerifyMode) { showAmapNaviToStationFragment(isShow) } else { - if (null == taskTabFragment || taskTabFragment!!.get() == null) return - taskTabFragment!!.get()!!.onNaviToEndStationByAMap(isShow) + // TODO: 需要复原 +// if (null == taskTabFragment || taskTabFragment!!.get() == null) return +// taskTabFragment!!.get()!!.onNaviToEndStationByAMap(isShow) } } else if (isShow) { //使用routing数据 showRoutingToStationFragment(true) diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/debug/DebugView.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/debug/DebugView.kt index 6cd50de673..66579ebe65 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/debug/DebugView.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/debug/DebugView.kt @@ -22,6 +22,7 @@ import com.mogo.commons.module.status.StatusDescriptor import com.mogo.commons.utils.MogoAnalyticUtils import com.mogo.eagle.core.function.main.MainMoGoApplication import com.mogo.eagle.core.network.utils.GsonUtil +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d import com.mogo.eagle.core.utilcode.util.AppUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler @@ -74,16 +75,19 @@ public class DebugView @JvmOverloads constructor( private var logHistoryTextView: TextView? = null fun printInfoMsg(msg: String) { + CallerLogger.i(TAG,msg) printMsg("Info $msg", MainMoGoApplication.getApp().getColor(R.color.background_info)) trackEvent("Info", msg) } fun printWarnMsg(msg: String) { + CallerLogger.w(TAG,msg) printMsg("Warn $msg", MainMoGoApplication.getApp().getColor(R.color.background_debug)) trackEvent("Warn", msg) } fun printErrorMsg(msg: String) { + CallerLogger.e(TAG,msg) printMsg("Error $msg", MainMoGoApplication.getApp().getColor(R.color.background_error)) trackEvent("Error", msg) } @@ -155,7 +159,7 @@ public class DebugView @JvmOverloads constructor( initBroadcastReceiver() LayoutInflater.from(context).inflate(R.layout.unmanned_taxi_debug_order, this, true) debugLogHistoryTextView.movementMethod = ScrollingMovementMethod.getInstance() - visibility = GONE + visibility = VISIBLE logHistoryTextView = debugLogHistoryTextView initView() diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/operational/TaxiOperationalDialogFragment.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/operational/TaxiOperationalDialogFragment.kt index f7b40c9862..092926449b 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/operational/TaxiOperationalDialogFragment.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/operational/TaxiOperationalDialogFragment.kt @@ -26,7 +26,6 @@ import com.mogo.och.unmanned.taxi.bean.QueryServingDurationRespBean import com.mogo.och.unmanned.taxi.bean.QueryTaskRespBean import com.mogo.och.unmanned.taxi.constant.StationTypeEnum import com.mogo.och.unmanned.taxi.constant.TaskTypeEnum -import com.mogo.och.unmanned.taxi.ui.task.TaxiCurrentTaskFragment import kotlinx.android.synthetic.main.unmanned_taxi_operational_data_view.dayCompletedOrdersView import kotlinx.android.synthetic.main.unmanned_taxi_operational_data_view.dayTotalOrdersView import kotlinx.android.synthetic.main.unmanned_taxi_operational_data_view.itemDayTv @@ -115,7 +114,7 @@ class TaxiOperationalDialogFragment : DialogFragment(), lifecycleScope.launchWhenStarted { mViewModel.uiStateFlow.map { it.operationalDataUIState }.collect { operationalDataUIState -> - d(TaxiCurrentTaskFragment.TAG, "uiStateFlow-initViewModelObserver: $operationalDataUIState") + d(TAG, "uiStateFlow-initViewModelObserver: $operationalDataUIState") when (operationalDataUIState) { is OperationalDataStateUIState.Init -> { } diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt index 45372c123c..83f27f04c6 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/TaxiTaskModel.kt @@ -276,14 +276,14 @@ object TaxiTaskModel { private val mMogoAutopilotStatusListener: IOchAutopilotStatusListener = object : IOchAutopilotStatusListener { override fun onAutopilotIpcConnectStatusChanged(status: AdasConstants.IpcConnectionStatus, reason: String?) { - DebugView.printInfoMsg( - "[域控连接状态变化] status=$status, reason=${ - if (TextUtils.isEmpty( - reason - ) - ) "" else reason - }" - ) +// DebugView.printInfoMsg( +// "[域控连接状态变化] status=$status, reason=${ +// if (TextUtils.isEmpty( +// reason +// ) +// ) "" else reason +// }" +// ) } override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?, lineId: Long) { diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarycurrent/ItineraryCurrentModel.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarycurrent/ItineraryCurrentModel.kt index c79a16007a..b843c773be 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarycurrent/ItineraryCurrentModel.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarycurrent/ItineraryCurrentModel.kt @@ -1,27 +1,505 @@ package com.mogo.och.unmanned.taxi.ui.itinerarycurrent import androidx.lifecycle.ViewModel +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.module.status.MogoStatusManager +import com.mogo.eagle.core.data.BaseData +import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.unmanned.CallerUnmannedListenerManager +import com.mogo.eagle.core.network.utils.GsonUtil +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.util.NetworkUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.common.module.biz.order.TaxiOrderStatusEnum +import com.mogo.och.common.module.manager.autopilot.line.LineManager +import com.mogo.och.common.module.manager.autopilot.location.OchLocationManager +import com.mogo.och.common.module.manager.distance.TrajectoryAndDistanceManager +import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager +import com.mogo.och.common.module.network.OchCommonServiceCallback +import com.mogo.och.common.module.utils.ToastUtilsOch +import com.mogo.och.common.module.voice.VoiceNotice +import com.mogo.och.unmanned.taxi.R +import com.mogo.och.unmanned.taxi.base.BaseViewModel +import com.mogo.och.unmanned.taxi.base.IUiIntent +import com.mogo.och.unmanned.taxi.bean.QueryCurrentTaskRespBean import com.mogo.och.unmanned.taxi.bean.StartGrayAndQueryContrailRsp +import com.mogo.och.unmanned.taxi.bean.StartServiceRespBean +import com.mogo.och.unmanned.taxi.bean.TrajectoryListRespBean +import com.mogo.och.unmanned.taxi.callback.ITaxiCarServiceCallback +import com.mogo.och.unmanned.taxi.callback.ITaxiTaskWithOrderCallback +import com.mogo.och.unmanned.taxi.constant.TaskStatusEnum +import com.mogo.och.unmanned.taxi.constant.TaskTypeEnum +import com.mogo.och.unmanned.taxi.constant.TaxiUnmannedConst +import com.mogo.och.unmanned.taxi.network.TaxiTaskWithOrderServiceManager +import com.mogo.och.unmanned.taxi.ui.debug.DebugView +import com.mogo.och.unmanned.taxi.ui.task.TaskUiIntent +import com.mogo.och.unmanned.taxi.ui.task.TaskWithOrderUIState +import com.mogo.och.unmanned.taxi.ui.task.TaxiTaskModel +import com.mogo.och.unmanned.taxi.ui.task.UnmannedState +import com.mogo.och.unmanned.taxi.utils.TaxiTrajectoryManager /** * @author XuXinChao * @description BadCase录包管理页面 * @since: 2022/12/15 */ -class ItineraryCurrentModel : ViewModel() { +class ItineraryCurrentModel : BaseViewModel(), + ITaxiTaskWithOrderCallback, ITaxiCarServiceCallback { private val TAG = ItineraryCurrentModel::class.java.simpleName + init { + TaxiTaskModel.addTaskWithOrderListener(TAG, this) + TaxiTaskModel.setCarServiceCallback(this) + } + private var viewCallback: SwtichLineViewCallback? = null + fun setDistanceCallback(viewCallback: SwtichLineViewCallback) { + this.viewCallback = viewCallback + } + + override fun onCleared() { - + TaxiTaskModel.removeTaskWithOrderListener(TAG) + TaxiTaskModel.removeCarServiceCallback() + super.onCleared() } - fun setDistanceCallback(viewCallback: SwtichLineViewCallback) { - this.viewCallback = viewCallback + override fun initUiState(): UnmannedState { + return UnmannedState(TaskWithOrderUIState.Init) + } + + override fun handleIntent(intent: IUiIntent) { + when (intent) { + is TaskUiIntent.StartTaskWithOrderLooper -> { //开始轮询 + startOrStopCurrentTaskWithOrderLoop(true) + } + + is TaskUiIntent.StartOrEndTakeOrder -> {//开始、暂停接单 + TaxiTaskModel.updateCarServingStatus() + } + + is TaskUiIntent.JumpPassengerCheck -> { //手动点击跳过乘客验证 + jumpPassengerCheck() + } + + is TaskUiIntent.JourneyCompleted -> { //点击服务完成 + journeyCompleted() + } + + is TaskUiIntent.CloseOrderByDriver -> { + closeOrderByDriver() + } + + is TaskUiIntent.CancelOrder -> {// 取消订单, 暂未加取消类型和原因 + cancelOrder(intent.type) + } + + is TaskUiIntent.StartTask -> { + startTask() + } + } + } + + fun startOrStopCurrentTaskWithOrderLoop(start: Boolean) { + d(TAG, "startOrStopCurrentTaskWithOrderLoop(): isStart=$start") + if (start) { + DebugView.printInfoMsg("[查询TaskWithOrder信息] start loop") + TaxiTaskModel.startQueryCurrentTaskWithOrderLoop() + } else { + DebugView.printInfoMsg("[查询TaskWithOrder信息] stop loop") + TaxiTaskModel.stopQueryCurrentTaskWithOrderLoop() + } + } + + private fun cancelOrder(cancelType: Int) { + val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() + currentTaskWithOrder?.order?.also { + TaxiTaskModel.cancelOrder(it.orderNo, cancelType) + } + } + + private fun jumpPassengerCheck() { + DebugView.printInfoMsg("[跳过乘客验证] 准备发送请求") + val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() + currentTaskWithOrder?.order?.also { + TaxiTaskWithOrderServiceManager.jumpPassengerCheck( + AbsMogoApplication.getApp().applicationContext, + it.orderNo, + object : OchCommonServiceCallback { + override fun onSuccess(data: BaseData?) { + DebugView.printInfoMsg("[跳过乘客验证] 请求success") + d(TAG, "jumpPassengerCheck onSuccess:") + } + + override fun onFail(code: Int, msg: String?) { + DebugView.printInfoMsg("[跳过乘客验证] 请求fail, code=$code, msg=$msg") + d(TAG, "jumpPassengerCheck onFail: code=$code, msg=$msg") + } + }) + } + } + + private fun journeyCompleted() { + DebugView.printInfoMsg("[服务完成] 准备发送请求") + val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() + currentTaskWithOrder?.order?.also { + TaxiTaskWithOrderServiceManager.orderCompleted( + AbsMogoApplication.getApp().applicationContext, + it.orderNo, + object : OchCommonServiceCallback { + override fun onSuccess(data: BaseData?) { + DebugView.printInfoMsg("[服务完成] 请求success") + d(TAG, "journeyCompleted onSuccess") + } + + override fun onFail(code: Int, msg: String?) { + DebugView.printInfoMsg("[服务完成] 请求fail, code=$code, msg=$msg") + d(TAG, "journeyCompleted onFail: code=$code, msg=$msg") + } + }) + } + } + + private fun closeOrderByDriver() { + val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() + currentTaskWithOrder?.order?.orderEndSite?.also { + TaxiTaskModel.submitArriveSite(it.siteId, true) + } + } + + private fun startTask(isStartAutopilot: Boolean = true) { + if (!TaxiTaskModel.checkCurrentTaskCondition()) { + ToastUtils.showShort("无任务!") + return + } + + TaxiTaskModel.getCurrentTaskWithOrder()?.let { + TaxiTaskModel.startTask( + if (it.order != null && it.order!!.orderStatus >= TaxiOrderStatusEnum.ArriveAtStart.code) + it.order!!.orderLine //当前若是启动的送驾任务 , 则使用订单信息的lineId + else + it.lineId + ,isStartAutopilot) + } + } + + private fun updateTaskAndOrderUi(currentTaskWithOrder: QueryCurrentTaskRespBean.Result?) { + d( + TAG, "updateTaskAndOrderUi: currentTaskWithOrder=${ + GsonUtil.getGson().toJson(currentTaskWithOrder) + }" + ) + sendUiState { + copy( + taskWithOrderUIState = TaskWithOrderUIState.TaskWithOrder( + currentTaskWithOrder + ) + ) + } + } + + private fun updatePrepareTaskDelayUI(delayTime: Long, isStart: Boolean) { + d(TAG, "UpdatePrepareTaskDelay120SUI = $isStart") + sendUiState { + copy( + taskWithOrderUIState = TaskWithOrderUIState.UpdatePrepareTaskDelay(delayTime, + isStart + ) + ) + } + } + + private fun updateDriveToNearestStationTaskUI(driveToNearestStationTask: StartServiceRespBean.Result?) { + d(TAG, "updateDriveToNearestStationTaskUI = ${driveToNearestStationTask?.toString()}") + sendUiState { + copy( + taskWithOrderUIState = TaskWithOrderUIState.TaskDriveToNearestStationTask( + driveToNearestStationTask + ) + ) + } + } + + private fun updateOrderTripInfoUI(mileage: Float, duration: Int) { + d(TAG, "updateOrderTripInfoUI") + OchChainLogManager.writeChainLog("到达目的地计算距离和时间", "距离:${mileage} 时间:${duration}") + sendUiState { + copy( + taskWithOrderUIState = TaskWithOrderUIState.UpdateOrderTripInfo( + mileage, duration + ) + ) + } + } + + private fun updateTaskTripInfoLocalCalculateUI(meters: Long, timeInSecond: Long) { + d(TAG, "UpdateTaskTripInfoLocalCalculateUI") + sendUiState { + copy( + taskWithOrderUIState = TaskWithOrderUIState.UpdateTaskTripLocalCalculateInfo( + meters, timeInSecond + ) + ) + } + } + + override fun onTaskWithOrderQuerySuccess(timeMillis: Long) { + } + + override fun onTaskWithOrderDataChanged(result: QueryCurrentTaskRespBean.Result?) { + d(TAG, "onTaskWithOrderChanged = result = " + GsonUtil.jsonFromObject(result)) + DebugView.printInfoMsg("[查询TaskWithOrder信息] 更新数据, 刷新UI") + updateTaskAndOrderUi(result) + // 设置task执行相关状态,切换模式时判断使用 + if (result == null || result.taskType == TaskTypeEnum.None.code) { + MogoStatusManager.getInstance().setTaxiUnmanedDriverPerformTask(TAG, false) + LineManager.setLineInfo(null); + } else { + MogoStatusManager.getInstance().setTaxiUnmanedDriverPerformTask(TAG, true) + } + } + + override fun onTaskStarted(result: QueryCurrentTaskRespBean.Result?) { + updateLocalCalculateStation(result) + if (result?.endSite != null){ + TaxiTaskModel.setBeautificationMode(true) + updateAutopilotControlParameters() + }else{ + clearDemoModeAndACParameters() + } + } + + private fun updateLocalCalculateStation(result: QueryCurrentTaskRespBean.Result?) { + if (result?.startSite != null && result.endSite != null + ) { + d(TAG, "updateLocalCalculateStation start") + val curTaskAndOrder = TaxiTaskModel.getCurrentTaskWithOrder() ?: return + if (curTaskAndOrder.startSite != null && curTaskAndOrder.endSite != null) { + val startStation = MogoLocation() + startStation.longitude = curTaskAndOrder.startSite!!.gcjLon + startStation.latitude = curTaskAndOrder.startSite!!.gcjLat + val endStation = MogoLocation() + endStation.longitude = curTaskAndOrder.endSite!!.gcjLon + endStation.latitude = curTaskAndOrder.endSite!!.gcjLat + TrajectoryAndDistanceManager.setStationPoint( + startStation, + endStation, + curTaskAndOrder.lineId + ) + } + } else { + TaxiTaskModel.clearLocalCalculateStation() + } + } + + /** + * 开始倒计时120s或者10s拉取任务 + * 演练任务120s拉取 + * 接驾任务10s拉取 + */ + override fun onTaskCompleted(result: QueryCurrentTaskRespBean.Result?) { + d(TAG, "onTaskCompleted: ${result?.currentStatus}, siteId=${result?.endSite?.siteId}") + + if (result?.order != null && result.servingStatus == 1){ + if (result.taskType <= TaskTypeEnum.VirtualTask.code + && result.order!!.orderStatus < TaxiOrderStatusEnum.ArriveAtStart.code) { + VoiceNotice.showNotice("已为您接到订单") + } + if (result.order!!.orderStatus == TaxiOrderStatusEnum.ArriveAtStart.code){ + VoiceNotice.showNotice("已到达上车地点,等待乘客上车") + } + } + + /** + * 1、有订单下(表示当前有订单或者未来有要执行的订单): + * 接驾任务需要立即拉取, 拉取时机在车辆前往上车点状态 + * 送驾任务需要立即拉取, 拉取时机在乘客已上车状态 + * 2、在没有订单情况下 + * 若当前到站的是前往标定站点, 则45s去拉取任务 + * 若当前是演练任务到站, 45s去拉取任务 + * 若当前是接驾任务到站, 此情况肯定是有订单的, 则走1 + * 若当前到站的是送驾任务, 不去拉取, 需等待司机点击服务完成按钮后拉取 + */ + + if (result?.order != null){ //接到订单情况下 + if (QueryCurrentTaskRespBean.isOrderOnTheWayToStart(result)){ //接驾任务拉取 + TaxiTaskModel.startPrepareTaskDelay( + TaxiUnmannedConst.START_PREPARE_TO_START_TASK_INTERVAL, + result?.endSite!!.siteId) + }else if (QueryCurrentTaskRespBean.isOrderUserArriveAtStart(result)) { //送驾任务拉取 + TaxiTaskModel.startPrepareTaskDelay(0, result?.endSite!!.siteId) + }else{ // 在已经接到订单的其他情况下, 取消倒计时任务拉取 + TaxiTaskModel.removePrepareTaskDelay() + } + }else{ //演练任务拉取 6.2.0使用配置的时间拉取, 默认45s + TaxiTaskModel.startPrepareTaskDelay( + CallerUnmannedListenerManager.getVirtualTaskPullTaskIntervalF() * 1000L, result?.endSite!!.siteId) + } + + clearDemoModeAndACParameters() + } + + override fun onTaskTrajectoryDataChanged(data: TrajectoryListRespBean?) { + TaxiTrajectoryManager.getInstance().syncTrajectoryInfo() //同步轨迹信息 + } + + override fun onOrderCancel() { + VoiceNotice.showNotice("已取消行程") + //取消自驾,D档位会溜车 map3.6.0 修改 + TaxiTaskModel.cancelAutopilot() + // 设置task执行相关状态,切换模式时判断使用 + MogoStatusManager.getInstance().setTaxiUnmanedDriverPerformTask(TAG, false) + LineManager.setLineInfo(null); + } + + override fun onOrderArriveAtEnd(orderNo: String) { + TaxiTaskModel.queryOrderByOrderNo(orderNo) + } + + /** + * 更新总全程信息(公里和分钟), 后端返回的数据 + */ + override fun onOrderTripInfoChanged(mileage: Float, duration: Int) { + updateOrderTripInfoUI(mileage, duration) + } + + override fun onOrderJourneyCompleted() { + updateTaskAndOrderUi(null) + //获取新的任务 + val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() + currentTaskWithOrder?.endSite?.also {//使用配置的时间拉取, 默认是45s + TaxiTaskModel.startPrepareTaskDelay( + CallerUnmannedListenerManager.getVirtualTaskPullTaskIntervalF() * 1000L, + it.siteId) + } + // 设置task执行相关状态,切换模式时判断使用 + MogoStatusManager.getInstance().setTaxiUnmanedDriverPerformTask(TAG, false) + LineManager.setLineInfo(null); + } + + override fun onStartAutopilot(postDelayTime: Long) { + UiThreadHandler.postDelayed(startTaskRunnable, postDelayTime) // 5s后或者倒计时结束开启自驾, 状态流转 + } + + private val startTaskRunnable: Runnable = Runnable { + startTask() //状态流转 + VoiceNotice.showNotice("车辆正在自动开启自动驾驶") + } + + /** + * 主动请求平行驾驶, 停止启动自驾命令, 任务状态需向下流转 + */ + override fun onStopAutopilot() { + UiThreadHandler.removeCallbacks(startTaskRunnable) + if (!TaxiTaskModel.checkCurrentTaskCondition()) { + d(TAG, "onStopAutopilot: 无任务无需流转状态") + return + } + startTask(false) + } + + override fun onPauseStartAutopilot() { + UiThreadHandler.removeCallbacks(startTaskRunnable) + } + + /** + * 开始倒计时120s或者10s拉取任务 + * 演练任务120s拉取 + * 接驾任务10s拉取 + */ + override fun onStartPrepareTaskUI(delayTime: Long, isStart: Boolean) { + updatePrepareTaskDelayUI(delayTime, isStart) + } + + /** + * 更新本次任务行程信息, 本地计算的数据 + */ + override fun onTaskTripInfoLocalCalculateChanged(meters: Long, timeInSecond: Long) { + updateTaskTripInfoLocalCalculateUI(meters, timeInSecond) + } + + override fun onCarEndServiceSuccess( + driveToNearestStationTask: StartServiceRespBean.Result?, + currentTaskWithOrder: QueryCurrentTaskRespBean.Result? + ) { + if (currentTaskWithOrder == null) return + if (currentTaskWithOrder.currentStatus < TaskStatusEnum.CompleteTask.code //任务未完成 + && currentTaskWithOrder.currentStatus > TaskStatusEnum.None.code // 暂停接单后查询到任务状态是0, 代表没任务 + || currentTaskWithOrder.order != null) {// 有订单未完成 + VoiceNotice.showNotice("暂停接单啦!要完成当前订单哦") + } else { + VoiceNotice.showNotice("暂停接单啦") + updateDriveToNearestStationTaskUI(driveToNearestStationTask) + } + } + + override fun onCarEndServiceFailed(code: Int, msg: String) { + ToastUtilsOch.showWithCodeMessage(code, msg) + } + + override fun onCarEndServiceError() { + val context = AbsMogoApplication.getApp().applicationContext + if (!NetworkUtils.isConnected(context)) { + ToastUtils.showShort(context.getString(R.string.network_error_tip)) + } else { + ToastUtils.showShort(context.getString(R.string.request_error_tip)) + } + } + + override fun onCarStartServiceSuccess( + driveToNearestStationTask: StartServiceRespBean.Result?, + currentTaskWithOrder: QueryCurrentTaskRespBean.Result? + ) { + VoiceNotice.showNotice("开始接单啦") + updateDriveToNearestStationTaskUI(driveToNearestStationTask) + } + + override fun onCarStartServiceFailed(code: Int, msg: String) { + val gcJ02Location = OchLocationManager.getGCJ02Location() + ToastUtilsOch.showWithCodeMessage( + code, + "$msg curLatitude = ${gcJ02Location.latitude}" + " curLongitude = ${gcJ02Location.longitude}" + ) + } + + override fun onCarStartServiceError() { + val context = AbsMogoApplication.getApp().applicationContext + if (!NetworkUtils.isConnected(context)) { + ToastUtils.showShort(context.getString(R.string.network_error_tip)) + } else { + ToastUtils.showShort(context.getString(R.string.request_error_tip)) + } + } + + private fun clearDemoModeAndACParameters(){ + if (FunctionBuildConfig.isDemoMode) { + d(TAG, "setIPCDemoMode:false") + CallerAutoPilotControlManager.setIPCDemoMode(false) + } + TaxiTaskModel.clearAutopilotControlParameters() + } + + /** + * 将业务订单信息保存,鹰眼可取用 + */ + private fun updateAutopilotControlParameters() { + val parameters = TaxiTaskModel.initAutopilotControlParameters() + if (null == parameters) { + CallerLogger.e(TAG, "AutopilotControlParameters is empty.") + return + } + d(TAG, "AutopilotControlParameters is update.") + DebugView.printInfoMsg("[启自驾] updateAutopilotControlParameters调用成功") + CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(parameters) } diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarycurrent/ItineraryCurrentView.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarycurrent/ItineraryCurrentView.kt index c43a3f0d3d..c0e72f1d27 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarycurrent/ItineraryCurrentView.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarycurrent/ItineraryCurrentView.kt @@ -1,17 +1,84 @@ package com.mogo.och.unmanned.taxi.ui.task.itinerarycurrent import android.content.Context +import android.graphics.Color +import android.os.CountDownTimer +import android.text.TextUtils import android.util.AttributeSet import android.view.LayoutInflater +import android.view.View import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.content.ContextCompat import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.findViewTreeViewModelStoreOwner +import androidx.lifecycle.lifecycleScope +import com.amap.api.navi.model.NaviLatLng +import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getState +import com.mogo.eagle.core.function.hmi.ui.widget.ItinerarySummaryDialog +import com.mogo.eagle.core.function.main.MainMoGoApplication +import com.mogo.eagle.core.network.utils.GsonUtil +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i +import com.mogo.eagle.core.utilcode.util.ClickUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.och.common.module.biz.order.TaxiOrderStatusEnum +import com.mogo.och.common.module.manager.autopilot.location.OchLocationManager +import com.mogo.och.common.module.map.AmapNaviToDestinationModel +import com.mogo.och.common.module.map.ICommonNaviChangedCallback +import com.mogo.och.common.module.map.MapMakerManager +import com.mogo.och.common.module.utils.DateTimeUtil +import com.mogo.och.common.module.utils.FlowBus +import com.mogo.och.common.module.utils.ResourcesUtils +import com.mogo.och.common.module.voice.VoiceNotice +import com.mogo.och.common.module.wigets.CommonSlideView +import com.mogo.och.common.module.wigets.OCHCommitDialog import com.mogo.och.unmanned.taxi.R import com.mogo.och.unmanned.taxi.TaxiUnmannedDriverProvider +import com.mogo.och.unmanned.taxi.bean.OrderDetail +import com.mogo.och.unmanned.taxi.bean.QueryCurrentTaskRespBean +import com.mogo.och.unmanned.taxi.bean.StartServiceRespBean +import com.mogo.och.unmanned.taxi.constant.TaskStatusEnum +import com.mogo.och.unmanned.taxi.constant.TaskTypeEnum +import com.mogo.och.unmanned.taxi.constant.TaxiDriverEventConst +import com.mogo.och.unmanned.taxi.constant.TaxiUnmannedConst.Companion.TAXI_END_MAP_MAKER +import com.mogo.och.unmanned.taxi.constant.TaxiUnmannedConst.Companion.TAXI_START_MAP_MAKER +import com.mogo.och.unmanned.taxi.constant.TaxiUnmannedConst.Companion.TYPE_MARKER_TAXI_ORDER +import com.mogo.och.unmanned.taxi.ui.debug.DebugView import com.mogo.och.unmanned.taxi.ui.itinerarycurrent.ItineraryCurrentModel +import com.mogo.och.unmanned.taxi.ui.task.TaskUiIntent +import com.mogo.och.unmanned.taxi.ui.task.TaskWithOrderUIState +import com.mogo.och.unmanned.taxi.ui.task.TaxiOrderCancelDialog +import com.mogo.och.unmanned.taxi.ui.task.TaxiTaskModel +import com.mogo.och.unmanned.taxi.utils.TaskUtils +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.aciv_task_type_exercise +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.aciv_task_type_order +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.actv_distance_end +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.actv_end_order +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.actv_submit_task +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.cancelOrder +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.commonSlideViewStartServer +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.gourp_order +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.group_itinerary_info +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.include_empty +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.naviToEnd +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.naviToStart +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.prepareTaskCountdownTv +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.taskStatus +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.actv_time_end +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.endStationName +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.startStationName +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.orderPhoneAndNum +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.pathwayPoint +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.trajectoryType +import kotlinx.android.synthetic.main.unmanned_itinerary_current.view.v_bg_route_point_station_name +import kotlinx.coroutines.flow.map -class ItineraryCurrentView: ConstraintLayout, ItineraryCurrentModel.SwtichLineViewCallback { +class ItineraryCurrentView: ConstraintLayout, ItineraryCurrentModel.SwtichLineViewCallback, + View.OnClickListener, ICommonNaviChangedCallback { constructor(context: Context) : super(context) @@ -27,6 +94,10 @@ class ItineraryCurrentView: ConstraintLayout, ItineraryCurrentModel.SwtichLineVi const val TAG = "SwitchBizView" } + private var mPrepareTasCountDownTimer: CountDownTimer? = null + + private var dialog: ItinerarySummaryDialog? = null + private var viewModel: ItineraryCurrentModel?=null private var fragment: LifecycleOwner?=null @@ -41,6 +112,272 @@ class ItineraryCurrentView: ConstraintLayout, ItineraryCurrentModel.SwtichLineVi fragment = TaxiUnmannedDriverProvider.getFragmentInfo() } + private fun initViewModelObserver() { + viewModel?.sendUiIntent(TaskUiIntent.StartTaskWithOrderLooper) + + //监听返回的数据状态 + fragment?.lifecycleScope?.launchWhenStarted { + viewModel?.uiStateFlow?.map { it.taskWithOrderUIState }?.collect { taskAndOrderUiState -> + d(TAG, "uiStateFlow-initViewModelObserver: $taskAndOrderUiState") + when (taskAndOrderUiState) { + is TaskWithOrderUIState.Init -> { + } + + // 开始接单后 需要将车开到最近的一个站点就位,然后才能开启 无人化 流程 + is TaskWithOrderUIState.TaskDriveToNearestStationTask -> { + if (taskAndOrderUiState.driveToNearestStationTask != null) { + updateViewByDriveToNearestStationTask(taskAndOrderUiState.driveToNearestStationTask) + } else { + updatePrepareTaskDelayUI(0, false) + initContainerView(false) + removeAllMapMarker() + } + } + + is TaskWithOrderUIState.TaskWithOrder -> { + val currentTaskWithOrder = taskAndOrderUiState.taskWithOrder + if (currentTaskWithOrder == null) { + initContainerView(false) + removeAllMapMarker() + } else { + updateViewByCurrentTaskWithOrder(currentTaskWithOrder) + } + updateNextTaskFragment(currentTaskWithOrder) + } + + is TaskWithOrderUIState.UpdateOrderTripInfo -> { + dialog?.setOrderMileage(taskAndOrderUiState.mileage*1000) + actv_distance_end.text = TaskUtils.getCurrentTaskDistance(taskAndOrderUiState.mileage.toLong()) + actv_time_end.text = TaskUtils.getCurrentTaskTime(taskAndOrderUiState.duration.toLong()) + } + + is TaskWithOrderUIState.UpdateTaskTripLocalCalculateInfo -> { + actv_distance_end.text = TaskUtils.getCurrentTaskDistance(taskAndOrderUiState.meters.toLong()) + actv_time_end.text = TaskUtils.getCurrentTaskTime(taskAndOrderUiState.timeInSecond.toLong()) + } + + is TaskWithOrderUIState.UpdatePrepareTaskDelay -> { + updatePrepareTaskDelayUI( + taskAndOrderUiState.delayTime, + taskAndOrderUiState.isStart + ) + } + } + } + } + } + + /** + * 更新拉取任务倒计时 + */ + private fun updatePrepareTaskDelayUI(millisInFuture: Long, isStart: Boolean) { + DebugView.printInfoMsg("距离任务获取还有 ${DateTimeUtil.second2MMSS(millisInFuture / 1000)}") + if (!isStart) { + prepareTaskCountdownTv.visibility = View.GONE + mPrepareTasCountDownTimer?.cancel() + mPrepareTasCountDownTimer = null + return + } + + if (mPrepareTasCountDownTimer != null) { + mPrepareTasCountDownTimer?.cancel() + mPrepareTasCountDownTimer = null + } + + mPrepareTasCountDownTimer = object : CountDownTimer(millisInFuture, 1000L) {// 倒计时后开启自驾 + + override fun onTick(millisUntilFinished: Long) { + DebugView.printInfoMsg("距离任务获取还有 ${DateTimeUtil.second2MMSS(millisUntilFinished / 1000)}") + // 倒计时 + UiThreadHandler.post { + prepareTaskCountdownTv.visibility = View.VISIBLE + prepareTaskCountdownTv.text = + "距离任务获取还有 ${DateTimeUtil.second2MMSS(millisUntilFinished / 1000)}" + } + } + + override fun onFinish() { + //倒计时结束了... + UiThreadHandler.post { + prepareTaskCountdownTv.visibility = View.INVISIBLE + } + mPrepareTasCountDownTimer?.cancel() + } + } + + mPrepareTasCountDownTimer?.start() + } + + /** + * 更新当前任务和订单信息 + */ + private fun updateViewByCurrentTaskWithOrder(taskAndOrder: QueryCurrentTaskRespBean.Result?) { + if (taskAndOrder == null) return + /** + * 根据任务类型判断任务显示, + * 虚拟单, 显示在进行中 前往上车点 + * 演练任务,显示演练任务, 同时有订单显示在待服务中 + * 当前任务是接驾任务,显示订单状态+运营单 订单显示在进行中, 任务不再显示 + */ + val taskType = taskAndOrder.taskType // 任务类型 + val order = taskAndOrder.order // 订单信息 + val endSite = taskAndOrder.endSite // 终点 + val currentStatus = taskAndOrder.currentStatus // 任务的状态 0:空闲 1:获取任务 2:开始任务 3:到达目的地 + + if ((endSite == null || currentStatus == TaskStatusEnum.CompleteTask.code) // 无任务或者任务已经完成的时候且无订单的时候 + && taskAndOrder.order == null + ) { + initContainerView(false) + removeAllMapMarker() + return + } + + initContainerView(true) + + when (taskType) { + TaskTypeEnum.None.code -> { + if (order != null && (currentStatus == TaskStatusEnum.CompleteTask.code + || currentStatus == TaskStatusEnum.None.code) + ) { //暂停接单会清空前往上车点任务 + updateOrderUI(order) + } + } + + TaskTypeEnum.VirtualTask.code -> { //演练任务 + + if (order != null && currentStatus == TaskStatusEnum.CompleteTask.code) { + updateOrderUI(order) + } else { + updateVirtualTaskUI(taskAndOrder) + } + } + + TaskTypeEnum.ToOrderEndTask.code, TaskTypeEnum.ToOrderStartTask.code -> {// 接驾任务 或 送驾任务 + order?.also { + updatePathwayPoint(taskType, endSite?.siteName) + updateOrderUI(it) + } + } + } + + updateMapMarkers(taskAndOrder) + updateRemainDistanceAndTime(false) + } + + // 第一个特殊任务 也是虚拟任务 + private fun updateViewByDriveToNearestStationTask(driveToNearestStationTask: StartServiceRespBean.Result?) { + if (driveToNearestStationTask == null) return + initContainerView(true) + // DriverToNearestStationTask 任务更新 + gourp_order.visibility = GONE + group_itinerary_info.visibility = VISIBLE + aciv_task_type_exercise.visibility = VISIBLE + // 更新任务状态,起点,终点 + taskStatus.text = resources.getString(R.string.task_start_to_virtual_site) + startStationName.text = resources.getString(R.string.task_current_loc) + endStationName.text = driveToNearestStationTask.siteName + + setOrRemoveMapMaker( + true, + TAXI_END_MAP_MAKER, + driveToNearestStationTask.wgs84Lat, + driveToNearestStationTask.wgs84Lon, + R.raw.end_marker + ) + + // 使用高德获取导航数据 + startNaviToStation( + false, + driveToNearestStationTask.gcjLat, + driveToNearestStationTask.gcjLon + ) + } + + private fun showEmptyView() { + gourp_order.visibility = GONE + aciv_task_type_exercise.visibility = GONE + group_itinerary_info.visibility = GONE + include_empty.visibility = VISIBLE + prepareTaskCountdownTv.visibility = GONE + } + + private fun initOnClickListener() { + naviToStart.setOnClickListener(this) + naviToEnd.setOnClickListener(this) + + cancelOrder.setOnClickListener(this) + taskStatus.setOnClickListener(this) + commonSlideViewStartServer.setSlideListener(object :CommonSlideView.SlideListener{ + override fun slideEnd() { + d(TAG, taskStatus.text.toString()) + startOrEndService() + } + }) + actv_submit_task.onClick { + startOrEndService() + } + actv_end_order.onClick { + startOrEndService() + } + } + + private fun initTaskDebugViewListener() { + fragment?.let { fr-> + aciv_task_type_exercise.setOnLongClickListener { + FlowBus.with(TaxiDriverEventConst.TaxiFragmentEvent.EVENT_TYPE_SHOW_DEBUG_VIEW) + .post(fr.lifecycleScope, true) + false + } + aciv_task_type_order.setOnLongClickListener { + FlowBus.with(TaxiDriverEventConst.TaxiFragmentEvent.EVENT_TYPE_SHOW_DEBUG_VIEW) + .post(fr.lifecycleScope, true) + false + } + } + } + + private fun startOrEndService() { + val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() + if (currentTaskWithOrder?.order == null) return + val order = currentTaskWithOrder.order + if (TaxiOrderStatusEnum.ArriveAtStart.code == order!!.orderStatus) { //到达乘客上车点,司机可跳过乘客屏认证 + viewModel?.sendUiIntent(TaskUiIntent.JumpPassengerCheck) + } else if (TaxiOrderStatusEnum.UserArriveAtStart.code == order.orderStatus) { + viewModel?.sendUiIntent(TaskUiIntent.StartTask) + } else if (TaxiOrderStatusEnum.ArriveAtEnd.code == order.orderStatus) { //点击了完成服务,结束订单并更新订单信息 + viewModel?.sendUiIntent(TaskUiIntent.JourneyCompleted) + } else if (TaxiOrderStatusEnum.OnTheWayToEnd.code == order.orderStatus) { //前往目的地过程中可提前结束行程 + //自驾中提示,接管后才能结束 + if (getState() + == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING + ) { + ToastUtils.showLong(R.string.taxi_switch_line_btn_warning1) + } else { + closeOrderDialog() + } + } + } + + private fun closeOrderDialog() { + val builder = OCHCommitDialog.Builder() + val closeOrderDialog = builder + .title(ResourcesUtils.getString(R.string.dialog_order_close_title)) + .tips(ResourcesUtils.getString(R.string.dialog_order_close_content)) + .confirmStr(ResourcesUtils.getString(R.string.dialog_order_close_confirm)) + .cancelStr(ResourcesUtils.getString(R.string.dialog_order_close_cancel)) + .build(context) + closeOrderDialog!!.setClickListener(object : OCHCommitDialog.ClickListener { + override fun confirm() { + viewModel?.sendUiIntent(TaskUiIntent.CloseOrderByDriver) + } + + override fun cancel() { + closeOrderDialog.dismiss() + } + }) + closeOrderDialog.show() + } + override fun onAttachedToWindow() { super.onAttachedToWindow() @@ -48,6 +385,434 @@ class ItineraryCurrentView: ConstraintLayout, ItineraryCurrentModel.SwtichLineVi ViewModelProvider(it).get(ItineraryCurrentModel::class.java) } viewModel?.setDistanceCallback(this) + initOnClickListener() + showEmptyView() + initTaskDebugViewListener() + initViewModelObserver() + } + + override fun onClick(v: View?) { + if (!ClickUtils.isFastClick()) { + i(TAG, "view点击过快") + return + } + when (v?.id) { + + cancelOrder.id -> { + val currentWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() + if (currentWithOrder?.order != null) { + val order = currentWithOrder.order + TaxiOrderCancelDialog(context, order!!.orderStatus) { type -> + viewModel?.sendUiIntent(TaskUiIntent.CancelOrder(type)) + }.show() + } + } + + naviToStart.id, + naviToEnd.id -> { + showNaviToEndStationFragment(true) + } + } + } + + /** + * 显示/隐藏 前往任务目的地的导航 + * + * @param isShow + */ + private fun showNaviToEndStationFragment(isShow: Boolean) { + fragment?.let { + FlowBus.with(TaxiDriverEventConst.TaxiFragmentEvent.EVENT_TYPE_START_NAVI_TO_END_STATION) + .post(it.lifecycleScope, isShow) + } + } + + /** + * 是否有正在进行的订单,进行UI显示 + * + * @param hasCurrentTask + */ + private fun initContainerView(hasCurrentTask: Boolean) { + d( + TAG, + "hasCurrentTask = $hasCurrentTask" + ) + if (hasCurrentTask) { + include_empty.visibility = View.GONE + prepareTaskCountdownTv.visibility = View.GONE + } else { + // 空页面 + include_empty.visibility = View.VISIBLE + // 倒计时 + prepareTaskCountdownTv.visibility = View.GONE + // 行程信息 + group_itinerary_info.visibility = View.GONE + // 订单信息 + gourp_order.visibility = View.GONE + // 途经点信息 + pathwayPoint.visibility = View.GONE + // 演练单标识 + aciv_task_type_exercise.visibility = View.GONE + // 轨迹标识 + trajectoryType.visibility = View.GONE + } + } + + private fun removeAllMapMarker() { + MapMakerManager.removeAllMapMarkerByOwner(TYPE_MARKER_TAXI_ORDER) + } + + private fun updateNextTaskFragment(result: QueryCurrentTaskRespBean.Result?) { + fragment?.let { + FlowBus.with(TaxiDriverEventConst.TabFragmentEvent.EVENT_TYPE_TASK_WITH_ORDER_CHANGED) + .post(it.lifecycleScope, result) + + if (result != null + && result.taskType == TaskTypeEnum.VirtualTask.code + && result.order != null + && result.currentStatus != TaskStatusEnum.CompleteTask.code + ) { + VoiceNotice.showNotice("已为您提前接到下一订单,待完成当前任务后服务") + FlowBus.with(TaxiDriverEventConst.TabFragmentEvent.EVENT_TYPE_SHOW_RED_POINT) + .post(it.lifecycleScope, true) + } else { + FlowBus.with(TaxiDriverEventConst.TabFragmentEvent.EVENT_TYPE_SHOW_RED_POINT) + .post(it.lifecycleScope, false) + } + } + + } + + private fun updateOrderUI(order: OrderDetail) { + cancelOrder.visibility = if (order.orderStatus == TaxiOrderStatusEnum.ArriveAtEnd.code + ) View.GONE else View.VISIBLE + gourp_order.visibility = View.VISIBLE + group_itinerary_info.visibility = View.VISIBLE + aciv_task_type_exercise.visibility = View.GONE +// orderStatus: 0 订单创建(为派单), 10 已派上司机(司机去往上车点), 20 司机到达上车点, +// 30 乘客到达上车点, 40 服务中(去往目的地), 50 到达目的地, 60 已完成, 70 已取消 + naviToStart.visibility = if (order.orderStatus + == TaxiOrderStatusEnum.OnTheWayToStart.code + ) View.VISIBLE else View.GONE + + naviToEnd.visibility = if (order.orderStatus + == TaxiOrderStatusEnum.OnTheWayToEnd.code + ) View.VISIBLE else View.GONE + + updatePrepareTaskDelayUI(0, false) + + orderPhoneAndNum.text = TaskUtils.getCurrentTaskPhoneNumAndPassengerCountHtml( + order.bookingUserPhone, + order.passengerSize + ) + startStationName.text = order.orderStartSite?.siteName + endStationName.text = order.orderEndSite?.siteName + TaxiTaskModel.getCurrentOrderTrajectoryList().also { + val orderTrajectory = it.firstOrNull {order.orderLine == it.lineId} + trajectoryType.visibility = if (orderTrajectory?.source == 2) + View.VISIBLE else View.GONE + } + + when (order.orderStatus) { + TaxiOrderStatusEnum.None.code -> { //无 + dismissDialog() + initContainerView(false) + removeAllMapMarker() + } + + TaxiOrderStatusEnum.ArriveAtEnd.code -> { //到达目的地 + taskStatus.text = resources.getString(R.string.task_start_end_site) + + actv_end_order.visibility = VISIBLE + actv_end_order.text = ResourcesUtils.getString(R.string.module_och_taxi_order_server_end) + commonSlideViewStartServer.visibility = GONE + actv_submit_task.visibility = GONE + + showDialog() + hideNaviBtns() + } + + TaxiOrderStatusEnum.OnTheWayToEnd.code -> { //送驾中 + dismissDialog() + taskStatus.text = resources.getString(R.string.task_start_end_site) + + actv_end_order.visibility = VISIBLE + actv_end_order.text = ResourcesUtils.getString(R.string.module_och_taxi_order_close) + commonSlideViewStartServer.visibility = GONE + actv_submit_task.visibility = GONE + + } + + TaxiOrderStatusEnum.UserArriveAtStart.code, TaxiOrderStatusEnum.ArriveAtStart.code -> { + //乘客到达上车点, 验证成功 ; 到达乘客上车点 + dismissDialog() + taskStatus.text = resources.getString(R.string.arrived_start_site) + + actv_end_order.visibility = GONE + commonSlideViewStartServer.visibility = GONE + actv_submit_task.visibility = VISIBLE + if (order.orderStatus == TaxiOrderStatusEnum.UserArriveAtStart.code) { + actv_submit_task.text = + ResourcesUtils.getString(R.string.module_och_taxi_order_server_start) + } + else { + actv_submit_task.text = + ResourcesUtils.getString(R.string.module_och_taxi_order_server_start_wait_check) + } + hideNaviBtns() + actv_time_end.text = TaskUtils.getCurrentTaskWaitTimeHtml() + } + + TaxiOrderStatusEnum.OnTheWayToStart.code -> { //前往上车地点 + dismissDialog() + taskStatus.text = resources.getString(R.string.task_start_start_site) + actv_end_order.visibility = GONE + commonSlideViewStartServer.visibility = VISIBLE + actv_submit_task.visibility = GONE + } + } + } + + //展示虚拟订单 + private fun updateVirtualTaskUI(taskAndOrder: QueryCurrentTaskRespBean.Result?) { + + if (taskAndOrder == null) return + + val startSite = taskAndOrder.startSite // 起点 + val endSite = taskAndOrder.endSite // 终点 + val currentStatus = taskAndOrder.currentStatus // 任务的状态 0:空闲 1:获取任务 2:开始任务 3:到达目的地 + + + + // 空页面 + include_empty.visibility = View.GONE + // 倒计时 + prepareTaskCountdownTv.visibility = View.GONE + // 行程信息 + group_itinerary_info.visibility = View.VISIBLE + // 订单信息 + gourp_order.visibility = View.GONE + // 途经点信息 + pathwayPoint.visibility = View.GONE + // 演练单标识 + aciv_task_type_exercise.visibility = View.VISIBLE + + naviToStart.visibility = View.GONE + naviToEnd.visibility = if (currentStatus >= TaskStatusEnum.StartTask.code) View.VISIBLE else View.GONE + + if (startSite == null || endSite == null) return + + taskStatus.text = resources.getString(R.string.task_start_end_site) + + + startStationName.text = startSite.siteName + endStationName.text = endSite.siteName + TaxiTaskModel.getCurrentOrderTrajectoryList().also { + val taskTrajectory = it.firstOrNull {taskAndOrder.lineId == it.lineId} + trajectoryType.visibility = if (taskTrajectory?.source == 2) + View.VISIBLE else View.GONE + } + updatePrepareTaskDelayUI(0, false) + } + + private fun updatePathwayPoint(taskType: Int, endSiteName: String?) { + if (TextUtils.isEmpty(endSiteName)) return + pathwayPoint.visibility = if (taskType == TaskTypeEnum.ToOrderStartTask.code) + View.VISIBLE else View.GONE + v_bg_route_point_station_name.text = "途径: $endSiteName" + } + + private fun updateMapMarkers(taskAndOrder: QueryCurrentTaskRespBean.Result?) { + if (taskAndOrder?.startSite != null + && taskAndOrder.endSite != null + ) { + when (taskAndOrder.currentStatus) { + TaskStatusEnum.GetTask.code -> { + setOrRemoveMapMaker( + true, + TAXI_START_MAP_MAKER, + taskAndOrder.startSite!!.wgs84Lat, + taskAndOrder.startSite!!.wgs84Lon, + R.raw.star_marker + ) + setOrRemoveMapMaker( + true, + TAXI_END_MAP_MAKER, + taskAndOrder.endSite!!.wgs84Lat, + taskAndOrder.endSite!!.wgs84Lon, + R.raw.end_marker + ) + } + + TaskStatusEnum.StartTask.code -> { + setOrRemoveMapMaker( + false, + TAXI_START_MAP_MAKER, + taskAndOrder.startSite!!.wgs84Lat, + taskAndOrder.startSite!!.wgs84Lon, + R.raw.star_marker + ) + setOrRemoveMapMaker( + true, + TAXI_END_MAP_MAKER, + taskAndOrder.endSite!!.wgs84Lat, + taskAndOrder.endSite!!.wgs84Lon, + R.raw.end_marker + ) + } + + TaskStatusEnum.CompleteTask.code -> { + setOrRemoveMapMaker( + false, + TAXI_START_MAP_MAKER, + taskAndOrder.startSite!!.wgs84Lat, + taskAndOrder.startSite!!.wgs84Lon, + R.raw.star_marker + ) + setOrRemoveMapMaker( + false, + TAXI_END_MAP_MAKER, + taskAndOrder.endSite!!.wgs84Lat, + taskAndOrder.endSite!!.wgs84Lon, + R.raw.end_marker + ) + } + } + } else { + d( + TAG, + "CurrentTaskWithOrder == " + GsonUtil.jsonFromObject(taskAndOrder) + ) + } + } + + /** + * 绘制地图起点终点 + * @param isAdd + * @param uuid + */ + private fun setOrRemoveMapMaker( + isAdd: Boolean, uuid: String, + lat: Double, lon: Double, resourceId: Int + ) { + if (isAdd) { + MapMakerManager.addMapMaker(TYPE_MARKER_TAXI_ORDER, uuid, lat, lon, resourceId) + } else { + MapMakerManager.removeMapMaker(uuid, lat, lon) + } + } + + /** + * 根据任务状态计算剩余历程和时间 + */ + private fun updateRemainDistanceAndTime(isVoicePlay: Boolean) { + val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() ?: return + d(TAG, "updateRemainDistanceAndTime ${currentTaskWithOrder.currentStatus}") + if (currentTaskWithOrder.currentStatus == TaskStatusEnum.StartTask.code) { + if (currentTaskWithOrder.endSite != null) { + startNaviToStation( + isVoicePlay, currentTaskWithOrder.endSite!!.gcjLat, + currentTaskWithOrder.endSite!!.gcjLon + ) + } + + } else if (currentTaskWithOrder.currentStatus == TaskStatusEnum.CompleteTask.code && + currentTaskWithOrder.taskType <= TaskTypeEnum.ToOrderStartTask.code + ) { + actv_distance_end.text = "已到达 ${currentTaskWithOrder.endSite?.siteName}" + } else { + actv_distance_end.text = "距离 -- 公里, 用时 -- 分钟" + } + } + + private fun startNaviToStation(isVoicePlay: Boolean, stationLat: Double, stationLng: Double) { + AmapNaviToDestinationModel.getInstance(context).destroyAmaNavi() + val gcJ02Location = OchLocationManager.getGCJ02Location() + val mCurLatitude = gcJ02Location.latitude + val mCurLongitude = gcJ02Location.longitude + d(TAG, "currentLatLng=$mCurLatitude $mCurLongitude") + val startNaviLatLng = NaviLatLng(mCurLatitude, mCurLongitude) + val endNaviLatLng = NaviLatLng(stationLat, stationLng) + AmapNaviToDestinationModel.getInstance(context).initAMapNavi(startNaviLatLng, endNaviLatLng) + AmapNaviToDestinationModel.getInstance(context).setVoiceIsMute(isVoicePlay) + AmapNaviToDestinationModel.getInstance(context).setTaxiNaviChangedCallback(this) + } + + private fun showDialog(){ + if(dialog==null&&context!=null){ + + } + context?.let { + if(dialog==null) { + dialog = ItinerarySummaryDialog(it, true, R.style.summary_dialog) + } + dialog?.let { dialogInner -> + if(!dialogInner.isShowing){ + dialogInner.show() + } + } + } + + } + + private fun dismissDialog(){ + dialog?.let { + if(it.isShowing){ + it.dismiss() + } + } + dialog = null + } + + private fun hideNaviBtns() { + naviToStart.visibility = View.GONE + naviToEnd.visibility = View.GONE + AmapNaviToDestinationModel.getInstance(context).destroyAmaNavi() + fragment?.let { + FlowBus.with(TaxiDriverEventConst.TaxiFragmentEvent.EVENT_TYPE_SHOW_AMAP_NAVI_TO_STATION_FRAGMENT) + .post(it.lifecycleScope, false) + FlowBus.with(TaxiDriverEventConst.TaxiFragmentEvent.EVENT_TYPE_SHOW_ROUTING_TO_STATION_FRAGMENT) + .post(it.lifecycleScope, false) + } + + } + + override fun onCurrentNaviDistAndTimeChanged(meters: Int, timeInSecond: Long) { + actv_distance_end.text = TaskUtils.getCurrentTaskDistance(meters.toLong()) + actv_time_end.text = TaskUtils.getCurrentTaskTime(timeInSecond) + } + + override fun reInitNaviAmap(isPlay: Boolean, isRestart: Boolean) { + d(TAG, "isPlay = $isPlay, isRestart=$isRestart") + if (!isRestart) { + fragment?.let { + FlowBus.with(TaxiDriverEventConst.TaxiFragmentEvent.EVENT_TYPE_SHOW_AMAP_NAVI_TO_STATION_FRAGMENT) + .post(it.lifecycleScope, false) + } + return + } + val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() + + UiThreadHandler.postDelayed({ + updateRemainDistanceAndTime(false) + }, 2000) + + UiThreadHandler.postDelayed({ + if (currentTaskWithOrder?.currentStatus == TaskStatusEnum.GetTask.code + ) { + if (naviToStart.visibility == View.GONE) { + naviToStart.visibility = View.VISIBLE + } + } + if ((currentTaskWithOrder?.currentStatus == TaskStatusEnum.StartTask.code + && currentTaskWithOrder.order == null) + || (currentTaskWithOrder?.order?.orderStatus == TaxiOrderStatusEnum.OnTheWayToEnd.code) + ) { + if (naviToEnd.visibility == View.GONE) { + naviToEnd.visibility = View.VISIBLE + } + } + }, 3000) } } diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarynext/ItineraryNextView.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarynext/ItineraryNextView.kt index 964d18fa25..84faaa5f93 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarynext/ItineraryNextView.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerarynext/ItineraryNextView.kt @@ -3,14 +3,30 @@ package com.mogo.och.unmanned.taxi.ui.task.itinerarynext import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater +import android.view.View import androidx.constraintlayout.widget.ConstraintLayout import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.findViewTreeViewModelStoreOwner -import com.mogo.och.common.module.wigets.WindowRelativeLayout +import com.mogo.eagle.core.utilcode.kotlin.onClick +import com.mogo.och.common.module.utils.FlowBus import com.mogo.och.unmanned.taxi.R import com.mogo.och.unmanned.taxi.TaxiUnmannedDriverProvider +import com.mogo.och.unmanned.taxi.bean.OrderDetail +import com.mogo.och.unmanned.taxi.bean.QueryCurrentTaskRespBean +import com.mogo.och.unmanned.taxi.constant.TaskStatusEnum +import com.mogo.och.unmanned.taxi.constant.TaskTypeEnum +import com.mogo.och.unmanned.taxi.constant.TaxiDriverEventConst import com.mogo.och.unmanned.taxi.ui.itinerarynext.ItineraryNextModel +import com.mogo.och.unmanned.taxi.ui.task.TaxiOrderCancelDialog +import com.mogo.och.unmanned.taxi.ui.task.TaxiTaskModel +import kotlinx.android.synthetic.main.unmanned_itinerary_next.view.aciv_order_close +import kotlinx.android.synthetic.main.unmanned_itinerary_next.view.actv_end_station_name +import kotlinx.android.synthetic.main.unmanned_itinerary_next.view.actv_order_count +import kotlinx.android.synthetic.main.unmanned_itinerary_next.view.actv_order_phone +import kotlinx.android.synthetic.main.unmanned_itinerary_next.view.actv_start_station_name +import kotlinx.android.synthetic.main.unmanned_itinerary_next.view.group_order_next +import kotlinx.android.synthetic.main.unmanned_itinerary_next.view.include_empty class ItineraryNextView: ConstraintLayout, ItineraryNextModel.SwtichLineViewCallback { @@ -40,6 +56,17 @@ class ItineraryNextView: ConstraintLayout, ItineraryNextModel.SwtichLineViewCall private fun initView() { fragment = TaxiUnmannedDriverProvider.getFragmentInfo() + + aciv_order_close.onClick { //取消待服务订单 + val currentWithOrder = TaxiTaskModel.getCurrentTaskWithOrder() + if (currentWithOrder?.order != null) { + val order = currentWithOrder.order + TaxiOrderCancelDialog(context, order!!.orderStatus) { type -> + TaxiTaskModel.cancelOrder(order.orderNo,type) + }.show() + } + } + showNoNextTaskView() } @@ -49,6 +76,69 @@ class ItineraryNextView: ConstraintLayout, ItineraryNextModel.SwtichLineViewCall ViewModelProvider(it)[ItineraryNextModel::class.java] } viewModel?.setDistanceCallback(this) + initTaskDebugViewListener() + } + + fun onTaskDataChanged(taskWithOrder: QueryCurrentTaskRespBean.Result?) { + if (taskWithOrder?.order == null) { + showNoNextTaskView() + return + } + + if (taskWithOrder.taskType == TaskTypeEnum.VirtualTask.code && + taskWithOrder.currentStatus != TaskStatusEnum.CompleteTask.code + ) { + val order = taskWithOrder.order + updateTaskUI(order!!) + } else { + showNoNextTaskView() + } + } + + private fun showNoNextTaskView() { + include_empty.visibility = View.VISIBLE + group_order_next.visibility = View.GONE + } + + private fun showNextTaskView() { + include_empty.visibility = View.GONE + group_order_next.visibility = View.VISIBLE + } + + private fun updateTaskUI(order: OrderDetail) { + showNextTaskView() + + var tempPhone = order.bookingUserPhone + + tempPhone.let { + if (it.length > 8) { + //截取电话号码前三位 + val phoneNumPre = it.substring(0, 3) + //截取电话号码后四位 + val phoneNumFix = it.substring(7) + tempPhone = "$phoneNumPre****$phoneNumFix" + } + } + actv_order_phone.text = tempPhone + + order.passengerSize + actv_order_count.text = "${order.passengerSize}人" + + order.orderStartSite?.let { + actv_start_station_name.text = it.siteName + } + order.orderEndSite?.let { + actv_end_station_name.text = it.siteName + } + } + + private fun initTaskDebugViewListener() { + fragment?.let { fr-> + FlowBus.with(TaxiDriverEventConst.TabFragmentEvent.EVENT_TYPE_TASK_WITH_ORDER_CHANGED) + .register(fr) { taskWithOrder -> + onTaskDataChanged(taskWithOrder) + } + } } } diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerayswitch/ItinerarySwitchView.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerayswitch/ItinerarySwitchView.kt index bc24b02e20..5a4ed664ae 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerayswitch/ItinerarySwitchView.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/ui/task/itinerayswitch/ItinerarySwitchView.kt @@ -84,10 +84,6 @@ class ItinerarySwitchView: ConstraintLayout, ItinerarySwitchModel.SwtichLineView .register(it) { show -> taxiServerSelector.setNextItineraryRedBagVisable( if (show) View.VISIBLE else View.GONE) } -// FlowBus.with(TaxiDriverEventConst.TabFragmentEvent.EVENT_TYPE_TASK_WITH_ORDER_CHANGED) -// .register(it) { taskWithOrder -> -// nextTaskFragment?.onTaskDataChanged(taskWithOrder) -// } } } diff --git a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/wigets/TaxiSelectViewGroup.kt b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/wigets/TaxiSelectViewGroup.kt index 9c04f15962..6e73abf9f6 100644 --- a/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/wigets/TaxiSelectViewGroup.kt +++ b/OCH/taxi/unmanned-driver/src/main/java/com/mogo/och/unmanned/taxi/wigets/TaxiSelectViewGroup.kt @@ -61,7 +61,7 @@ class TaxiSelectViewGroup @JvmOverloads constructor( override fun onVisibilityAggregated(isVisible: Boolean) { super.onVisibilityAggregated(isVisible) if(isVisible){ - + textCurrentItinerary.setCheck(true) }else{ } diff --git a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_itinerary_current.xml b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_itinerary_current.xml index fd6679d196..c473742cc3 100644 --- a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_itinerary_current.xml +++ b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_itinerary_current.xml @@ -8,7 +8,7 @@ xmlns:tools="http://schemas.android.com/tools"> - + + + @@ -144,14 +158,14 @@ android:textSize="@dimen/dp_32" android:textColor="@color/taxi_color_CCCCCC" app:layout_constraintTop_toBottomOf="@+id/actv_distance_end" - app:layout_constraintStart_toStartOf="@+id/actv_current_itinerary_start_name" - app:layout_constraintBottom_toTopOf="@+id/actv_current_itinerary_end_name" + app:layout_constraintStart_toStartOf="@+id/startStationName" + app:layout_constraintBottom_toTopOf="@+id/endStationName" android:layout_width="wrap_content" android:layout_height="wrap_content"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_itinerary_next.xml b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_itinerary_next.xml index 52d197d77d..154b09b2c4 100644 --- a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_itinerary_next.xml +++ b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_itinerary_next.xml @@ -72,17 +72,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"/> - - - + + + + \ No newline at end of file diff --git a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_switch_itinerary.xml b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_switch_itinerary.xml index 2c807a6f4e..d2790945a0 100644 --- a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_switch_itinerary.xml +++ b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_switch_itinerary.xml @@ -28,19 +28,21 @@ app:layout_constraintStart_toStartOf="parent" android:layout_marginTop="@dimen/dp_28" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintBottom_toBottomOf="parent" android:visibility="gone" app:layout_constraintTop_toBottomOf="@+id/taxiServerSelector" android:layout_width="match_parent" - android:layout_height="wrap_content"/> + android:layout_height="0dp"/> + android:layout_height="0dp"/> \ No newline at end of file diff --git a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_base_fragment.xml b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_base_fragment.xml index d1f28311ba..daf8149f23 100644 --- a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_base_fragment.xml +++ b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_base_fragment.xml @@ -75,4 +75,13 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> + + + \ No newline at end of file diff --git a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_panel.xml b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_panel.xml index 277e864b33..84ba5addce 100644 --- a/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_panel.xml +++ b/OCH/taxi/unmanned-driver/src/main/res/layout/unmanned_taxi_panel.xml @@ -9,11 +9,4 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" /> - - \ No newline at end of file diff --git a/OCH/taxi/unmanned-driver/src/main/res/values/colors.xml b/OCH/taxi/unmanned-driver/src/main/res/values/colors.xml index cd63f6153e..510aaafcfb 100644 --- a/OCH/taxi/unmanned-driver/src/main/res/values/colors.xml +++ b/OCH/taxi/unmanned-driver/src/main/res/values/colors.xml @@ -43,4 +43,5 @@ #80000000 #2EACFF #FF4E41 + #91A1EA \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_report_error.png b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_report_error.png index 54f4c05d77..766d4332f7 100644 Binary files a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_report_error.png and b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable-xhdpi/icon_report_error.png differ