From 154b85c617a5099975e9f197f30b0aa2bbd77659 Mon Sep 17 00:00:00 2001 From: tongchenfei Date: Fri, 14 Aug 2020 14:16:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=8B=E6=95=85=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A8=E9=80=81=E6=8E=A5=E6=94=B6=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A2=E8=B7=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- .../com/mogo/launcher/MogoApplication.java | 1 + .../mogo/tanlu/api/MogoTanluApiProvider.java | 3 +- .../roadcondition/service/UploadParams.kt | 16 +++++-- .../module/share/StrategyShareProvider.kt | 27 ++++++++++++ .../share/constant/StrategyShareConst.kt | 4 ++ .../AccidentStrategyPushWrapper.kt | 11 +++++ .../AccidentStrategyReceiver.kt | 25 +++++++++++ .../com/mogo/service/MogoServicePaths.java | 6 +++ .../mogo/service/tanlu/TanluUploadParams.java | 42 +++++++++++++++++++ 10 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt create mode 100644 modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/StrategyShareConst.kt create mode 100644 modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyPushWrapper.kt create mode 100644 modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyReceiver.kt diff --git a/.idea/misc.xml b/.idea/misc.xml index 21e99e2dc0..cd77a1f062 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index 99cd7e7447..da2288e735 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -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 ) ); diff --git a/libraries/mogo-tanlu-api/src/main/java/com/zhidao/mogo/tanlu/api/MogoTanluApiProvider.java b/libraries/mogo-tanlu-api/src/main/java/com/zhidao/mogo/tanlu/api/MogoTanluApiProvider.java index 44f60ecab8..9342e15065 100644 --- a/libraries/mogo-tanlu-api/src/main/java/com/zhidao/mogo/tanlu/api/MogoTanluApiProvider.java +++ b/libraries/mogo-tanlu-api/src/main/java/com/zhidao/mogo/tanlu/api/MogoTanluApiProvider.java @@ -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 不允许为空"); } diff --git a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/UploadParams.kt b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/UploadParams.kt index 690b2ec53e..75797e8bda 100644 --- a/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/UploadParams.kt +++ b/libraries/tanlulib/src/main/java/com/zhidao/roadcondition/service/UploadParams.kt @@ -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 { override fun createFromParcel(parcel: Parcel): UploadParams { return UploadParams(parcel) diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt new file mode 100644 index 0000000000..eb49f7af20 --- /dev/null +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/StrategyShareProvider.kt @@ -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)) + } +} \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/StrategyShareConst.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/StrategyShareConst.kt new file mode 100644 index 0000000000..014701a56d --- /dev/null +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/constant/StrategyShareConst.kt @@ -0,0 +1,4 @@ +package com.mogo.module.share.constant + +const val S_TAG = "StrategyShare" +const val ACCIDENT_STRATEGY_SHARE_PUSH_TYPE = 401013 \ No newline at end of file diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyPushWrapper.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyPushWrapper.kt new file mode 100644 index 0000000000..98779716f9 --- /dev/null +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyPushWrapper.kt @@ -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) diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyReceiver.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyReceiver.kt new file mode 100644 index 0000000000..7ed36e0f56 --- /dev/null +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/AccidentStrategyReceiver.kt @@ -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 { + override fun target(): Class = 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))) + } + } +} \ No newline at end of file diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java b/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java index d2366e3c2c..576821ada1 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/MogoServicePaths.java @@ -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"; } diff --git a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/TanluUploadParams.java b/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/TanluUploadParams.java index 72cd49df3d..802e883c40 100644 --- a/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/TanluUploadParams.java +++ b/services/mogo-service-api/src/main/java/com/mogo/service/tanlu/TanluUploadParams.java @@ -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{" +