[Taxi无人化] refactor: 去除无用类 / 修改命名;
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
package com.mogo.och.taxi.bean;
|
||||
|
||||
/**
|
||||
* Created by pangfan on 2021/8/19
|
||||
*
|
||||
* 司机取消订单请求的数据结构
|
||||
*/
|
||||
public class OrderCancelReqBean {
|
||||
public String sn;
|
||||
public String orderNo; //订单号(必须)
|
||||
public int cancelType; //取消类型(必须)
|
||||
public String cancelReason; //取消原因(必须)
|
||||
|
||||
public OrderCancelReqBean(String sn, String orderNo, int cancelType, String cancelReason) {
|
||||
this.sn = sn;
|
||||
this.orderNo = orderNo;
|
||||
this.cancelType = cancelType;
|
||||
this.cancelReason = cancelReason;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.mogo.och.taxi.bean;
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData;
|
||||
|
||||
/**
|
||||
* Created on 2021/9/7
|
||||
*
|
||||
* 查询订单路径信息(起始点里程、预估时间等)返回数据结构
|
||||
*/
|
||||
public class OrderQueryRouteInfoRespBean extends BaseData {
|
||||
public Result data;
|
||||
|
||||
public static class Result {
|
||||
// 到上车点
|
||||
public long durationToStart; //司机绑定时的位置距离上车点时长,单位:秒
|
||||
public long distanceToStart; //司机绑定时的位置距离上车点距离,单位:米
|
||||
|
||||
// 起点至终点
|
||||
public long durationToEnd; //订单上车点到目的地的时长,单位:秒
|
||||
public long distanceToEnd; //订单上车点到目的地的距离,单位:米
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.och.taxi.bean
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.och.taxi.constant.TaskStatusEnum
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum
|
||||
|
||||
/**
|
||||
@@ -140,6 +141,16 @@ data class QueryCurrentTaskRespBean(var data: Result?) : BaseData() {
|
||||
}
|
||||
return data.order!!.orderStatus == TaxiOrderStatusEnum.ArriveAtStart.code
|
||||
}
|
||||
|
||||
/**
|
||||
* with task.currentStatus == StartTask
|
||||
*/
|
||||
fun isStartTaskType(data: QueryCurrentTaskRespBean.Result?): Boolean {
|
||||
if (data == null) {
|
||||
return false
|
||||
}
|
||||
return data.currentStatus == TaskStatusEnum.StartTask.code
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,16 @@ import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
/**
|
||||
* Created on 2021/9/10
|
||||
*
|
||||
* <p>
|
||||
* Model->Presenter回调:状态控制器监听(accOn、adas ui show、voice ui show、push ui show、v2x ui show等等)
|
||||
*/
|
||||
public interface ITaxiControllerStatusCallback {
|
||||
// 是否vr map模式
|
||||
void onVRModeChanged(boolean isVRMode);
|
||||
|
||||
// 自车定位
|
||||
void onCarLocationChanged(MogoLocation location);
|
||||
|
||||
//开始开启自动驾驶
|
||||
void startOpenAutopilot();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ class TaxiUnmannedConst {
|
||||
// 到达起始点围栏
|
||||
const val ARRIVE_AT_START_STATION_DISTANCE = 15 //围栏由20m改为50m 再次改为15m
|
||||
|
||||
const val BUSINESSTYPE = 15 //9 taxi , 10 bus
|
||||
const val BUSINESSTYPE = 9 //9 taxi , 10 bus
|
||||
|
||||
// 上报心跳轮询ms
|
||||
const val LOOP_PERIOD_60S = 60 * 1000L
|
||||
|
||||
@@ -224,11 +224,11 @@ class TaxiFragment : BaseTaxiTabFragment<TaxiFragment, TaxiPresenter>(),
|
||||
*/
|
||||
private fun initOrderDebugView() {
|
||||
findViewById<View>(R.id.test_bar_to_virtual)?.setOnClickListener {
|
||||
TaxiTaskModel.setArriveAtUntruthStation()
|
||||
TaxiTaskModel.mockArriveAtNearestStation()
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.test_bar_to_end)?.setOnClickListener {
|
||||
TaxiTaskModel.setArriveAtEndStation()
|
||||
TaxiTaskModel.mockArriveAtEndStation()
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.test_bar_start_service_confirm)?.setOnClickListener {
|
||||
@@ -237,7 +237,7 @@ class TaxiFragment : BaseTaxiTabFragment<TaxiFragment, TaxiPresenter>(),
|
||||
return@setOnClickListener
|
||||
}
|
||||
//当前订单状态若为20 , 则使用的lineId为订单信息的
|
||||
TaxiTaskModel.getCurTaskAndOrder()?.let {
|
||||
TaxiTaskModel.getCurrentTaskWithOrder()?.let {
|
||||
TaxiTaskModel.startTask(
|
||||
if (it.order != null && it.order!!.orderStatus >= TaxiOrderStatusEnum.ArriveAtStart.code)
|
||||
it.order!!.orderLine
|
||||
@@ -251,7 +251,7 @@ class TaxiFragment : BaseTaxiTabFragment<TaxiFragment, TaxiPresenter>(),
|
||||
if (!isStarting) {
|
||||
mPresenter.startAutoPilot()
|
||||
}
|
||||
TaxiTaskModel.setOnTheWayToEndStation()
|
||||
TaxiTaskModel.mockOnTheWayToEndStation()
|
||||
}
|
||||
|
||||
findViewById<View>(R.id.test_bar_route)?.setOnClickListener { testRouteInfoUpload() }
|
||||
|
||||
@@ -16,10 +16,9 @@ import com.mogo.och.common.module.manager.OCHAdasAbilityManager;
|
||||
import com.mogo.och.taxi.callback.ITaxiADASStatusCallback;
|
||||
import com.mogo.och.taxi.callback.ITaxiControllerStatusCallback;
|
||||
import com.mogo.och.taxi.callback.ITaxiOrderStatusCallback;
|
||||
import com.mogo.och.taxi.constant.TaxiDriverRoleEnum;
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum;
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst;
|
||||
import com.mogo.och.taxi.constant.TaxiCarServingStatusManager;
|
||||
import com.mogo.och.taxi.constant.TaxiDriverRoleEnum;
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst;
|
||||
import com.mogo.och.taxi.ui.task.TaxiTaskModel;
|
||||
|
||||
/**
|
||||
@@ -81,11 +80,6 @@ public class TaxiPresenter extends Presenter<TaxiFragment> implements ITaxiADASS
|
||||
TaxiTaskModel.INSTANCE.startAutoPilot();
|
||||
}
|
||||
|
||||
// 获取当前订单状态
|
||||
public TaxiOrderStatusEnum getCurOrderStatus() {
|
||||
return TaxiTaskModel.INSTANCE.getCurOrderStatus();
|
||||
}
|
||||
|
||||
// 登出
|
||||
public void logout() {
|
||||
TaxiTaskModel.INSTANCE.logout();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.och.taxi.base
|
||||
package com.mogo.och.taxi.ui.common
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
@@ -39,7 +39,7 @@ class DebugView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun toggleOrderDebugView() {
|
||||
val data = TaxiTaskModel.getCurTaskAndOrder()
|
||||
val data = TaxiTaskModel.getCurrentTaskWithOrder()
|
||||
val curContrail = TaxiTaskModel.getCurrentTaskTrajectory()
|
||||
|
||||
visibility =
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.mogo.commons.mvp.MvpDialogFragment
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.och.taxi.R
|
||||
import com.mogo.och.taxi.base.AvoidLeakDialog
|
||||
import com.mogo.och.taxi.ui.common.AvoidLeakDialog
|
||||
import com.mogo.och.taxi.bean.QueryCurrentTaskRespBean
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum.*
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum.Companion.valueOf
|
||||
|
||||
@@ -90,7 +90,7 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, UnmannedIntent>(),
|
||||
}
|
||||
|
||||
private fun cancelOrder(cancelType: Int) {
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurTaskAndOrder()
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder()
|
||||
currentTaskWithOrder?.order?.also {
|
||||
cancelOrder(AbsMogoApplication.getApp().applicationContext,
|
||||
it.orderNo,
|
||||
@@ -108,7 +108,7 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, UnmannedIntent>(),
|
||||
}
|
||||
|
||||
private fun jumpPassengerCheck() {
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurTaskAndOrder()
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder()
|
||||
currentTaskWithOrder?.order?.also {
|
||||
TaxiTaskWithOrderServiceManager.jumpPassengerCheck(AbsMogoApplication.getApp().applicationContext,
|
||||
it.orderNo,
|
||||
@@ -125,7 +125,7 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, UnmannedIntent>(),
|
||||
}
|
||||
|
||||
private fun journeyCompleted() {
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurTaskAndOrder()
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder()
|
||||
currentTaskWithOrder?.order?.also {
|
||||
TaxiTaskWithOrderServiceManager.orderCompleted(AbsMogoApplication.getApp().applicationContext,
|
||||
it.orderNo,
|
||||
@@ -142,7 +142,7 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, UnmannedIntent>(),
|
||||
}
|
||||
|
||||
private fun closeOrderByDriver() {
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurTaskAndOrder()
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder()
|
||||
currentTaskWithOrder?.order?.orderEndSite?.also {
|
||||
TaxiTaskModel.submitArriveSite(it.siteId, true)
|
||||
}
|
||||
@@ -154,7 +154,7 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, UnmannedIntent>(),
|
||||
return
|
||||
}
|
||||
//当前订单状态若为20 , 则使用的lineId为订单信息的
|
||||
TaxiTaskModel.getCurTaskAndOrder()?.let {
|
||||
TaxiTaskModel.getCurrentTaskWithOrder()?.let {
|
||||
TaxiTaskModel.startTask(
|
||||
if (it.order != null && it.order!!.orderStatus >= TaxiOrderStatusEnum.ArriveAtStart.code)
|
||||
it.order!!.orderLine
|
||||
@@ -214,7 +214,7 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, UnmannedIntent>(),
|
||||
if (isOrderArrivedAtStart) {
|
||||
TaxiTaskModel.prepareNextTask(siteId)
|
||||
} else {
|
||||
TaxiTaskModel.startPrepareTask120S(siteId)
|
||||
TaxiTaskModel.startPrepareTaskDelay120S(siteId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,9 +239,9 @@ class TaxiCurrentTaskViewModel : BaseViewModel<UnmannedState, UnmannedIntent>(),
|
||||
override fun onOrderJourneyCompleted() {
|
||||
updateTaskAndOrderUi(null)
|
||||
//获取新的任务
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurTaskAndOrder()
|
||||
val currentTaskWithOrder = TaxiTaskModel.getCurrentTaskWithOrder()
|
||||
currentTaskWithOrder?.endSite?.also {
|
||||
TaxiTaskModel.startPrepareTask120S(it.siteId)
|
||||
TaxiTaskModel.startPrepareTaskDelay120S(it.siteId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceM
|
||||
import com.mogo.och.common.module.manager.distancemamager.TrajectoryAndDistanceManager.setStationPoint
|
||||
import com.mogo.och.common.module.map.AmapNaviToDestinationModel
|
||||
import com.mogo.och.common.module.utils.CoordinateCalculateRouteUtil.coordinateConverterWgsToGcjLocations
|
||||
import com.mogo.och.taxi.bean.OrderDetail
|
||||
import com.mogo.och.taxi.bean.PrepareTaskRespBean
|
||||
import com.mogo.och.taxi.bean.QueryCarOrderByNoRespBean
|
||||
import com.mogo.och.taxi.bean.QueryCurrentTaskRespBean
|
||||
@@ -69,7 +68,6 @@ import com.mogo.och.taxi.constant.TaskStatusEnum
|
||||
import com.mogo.och.taxi.constant.TaskTypeEnum
|
||||
import com.mogo.och.taxi.constant.TaxiCarServingStatusManager
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum
|
||||
import com.mogo.och.taxi.constant.TaxiOrderStatusEnum.Companion.valueOf
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst.Companion.BUSINESSTYPE
|
||||
import com.mogo.och.taxi.network.TaxiTaskWithOrderServiceManager
|
||||
@@ -158,6 +156,23 @@ object TaxiTaskModel {
|
||||
mTaxiCarServiceCallback = callback
|
||||
}
|
||||
|
||||
private fun getCurTaskStatus(): Int? {
|
||||
if (mCurrentTaskWithOrder == null) TaskStatusEnum.None
|
||||
return mCurrentTaskWithOrder?.currentStatus
|
||||
}
|
||||
|
||||
fun getCurrentTaskWithOrder(): QueryCurrentTaskRespBean.Result? {
|
||||
return mCurrentTaskWithOrder
|
||||
}
|
||||
|
||||
fun getCurrentOrderTrajectoryList(): MutableList<TrajectoryListRespBean.Result>? {
|
||||
return mTaskTrajectoryList
|
||||
}
|
||||
|
||||
fun getCurrentTaskTrajectory(): TrajectoryListRespBean.Result? {
|
||||
return mCurrentTaskTrajectory
|
||||
}
|
||||
|
||||
fun init() {
|
||||
loginService =
|
||||
ARouter.getInstance().build(OchCommonConst.LOGINSERVICE).navigation() as LoginService
|
||||
@@ -339,11 +354,11 @@ object TaxiTaskModel {
|
||||
if (null == mogoLocation) return
|
||||
|
||||
if (mDriveToNearestStationTask != null) {
|
||||
judgeUntruthStation(mDriveToNearestStationTask, mogoLocation)
|
||||
judgeDriveToNearestStationTaskStation(mDriveToNearestStationTask, mogoLocation)
|
||||
}
|
||||
|
||||
if (checkCurrentTaskCondition()
|
||||
&& mCurrentTaskWithOrder?.currentStatus == TaskStatusEnum.StartTask.code
|
||||
&& QueryCurrentTaskRespBean.isStartTaskType(mCurrentTaskWithOrder)
|
||||
) {
|
||||
// judgeTaskStartStation(mogoLocation)
|
||||
judgeTaskEndSiteStation(mogoLocation)
|
||||
@@ -482,6 +497,41 @@ object TaxiTaskModel {
|
||||
}
|
||||
}
|
||||
|
||||
private fun judgeDriveToNearestStationTaskStation(
|
||||
virtualTask: StartServiceRespBean.Result?,
|
||||
currentLocation: MogoLocation
|
||||
) {
|
||||
if (mDriveToNearestStationTask == null || virtualTask == null) return
|
||||
val distance = CoordinateUtils.calculateLineDistance(
|
||||
virtualTask.gcjLon, virtualTask.gcjLat,
|
||||
currentLocation.longitude, currentLocation.latitude
|
||||
).toDouble()
|
||||
i(
|
||||
TAG,
|
||||
"judgeDriveToNearestStationTaskStation() ${virtualTask.siteName} distance = $distance"
|
||||
)
|
||||
if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE) { // 15米内到站
|
||||
submitArriveSite(virtualTask.siteId, true)
|
||||
}
|
||||
}
|
||||
|
||||
//根据围栏判断,是否到达起点
|
||||
private fun judgeTaskStartStation(location: MogoLocation) {
|
||||
if (checkCurrentTaskCondition()) {
|
||||
val startSite = mCurrentTaskWithOrder!!.startSite ?: return
|
||||
val startLon = startSite.gcjLon
|
||||
val startLat = startSite.gcjLat
|
||||
val distance = CoordinateUtils.calculateLineDistance(
|
||||
startLon, startLat,
|
||||
location.longitude, location.latitude
|
||||
).toDouble()
|
||||
i(TAG, "judgeTaskStartStation() distance = $distance")
|
||||
if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE) {
|
||||
submitArriveSite(startSite.siteId, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun autopilotArriveAtStation() {
|
||||
if (!checkCurrentTaskCondition()) return
|
||||
i(
|
||||
@@ -668,7 +718,7 @@ object TaxiTaskModel {
|
||||
if (mCurrentTaskWithOrder!!.startSite != null && mCurrentTaskWithOrder!!.endSite != null
|
||||
&& mCurrentTaskWithOrder!!.currentStatus <= TaskStatusEnum.StartTask.code
|
||||
) {
|
||||
val curTaskAndOrder = getCurTaskAndOrder() ?: return
|
||||
val curTaskAndOrder = getCurrentTaskWithOrder() ?: return
|
||||
if (curTaskAndOrder.startSite != null && curTaskAndOrder.endSite != null) {
|
||||
val startStation = MogoLocation()
|
||||
startStation.longitude = curTaskAndOrder.startSite!!.gcjLon
|
||||
@@ -720,6 +770,21 @@ object TaxiTaskModel {
|
||||
})
|
||||
}
|
||||
|
||||
fun startTask(lineId: Long) {
|
||||
TaxiTaskWithOrderServiceManager.startTask(
|
||||
mContext,
|
||||
lineId,
|
||||
object : OchCommonServiceCallback<BaseData> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
d(TAG, "startTask onSuccess: data=${GsonUtil.jsonFromObject(data)}")
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
d(TAG, "startTask onFail: code=$code, msg=$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun prepareNextTask(siteId: Long) {
|
||||
TaxiTaskWithOrderServiceManager.prepareTask(
|
||||
mContext,
|
||||
@@ -742,13 +807,13 @@ object TaxiTaskModel {
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
d(TAG, "prepareNextTask onFail: code=$code ,msg=$msg")
|
||||
if (LoginStatusManager.isLogin() && TaxiCarServingStatusManager.isCarServingStatus()) {
|
||||
startPrepareTask120S(siteId)
|
||||
startPrepareTaskDelay120S(siteId)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun startPrepareTask120S(siteId: Long) {
|
||||
fun startPrepareTaskDelay120S(siteId: Long) {
|
||||
UiThreadHandler.postDelayed({
|
||||
prepareNextTask(siteId)
|
||||
}, TaxiUnmannedConst.TIMER_PREPARE_TASK_INTERVAL_120S)
|
||||
@@ -835,117 +900,6 @@ object TaxiTaskModel {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前订单状态
|
||||
fun getCurOrderStatus(): TaxiOrderStatusEnum? {
|
||||
if (mCurrentTaskWithOrder == null) TaxiOrderStatusEnum.None
|
||||
val order: OrderDetail = mCurrentTaskWithOrder!!.order!!
|
||||
return valueOf(order.orderStatus)
|
||||
}
|
||||
|
||||
private fun getCurTaskStatus(): Int? {
|
||||
if (mCurrentTaskWithOrder == null) TaskStatusEnum.None
|
||||
return mCurrentTaskWithOrder?.currentStatus
|
||||
}
|
||||
|
||||
fun getCurTaskAndOrder(): QueryCurrentTaskRespBean.Result? {
|
||||
return mCurrentTaskWithOrder
|
||||
}
|
||||
|
||||
fun getCurUntruthTask(): StartServiceRespBean.Result? {
|
||||
return mDriveToNearestStationTask
|
||||
}
|
||||
|
||||
fun getCurrentOrderTrajectoryList(): MutableList<TrajectoryListRespBean.Result>? {
|
||||
return mTaskTrajectoryList
|
||||
}
|
||||
|
||||
fun getCurrentTaskTrajectory(): TrajectoryListRespBean.Result? {
|
||||
return mCurrentTaskTrajectory
|
||||
}
|
||||
|
||||
//更新本地currentOrder信息,并保存订单到本地避免车机重启丢失数据
|
||||
private fun updateNativeCurrentOrder(data: QueryCurrentTaskRespBean.Result?) {
|
||||
if (data == null) {
|
||||
return
|
||||
}
|
||||
mCurrentTaskWithOrder = data
|
||||
|
||||
SharedPrefsMgr.getInstance(mContext!!).putString(
|
||||
TaxiUnmannedConst.SP_KEY_OCH_TAXI_ORDER,
|
||||
GsonUtil.jsonFromObject(data)
|
||||
)
|
||||
|
||||
val currentOrder = mCurrentTaskWithOrder!!.order
|
||||
|
||||
if (currentOrder != null) {
|
||||
if (currentOrder!!.orderStatus == TaxiOrderStatusEnum.OnTheWayToEnd.code) {
|
||||
if (FunctionBuildConfig.isDemoMode) {
|
||||
// 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后,置true
|
||||
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true
|
||||
CallerAutoPilotControlManager.setIgnoreConditionDraw(true)
|
||||
CallerAutoPilotControlManager.setIPCDemoMode(true)
|
||||
d(TAG, "美化模式-ignore:置为true(更新本地order信息)")
|
||||
}
|
||||
updateAutopilotControlParameters()
|
||||
}
|
||||
if (currentOrder!!.orderStatus == TaxiOrderStatusEnum.ArriveAtEnd.code) {
|
||||
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.")
|
||||
updateAutopilotControlParameters(parameters)
|
||||
}
|
||||
|
||||
private fun clearAutopilotControlParameters() {
|
||||
d(TAG, "AutopilotControlParameters is clear.")
|
||||
updateAutopilotControlParameters(null)
|
||||
}
|
||||
|
||||
fun updateUntruthTask(untruthTask: StartServiceRespBean.Result?) {
|
||||
mDriveToNearestStationTask = untruthTask
|
||||
}
|
||||
|
||||
//清除任务订单信息
|
||||
fun clearCurrentOCHOrder() {
|
||||
mCurrentTaskWithOrder = null
|
||||
clearAutopilotControlParameters()
|
||||
TaxiTrajectoryManager.getInstance().syncTrajectoryInfo()
|
||||
SharedPrefsMgr.getInstance(mContext!!).remove(TaxiUnmannedConst.SP_KEY_OCH_TAXI_ORDER)
|
||||
isRestartAutopilot = false
|
||||
if (FunctionBuildConfig.isDemoMode) {
|
||||
// 当美化模式(演示模式)开启时: 取消或订单已完成时,置false
|
||||
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false
|
||||
CallerAutoPilotControlManager.setIgnoreConditionDraw(false)
|
||||
CallerAutoPilotControlManager.setIPCDemoMode(false)
|
||||
d(TAG, "美化模式-ignore:置为false(已完成or清除当前订单)")
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkCurrentOrder(): Boolean {
|
||||
return mCurrentTaskWithOrder != null && mCurrentTaskWithOrder!!.order != null
|
||||
}
|
||||
|
||||
/**
|
||||
* 以当前订单为基础,开启自动驾驶
|
||||
*/
|
||||
@@ -1061,7 +1015,7 @@ object TaxiTaskModel {
|
||||
mCurrentTaskTrajectory!!.txtFileUrl,
|
||||
mCurrentTaskTrajectory!!.txtFileMd5,
|
||||
mCurrentTaskTrajectory!!.contrailSaveTime,
|
||||
"", // todo 这里原来传的是carModel, 现在没有这个信息
|
||||
BUSINESSTYPE.toString(),
|
||||
mCurrentTaskTrajectory!!.csvFileUrlDPQP,
|
||||
mCurrentTaskTrajectory!!.csvFileMd5DPQP,
|
||||
mCurrentTaskTrajectory!!.txtFileUrlDPQP,
|
||||
@@ -1082,57 +1036,6 @@ object TaxiTaskModel {
|
||||
}
|
||||
}
|
||||
|
||||
//根据围栏判断,是否到达起点
|
||||
private fun judgeTaskStartStation(location: MogoLocation) {
|
||||
if (checkCurrentTaskCondition()) {
|
||||
val startSite = mCurrentTaskWithOrder!!.startSite ?: return
|
||||
val startLon = startSite.gcjLon
|
||||
val startLat = startSite.gcjLat
|
||||
val distance = CoordinateUtils.calculateLineDistance(
|
||||
startLon, startLat,
|
||||
location.longitude, location.latitude
|
||||
).toDouble()
|
||||
i(TAG, "judgeTaskStartStation() distance = $distance")
|
||||
if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE) {
|
||||
submitArriveSite(startSite.siteId, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun judgeUntruthStation(
|
||||
virtualTask: StartServiceRespBean.Result?,
|
||||
currentLocation: MogoLocation
|
||||
) {
|
||||
if (mDriveToNearestStationTask == null || virtualTask == null) return
|
||||
val distance = CoordinateUtils.calculateLineDistance(
|
||||
virtualTask.gcjLon, virtualTask.gcjLat,
|
||||
currentLocation.longitude, currentLocation.latitude
|
||||
).toDouble()
|
||||
i(
|
||||
TAG,
|
||||
"judgeEndStation() ${virtualTask.siteName} distance = $distance"
|
||||
)
|
||||
if (distance <= TaxiUnmannedConst.ARRIVE_AT_START_STATION_DISTANCE) { // 15米内到站
|
||||
submitArriveSite(virtualTask.siteId, true)
|
||||
}
|
||||
}
|
||||
|
||||
fun startTask(lineId: Long) {
|
||||
TaxiTaskWithOrderServiceManager.startTask(
|
||||
mContext,
|
||||
lineId,
|
||||
object : OchCommonServiceCallback<BaseData> {
|
||||
override fun onSuccess(data: BaseData?) {
|
||||
d(TAG, "startTask onSuccess: data=${GsonUtil.jsonFromObject(data)}")
|
||||
}
|
||||
|
||||
override fun onFail(code: Int, msg: String?) {
|
||||
d(TAG, "startTask onFail: code=$code, msg=$msg")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun judgeTaskEndSiteStation(currentLocation: MogoLocation) {
|
||||
if (!checkCurrentTaskCondition()) {
|
||||
return
|
||||
@@ -1174,39 +1077,11 @@ object TaxiTaskModel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun setArriveAtUntruthStation() {
|
||||
if (mDriveToNearestStationTask == null) {
|
||||
ToastUtils.showShort("无虚拟站点!")
|
||||
return
|
||||
}
|
||||
submitArriveSite(mDriveToNearestStationTask!!.siteId, false)
|
||||
}
|
||||
|
||||
fun setArriveAtEndStation() {
|
||||
if (!checkCurrentTaskCondition()) {
|
||||
ToastUtils.showShort("无任务!")
|
||||
return
|
||||
}
|
||||
// arriveSite(mCurrentTaskAndOrder?.endSite!!.siteId, true)
|
||||
autopilotArriveAtStation()
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试开启自动驾驶
|
||||
*/
|
||||
fun setOnTheWayToEndStation() {
|
||||
if (!checkCurrentOrder()) {
|
||||
ToastUtils.showShort("订单状态不匹配该操作!")
|
||||
}
|
||||
startAutoPilot()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置路径规划起终点
|
||||
*/
|
||||
fun setRouteLineMarker() {
|
||||
val curTaskAndOrder = getCurTaskAndOrder()
|
||||
val curTaskAndOrder = getCurrentTaskWithOrder()
|
||||
if (curTaskAndOrder != null) {
|
||||
if (curTaskAndOrder.startSite == null || curTaskAndOrder.endSite == null) {
|
||||
cleanLineMarker()
|
||||
@@ -1232,6 +1107,24 @@ object TaxiTaskModel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除任务订单信息
|
||||
*/
|
||||
fun clearCurrentOCHOrder() {
|
||||
mCurrentTaskWithOrder = null
|
||||
clearAutopilotControlParameters()
|
||||
TaxiTrajectoryManager.getInstance().syncTrajectoryInfo()
|
||||
SharedPrefsMgr.getInstance(mContext).remove(TaxiUnmannedConst.SP_KEY_OCH_TAXI_ORDER)
|
||||
isRestartAutopilot = false
|
||||
if (FunctionBuildConfig.isDemoMode) {
|
||||
// 当美化模式(演示模式)开启时: 取消或订单已完成时,置false
|
||||
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false
|
||||
CallerAutoPilotControlManager.setIgnoreConditionDraw(false)
|
||||
CallerAutoPilotControlManager.setIPCDemoMode(false)
|
||||
d(TAG, "美化模式-ignore:置为false(已完成or清除当前订单)")
|
||||
}
|
||||
}
|
||||
|
||||
// 登出
|
||||
fun logout() {
|
||||
loginService!!.loginOut(
|
||||
@@ -1259,4 +1152,90 @@ object TaxiTaskModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//更新本地currentOrder信息,并保存订单到本地避免车机重启丢失数据
|
||||
private fun updateNativeCurrentOrder(data: QueryCurrentTaskRespBean.Result?) {
|
||||
if (data == null) {
|
||||
return
|
||||
}
|
||||
mCurrentTaskWithOrder = data
|
||||
|
||||
SharedPrefsMgr.getInstance(mContext!!).putString(
|
||||
TaxiUnmannedConst.SP_KEY_OCH_TAXI_ORDER,
|
||||
GsonUtil.jsonFromObject(data)
|
||||
)
|
||||
|
||||
val currentOrder = mCurrentTaskWithOrder!!.order
|
||||
|
||||
if (currentOrder != null) {
|
||||
if (currentOrder!!.orderStatus == TaxiOrderStatusEnum.OnTheWayToEnd.code) {
|
||||
if (FunctionBuildConfig.isDemoMode) {
|
||||
// 当美化模式(演示模式)开启时: 订单对应自动驾驶开启后,置true
|
||||
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true
|
||||
CallerAutoPilotControlManager.setIgnoreConditionDraw(true)
|
||||
CallerAutoPilotControlManager.setIPCDemoMode(true)
|
||||
d(TAG, "美化模式-ignore:置为true(更新本地order信息)")
|
||||
}
|
||||
updateAutopilotControlParameters()
|
||||
}
|
||||
if (currentOrder!!.orderStatus == TaxiOrderStatusEnum.ArriveAtEnd.code) {
|
||||
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.")
|
||||
updateAutopilotControlParameters(parameters)
|
||||
}
|
||||
|
||||
private fun clearAutopilotControlParameters() {
|
||||
d(TAG, "AutopilotControlParameters is clear.")
|
||||
updateAutopilotControlParameters(null)
|
||||
}
|
||||
|
||||
fun mockArriveAtNearestStation() {
|
||||
if (mDriveToNearestStationTask == null) {
|
||||
ToastUtils.showShort("无虚拟站点!")
|
||||
return
|
||||
}
|
||||
submitArriveSite(mDriveToNearestStationTask!!.siteId, false)
|
||||
}
|
||||
|
||||
fun mockArriveAtEndStation() {
|
||||
if (!checkCurrentTaskCondition()) {
|
||||
ToastUtils.showShort("无任务!")
|
||||
return
|
||||
}
|
||||
// arriveSite(mCurrentTaskAndOrder?.endSite!!.siteId, true)
|
||||
autopilotArriveAtStation()
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试开启自动驾驶
|
||||
*/
|
||||
fun mockOnTheWayToEndStation() {
|
||||
if (mCurrentTaskWithOrder == null || mCurrentTaskWithOrder?.order == null) {
|
||||
ToastUtils.showShort("订单状态不匹配该操作!")
|
||||
}
|
||||
startAutoPilot()
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.mogo.och.taxi.utils;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils;
|
||||
import com.mogo.och.taxi.bean.TrajectoryListRespBean;
|
||||
import com.mogo.och.taxi.bean.OrderDetail;
|
||||
import com.mogo.och.taxi.bean.QueryCurrentTaskRespBean;
|
||||
import com.mogo.och.taxi.bean.TrajectoryListRespBean;
|
||||
import com.mogo.och.taxi.constant.TaskStatusEnum;
|
||||
import com.mogo.och.taxi.constant.TaxiUnmannedConst;
|
||||
import com.mogo.och.taxi.ui.task.TaxiTaskModel;
|
||||
@@ -24,8 +26,6 @@ import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
/**
|
||||
* Taxi轨迹管理:给MEC下发用于轨迹下载的信息
|
||||
* Created on 2022/6/22
|
||||
@@ -68,7 +68,7 @@ public class TaxiTrajectoryManager {
|
||||
* 同步订单信息
|
||||
*/
|
||||
public void syncTrajectoryInfo() {
|
||||
QueryCurrentTaskRespBean.Result taskAndOrder = TaxiTaskModel.INSTANCE.getCurTaskAndOrder();
|
||||
QueryCurrentTaskRespBean.Result taskAndOrder = TaxiTaskModel.INSTANCE.getCurrentTaskWithOrder();
|
||||
if (taskAndOrder == null || taskAndOrder.getCurrentStatus() >= TaskStatusEnum.StartTask.getCode()) {
|
||||
CallerLogger.d(M_TAXI + TAG, "syncTrajectoryInfo() stop.");
|
||||
stopTrajReqLoop();
|
||||
@@ -117,7 +117,7 @@ public class TaxiTrajectoryManager {
|
||||
}
|
||||
|
||||
private void setupAutoPilotLine() {
|
||||
QueryCurrentTaskRespBean.Result taskAndOrder = TaxiTaskModel.INSTANCE.getCurTaskAndOrder();
|
||||
QueryCurrentTaskRespBean.Result taskAndOrder = TaxiTaskModel.INSTANCE.getCurrentTaskWithOrder();
|
||||
|
||||
if (taskAndOrder == null || taskAndOrder.getEndSite() == null) {
|
||||
CallerLogger.e(M_TAXI + TAG,
|
||||
@@ -125,9 +125,10 @@ public class TaxiTrajectoryManager {
|
||||
} else {
|
||||
/**
|
||||
* 主要加载和预加载轨迹方案
|
||||
* 1、获取当前跑的任务的lineId 2、当前任务lineId是否在运营单的轨迹集合里
|
||||
* 3、存在, 通知下载加载当前任务的轨迹以及预加载lineId在集合对应的下一个lineId对应的轨迹
|
||||
* 4、若不存在,说明当前的执行的任务是与订单无关的演练任务,通知下载加载当前任务的轨迹以及预加载订单轨迹集合的第一个
|
||||
* 1、获取当前跑的任务的lineId
|
||||
* 2、当前任务lineId是否在运营单的轨迹集合里
|
||||
* 3、存在, 通知下载加载当前任务的轨迹以及预加载lineId在集合对应的下一个lineId对应的轨迹
|
||||
* 4、若不存在,说明当前的执行的任务是与订单无关的演练任务,通知下载加载当前任务的轨迹以及预加载订单轨迹集合的第一个
|
||||
*/
|
||||
|
||||
final TrajectoryListRespBean.Result curTaskContrail = TaxiTaskModel.INSTANCE.getCurrentTaskTrajectory();
|
||||
@@ -138,7 +139,7 @@ public class TaxiTrajectoryManager {
|
||||
if (mAutoPilotLine == null) {
|
||||
mAutoPilotLine = new AutopilotControlParameters.AutoPilotLine(curTaskContrail.getLineId(), curTaskContrail.getLineName(),
|
||||
curTaskContrail.getCsvFileUrl(), curTaskContrail.getCsvFileMd5(), curTaskContrail.getTxtFileUrl(),
|
||||
curTaskContrail.getTxtFileMd5(), curTaskContrail.getContrailSaveTime(), "",//todo curTaskContrail.getCarModel()
|
||||
curTaskContrail.getTxtFileMd5(), curTaskContrail.getContrailSaveTime(), String.valueOf(TaxiUnmannedConst.BUSINESSTYPE),
|
||||
curTaskContrail.getCsvFileUrlDPQP(), curTaskContrail.getCsvFileMd5DPQP(), curTaskContrail.getTxtFileUrlDPQP(),
|
||||
curTaskContrail.getTxtFileMd5DPQP(), curTaskContrail.getContrailSaveTimeDPQP());
|
||||
} else {
|
||||
@@ -149,7 +150,7 @@ public class TaxiTrajectoryManager {
|
||||
mAutoPilotLine.setStopUrl(curTaskContrail.getTxtFileUrl());
|
||||
mAutoPilotLine.setStopMd5(curTaskContrail.getTxtFileMd5());
|
||||
mAutoPilotLine.setTimestamp(curTaskContrail.getContrailSaveTime());
|
||||
mAutoPilotLine.setVehicleModel("");// todo curTaskContrail.getCarModel()
|
||||
mAutoPilotLine.setVehicleModel(String.valueOf(TaxiUnmannedConst.BUSINESSTYPE));
|
||||
mAutoPilotLine.setTrajUrl_dpqp(curTaskContrail.getCsvFileUrlDPQP());
|
||||
mAutoPilotLine.setTrajMd5_dpqp(curTaskContrail.getCsvFileMd5DPQP());
|
||||
mAutoPilotLine.setStopUrl_dpqp(curTaskContrail.getTxtFileUrlDPQP());
|
||||
@@ -189,7 +190,7 @@ public class TaxiTrajectoryManager {
|
||||
if (mPreAutoPilotLine == null) {
|
||||
mPreAutoPilotLine = new AutopilotControlParameters.AutoPilotLine(preloadContrail.getLineId(), preloadContrail.getLineName(),
|
||||
preloadContrail.getCsvFileUrl(), preloadContrail.getCsvFileMd5(), preloadContrail.getTxtFileUrl(),
|
||||
preloadContrail.getTxtFileMd5(), preloadContrail.getContrailSaveTime(), "",//todo curTaskContrail.getCarModel()
|
||||
preloadContrail.getTxtFileMd5(), preloadContrail.getContrailSaveTime(), String.valueOf(TaxiUnmannedConst.BUSINESSTYPE),
|
||||
preloadContrail.getCsvFileUrlDPQP(), preloadContrail.getCsvFileMd5DPQP(), preloadContrail.getTxtFileUrlDPQP(),
|
||||
preloadContrail.getTxtFileMd5DPQP(), preloadContrail.getContrailSaveTimeDPQP());
|
||||
} else {
|
||||
@@ -200,7 +201,7 @@ public class TaxiTrajectoryManager {
|
||||
mPreAutoPilotLine.setStopUrl(preloadContrail.getTxtFileUrl());
|
||||
mPreAutoPilotLine.setStopMd5(preloadContrail.getTxtFileMd5());
|
||||
mPreAutoPilotLine.setTimestamp(preloadContrail.getContrailSaveTime());
|
||||
mPreAutoPilotLine.setVehicleModel("");// todo curTaskContrail.getCarModel()
|
||||
mPreAutoPilotLine.setVehicleModel(String.valueOf(TaxiUnmannedConst.BUSINESSTYPE));
|
||||
mPreAutoPilotLine.setTrajUrl_dpqp(preloadContrail.getCsvFileUrlDPQP());
|
||||
mPreAutoPilotLine.setTrajMd5_dpqp(preloadContrail.getCsvFileMd5DPQP());
|
||||
mPreAutoPilotLine.setStopUrl_dpqp(preloadContrail.getTxtFileUrlDPQP());
|
||||
|
||||
Reference in New Issue
Block a user