lihao1 %!s(int64=3) %!d(string=hai) anos
pai
achega
a889066b88

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

@@ -0,0 +1,27 @@
+package cn.sagacloud.android.cadengine.types;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * Created by lihao.
+ * Date: 2021/6/10
+ */
+public class Pointz2 {
+    public float x;
+    public float y;
+    public float z;
+
+    public Pointz2() {
+    }
+
+    public Pointz2(float x, float y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    public Pointz2(float x, float y, float z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+}

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

@@ -12,6 +12,9 @@ interface ComponentDao {
     @Query("select * from component where id = :id")
     suspend fun getComponentById(id: String): ComponentEntity
 
+    @Query("select * from component where class_code = :code")
+    suspend fun getComponentByCode(code: String): List<ComponentEntity>
+
     @Insert(onConflict = OnConflictStrategy.REPLACE)
     suspend fun insComponent(vararg comp: ComponentEntity)
 

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

@@ -5,6 +5,7 @@ import androidx.room.ColumnInfo
 import androidx.room.Entity
 import androidx.room.PrimaryKey
 import cn.sagacloud.android.cadengine.types.PointZ
+import cn.sagacloud.android.cadengine.types.Pointz2
 import com.framework.mvvm.model.db.entity.BaseEntity
 import com.google.gson.JsonElement
 import java.io.Serializable
@@ -91,3 +92,10 @@ data class InfosforEquip(
     var equipCheck: Any,
     var digitalDeliveryID: String,
 )
+
+data class InfosforEq(
+    val location: Pointz2,
+    var zRegion: String,
+    var equipCheck: Any,
+    var digitalDeliveryID: String,
+)

+ 5 - 1
demo/src/main/java/com/framework/mvvm/model/repository/AdmRepository.kt

@@ -231,6 +231,10 @@ class AdmRepository(
         return db.objectDao().getSpaceByFloorId(floorId)
     }
 
+    suspend fun getCompType(code: String): List<ComponentEntity> {
+        return db.componentDao().getComponentByCode(code)
+    }
+
     /**
      * 返回楼层
      */
@@ -454,7 +458,7 @@ class AdmRepository(
                 && qrCodes.isEmpty() && objects.isEmpty() && relations.isEmpty()
                 && problemArchs.isEmpty() && problemEquips.isEmpty() && areas.isEmpty()
             ) {
-                Log.e("uploadBuilding","nothing to upload")
+                Log.e("uploadBuilding", "nothing to upload")
                 return
             }
 

+ 28 - 0
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 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
 import com.google.gson.Gson
@@ -72,6 +73,7 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
     private lateinit var localName: ListItemView
     private lateinit var location: ListItemView
     private lateinit var serveArea: ListItemView
+    private lateinit var compType: ListItemView
     private lateinit var doneSwitch: RMTristateSwitch
     private lateinit var height: ListItemView
     private lateinit var locationWhere: ListItemView
@@ -155,6 +157,7 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
         expandLvPipe = findViewById(R.id.expandLvPipe)
         expandLvRelation = findViewById(R.id.expandLvRelation)
         stateName = findViewById(R.id.stateName)
+        compType = findViewById(R.id.compType)
         expandLvPipe.setGroupIndicator(null)
         expandLvPipe.divider = null
         expandLvRelation.setGroupIndicator(null)
@@ -231,6 +234,13 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
             intent.putExtra("params", bundle)
             startActivity(intent)
         }
+        compType.setOnClickListener {
+            if (equipEntity == null) {
+                ToastUtils.showMyToast("请选择设备类")
+                return@setOnClickListener
+            }
+            equipVM.getCompType(equipEntity!!.code!!)
+        }
     }
 
     //重写onTouch方法
@@ -341,6 +351,11 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
                                 position!!.z.region = zRegion.toString()
                             }
                         }
