This commit is contained in:
qiji4215 2023-04-27 10:34:08 +08:00
commit ad1156a4fc
7 changed files with 50 additions and 15 deletions

View File

@ -33,7 +33,7 @@ android {
signingConfigs { signingConfigs {
debug { debug {
storeFile file('D:/WrokSpace/OneMapQS/fastmap.keystore') storeFile file('../fastmap.keystore')
storePassword "navinfo" storePassword "navinfo"
keyAlias "fastmap" keyAlias "fastmap"
keyPassword "navinfo" keyPassword "navinfo"

View File

@ -15,7 +15,7 @@ open class TaskBean @JvmOverloads constructor(
/** /**
* 测评任务id * 测评任务id
*/ */
@PrimaryKey // @PrimaryKey
var id: Int = 0, var id: Int = 0,
/** /**
* 测评任务名称 * 测评任务名称

View File

@ -46,7 +46,7 @@ class RealmOperateHelper() {
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null) val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
// 查询realm中对应tile号的数据 // 查询realm中对应tile号的数据
val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java) val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java)
.equalTo("table", "HAD_LINK") .equalTo("table", "OMDB_RD_LINK")
.and() .and()
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd") .rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd")
.findAll() .findAll()
@ -89,7 +89,7 @@ class RealmOperateHelper() {
val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null) val yEnd = tileYSet.stream().max(Comparator.naturalOrder()).orElse(null)
// 查询realm中对应tile号的数据 // 查询realm中对应tile号的数据
val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java) val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java)
.notEqualTo("table", "HAD_LINK") .notEqualTo("table", "OMDB_RD_LINK")
.and() .and()
.rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd") .rawPredicate("tileX>=$xStart and tileX<=$xEnd and tileY>=$yStart and tileY<=$yEnd")
.findAll() .findAll()
@ -119,7 +119,7 @@ class RealmOperateHelper() {
val result = mutableListOf<RenderEntity>() val result = mutableListOf<RenderEntity>()
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java) val realmList = Realm.getDefaultInstance().where(RenderEntity::class.java)
.notEqualTo("table", "HAD_LINK") .notEqualTo("table", "OMDB_RD_LINK")
.and() .and()
.equalTo("properties['LINK_PID']", linkPid) .equalTo("properties['LINK_PID']", linkPid)
.findAll() .findAll()

View File

@ -44,7 +44,9 @@ class TaskDownloadScope(
//改进的代码 //改进的代码
fun start() { fun start() {
launch{
change(FileDownloadStatus.WAITING) change(FileDownloadStatus.WAITING)
}
downloadManager.launchScope(this@TaskDownloadScope) downloadManager.launchScope(this@TaskDownloadScope)
} }
@ -54,9 +56,12 @@ class TaskDownloadScope(
*/ */
fun pause() { fun pause() {
downloadJob?.cancel("pause") downloadJob?.cancel("pause")
launch{
change(FileDownloadStatus.PAUSE) change(FileDownloadStatus.PAUSE)
} }
}
/** /**
* 启动协程进行下载 * 启动协程进行下载
* 请不要尝试在外部调用此方法,那样会脱离[OfflineMapDownloadManager]的管理 * 请不要尝试在外部调用此方法,那样会脱离[OfflineMapDownloadManager]的管理
@ -85,18 +90,20 @@ class TaskDownloadScope(
* 更新任务 * 更新任务
* @param status [OfflineMapCityBean.Status] * @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) { if (taskBean.status != status || status == FileDownloadStatus.LOADING || status == FileDownloadStatus.IMPORTING) {
taskBean.status = status taskBean.status = status
taskBean.message = message taskBean.message = message
downloadData.postValue(taskBean) downloadData.postValue(taskBean)
launch { if (status != FileDownloadStatus.LOADING && status != FileDownloadStatus.IMPORTING) {
val realm = Realm.getDefaultInstance() val realm = Realm.getDefaultInstance()
realm.executeTransaction { realm.executeTransaction {
it.copyToRealmOrUpdate(taskBean) it.copyToRealmOrUpdate(taskBean)
} }
} }
} }
Log.e("jingo", "我被挂起 E")
} }
/** /**
@ -182,7 +189,7 @@ class TaskDownloadScope(
randomAccessFile.seek(startPosition) randomAccessFile.seek(startPosition)
taskBean.currentSize = startPosition taskBean.currentSize = startPosition
inputStream = responseBody.byteStream() inputStream = responseBody.byteStream()
val bufferSize = 1024 * 2 val bufferSize = 1024 * 4
val buffer = ByteArray(bufferSize) val buffer = ByteArray(bufferSize)
var readLength = 0 var readLength = 0
@ -198,13 +205,17 @@ class TaskDownloadScope(
} }
if (taskBean.currentSize == taskBean.fileSize) { if (taskBean.currentSize == taskBean.fileSize) {
importData(fileTemp) inputStream?.close()
randomAccessFile?.close()
inputStream = null
randomAccessFile = null
importData()
} else { } else {
change(FileDownloadStatus.PAUSE) change(FileDownloadStatus.PAUSE)
} }
} catch (e: Throwable) { } catch (e: Throwable) {
change(FileDownloadStatus.ERROR) change(FileDownloadStatus.ERROR)
Log.e("jingo","数据下载出错 ${e.message}") Log.e("jingo", "数据下载出错 ${e.message}")
} finally { } finally {
inputStream?.close() inputStream?.close()
randomAccessFile?.close() randomAccessFile?.close()

View File

@ -7,7 +7,7 @@ class MetadataUtils {
const val TITLE_ELEMENT_TYPE = "类型" const val TITLE_ELEMENT_TYPE = "类型"
const val TITLE_ELEMENT_CODE = "要素代码" const val TITLE_ELEMENT_CODE = "要素代码"
const val TITLE_CLASS_TYPE = "要素分类" const val TITLE_CLASS_TYPE = "要素分类"
const val TITLE_PROBLEM_TYPE = "问题类型·" const val TITLE_PROBLEM_TYPE = "问题类型"
const val TITLE_PHENOMENON = "问题现象" const val TITLE_PHENOMENON = "问题现象"
} }

View File

@ -6,6 +6,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.navinfo.collect.library.data.entity.QsRecordBean import com.navinfo.collect.library.data.entity.QsRecordBean
import com.navinfo.collect.library.map.NIMapController 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.RealmOperateHelper
import com.navinfo.omqs.db.RoomAppDatabase import com.navinfo.omqs.db.RoomAppDatabase
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
@ -13,6 +14,7 @@ import io.realm.Realm
import io.realm.kotlin.where import io.realm.kotlin.where
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.locationtech.jts.geom.Point
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
@ -57,6 +59,17 @@ class EvaluationResultViewModel @Inject constructor(
setOnMapClickListener { setOnMapClickListener {
liveDataQsRecordBean.value!!.geometry = it.toGeometry() liveDataQsRecordBean.value!!.geometry = it.toGeometry()
addMarker(it, markerTitle) 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 { geoPoint?.let {
liveDataQsRecordBean.value!!.geometry = it.toGeometry() liveDataQsRecordBean.value!!.geometry = it.toGeometry()
mapController.markerHandle.addMarker(geoPoint, markerTitle) 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
}
}
} }
} }

View File

@ -26,12 +26,12 @@ class TaskListViewModel @Inject constructor(
fun getTaskList(context: Context) { fun getTaskList(context: Context) {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
val realm = Realm.getDefaultInstance()
Log.e("jingo", "realm hashCOde ${realm.hashCode()}")
var taskList: List<TaskBean> = mutableListOf() var taskList: List<TaskBean> = mutableListOf()
when (val result = networkService.getTaskList("02911")) { when (val result = networkService.getTaskList("02911")) {
is NetResult.Success -> { is NetResult.Success -> {
if (result.data != null) { if (result.data != null) {
val realm = Realm.getDefaultInstance()
realm.executeTransaction { realm.executeTransaction {
result.data.obj?.let { list -> result.data.obj?.let { list ->
for (task in list) { for (task in list) {