Jelajahi Sumber

@task: annotation before_cal_rels and calRules

bai 3 tahun lalu
induk
melakukan
fb7384a9e0

+ 6 - 0
demo/src/main/java/com/framework/mvvm/model/db/dao/ObjectDao.kt

@@ -23,6 +23,12 @@ interface ObjectDao {
     @Delete
     suspend fun delObject(obj: ObjectEntity)
 
+    /**
+     * 返回楼层类型的 ObjectEntity
+     */
+    @Query("select * from object where obj_type = 'floor'")
+    suspend fun getFloors(): List<ObjectEntity>
+
     // @Transaction
     // @Query("select * from object")
     // fun getObjectAndInfosWithOutlines() : List<ObjectAndInfosWithOutlines>

+ 2 - 2
demo/src/main/java/com/framework/mvvm/model/db/entity/RelationDictEntity.kt

@@ -23,8 +23,8 @@ class RelationDictEntity(
     @ColumnInfo(name = "directional") val directional: Int?,      // 方向
     @ColumnInfo(name = "target_Objs") val targetObjs: String?,     // 目标对象
     @ColumnInfo(name = "attribute") val attribute: String?,          // 属性
-    @ColumnInfo(name = "before_cal_rels") val beforeCalRels: String?,
-    @ColumnInfo(name = "calRules") val calRules: String?,
+    //@ColumnInfo(name = "before_cal_rels") val beforeCalRels: String?,
+    //@ColumnInfo(name = "calRules") val calRules: String?,
     @ColumnInfo(name = "fromObjType") val fromObjType: String?,
     @ColumnInfo(name = "toObjType") val toObjType: String?,
     @ColumnInfo(name = "remark") val remark: String?

+ 19 - 12
demo/src/main/java/com/framework/mvvm/model/repository/AdmRepository.kt

@@ -106,17 +106,16 @@ class AdmRepository(
     suspend fun requestDict(request: AdmRequest) {
         request(
             from = { api.getDict(request) },
-            to = { define ->
-
-                val pipeConfig = define.pipeConfig
-                val infosConfig = define.infosConfig
-                val config = define.config
-                val m2dTypes = define.m2dTypes
-                val relConfig = define.relConfig
-                val system = define.dict.system
-                val equipment = define.dict.equipment
-                val relation = define.dict.relation
-                val major = define.dict.major
+            to = { dict ->
+                val pipeConfig = dict.pipeConfig
+                val infosConfig = dict.infosConfig
+                val config = dict.config
+                val m2dTypes = dict.m2dTypes
+                val relConfig = dict.relConfig
+                val system = dict.dict.system
+                val equipment = dict.dict.equipment
+                val relation = dict.dict.relation
+                val major = dict.dict.major
 
                 try {
                     db.pipeConfigDao().insConfigs(pipeConfig)
@@ -131,7 +130,8 @@ class AdmRepository(
                 } catch (e: Exception) {
                     Log.d("requestDict", e.message!!)
                 }
-            }
+            },
+            error = { println("error:$it") }
         )
     }
 
@@ -168,4 +168,11 @@ class AdmRepository(
         )
     }
 
+    /**
+     * 返回楼层
+     */
+    suspend fun getFloors(): List<ObjectEntity> {
+        return db.objectDao().getFloors()
+    }
+
 }

+ 1 - 2
demo/src/main/java/com/framework/mvvm/model/vo/AdmRequest.kt

@@ -7,6 +7,5 @@ data class AdmRequest(
     val userId: String = "",
     val projectId: String = "",
     val groupCode: String = "",
-    val buildingId: String = "",
-    val floorId: String = ""
+    val buildingId: String = ""
 )

+ 17 - 0
demo/src/main/java/com/framework/mvvm/model/vo/FloorInfo.kt

@@ -0,0 +1,17 @@
+package com.framework.mvvm.model.vo
+
+import kotlinx.serialization.Serializable
+
+/**
+ * 楼层的 Infos
+ */
+@Serializable
+data class FloorInfo(
+    val count: String?,
+    val modelId: String?,
+    val bimIdPre: String?,
+    val floorMap: String?,          // 楼层地图
+    val floorElevation: Double,
+    val floorSequenceID: Double,
+    //val outline: List<Outline>
+)

+ 13 - 0
demo/src/main/java/com/framework/mvvm/model/vo/Outline.kt

@@ -0,0 +1,13 @@
+package com.framework.mvvm.model.vo
+
+import kotlinx.serialization.Serializable
+
+/**
+ * Outline
+ */
+@Serializable
+data class Outline(
+    val x: Double,
+    val y: Double,
+    var z: Double = 0.0
+)

+ 21 - 16
demo/src/main/java/com/framework/mvvm/mv/AdmViewModel.kt

@@ -23,28 +23,19 @@ class AdmViewModel(private val repository: AdmRepository) : ViewModel() {
             }
         }
 
-    fun requestFrame1(request: AdmRequest) {
-        _frameRequest.value = request
-    }
-
-    fun retry() {
-        _frameRequest.value?.let {
-            _frameRequest.value = it
-        }
-    }
-
-    fun insProjects(projects: List<ProjectEntity>) {
-        viewModelScope.launch {
-            repository.insProject(projects)
-        }
-    }
-
+    /**
+     * 请求架构数据
+     */
     fun requestFrame(request: AdmRequest) {
         viewModelScope.launch {
             repository.requestFrame(request)
         }
     }
 
+
+    /**
+     * 请求字典
+     */
     fun requestDict(request: AdmRequest) {
         viewModelScope.launch {
             repository.requestDict(request)
@@ -60,4 +51,18 @@ class AdmViewModel(private val repository: AdmRepository) : ViewModel() {
         }
     }
 
+    /**
+     * 下载底图
+     */
+    fun downloadFloorMap() {
+        viewModelScope.launch {
+            val floors =  repository.getFloors()
+            floors.forEach {
+
+            }
+            // 遍历 floor ,创建 FloorInfo
+            //  获取 floorMap
+
+        }
+    }
 }