|
@@ -3,8 +3,8 @@ package com.framework.mvvm.mv
|
|
|
import androidx.lifecycle.ViewModel
|
|
|
import androidx.lifecycle.viewModelScope
|
|
|
import cn.sagacloud.cadengine.OkhttpUtil
|
|
|
-import com.framework.app.pathDownloadMap
|
|
|
import com.framework.app.IP
|
|
|
+import com.framework.app.pathDownloadMap
|
|
|
import com.framework.mvvm.model.db.entity.ObjectEntity
|
|
|
import com.framework.mvvm.model.repository.AdmRepository
|
|
|
import com.framework.mvvm.model.vo.AdmRequest
|
|
@@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.StateFlow
|
|
|
import kotlinx.coroutines.flow.flow
|
|
|
import kotlinx.coroutines.flow.stateIn
|
|
|
import kotlinx.coroutines.launch
|
|
|
+import kotlinx.coroutines.withContext
|
|
|
import kotlinx.serialization.decodeFromString
|
|
|
import kotlinx.serialization.json.Json
|
|
|
|
|
@@ -70,9 +71,15 @@ class AdmViewModel(private val repository: AdmRepository) : ViewModel() {
|
|
|
/**
|
|
|
* 上传建筑数据
|
|
|
*/
|
|
|
- fun uploadBuilding(projectId: String, buildingId: String) {
|
|
|
+ fun uploadBuilding(block: (() -> Unit)? = null) {
|
|
|
viewModelScope.launch(Dispatchers.IO) {
|
|
|
- repository.uploadBuilding(projectId, buildingId)
|
|
|
+ val buildings = repository.getBuildings()
|
|
|
+ for (building in buildings) {
|
|
|
+ repository.uploadBuilding(building.projectId, building.id)
|
|
|
+ }
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
+ block?.invoke()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|