策略上报:自动拥堵 接口调整
This commit is contained in:
@@ -3,4 +3,4 @@ package com.mogo.module.share.bean
|
||||
import com.mogo.commons.data.BaseData
|
||||
|
||||
data class AverateSpeedResponse(var result:Result):BaseData()
|
||||
data class Result(var upload:Boolean)
|
||||
data class Result(var upload:Boolean,var poiType:String)
|
||||
|
||||
@@ -22,5 +22,5 @@ interface ShareApiService {
|
||||
*/
|
||||
@Headers("Content-type:application/json;charset=UTF-8")
|
||||
@POST("/deva/car/path/no/poiStrategyCheck/v1")
|
||||
fun sendAverageSpeedForBlockStrategy(@Body request:RequestBody):Observable<AverateSpeedResponse>
|
||||
fun sendAverageSpeedForBlockStrategy(@Body request:RequestBody,@Query("sn") sn:String):Observable<AverateSpeedResponse>
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.os.SystemClock
|
||||
import android.util.ArrayMap
|
||||
import com.mogo.commons.network.SubscribeImpl
|
||||
import com.mogo.commons.network.Utils
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.module.share.bean.AverateSpeedResponse
|
||||
import com.mogo.module.share.constant.HttpConstant
|
||||
@@ -12,6 +13,7 @@ import com.mogo.module.share.net.ShareApiService
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.tanlu.IMogoTanluProvider
|
||||
import com.mogo.service.tanlu.TanluUploadParams
|
||||
import com.mogo.utils.DeviceIdUtils
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.mogo.utils.network.RequestOptions
|
||||
import com.mogo.utils.network.utils.GsonUtil
|
||||
@@ -92,17 +94,17 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService
|
||||
}
|
||||
|
||||
private fun uploadAverageSpeed(average: Float) {
|
||||
val params = ArrayMap<String, String>()
|
||||
params["speed"] = average.toString()
|
||||
val params = ArrayMap<String, Any>()
|
||||
params["speed"] = average.toInt()
|
||||
val body = RequestBody.create(MediaType.parse("Content-type:application/json;charset=UTF-8"), GsonUtil.jsonFromObject(params))
|
||||
val disposable = apis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendAverageSpeedForBlockStrategy(body).subscribeOn(Schedulers.io()).subscribe(object : SubscribeImpl<AverateSpeedResponse>(RequestOptions.create(context)) {
|
||||
val disposable = apis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendAverageSpeedForBlockStrategy(body, Utils.getSn()).subscribeOn(Schedulers.io()).subscribe(object : SubscribeImpl<AverateSpeedResponse>(RequestOptions.create(context)) {
|
||||
override fun onSuccess(response: AverateSpeedResponse?) {
|
||||
super.onSuccess(response)
|
||||
response?.let {
|
||||
Logger.d(TAG, "收到服务端返回结果: $it")
|
||||
// 收到服务端回调,视情况进行视频上报
|
||||
if (it.result.upload) {
|
||||
val p = TanluUploadParams(IMogoTanluProvider.TYPE_BLOCK, IMogoTanluProvider.UPLOAD_FROM_STRATEGY_BLOCK_AUTO)
|
||||
val p = TanluUploadParams(it.result.poiType, IMogoTanluProvider.UPLOAD_FROM_STRATEGY_BLOCK_AUTO)
|
||||
val location = ServiceApisManager.serviceApis.mapServiceApi.getSingletonLocationClient(context).lastKnowLocation
|
||||
val latLon = MogoLatLng(location.latitude, location.longitude)
|
||||
p.location = latLon
|
||||
|
||||
Reference in New Issue
Block a user