添加事故相关推送接收以及相关探路接口

This commit is contained in:
tongchenfei
2020-08-14 14:16:06 +08:00
parent 58311d4a6a
commit 154b85c617
10 changed files with 131 additions and 6 deletions

2
.idea/misc.xml generated
View File

@@ -4,7 +4,7 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
</project>

View File

@@ -74,6 +74,7 @@ public class MogoApplication extends AbsMogoApplication {
MogoModulePaths.addBaseModule( new MogoModule( ServiceConst.PATH_REFRESH_STRATEGY, ServiceConst.PATH_REFRESH_STRATEGY ) );
MogoModulePaths.addBaseModule( new MogoModule( V2XConst.PATH_V2X_UI, V2XConst.MODULE_NAME ) );
MogoModulePaths.addBaseModule(new MogoModule( MogoServicePaths.PATH_STRATEGY_SHARE,"StrategyShare"));
MogoModulePaths.addModule( new MogoModule( V2XConst.PATH_EVENT_PANEL, V2XConst.MODULE_NAME_EVENT_PANEL ) );
MogoModulePaths.addModule( new MogoModule( PushUIConstants.PATH, PushUIConstants.NAME ) );

View File

@@ -42,7 +42,8 @@ public class MogoTanluApiProvider implements IMogoTanluProvider {
properties.put("from", params.getFromType());
AnalyticsUtils.track("v2x_share_type", properties);
MainService.Companion.launchService(context, new UploadParams(params.getEventType(),
params.getFromType(), params.getDuration()));
params.getFromType(), params.getDuration(), params.getParentId(),
params.getLocation().lat, params.getLocation().lon));
}else{
throw new IllegalArgumentException("TanluUploadParams 不允许为空");
}

View File

@@ -2,29 +2,37 @@ package com.zhidao.roadcondition.service
import android.os.Parcel
import android.os.Parcelable
import com.mogo.map.MogoLatLng
class UploadParams(val eventType:String,val fromType:String,val duration:Int) : Parcelable {
class UploadParams(val eventType: String, val fromType: String, val duration: Int, val parentId: String, val lat: Double, val lon: Double) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readString()!!,
parcel.readString()!!,
parcel.readInt())
parcel.readInt(),
parcel.readString()!!,
parcel.readDouble(),
parcel.readDouble()
)
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(eventType)
parcel.writeString(fromType)
parcel.writeInt(duration)
parcel.writeString(parentId)
parcel.writeDouble(lat)
parcel.writeDouble(lon)
}
override fun describeContents(): Int {
return 0
}
override fun toString(): String {
return "UploadParams(eventType='$eventType', fromType='$fromType', duration=$duration)"
return "UploadParams(eventType='$eventType', fromType='$fromType', duration=$duration, parentId='$parentId', lat=$lat, lon=$lon)"
}
companion object CREATOR : Parcelable.Creator<UploadParams> {
override fun createFromParcel(parcel: Parcel): UploadParams {
return UploadParams(parcel)

View File

@@ -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))
}
}

View File

@@ -0,0 +1,4 @@
package com.mogo.module.share.constant
const val S_TAG = "StrategyShare"
const val ACCIDENT_STRATEGY_SHARE_PUSH_TYPE = 401013

View File

@@ -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)

View File

@@ -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)))
}
}
}

View File

@@ -238,4 +238,10 @@ public class MogoServicePaths {
*/
@Deprecated
public static final String PATH_TANLU_API = "/tanlulib/api";
/**
* 策略上报
*/
@Deprecated
public static final String PATH_STRATEGY_SHARE = "/strategy/share";
}

View File

@@ -1,5 +1,7 @@
package com.mogo.service.tanlu;
import com.mogo.map.MogoLatLng;
/**
* 探路事件上报参数封装
* @author tongchenfei
@@ -22,6 +24,15 @@ public class TanluUploadParams {
*/
private int duration = IMogoTanluProvider.DEFAULT_VIDEO_DURATION;
/**
* 针对策略上报新增字段用于车辆经过事故事件上报时记录经过的事故事件id
*/
private String parentId = "";
/**
* 针对策略上报新增字段,用于车辆经过事故事件上报时,记录触发围栏时的经纬度坐标
*/
private MogoLatLng location = new MogoLatLng(0, 0);
public TanluUploadParams(String eventType){
this(eventType, IMogoTanluProvider.UPLOAD_FROM_USER);
}
@@ -37,6 +48,21 @@ public class TanluUploadParams {
this.fromType = fromType;
}
/**
* 针对策略上报新增构造方法方便传入parentId和location
* @param eventType 事件类型
* @param fromType 触发类型,是手动还是被动
* @param parentId 经过事件id
* @param location 触发围栏的坐标
*/
public TanluUploadParams(String eventType, String fromType, String parentId,
MogoLatLng location) {
this.eventType = eventType;
this.fromType = fromType;
this.parentId = parentId;
this.location = location;
}
public String getEventType() {
return eventType;
}
@@ -61,6 +87,22 @@ public class TanluUploadParams {
this.duration = duration;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public MogoLatLng getLocation() {
return location;
}
public void setLocation(MogoLatLng location) {
this.location = location;
}
@Override
public String toString() {
return "TanluUploadParams{" +