修改车信存储

This commit is contained in:
squallzhjch 2023-12-01 16:43:25 +08:00
parent b5afd6fd2b
commit 8dfd95dff4
26 changed files with 234 additions and 93 deletions

View File

@ -17,7 +17,7 @@ android {
compileSdk 33 compileSdk 33
defaultConfig { defaultConfig {
applicationId "com.navinfo.omqs" // applicationId "com.navinfo.omqs"
minSdk 21 minSdk 21
targetSdk 21 targetSdk 21
versionCode 1 versionCode 1
@ -26,7 +26,7 @@ android {
multiDexEnabled true multiDexEnabled true
ndk { ndk {
abiFilters "armeabi-v7a", "armeabi", "mips" abiFilters "arm64-v8a", "armeabi-v7a", "armeabi", "mips"
} }
} }

View File

@ -127,10 +127,10 @@ class LoginViewModel @Inject constructor(
if (userNameCache == userName && passwordCache == password) { if (userNameCache == userName && passwordCache == password) {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
createUserFolder(context, userCodeCache, userRealName) createUserFolder(context, userCodeCache, userRealName)
getOfflineCityList(context) // getOfflineCityList(context)
// loginStatus.postValue(LoginStatus.LOGIN_STATUS_SUCCESS) // loginStatus.postValue(LoginStatus.LOGIN_STATUS_SUCCESS)
} }
return // return
} }
} }
//不指定IO会在主线程里运行 //不指定IO会在主线程里运行

View File