+                        if (staticInfoAdapter.hashMap != null && staticInfoAdapter.hashMap.get("compType") != null) {
+                            val compCode = staticInfoAdapter.hashMap.get("compType")
+                            compType.setTvRight(compCode.toString())
+
+                        }
                         if (staticInfoAdapter.hashMap != null && staticInfoAdapter.hashMap.get("equipPhoto") != null) {
                             val infoList = Gson().fromJson<List<Photos>>(
                                 staticInfoAdapter.hashMap.get("equipPhoto").toString(),
@@ -506,6 +521,19 @@ class EquipDetailActivity : BaseActivity(), View.OnTouchListener {
                 EquipDetailVM.SERVE_AREA -> {
                     serveArea.setTvRight(params.toString())
                 }
+
+                EquipDetailVM.COMP_TYPE -> {
+                    val compTypes = params as ArrayList<ComponentEntity>
+                    val pop = SelectListSinglePopupWindow(this)
+                    pop.setGenList(compTypes, Constant.TYPE7)
+                    pop.setTitle(true, "选择对象")
+                    pop.showAtLocation(root, Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL, 0, 0)
+                    pop.setOnItemClickListener {
+                        val comp = compTypes[it]
+                        compType.setTvRight(comp.compName)
+                        staticInfoAdapter.hashMap["compType"] = comp.compCode
+                    }
+                }
             }
         }, this, buildingId, floorId, projectId)
         equipVM.getEquipment(deviceId)

+ 29 - 1
demo/src/main/java/com/sybotan/android/demo/activities/Space3DActivity.kt

@@ -2,10 +2,14 @@ package com.sybotan.android.demo.activities
 
 import androidx.appcompat.app.AppCompatActivity
 import android.os.Bundle
+import android.webkit.JavascriptInterface
 import android.webkit.WebSettings
 import android.webkit.WebView
 import android.webkit.WebViewClient
 import com.sybotan.android.demo.R
+import com.sybotan.android.demo.bean.model3d.MeshObject
+import com.sybotan.android.demo.tools.ToastUtils
+import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType
 
 class Space3DActivity : AppCompatActivity() {
 
@@ -14,16 +18,40 @@ class Space3DActivity : AppCompatActivity() {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_space3_dactivity)
         webview = findViewById(R.id.webview)
-        val settings: WebSettings = webview.getSettings()
+        webview.clearCache(true)
+        val settings: WebSettings = webview.settings
         settings.javaScriptEnabled = true
         settings.defaultTextEncodingName = "utf-8"
         settings.builtInZoomControls = true
         settings.loadsImagesAutomatically = true
         settings.layoutAlgorithm = WebSettings.LayoutAlgorithm.SINGLE_COLUMN
+        // 是否启动概述模式浏览界面,当页面宽度超过WebView显示宽度时,缩小页面适应WebView。默认false
+        settings.loadWithOverviewMode = true
+        settings.domStorageEnabled = true
+        settings.databaseEnabled = true
+        settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
+        webview.addJavascriptInterface(this, "android")
         webview.webViewClient = MyWebViewClient()
         webview.loadUrl("http://60.205.177.43:8000/APP/#/?PageType=1")
     }
 
