From 55c37faf061f833e2ce4dd2d0ed3c09e29b9830c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Thu, 6 Aug 2020 18:22:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=E9=92=88=E5=AF=B9?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE=E7=9A=84=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=EF=BC=8C=E4=B8=89=E5=88=86=E9=92=9F=E5=86=85=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=98=AF=E5=8F=AF=E4=BB=A5=E8=A2=AB=E6=B6=88=E8=B4=B9?= =?UTF-8?q?=E6=8E=89=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/V2XMessageListener_401012.java | 77 ++++++++++--------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401012.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401012.java index 3716e804b7..2c794c6e75 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401012.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/listener/V2XMessageListener_401012.java @@ -15,6 +15,7 @@ import com.mogo.module.service.Utils; import com.mogo.module.v2x.V2XConst; import com.mogo.module.v2x.V2XServiceManager; import com.mogo.module.v2x.alarm.V2XAlarmServer; +import com.mogo.module.v2x.utils.TimeConstants; import com.mogo.module.v2x.utils.TimeUtils; import com.mogo.module.v2x.utils.V2XUtils; import com.mogo.service.connection.IMogoOnMessageListener; @@ -42,42 +43,48 @@ public class V2XMessageListener_401012 implements IMogoOnMessageListener 0) { - MarkerExploreWay markerExploreWay = response.getExploreWay().get(0); - MarkerLocation markerLocation = markerExploreWay.getLocation(); - // 记录道路事件 - V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity(); - v2XRoadEventEntity.setLocation(markerLocation); - // 探路目前只有上报拥堵 - v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType()); - // 当前车辆数据 - MogoLocation currentLocation = V2XServiceManager.getV2XStatusManager().getLocation(); - float calculateDistance; - if (currentLocation.getLatitude() > 0 || currentLocation.getLongitude() > 0) { - calculateDistance = Utils.calculateLineDistance( - new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()), - new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude()) - ); - markerExploreWay.setDistance(calculateDistance); + long timeSpan = TimeUtils.getTimeSpan(TimeUtils.getNowMills(), response.getMessageTime(), TimeConstants.MIN); + // 三分钟以内的消息才会提示用户 + if (timeSpan <= 3) { + if (response.getExploreWay() != null && response.getExploreWay().size() > 0) { + MarkerExploreWay markerExploreWay = response.getExploreWay().get(0); + MarkerLocation markerLocation = markerExploreWay.getLocation(); + // 记录道路事件 + V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity(); + v2XRoadEventEntity.setLocation(markerLocation); + // 探路目前只有上报拥堵 + v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType()); + // 当前车辆数据 + MogoLocation currentLocation = V2XServiceManager.getV2XStatusManager().getLocation(); + float calculateDistance; + if (currentLocation.getLatitude() > 0 || currentLocation.getLongitude() > 0) { + calculateDistance = Utils.calculateLineDistance( + new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()), + new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude()) + ); + markerExploreWay.setDistance(calculateDistance); + } + v2XRoadEventEntity.setDistance(markerExploreWay.getDistance()); + v2XRoadEventEntity.setNoveltyInfo(markerExploreWay); + v2XRoadEventEntity.setExpireTime(20000); + + // 记录播报过的道路事件 + V2XAlarmServer.mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString()); + + V2XMessageEntity v2xMessageEntity = new V2XMessageEntity<>(); + // 控制类型 + v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_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); } - v2XRoadEventEntity.setDistance(markerExploreWay.getDistance()); - v2XRoadEventEntity.setNoveltyInfo(markerExploreWay); - v2XRoadEventEntity.setExpireTime(20000); - - // 记录播报过的道路事件 - V2XAlarmServer.mAlertRoadEventList.put(v2XRoadEventEntity, TimeUtils.getNowString()); - - V2XMessageEntity v2xMessageEntity = new V2XMessageEntity<>(); - // 控制类型 - v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_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); + } else { + Logger.e(MODULE_NAME, "V2XMessageListener_401012==V2X服务端下发:消息已过期,大于3分钟了不进行消费"); } } catch (Exception e) { e.printStackTrace();