|
@@ -45,9 +45,8 @@ class AdmViewModel(private val repository: AdmRepository) : ViewModel() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 请求建筑数据
|
|
|
- */
|
|
|
+ /* 请求建筑数据
|
|
|
+
|
|
|
fun requestBuilding(request: AdmRequest, block: ((Building) -> Unit)? = null) {
|
|
|
viewModelScope.launch(Dispatchers.IO) {
|
|
|
repository.requestBuilding(request, block)
|
|
@@ -70,7 +69,7 @@ class AdmViewModel(private val repository: AdmRepository) : ViewModel() {
|
|
|
|
|
|
println("floor map over !!!, floors: ${floors.size}")
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/**
|
|
|
* 上传建筑数据
|
|
@@ -109,27 +108,29 @@ class AdmViewModel(private val repository: AdmRepository) : ViewModel() {
|
|
|
sp.edit { putString(it.buildingId, it.timestamp) }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 下载地图
|
|
|
+ val floors = repository.getFloors()
|
|
|
+ floors.forEach {
|
|
|
+ val strInfo = it.strInfos
|
|
|
+ if (!strInfo.isNullOrEmpty()) {
|
|
|
+ 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")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
withContext(Dispatchers.Main) {
|
|
|
block?.invoke()
|
|
|
}
|
|
|
}
|
|
|
- /*val buildings = mVm.getBuildings()
|
|
|
- println("download buildings: ${buildings.size} $buildings")
|
|
|
- for (building in buildings) {
|
|
|
- mVm.requestBuilding(
|
|
|
- AdmRequest(
|
|
|
- userId = "bdtp",
|
|
|
- projectId = building.projectId,
|
|
|
- groupCode = "BR",
|
|
|
- buildingId = building.id,
|
|
|
- uploadFlag = sp.getString(deviceId, "") ?: "",
|
|
|
- lastDownloadTime = sp.getString(timestamp, "") ?: ""
|
|
|
- )
|
|
|
- ) {
|
|
|
- println("buildingIdTimestamp -> ${it.buildingId}, ${it.timestamp}")
|
|
|
- sp.edit { putString(it.buildingId, it.timestamp) }
|
|
|
- }
|
|
|
- }*/
|
|
|
}
|
|
|
|
|
|
/**
|