[2.14.0] add func of line id upload
This commit is contained in:
@@ -1,20 +1,27 @@
|
||||
package com.mogo.eagle.core.function.v2x
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.commons.constants.HostConst.DATA_CENTER_HOST
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.v2x.LineUploadData
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.v2x.events.network.V2XRefreshModel
|
||||
import com.mogo.eagle.core.function.v2x.road.V2XEventServiceApi
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.apiCall
|
||||
import com.mogo.eagle.core.network.request
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class LineUploadManager private constructor(context: Context) {
|
||||
class LineUploadManager private constructor(context: Context) : IMoGoAutopilotStatusListener {
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -43,33 +50,44 @@ class LineUploadManager private constructor(context: Context) {
|
||||
mContext = context
|
||||
}
|
||||
|
||||
private var lineId: Long? by Delegates.observable(
|
||||
CallerAutoPilotStatusListenerManager
|
||||
.getAutoPilotStatusInfo().autopilotControlParameters?.autoPilotLine?.lineId
|
||||
) { _, _, newValue ->
|
||||
CallerLogger.d(TAG, " old line : $lineId , new line : $newValue")
|
||||
lineId = newValue
|
||||
// uploadLine()
|
||||
fun init(){
|
||||
Log.d("emArrow","LineUploadManager addListener")
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
private fun uploadLine() {
|
||||
lineId?.let {
|
||||
val lineUploadData = LineUploadData(it, MoGoAiCloudClientConfig.getInstance().sn)
|
||||
disposable = MoGoRetrofitFactory.getInstance(HostConst.getHost()) //todo 改域名
|
||||
.create(V2XEventServiceApi::class.java)
|
||||
.uploadLineId(lineUploadData)
|
||||
.retry(3)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { data ->
|
||||
CallerLogger.d(TAG, " uploadLine : $data")
|
||||
}
|
||||
private fun getHost(): String {
|
||||
return when (DebugConfig.getNetMode()) {
|
||||
DebugConfig.NET_MODE_DEV, DebugConfig.NET_MODE_QA -> "http://dzt-test.zhidaozhixing.com/"
|
||||
DebugConfig.NET_MODE_RELEASE -> "http://dzt.zhidaozhixing.com/"
|
||||
else -> "http://dzt.zhidaozhixing.com/"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotRouteLineId(lineId: Long) {
|
||||
super.onAutopilotRouteLineId(lineId)
|
||||
if (lineId > 0) {
|
||||
uploadLine(lineId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun uploadLine(lineId: Long) {
|
||||
val lineUploadData = LineUploadData(lineId, MoGoAiCloudClientConfig.getInstance().sn)
|
||||
disposable = MoGoRetrofitFactory.getInstance(DATA_CENTER_HOST)
|
||||
.create(V2XEventServiceApi::class.java)
|
||||
.uploadLineId(lineUploadData)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe ({ data ->
|
||||
Log.d("emArrow", " uploadLine : $data")
|
||||
},{
|
||||
Log.d("emArrow", "e : ${it.message}")
|
||||
})
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
mContext = null
|
||||
disposable?.dispose()
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,10 @@ class V2XProvider : IV2XEventProvider {
|
||||
SpeedLimitDataManager.getInstance().start()
|
||||
TrafficLightDispatcher.INSTANCE.initServer(context)
|
||||
SpeedLimitDispatcher.INSTANCE.initLimit(context)
|
||||
LineUploadManager.getInstance(context)
|
||||
|
||||
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){
|
||||
LineUploadManager.getInstance(context)?.init()
|
||||
}
|
||||
|
||||
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) && AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) {
|
||||
//不处理
|
||||
@@ -52,9 +55,13 @@ class V2XProvider : IV2XEventProvider {
|
||||
} else {
|
||||
V2XEventManager.onDestroy()
|
||||
}
|
||||
mContext?.let {
|
||||
LineUploadManager.getInstance(it)?.onDestroy()
|
||||
|
||||
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){
|
||||
mContext?.let {
|
||||
LineUploadManager.getInstance(it)?.onDestroy()
|
||||
}
|
||||
}
|
||||
|
||||
// RedLightWarningManager.INSTANCE.onDestroy()
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.function.v2x.road
|
||||
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.v2x.LineUploadData
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.*
|
||||
@@ -11,7 +12,7 @@ interface V2XEventServiceApi {
|
||||
fun queryAllV2XEventsByLineId(@Query("lineId") lineId: String, @Query("sn") sn: String): Observable<V2XEventResult>
|
||||
|
||||
@Headers("Content-type:application/json;charset=UTF-8" )
|
||||
@POST( "" )
|
||||
@POST( "/yycp-data-center-service/carTrack/receiveCarTrack/")
|
||||
fun uploadLineId(@Body lineId: LineUploadData): Observable<BaseData>
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user