Merge branch 'dev_arch_opt_3.0' into dev_robosweeper-d_app-module_221230_1.1.0
# Conflicts: # core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/report/IPCReportManager.kt
This commit is contained in:
@@ -12,6 +12,7 @@ class AiCloudSocketBizProvider : IMoGoFunctionServerProvider {
|
||||
get() = "AiCloudSocketBizProvider"
|
||||
|
||||
override fun init(context: Context?) {
|
||||
//todo bus加载
|
||||
context?.let {
|
||||
SocketManager.getInstance().init(it, 0.0, 0.0)
|
||||
SocketManager.getInstance().registerOnMessageListener(401012, V2XMessageListener401012())
|
||||
|
||||
@@ -134,8 +134,6 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
|
||||
if (gnssInfo != null) {
|
||||
if (1 == FunctionBuildConfig.gpsProvider) {
|
||||
// 同步给MAP地图
|
||||
//CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(gnssInfo)
|
||||
// 同步更新经纬度和系统时间至 AutoPilotStatusListener
|
||||
CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(
|
||||
gnssInfo.satelliteTime,
|
||||
@@ -146,7 +144,6 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 老底盘信息,透传底盘状态,pb参考底盘
|
||||
* TODO 目前由于M1车型不会在新底盘PB添加新的字段 所以临时保留
|
||||
@@ -369,7 +366,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
//他车轨迹预测
|
||||
}
|
||||
|
||||
override fun onPointCloud(pointCloud: ByteArray?) {
|
||||
override fun onPointCloud(header: MessagePad.Header, pointCloud: ByteArray?) {
|
||||
//点云数据透传
|
||||
CallerAutopilotPointCloudListenerManager.invokeAutopilotPointCloudDataUpdate(pointCloud)
|
||||
}
|
||||
@@ -595,6 +592,16 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
) {
|
||||
|
||||
}
|
||||
/**
|
||||
* 清扫车后部摄像头视频 10Hz
|
||||
*
|
||||
* @param header 头
|
||||
* @param data 数据
|
||||
*/
|
||||
override fun onBackCameraVideo(header: MessagePad.Header, data: ByteArray) {
|
||||
CallerSweeperFutianBackCameraVideoListenerManager.invokeSweeperFutianBackCameraVideo(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 清扫车指标数据
|
||||
*
|
||||
|
||||
@@ -6,8 +6,6 @@ import com.mogo.eagle.core.data.constants.MoGoConfig
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.data.obu.MogoObuConst
|
||||
import com.mogo.eagle.core.function.api.datacenter.obu.IMoGoObuProvider
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.CommonUtils
|
||||
|
||||
@@ -24,13 +22,12 @@ class MoGoObuProvider : IMoGoObuProvider {
|
||||
get() = TAG
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
MogoObuDcCombineManager.INSTANCE.destoryListener()
|
||||
}
|
||||
|
||||
override fun init(context: Context) {
|
||||
//obu融合数据
|
||||
MogoObuDcCombineManager.INSTANCE.init(context)
|
||||
CallerLogger.d("$M_OBU$TAG", "初始化蘑菇自研OBU…… localIp = " + CommonUtils.getLocalIPAddress())
|
||||
|
||||
//bus乘客版本obu功能去掉,大理项目需要全部车辆接收,不再限制
|
||||
mContext = context
|
||||
|
||||
@@ -56,19 +56,27 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
}
|
||||
|
||||
override fun onMoGoObuRsiWarning(rsiWarningData: ObuScene.RsiWarningData) {
|
||||
onMogoObuDcRsiWarning(rsiWarningData)
|
||||
if (HmiBuildConfig.isShowObuV2iView) {
|
||||
onMogoObuDcRsiWarning(rsiWarningData)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoGoObuRsmWarning(rsmWarningData: ObuScene.RsmWarningData) {
|
||||
onMogoObuDcRsmWarning(rsmWarningData)
|
||||
if (HmiBuildConfig.isShowObuV2iView) {
|
||||
onMogoObuDcRsmWarning(rsmWarningData)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoGoObuSpatWarning(spatWarningData: ObuScene.SpatWarningData) {
|
||||
onMogoObuDcSpatWarning(spatWarningData)
|
||||
if (HmiBuildConfig.isShowObuV2iView) {
|
||||
onMogoObuDcSpatWarning(spatWarningData)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoGoObuMapMath(mapMatchData: ObuScene.MapMatchData) {
|
||||
onMogoObuMapMath(mapMatchData)
|
||||
if (HmiBuildConfig.isShowObuV2iView) {
|
||||
onMogoObuMapMath(mapMatchData)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,13 +127,13 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
ttsContent = EventTypeEnumNew.getWarningTts(appId)
|
||||
alertContent = String.format( //事件才有影响范围
|
||||
alertContent,
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(),
|
||||
Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString()
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance).toString(),
|
||||
Math.round(rsiWarningData.warningMsgList[0].eventRadius).toString()
|
||||
)
|
||||
ttsContent = String.format(
|
||||
ttsContent,
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(),
|
||||
Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString()
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance).toString(),
|
||||
Math.round(rsiWarningData.warningMsgList[0].eventRadius).toString()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -202,11 +210,11 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
ttsContent = EventTypeEnumNew.getWarningTts(appId)
|
||||
alertContent = String.format( //标牌是没有影响范围的
|
||||
alertContent,
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString()
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance).toString()
|
||||
)
|
||||
ttsContent = String.format(
|
||||
ttsContent,
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString()
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance).toString()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -217,13 +225,13 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
ttsContent = EventTypeEnumNew.getWarningTts(appId)
|
||||
alertContent = String.format( //事件才有影响范围
|
||||
alertContent,
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(),
|
||||
Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString()
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance).toString(),
|
||||
Math.round(rsiWarningData.warningMsgList[0].eventRadius).toString()
|
||||
)
|
||||
ttsContent = String.format(
|
||||
ttsContent,
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance / 100.0).toString(),
|
||||
Math.round(rsiWarningData.warningMsgList[0].eventRadius / 10.0).toString()
|
||||
Math.round(rsiWarningData.warningMsgList[0].distance).toString(),
|
||||
Math.round(rsiWarningData.warningMsgList[0].eventRadius).toString()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -237,16 +245,18 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
|
||||
CallerLogger.d(
|
||||
"${M_OBU}${TAG}",
|
||||
"MogoObuDcCombineManager ttsContent = $ttsContent --alertContent = $alertContent --appId = $appId ---direction = ${direction.direction} --distance = ${rsiWarningData.warningMsgList[0].distance} ---eventRadius = ${rsiWarningData.warningMsgList[0].eventRadius} --speedMaxLimit = ${rsiWarningData.warningMsgList[0].speedMaxLimit}"
|
||||
)
|
||||
"MogoObuDcCombineManager ttsContent = $ttsContent --alertContent = $alertContent --appId = $appId ---direction = ${direction.direction} --distance = ${rsiWarningData.warningMsgList[0].distance} ---eventRadius = ${rsiWarningData.warningMsgList[0].eventRadius} --speedMaxLimit = ${rsiWarningData.warningMsgList[0].speedMaxLimit}")
|
||||
when (status) {
|
||||
// 添加
|
||||
MogoObuConstants.STATUS.ADD -> {
|
||||
if (alertContent.isEmpty() || ttsContent.isEmpty()) {
|
||||
return
|
||||
}
|
||||
saveObuToDcData(appId, alertContent, ttsContent)
|
||||
showWarning(appId, alertContent, ttsContent, direction)
|
||||
//大于10m,才提示rsi
|
||||
if (Math.round(rsiWarningData.warningMsgList[0].distance) > 10) {
|
||||
saveObuToDcData(appId, alertContent, ttsContent)
|
||||
showWarning(appId, alertContent, ttsContent, direction)
|
||||
}
|
||||
}
|
||||
|
||||
MogoObuConstants.STATUS.UPDATE -> { // 更新
|
||||
@@ -380,33 +390,31 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
* 地图匹配 是OBU算法输出地图匹配结果,主车匹配道路哪条路或者哪条车道
|
||||
*/
|
||||
fun onMogoObuMapMath(data: ObuScene.MapMatchData?) {
|
||||
if (HmiBuildConfig.isShowObuLimitSpeedView) {
|
||||
if (data != null) {
|
||||
CallerLogger.d(
|
||||
"${M_OBU}${TAG}",
|
||||
"MogoObuDcCombineManager onMogoObuMapMath = ${data.status} --speedMaxLimit = ${
|
||||
Math.round(
|
||||
(data.speedMaxLimit * 0.02 * 3.6)
|
||||
)
|
||||
} --- data.speedMaxLimit = ${data.speedMaxLimit}"
|
||||
)
|
||||
when (data.status) {
|
||||
MogoObuConstants.STATUS.ADD -> { // 添加
|
||||
CallerLimitingVelocityListenerManager.invokeUnion(
|
||||
(data.speedMaxLimit * 0.02 * 3.6).roundToInt().toInt(),
|
||||
DataSourceType.OBU
|
||||
)
|
||||
}
|
||||
if (data != null) {
|
||||
CallerLogger.d(
|
||||
"${M_OBU}${TAG}",
|
||||
"MogoObuDcCombineManager onMogoObuMapMath = ${data.status} --speedMaxLimit = ${
|
||||
Math.round(
|
||||
(data.speedMaxLimit * 3.6)
|
||||
)
|
||||
} --- data.speedMaxLimit = ${data.speedMaxLimit}"
|
||||
)
|
||||
when (data.status) {
|
||||
MogoObuConstants.STATUS.ADD -> { // 添加
|
||||
CallerLimitingVelocityListenerManager.invokeUnion(
|
||||
(data.speedMaxLimit * 3.6).roundToInt(),
|
||||
DataSourceType.OBU
|
||||
)
|
||||
}
|
||||
|
||||
MogoObuConstants.STATUS.UPDATE -> { // 更新
|
||||
}
|
||||
MogoObuConstants.STATUS.UPDATE -> { // 更新
|
||||
}
|
||||
|
||||
MogoObuConstants.STATUS.DELETE -> { // 删除
|
||||
CallerLimitingVelocityListenerManager.invokeUnion(
|
||||
-1,
|
||||
DataSourceType.OBU
|
||||
)
|
||||
}
|
||||
MogoObuConstants.STATUS.DELETE -> { // 删除
|
||||
CallerLimitingVelocityListenerManager.invokeUnion(
|
||||
-1,
|
||||
DataSourceType.OBU
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -521,15 +529,15 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
"MogoObuDcCombineManager 绿波通行引导 --------> speed_min = ${currentLight.suggestMinSpeed} --speed_max = ${currentLight.suggestMaxSpeed}"
|
||||
)
|
||||
val adviceSpeed =
|
||||
"${Math.round(currentLight.suggestMinSpeed * 3.6 * 0.02)} - ${
|
||||
"${Math.round(currentLight.suggestMinSpeed * 3.6)} - ${
|
||||
Math.round(
|
||||
currentLight.suggestMaxSpeed * 3.6 * 0.02
|
||||
currentLight.suggestMaxSpeed * 3.6
|
||||
)
|
||||
}"
|
||||
val adviceSpeedTts =
|
||||
"${Math.round(currentLight.suggestMinSpeed * 3.6 * 0.02)} - ${
|
||||
"${Math.round(currentLight.suggestMinSpeed * 3.6)} - ${
|
||||
Math.round(
|
||||
currentLight.suggestMaxSpeed * 3.6 * 0.02
|
||||
currentLight.suggestMaxSpeed * 3.6
|
||||
)
|
||||
}"
|
||||
|
||||
@@ -566,7 +574,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
}
|
||||
// 红灯
|
||||
2, 3 -> {
|
||||
val red = (currentLight.countDown / 10).toInt()
|
||||
val red = currentLight.countDown.toInt()
|
||||
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
|
||||
TrafficLightEnum.RED,
|
||||
red,
|
||||
@@ -575,7 +583,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
}
|
||||
// 绿灯
|
||||
4, 5, 6 -> {
|
||||
val green = (currentLight.countDown / 10).toInt()
|
||||
val green = currentLight.countDown.toInt()
|
||||
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
|
||||
TrafficLightEnum.GREEN,
|
||||
green,
|
||||
@@ -584,7 +592,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
}
|
||||
// 黄灯
|
||||
7, 8 -> {
|
||||
val yellow = (currentLight.countDown / 10).toInt()
|
||||
val yellow = currentLight.countDown.toInt()
|
||||
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
|
||||
TrafficLightEnum.YELLOW,
|
||||
yellow,
|
||||
|
||||
@@ -407,6 +407,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
|
||||
alertContent = EventTypeEnumNew.getWarningContent(appId)
|
||||
ttsContent = EventTypeEnumNew.getWarningTts(appId)
|
||||
|
||||
alertContent = String.format( //标牌是没有影响范围的
|
||||
alertContent,
|
||||
Math.round(data.warningMsgList[0].distance).toString()
|
||||
@@ -455,8 +456,11 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
if (alertContent.isEmpty() || ttsContent.isEmpty()) {
|
||||
return
|
||||
}
|
||||
saveObuData(appId, alertContent, ttsContent)
|
||||
showWarning(appId, alertContent, ttsContent, direction)
|
||||
//大于10m,才提示rsi
|
||||
if (Math.round(data.warningMsgList[0].distance) > 10) {
|
||||
saveObuData(appId, alertContent, ttsContent)
|
||||
showWarning(appId, alertContent, ttsContent, direction)
|
||||
}
|
||||
|
||||
// 更新数据
|
||||
TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data)
|
||||
@@ -661,7 +665,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
|
||||
/**
|
||||
* 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示
|
||||
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截
|
||||
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容
|
||||
* @see com.mogo.module.common.enums.EventTypeEnumNew
|
||||
* EventTypeEnumNew在定义的id为了防止重复,和原始数据是不一样的,有对应关系
|
||||
*/
|
||||
@@ -806,7 +810,6 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType)
|
||||
v2xType = EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
when (status) {
|
||||
|
||||
@@ -50,9 +50,11 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
|
||||
private var mContext: Context? = null
|
||||
|
||||
//是否有AI获取红绿灯灯态
|
||||
@Volatile
|
||||
private var hasAiLightStatus: Boolean = false
|
||||
|
||||
//obu数据
|
||||
@Volatile
|
||||
private var hasObuLightStatus: Boolean = false
|
||||
|
||||
fun initServer(context: Context) {
|
||||
|
||||
@@ -1,26 +1,35 @@
|
||||
package com.mogo.eagle.core.function.msgbox
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Looper
|
||||
import com.mogo.eagle.core.data.deva.report.ReportEntity
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.msgbox.*
|
||||
import com.mogo.eagle.core.data.deva.report.ReportEntity
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxListenerManager
|
||||
import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb
|
||||
import com.mogo.eagle.core.function.msgbox.db.MsgBoxInfo
|
||||
import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ProcessUtils
|
||||
import com.mogo.eagle.core.utilcode.util.SPUtils
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
object DataManager {
|
||||
|
||||
// private val msgBoxMap: EnumMap<MsgBoxType, MutableList<MsgBoxBean>> = EnumMap(MsgBoxType::class.java)
|
||||
|
||||
const val TAG = "DataManager"
|
||||
|
||||
// 消失时间5000ms
|
||||
const val DISMISS_TIME = 5000L
|
||||
|
||||
@@ -148,6 +157,10 @@ object DataManager {
|
||||
* 从本地数据库中查询数据
|
||||
*/
|
||||
fun queryAllMessages(context: Context) {
|
||||
if (!ProcessUtils.isMainProcess(context)) {
|
||||
return
|
||||
}
|
||||
clearMessageBoxTable(context)
|
||||
scope.launch {
|
||||
initCache()
|
||||
try {
|
||||
@@ -158,6 +171,38 @@ object DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
private fun clearMessageBoxTable(context: Context) {
|
||||
Thread {
|
||||
val lastLaunchTimeStr = SPUtils.getInstance().getString("last_launch", "")
|
||||
val format = SimpleDateFormat("yyyy-MM-dd")
|
||||
val currDate = Date(System.currentTimeMillis())
|
||||
val currTimeStr = format.format(currDate)
|
||||
try {
|
||||
if (lastLaunchTimeStr != null && lastLaunchTimeStr.isNotEmpty()) {
|
||||
val isSameDay = currTimeStr == lastLaunchTimeStr
|
||||
// 超过一天需要清除消息盒子中的数据,并把时间戳存入SP
|
||||
if (!isSameDay) {
|
||||
val file: File = context.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME)
|
||||
if (file != null && file.exists()) {
|
||||
context.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME)
|
||||
}
|
||||
SPUtils.getInstance().put("last_launch", currTimeStr)
|
||||
}
|
||||
} else {
|
||||
// 首次使用App或中途仅删除sp文件
|
||||
val file: File = context.getDatabasePath(MsgBoxDb.INTERNAL_DB_NAME)
|
||||
if (file != null && file.exists()) {
|
||||
context.deleteDatabase(MsgBoxDb.INTERNAL_DB_NAME)
|
||||
}
|
||||
SPUtils.getInstance().put("last_launch", currTimeStr)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e(TAG, e.message)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
private fun initCache() {
|
||||
if (cacheNotifyList.isNotEmpty()) {
|
||||
cacheNotifyList.clear()
|
||||
@@ -170,86 +215,87 @@ object DataManager {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun getCacheMessages(context: Context): List<MsgBoxBean> = withContext(Dispatchers.IO) {
|
||||
delay(2000)
|
||||
return@withContext MsgBoxDb.getDb(context)
|
||||
.monitorDao()
|
||||
.getAllCachedMessages()
|
||||
.map { msgInfo ->
|
||||
val json = msgInfo.bean2Json
|
||||
when (msgInfo.obj2JsonType) {
|
||||
MsgBoxType.V2X.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
GsonUtils.fromJson(json, V2XMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheNotifyList.add(this@apply)
|
||||
private suspend fun getCacheMessages(context: Context): List<MsgBoxBean> =
|
||||
withContext(Dispatchers.IO) {
|
||||
delay(2000)
|
||||
return@withContext MsgBoxDb.getDb(context)
|
||||
.monitorDao()
|
||||
.getAllCachedMessages()
|
||||
.map { msgInfo ->
|
||||
val json = msgInfo.bean2Json
|
||||
when (msgInfo.obj2JsonType) {
|
||||
MsgBoxType.V2X.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
GsonUtils.fromJson(json, V2XMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheNotifyList.add(this@apply)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgBoxType.OBU.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.OBU,
|
||||
GsonUtils.fromJson(json, V2XMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheNotifyList.add(this@apply)
|
||||
MsgBoxType.OBU.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.OBU,
|
||||
GsonUtils.fromJson(json, V2XMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheNotifyList.add(this@apply)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgBoxType.OPERATION.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.OPERATION,
|
||||
GsonUtils.fromJson(json, OperationMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheNotifyList.add(this@apply)
|
||||
MsgBoxType.OPERATION.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.OPERATION,
|
||||
GsonUtils.fromJson(json, OperationMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheNotifyList.add(this@apply)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgBoxType.REPORT.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.REPORT,
|
||||
GsonUtils.fromJson(json, ReportEntity::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheSysInfoList.add(this@apply)
|
||||
MsgBoxType.REPORT.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.REPORT,
|
||||
GsonUtils.fromJson(json, ReportEntity::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheSysInfoList.add(this@apply)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgBoxType.RECORD.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.RECORD,
|
||||
GsonUtils.fromJson(json, RecordBagMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheRecordList.add(this@apply)
|
||||
MsgBoxType.RECORD.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.RECORD,
|
||||
GsonUtils.fromJson(json, RecordBagMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheRecordList.add(this@apply)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MsgBoxType.NOTICE.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.NOTICE,
|
||||
GsonUtils.fromJson(json, NoticeFrCloudMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheNotifyList.add(this@apply)
|
||||
MsgBoxType.NOTICE.ordinal -> {
|
||||
return@map MsgBoxBean(
|
||||
MsgBoxType.NOTICE,
|
||||
GsonUtils.fromJson(json, NoticeFrCloudMsg::class.java)
|
||||
).apply {
|
||||
this.timestamp = msgInfo.timeStamp
|
||||
withContext(Dispatchers.Main) {
|
||||
cacheNotifyList.add(this@apply)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
return@map MsgBoxBean(MsgBoxType.V2X, V2XMsg())
|
||||
else -> {
|
||||
return@map MsgBoxBean(MsgBoxType.V2X, V2XMsg())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 存储到本地数据库
|
||||
@@ -298,7 +344,8 @@ object DataManager {
|
||||
fun delMsgBoxBean(context: Context, msgBoxBean: MsgBoxBean) {
|
||||
scope.launch {
|
||||
withContext(Dispatchers.Default) {
|
||||
val msgBoxInfo = MsgBoxInfo(msgBoxBean.bean2Json, msgBoxBean.type.ordinal, msgBoxBean.timestamp)
|
||||
val msgBoxInfo =
|
||||
MsgBoxInfo(msgBoxBean.bean2Json, msgBoxBean.type.ordinal, msgBoxBean.timestamp)
|
||||
MsgBoxDb.getDb(context)
|
||||
.monitorDao()
|
||||
.deleteMsg(msgBoxInfo)
|
||||
|
||||
Reference in New Issue
Block a user