Merge branch 'master' of https://gitlab.navinfo.com/CollectVehicle/OneMapQS
This commit is contained in:
commit
ad1156a4fc
@ -33,7 +33,7 @@ android {
|
||||
|
||||
signingConfigs {
|
||||
debug {
|
||||
storeFile file('D:/WrokSpace/OneMapQS/fastmap.keystore')
|
||||
storeFile file('../fastmap.keystore')
|
||||
storePassword "navinfo"
|
||||
keyAlias "fastmap"
|
||||
keyPassword "navinfo"
|
||||
|
@ -15,7 +15,7 @@ open class TaskBean @JvmOverloads constructor(
|
||||
/**
|
||||
* 测评任务id
|
||||
*/
|
||||
@PrimaryKey
|
||||
// @PrimaryKey
|
||||
var id: Int = 0,
|
||||
/**
|
||||
* 测评任务名称
|
||||
|
@ -46,7 +46,7 @@ class RealmOperateHelper() {
|
||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||
// 查询realm中对应tile号的数据
|
||||
val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java)
|
||||
.equalTo("table", "HAD_LINK")
|
||||
.equalTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd")
|
||||
.findAll()
|
||||
@ -89,7 +89,7 @@ class RealmOperateHelper() {
|
||||
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
|
||||
// 查询realm中对应tile号的数据
|
||||
val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java)
|
||||
.notEqualTo("table", "HAD_LINK")
|
||||
.notEqualTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd")
|
||||
.findAll()
|
||||
@ -119,7 +119,7 @@ class RealmOperateHelper() {
|
||||
val result = mutableListOf<RenderEntity>()
|
||||
withContext(Dispatchers.IO) {
|
||||
val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java)
|
||||
.notEqualTo("table", "HAD_LINK")
|
||||
.notEqualTo("table", "OMDB_RD_LINK")
|
||||
.and()
|
||||
.equalTo("properties['LINK_PID']", linkPid)
|
||||
.findAll()
|
||||
|
@ -44,7 +44,9 @@ class TaskDownloadScope(
|
||||
|
||||
//改进的代码
|
||||
fun start() {
|
||||
change(FileDownloadStatus.WAITING)
|
||||
launch{
|
||||
change(FileDownloadStatus.WAITING)
|
||||
}
|
||||
downloadManager.launchScope(this@TaskDownloadScope)
|
||||
}
|
||||
|
||||
@ -54,7 +56,10 @@ class TaskDownloadScope(
|
||||
*/
|
||||
fun pause() {
|
||||
downloadJob?.cancel("pause")
|
||||
change(FileDownloadStatus.PAUSE)
|
||||
launch{
|
||||
change(FileDownloadStatus.PAUSE)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,18 +90,20 @@ class TaskDownloadScope(
|
||||
* 更新任务
|
||||
* @param status [OfflineMapCityBean.Status]
|
||||
*/
|
||||
private fun change(status: Int, message: String = "") {
|
||||
private suspend fun change(status: Int, message: String = "") {
|
||||
Log.e("jingo", "我被挂起 S")
|
||||
if (taskBean.status != status || status == FileDownloadStatus.LOADING || status == FileDownloadStatus.IMPORTING) {
|
||||
taskBean.status = status
|
||||
taskBean.message = message
|
||||
downloadData.postValue(taskBean)
|
||||
launch {
|
||||
if (status != FileDownloadStatus.LOADING && status != FileDownloadStatus.IMPORTING) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
it.copyToRealmOrUpdate(taskBean)
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.e("jingo", "我被挂起 E")
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,7 +189,7 @@ class TaskDownloadScope(
|
||||
randomAccessFile.seek(startPosition)
|
||||
taskBean.currentSize = startPosition
|
||||
inputStream = responseBody.byteStream()
|
||||
val bufferSize = 1024 * 2
|
||||
val bufferSize = 1024 * 4
|
||||
val buffer = ByteArray(bufferSize)
|
||||
|
||||
var readLength = 0
|
||||
@ -198,13 +205,17 @@ class TaskDownloadScope(
|
||||
}
|
||||
|
||||
if (taskBean.currentSize == taskBean.fileSize) {
|
||||
importData(fileTemp)
|
||||
inputStream?.close()
|
||||
randomAccessFile?.close()
|
||||
inputStream = null
|
||||
randomAccessFile = null
|
||||
importData()
|
||||
} else {
|
||||
change(FileDownloadStatus.PAUSE)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
change(FileDownloadStatus.ERROR)
|
||||
Log.e("jingo","数据下载出错 ${e.message}")
|
||||
Log.e("jingo", "数据下载出错 ${e.message}")
|
||||
} finally {
|
||||
inputStream?.close()
|
||||
randomAccessFile?.close()
|
||||
|
@ -7,7 +7,7 @@ class MetadataUtils {
|
||||
const val TITLE_ELEMENT_TYPE = "类型"
|
||||
const val TITLE_ELEMENT_CODE = "要素代码"
|
||||
const val TITLE_CLASS_TYPE = "要素分类"
|
||||
const val TITLE_PROBLEM_TYPE = "问题类型·"
|
||||
const val TITLE_PROBLEM_TYPE = "问题类型"
|
||||
const val TITLE_PHENOMENON = "问题现象"
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.navinfo.collect.library.data.entity.QsRecordBean
|
||||
import com.navinfo.collect.library.map.NIMapController
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import com.navinfo.omqs.db.RealmOperateHelper
|
||||
import com.navinfo.omqs.db.RoomAppDatabase
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
@ -13,6 +14,7 @@ import io.realm.Realm
|
||||
import io.realm.kotlin.where
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.locationtech.jts.geom.Point
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -57,6 +59,17 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
setOnMapClickListener {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
addMarker(it, markerTitle)
|
||||
viewModelScope.launch {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
point = GeometryTools.createPoint(
|
||||
it.longitude,
|
||||
it.latitude
|
||||
), sort = true
|
||||
)
|
||||
if (linkList.isNotEmpty()) {
|
||||
liveDataQsRecordBean.value!!.linkId = linkList[0].id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,6 +95,17 @@ class EvaluationResultViewModel @Inject constructor(
|
||||
geoPoint?.let {
|
||||
liveDataQsRecordBean.value!!.geometry = it.toGeometry()
|
||||
mapController.markerHandle.addMarker(geoPoint, markerTitle)
|
||||
viewModelScope.launch {
|
||||
val linkList = realmOperateHelper.queryLink(
|
||||
GeometryTools.createPoint(
|
||||
geoPoint.longitude,
|
||||
geoPoint.latitude
|
||||
)
|
||||
)
|
||||
if (linkList.isNotEmpty()) {
|
||||
liveDataQsRecordBean.value!!.linkId = linkList[0].id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,12 +26,12 @@ class TaskListViewModel @Inject constructor(
|
||||
|
||||
fun getTaskList(context: Context) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
Log.e("jingo", "realm hashCOde ${realm.hashCode()}")
|
||||
|
||||
var taskList: List<TaskBean> = mutableListOf()
|
||||
when (val result = networkService.getTaskList("02911")) {
|
||||
is NetResult.Success -> {
|
||||
if (result.data != null) {
|
||||
val realm = Realm.getDefaultInstance()
|
||||
realm.executeTransaction {
|
||||
result.data.obj?.let { list ->
|
||||
for (task in list) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user