1、适配上传接口2、代码融合

This commit is contained in:
qiji4215
2023-07-14 14:20:34 +08:00
parent c3f299222a
commit c8ac5c9582
8 changed files with 193 additions and 238 deletions

View File

@@ -54,7 +54,7 @@ data class EvaluationInfo(
val roadClassfcation: String = "",//道路种别
@SerializedName("roadFunctionGrade")
val roadFunctionGrade: String = "",//道路功能等级
val roadFunctionGrade: Int = 3,//道路功能等级
@SerializedName("noEvaluationreason")
val noEvaluationreason: String = "",//未测评原因
@@ -63,7 +63,7 @@ data class EvaluationInfo(
val linkLength: Double = 0.0,//link长度(m 保留3位小数)
@SerializedName("dataLevel")
val dataLevel: String = "",//数据级别
val dataLevel: Int = 3,//数据级别
@SerializedName("linstringLength")
val linstringLength: Double = 0.0,//错误要素长度m

View File

@@ -123,54 +123,13 @@ class TaskUploadScope(
}
taskBean.hadLinkDvoList.forEach { hadLinkDvoBean ->
val objects = realm.where(QsRecordBean::class.java)
.equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).findAll()
if (objects != null&&objects.size>0) {
val copyList = realm.copyFromRealm(objects)
copyList.forEach {
var problemType = 0
if(it.problemType=="错误"){
problemType = 0
}else if(it.problemType=="多余"){
problemType = 1
}else if(it.problemType=="遗漏"){
problemType = 2
}
var evaluationWay = 2
val evaluationInfo = EvaluationInfo(
evaluationTaskId = taskBean.id.toString(),
linkPid = hadLinkDvoBean.linkPid,//"84207223282277331"
linkStatus = 1,
markId = hadLinkDvoBean.mesh,//"20065597"
trackPhotoNumber = "",
markGeometry = it.geometry,
featureName = it.classCode,
problemType = problemType,
problemPhenomenon = it.phenomenon,
problemDesc = it.description,
problemLink = it.problemLink,
preliminaryAnalysis = it.cause,
evaluatorName = it.checkUserId,
evaluationDate = it.checkTime,
evaluationWay = evaluationWay,
roadClassfcation = "",
roadFunctionGrade = "",
noEvaluationreason = "",
linkLength = 0.0,
dataLevel = "",
linstringLength = 0.0,
)
bodyList.add(evaluationInfo)
}
}else{
val linkStatus = 1
//存在原因标记未测评
if(hadLinkDvoBean.reason.isNotEmpty()){
val linkStatus = 0
}else{
val linkStatus = 1
}
val linkStatus = 1
//存在原因标记未测评
if(hadLinkDvoBean.reason.isNotEmpty()){
//未测评
val linkStatus = 0
val evaluationInfo = EvaluationInfo(
evaluationTaskId = taskBean.id.toString(),
linkPid = hadLinkDvoBean.linkPid,//"84207223282277331"
@@ -188,14 +147,64 @@ class TaskUploadScope(
evaluationDate = "",
evaluationWay = 2,
roadClassfcation = "",
roadFunctionGrade = "",
roadFunctionGrade = 0,
noEvaluationreason = hadLinkDvoBean.reason,
linkLength = 0.0,
dataLevel = "",
dataLevel = 0,
linstringLength = 0.0,
)
bodyList.add(evaluationInfo)
}else{
val linkStatus = hadLinkDvoBean.linkStatus
var s: String = "%.3f".format(hadLinkDvoBean.linkLength)//保留一位小数(且支持四舍五入)
val objects = realm.where(QsRecordBean::class.java).equalTo("linkId", /*"84207223282277331"*/hadLinkDvoBean.linkPid).findAll()
if (objects != null&&objects.size>0) {
val copyList = realm.copyFromRealm(objects)
copyList.forEach {
var problemType = 0
if(it.problemType=="错误"){
problemType = 0
}else if(it.problemType=="多余"){
problemType = 1
}else if(it.problemType=="遗漏"){
problemType = 2
}
var evaluationWay = 2
val evaluationInfo = EvaluationInfo(
evaluationTaskId = taskBean.id.toString(),
linkPid = hadLinkDvoBean.linkPid,//"84207223282277331"
linkStatus = linkStatus,
markId = hadLinkDvoBean.mesh,//"20065597"
trackPhotoNumber = "",
markGeometry = it.geometry,
featureName = it.classCode,
problemType = problemType,
problemPhenomenon = it.phenomenon,
problemDesc = it.description,
problemLink = it.problemLink,
preliminaryAnalysis = it.cause,
evaluatorName = it.checkUserId,
evaluationDate = it.checkTime,
evaluationWay = evaluationWay,
roadClassfcation = "",
roadFunctionGrade = 3,
noEvaluationreason = "",
linkLength = s.toDouble(),
dataLevel = 3,
linstringLength = 0.0,
)
bodyList.add(evaluationInfo)
}
}
}
}
if(bodyList.size>0){

View File

@@ -12,6 +12,7 @@ import android.widget.EditText
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.annotation.RequiresApi
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
@@ -145,6 +146,7 @@ class MainActivity : BaseActivity() {
}
@RequiresApi(Build.VERSION_CODES.M)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -370,6 +372,7 @@ class MainActivity : BaseActivity() {
mapController.mMapView.onPause()
}
@RequiresApi(Build.VERSION_CODES.M)
override fun onDestroy() {
super.onDestroy()
viewModel.speakMode?.shutdown()
@@ -400,6 +403,7 @@ class MainActivity : BaseActivity() {
/**
* 打开相机预览
*/
@RequiresApi(Build.VERSION_CODES.M)
fun openCamera() {
//显示轨迹图层
viewModel.onClickCameraButton(this)
@@ -408,6 +412,7 @@ class MainActivity : BaseActivity() {
/**
* 开关菜单
*/
@RequiresApi(Build.VERSION_CODES.M)
fun onClickMenu() {
//显示菜单图层
viewModel.onClickMenu()
@@ -543,6 +548,7 @@ class MainActivity : BaseActivity() {
.animateTo(GeoPoint( mapController.mMapView.vtmMap.mapPosition.geoPoint.latitude,mapController.mMapView.vtmMap.mapPosition.geoPoint.longitude))
}
@RequiresApi(Build.VERSION_CODES.M)
private fun voiceOnTouchStart() {
viewModel.startSoundMetter(this, binding.mainActivityVoice)
}
@@ -625,6 +631,7 @@ class MainActivity : BaseActivity() {
/**
* 打开道路名称属性看板选择的道路在viewmodel里记录不用
*/
@RequiresApi(Build.VERSION_CODES.M)
fun openRoadNameFragment() {
if (viewModel.liveDataRoadName.value != null) {
viewModel.showSignMoreInfo(viewModel.liveDataRoadName.value!!)
@@ -643,7 +650,6 @@ class MainActivity : BaseActivity() {
*/
fun onClickTaskLink() {
rightController.navigate(R.id.TaskLinkFragment)
}
/**

View File

@@ -151,7 +151,9 @@ class MainViewModel @Inject constructor(
liveDataNILocationList.value = list
}
})
initLocation()
//处理地图点击操作
viewModelScope.launch(Dispatchers.Default) {
mapController.onMapClickFlow.collectLatest {
@@ -172,33 +174,15 @@ class MainViewModel @Inject constructor(
/**
* 初始化选中的任务高亮高亮
*/
@RequiresApi(Build.VERSION_CODES.M)
private fun initTaskData() {
viewModelScope.launch {
val realm = Realm.getDefaultInstance()
val results = realm.where(TaskBean::class.java).findAll()
val list = realm.copyFromRealm(results)
results.addChangeListener { changes ->
val list2 = realm.copyFromRealm(changes)
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
for (item in list2) {
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
}
}
mapController.lineHandler.omdbTaskLinkLayer.removeAll()
for (item in list) {
mapController.lineHandler.omdbTaskLinkLayer.addLineList(item.hadLinkDvoList)
}
private suspend fun initTaskData() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
val realm = Realm.getDefaultInstance()
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
if (res != null) {
val taskBean = realm.copyFromRealm(res)
mapController.lineHandler.omdbTaskLinkLayer.addLineList(taskBean.hadLinkDvoList)
}
val id = sharedPreferences.getInt(Constant.SELECT_TASK_ID, -1)
val realm = Realm.getDefaultInstance()
val res = realm.where(TaskBean::class.java).equalTo("id", id).findFirst()
if (res != null) {
val taskBean = realm.copyFromRealm(res)
mapController.lineHandler.omdbTaskLinkLayer.addLineList(taskBean.hadLinkDvoList)
}
}
/**
@@ -237,6 +221,7 @@ class MainViewModel @Inject constructor(
/**
* 初始化定位信息
*/
@RequiresApi(Build.VERSION_CODES.N)
private fun initLocation() {
//用于定位点存储到数据库
viewModelScope.launch(Dispatchers.Default) {
@@ -290,7 +275,12 @@ class MainViewModel @Inject constructor(
//用于定位点捕捉道路
viewModelScope.launch(Dispatchers.Default) {
mapController.locationLayerHandler.niLocationFlow.collectLatest { location ->
if (!isSelectRoad()) captureLink(GeoPoint(location.latitude, location.longitude))
if (!isSelectRoad()) captureLink(
GeoPoint(
location.latitude,
location.longitude
)
)
}
}
@@ -459,9 +449,13 @@ class MainViewModel @Inject constructor(
mCameraDialog!!.stopVideo()
try {
if (!mCameraDialog!!.getmShareUtil().connectstate) {
mCameraDialog!!.updateCameraResources(1, mCameraDialog!!.getmDeviceNum())
mCameraDialog!!.updateCameraResources(
1,
mCameraDialog!!.getmDeviceNum()
)
}
TakePhotoManager.getInstance().getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
TakePhotoManager.getInstance()
.getCameraVedioClent(mCameraDialog!!.getmDeviceNum())
.StopSearch()
} catch (e: Exception) {
}
@@ -598,4 +592,5 @@ class MainViewModel @Inject constructor(
liveDataSignMoreInfo.value = data
}
}

View File

@@ -1,5 +1,6 @@
package com.navinfo.omqs.ui.fragment.tasklist
import android.app.Dialog
import android.content.Context
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
@@ -33,7 +34,7 @@ class TaskViewModel @Inject constructor(
private val networkService: NetworkService,
private val mapController: NIMapController,
private val sharedPreferences: SharedPreferences
) : ViewModel() {
) : ViewModel(), OnSharedPreferenceChangeListener {
/**
* 用来更新任务列表
@@ -57,9 +58,6 @@ class TaskViewModel @Inject constructor(
*/
val liveDataCloseTask = MutableLiveData<Boolean>()
private val colors =
arrayOf(Color.RED, Color.YELLOW, Color.BLUE, Color.MAGENTA, Color.GREEN, Color.CYAN)
/**
* 当前选中的任务
*/

View File

@@ -45,7 +45,7 @@ class SignUtil {
*获取道路功能等级文字
*/
private fun getLinkFunctionClassText(data: RenderEntity): String {
return "等级${data.properties["functionClass"]}"
return "FC${data.properties["functionClass"]}"
}
/**
@@ -55,9 +55,9 @@ class SignUtil {
val direct = data.properties["direct"]
when (direct?.toInt()) {
0 -> return "不应用"
1 -> return "方向"
2 -> return "方向"
3 -> return "方向"
1 -> return ""
2 -> return ""
3 -> return ""
}
return ""
}