Jelajahi Sumber

feat 空间详情 本地名称与本地编码赋值

lihao1 3 tahun lalu
induk
melakukan
07adb12f9e

+ 18 - 0
cadengine/src/main/java/cn/sagacloud/android/cadengine/types/Pointz2.java

@@ -8,12 +8,30 @@ import com.google.gson.annotations.SerializedName;
  */
 public class Pointz2 {
     public float x;
+    public float X;
     public float y;
+    public float Y;
     public float z;
+    public float Z;
 
     public Pointz2() {
     }
 
+    public float x() {
+        if (x == 0f) return X;
+        else return x;
+    }
+
+    public float y() {
+        if (y == 0f) return Y;
+        else return y;
+    }
+
+    public float z() {
+        if (z == 0f) return Z;
+        else return z;
+    }
+
     public Pointz2(float x, float y) {
         this.x = x;
         this.y = y;

+ 0 - 7
demo/src/main/java/com/framework/mvvm/model/db/entity/task/ObjectEntity.kt

@@ -86,13 +86,6 @@ data class InfosforSpace(
     val digitalDeliveryID: String,
 )
 
-data class InfosforEquip(
-    val location: PointZ,
-    var zRegion: String,
-    var equipCheck: Any,
-    var digitalDeliveryID: String,
-)
-
 data class InfosforEq(
     val location: Pointz2,
     var zRegion: String,

+ 10 - 4
demo/src/main/java/com/sybotan/android/demo/activities/EquipDetailActivity.kt

@@ -20,6 +20,7 @@ import com.bumptech.glide.Glide
 import com.sybotan.android.demo.R
 import com.sybotan.android.demo.adapter.StaticInfoAdapter
 import cn.sagacloud.android.cadengine.types.Photos
+import cn.sagacloud.android.cadengine.types.Pointz2
 import com.framework.mvvm.model.db.entity.dict.ComponentEntity
 import com.framework.mvvm.model.db.entity.task.*
 import com.framework.mvvm.model.db.entity.dict.EquipmentEntity
@@ -356,6 +357,11 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
                             compType.setTvRight(compCode.toString())
 
                         }
+                        if (staticInfoAdapter.hashMap != null && staticInfoAdapter.hashMap.get("location") != null) {
+                            val position = Gson().fromJson(staticInfoAdapter.hashMap.get("location").toString(), Pointz2::class.java)
+                            location.setTvRight("(x=${position?.x()},y=${position?.y()})")
+
+                        }
                         if (staticInfoAdapter.hashMap != null && staticInfoAdapter.hashMap.get("equipPhoto") != null) {
                             val infoList = Gson().fromJson<List<Photos>>(
                                 staticInfoAdapter.hashMap.get("equipPhoto").toString(),
@@ -374,14 +380,14 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
                     var equip = params as ObjectEntity
                     this.equip = equip
                     deviceId = equip.id
-                    val infos = Gson().fromJson(equip.infos, InfosforEquip::class.java)
-                    height.setTvRight(infos.location.z.toString())
+                    val infos = Gson().fromJson(equip.infos, InfosforEq::class.java)
+                    height.setTvRight(infos.location.z().toString())
                     if (position!!.z == null) {
                         val z = Z()
-                        z.offset = infos.location.z.toString()
+                        z.offset = infos.location.z().toString()
                         position!!.z = z
                     } else {
-                        position!!.z.offset = infos.location.z.toString()
+                        position!!.z.offset = infos.location.z().toString()
                     }
                     if (this.equipEntity == null) {
                         for (eq in equips) {

+ 6 - 6
demo/src/main/java/com/sybotan/android/demo/activities/GraphyActivity.kt

@@ -60,8 +60,8 @@ import com.arashivision.sdkcamera.camera.callback.ICameraChangedCallback
 import com.arashivision.sdkcamera.camera.callback.ICaptureStatusListener
 import com.bumptech.glide.Glide
 import com.framework.mvvm.model.db.entity.dict.MajorEntity
+import com.framework.mvvm.model.db.entity.task.InfosforEq
 import com.framework.mvvm.model.db.entity.task.ObjectEntity
-import com.framework.mvvm.model.db.entity.task.InfosforEquip
 import com.framework.mvvm.mv.AdmViewModel
 import com.google.gson.Gson
 import com.google.gson.reflect.TypeToken
@@ -1850,9 +1850,9 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
                 break
             }
         }
-        val info = gson.fromJson(bus.equip.infos, InfosforEquip::class.java)
+        val info = gson.fromJson(bus.equip.infos, InfosforEq::class.java)
         scene.type = "equip"
-        equipLocation.setText("(${info.location!!.x},${-info.location.y})")
+        equipLocation.setText("(${info.location!!.x()},${-info.location.y()})")
         drawLl.visibility = View.GONE
         equipLl.visibility = View.VISIBLE
         equipRg.clearCheck()
@@ -1865,10 +1865,10 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
         } else if (info.zRegion.equals("air")) {
             air.isChecked = true
         }
-        equipEdit.setText(info.location.z.toString())
+        equipEdit.setText(info.location.z().toString())
 
-        scene.point.mX = info.location.x
-        scene.point.mY = -info.location.y
+        scene.point.mX = info.location.x()
+        scene.point.mY = -info.location.y()
         scene.point.equipState = 4
         scene.eqItem = EquipItem(this@GraphyActivity, scene.point)
         scene.eqItem!!.isVisible = true

+ 9 - 0
demo/src/main/java/com/sybotan/android/demo/activities/SpaceDetailActivity.kt

@@ -17,6 +17,7 @@ import com.sybotan.android.demo.adapter.StaticInfoAdapter
 import cn.sagacloud.android.cadengine.types.Photos
 import cn.sagacloud.android.cadengine.types.TunableSpace
 import com.framework.mvvm.model.db.entity.task.Infos
+import com.framework.mvvm.model.db.entity.task.ObjectEntity
 import com.google.gson.Gson
 import com.google.gson.reflect.TypeToken
 import com.sybotan.android.demo.retrofit.Constant
@@ -115,6 +116,14 @@ class SpaceDetailActivity : BaseActivity() {
                             beans.addAll(infoList)
                         }
                     }
+                    spaceVM.getSpace(spaceId)
+                }
+                SpaceDetailVM.SPACE_OBJECT -> {
+                    if (params != null) {
+                        val spaceEntity = params as ObjectEntity
+                        staticInfoAdapter.hashMap["localId"] = spaceEntity.localId
+                        staticInfoAdapter.hashMap["localName"] = spaceEntity.localName
+                    }
                 }
             }
         }, this, buildingId, floorId, projectId)

