[Feat]统一NDE域名
This commit is contained in:
@@ -12,6 +12,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager.V2NC
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.function.biz.dispatch.DispatchAutoPilotManager.Companion.dispatchAutoPilotManager
|
||||
import com.mogo.eagle.function.biz.monitoring.CronTaskManager.Companion.cronTaskManager
|
||||
import com.mogo.eagle.function.biz.nde.NdeNetworkManager
|
||||
import com.mogo.eagle.function.biz.notice.NoticeSocketManager.Companion.noticeSocketManager
|
||||
import com.mogo.eagle.function.biz.notice.network.NoticeNetWorkManager
|
||||
import com.mogo.eagle.function.biz.v2x.busstation.PassBusStationEventManager
|
||||
@@ -52,6 +53,7 @@ class FuncBizProvider : IMoGoFuncBizProvider {
|
||||
V2NIdentifyDrawer.init()
|
||||
// RedLightWarningManager.INSTANCE.listenTrafficLight()
|
||||
V2XEventAnalyticsManager.init()
|
||||
NdeNetworkManager.init()
|
||||
PassBusStationEventManager.init()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.mogo.eagle.function.biz.nde
|
||||
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Headers
|
||||
import retrofit2.http.Query
|
||||
|
||||
const val ROUTE_ADDRESS = "/nde-urlRoute-service/alloc/routeUrlAddr"
|
||||
|
||||
interface INDEApiService {
|
||||
|
||||
@Headers("Content-type:application/json;charset=UTF-8" )
|
||||
@GET(ROUTE_ADDRESS)
|
||||
fun queryNDEHost(@Query("lon") lon: Double, @Query("lat") lat: Double,): BaseResponse<NdeHostResult?>
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mogo.eagle.function.biz.nde
|
||||
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.apiCall
|
||||
import com.mogo.eagle.core.network.cancel
|
||||
import com.mogo.eagle.core.network.request
|
||||
|
||||
class NDEV2NModel private constructor() {
|
||||
|
||||
companion object {
|
||||
val ndeV2NModel by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
NDEV2NModel()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getNetWorkApi(baseUrl: String = HostConst.getNDEHost()): INDEApiService {
|
||||
return MoGoRetrofitFactory.getInstanceNoCallAdapter(baseUrl)
|
||||
.create(INDEApiService::class.java)
|
||||
}
|
||||
|
||||
fun queryNdeHostByLoc(
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
onSuccess: ((NdeHostResult?) -> Unit),
|
||||
onError: ((String) -> Unit)
|
||||
) {
|
||||
request<BaseResponse<NdeHostResult?>>("queryNdeHostByLoc") {
|
||||
loader {
|
||||
apiCall {
|
||||
getNetWorkApi().queryNDEHost(lon, lat)
|
||||
}
|
||||
}
|
||||
onSuccess {
|
||||
onSuccess.invoke(it.result)
|
||||
}
|
||||
onError {
|
||||
onError.invoke(it.message.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun cancelRequest(tag: String) {
|
||||
cancel(tag)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mogo.eagle.function.biz.nde
|
||||
|
||||
data class NdeHostResult(
|
||||
val ip: String?,
|
||||
val host: String?,
|
||||
val port: Int,// 长连接用的
|
||||
val address: String?,
|
||||
val httpAddr: String?// Http请求用的
|
||||
)
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mogo.eagle.function.biz.nde
|
||||
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoCloudConfigListener
|
||||
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.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerCloudConfigListenerManager
|
||||
import com.mogo.eagle.core.utilcode.util.TAG
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import com.zhjt.mogo.adas.data.AdasConstants
|
||||
|
||||
object NdeNetworkManager: IMoGoChassisLocationWGS84Listener, IMoGoCloudConfigListener,
|
||||
IMoGoAutopilotStatusListener {
|
||||
@Volatile
|
||||
private var isFirst = true
|
||||
|
||||
fun init() {
|
||||
// 监听连上域控
|
||||
CallerAutoPilotStatusListenerManager.addListener("${TAG}${this.hashCode()}", this)
|
||||
// 监听发过来的配置信息
|
||||
CallerCloudConfigListenerManager.addListener("${TAG}${this.hashCode()}", this)
|
||||
CallerChassisLocationWGS84ListenerManager.addListener("${TAG}${this.hashCode()}", this)
|
||||
}
|
||||
|
||||
override fun onAutopilotIpcConnectStatusChanged(
|
||||
status: AdasConstants.IpcConnectionStatus,
|
||||
reason: String?
|
||||
) {
|
||||
if (status == AdasConstants.IpcConnectionStatus.CONNECTED) {
|
||||
CallerAutoPilotControlManager.sendCloudConfigRequest()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCloudConfig(config: MessagePad.CloudConfig) {
|
||||
config.addrsList.forEach {
|
||||
if (it.type == 1) {// NDE云
|
||||
HostConst.updateNdeHost(it.domain, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
|
||||
if (gnssInfo.longitude < 0.000001 || gnssInfo.latitude < 0.000001) {
|
||||
return
|
||||
} else {
|
||||
if (isFirst) {
|
||||
isFirst = false
|
||||
if (HostConst.getHostSource() < 0) {
|
||||
NDEV2NModel.ndeV2NModel.queryNdeHostByLoc(gnssInfo.longitude, gnssInfo.latitude, { it->
|
||||
it?.let { result ->
|
||||
if (HostConst.getHostSource() <= 0) {
|
||||
HostConst.updateNdeHost(result.httpAddr, 0)
|
||||
}
|
||||
}
|
||||
}, {})
|
||||
CallerChassisLocationWGS84ListenerManager.removeListener("${TAG}${this.hashCode()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user