+//    @JavascriptInterface
+//    fun MeshClick(meshObject: Any) {
+//        runOnUiThread {
+//            if (meshObject is MeshObject) {
+//                val mo = meshObject as MeshObject
+//                ToastUtils.showMyToast("选中了ID:${mo.ID}")
+//            }
+//        }
+//    }
+
+    @JavascriptInterface
+    fun MeshClick(meshObject: String) {
+        runOnUiThread {
+            ToastUtils.showMyToast("选中了ID:${meshObject}")
+        }
+    }
+
     class MyWebViewClient : WebViewClient() {
         //兼容低版本
         override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {

+ 5 - 0
demo/src/main/java/com/sybotan/android/demo/adapter/PersonalSelectSingleAdapter.java

@@ -13,6 +13,7 @@ import android.widget.TextView;
 import androidx.recyclerview.widget.RecyclerView;
 
 
+import com.framework.mvvm.model.db.entity.dict.ComponentEntity;
 import com.framework.mvvm.model.db.entity.dict.MajorEntity;
 import com.framework.mvvm.model.db.entity.task.ObjectEntity;
 import com.framework.mvvm.model.db.entity.task.Options;
@@ -82,6 +83,10 @@ public class PersonalSelectSingleAdapter extends RecyclerView.Adapter<PersonalSe
             String options = (String) item;
             holder.choice_name.setText(options);
         }
+        if (type.equals(Constant.TYPE7)) {
+            ComponentEntity options = (ComponentEntity) item;
+            holder.choice_name.setText(options.getCompName());
+        }
         if (selectPosition > 0 && selectPosition - 1 == position) {
             holder.choice_name.setTextColor(context.getResources().getColor(R.color.blue_2f48b7));
         } else {

+ 7 - 0
demo/src/main/java/com/sybotan/android/demo/bean/model3d/MeshObject.kt

@@ -0,0 +1,7 @@
+package com.sybotan.android.demo.bean.model3d
+
+/**
+ * Created by lihao.
+ * Date: 2021/11/22
+ */
+data class MeshObject(val ID: String, val Type: String)

+ 1 - 0
demo/src/main/java/com/sybotan/android/demo/retrofit/Constant.java

@@ -25,4 +25,5 @@ public class Constant {
     public static final String TYPE4 = "EquipItem";
     public static final String TYPE5 = "space";
     public static final String TYPE6 = "String";
+    public static final String TYPE7 = "compType";
 }

+ 12 - 2
demo/src/main/java/com/sybotan/android/demo/viewmodel/EquipDetailVM.kt

@@ -163,7 +163,7 @@ class EquipDetailVM(
                 localId = hashMap["localName"].toString()
             }
             hashMap!!.put("equipContent", equipContent)
-            var photos= ArrayList<Photos>()
+            var photos = ArrayList<Photos>()
             beans.filter { bean -> bean.itemType != 1 }.forEach { photos.add(it) }
             hashMap!!.put("equipPhoto", gson.toJson(photos))
             hashMap!!.put("equipCheck", checked)
@@ -400,7 +400,7 @@ class EquipDetailVM(
             if (from == null) {
                 rel.objFromLocalId = "该设备"
             } else {
-                rel.objFromLocalId =ObjectNameUtils.getEquipName(from.infos)
+                rel.objFromLocalId = ObjectNameUtils.getEquipName(from.infos)
             }
             val to = repo.getObject(rel.objTo!!)
             if (to == null) {
@@ -682,6 +682,13 @@ class EquipDetailVM(
         }
     }
 
+    fun getCompType(code: String) {
+        viewModelScope.launch {
+            val compTypes = repo.getCompType(code)
+            mEmitter.SendDirective(COMP_TYPE, compTypes)
+        }
+    }
+
     companion object {
 
         //查询设备类
@@ -719,6 +726,9 @@ class EquipDetailVM(
 
         //无模型设备
         const val CONTAINER_EQUIP = "CONTAINER_EQUIP"
+
+        //构件类型
+        const val COMP_TYPE = "COMP_TYPE"
     }
 
 }

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

@@ -199,7 +199,7 @@ class GraphyVM(
                         val child = Children()
                         child.deviceId = equip.id
                         child.name = equip.name
-                        val infos = gson.fromJson(equip.infos, InfosforEquip::class.java)
+                        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)
@@ -243,7 +243,7 @@ class GraphyVM(
                     val child = Children()
                     child.deviceId = equip.id
                     child.name = equip.name
-                    val infos = gson.fromJson(equip.infos, InfosforEquip::class.java)
+                    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)

+ 9 - 0
demo/src/main/res/layout/activity_equip_detail.xml

@@ -67,6 +67,15 @@
 
         <include layout="@layout/view_picture" />
 
+        <com.sybotan.android.demo.view.ListItemView
+            android:id="@+id/compType"
+            android:layout_width="match_parent"
+            android:layout_height="44dp"
+            android:layout_marginTop="10dp"
+            app:LeftText="构建类型"
+            app:RightText="请选择"
+            app:Type="0" />
+
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="55dp"