Merge branch 'dev_robotaxi-d_231016_6.2.0_local' into dev_robotaxi-d_231024_6.1.2

This commit is contained in:
wangmingjun
2023-10-24 17:23:34 +08:00
9 changed files with 241 additions and 152 deletions

View File

@@ -1,8 +1,6 @@
package com.mogo.och.common.module.wigets;
import android.annotation.SuppressLint
import android.content.Context
import android.os.CountDownTimer
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
@@ -28,7 +26,7 @@ class StartAutopilotAnimationView @JvmOverloads constructor(
) : RelativeLayout(context, attrs, defStyleAttr){
companion object {
private const val ALL_CLOSE_TIMER = 10000L
private const val ALL_CLOSE_TIMER = 5000L
private const val TAG = "StartAutopilotAnimationView"
}
@@ -188,12 +186,12 @@ class StartAutopilotAnimationView @JvmOverloads constructor(
startAutopilotTip.visibility = VISIBLE
startTimer = object : CountDownTimerExt(ALL_CLOSE_TIMER, 1000L) {// 5倒计时后开启自驾
startTimer = object : CountDownTimerExt(ALL_CLOSE_TIMER, 1000L) {// 5s倒计时后开启自驾
override fun onTimerTick(value: Long) {
// 倒计时
UiThreadHandler.post {
startAutopilotTip.text = "${(value/1000).toInt()} 车辆即将自动开启自动驾驶"
startAutopilotTip.text = "${Math.ceil(value.toDouble()/1000).toInt()} 车辆即将自动开启自动驾驶"
}
playDI()
}
@@ -201,8 +199,8 @@ class StartAutopilotAnimationView @JvmOverloads constructor(
override fun onTimerFinish() {
//倒计时结束了...
UiThreadHandler.post {
SoundPoolHelper.getSoundPoolHelper().releaseSoundPool()
startAutopilotTip.text = "车辆正在自动开启自动驾驶"
dismiss(DirectionEnum.ALERT_WARNING_TOP)
}
}

View File

@@ -131,6 +131,15 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
return data.order!!.orderStatus == TaxiOrderStatusEnum.ArriveAtEnd.code
}
fun isOrderOnTheWayToStart(data: Result?): Boolean {
if (data == null) {
return false
}
if (data.order == null) {
return false
}
return data.order!!.orderStatus == TaxiOrderStatusEnum.OnTheWayToStart.code
}
/**
* with order.orderStatus == ArriveAtStart
*/
@@ -144,7 +153,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
return data.order!!.orderStatus == TaxiOrderStatusEnum.ArriveAtStart.code
}
fun isUserArriveAtStart(data: Result?): Boolean {
fun isOrderUserArriveAtStart(data: Result?): Boolean {
if (data == null) {
return false
}
@@ -157,7 +166,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
/**
* with task.currentStatus == StartTask
*/
fun isStartTaskType(data: Result?): Boolean {
fun isTaskStartTaskType(data: Result?): Boolean {
if (data == null) {
return false
}
@@ -167,7 +176,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
/**
* with task.currentStatus == CompleteTask
*/
fun isCompleteTaskType(data: Result?): Boolean {
fun isTaskCompleteTaskType(data: Result?): Boolean {
if (data == null) {
return false
}
@@ -177,7 +186,7 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
/**
* with task.currentStatus == GetTask
*/
fun isGetTaskType(data: Result?): Boolean {
fun isTaskGetTaskType(data: Result?): Boolean {
if (data == null) {
return false
}

View File

@@ -5,7 +5,8 @@ import com.mogo.och.taxi.bean.TrajectoryListRespBean
interface ITaxiTaskWithOrderCallback {
fun onTaskWithOrderDataChanged(taskWithOrder: QueryCurrentTaskRespBean.Result?)
fun onTaskCompleted(result: QueryCurrentTaskRespBean.Result)
fun onTaskCompleted(result: QueryCurrentTaskRespBean.Result?)
fun onTaskStarted(result: QueryCurrentTaskRespBean.Result?)
fun onTaskTrajectoryDataChanged(data: TrajectoryListRespBean?)
fun onOrderCancel()
fun onOrderArriveAtEnd(orderNo: String)

View File

@@ -80,11 +80,15 @@ class TaxiUnmannedConst {
const val TIMER_START_AUTOPILOT_INTERVAL = 20 * 1000L
const val TIMER_PREPARE_TASK_INTERVAL_120S = 120 * 1000L //120s再次获取任务
const val TIMER_PREPARE_VIRTUAL_TASK_INTERVAL = 45 * 1000L //45s再次获取任务
const val START_AUTOPILOT_COUNTDOWN_INTERVAL = 10 * 1000L // 自动启动自驾倒数计时
const val START_PREPARE_TO_START_TASK_INTERVAL = 0L // 直接拉取接驾任务
const val START_AUTOPILOT_ANIMATION_INTERVAL = 12 * 1000L // 12s 开启自驾闪烁动画
const val START_PREPARE_TASK_RETRY_INTERVAL = 10 * 1000L // 直接拉取接驾任务
const val START_AUTOPILOT_COUNTDOWN_INTERVAL = 5 * 1000L // 自动启动自驾倒数计时
const val START_AUTOPILOT_ANIMATION_INTERVAL = 7 * 1000L // 开启自驾闪烁动画
}
}

View File

@@ -57,7 +57,7 @@ class TaxiFragment : BaseTaxiTabFragment<TaxiFragment, TaxiPresenter>(),
fun changeOverview(eventLogout: EventLogout) {
if (eventLogout.messgae == EventLogout.LOGOUT_TYPE) {
d(SceneConstant.M_TAXI + TAG, "changeOverview Event消息去登出")
mPresenter.logout()
mPresenter?.logout()
}
}
@@ -107,12 +107,12 @@ class TaxiFragment : BaseTaxiTabFragment<TaxiFragment, TaxiPresenter>(),
// 在自动驾驶中,或者自己确认车辆环境可开启自动驾驶 则可点击
if (!isStarting) {
d(SceneConstant.M_TAXI + TAG, "startAutopilot")
mPresenter.startAutoPilot()
mPresenter?.startAutoPilot()
}
}
override fun pauseStartAutopilot() {
mPresenter.pauseStartAutopilot()
mPresenter?.pauseStartAutopilot()
}
override fun resumeStartAutopilot(remainingTime: Long) {
@@ -120,7 +120,7 @@ class TaxiFragment : BaseTaxiTabFragment<TaxiFragment, TaxiPresenter>(),
}
override fun startNaviToEndStation(isShow: Boolean) {
mPresenter.startNaviToEndStation(isShow)
mPresenter?.startNaviToEndStation(isShow)
}
override fun initViews() {
@@ -134,7 +134,7 @@ class TaxiFragment : BaseTaxiTabFragment<TaxiFragment, TaxiPresenter>(),
}
override fun stopAutoStartAutopilot() {
mPresenter.stopAutoStartAutopilot()
mPresenter?.stopAutoStartAutopilot()
}
private fun initFlowEvent() {
@@ -275,7 +275,7 @@ class TaxiFragment : BaseTaxiTabFragment<TaxiFragment, TaxiPresenter>(),
findViewById<View>(R.id.test_bar_on_the_way_to_end)?.setOnClickListener {
if (!isStarting) {
mPresenter.startAutoPilot()
mPresenter?.startAutoPilot()
}
TaxiTaskModel.mockOnTheWayToEndStation()
}

View File

@@ -199,7 +199,10 @@ public class DebugView @JvmOverloads constructor(
initViewByData(taskWithOrder)
}
override fun onTaskCompleted(result: QueryCurrentTaskRespBean.Result) {
override fun onTaskCompleted(result: QueryCurrentTaskRespBean.Result?) {
}
override fun onTaskStarted(result: QueryCurrentTaskRespBean.Result?) {
}
override fun onTaskTrajectoryDataChanged(data: TrajectoryListRespBean?) {

View File

@@ -217,9 +217,14 @@ class TaxiCurrentTaskFragment : BaseFragment(),
return
}
if (mPrepareTasCountDownTimer != null){
mPrepareTasCountDownTimer?.cancel()
mPrepareTasCountDownTimer = null
}
prepareTaskCountdownTv.visibility = View.VISIBLE
mPrepareTasCountDownTimer =
object : CountDownTimer(millisInFuture, 1000L) {// 5倒计时后开启自驾
object : CountDownTimer(millisInFuture, 1000L) {// 倒计时后开启自驾
override fun onTick(millisUntilFinished: Long) {
// 倒计时

View File

@@ -2,17 +2,22 @@ package com.mogo.och.taxi.ui.task
import com.mogo.commons.AbsMogoApplication
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.autopilot.CallerChassisLocationGCJ02ListenerManager
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.mogo.logger.scene.SceneConstant
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.network.OchCommonServiceCallback
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager
import com.mogo.och.common.module.utils.ToastUtilsOch
import com.mogo.och.common.module.voice.VoiceNotice
import com.mogo.och.common.module.wigets.StartAutopilotAnimationView
import com.mogo.och.taxi.R
import com.mogo.och.taxi.base.BaseViewModel
import com.mogo.och.taxi.base.IUiIntent
@@ -98,19 +103,19 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, TaskUiIntent>(),
}
private fun jumpPassengerCheck() {
DebugView.printInfoMsg("[开始服务] 准备发送请求")
DebugView.printInfoMsg("[跳过乘客验证] 准备发送请求")
val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder()
currentTaskWithOrder?.order?.also {
TaxiTaskWithOrderServiceManager.jumpPassengerCheck(AbsMogoApplication.getApp().applicationContext,
it.orderNo,
object : OchCommonServiceCallback<BaseData> {
override fun onSuccess(data: BaseData?) {
DebugView.printInfoMsg("[开始服务] 请求success")
DebugView.printInfoMsg("[跳过乘客验证] 请求success")
d(TAG, "jumpPassengerCheck onSuccess:")
}
override fun onFail(code: Int, msg: String?) {
DebugView.printInfoMsg("[开始服务] 请求fail, code=$code, msg=$msg")
DebugView.printInfoMsg("[跳过乘客验证] 请求fail, code=$code, msg=$msg")
d(TAG, "jumpPassengerCheck onFail: code=$code, msg=$msg")
}
})
@@ -225,15 +230,48 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, TaskUiIntent>(),
updateTaskAndOrderUi(result)
}
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) {
override fun onTaskCompleted(result: QueryCurrentTaskRespBean.Result?) {
d(TAG, "onTaskCompleted: ${result?.currentStatus}, siteId=${result?.endSite?.siteId}")
if (result.order != null && result.servingStatus == 1){
if (result?.order != null && result.servingStatus == 1){
if (result.taskType <= TaskTypeEnum.VirtualTask.code
&& result.order!!.orderStatus < TaxiOrderStatusEnum.ArriveAtStart.code) {
VoiceNotice.showNotice("已为您接到订单")
@@ -243,17 +281,35 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, TaskUiIntent>(),
}
}
if (QueryCurrentTaskRespBean.isUserArriveAtStart(result)) {
TaxiTaskModel.removePrepareTaskDelay()
TaxiTaskModel.prepareNextTask(0,result.endSite!!.siteId)
}else if (!QueryCurrentTaskRespBean.isOrderArriveAtStart(result)
|| !QueryCurrentTaskRespBean.isOrderArriveAtEnd(result)){
TaxiTaskModel.startPrepareTaskDelay(
if (TaskTypeEnum.isToOrderStartTask(result))
TaxiUnmannedConst.START_AUTOPILOT_COUNTDOWN_INTERVAL
else TaxiUnmannedConst.TIMER_PREPARE_TASK_INTERVAL_120S,
result.endSite!!.siteId)
/**
* 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{
if (result?.taskType == TaskTypeEnum.None.code){
TaxiTaskModel.startPrepareTaskDelay(
TaxiUnmannedConst.TIMER_PREPARE_VIRTUAL_TASK_INTERVAL, result?.endSite!!.siteId)
}else{
TaxiTaskModel.startPrepareTaskDelay(
TaxiUnmannedConst.TIMER_PREPARE_VIRTUAL_TASK_INTERVAL, result?.endSite!!.siteId)
}
}
clearDemoModeAndACParameters()
}
override fun onTaskTrajectoryDataChanged(data: TrajectoryListRespBean?) {
@@ -283,13 +339,13 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, TaskUiIntent>(),
//获取新的任务
val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder()
currentTaskWithOrder?.endSite?.also {
TaxiTaskModel.startPrepareTaskDelay(TaxiUnmannedConst.TIMER_PREPARE_TASK_INTERVAL_120S,
TaxiTaskModel.startPrepareTaskDelay(TaxiUnmannedConst.TIMER_PREPARE_VIRTUAL_TASK_INTERVAL,
it.siteId)
}
}
override fun onStartAutopilot(postDelayTime: Long) {
UiThreadHandler.postDelayed(startTaskRunnable, postDelayTime) // 10s后或者倒计时继续开启自驾, 状态流转
UiThreadHandler.postDelayed(startTaskRunnable, postDelayTime) // 5s后或者倒计时结束开启自驾, 状态流转
}
private val startTaskRunnable: Runnable = Runnable {
@@ -382,4 +438,26 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, TaskUiIntent>(),
ToastUtils.showShort(context.getString(R.string.request_error_tip))
}
}
private fun clearDemoModeAndACParameters(){
if (FunctionBuildConfig.isDemoMode) {
d(TAG, "setIPCDemoModefalse")
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)
}
}

View File

@@ -120,6 +120,8 @@ object TaxiTaskModel {
private var mIsArrivedSiteStartTag = false //到站接口请求标志位,防止围栏触发多次调用到站接口, true 接口请求, false : 接口请求完成
private var isPrepareingNextTask = false // 拉取任务接口标志位
fun addTaskWithOrderListener(tag: String, listener: ITaxiTaskWithOrderCallback) {
if (mTaxiTaskWithOrderCallbackMap.containsKey(tag)) {
return
@@ -259,7 +261,7 @@ object TaxiTaskModel {
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
DebugView.printInfoMsg("[自驾状态变化] afterValue=STATUS_AUTOPILOT_RUNNINGmeaning=自动驾驶中")
mADASStatusCallback?.onAutopilotRunning()
if ((QueryCurrentTaskRespBean.isStartTaskType(mCurrentTaskWithOrder))) {
if ((QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder))) {
TaxiAnalyticsManager.getInstance().triggerStartAutopilotEvent(
isRestartAutopilot,
true,
@@ -268,22 +270,13 @@ object TaxiTaskModel {
mCurrentTaskWithOrder!!.lineId,
mCurrentTaskWithOrder!!.order!!.orderNo
)
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后置true
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true
CallerAutoPilotControlManager.setIgnoreConditionDraw(true)
CallerAutoPilotControlManager.setIPCDemoMode(true)
d(
TAG,
"美化模式-ignore置为true到达出发点且已开启自动驾驶"
)
}
setBeautificationMode(true)
}
} else if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE) {
DebugView.printInfoMsg("[自驾状态变化] afterValue=STATUS_AUTOPILOT_ENABLEmeaning=可自动驾驶,人工干预状态")
if ((FunctionBuildConfig.isDemoMode
&& checkCurrentTaskCondition()
&& QueryCurrentTaskRespBean.isStartTaskType(mCurrentTaskWithOrder)
&& QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder)
)
) {
// 当美化模式演示模式开启时且有订单、且为去往目的地状态维持自动驾驶icon开启状态
@@ -294,7 +287,7 @@ object TaxiTaskModel {
DebugView.printInfoMsg("[自驾状态变化] afterValue=STATUS_AUTOPILOT_DISABLEmeaning=不可自动驾驶")
if ((FunctionBuildConfig.isDemoMode
&& checkCurrentTaskCondition()
&& QueryCurrentTaskRespBean.isStartTaskType(mCurrentTaskWithOrder)
&& QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder)
)
) {
// 当美化模式演示模式开启时且有订单、且为去往目的地状态维持自动驾驶icon开启状态
@@ -305,7 +298,7 @@ object TaxiTaskModel {
DebugView.printInfoMsg("[自驾状态变化] afterValue=STATUS_PARALLEL_DRIVINGmeaning=平行驾驶中")
if (FunctionBuildConfig.isDemoMode) {
if ((checkCurrentTaskCondition()
&& QueryCurrentTaskRespBean.isStartTaskType(
&& QueryCurrentTaskRespBean.isTaskStartTaskType(
mCurrentTaskWithOrder
)
)
@@ -332,7 +325,34 @@ object TaxiTaskModel {
)
return
}
autopilotArriveAtStation()
//围栏已经到站, 拉取到下一个任务, 此时自驾的到站才传递过来, 导致直接上报了当前任务的终点站到站, 造成任务一开始立马到站的问题
//解决方案: 根据自驾到站的经纬度和当前任务终点站的坐标比对, 如果距离在15米内, 则任务到站正确, 否则不请求到站
if (!checkCurrentTaskCondition()) return
val endSiteLat: Double? = mCurrentTaskWithOrder?.endSite?.gcjLat
val endSiteLon: Double? = mCurrentTaskWithOrder?.endSite?.gcjLon
val mapEndSiteLatWgs: Double? = arrivalNotification?.endLocation?.latitude
val mapEndSiteLonWgs: Double? = arrivalNotification?.endLocation?.longitude
if (endSiteLon != null && endSiteLat != null && mapEndSiteLonWgs != null && mapEndSiteLatWgs != null){
var latLngs = CoordinateUtils.transformWgsToGcj(mapEndSiteLatWgs,mapEndSiteLonWgs)
val distance = CoordinateUtils.calculateLineDistance(
endSiteLon, endSiteLat,
latLngs[0], latLngs[1]
).toDouble()
if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE){// 两坐标小于15米
DebugView.printInfoMsg("[MAP到站通知] 到站坐标和任务终点15米内, 请求到站")
autopilotArriveAtStation()
}else{
DebugView.printInfoMsg("[MAP到站通知] 到站坐标和任务终点不一致, 不请求到站")
}
}else{
DebugView.printInfoMsg("[MAP到站通知] endSiteLat = $endSiteLat, endSiteLon = $endSiteLon, " +
"mapEndSiteLat = $mapEndSiteLatWgs, mapEndSiteLon = $mapEndSiteLonWgs")
}
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 到达目的地置false
// 2022.10.08 到达目的地时候取消自动起自驾, 服务完成取消引导线和自动驾驶按钮状态
@@ -366,7 +386,7 @@ object TaxiTaskModel {
}
if (checkCurrentTaskCondition()
&& QueryCurrentTaskRespBean.isStartTaskType(mCurrentTaskWithOrder)
&& QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder)
) {
judgeTaskEndSiteStation(mogoLocation)
}
@@ -557,8 +577,10 @@ object TaxiTaskModel {
isArrivedNearestStation: Boolean = false
) {
if (mIsArrivedSiteStartTag) {
DebugView.printInfoMsg("arriveSite接口正在调用中")
i(TAG, message = "arriveSite接口正在调用中 mIsArrivedSite = $mIsArrivedSiteStartTag")
DebugView.printInfoMsg("[上报ArriveSite] arriveSite接口正在调用中, 跳过本次请求" +
", siteId=$siteId, isArriveAtEndSite=$isArriveAtEndSite")
i(TAG, message = "arriveSite接口正在调用中, 跳过本次请求 mIsArrivedSite = $mIsArrivedSiteStartTag" +
", siteId=$siteId, isArriveAtEndSite=$isArriveAtEndSite")
return
}
mIsArrivedSiteStartTag = true
@@ -698,8 +720,6 @@ object TaxiTaskModel {
mCurrentTaskWithOrder = result
updateLocalCalculateStation()
// 任务为空
if (result?.endSite == null && result?.order == null) {
d(TAG, "queryCurrentTaskOnce: 任务为空")
@@ -710,15 +730,23 @@ object TaxiTaskModel {
}
}
clearCurrentOCHOrder()
clearLocalCalculateStation()
return
}
//开始任务处理
if (QueryCurrentTaskRespBean.isTaskStartTaskType(result)){
mTaxiTaskWithOrderCallbackMap.forEach {
val listener = it.value
listener.onTaskStarted(result)
}
}
//当前任务完成且订单状态到达乘客上车点, 则立马去拉取任务 不再等120s,否则送驾任务要等120s后才能去执行(8.29废)
//8.29更新: 当前任务完成且订单状态为乘客已上车, 则立马去拉取任务 不再等120s,否则送驾任务要等120s后才能去执行
// 主要是解决A-B演练任务同时接到A-B订单状态流转的问题
//注意: 需要去除到达乘客上车点的节点, 这个节点不拉取任务
if (result.currentStatus == TaskStatusEnum.CompleteTask.code
) {
if (QueryCurrentTaskRespBean.isTaskCompleteTaskType(result)) {
mIsArrivedSiteStartTag = false //任务完成说明到站, 更新到站标识位, 不再到站接口请求成功更新
mADASStatusCallback?.updateAutopilotStatus()
mTaxiTaskWithOrderCallbackMap.forEach {
@@ -746,8 +774,8 @@ object TaxiTaskModel {
}
queryTaskTrajectoryByLineIds(linesIds.toTypedArray(), result.lineId)
//自动去启动自驾
if (result.currentStatus == TaskStatusEnum.GetTask.code &&
//自动去启动自驾, 拿到任务并且任务类型是演练和接驾任务
if (QueryCurrentTaskRespBean.isTaskGetTaskType(result) &&
result.taskType <= TaskTypeEnum.ToOrderStartTask.code
) {
if (result.order == null || result.order!!.orderStatus < TaxiOrderStatusEnum.ArriveAtStart.code) {
@@ -767,7 +795,6 @@ object TaxiTaskModel {
listener.onTaskWithOrderDataChanged(mCurrentTaskWithOrder)
}
}
updateDemoModeAndAutopilotParameters(result)
}
}
@@ -798,29 +825,12 @@ object TaxiTaskModel {
})
}
fun updateLocalCalculateStation() {
if (mCurrentTaskWithOrder != null &&
mCurrentTaskWithOrder?.startSite != null && mCurrentTaskWithOrder?.endSite != null
&& mCurrentTaskWithOrder?.currentStatus == TaskStatusEnum.StartTask.code
) {
d(TAG, "updateLocalCalculateStation start")
val curTaskAndOrder = 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
setStationPoint(startStation, endStation, curTaskAndOrder.lineId)
}
} else {
d(TAG, "updateLocalCalculateStation stop")
if (mDriveToNearestStationTask == null){
AmapNaviToDestinationModel.getInstance(mContext).destroyAmaNavi()
}
setStationPoint(null, null, -1L)
fun clearLocalCalculateStation(){
d(TAG, "updateLocalCalculateStation stop")
if (mDriveToNearestStationTask == null){
AmapNaviToDestinationModel.getInstance(mContext).destroyAmaNavi()
}
setStationPoint(null, null, -1L)
}
fun queryOrderByOrderNo(orderNo: String) {
@@ -902,7 +912,14 @@ object TaxiTaskModel {
})
}
fun prepareNextTask(delayTime: Long, siteId: Long) {
private fun prepareNextTask(siteId: Long) {
if (isPrepareingNextTask){
DebugView.printInfoMsg("[PrepareNextTask] 请求调用中, 直接return")
d(TAG, "[PrepareNextTask] 请求调用中, 直接return")
return
}
isPrepareingNextTask = false
DebugView.printInfoMsg("[PrepareNextTask] 准备发送请求, siteId=$siteId")
TaxiTaskWithOrderServiceManager.prepareTask(
mContext,
@@ -915,13 +932,30 @@ object TaxiTaskModel {
"isCarServingStatus = ${TaxiCarServingStatusManager.isCarServingStatus()}"
)
DebugView.printInfoMsg("[PrepareNextTask] 请求success")
isPrepareingNextTask = false
}
override fun onFail(code: Int, msg: String?) {
DebugView.printErrorMsg("[PrepareNextTask] 请求fail, code=$code ,msg=$msg")
d(TAG, "prepareNextTask onFail: code=$code ,msg=$msg")
isPrepareingNextTask = false
if (LoginStatusManager.isLogin() && TaxiCarServingStatusManager.isCarServingStatus()) {
startPrepareTaskDelay(delayTime, siteId)
mCurrentTaskWithOrder?.endSite?.siteId?.also {
startPrepareTaskDelay(TaxiUnmannedConst.START_PREPARE_TASK_RETRY_INTERVAL,it)
}
}
}
override fun onError() {
super.onError()
DebugView.printErrorMsg("[PrepareNextTask] 请求onError, " +
"net = ${NetworkUtils.isConnected(mContext)}")
d(TAG, "prepareNextTask onError, , net = ${NetworkUtils.isConnected(mContext)}")
isPrepareingNextTask = false
if (LoginStatusManager.isLogin() && TaxiCarServingStatusManager.isCarServingStatus()) {
mCurrentTaskWithOrder?.endSite?.siteId?.also {
startPrepareTaskDelay(TaxiUnmannedConst.START_PREPARE_TASK_RETRY_INTERVAL,it)
}
}
}
})
@@ -931,7 +965,7 @@ object TaxiTaskModel {
removePrepareTaskDelay()
mPrepareTaskDelayRunnable = Runnable {
prepareNextTask(delayTime, siteId)
prepareNextTask(siteId)
}
mTaxiTaskWithOrderCallbackMap.forEach {
@@ -945,7 +979,7 @@ object TaxiTaskModel {
)
}
fun removePrepareTaskDelay() {
private fun removePrepareTaskDelay() {
if (mPrepareTaskDelayRunnable != null) {
DebugView.printInfoMsg("[PrepareNextTask] removeCallbacks, 取消prepareNextTask倒计时")
UiThreadHandler.removeCallbacks(mPrepareTaskDelayRunnable)
@@ -1088,9 +1122,9 @@ object TaxiTaskModel {
fun startAutopilotByClick() {
//订单状态流转成功, 点击了开启自驾按钮, 启动自驾
if (QueryCurrentTaskRespBean.isStartTaskType(mCurrentTaskWithOrder)) {
if (QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder)) {
startAutoPilot()
} else if (QueryCurrentTaskRespBean.isGetTaskType(mCurrentTaskWithOrder)) {
} else if (QueryCurrentTaskRespBean.isTaskGetTaskType(mCurrentTaskWithOrder)) {
startTask(mCurrentTaskWithOrder!!.lineId, true)
} else {
e(TAG, "task currentStatus is not StartTask.")
@@ -1178,7 +1212,7 @@ object TaxiTaskModel {
mControllerStatusCallback?.startOpenAutopilot()
}
private fun initAutopilotControlParameters(): AutopilotControlParameters? {
fun initAutopilotControlParameters(): AutopilotControlParameters? {
if (!checkCurrentTaskCondition()) {
e(TAG, "no order or order is empty.")
return null
@@ -1233,7 +1267,7 @@ object TaxiTaskModel {
}
private fun judgeTaskEndSiteStation(currentLocation: MogoLocation) {
if (!checkCurrentTaskCondition()) {
if (!checkCurrentTaskCondition() || !QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder)) {
return
}
val endSite = mCurrentTaskWithOrder!!.endSite ?: return
@@ -1260,7 +1294,7 @@ object TaxiTaskModel {
)
if (!checkCurrentTaskCondition()
|| getCurTaskStatus() != TaskStatusEnum.StartTask.code
|| !QueryCurrentTaskRespBean.isTaskStartTaskType(mCurrentTaskWithOrder)
) {
i(TAG, "task null or TaskStatus = ${getCurTaskStatus()}")
return
@@ -1326,12 +1360,19 @@ object TaxiTaskModel {
clearAutopilotControlParameters()
mIsArrivedSiteStartTag = false
isRestartAutopilot = false
setBeautificationMode(false)
}
/**
* 设置美化模式相关项开/关
*/
fun setBeautificationMode(isOpen: Boolean){
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 取消或订单已完成时置false
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false
CallerAutoPilotControlManager.setIgnoreConditionDraw(false)
CallerAutoPilotControlManager.setIPCDemoMode(false)
d(TAG, "美化模式-ignore置为false已完成or清除当前任务")
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = isOpen
CallerAutoPilotControlManager.setIgnoreConditionDraw(isOpen)
CallerAutoPilotControlManager.setIPCDemoMode(isOpen)
d(TAG, "美化模式-ignore置为$isOpen, true表示:到达出发点且已开启自动驾驶; false表示:已完成or清除当前任务")
}
}
@@ -1362,57 +1403,7 @@ object TaxiTaskModel {
}
}
}
//运营模式(美化模式), 鹰眼数据同步
private fun updateDemoModeAndAutopilotParameters(data: QueryCurrentTaskRespBean.Result?) {
if (data == null) {
return
}
val endSite = data.endSite
if (endSite != null) {
if (QueryCurrentTaskRespBean.isStartTaskType(data)) {
if (FunctionBuildConfig.isDemoMode) {
// 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后置true
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true
CallerAutoPilotControlManager.setIgnoreConditionDraw(true)
CallerAutoPilotControlManager.setIPCDemoMode(true)
d(TAG, "美化模式-ignore置为true更新本地order信息")
}
updateAutopilotControlParameters()
}
if (QueryCurrentTaskRespBean.isCompleteTaskType(data)) {
if (FunctionBuildConfig.isDemoMode) {
d(TAG, "setIPCDemoModefalse")
CallerAutoPilotControlManager.setIPCDemoMode(false)
}
clearAutopilotControlParameters()
}
} else {
if (FunctionBuildConfig.isDemoMode) {
d(TAG, "setIPCDemoModefalse")
CallerAutoPilotControlManager.setIPCDemoMode(false)
}
clearAutopilotControlParameters()
}
}
/**
* 将业务订单信息保存,鹰眼可取用
*/
private fun updateAutopilotControlParameters() {
val parameters = initAutopilotControlParameters()
if (null == parameters) {
e(TAG, "AutopilotControlParameters is empty.")
return
}
d(TAG, "AutopilotControlParameters is update.")
DebugView.printInfoMsg("[启自驾] updateAutopilotControlParameters调用成功")
updateAutopilotControlParameters(parameters)
}
private fun clearAutopilotControlParameters() {
fun clearAutopilotControlParameters() {
d(TAG, "AutopilotControlParameters is clear.")
DebugView.printInfoMsg("[启自驾] clearAutopilotControlParameters调用成功")
updateAutopilotControlParameters(null)
@@ -1448,7 +1439,7 @@ object TaxiTaskModel {
d(
TAG, "stopAutoStartAutopilot = ${mCurrentTaskWithOrder?.currentStatus}"
)
if (QueryCurrentTaskRespBean.isGetTaskType(mCurrentTaskWithOrder)) {
if (QueryCurrentTaskRespBean.isTaskGetTaskType(mCurrentTaskWithOrder)) {
mControllerStatusCallback?.stopOpenAutopilotNonManual()
mTaxiTaskWithOrderCallbackMap.forEach {
val listener = it.value