[6.1.0] 任务/订单回调接口部分逻辑整理
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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?) {
|
||||
|
||||
@@ -2,14 +2,20 @@ 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
|
||||
@@ -225,15 +231,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("已为您接到订单")
|
||||
@@ -245,15 +284,17 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, TaskUiIntent>(),
|
||||
|
||||
if (QueryCurrentTaskRespBean.isUserArriveAtStart(result)) {
|
||||
TaxiTaskModel.removePrepareTaskDelay()
|
||||
TaxiTaskModel.prepareNextTask(0,result.endSite!!.siteId)
|
||||
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)
|
||||
result?.endSite!!.siteId)
|
||||
}
|
||||
|
||||
clearDemoModeAndACParameters()
|
||||
}
|
||||
|
||||
override fun onTaskTrajectoryDataChanged(data: TrajectoryListRespBean?) {
|
||||
@@ -382,4 +423,26 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, TaskUiIntent>(),
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -268,16 +268,7 @@ 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_ENABLE,meaning=可自动驾驶,人工干预状态")
|
||||
@@ -698,8 +689,6 @@ object TaxiTaskModel {
|
||||
|
||||
mCurrentTaskWithOrder = result
|
||||
|
||||
updateLocalCalculateStation()
|
||||
|
||||
// 任务为空
|
||||
if (result?.endSite == null && result?.order == null) {
|
||||
d(TAG, "queryCurrentTaskOnce: 任务为空")
|
||||
@@ -710,15 +699,23 @@ object TaxiTaskModel {
|
||||
}
|
||||
}
|
||||
clearCurrentOCHOrder()
|
||||
clearLocalCalculateStation()
|
||||
return
|
||||
}
|
||||
|
||||
//开始任务处理
|
||||
if (QueryCurrentTaskRespBean.isStartTaskType(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.isCompleteTaskType(result)) {
|
||||
mIsArrivedSiteStartTag = false //任务完成说明到站, 更新到站标识位, 不再到站接口请求成功更新
|
||||
mADASStatusCallback?.updateAutopilotStatus()
|
||||
mTaxiTaskWithOrderCallbackMap.forEach {
|
||||
@@ -746,7 +743,7 @@ object TaxiTaskModel {
|
||||
}
|
||||
queryTaskTrajectoryByLineIds(linesIds.toTypedArray(), result.lineId)
|
||||
|
||||
//自动去启动自驾
|
||||
//自动去启动自驾, 拿到任务并且任务类型是演练和接驾任务
|
||||
if (result.currentStatus == TaskStatusEnum.GetTask.code &&
|
||||
result.taskType <= TaskTypeEnum.ToOrderStartTask.code
|
||||
) {
|
||||
@@ -767,7 +764,6 @@ object TaxiTaskModel {
|
||||
listener.onTaskWithOrderDataChanged(mCurrentTaskWithOrder)
|
||||
}
|
||||
}
|
||||
updateDemoModeAndAutopilotParameters(result)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -798,29 +794,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) {
|
||||
@@ -1178,7 +1157,7 @@ object TaxiTaskModel {
|
||||
mControllerStatusCallback?.startOpenAutopilot()
|
||||
}
|
||||
|
||||
private fun initAutopilotControlParameters(): AutopilotControlParameters? {
|
||||
fun initAutopilotControlParameters(): AutopilotControlParameters? {
|
||||
if (!checkCurrentTaskCondition()) {
|
||||
e(TAG, "no order or order is empty.")
|
||||
return null
|
||||
@@ -1326,12 +1305,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 +1348,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, "setIPCDemoMode:false")
|
||||
CallerAutoPilotControlManager.setIPCDemoMode(false)
|
||||
}
|
||||
clearAutopilotControlParameters()
|
||||
}
|
||||
} else {
|
||||
if (FunctionBuildConfig.isDemoMode) {
|
||||
d(TAG, "setIPCDemoMode:false")
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user