@ -20,6 +20,7 @@ import androidx.annotation.RequiresApi
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.alibaba.fastjson.JSON
import com.blankj.utilcode.util.ToastUtils import com.blankj.utilcode.util.ToastUtils
import com.navinfo.collect.library.data.entity.* import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.enums.DataCodeEnum import com.navinfo.collect.library.enums.DataCodeEnum
@ -45,6 +46,8 @@ import io.realm.RealmList
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.json.JSONArray
import org.json.JSONObject
import org.locationtech.jts.geom.Geometry import org.locationtech.jts.geom.Geometry
import org.oscim.core.GeoPoint import org.oscim.core.GeoPoint
import org.oscim.core.GeometryBuffer.GeometryType import org.oscim.core.GeometryBuffer.GeometryType
@ -69,7 +72,7 @@ class EvaluationResultViewModel @Inject constructor(
/** /**
* 车信列表 * 车信列表
*/ */
var laneInfoList: MutableList<LaneInfoItem>? = null val laneInfoList = MutableLiveData<MutableList<LaneInfoItem>>()
var liveDataLanInfoChange = MutableLiveData<String>() var liveDataLanInfoChange = MutableLiveData<String>()
@ -174,7 +177,7 @@ class EvaluationResultViewModel @Inject constructor(
if (bean != null) { if (bean != null) {
renderEntity = bean.renderEntity renderEntity = bean.renderEntity
if (renderEntity!!.code == DataCodeEnum.OMDB_LANEINFO.code) { if (renderEntity!!.code == DataCodeEnum.OMDB_LANEINFO.code) {
laneInfoList = SignUtil.getLineInfoIcons(renderEntity!!) laneInfoList.postValue(SignUtil.getLineInfoIcons(renderEntity!!))
} }
} }
@ -280,7 +283,7 @@ class EvaluationResultViewModel @Inject constructor(
if (bean != null) { if (bean != null) {
renderEntity = bean.renderEntity renderEntity = bean.renderEntity
if (renderEntity!!.code == DataCodeEnum.OMDB_LANEINFO.code) { if (renderEntity!!.code == DataCodeEnum.OMDB_LANEINFO.code) {
laneInfoList = SignUtil.getLineInfoIcons(renderEntity!!) laneInfoList.postValue(SignUtil.getLineInfoIcons(renderEntity!!))
} }
} }
@ -454,7 +457,42 @@ class EvaluationResultViewModel @Inject constructor(
liveDataToastMessage.postValue("没有绑定到任何link请选择") liveDataToastMessage.postValue("没有绑定到任何link请选择")
return@launch return@launch
} }
if (liveDataQsRecordBean.value!!.classCode == DataCodeEnum.OMDB_LANEINFO.code)
try {
val jsonObject: JSONObject = if (liveDataQsRecordBean.value!!.remarks != "") {
JSONObject(liveDataQsRecordBean.value!!.remarks)
} else {
JSONObject()
}
if (!jsonObject.has("original")) {
renderEntity?.let {
val laneOldList = SignUtil.getLineInfoIcons(it)
val jsonOriginalArray = JSONArray()
for (lane in laneOldList) {
val jsonItem = JSONObject()
jsonItem.put("id", lane.id)
jsonItem.put("type", lane.type)
jsonOriginalArray.put(jsonItem)
}
jsonObject.put("original", jsonOriginalArray)
}
}
laneInfoList.value?.let {
val jsonOriginalArray = JSONArray()
for (lane in it) {
val jsonItem = JSONObject()
jsonItem.put("id", lane.id)
jsonItem.put("type", lane.type)
jsonOriginalArray.put(jsonItem)
}
jsonObject.put("now", jsonOriginalArray)
}
liveDataQsRecordBean.value!!.remarks = jsonObject.toString()
} catch (e: Exception) {
}
Log.e("jingo", "车信json ${liveDataQsRecordBean.value!!.remarks}")
val realm = realmOperateHelper.getRealmDefaultInstance() val realm = realmOperateHelper.getRealmDefaultInstance()
liveDataQsRecordBean.value!!.taskId = liveDataTaskBean.value!!.id liveDataQsRecordBean.value!!.taskId = liveDataTaskBean.value!!.id
liveDataQsRecordBean.value!!.checkTime = DateTimeUtil.getDataTime() liveDataQsRecordBean.value!!.checkTime = DateTimeUtil.getDataTime()
@ -504,7 +542,7 @@ class EvaluationResultViewModel @Inject constructor(
@RequiresApi(Build.VERSION_CODES.N) @RequiresApi(Build.VERSION_CODES.N)
fun initData(id: String) { fun initData(id: String) {
Log.e("jingo", "捕捉到的要素 id = $id") Log.e("jingo", "捕捉到的要素 id = $id")
viewModelScope.launch(Dispatchers.Main) { viewModelScope.launch(Dispatchers.IO) {
val realm = realmOperateHelper.getRealmDefaultInstance() val realm = realmOperateHelper.getRealmDefaultInstance()
@ -523,16 +561,43 @@ class EvaluationResultViewModel @Inject constructor(
} }
liveDataQsRecordBean.postValue(it.copy()) liveDataQsRecordBean.postValue(it.copy())
var hisNowLanInfo = false
if (it.classCode == DataCodeEnum.OMDB_LANEINFO.code) {
try {
val jsonObject = JSONObject(it.remarks)
if (jsonObject.has("now")) {
val jsonArray = jsonObject.getJSONArray("now")
val list = mutableListOf<LaneInfoItem>()
for (i in 0 until jsonArray.length()) {
val itemObject = jsonArray[i] as JSONObject
if (itemObject.has("id") && itemObject.has("type")) {
list.add(LaneInfoItem(itemObject.getInt("id"), itemObject.getInt("type")))
}
}
hisNowLanInfo = true
laneInfoList.postValue(list)
}
// editLaneInfoProblem()
} catch (e: Exception) {
}
}
launch(Dispatchers.Main) {
val p = GeometryTools.createGeoPoint(it.geometry) val p = GeometryTools.createGeoPoint(it.geometry)
mapController.markerHandle.addMarker( mapController.markerHandle.addMarker(
GeoPoint( GeoPoint(
p.latitude, p.longitude p.latitude, p.longitude
), TAG, "", null ), TAG, "", null
) )
//定位 //定位
val mapPosition = mapController.mMapView.vtmMap.mapPosition val mapPosition = mapController.mMapView.vtmMap.mapPosition
mapPosition.setPosition(p.latitude, p.longitude) mapPosition.setPosition(p.latitude, p.longitude)
mapController.mMapView.vtmMap.animator().animateTo(300, mapPosition) mapController.mMapView.vtmMap.animator().animateTo(300, mapPosition)
}
//获取linkid //获取linkid
if (it.linkId.isNotEmpty()) { if (it.linkId.isNotEmpty()) {
val link = realmOperateHelper.queryLink(it.linkId) val link = realmOperateHelper.queryLink(it.linkId)
@ -548,7 +613,7 @@ class EvaluationResultViewModel @Inject constructor(
} }
} }
liveDataQsRecordBean.value?.attachmentBeanList = it.attachmentBeanList liveDataQsRecordBean.value?.attachmentBeanList = it.attachmentBeanList
liveDataLanInfoChange.value = it.description liveDataLanInfoChange.postValue(it.description)
// 显示语音数据到界面 // 显示语音数据到界面
getChatMsgEntityList() getChatMsgEntityList()
realm.close() realm.close()
@ -565,7 +630,8 @@ class EvaluationResultViewModel @Inject constructor(
.equalTo("linkPid", it.linkId).findFirst() .equalTo("linkPid", it.linkId).findFirst()
if (r != null) { if (r != null) {
renderEntity = realm2.copyFromRealm(r) renderEntity = realm2.copyFromRealm(r)
laneInfoList = SignUtil.getLineInfoIcons(renderEntity!!) if (!hisNowLanInfo)
laneInfoList.postValue(SignUtil.getLineInfoIcons(renderEntity!!))
} }
} }
realm2.close() realm2.close()
@ -778,7 +844,10 @@ class EvaluationResultViewModel @Inject constructor(
* 增加车信 * 增加车信
*/ */
fun updateLaneInfo(index: Int, id: Int, type: Int) { fun updateLaneInfo(index: Int, id: Int, type: Int) {
laneInfoList?.let { if (laneInfoList.value == null) {
laneInfoList.value = mutableListOf<LaneInfoItem>()
}
laneInfoList.value?.let {
val laneInfoItem = it[index] val laneInfoItem = it[index]
if (laneInfoItem.id != id || laneInfoItem.type != type) { if (laneInfoItem.id != id || laneInfoItem.type != type) {
laneInfoItem.id = id laneInfoItem.id = id
@ -792,7 +861,10 @@ class EvaluationResultViewModel @Inject constructor(
* 增加车信 * 增加车信
*/ */
fun addLaneInfo(id: Int, type: Int): Int { fun addLaneInfo(id: Int, type: Int): Int {
laneInfoList?.let { if (laneInfoList.value == null) {
laneInfoList.value = mutableListOf<LaneInfoItem>()
}
laneInfoList.value?.let {
it.add(LaneInfoItem(id, type)) it.add(LaneInfoItem(id, type))
editLaneInfoProblem() editLaneInfoProblem()
return it.size return it.size
@ -804,7 +876,10 @@ class EvaluationResultViewModel @Inject constructor(
* 删除车信 * 删除车信
*/ */
fun backspaceLaneInfo() { fun backspaceLaneInfo() {
laneInfoList?.let { if (laneInfoList.value == null) {
laneInfoList.value = mutableListOf<LaneInfoItem>()
}
laneInfoList.value?.let {
if (it.isNotEmpty()) { if (it.isNotEmpty()) {
it.removeLast() it.removeLast()
editLaneInfoProblem() editLaneInfoProblem()
@ -816,20 +891,76 @@ class EvaluationResultViewModel @Inject constructor(
* 删除车信 * 删除车信
*/ */
fun removeAllLaneInfo() { fun removeAllLaneInfo() {
laneInfoList?.clear() laneInfoList.value?.clear()
} }
/** /**
* 组织车信备注文字 * 组织车信备注文字
*/ */
private fun editLaneInfoProblem() { private fun editLaneInfoProblem() {
laneInfoList?.let { if (laneInfoList.value == null) {
laneInfoList.value = mutableListOf<LaneInfoItem>()
}
laneInfoList.value?.let {
liveDataQsRecordBean.value?.let { bean -> liveDataQsRecordBean.value?.let { bean ->
var strBuffer = StringBuffer() val strBuffer = StringBuffer()
if (bean.problemType == "遗漏") if (bean.problemType == "遗漏")
strBuffer.append("车信缺失,车道从左到右分别是:") strBuffer.append("车信缺失\n")
else if (bean.problemType == "错误") else if (bean.problemType == "错误")
strBuffer.append("车信错误,车道从左到右分别是:") strBuffer.append("车信错误\n")
renderEntity?.let {
val oldList = SignUtil.getLineInfoIcons(it)
strBuffer.append("原车道:")
for (item in oldList) {
when (item.id) {
R.drawable.laneinfo_1 -> strBuffer.append("[直(1)")
R.drawable.laneinfo_2 -> strBuffer.append("[左(2)")
R.drawable.laneinfo_3 -> strBuffer.append("[右(3)")
R.drawable.laneinfo_5 -> strBuffer.append("[左斜前(5)")
R.drawable.laneinfo_6 -> strBuffer.append("[右斜前(6)")
R.drawable.laneinfo_4 -> strBuffer.append("[调(4)")
R.drawable.laneinfo_7 -> strBuffer.append("[反向调(7)")
R.drawable.laneinfo_1_2 -> strBuffer.append("[左直(1,2)")
R.drawable.laneinfo_1_5 -> strBuffer.append("[左斜前直(1,5)")
R.drawable.laneinfo_2_5 -> strBuffer.append("[左左斜前(2,5)")
R.drawable.laneinfo_2_6 -> strBuffer.append("[左右斜前(2,6)")
R.drawable.laneinfo_1_3 -> strBuffer.append("[直右(1,3)")
R.drawable.laneinfo_1_6 -> strBuffer.append("[右斜前直(1,6)")
R.drawable.laneinfo_3_5 -> strBuffer.append("[左斜前右(3,5)")
R.drawable.laneinfo_3_6 -> strBuffer.append("[右斜前右(3,6)")
R.drawable.laneinfo_2_3 -> strBuffer.append("[左右(2,3)")
R.drawable.laneinfo_5_6 -> strBuffer.append("[左斜前右斜前(5,6)")
R.drawable.laneinfo_1_4 -> strBuffer.append("[直调(1,4)")
R.drawable.laneinfo_4_5 -> strBuffer.append("[调左斜前(4,5)")
R.drawable.laneinfo_2_4 -> strBuffer.append("[左调(2,4)")
R.drawable.laneinfo_3_4 -> strBuffer.append("[右调(3,4)")
R.drawable.laneinfo_4_6 -> strBuffer.append("[调右斜前(4,6)")
R.drawable.laneinfo_1_7 -> strBuffer.append("[直反向调(1,7)")
R.drawable.laneinfo_1_2_3 -> strBuffer.append("[左直右(1,2,3)")
R.drawable.laneinfo_1_2_4 -> strBuffer.append("[调左直(1,2,4)")
R.drawable.laneinfo_1_2_5 -> strBuffer.append("[左左斜前直(1,2,5)")
R.drawable.laneinfo_1_2_6 -> strBuffer.append("[左直右斜前(1,2,6)")
R.drawable.laneinfo_1_3_4 -> strBuffer.append("[调直右(1,3,4)")
R.drawable.laneinfo_1_3_5 -> strBuffer.append("[左斜前直右(1,3,5)")
R.drawable.laneinfo_1_3_6 -> strBuffer.append("[直右斜前右(1,3,6)")
R.drawable.laneinfo_2_3_4 -> strBuffer.append("[调左右(2,3,4)")
R.drawable.laneinfo_0 -> strBuffer.append("[不允许存在(0)")
}
when (item.type) {
1 -> {
strBuffer.append("(附加)]")
}
2 -> {
strBuffer.append("(公交)]")
}
else -> {
strBuffer.append("]")
}
}
}
}
strBuffer.append("\n现车道:")
for (item in it) { for (item in it) {
when (item.id) { when (item.id) {
R.drawable.laneinfo_1 -> strBuffer.append("[直(1)") R.drawable.laneinfo_1 -> strBuffer.append("[直(1)")
@ -865,14 +996,18 @@ class EvaluationResultViewModel @Inject constructor(
R.drawable.laneinfo_2_3_4 -> strBuffer.append("[调左右(2,3,4)") R.drawable.laneinfo_2_3_4 -> strBuffer.append("[调左右(2,3,4)")
R.drawable.laneinfo_0 -> strBuffer.append("[不允许存在(0)") R.drawable.laneinfo_0 -> strBuffer.append("[不允许存在(0)")
} }
if (item.type == 1) { when (item.type) {
1 -> {
strBuffer.append("(附加)]") strBuffer.append("(附加)]")
} else if (item.type == 2) { }
2 -> {
strBuffer.append("(公交)]") strBuffer.append("(公交)]")
} else { }
else -> {
strBuffer.append("]") strBuffer.append("]")
} }
} }
}
liveDataQsRecordBean.value!!.description = strBuffer.toString() liveDataQsRecordBean.value!!.description = strBuffer.toString()
liveDataLanInfoChange.value = strBuffer.toString() liveDataLanInfoChange.value = strBuffer.toString()
} }

View File

@ -10,6 +10,7 @@ import android.widget.AdapterView
import android.widget.ImageView import android.widget.ImageView
import com.navinfo.omqs.R import com.navinfo.omqs.R
import com.navinfo.omqs.databinding.FragmentLineInfoEditBinding import com.navinfo.omqs.databinding.FragmentLineInfoEditBinding
import com.navinfo.omqs.ui.activity.map.LaneInfoItem
import com.navinfo.omqs.ui.fragment.BaseFragment import com.navinfo.omqs.ui.fragment.BaseFragment
import com.navinfo.omqs.ui.other.shareViewModels import com.navinfo.omqs.ui.other.shareViewModels
@ -37,7 +38,10 @@ class LaneInfoEditFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
initLaneInfo() viewModel.laneInfoList.observe(viewLifecycleOwner){
initLaneInfo(it)
viewModel.laneInfoList.removeObservers(viewLifecycleOwner)
}
initFLowLayout() initFLowLayout()
binding.laneInfoBackspace.setOnClickListener { binding.laneInfoBackspace.setOnClickListener {
@ -271,8 +275,7 @@ class LaneInfoEditFragment : BaseFragment() {
/** /**
* 初始化车道信息 * 初始化车道信息
*/ */
private fun initLaneInfo() { private fun initLaneInfo(list:MutableList<LaneInfoItem>) {
if (viewModel.laneInfoList != null) {
val container = binding.laneInfoTopContainer val container = binding.laneInfoTopContainer
container.removeAllViews() container.removeAllViews()
val lineViewS = View(context) val lineViewS = View(context)
@ -280,8 +283,8 @@ class LaneInfoEditFragment : BaseFragment() {
lineViewS.background = lineViewS.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line) requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
container.addView(lineViewS, lineViewS.layoutParams) container.addView(lineViewS, lineViewS.layoutParams)
for (i in viewModel.laneInfoList!!.indices) { for (i in list.indices) {
val laneInfo = viewModel.laneInfoList!![i] val laneInfo = list[i]
val imageView = ImageView(context) val imageView = ImageView(context)
val drawable = requireContext().getDrawable(laneInfo.id) val drawable = requireContext().getDrawable(laneInfo.id)
val color = when (laneInfo.type) { val color = when (laneInfo.type) {
@ -300,7 +303,7 @@ class LaneInfoEditFragment : BaseFragment() {
// 将 ImageView 的颜色设置为红色 // 将 ImageView 的颜色设置为红色
imageView.layoutParams = ViewGroup.LayoutParams(45, 100) imageView.layoutParams = ViewGroup.LayoutParams(45, 100)
container.addView(imageView, imageView.layoutParams) container.addView(imageView, imageView.layoutParams)
if (i < viewModel.laneInfoList!!.size - 1) { if (i < list.size - 1) {
val lineView = View(context) val lineView = View(context)
lineView.layoutParams = ViewGroup.LayoutParams(24, 110) lineView.layoutParams = ViewGroup.LayoutParams(24, 110)
lineView.background = lineView.background =
@ -328,4 +331,3 @@ class LaneInfoEditFragment : BaseFragment() {
container.addView(lineViewE, lineViewE.layoutParams) container.addView(lineViewE, lineViewE.layoutParams)
} }
} }
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -93,7 +93,10 @@ open class QsRecordBean @JvmOverloads constructor(
* 显示坐标 * 显示坐标
*/ */
var guideGeometry: String = "", var guideGeometry: String = "",
/**
* 备份数据
*/
var remarks: String = "",
) : RealmObject() { ) : RealmObject() {
fun copy(): QsRecordBean { fun copy(): QsRecordBean {
@ -115,6 +118,7 @@ open class QsRecordBean @JvmOverloads constructor(
t_lifecycle = t_lifecycle, t_lifecycle = t_lifecycle,
t_status = t_status, t_status = t_status,
attachmentBeanList = attachmentBeanList, attachmentBeanList = attachmentBeanList,
remarks = remarks,
) )
qs.geometry = geometry qs.geometry = geometry
return qs return qs

2
vtm

@ -1 +1 @@
Subproject commit c046e788f5c739612a31c308639fca2de639669a Subproject commit dc42d4579611037fb2ef6986390fe74368f0d29a