+ 6 - 6
demo/src/main/java/com/sybotan/android/demo/viewmodel/GraphyVM.kt

@@ -224,10 +224,10 @@ class GraphyVM(
                                 child.type = 3
                             }
                             val position = Position()
-                            position.x = infos.location.x.toString()
-                            position.y = infos.location.y.toString()
+                            position.x = infos.location.x().toString()
+                            position.y = infos.location.y().toString()
                             val z = Z()
-                            z.offset = infos.location.z.toString()
+                            z.offset = infos.location.z().toString()
                             z.region = infos.zRegion
                             position.z = z
                             child.position = gson.toJson(position)
@@ -268,10 +268,10 @@ class GraphyVM(
                             child.type = 3
                         }
                         val position = Position()
-                        position.x = infos.location.x.toString()
-                        position.y = infos.location.y.toString()
+                        position.x = infos.location.x().toString()
+                        position.y = infos.location.y().toString()
                         val z = Z()
-                        z.offset = infos.location.z.toString()
+                        z.offset = infos.location.z().toString()
                         z.region = infos.zRegion
                         position.z = z
                         child.position = gson.toJson(position)

+ 10 - 0
demo/src/main/java/com/sybotan/android/demo/viewmodel/SpaceDetailVM.kt

@@ -122,6 +122,13 @@ class SpaceDetailVM(
         }
     }
 
+    fun getSpace(spaceId: String) {
+        viewModelScope.launch {
+            val spaceObj = repo.getObject(spaceId)
+            mEmitter.SendDirective(SPACE_OBJECT, spaceObj)
+        }
+    }
+
 
     companion object {
         //静态信息点配置
@@ -129,6 +136,9 @@ class SpaceDetailVM(
 
         //对象静态信息点值
         const val SPACE_INFOS = "SPACE_INFOS"
+
+        //空间实例
+        const val SPACE_OBJECT = "SPACE_OBJECT"
     }
 
 }