Browse Source

feat 关系平面图选择设备逻辑优化、设备名称(设备编码)、关系选择

lihao1 3 years ago
parent
commit
c8d4cdaff3

+ 2 - 1
demo/build.gradle

@@ -20,7 +20,8 @@ android {
         multiDexEnabled true
         ndk {
             //选择要添加的对应cpu类型的.so库。
-            abiFilters 'arm64-v8a'
+//            abiFilters 'arm64-v8a'
+            abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64'
             // 还可以添加 abiFilters 'armeabi', 'armeabi-v7a', 'x86', 'x86_64', 'mips', 'mips64', 'arm64-v8a'
 
         }

+ 2 - 2
demo/src/main/java/com/sybotan/android/demo/activities/ChooseEquipActivity.kt

@@ -375,9 +375,9 @@ class ChooseEquipActivity : BaseActivity(), DIAware {
                     }
                     for (rel in chooseRelList) {
                         for (point in scene.equipList) {
-                            if (point.data.deviceId.equals(rel.objFrom) || point.data.deviceId.equals(rel.objTo)) {
+                            if ((point.data.deviceId.equals(rel.objFrom) && deviceId != rel.objFrom) || (point.data.deviceId.equals(rel.objTo)) && deviceId != rel.objTo) {
                                 point.data.equipState = 4
-                                break
+
                             }
                         }
                     }

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

@@ -699,7 +699,9 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
     private fun doPicDatas(pathList: List<String>?) {
         getInstance().dealLocalData<Photos>(this) { name, params ->
             when (name) {
-                SHOW_DIALOG_IN_MAIN -> ToastUtils.showMyToast("图片上传中")
+                SHOW_DIALOG_IN_MAIN -> {
+                    //ToastUtils.showMyToast("图片上传中")
+                }
                 DEAL_IO_DATA -> {
                     val emitter =
                         params as ObservableEmitter<String>
@@ -721,7 +723,7 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
                                 val photosList = ArrayList<Photos>()
                                 if (staticInfoAdapter.hashMap[info!!.code] != null) {
                                     val value = Gson().fromJson<ArrayList<Photos>>(
-                                        staticInfoAdapter.hashMap[info!!.code] as String, object : TypeToken<List<Photos?>?>() {}.type
+                                        Gson().toJson(staticInfoAdapter.hashMap[info!!.code]), object : TypeToken<List<Photos?>?>() {}.type
                                     )
                                     photosList.addAll(value)
                                 }
@@ -736,13 +738,13 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
                     emitter.onNext("")
                 }
                 DEAL_DATA_NEXT -> {
-                    ToastUtils.showMyToast("图片上传完毕")
+//                    ToastUtils.showMyToast("图片上传完毕")
 //                    if (info != null) {
 //                        staticInfoAdapter.hashMap.put(info.code, beans)
 //                    }
                 }
                 DEAL_DATA_ERROR -> {
-                    ToastUtils.showMyToast("图片上传失败")
+//                    ToastUtils.showMyToast("图片上传失败")
                 }
                 else -> {
                 }

+ 35 - 8
demo/src/main/java/com/sybotan/android/demo/activities/Space3DActivity.kt

@@ -11,9 +11,7 @@ import com.framework.mvvm.model.db.entity.task.ObjectEntity
 import com.google.gson.Gson
 import com.sybotan.android.demo.R
 import com.sybotan.android.demo.bean.SpaceInfo
-import com.sybotan.android.demo.bean.model3d.FunctionEndBlockModel
-import com.sybotan.android.demo.bean.model3d.SetFloorPathModel
-import com.sybotan.android.demo.bean.model3d.SpaceData3D
+import com.sybotan.android.demo.bean.model3d.*
 import com.sybotan.android.demo.data.PageParam
 import com.sybotan.android.demo.tools.ToastUtils
 import com.sybotan.android.demo.viewmodel.Space3DVM
@@ -61,9 +59,8 @@ class Space3DActivity : BaseActivity(), DIAware {
         WebView.setWebContentsDebuggingEnabled(true)
         webview.addJavascriptInterface(this, "android")
         webview.webViewClient = MyWebViewClient()
-        webview.loadUrl("http://60.205.177.43:8000/APP/")
-//        webview.loadUrl("file:///android_asset/dist/index.html")
-
+//        webview.loadUrl("http://60.205.177.43:8000/APP/")
+        webview.loadUrl("file:///android_asset/dist/index.html")
 
         viewModel = Space3DVM(this.application, { name, param ->
             when (name) {
@@ -82,7 +79,7 @@ class Space3DActivity : BaseActivity(), DIAware {
                         space3D.ID.add(id)
                         if (space3D.ID.size >= 5 || space == spaces[spaces.size - 1]) {
                             if (space === spaces[spaces.size - 1]) {
-                                Thread.sleep(300)
+                                Thread.sleep(1000)
                                 isLastSpace = true
                             }
                             spaceDataList.add(space3D)
@@ -110,13 +107,34 @@ class Space3DActivity : BaseActivity(), DIAware {
         }
     }
 
+    /**
+     * 获取本地离线的楼层列表回调函数
+     */
+    @JavascriptInterface
+    fun GetLocalHostMeshData(meshObject: String) {
+        runOnUiThread {
+            ToastUtils.showMyToast("选中了ID:${meshObject}")
+        }
+    }
+
+    /**
+     * 楼层离线结果回调函数
+     */
+    @JavascriptInterface
+    fun DownLoadEnd(meshObject: String) {
+        runOnUiThread {
+            ToastUtils.showMyToast("选中了ID:${meshObject}")
+        }
+    }
+
     @JavascriptInterface
     fun FunctionEndBlock(name: String) {
         val nameObject = gson.fromJson(name, FunctionEndBlockModel::class.java)
         when (nameObject.Name) {
             "OpenPage" -> {
 //                runOnUiThread { webview.loadUrl("javascript:OpenTestData()") }
-                runOnUiThread { viewModel.getFloorSpace() }
+                runOnUiThread { viewModel.getFloorSpace()
+                    }
             }
             "SetSpaceData" -> {
                 if (isLastSpace) {
@@ -133,6 +151,15 @@ class Space3DActivity : BaseActivity(), DIAware {
             "SetFloorPath" -> {
                 runOnUiThread {
                     webview.loadUrl("javascript:LoadAllModelWithFloor()")
+                    val floorList = ArrayList<GetLocalHostMeshDataModel>()
+                    floorList.add(GetLocalHostMeshDataModel(projectId))
+                    webview.loadUrl("javascript:GetLocalHostMeshData($'${gson.toJson(floorList)}')")
+                    val config = DownLoadFloorMeshDataConfig()
+                    config.FloorID = floorId
+                    config.ProjectID = projectId
+                    val configList = ArrayList<DownLoadFloorMeshDataConfig>()
+                    configList.add(config)
+                    webview.loadUrl("javascript:DownLoadFloorMeshData('${gson.toJson(configList)}')")
                 }
             }
             "OpenTestData" -> {

+ 10 - 0
demo/src/main/java/com/sybotan/android/demo/bean/model3d/DownLoadFloorMeshDataConfig.java

@@ -0,0 +1,10 @@
+package com.sybotan.android.demo.bean.model3d;
+
+/**
+ * Created by lihao.
+ * Date: 2022/1/12
+ */
+public class DownLoadFloorMeshDataConfig {
+    public String ProjectID;
+    public String FloorID;
+}

+ 8 - 2
demo/src/main/java/com/sybotan/android/demo/bean/model3d/GetLocalHostMeshDataModel.java

@@ -2,9 +2,15 @@ package com.sybotan.android.demo.bean.model3d;
 
 /**
  * Created by lihao.
- * Date: 2021/12/7
+ * Date: 2022/1/12
  */
 public class GetLocalHostMeshDataModel {
-    public String ProjectID;
     public String FloorID;
+
+    public GetLocalHostMeshDataModel(String floorID) {
+        FloorID = floorID;
+    }
+
+    public GetLocalHostMeshDataModel() {
+    }
 }

+ 5 - 2
demo/src/main/java/com/sybotan/android/demo/tools/ObjectNameUtils.kt

@@ -2,7 +2,6 @@ package com.sybotan.android.demo.tools
 
 import android.text.TextUtils
 import com.framework.mvvm.model.db.entity.task.ObjectEntity
-import com.google.gson.JsonElement
 
 /**
  * Created by lihao.
@@ -20,7 +19,11 @@ class ObjectNameUtils {
             }
 //            val infos = objectEntity?.infos?.asJsonObject
 //            return if (infos?.get("digitalDeliveryID") == null) "--" else infos.get("digitalDeliveryID").toString()
-            return if (TextUtils.isEmpty(objectEntity.localName)) "--" else objectEntity.localName.toString()
+            var name = if (TextUtils.isEmpty(objectEntity.localName)) "--" else objectEntity.localName.toString()
+            if (!TextUtils.isEmpty(objectEntity.localId)) {
+                name += "(${objectEntity.localId})"
+            }
+            return name
         }
     }
 

+ 5 - 1
demo/src/main/java/com/sybotan/android/demo/viewmodel/ChooseSpaceVM.kt

@@ -358,7 +358,11 @@ class ChooseSpaceVM(
             for (type in group.targetTypes) {
                 val objs = repo.getObjectByCode(type.targetCode!!, buildingId, floorId)
                 if (!CommonUtils.IsNull(objs)) {
-                    objects.addAll(objs)
+                    for (obj in objs) {
+                        if (TextUtils.isEmpty(obj.containerId)) {
+                            objects.add(obj)
+                        }
+                    }
                 }
             }
             mEmitter.SendDirective(EQUIPS, objects)

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

@@ -190,23 +190,73 @@ class GraphyVM(
     fun getSpaceEq(choseSpace: TunableSpaceItem?) {
         viewModelScope.launch {
             val equips = repo.getEquipByFloorId(floorId)
-            equips.filter { !TextUtils.isEmpty(it.containerId) }
+//            equips.filter { !TextUtils.isEmpty(it.containerId) }
             var models: ArrayList<SpaceEqModel> = ArrayList()
             for (equip in equips) {
-                var hasParent = false
-                for (model in models) {
-                    if (model.type!!.equals(equip.classCode)) {
-                        hasParent = true
+                if (TextUtils.isEmpty(equip.containerId)) {
+                    var hasParent = false
+                    for (model in models) {
+                        if (model.type!!.equals(equip.classCode)) {
+                            hasParent = true
+                            val child = Children()
+                            child.deviceId = equip.id
+                            child.name = equip.name
+                            val infos = gson.fromJson(equip.infos, InfosforEq::class.java)
+                            child.digitalDeliveryID = infos.digitalDeliveryID
+                            if (!equip.infos!!.asJsonObject.keySet().isEmpty() && infos.location != null) {
+                                val eqProblems = repo.getEqProblem(equip.id)
+                                //1-蓝 2-绿 3-红
+                                if (eqProblems == null || TextUtils.isEmpty(eqProblems.id)) {
+                                    if (infos.equipCheck != null && (infos.equipCheck is Double || infos.equipCheck is Int)) {
+                                        when {
+                                            infos.equipCheck.toInt() == RMTristateSwitch.STATE_LEFT -> {
+                                                child.type = 5
+                                            }
+                                            infos.equipCheck.toInt() == RMTristateSwitch.STATE_MIDDLE -> {
+                                                child.type = 1
+                                            }
+                                            infos.equipCheck.toInt() == RMTristateSwitch.STATE_RIGHT -> {
+                                                child.type = 2
+                                            }
+                                            infos.equipCheck.toInt() == 3 -> {
+                                                child.type = 6
+                                            }
+                                        }
+                                    } else {
+                                        child.type = 1
+                                    }
+                                } else {
+                                    child.type = 3
+                                }
+                                val position = Position()
+                                if (infos.location != null) {
+                                    position.x = infos.location.x().toString()
+                                    position.y = infos.location.y().toString()
+                                    val z = Z()
+                                    z.offset = infos.location.z().toString()
+                                    z.region = infos.zRegion
+                                    position.z = z
+                                    child.position = gson.toJson(position)
+                                }
+                                model.children.add(child)
+                            }
+                        }
+                    }
+                    if (!hasParent) {
+                        val spaceModel = SpaceEqModel()
+                        spaceModel.type = equip.classCode
+                        var equipEntity = repo.getEquipByCode(equip.classCode!!)
+                        spaceModel.typeName = equipEntity?.name
                         val child = Children()
                         child.deviceId = equip.id
                         child.name = equip.name
                         val infos = gson.fromJson(equip.infos, InfosforEq::class.java)
                         child.digitalDeliveryID = infos.digitalDeliveryID
-                        if (!equip.infos!!.asJsonObject.keySet().isEmpty() && infos.location != null) {
+                        if (!equip.infos!!.asJsonObject.keySet().isEmpty()) {
                             val eqProblems = repo.getEqProblem(equip.id)
-                            //1-蓝 2-绿 3-红
                             if (eqProblems == null || TextUtils.isEmpty(eqProblems.id)) {
-                                if (infos.equipCheck != null && (infos.equipCheck is Double || infos.equipCheck is Int)) {
+                                //type 1-蓝 2-绿 3-红 4-黄 5-紫
+                                if (infos.equipCheck is Double || infos.equipCheck is Int) {
                                     when {
                                         infos.equipCheck.toInt() == RMTristateSwitch.STATE_LEFT -> {
                                             child.type = 5
@@ -217,9 +267,6 @@ class GraphyVM(
                                         infos.equipCheck.toInt() == RMTristateSwitch.STATE_RIGHT -> {
                                             child.type = 2
                                         }
-                                        infos.equipCheck.toInt() == 3 -> {
-                                            child.type = 6
-                                        }
                                     }
                                 } else {
                                     child.type = 1
@@ -237,54 +284,9 @@ class GraphyVM(
                                 position.z = z
                                 child.position = gson.toJson(position)
                             }
-                            model.children.add(child)
-                        }
-                    }
-                }
-                if (!hasParent) {
-                    val spaceModel = SpaceEqModel()
-                    spaceModel.type = equip.classCode
-                    var equipEntity = repo.getEquipByCode(equip.classCode!!)
-                    spaceModel.typeName = equipEntity?.name
-                    val child = Children()
-                    child.deviceId = equip.id
-                    child.name = equip.name
-                    val infos = gson.fromJson(equip.infos, InfosforEq::class.java)
-                    child.digitalDeliveryID = infos.digitalDeliveryID
-                    if (!equip.infos!!.asJsonObject.keySet().isEmpty()) {
-                        val eqProblems = repo.getEqProblem(equip.id)
-                        if (eqProblems == null || TextUtils.isEmpty(eqProblems.id)) {
-                            //type 1-蓝 2-绿 3-红 4-黄 5-紫
-                            if (infos.equipCheck is Double || infos.equipCheck is Int) {
-                                when {
-                                    infos.equipCheck.toInt() == RMTristateSwitch.STATE_LEFT -> {
-                                        child.type = 5
-                                    }
-                                    infos.equipCheck.toInt() == RMTristateSwitch.STATE_MIDDLE -> {
-                                        child.type = 1
-                                    }
-                                    infos.equipCheck.toInt() == RMTristateSwitch.STATE_RIGHT -> {
-                                        child.type = 2
-                                    }
-                                }
-                            } else {
-                                child.type = 1
-                            }
-                        } else {
-                            child.type = 3
-                        }
-                        val position = Position()
-                        if (infos.location != null) {
-                            position.x = infos.location.x().toString()
-                            position.y = infos.location.y().toString()
-                            val z = Z()
-                            z.offset = infos.location.z().toString()
-                            z.region = infos.zRegion
-                            position.z = z
-                            child.position = gson.toJson(position)
+                            spaceModel.children.add(child)
+                            models.add(spaceModel)
                         }
-                        spaceModel.children.add(child)
-                        models.add(spaceModel)
                     }
                 }
             }

+ 2 - 2
gradle.properties

@@ -17,14 +17,14 @@ SAGA_SERVICE_VERSION=1.4.140
 MAVEN_REPO_RELEASE_URL=http\://dev.dp.sagacloud.cn\:8082/repository/maven-releases/
 EVENTBUS_VERSION=3.1.1
 EASYPERMISSIONS_VERSION=1.2.0
-SAGA_ANDROID_VERSION=1.0.9
+SAGA_ANDROID_VERSION=1.0.11
 JUNIT_VERSION=5.3.1
 KOTLIN_VERSION=1.5.31
 SAGA_GROUP=cn.sagacloud
 SYBOTAN_KOTLIN_VERSION=1.2.42
 android.useAndroidX=true
 LICENSE_NAME=The Apache Software License, Version 2.0
-SAGA_CODE=21
+SAGA_CODE=23
 MAVEN_REPO_SNAPSHOT_URL=http\://dev.dp.sagacloud.cn\:8082/repository/maven-snapshots/
 NEXUS_USERNAME=saga
 DEVELOPER_ID=Andy.Sybotan