董宏宇
2020-10-23 20:22:52 +08:00
parent 5c3134f57d
commit 73896a9484
7 changed files with 182 additions and 25 deletions

View File

@@ -1,5 +1,6 @@
package com.mogo.module.v2x.adapter.holder;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -13,12 +14,16 @@ import com.mogo.module.common.entity.V2XEventShowEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.alarm.V2XEarlyWarningServer;
import com.mogo.module.v2x.scenario.scene.ugc.V2XEventUgcScenario;
import com.mogo.module.v2x.utils.EventTypeUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.module.v2x.voice.V2XVoiceCallbackListener;
import com.mogo.module.v2x.voice.V2XVoiceConstants;
import com.mogo.module.v2x.voice.V2XVoiceManager;
import com.mogo.utils.network.utils.GsonUtil;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* e-mail : 1358506549@qq.com
@@ -30,11 +35,12 @@ import com.mogo.module.v2x.voice.V2XVoiceManager;
* @author donghongyu
*/
public class V2XEventUgcVH extends V2XBaseViewHolder<V2XEventShowEntity> {
private final String TAG = "V2XEventUgcVH";
// 语音控制反馈 YES
private V2XVoiceCallbackListener mFeedBackYes = (command, intent) -> manualMarkingTrafficJam();
private V2XVoiceCallbackListener mFeedBackYes = (command, intent) -> manualMarkingTrafficJam(1);
// 语音控制反馈 NO
private V2XVoiceCallbackListener mFeedBackNo = (command, intent) -> manualMarkingTrafficJam();
private V2XVoiceCallbackListener mFeedBackNo = (command, intent) -> manualMarkingTrafficJam(0);
private ImageView ivEventTypeIcon;
@@ -48,12 +54,6 @@ public class V2XEventUgcVH extends V2XBaseViewHolder<V2XEventShowEntity> {
private V2XEventShowEntity mV2XEventShowEntity;
// 要反馈的道路事件信息
private String eventId = "122";//要反馈的道路事件ID
private int status = 1;//状态1--有用0--没用
private String helpId = "11221";//本车弹窗的时候分享的事件ID如果没用后台应做删除操作
public V2XEventUgcVH(ViewGroup viewGroup) {
super(LayoutInflater.from(viewGroup.getContext())
.inflate(R.layout.item_v2x_event_ugc, viewGroup, false));
@@ -92,6 +92,8 @@ public class V2XEventUgcVH extends V2XBaseViewHolder<V2XEventShowEntity> {
@Override
public void initView(V2XEventShowEntity v2XEventShowEntity) {
try {
Log.w(MODULE_NAME + "_" + TAG, "v2XEventShowEntity=" + GsonUtil.jsonFromObject(v2XEventShowEntity));
if (v2XEventShowEntity == null) {
return;
}
@@ -125,13 +127,13 @@ public class V2XEventUgcVH extends V2XBaseViewHolder<V2XEventShowEntity> {
ivEventReportTrue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manualMarkingTrafficJam();
manualMarkingTrafficJam(1);
}
});
ivEventReportErr.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
manualMarkingTrafficJam();
manualMarkingTrafficJam(0);
}
});
}
@@ -144,14 +146,14 @@ public class V2XEventUgcVH extends V2XBaseViewHolder<V2XEventShowEntity> {
/**
* 对道路事件进行反馈
*/
void manualMarkingTrafficJam() {
void manualMarkingTrafficJam(int status) {
AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice("已反馈", null);
V2XServiceManager
.getV2XRefreshModel()
.manualMarkingTrafficJam(
eventId,
mNoveltyInfo.getInfoId(),
status,
helpId);
"");
delayedCloseWindow();
}

View File

@@ -48,6 +48,8 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
* 这里是车机端自己实现预警信息的触发操作首先获取当前车位置周围2公里范围的道路事件
* 普通模式根据当前「车辆位置」及「行驶方向」判断「车辆前方」「500米」是否有道路事件需要触发。
* 导航模式根据当前「路径规划」及「行驶方向」判断「路径前方」「500米」是否有道路事件需要触发。
* 疲劳驾驶:根据服务端下发的触发条件进行触发
* <p>
* version: 1.0
*/
public class V2XAlarmServer {
@@ -67,6 +69,8 @@ public class V2XAlarmServer {
CopyOnWriteArrayList<V2XRoadEventEntity> v2XRoadEventEntityList,
MogoLocation currentLocation) {
try {
// 检测道路事件是否需UGC问答
V2XEarlyWarningServer.roadEventUgcCheck(currentLocation);
// Logger.w(MODULE_NAME, "V2X预警--车辆状态:" + currentLocation);
// Logger.w(MODULE_NAME, "V2X预警--车辆速度:" + currentLocation.getSpeed());
// Logger.w(MODULE_NAME, "V2X预警--v2XRoadEventEntityList" + GsonUtil.jsonFromObject(v2XRoadEventEntityList));

View File

@@ -0,0 +1,104 @@
package com.mogo.module.v2x.alarm;
import android.content.Intent;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.mogo.map.MogoLatLng;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XRoadEventEntity;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
import com.mogo.module.v2x.utils.EventTypeUtils;
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.service.share.IMogoTanluProvider;
import com.mogo.service.share.TanluUploadParams;
import com.mogo.utils.logger.Logger;
import java.util.Set;
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
/**
* V2X 道路预警服务
*/
public class V2XEarlyWarningServer {
private static final String TAG = "V2XEarlyWarningServer";
/**
* 对提醒过的道路事件进行UGC检测
*
* @param currentLocation 当前车辆位置
*/
public static void roadEventUgcCheck(MogoLocation currentLocation) {
try {
if (currentLocation != null) {
// 循环已经播报的道路事件将刚行驶过的道路事件进行弹窗交互进行UGC问答
Set<V2XRoadEventEntity> keySet = V2XAlarmServer.mAlertRoadEventList.keySet();
for (V2XRoadEventEntity v2XRoadEventEntity : keySet) {
// 计算车辆距离指定气泡的距离
MarkerLocation eventLocation = v2XRoadEventEntity.getLocation();
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
currentLocation.getLongitude(),
currentLocation.getLatitude(),
eventLocation.getLon(),
eventLocation.getLat(),
(int) currentLocation.getBearing()
);
// 判断车辆行驶角度是否与事件相反,相反的话表示已经行驶过去了
if (155 <= eventAngle) {
if (EventTypeUtils.isNeedRoadEventUgc(v2XRoadEventEntity.getPoiType())) {
Logger.w(MODULE_NAME + "_" + TAG, "V2X预警--事件与车头角度夹角过大:" +
"\n角度" + eventAngle + "" +
"\n事件详情" + v2XRoadEventEntity.getNoveltyInfo().getInfoId() +
"\n库存事件" + V2XAlarmServer.mAlertRoadEventList.size()
);
// 弹出UGC
V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioRoadEventUGCData();
// 加载数据源
V2XMessageEntity<V2XRoadEventEntity> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_EVENT_UGC_WARNING);
// 设置数据
v2xMessageEntity.setContent(v2XRoadEventEntity);
// 控制展示状态
v2xMessageEntity.setShowState(true);
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(V2XUtils.getApp()).sendBroadcast(intent);
// 上报事故
TanluUploadParams params =
new TanluUploadParams(
v2XRoadEventEntity.getPoiType(),
IMogoTanluProvider.UPLOAD_FROM_STRATEGY_UGC,
v2XRoadEventEntity.getNoveltyInfo().getInfoIdInt(),
new MogoLatLng(v2XRoadEventEntity.getLocation().getLat(),
v2XRoadEventEntity.getLocation().getLon())
);
V2XServiceManager.getTanluManager().uploadRoadCondition(params);
}
// 移出已经预警的事件列表
V2XAlarmServer.mAlertRoadEventList.remove(v2XRoadEventEntity);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -4,18 +4,43 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.mogo.module.common.entity.V2XMessageEntity
import com.mogo.module.common.entity.V2XRoadEventEntity
import com.mogo.module.v2x.V2XConst
import com.mogo.module.v2x.alarm.V2XEarlyWarningServer
/**
* ugc上报反馈
* http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=42321443
*/
class UgcUploadStatusReceiver : BroadcastReceiver() {
private val TAG = "UgcUploadStatusReceiver"
override fun onReceive(context: Context, intent: Intent) {
if (intent.action == "com.v2x.ugc.upload.status"){
var id = intent.getLongExtra("id", 0)
var type = intent.getStringExtra("type")
var fromType = intent.getStringExtra("fromType")
if (intent.action == "com.v2x.ugc.upload.status") {
val id = intent.getLongExtra("id", 0)
val type = intent.getStringExtra("type")
val fromType = intent.getStringExtra("fromType")
Log.d(V2XConst.MODULE_NAME + "_" + TAG, "后台上传道路事件成功id=$id type=$type fromType=$fromType")
/*
// 由于目前日活不多,所以先采用直接上传的方式,不进行用户反馈删除,
// 先保证用户体验,建议后续还是将分享事件的修改为可以临时存储的方式@李小鹏
// 记录新上传的Ugc事件Id
V2XEarlyWarningServer.ugcEventId = id
// 弹窗
val v2xMessageEntity = V2XMessageEntity<V2XRoadEventEntity>()
// 控制类型
v2xMessageEntity.type = V2XMessageEntity.V2XTypeEnum.ALERT_EVENT_UGC_WARNING
// 设置数据
v2xMessageEntity.content = V2XEarlyWarningServer.currentUgcRoadEvent
// 控制展示状态
v2xMessageEntity.isShowState = true
val intent = Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION)
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity)
LocalBroadcastManager.getInstance(context).sendBroadcast(intent)
*/
}
}
}

View File

@@ -57,14 +57,6 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
V2XRoadEventEntity v2XRoadEventEntity = v2XMessageEntity.getContent();
if (v2XRoadEventEntity != null) {
//只上报事故
// if (v2XRoadEventEntity.getPoiType() != null && v2XRoadEventEntity.getPoiType().equals(MarkerPoiTypeEnum.FOURS_ACCIDENT)) {
//// V2XServiceManager.getMoGoStatusManager().setUploadingStatus(ServiceConst.CARD_TYPE_ROAD_CONDITION, true);
// TanluUploadParams params = new TanluUploadParams(v2XRoadEventEntity.getPoiType(),
// IMogoTanluProvider.UPLOAD_FROM_STRATEGY_ACCIDENT_AUTO);
// V2XServiceManager.getTanluManager().uploadRoadCondition(params);
// }
if (v2XMessageEntity.isShowState()) {
if (!isSameScenario(v2XMessageEntity)) {
// 更新要提醒的数据

View File

@@ -134,6 +134,27 @@ public class EventTypeUtils {
return isRoadEvent;
}
/**
* 是否需要UGC预警
*
* @param poiType
* @return
*/
public static boolean isNeedRoadEventUgc(String poiType) {
boolean isRoadEvent = false;
// 进行类型分发
switch (poiType) {
case V2XPoiTypeEnum.ROAD_CLOSED://封路
case V2XPoiTypeEnum.FOURS_ROAD_WORK://施工
case V2XPoiTypeEnum.FOURS_BLOCK_UP://拥堵
case V2XPoiTypeEnum.FOURS_ACCIDENT://事故
isRoadEvent = true;
break;
}
return isRoadEvent;
}
/**
* 获取 UGC 问答使用的 Title 和 TTS 以及展示图表
*