|
@@ -12,7 +12,6 @@ import com.framework.app.timestamp
|
|
|
import com.framework.mvvm.model.db.entity.ObjectEntity
|
|
|
import com.framework.mvvm.model.repository.AdmRepository
|
|
|
import com.framework.mvvm.model.vo.AdmRequest
|
|
|
-import com.framework.mvvm.model.vo.Building
|
|
|
import com.framework.mvvm.model.vo.FloorInfo
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
import kotlinx.coroutines.flow.SharingStarted.Companion.WhileSubscribed
|
|
@@ -45,31 +44,38 @@ class AdmViewModel(private val repository: AdmRepository) : ViewModel() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /* 请求建筑数据
|
|
|
+ fun requestFrameAndDict(request: AdmRequest, block: (() -> Unit)? = null) {
|
|
|
+ viewModelScope.launch {
|
|
|
+ repository.requestFrame(request)
|
|
|
+ repository.requestDict(request)
|
|
|
+ block?.invoke()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* 请求建筑数据
|
|
|
|
|
|
- fun requestBuilding(request: AdmRequest, block: ((Building) -> Unit)? = null) {
|
|
|
- viewModelScope.launch(Dispatchers.IO) {
|
|
|
- repository.requestBuilding(request, block)
|
|
|
- val floors = repository.getFloors()
|
|
|
- floors.forEach {
|
|
|
- val strInfo = it.strInfos
|
|
|
- if (!strInfo.isNullOrEmpty() && strInfo.contains("floorMap")) {
|
|
|
- try {
|
|
|
- val info = Json.decodeFromString<FloorInfo>(strInfo)
|
|
|
- val map = info.floorMap
|
|
|
- val floorMap =
|
|
|
- OkhttpUtil.getGzipMap("$IP$pathDownloadMap${map!!}")
|
|
|
- it.floorMap = floorMap
|
|
|
- repository.updateObject(it)
|
|
|
- } catch (e: Exception) {
|
|
|
- println("floor map Exception: $e")
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ fun requestBuilding(request: AdmRequest, block: ((Building) -> Unit)? = null) {
|
|
|
+ viewModelScope.launch(Dispatchers.IO) {
|
|
|
+ repository.requestBuilding(request, block)
|
|
|
+ val floors = repository.getFloors()
|
|
|
+ floors.forEach {
|
|
|
+ val strInfo = it.strInfos
|
|
|
+ if (!strInfo.isNullOrEmpty() && strInfo.contains("floorMap")) {
|
|
|
+ try {
|
|
|
+ val info = Json.decodeFromString<FloorInfo>(strInfo)
|
|
|
+ val map = info.floorMap
|
|
|
+ val floorMap =
|
|
|
+ OkhttpUtil.getGzipMap("$IP$pathDownloadMap${map!!}")
|
|
|
+ it.floorMap = floorMap
|
|
|
+ repository.updateObject(it)
|
|
|
+ } catch (e: Exception) {
|
|
|
+ println("floor map Exception: $e")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- println("floor map over !!!, floors: ${floors.size}")
|
|
|
- }
|
|
|
- }*/
|
|
|
+ println("floor map over !!!, floors: ${floors.size}")
|
|
|
+ }
|
|
|
+ }*/
|
|
|
|
|
|
/**
|
|
|
* 上传建筑数据
|