[2.13.2][feat]V2X事件汇总的消息加入消息盒子
This commit is contained in:
@@ -4,7 +4,7 @@ import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_V2X_MODULE
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider
|
||||
import com.mogo.eagle.core.function.api.v2x.IV2XEventProvider
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightManager
|
||||
import com.mogo.eagle.core.function.v2x.events.V2XEventManager
|
||||
import com.mogo.eagle.core.function.v2x.speedlimit.SpeedLimitDataManager
|
||||
@@ -13,7 +13,7 @@ import com.mogo.eagle.core.function.v2x.vip.VipCarManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
|
||||
@Route(path = PATH_V2X_MODULE)
|
||||
class V2XProvider : IMoGoFunctionServerProvider {
|
||||
class V2XProvider : IV2XEventProvider {
|
||||
|
||||
override val functionName: String
|
||||
get() = "V2XProvider"
|
||||
@@ -33,6 +33,10 @@ class V2XProvider : IMoGoFunctionServerProvider {
|
||||
// RedLightWarningManager.INSTANCE.listenTrafficLight()
|
||||
}
|
||||
|
||||
override fun queryWholeRoadEvents() {
|
||||
V2XEventManager.queryWholeRoadEvents()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
VipCarManager.INSTANCE.destroy()
|
||||
TrafficLightDispatcher.INSTANCE.destroy()
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.mogo.eagle.core.function.v2x.events
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.*
|
||||
import android.os.*
|
||||
import android.provider.Settings.System
|
||||
import android.util.*
|
||||
import androidx.localbroadcastmanager.content.*
|
||||
import com.mogo.cloud.commons.utils.*
|
||||
import com.mogo.cloud.passport.*
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.commons.module.ServiceConst.CARD_TYPE_ROAD_CONDITION
|
||||
import com.mogo.commons.module.status.IMogoStatusChangedListener
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
@@ -25,6 +24,7 @@ import com.mogo.eagle.core.data.map.entity.MarkerExploreWay
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.data.msgbox.DataSourceType
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg
|
||||
@@ -32,6 +32,7 @@ import com.mogo.eagle.core.data.traffic.*
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.*
|
||||
import com.mogo.eagle.core.function.api.map.listener.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
@@ -61,6 +62,8 @@ import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerCardResult
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XOptimalRoute
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XWarningTarget
|
||||
import com.mogo.eagle.core.function.v2x.internal.event.V2XEvent
|
||||
import com.mogo.eagle.core.function.v2x.road.V2XEventServiceApi
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.utils.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
@@ -76,6 +79,9 @@ import com.shuyu.gsyvideoplayer.model.*
|
||||
import com.shuyu.gsyvideoplayer.player.*
|
||||
import com.shuyu.gsyvideoplayer.utils.*
|
||||
import com.zhjt.service.chain.*
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.android.*
|
||||
import mogo.telematics.pad.MessagePad
|
||||
@@ -98,6 +104,8 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
// 记录历史行驶轨迹,用于车行驶方向计算,只保留两个数据
|
||||
private val historyPath = arrayOfNulls<MogoLocation>(2)
|
||||
|
||||
var v2xEventDisposable: Disposable? = null
|
||||
|
||||
fun init(context: Context) {
|
||||
BridgeApi.init(context)
|
||||
if (hasInit.compareAndSet(false, true)) {
|
||||
@@ -674,6 +682,63 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
}
|
||||
}
|
||||
|
||||
fun queryWholeRoadEvents() {
|
||||
if (v2xEventDisposable != null && !v2xEventDisposable!!.isDisposed) {
|
||||
v2xEventDisposable!!.dispose()
|
||||
}
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
val lineId = getLineId()
|
||||
if (lineId > 0) {
|
||||
realQueryV2xEvents(lineId.toString(), sn)
|
||||
} else {
|
||||
UiThreadHandler.postDelayed({
|
||||
realQueryV2xEvents(getLineId().toString(), sn)
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
|
||||
private fun realQueryV2xEvents(lineId: String, sn: String) {
|
||||
v2xEventDisposable = MoGoRetrofitFactory.getInstance(HostConst.getHost())
|
||||
.create(V2XEventServiceApi::class.java)
|
||||
.queryAllV2XEventsByLineId(lineId, sn)
|
||||
.map {
|
||||
if (it.code == 200 || it.code == 0) {
|
||||
CallerLogger.d(M_V2X + TAG, "请求成功,size为:${it.result?.v2XEventList?.size}")
|
||||
return@map it.result?.v2XEventList
|
||||
} else {
|
||||
CallerLogger.d(M_V2X + TAG, "请求失败,code为:${it.code}")
|
||||
return@map ArrayList()
|
||||
}
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
val size = it?.size ?: 0
|
||||
if (size > 0) {
|
||||
val msgBoxBean = MsgBoxBean(MsgBoxType.V2X, V2XMsg("", "查询到当前全程共${size}个事件", ""))
|
||||
msgBoxBean.sourceType = DataSourceType.SUMMARY
|
||||
CallerMsgBoxManager.saveMsgBox(msgBoxBean)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getLineId(): Long {
|
||||
var lineId: Long = -1
|
||||
val parameter = CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo()
|
||||
.autopilotControlParameters
|
||||
if (parameter != null) {
|
||||
if (parameter.autoPilotLine != null) {
|
||||
lineId = parameter.autoPilotLine!!.lineId
|
||||
CallerLogger.d(M_V2X + TAG, "lineId为:$lineId")
|
||||
} else {
|
||||
CallerLogger.d(M_V2X + TAG, "parameter.autoPilotLine为null")
|
||||
}
|
||||
} else {
|
||||
CallerLogger.d(M_V2X + TAG, "parameter为null")
|
||||
}
|
||||
return lineId
|
||||
}
|
||||
|
||||
override fun onFail(msg: String) {
|
||||
CallerLogger.e("$M_V2X$TAG", "Error: $msg")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.mogo.eagle.core.function.v2x.road
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
|
||||
|
||||
@Keep
|
||||
data class V2XEventResult (
|
||||
@SerializedName("result")
|
||||
var result: Result?
|
||||
): BaseData()
|
||||
|
||||
@Keep
|
||||
data class Result(
|
||||
@SerializedName("eventList")
|
||||
var v2XEventList: List<V2XEvent>?
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class V2XEvent(
|
||||
@SerializedName("receiveTime")
|
||||
var receiveTime: Long,
|
||||
|
||||
@SerializedName("detectTime")
|
||||
var detectTime: Long,
|
||||
|
||||
@SerializedName("id")
|
||||
var id: String?,
|
||||
|
||||
@SerializedName("center")
|
||||
var center: Center?,
|
||||
|
||||
@SerializedName("centerRoad")
|
||||
var centerRoad: CenterRoad?,
|
||||
|
||||
@SerializedName("radius")
|
||||
var radius: Double,
|
||||
|
||||
@SerializedName("poiType")
|
||||
var poiType: String?
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class Center(
|
||||
@SerializedName("lat")
|
||||
var lat: Double,
|
||||
|
||||
@SerializedName("lon")
|
||||
var lon: Double
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class CenterRoad(
|
||||
@SerializedName("bearing")
|
||||
var bearing: Double,
|
||||
|
||||
@SerializedName("laneNo")
|
||||
var laneNo: Long,
|
||||
|
||||
@SerializedName("roadId")
|
||||
var roadId: String?,
|
||||
|
||||
@SerializedName("roadName")
|
||||
var roadName: String?,
|
||||
|
||||
@SerializedName("tileId")
|
||||
var tileId: Long
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.eagle.core.function.v2x.road
|
||||
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Query
|
||||
|
||||
interface V2XEventServiceApi {
|
||||
|
||||
@GET("/eagleEye-mis/config/queryV2NInformation")
|
||||
fun queryAllV2XEventsByLineId(@Query("lineId") lineId: String, @Query("sn") sn: String): Observable<V2XEventResult>
|
||||
}
|
||||
Reference in New Issue
Block a user