添加事故相关推送接收以及相关探路接口
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.share
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.facade.template.IProvider
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.module.share.constant.ACCIDENT_STRATEGY_SHARE_PUSH_TYPE
|
||||
import com.mogo.module.share.constant.S_TAG
|
||||
import com.mogo.module.share.strategyreceiver.AccidentStrategyReceiver
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.MogoServicePaths
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
/**
|
||||
* 策略上报入口,服务端策略上报Push的接收地,接收后再调用tanlu相关接口进行视频抓取
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_STRATEGY_SHARE)
|
||||
class StrategyShareProvider : IProvider {
|
||||
override fun init(context: Context?) {
|
||||
Logger.d(S_TAG, "策略上报Provider初始化====")
|
||||
val apis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis
|
||||
// 注册事故
|
||||
apis.getSocketManagerApi(context).registerOnMessageListener(ACCIDENT_STRATEGY_SHARE_PUSH_TYPE, AccidentStrategyReceiver(apis))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.mogo.module.share.constant
|
||||
|
||||
const val S_TAG = "StrategyShare"
|
||||
const val ACCIDENT_STRATEGY_SHARE_PUSH_TYPE = 401013
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.module.share.strategyreceiver
|
||||
|
||||
data class AccidentStrategyPushWrapper(
|
||||
/**
|
||||
* 策略类型,1代表事故
|
||||
*/
|
||||
val type: Int,
|
||||
/**
|
||||
* 触发点的poiType
|
||||
*/
|
||||
val id: String, val lat: Double, val lon: Double)
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mogo.module.share.strategyreceiver
|
||||
|
||||
import com.mogo.map.MogoLatLng
|
||||
import com.mogo.module.share.constant.S_TAG
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.service.connection.IMogoOnMessageListener
|
||||
import com.mogo.service.tanlu.IMogoTanluProvider
|
||||
import com.mogo.service.tanlu.TanluUploadParams
|
||||
import com.mogo.utils.logger.Logger
|
||||
|
||||
/**
|
||||
* 车辆经过事故事件,上报视频
|
||||
* @author tong
|
||||
*/
|
||||
class AccidentStrategyReceiver(private val apis: IMogoServiceApis):IMogoOnMessageListener<AccidentStrategyPushWrapper> {
|
||||
override fun target(): Class<AccidentStrategyPushWrapper> = AccidentStrategyPushWrapper::class.java
|
||||
|
||||
override fun onMsgReceived(obj: AccidentStrategyPushWrapper?) {
|
||||
obj?.let {
|
||||
Logger.d(S_TAG, "Accident strategy share onMessageReceived: $obj")
|
||||
// 调用探路接口上报,现在只接入了事故事件上报这一种策略上报,所以poiType固定为TypeAccident
|
||||
apis.tanluApi.uploadRoadCondition(TanluUploadParams(IMogoTanluProvider.TYPE_ACCIDENT, IMogoTanluProvider.UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO, it.id, MogoLatLng(it.lat, it.lon)))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user