[6.6.1]
[fix] [修复 session 超时未清理]
This commit is contained in:
@@ -14,19 +14,22 @@ import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager
|
||||
import com.mogo.och.common.module.manager.autopilot.autopilot.bean.SessionWithTime
|
||||
import com.mogo.och.common.module.manager.autopilot.line.LineManager
|
||||
import com.mogo.och.common.module.manager.distance.TrajectoryAndDistanceManager
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
import com.zhjt.mogo.adas.common.MessageType
|
||||
import com.zhjt.mogo.adas.data.bean.ReceivedAck
|
||||
import com.zhjt.mogo.adas.data.bean.ReceivedAck.Status
|
||||
import fsm.Fsm2024
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
object OchAutoPilotManager : IMoGoReceiveReceivedAckListener, IMoGoFsm2024Listener {
|
||||
|
||||
const val TAG = "OchAutoPilotManager"
|
||||
|
||||
private val globalSessionId = AtomicLong(-1)
|
||||
private val globalSessionId = AtomicReference<SessionWithTime>()
|
||||
private val fsmBackSessionId = AtomicLong(-1L)
|
||||
|
||||
init {
|
||||
@@ -51,18 +54,27 @@ object OchAutoPilotManager : IMoGoReceiveReceivedAckListener, IMoGoFsm2024Listen
|
||||
* 启动自驾中禁止再次启动自驾
|
||||
*/
|
||||
@JvmStatic
|
||||
fun canStartAutopilotBySessionId():Boolean{
|
||||
return (globalSessionId.get()==-1L).apply {
|
||||
if(!this) {
|
||||
fun canStartAutopilotBySessionId(): Boolean {
|
||||
val sessionInfo = globalSessionId.get()
|
||||
val currentTimeMillis = System.currentTimeMillis()
|
||||
if(sessionInfo==null){
|
||||
return true
|
||||
}else{
|
||||
if(currentTimeMillis-sessionInfo.setTime>=OchAutopilotAnalytics.LOOP_PERIOD_16S){
|
||||
clearGlobalSessionId("检测session 自带的时间 ${currentTimeMillis}_${sessionInfo.setTime}_${sessionInfo.sessionId}")
|
||||
return true
|
||||
}else{
|
||||
ToastUtils.showLong("自驾启动中,请勿重复点击")
|
||||
OchAutopilotAnalytics.triggerCanStartAutopilotBySessionId(globalSessionId.get())
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun canStartAutopilotBySessionIdInner():Boolean{
|
||||
return (globalSessionId.get()==-1L)
|
||||
OchChainLogManager.writeChainLogAutopilot("自驾流程","清理SessiongId")
|
||||
return (globalSessionId.get()==null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -88,14 +100,15 @@ object OchAutoPilotManager : IMoGoReceiveReceivedAckListener, IMoGoFsm2024Listen
|
||||
return true
|
||||
}
|
||||
|
||||
fun clearGlobalSessionId(){
|
||||
globalSessionId.set(-1)
|
||||
fun clearGlobalSessionId(log:String){
|
||||
OchChainLogManager.writeChainLogAutopilot("自驾流程","清理SessiongId${globalSessionId}_${fsmBackSessionId}_${log}")
|
||||
globalSessionId.set(null)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun startAutoPilot(controlParameters: AutopilotControlParameters?): Long {
|
||||
val sessionId = CallerAutoPilotControlManager.startAutoPilot(controlParameters)
|
||||
globalSessionId.set(sessionId)
|
||||
globalSessionId.set(SessionWithTime(sessionId,System.currentTimeMillis()))
|
||||
fsmBackSessionId.set(-1L)
|
||||
OchAutopilotAnalytics.triggerStartAutopilotParameters(controlParameters, sessionId)
|
||||
return sessionId
|
||||
@@ -120,9 +133,14 @@ object OchAutoPilotManager : IMoGoReceiveReceivedAckListener, IMoGoFsm2024Listen
|
||||
* 启动自驾失败切 FSM返回的Session和启动SessionId 不同
|
||||
*/
|
||||
fun checkStartSessionAndFailSessionId(){
|
||||
if(globalSessionId.get() != fsmBackSessionId.get()){
|
||||
OchAutopilotAnalytics.triggerStartAutopilotFailCheckSessionDiff(globalSessionId.get(),
|
||||
fsmBackSessionId.get())
|
||||
val sessionInfo = globalSessionId.get()
|
||||
if(sessionInfo!=null) {
|
||||
if (sessionInfo.sessionId != fsmBackSessionId.get()) {
|
||||
OchAutopilotAnalytics.triggerStartAutopilotFailCheckSessionDiff(
|
||||
sessionInfo,
|
||||
fsmBackSessionId.get()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,11 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.DateTimeUtils
|
||||
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager
|
||||
import com.mogo.och.common.module.manager.autopilot.autopilot.bean.SessionWithTime
|
||||
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
|
||||
import com.mogo.och.common.module.manager.loop.BizLoopManager
|
||||
import com.mogo.och.common.module.utils.RxUtils
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
||||
object OchAutopilotAnalytics {
|
||||
|
||||
@@ -49,6 +52,7 @@ object OchAutopilotAnalytics {
|
||||
private const val EVENT_PARAM_VEHICLE_START_AUTOPILOT_CMD_SESSION_ID_FSM_RETURN = "cmd_session_id_fsm_return"
|
||||
|
||||
private val LOOP_PERIOD_15S = 15 * 1000L
|
||||
val LOOP_PERIOD_16S = 16 * 1000L
|
||||
|
||||
|
||||
private var mStartAutopilotKey: String? = null
|
||||
@@ -94,34 +98,36 @@ object OchAutopilotAnalytics {
|
||||
/**
|
||||
* 等待底盘返回的间隙 重复启动自驾
|
||||
*/
|
||||
fun triggerCanStartAutopilotBySessionId(globalSessionId : Long){
|
||||
fun triggerCanStartAutopilotBySessionId(globalSessionId : SessionWithTime){
|
||||
val map = hashMapOf<String, Any>()
|
||||
map[EVENT_PARAM_AUTOPILOTANALYTICS_GROUP] = EVENT_PARAM_AUTOPILOTANALYTICS_GROUP
|
||||
OchChainLogManager.writeChainLog("启动自驾Session判断","已有globalSessionId:${globalSessionId}", eventID = EVENT_KEY_VEHICLE_START_AUTOPILOT_CMD_SESSION_DUPLICATED, patch = map)
|
||||
OchChainLogManager.writeChainLog("启动自驾Session判断","已有globalSessionId:${globalSessionId.sessionId}_创建时间:${globalSessionId.setTime}", eventID = EVENT_KEY_VEHICLE_START_AUTOPILOT_CMD_SESSION_DUPLICATED, patch = map)
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动失败后 对比两个session是否相同
|
||||
*/
|
||||
fun triggerStartAutopilotFailCheckSessionDiff(globalSessionId: Long, fsmBackSessionId: Long){
|
||||
fun triggerStartAutopilotFailCheckSessionDiff(globalSessionId: SessionWithTime, fsmBackSessionId: Long){
|
||||
val map = hashMapOf<String, Any>()
|
||||
map[EVENT_PARAM_AUTOPILOTANALYTICS_GROUP] = EVENT_PARAM_AUTOPILOTANALYTICS_GROUP
|
||||
map[EVENT_PARAM_VEHICLE_START_AUTOPILOT_CMD_SESSION_ID_START] = globalSessionId
|
||||
map[EVENT_PARAM_VEHICLE_START_AUTOPILOT_CMD_SESSION_ID_START] = "${globalSessionId.sessionId}_${globalSessionId.setTime}"
|
||||
map[EVENT_PARAM_VEHICLE_START_AUTOPILOT_CMD_SESSION_ID_FSM_RETURN] = fsmBackSessionId
|
||||
OchChainLogManager.writeChainLog("启动自驾失败且SessionId不同","globalSessionId:${globalSessionId}——————fsmBackSessionId:${fsmBackSessionId}", eventID = EVENT_KEY_VEHICLE_START_AUTOPILOT_CMD_SESSION_DIFF, patch = map)
|
||||
}
|
||||
|
||||
|
||||
private val timeOutRunnable = Runnable {
|
||||
// 15s内未开启,上报失败埋点
|
||||
triggerStartAutopilotFailureEvent("", "15s后app等待超时", System.currentTimeMillis())
|
||||
}
|
||||
private var timeOutDisposable: Disposable?=null
|
||||
|
||||
/**
|
||||
* 底盘明确告知启动自驾失败
|
||||
*/
|
||||
fun triggerStartAutopilotFailureEventByAdas(failCode: String, failMsg: String, startFailDate: Long) {
|
||||
BizLoopManager.removeCallback(timeOutRunnable)
|
||||
OchChainLogManager.writeChainLogAutopilot("自驾流程","启动自驾失败回调${failCode}_${failMsg}")
|
||||
if(OchAutoPilotManager.canStartAutopilotBySessionIdInner()){
|
||||
CallerLogger.e(SceneConstant.M_OCHCOMMON + "triggerStartAutopilotFailureEvent canStartAutopilotBySessionIdInner == false")
|
||||
OchChainLogManager.writeChainLogAutopilot("自驾流程","异常情况 启动自驾失败回调${failCode}_${failMsg}_sessiong为空")
|
||||
return
|
||||
}
|
||||
RxUtils.disposeSubscribe(timeOutDisposable)
|
||||
// 判断Session 是否相同
|
||||
OchAutoPilotManager.checkStartSessionAndFailSessionId()
|
||||
triggerStartAutopilotFailureEvent(failCode, failMsg, startFailDate)
|
||||
@@ -132,12 +138,10 @@ object OchAutopilotAnalytics {
|
||||
}
|
||||
|
||||
private fun triggerStartAutopilotFailureEvent(failCode: String, failMsg: String, startFailDate: Long) {
|
||||
if(OchAutoPilotManager.canStartAutopilotBySessionIdInner()){
|
||||
CallerLogger.e(SceneConstant.M_OCHCOMMON + "triggerStartAutopilotFailureEvent canStartAutopilotBySessionIdInner == false")
|
||||
OchAutoPilotManager.clearGlobalSessionId("$failMsg _ ${failCode}")
|
||||
if (mStartAutopilotParams.isEmpty()) {
|
||||
return
|
||||
}
|
||||
OchAutoPilotManager.clearGlobalSessionId()
|
||||
if (mStartAutopilotParams.isEmpty()) return
|
||||
CallerLogger.e(SceneConstant.M_OCHCOMMON + "triggerStartAutopilotFailureEvent", failMsg)
|
||||
if (CallerAutoPilotStatusListenerManager.getState() != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
mStartAutopilotParams[EVENT_PARAM_START_FAILURE_CODE] = failCode
|
||||
@@ -170,15 +174,19 @@ object OchAutopilotAnalytics {
|
||||
triggerDate: Long,
|
||||
source:Int = 0
|
||||
) {
|
||||
OchChainLogManager.writeChainLogAutopilot("自驾流程","send:${send}_${restart}_${startName}_${endName}_${lineId}_${orderId}_${source}_${triggerDate}")
|
||||
mStartAutopilotKey = if (restart) getEventKeyRestartService() else getEventKeyStartService()
|
||||
if (send) {
|
||||
if(OchAutoPilotManager.canStartAutopilotBySessionIdInner()){
|
||||
CallerLogger.e(SceneConstant.M_OCHCOMMON + "triggerStartAutopilotEvent canStartAutopilotBySessionIdInner == false")
|
||||
OchChainLogManager.writeChainLogAutopilot("自驾流程","异常情况 启动自驾成功_sessiong为空")
|
||||
return
|
||||
}
|
||||
OchAutoPilotManager.clearGlobalSessionId("启动自驾成功")
|
||||
RxUtils.disposeSubscribe(timeOutDisposable)
|
||||
if (mStartAutopilotParams.isEmpty()) {
|
||||
return
|
||||
}
|
||||
OchAutoPilotManager.clearGlobalSessionId()
|
||||
BizLoopManager.removeCallback(timeOutRunnable)
|
||||
if (mStartAutopilotParams.isEmpty()) return
|
||||
// 开启成功,上报埋点
|
||||
mStartAutopilotParams[EVENT_PARAM_START_FAILURE_CODE] = ""
|
||||
mStartAutopilotParams[EVENT_PARAM_START_FAILURE_MSG] = ""
|
||||
@@ -198,8 +206,10 @@ object OchAutopilotAnalytics {
|
||||
mStartAutopilotParams[EVENT_PARAM_END_NAME] = endName
|
||||
mStartAutopilotParams[EVENT_PARAM_LINE_ID] = lineId
|
||||
mStartAutopilotParams[EVENT_PARAM_ORDER_NUMBER] = orderId?:""
|
||||
BizLoopManager.removeCallback(timeOutRunnable)
|
||||
BizLoopManager.postDelayed(timeOutRunnable,LOOP_PERIOD_15S)
|
||||
RxUtils.disposeSubscribe(timeOutDisposable)
|
||||
timeOutDisposable = RxUtils.createSubscribe(LOOP_PERIOD_15S) {
|
||||
triggerStartAutopilotFailureEvent("", "15s后app等待超时", System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package com.mogo.och.common.module.manager.autopilot.autopilot.bean
|
||||
|
||||
data class SessionWithTime(val sessionId:Long,val setTime:Long)
|
||||
Reference in New Issue
Block a user