修改车信存储

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
defaultConfig {
applicationId "com.navinfo.omqs"
// applicationId "com.navinfo.omqs"
minSdk 21
targetSdk 21
versionCode 1
@ -26,7 +26,7 @@ android {
multiDexEnabled true
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) {
viewModelScope.launch(Dispatchers.IO) {
createUserFolder(context, userCodeCache, userRealName)
getOfflineCityList(context)
// getOfflineCityList(context)
// loginStatus.postValue(LoginStatus.LOGIN_STATUS_SUCCESS)
}
return
// return
}
}
//不指定IO会在主线程里运行

View File

@ -20,6 +20,7 @@ import androidx.annotation.RequiresApi
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.alibaba.fastjson.JSON
import com.blankj.utilcode.util.ToastUtils
import com.navinfo.collect.library.data.entity.*
import com.navinfo.collect.library.enums.DataCodeEnum
@ -45,6 +46,8 @@ import io.realm.RealmList
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.json.JSONArray
import org.json.JSONObject
import org.locationtech.jts.geom.Geometry
import org.oscim.core.GeoPoint
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>()
@ -139,7 +142,7 @@ class EvaluationResultViewModel @Inject constructor(
init {
mapController.mMapView.addOnNIMapClickListener(TAG, object : OnGeoPointClickListener {
override fun onMapClick(tag: String, point: GeoPoint,other:String) {
override fun onMapClick(tag: String, point: GeoPoint, other: String) {
if (tag == TAG) {
liveDataQsRecordBean.value!!.geometry =
GeometryTools.createGeometry(point).toText()
@ -174,7 +177,7 @@ class EvaluationResultViewModel @Inject constructor(
if (bean != null) {
renderEntity = bean.renderEntity
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) {
renderEntity = bean.renderEntity
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请选择")
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()
liveDataQsRecordBean.value!!.taskId = liveDataTaskBean.value!!.id
liveDataQsRecordBean.value!!.checkTime = DateTimeUtil.getDataTime()
@ -504,7 +542,7 @@ class EvaluationResultViewModel @Inject constructor(
@RequiresApi(Build.VERSION_CODES.N)
fun initData(id: String) {
Log.e("jingo", "捕捉到的要素 id = $id")
viewModelScope.launch(Dispatchers.Main) {
viewModelScope.launch(Dispatchers.IO) {
val realm = realmOperateHelper.getRealmDefaultInstance()
@ -523,16 +561,43 @@ class EvaluationResultViewModel @Inject constructor(
}
liveDataQsRecordBean.postValue(it.copy())
val p = GeometryTools.createGeoPoint(it.geometry)
mapController.markerHandle.addMarker(
GeoPoint(
p.latitude, p.longitude
), TAG, "", null
)
//定位
val mapPosition = mapController.mMapView.vtmMap.mapPosition
mapPosition.setPosition(p.latitude, p.longitude)
mapController.mMapView.vtmMap.animator().animateTo(300, mapPosition)
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)
mapController.markerHandle.addMarker(
GeoPoint(
p.latitude, p.longitude
), TAG, "", null
)
//定位
val mapPosition = mapController.mMapView.vtmMap.mapPosition
mapPosition.setPosition(p.latitude, p.longitude)
mapController.mMapView.vtmMap.animator().animateTo(300, mapPosition)
}
//获取linkid
if (it.linkId.isNotEmpty()) {
val link = realmOperateHelper.queryLink(it.linkId)
@ -548,15 +613,15 @@ class EvaluationResultViewModel @Inject constructor(
}
}
liveDataQsRecordBean.value?.attachmentBeanList = it.attachmentBeanList
liveDataLanInfoChange.value = it.description
liveDataLanInfoChange.postValue(it.description)
// 显示语音数据到界面
getChatMsgEntityList()
realm.close()
//增加要素高亮
if(it.elementId!=null){
if (it.elementId != null) {
val realm2 = realmOperateHelper.getSelectTaskRealmInstance()
val rEntity = realm2.where(RenderEntity::class.java).equalTo("id",it.elementId).findFirst()
if(rEntity!=null){
val rEntity = realm2.where(RenderEntity::class.java).equalTo("id", it.elementId).findFirst()
if (rEntity != null) {
show(rEntity!!)
}
if (it.classCode == DataCodeEnum.OMDB_LANEINFO.code) {
@ -565,7 +630,8 @@ class EvaluationResultViewModel @Inject constructor(
.equalTo("linkPid", it.linkId).findFirst()
if (r != null) {
renderEntity = realm2.copyFromRealm(r)
laneInfoList = SignUtil.getLineInfoIcons(renderEntity!!)
if (!hisNowLanInfo)
laneInfoList.postValue(SignUtil.getLineInfoIcons(renderEntity!!))
}
}
realm2.close()
@ -778,7 +844,10 @@ class EvaluationResultViewModel @Inject constructor(
* 增加车信
*/
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]
if (laneInfoItem.id != id || laneInfoItem.type != type) {
laneInfoItem.id = id
@ -792,7 +861,10 @@ class EvaluationResultViewModel @Inject constructor(
* 增加车信
*/
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))
editLaneInfoProblem()
return it.size
@ -804,7 +876,10 @@ class EvaluationResultViewModel @Inject constructor(
* 删除车信
*/
fun backspaceLaneInfo() {
laneInfoList?.let {
if (laneInfoList.value == null) {
laneInfoList.value = mutableListOf<LaneInfoItem>()
}
laneInfoList.value?.let {
if (it.isNotEmpty()) {
it.removeLast()
editLaneInfoProblem()
@ -816,20 +891,76 @@ class EvaluationResultViewModel @Inject constructor(
* 删除车信
*/
fun removeAllLaneInfo() {
laneInfoList?.clear()
laneInfoList.value?.clear()
}
/**
* 组织车信备注文字
*/
private fun editLaneInfoProblem() {
laneInfoList?.let {
if (laneInfoList.value == null) {
laneInfoList.value = mutableListOf<LaneInfoItem>()
}
laneInfoList.value?.let {
liveDataQsRecordBean.value?.let { bean ->
var strBuffer = StringBuffer()
val strBuffer = StringBuffer()
if (bean.problemType == "遗漏")
strBuffer.append("车信缺失,车道从左到右分别是:")
strBuffer.append("车信缺失\n")
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) {
when (item.id) {
R.drawable.laneinfo_1 -> strBuffer.append("[直(1)")
@ -865,12 +996,16 @@ class EvaluationResultViewModel @Inject constructor(
R.drawable.laneinfo_2_3_4 -> strBuffer.append("[调左右(2,3,4)")
R.drawable.laneinfo_0 -> strBuffer.append("[不允许存在(0)")
}
if (item.type == 1) {
strBuffer.append("(附加)]")
} else if (item.type == 2) {
strBuffer.append("(公交)]")
} else {
strBuffer.append("]")
when (item.type) {
1 -> {
strBuffer.append("(附加)]")
}
2 -> {
strBuffer.append("(公交)]")
}
else -> {
strBuffer.append("]")
}
}
}
liveDataQsRecordBean.value!!.description = strBuffer.toString()

View File

@ -10,6 +10,7 @@ import android.widget.AdapterView
import android.widget.ImageView
import com.navinfo.omqs.R
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.other.shareViewModels
@ -37,7 +38,10 @@ class LaneInfoEditFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
initLaneInfo()
viewModel.laneInfoList.observe(viewLifecycleOwner){
initLaneInfo(it)
viewModel.laneInfoList.removeObservers(viewLifecycleOwner)
}
initFLowLayout()
binding.laneInfoBackspace.setOnClickListener {
@ -271,61 +275,59 @@ class LaneInfoEditFragment : BaseFragment() {
/**
* 初始化车道信息
*/
private fun initLaneInfo() {
if (viewModel.laneInfoList != null) {
val container = binding.laneInfoTopContainer
container.removeAllViews()
val lineViewS = View(context)
lineViewS.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewS.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
container.addView(lineViewS, lineViewS.layoutParams)
for (i in viewModel.laneInfoList!!.indices) {
val laneInfo = viewModel.laneInfoList!![i]
val imageView = ImageView(context)
val drawable = requireContext().getDrawable(laneInfo.id)
val color = when (laneInfo.type) {
1 -> requireContext().resources.getColor(R.color.lane_info_1)
2 -> requireContext().resources.getColor(R.color.lane_info_2)
else -> requireContext().resources.getColor(R.color.white)
}
// 创建 PorterDuffColorFilter 对象
val colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
// 将 PorterDuffColorFilter 设置给 Drawable
drawable!!.colorFilter = colorFilter
// 将 Drawable 设置给 ImageView
imageView.scaleType = ImageView.ScaleType.FIT_XY
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN)
imageView.setImageDrawable(drawable)
// 将 ImageView 的颜色设置为红色
imageView.layoutParams = ViewGroup.LayoutParams(45, 100)
container.addView(imageView, imageView.layoutParams)
if (i < viewModel.laneInfoList!!.size - 1) {
val lineView = View(context)
lineView.layoutParams = ViewGroup.LayoutParams(24, 110)
lineView.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
container.addView(lineView, lineView.layoutParams)
}
imageView.tag = i
imageView.setOnClickListener {
selectView = if (selectView == it) {
private fun initLaneInfo(list:MutableList<LaneInfoItem>) {
val container = binding.laneInfoTopContainer
container.removeAllViews()
val lineViewS = View(context)
lineViewS.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewS.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
container.addView(lineViewS, lineViewS.layoutParams)
for (i in list.indices) {
val laneInfo = list[i]
val imageView = ImageView(context)
val drawable = requireContext().getDrawable(laneInfo.id)
val color = when (laneInfo.type) {
1 -> requireContext().resources.getColor(R.color.lane_info_1)
2 -> requireContext().resources.getColor(R.color.lane_info_2)
else -> requireContext().resources.getColor(R.color.white)
}
// 创建 PorterDuffColorFilter 对象
val colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)
// 将 PorterDuffColorFilter 设置给 Drawable
drawable!!.colorFilter = colorFilter
// 将 Drawable 设置给 ImageView
imageView.scaleType = ImageView.ScaleType.FIT_XY
imageView.setColorFilter(color, PorterDuff.Mode.SRC_IN)
imageView.setImageDrawable(drawable)
// 将 ImageView 的颜色设置为红色
imageView.layoutParams = ViewGroup.LayoutParams(45, 100)
container.addView(imageView, imageView.layoutParams)
if (i < list.size - 1) {
val lineView = View(context)
lineView.layoutParams = ViewGroup.LayoutParams(24, 110)
lineView.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
container.addView(lineView, lineView.layoutParams)
}
imageView.tag = i
imageView.setOnClickListener {
selectView = if (selectView == it) {
selectView!!.setBackgroundColor(requireContext().resources.getColor(R.color.gray))
null
} else {
if (selectView != null) {
selectView!!.setBackgroundColor(requireContext().resources.getColor(R.color.gray))
null
} else {
if (selectView != null) {
selectView!!.setBackgroundColor(requireContext().resources.getColor(R.color.gray))
}
imageView.setBackgroundColor(requireContext().resources.getColor(R.color.lane_info_0))
it as ImageView
}
imageView.setBackgroundColor(requireContext().resources.getColor(R.color.lane_info_0))
it as ImageView
}
}
val lineViewE = View(context)
lineViewE.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewE.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
container.addView(lineViewE, lineViewE.layoutParams)
}
val lineViewE = View(context)
lineViewE.layoutParams = ViewGroup.LayoutParams(24, 110)
lineViewE.background =
requireContext().getDrawable(R.drawable.shape_vertical_dashed_line)
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,8 +93,11 @@ open class QsRecordBean @JvmOverloads constructor(
* 显示坐标
*/
var guideGeometry: String = "",
) : RealmObject() {
/**
* 备份数据
*/
var remarks: String = "",
) : RealmObject() {
fun copy(): QsRecordBean {
val qs = QsRecordBean(
@ -115,6 +118,7 @@ open class QsRecordBean @JvmOverloads constructor(
t_lifecycle = t_lifecycle,
t_status = t_status,
attachmentBeanList = attachmentBeanList,
remarks = remarks,
)
qs.geometry = geometry
return qs

2
vtm

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