[6.0.0] 增加拉取任务2分钟倒计时UI
This commit is contained in:
@@ -150,4 +150,21 @@ public class DateTimeUtil {
|
||||
return stringBuffer.toString();
|
||||
|
||||
}
|
||||
|
||||
public static String second2MMSS(Long second) {
|
||||
if (second == null || second < 0) {
|
||||
return "00:00";
|
||||
}
|
||||
long m = (long) Math.floor((second % 3600) / 60.0);// 向上取整
|
||||
long s = second % 60;
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
if (m > 0) {
|
||||
stringBuffer.append(m < 10 ? ("0" + m) : m).append(":");
|
||||
}else {
|
||||
stringBuffer.append("00:");
|
||||
}
|
||||
stringBuffer.append(s < 10 ? ("0" + s) : s);
|
||||
return stringBuffer.toString();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,6 @@ interface ITaxiTaskWithOrderCallback {
|
||||
fun onOrderTotalMileAndDurationChanged(mileage: Float, duration: Int)
|
||||
fun onOrderJourneyCompleted()
|
||||
fun onStartAutopilot()
|
||||
|
||||
fun onStartPrepareTask120s()
|
||||
}
|
||||
@@ -198,4 +198,8 @@ public class DebugView @JvmOverloads constructor(
|
||||
|
||||
override fun onStartAutopilot() {
|
||||
}
|
||||
|
||||
override fun onStartPrepareTask120s() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.taxi.ui.unmanned
|
||||
package com.mogo.och.taxi.ui.task
|
||||
|
||||
import com.mogo.och.taxi.base.IUiState
|
||||
import com.mogo.och.taxi.bean.QueryCurrentTaskRespBean
|
||||
@@ -24,4 +24,6 @@ sealed class TaskWithOrderUIState {
|
||||
TaskWithOrderUIState()
|
||||
|
||||
data class UpdateTaskTripInfo(val mileage: Float, val duration: Int) : TaskWithOrderUIState()
|
||||
|
||||
data class UpdatePrepareTaskDelay120S(val isStart: Boolean) : TaskWithOrderUIState()
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
@@ -24,6 +25,7 @@ import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel
|
||||
import com.mogo.och.common.module.map.ICommonNaviChangedCallback
|
||||
import com.mogo.och.common.module.utils.DateTimeUtil
|
||||
import com.mogo.och.common.module.voice.VoiceNotice
|
||||
import com.mogo.och.common.module.wigets.OCHCommitDialog
|
||||
import com.mogo.och.taxi.R
|
||||
@@ -35,10 +37,9 @@ import com.mogo.och.taxi.constant.TaskTypeEnum
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst.Companion.TAXI_END_MAP_MAKER
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst.Companion.TAXI_START_MAP_MAKER
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst.Companion.TIMER_PREPARE_TASK_INTERVAL_120S
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst.Companion.TYPE_MARKER_TAXI_ORDER
|
||||
import com.mogo.och.taxi.ui.base.TaxiFragment
|
||||
import com.mogo.och.taxi.ui.task.TaxiTaskModel
|
||||
import com.mogo.och.taxi.ui.unmanned.TaskWithOrderUIState
|
||||
import com.mogo.och.taxi.utils.MapMakerManager
|
||||
import com.mogo.och.taxi.utils.TaskUtils
|
||||
import kotlinx.android.synthetic.main.task_fragment_current.cancelOrder
|
||||
@@ -56,6 +57,7 @@ import kotlinx.android.synthetic.main.task_fragment_current.taskOtherInfo
|
||||
import kotlinx.android.synthetic.main.task_fragment_current.taskStatus
|
||||
import kotlinx.android.synthetic.main.task_fragment_current.taskTypeTv
|
||||
import kotlinx.android.synthetic.main.taxi_no_data_common_view.noOrderDataTv
|
||||
import kotlinx.android.synthetic.main.taxi_no_data_common_view.prepareTaskCountdownTv
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
/**
|
||||
@@ -67,6 +69,8 @@ class TaxiCurrentTaskFragment : BaseFragment(),
|
||||
|
||||
private lateinit var mViewModel: TaxiCurrentTaskViewModel
|
||||
|
||||
private var prepareTasCountDownTimer: CountDownTimer? = null
|
||||
|
||||
companion object {
|
||||
const val TAG = M_TAXI + "TaxiCurrentTaskFragment"
|
||||
private var mTaxiFragment: TaxiFragment? = null
|
||||
@@ -159,6 +163,7 @@ class TaxiCurrentTaskFragment : BaseFragment(),
|
||||
if (taskAndOrderUiState.driveToNearestStationTask != null) {
|
||||
updateViewByDriveToNearestStationTask(taskAndOrderUiState.driveToNearestStationTask)
|
||||
} else {
|
||||
prepareTaskCountdownTv.visibility = View.GONE
|
||||
initContainerView(false)
|
||||
removeAllMapMarker()
|
||||
}
|
||||
@@ -183,11 +188,45 @@ class TaxiCurrentTaskFragment : BaseFragment(),
|
||||
taskAndOrderUiState.duration
|
||||
)
|
||||
}
|
||||
|
||||
is TaskWithOrderUIState.UpdatePrepareTaskDelay120S -> {
|
||||
if (taskAndOrderUiState.isStart){
|
||||
updatePrepareTaskDelay120SUI()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新120s倒计时
|
||||
*/
|
||||
private fun updatePrepareTaskDelay120SUI() {
|
||||
prepareTaskCountdownTv.visibility = View.VISIBLE
|
||||
prepareTasCountDownTimer = object : CountDownTimer(TIMER_PREPARE_TASK_INTERVAL_120S, 1000L) {// 5倒计时后开启自驾
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
// 倒计时
|
||||
UiThreadHandler.post {
|
||||
prepareTaskCountdownTv.text =
|
||||
"距离任务获取还有 ${DateTimeUtil.second2MMSS(millisUntilFinished/1000)}"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
//倒计时结束了...
|
||||
UiThreadHandler.post {
|
||||
prepareTaskCountdownTv.visibility = View.GONE
|
||||
}
|
||||
prepareTasCountDownTimer?.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
prepareTasCountDownTimer?.start()
|
||||
}
|
||||
|
||||
private fun updateViewByDriveToNearestStationTask(driveToNearestStationTask: StartServiceRespBean.Result?) {
|
||||
if (driveToNearestStationTask == null) return
|
||||
initContainerView(true)
|
||||
@@ -306,6 +345,8 @@ class TaxiCurrentTaskFragment : BaseFragment(),
|
||||
TaskTypeEnum.None.code -> {
|
||||
if (order != null && currentStatus == TaskStatusEnum.CompleteTask.code) {
|
||||
handleOrderView(order)
|
||||
updateOrderUI(order)
|
||||
VoiceNotice.showNotice("已为您接到订单")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,17 +363,7 @@ class TaxiCurrentTaskFragment : BaseFragment(),
|
||||
if (currentStatus >= TaskStatusEnum.StartTask.code) View.VISIBLE else View.GONE
|
||||
taskOtherInfo.visibility =
|
||||
if (currentStatus == TaskStatusEnum.GetTask.code) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
TaskTypeEnum.ToOrderEndTask.code, TaskTypeEnum.ToOrderStartTask.code -> {// 接驾任务 或 送驾任务
|
||||
order.also {
|
||||
handleOrderView(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
when (taskType) {
|
||||
TaskTypeEnum.VirtualTask.code -> {// 演练任务
|
||||
if (order != null && currentStatus == TaskStatusEnum.CompleteTask.code) {
|
||||
updateOrderUI(order)
|
||||
VoiceNotice.showNotice("已为您接到订单")
|
||||
@@ -349,18 +380,14 @@ class TaxiCurrentTaskFragment : BaseFragment(),
|
||||
updateStartAndEndStationPointByStatus(true)
|
||||
}
|
||||
|
||||
TaskTypeEnum.ToOrderEndTask.code, TaskTypeEnum.ToOrderStartTask.code -> {// 送驾/接驾任务任务
|
||||
if (order == null) return
|
||||
updateOrderUI(order)
|
||||
}
|
||||
|
||||
TaskTypeEnum.None.code -> {
|
||||
if (order != null && currentStatus == TaskStatusEnum.CompleteTask.code) {
|
||||
updateOrderUI(order)
|
||||
VoiceNotice.showNotice("已为您接到订单")
|
||||
TaskTypeEnum.ToOrderEndTask.code, TaskTypeEnum.ToOrderStartTask.code -> {// 接驾任务 或 送驾任务
|
||||
order?.also {
|
||||
handleOrderView(it)
|
||||
updateOrderUI(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateMapMarkers(taskAndOrder)
|
||||
updateRemainDistanceAndTime(false)
|
||||
}
|
||||
@@ -558,6 +585,8 @@ class TaxiCurrentTaskFragment : BaseFragment(),
|
||||
|
||||
override fun onDestroyView() {
|
||||
AmapNaviToDestinationModel.getInstance(context).destroyAmaNavi()
|
||||
prepareTasCountDownTimer?.cancel()
|
||||
prepareTasCountDownTimer = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
@@ -724,7 +753,7 @@ class TaxiCurrentTaskFragment : BaseFragment(),
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
mViewModel.startOrStopOrderLoop(false)
|
||||
mViewModel.startOrStopCurrentTaskWithOrderLoop(false)
|
||||
super.onDestroy()
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,7 @@ import com.mogo.och.taxi.constant.TaskStatusEnum
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst
|
||||
import com.mogo.och.taxi.network.TaxiTaskWithOrderServiceManager
|
||||
import com.mogo.och.taxi.network.TaxiTaskWithOrderServiceManager.cancelOrder
|
||||
import com.mogo.och.taxi.ui.debug.DebugView
|
||||
import com.mogo.och.taxi.ui.unmanned.TaskWithOrderUIState
|
||||
import com.mogo.och.taxi.ui.unmanned.UnmannedState
|
||||
import com.mogo.och.taxi.utils.TaxiTrajectoryManager
|
||||
|
||||
/**
|
||||
@@ -176,6 +173,17 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, TaskUiIntent>(),
|
||||
}
|
||||
}
|
||||
|
||||
private fun updatePrepareTaskDelay120SUI(isStart: Boolean){
|
||||
d(TAG, "UpdatePrepareTaskDelay120SUI = $isStart")
|
||||
sendUiState {
|
||||
copy(
|
||||
taskWithOrderUIState = TaskWithOrderUIState.UpdatePrepareTaskDelay120S(
|
||||
isStart
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateDriveToNearestStationTaskUI(driveToNearestStationTask: StartServiceRespBean.Result?) {
|
||||
d(TAG, "updateDriveToNearestStationTaskUI = ${driveToNearestStationTask?.toString()}")
|
||||
sendUiState {
|
||||
@@ -247,6 +255,13 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, TaskUiIntent>(),
|
||||
}, TaxiUnmannedConst.START_AUTOPILOT_COUNTDOWN_INTERVAL) // 10s后开启自驾, 状态流转
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始倒计时120拉取任务
|
||||
*/
|
||||
override fun onStartPrepareTask120s() {
|
||||
updatePrepareTaskDelay120SUI(true)
|
||||
}
|
||||
|
||||
override fun onCarEndServiceSuccess(
|
||||
driveToNearestStationTask: StartServiceRespBean.Result?,
|
||||
currentTaskWithOrder: QueryCurrentTaskRespBean.Result?
|
||||
|
||||
@@ -72,6 +72,7 @@ import com.mogo.och.taxi.constant.TaxiOrderStatusEnum
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst.Companion.BUSINESSTYPE
|
||||
import com.mogo.och.taxi.network.TaxiTaskWithOrderServiceManager
|
||||
import com.mogo.och.taxi.ui.debug.DebugView
|
||||
import com.mogo.och.taxi.utils.RxJavaUtils
|
||||
import com.mogo.och.taxi.utils.TaxiAnalyticsManager
|
||||
import com.mogo.och.taxi.utils.TaxiTrajectoryManager
|
||||
@@ -326,6 +327,7 @@ object TaxiTaskModel {
|
||||
override fun onAutopilotSNRequest() {}
|
||||
override fun onAutopilotArriveAtStation(arrivalNotification: ArrivalNotification?) {
|
||||
i(TAG, "onAutopilotArriveAtStation = ${arrivalNotification.toString()}")
|
||||
DebugView.printInfoMsg("[MAP到站通知] 上报到站,location=${arrivalNotification?.endLocation}")
|
||||
if (arrivalNotification == null || !checkCurrentTaskCondition() ||
|
||||
mCurrentTaskWithOrder?.currentStatus == TaskStatusEnum.CompleteTask.code
|
||||
) {
|
||||
@@ -388,6 +390,7 @@ object TaxiTaskModel {
|
||||
d(
|
||||
TAG, "getWayPointsList.Size = ${globalPathResp.wayPointsList.size}"
|
||||
)
|
||||
DebugView.printInfoMsg("[MAP全局规划回调] 回调,getWayPointsList.Size=${globalPathResp.wayPointsList.size}")
|
||||
if (it.size > 0) {
|
||||
// 本地计算全路径长度(实时更新剩余距离,剩余时间,预计到达时间)
|
||||
if (checkCurrentTaskCondition()) {
|
||||
@@ -417,6 +420,7 @@ object TaxiTaskModel {
|
||||
startFailedCode: String,
|
||||
startFailedMessage: String
|
||||
) {
|
||||
DebugView.printInfoMsg("[启自驾回调] 执行失败,code=$startFailedCode, msg=$startFailedMessage")
|
||||
TaxiAnalyticsManager.getInstance()
|
||||
.triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage)
|
||||
if (mADASStatusCallback != null && !FunctionBuildConfig.isDemoMode) {
|
||||
@@ -524,6 +528,7 @@ object TaxiTaskModel {
|
||||
"judgeDriveToNearestStationTaskStation() ${virtualTask.siteName} distance = $distance"
|
||||
)
|
||||
if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE) { // 15米内到站
|
||||
DebugView.printInfoMsg("[高德定位围栏] 触发围栏,任务类型:DriveToNearestStationTask,围栏范围:${TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE}米")
|
||||
submitArriveSite(virtualTask.siteId, true, isArrivedNearestStation = true)
|
||||
}
|
||||
}
|
||||
@@ -563,6 +568,7 @@ object TaxiTaskModel {
|
||||
*/
|
||||
fun submitArriveSite(siteId: Long, isArriveAtEndSite: Boolean,
|
||||
isArrivedNearestStation : Boolean = false) {
|
||||
DebugView.printInfoMsg("[上报ArriveSite] siteId=$siteId, isArriveAtEndSite=$isArriveAtEndSite")
|
||||
i(TAG, message = "submitArriveSite: siteId=$siteId isArriveAtEndSite=$isArriveAtEndSite")
|
||||
TaxiTaskWithOrderServiceManager.arriveSite(
|
||||
mContext,
|
||||
@@ -570,6 +576,7 @@ object TaxiTaskModel {
|
||||
object : OchCommonServiceCallback<BaseData> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
if (data == null || data.code != 0) return
|
||||
DebugView.printInfoMsg("[上报ArriveSite] success siteId=$siteId, isArriveAtEndSite=$isArriveAtEndSite")
|
||||
d(TAG, "submitArriveSite-onSuccess data=" + GsonUtil.jsonFromObject(data))
|
||||
mDriveToNearestStationTask = null
|
||||
if (isArrivedNearestStation){// 播报提醒
|
||||
@@ -584,6 +591,7 @@ object TaxiTaskModel {
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
DebugView.printErrorMsg("[上报ArriveSite] failed, code=$code, msg=$msg")
|
||||
d(TAG, "code=$code msg=$msg")
|
||||
}
|
||||
})
|
||||
@@ -639,10 +647,11 @@ object TaxiTaskModel {
|
||||
AbsMogoApplication.getApp().applicationContext,
|
||||
object : OchCommonServiceCallback<QueryCurrentTaskRespBean> {
|
||||
override fun onSuccess(data: QueryCurrentTaskRespBean?) {
|
||||
//DebugView.printInfoMsg("[查询TaskWithOrder信息] success")
|
||||
if (data?.data == null) {
|
||||
d(
|
||||
TAG,
|
||||
"queryCurrentTaskOnce onSuccess: data.code != 0 || data === null || data.data === null"
|
||||
"queryCurrentTaskOnce onSuccess: data == null || data.data == null"
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -696,7 +705,8 @@ object TaxiTaskModel {
|
||||
// 主要是解决A-B演练任务同时接到A-B订单状态流转的问题
|
||||
//注意: 需要去除到达乘客上车点的节点, 这个节点不拉取任务
|
||||
if (result?.currentStatus == TaskStatusEnum.CompleteTask.code
|
||||
&& !QueryCurrentTaskRespBean.isOrderArriveAtStart(result)) {
|
||||
&& !QueryCurrentTaskRespBean.isOrderArriveAtStart(result)
|
||||
) {
|
||||
mTaxiTaskWithOrderCallbackMap.forEach {
|
||||
val listener = it.value
|
||||
listener.onTaskCompleted(
|
||||
@@ -754,6 +764,7 @@ object TaxiTaskModel {
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
d(TAG, "queryCurrentTaskOnce onFail: code=$code, msg=$msg")
|
||||
DebugView.printErrorMsg("[查询TaskWithOrder信息] fail, code=$code, msg=$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -761,15 +772,18 @@ object TaxiTaskModel {
|
||||
/**
|
||||
* 取消订单 进行中/待服务
|
||||
*/
|
||||
fun cancelOrder(orderNo: String,cancelType: Int){
|
||||
fun cancelOrder(orderNo: String, cancelType: Int) {
|
||||
DebugView.printInfoMsg("[取消订单] 准备发送请求")
|
||||
TaxiTaskWithOrderServiceManager.cancelOrder(AbsMogoApplication.getApp().applicationContext,
|
||||
orderNo, cancelType,
|
||||
object : OchCommonServiceCallback<BaseData> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
DebugView.printInfoMsg("[取消订单] 请求success")
|
||||
d(TAG, "handleCancelOrder() = onSuccess")
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
DebugView.printErrorMsg("[取消订单] 请求fail, code=$code, msg=$msg")
|
||||
d(TAG, "handleCancelOrder() $code $msg")
|
||||
}
|
||||
})
|
||||
@@ -842,22 +856,26 @@ object TaxiTaskModel {
|
||||
}
|
||||
|
||||
fun startTask(lineId: Long) {
|
||||
DebugView.printInfoMsg("[开始任务] 准备发送请求")
|
||||
TaxiTaskWithOrderServiceManager.startTask(
|
||||
mContext,
|
||||
lineId,
|
||||
object : OchCommonServiceCallback<BaseData> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
DebugView.printInfoMsg("[开始任务] 请求success")
|
||||
startAutoPilot() //自驾开启
|
||||
d(TAG, "startTask onSuccess: data=${GsonUtil.jsonFromObject(data)}")
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
DebugView.printErrorMsg("[开始任务] 请求fail, code=$code, msg=$msg")
|
||||
d(TAG, "startTask onFail: code=$code, msg=$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun prepareNextTask(siteId: Long) {
|
||||
DebugView.printInfoMsg("[PrepareNextTask] 准备发送请求")
|
||||
TaxiTaskWithOrderServiceManager.prepareTask(
|
||||
mContext,
|
||||
siteId,
|
||||
@@ -868,6 +886,7 @@ object TaxiTaskModel {
|
||||
"prepareNextTask onSuccess:${GsonUtil.jsonFromObject(data)}, " +
|
||||
"isCarServingStatus = ${TaxiCarServingStatusManager.isCarServingStatus()}"
|
||||
)
|
||||
DebugView.printInfoMsg("[PrepareNextTask] 请求success")
|
||||
if (data?.data == null) return
|
||||
//去下载轨迹, 下发给工控机下载
|
||||
// queryTaskTrajectoryByLineIds(
|
||||
@@ -877,6 +896,7 @@ object TaxiTaskModel {
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
DebugView.printErrorMsg("[PrepareNextTask] 请求fail, code=$code ,msg=$msg")
|
||||
d(TAG, "prepareNextTask onFail: code=$code ,msg=$msg")
|
||||
if (LoginStatusManager.isLogin() && TaxiCarServingStatusManager.isCarServingStatus()) {
|
||||
startPrepareTaskDelay120S(siteId)
|
||||
@@ -886,6 +906,13 @@ object TaxiTaskModel {
|
||||
}
|
||||
|
||||
fun startPrepareTaskDelay120S(siteId: Long) {
|
||||
DebugView.printInfoMsg("[PrepareNextTask] 倒计时${TaxiUnmannedConst.TIMER_PREPARE_TASK_INTERVAL_120S/1000}秒后prepareNextTask")
|
||||
|
||||
mTaxiTaskWithOrderCallbackMap.forEach {
|
||||
val listener = it.value
|
||||
listener.onStartPrepareTask120s()
|
||||
}
|
||||
|
||||
UiThreadHandler.postDelayed({
|
||||
prepareNextTask(siteId)
|
||||
}, TaxiUnmannedConst.TIMER_PREPARE_TASK_INTERVAL_120S)
|
||||
@@ -895,6 +922,7 @@ object TaxiTaskModel {
|
||||
* 查询当前任务的轨迹
|
||||
*/
|
||||
fun queryTaskTrajectoryByLineIds(planningLineIds: Array<Long>, currentTaskLineId: Long) {
|
||||
DebugView.printInfoMsg("[查询轨迹信息] 准备发送请求")
|
||||
TaxiTaskWithOrderServiceManager.queryTrajectoryByLindIds(
|
||||
mContext,
|
||||
planningLineIds,
|
||||
@@ -904,6 +932,7 @@ object TaxiTaskModel {
|
||||
TAG,
|
||||
"queryTaskTrajectoryByLineIds onSuccess: ${GsonUtil.jsonFromObject(data?.data)}"
|
||||
)
|
||||
DebugView.printInfoMsg("[查询轨迹信息] 请求success")
|
||||
data?.data?.also {
|
||||
mTaskTrajectoryList.addAll(it)
|
||||
mCurrentTaskTrajectory = it.first { currentTaskLineId == it.lineId }
|
||||
@@ -915,6 +944,7 @@ object TaxiTaskModel {
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
DebugView.printErrorMsg("[查询轨迹信息] 请求fail, code=$code, msg=$msg")
|
||||
d(TAG, "queryTaskTrajectoryByLineIds onFail: code=$code, msg=$msg")
|
||||
}
|
||||
})
|
||||
@@ -926,10 +956,12 @@ object TaxiTaskModel {
|
||||
return
|
||||
}
|
||||
if (TaxiCarServingStatusManager.isCarServingStatus()) {//接单状态下,去结束
|
||||
DebugView.printInfoMsg("[暂停接单] 准备发送请求")
|
||||
TaxiTaskWithOrderServiceManager.endService(
|
||||
mContext,
|
||||
object : OchCommonServiceCallback<BaseData> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
DebugView.printInfoMsg("[暂停接单] 请求success")
|
||||
loginService?.queryLoginStatusByNet()
|
||||
//需要将虚拟任务停掉, 虚拟任务会再开始接单后获取新的
|
||||
mDriveToNearestStationTask = null
|
||||
@@ -941,20 +973,24 @@ object TaxiTaskModel {
|
||||
|
||||
override fun onError() {
|
||||
mTaxiCarServiceCallback?.onCarEndServiceError()
|
||||
DebugView.printErrorMsg("[暂停接单] 请求error")
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
DebugView.printErrorMsg("[暂停接单] 请求fail, code=$code, msg=$msg")
|
||||
mTaxiCarServiceCallback?.onCarEndServiceFailed(code, msg)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
//暂停接单状态下,去接单
|
||||
DebugView.printInfoMsg("[开始接单] 准备发送请求")
|
||||
TaxiTaskWithOrderServiceManager.startService(mContext,
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().latitude,
|
||||
CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().longitude,
|
||||
object : OchCommonServiceCallback<StartServiceRespBean> {
|
||||
override fun onSuccess(data: StartServiceRespBean?) {
|
||||
if (data == null) return
|
||||
DebugView.printInfoMsg("[开始接单] 请求success")
|
||||
d(TAG, "data.data=" + GsonUtil.jsonFromObject(data.data))
|
||||
loginService?.queryLoginStatusByNet()
|
||||
mDriveToNearestStationTask = data.data
|
||||
@@ -965,10 +1001,12 @@ object TaxiTaskModel {
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String) {
|
||||
DebugView.printErrorMsg("[开始接单] 请求fail, code=$code, msg=$msg")
|
||||
mTaxiCarServiceCallback?.onCarStartServiceFailed(code, msg)
|
||||
}
|
||||
|
||||
override fun onError() {
|
||||
DebugView.printErrorMsg("[开始接单] 请求error")
|
||||
mTaxiCarServiceCallback?.onCarStartServiceError()
|
||||
}
|
||||
})
|
||||
@@ -987,12 +1025,14 @@ object TaxiTaskModel {
|
||||
fun startAutoPilot() {
|
||||
if (!checkCurrentTaskCondition()) {
|
||||
e(TAG, "no order or order is empty.")
|
||||
DebugView.printErrorMsg("[启自驾] 当前订单不存在或异常!")
|
||||
ToastUtils.showShort("当前订单不存在或异常!")
|
||||
return
|
||||
}
|
||||
|
||||
if (mCurrentTaskTrajectory == null) {
|
||||
e(TAG, "no order or order is empty.")
|
||||
DebugView.printErrorMsg("[启自驾] 轨迹信息不存在!")
|
||||
ToastUtils.showShort("轨迹信息不存在!")
|
||||
}
|
||||
|
||||
@@ -1003,6 +1043,7 @@ object TaxiTaskModel {
|
||||
&& TextUtils.isEmpty(mCurrentTaskTrajectory!!.csvFileUrlDPQP)
|
||||
) {
|
||||
ToastUtils.showLong("无发布轨迹, 请发布后重试")
|
||||
DebugView.printErrorMsg("[启自驾] 无发布轨迹, 请发布后重试")
|
||||
e(
|
||||
TAG, "isPassStartAutopilotCommand = " +
|
||||
FunctionBuildConfig.isPassStartAutopilotCommand
|
||||
@@ -1020,6 +1061,7 @@ object TaxiTaskModel {
|
||||
OCHAdasAbilityManager.getInstance().autopilotUnAbilityReason +
|
||||
", 请稍候重试"
|
||||
)
|
||||
DebugView.printErrorMsg("[启自驾] ${OCHAdasAbilityManager.getInstance().autopilotUnAbilityReason}")
|
||||
TaxiAnalyticsManager.getInstance().triggerUnableStartAPReasonEvent(
|
||||
mCurrentTaskWithOrder!!.startSite!!.siteName,
|
||||
mCurrentTaskWithOrder!!.endSite!!.siteName,
|
||||
@@ -1038,6 +1080,7 @@ object TaxiTaskModel {
|
||||
return
|
||||
}
|
||||
CallerAutoPilotControlManager.startAutoPilot(parameters)
|
||||
DebugView.printInfoMsg("[启自驾] 调用成功")
|
||||
d(
|
||||
TAG, "start autopilot with parameter: %s",
|
||||
GsonUtil.jsonFromObject(parameters)
|
||||
@@ -1105,6 +1148,7 @@ object TaxiTaskModel {
|
||||
fun cancelAutopilot() {
|
||||
try {
|
||||
CallerAutoPilotControlManager.cancelAutoPilot()
|
||||
DebugView.printInfoMsg("[取消自驾] 调用成功")
|
||||
d(TAG, "结束自动驾驶")
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@@ -1147,11 +1191,25 @@ object TaxiTaskModel {
|
||||
//3、刚过站且过站距离在15m内, 提交到站
|
||||
if (stationAngle > 90) {
|
||||
i(TAG, "judgeEndStation() = 刚过站且在15m内")
|
||||
DebugView.printInfoMsg(
|
||||
"[高德定位围栏] 触发围栏,任务类型:${
|
||||
TaskTypeEnum.valueOf(
|
||||
mCurrentTaskWithOrder?.taskType ?: 0
|
||||
)?.name
|
||||
},围栏范围:${TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE}米 刚过站且在15m内"
|
||||
)
|
||||
submitArriveSite(endSite.siteId, true)
|
||||
}else{
|
||||
} else {
|
||||
// 4、 没有过站距离小于15m 速度小于0.5(根据M1来的模数 可能要调)
|
||||
if (currentLocation.gnssSpeed < 0.5) {
|
||||
i(TAG, "judgeEndStation() = 没有过站、速度基本为零且在15m内")
|
||||
DebugView.printInfoMsg(
|
||||
"[高德定位围栏] 触发围栏,任务类型:${
|
||||
TaskTypeEnum.valueOf(
|
||||
mCurrentTaskWithOrder?.taskType ?: 0
|
||||
)?.name
|
||||
},围栏范围:${TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE}米 没有过站、速度基本为零且在15m内"
|
||||
)
|
||||
submitArriveSite(endSite.siteId, true)
|
||||
}
|
||||
}
|
||||
@@ -1215,6 +1273,7 @@ object TaxiTaskModel {
|
||||
)
|
||||
mCurrentTaskWithOrder = null
|
||||
mDriveToNearestStationTask = null
|
||||
DebugView.printInfoMsg("[登出] 退出登陆")
|
||||
}
|
||||
|
||||
//导航去订单终点目的地
|
||||
@@ -1288,11 +1347,13 @@ object TaxiTaskModel {
|
||||
return
|
||||
}
|
||||
d(TAG, "AutopilotControlParameters is update.")
|
||||
DebugView.printInfoMsg("[启自驾] updateAutopilotControlParameters调用成功")
|
||||
updateAutopilotControlParameters(parameters)
|
||||
}
|
||||
|
||||
private fun clearAutopilotControlParameters() {
|
||||
d(TAG, "AutopilotControlParameters is clear.")
|
||||
DebugView.printInfoMsg("[启自驾] clearAutopilotControlParameters调用成功")
|
||||
updateAutopilotControlParameters(null)
|
||||
}
|
||||
|
||||
@@ -1309,7 +1370,6 @@ object TaxiTaskModel {
|
||||
ToastUtils.showShort("无任务!")
|
||||
return
|
||||
}
|
||||
// arriveSite(mCurrentTaskAndOrder?.endSite!!.siteId, true)
|
||||
autopilotArriveAtStation()
|
||||
}
|
||||
|
||||
|
||||
@@ -25,4 +25,16 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/no_order_data_iv"
|
||||
android:text="暂无服务订单"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/prepareTaskCountdownTv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="#91A1EA"
|
||||
android:textSize="@dimen/dp_30"
|
||||
android:layout_marginTop="50dp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@+id/noOrderDataTv" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user