|
@@ -47,6 +47,7 @@ import androidx.appcompat.widget.LinearLayoutCompat
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
+import cn.hutool.core.collection.CollectionUtil
|
|
|
import cn.sagacloud.android.cadengine.FloorScene
|
|
|
import cn.sagacloud.android.cadengine.Lasso
|
|
|
import cn.sagacloud.android.cadengine.Opt
|
|
@@ -58,6 +59,7 @@ import com.arashivision.sdkcamera.camera.InstaCameraManager
|
|
|
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.ObjectEntity
|
|
|
import com.framework.mvvm.model.db.entity.task.InfosforEquip
|
|
|
import com.framework.mvvm.mv.AdmViewModel
|
|
@@ -77,6 +79,7 @@ import com.sybotan.android.demo.retrofit.BaseViewModelInterface
|
|
|
import com.sybotan.android.demo.retrofit.Constant
|
|
|
import com.sybotan.android.demo.tools.*
|
|
|
import com.sybotan.android.demo.view.MaxHeightRecyclerView
|
|
|
+import com.sybotan.android.demo.view.SelectListSinglePopupWindow
|
|
|
import com.sybotan.android.demo.viewmodel.GraphyVM
|
|
|
import com.sybotan.android.graphy.SGraphyView
|
|
|
import com.sybotan.android.graphy.events.SGraphyViewMoveEvent
|
|
@@ -148,6 +151,7 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
|
|
|
/** 楼层地图 */
|
|
|
private lateinit var floorMap: String
|
|
|
+ private var major: String = ""
|
|
|
|
|
|
/**
|
|
|
* space 结构核查
|
|
@@ -181,6 +185,7 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
*/
|
|
|
val beans: ArrayList<Photos> = ArrayList()
|
|
|
lateinit var pictureAdapter: PictureAdapter
|
|
|
+ lateinit var spaceEqList: ArrayList<SpaceEqModel>
|
|
|
|
|
|
@Subscribe
|
|
|
fun test(msg: SGraphyViewMoveEvent) {
|
|
@@ -223,6 +228,7 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
private lateinit var sift: TextView
|
|
|
private lateinit var checkAll: CheckBox
|
|
|
private lateinit var onlySpace: CheckBox
|
|
|
+ private lateinit var root: LinearLayout
|
|
|
|
|
|
/**
|
|
|
* 创建Activity时的回调函数
|
|
@@ -374,6 +380,7 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
checkAll = findViewById(R.id.checkAll)
|
|
|
onlySpace = findViewById(R.id.onlySpace)
|
|
|
sift = findViewById(R.id.sift)
|
|
|
+ root = findViewById(R.id.root)
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1264,27 +1271,34 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
|
|
|
/** 查询空间下的设备(所在关系) */
|
|
|
GraphyVM.SPACE_EQ -> {
|
|
|
- val list = params as List<SpaceEqModel>
|
|
|
+ spaceEqList = params as ArrayList<SpaceEqModel>
|
|
|
for (item in scene.equipList) {
|
|
|
scene.removeItem(item)
|
|
|
}
|
|
|
scene.equipList.clear()
|
|
|
- initEquipChoose(list)
|
|
|
- refreshEquip(list)
|
|
|
+ initEquipChoose(spaceEqList)
|
|
|
+ refreshEquip(spaceEqList)
|
|
|
checkAll.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
if (isChecked) {
|
|
|
- for (model in list) {
|
|
|
+ for (model in spaceEqList) {
|
|
|
model.isCheck = false
|
|
|
equipClassList.add(model.type!!)
|
|
|
}
|
|
|
} else {
|
|
|
- for (model in list) {
|
|
|
+ equipClassList.clear()
|
|
|
+ for (model in spaceEqList) {
|
|
|
model.isCheck = true
|
|
|
- equipClassList.remove(model.type!!)
|
|
|
}
|
|
|
}
|
|
|
- initEquipChoose(list)
|
|
|
- refreshEquip(list)
|
|
|
+ initEquipChoose(spaceEqList)
|
|
|
+ refreshEquip(spaceEqList)
|
|
|
+ }
|
|
|
+ onlySpace.setOnCheckedChangeListener { buttonView, isChecked ->
|
|
|
+ initEquipChoose(spaceEqList)
|
|
|
+ refreshEquip(spaceEqList)
|
|
|
+ }
|
|
|
+ sift.setOnClickListener {
|
|
|
+ graphyVM.getMajor()
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1295,6 +1309,26 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
piprRv.adapter = adapter
|
|
|
}
|
|
|
|
|
|
+ /** 专业列表 */
|
|
|
+ GraphyVM.MAJORS_LIST -> {
|
|
|
+ val majors = params as ArrayList<MajorEntity>
|
|
|
+ val popupWindow = SelectListSinglePopupWindow(this)
|
|
|
+ popupWindow.setGenList(majors, Constant.TYPE3)
|
|
|
+ popupWindow.setBtn(true, "全部")
|
|
|
+ popupWindow.showAtLocation(root, Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL, 0, 0)
|
|
|
+ popupWindow.setOnItemClickListener {
|
|
|
+ if (it == -1) {
|
|
|
+ this.major = ""
|
|
|
+ sift.setText("专业:全部")
|
|
|
+ } else {
|
|
|
+ this.major = majors.get(it).code
|
|
|
+ sift.setText("专业:${majors.get(it).label}")
|
|
|
+ }
|
|
|
+ initEquipChoose(spaceEqList)
|
|
|
+ refreshEquip(spaceEqList)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/** 添加管线 */
|
|
|
GraphyVM.ADD_PIPE -> {
|
|
|
pipeLl.visibility = View.GONE
|
|
@@ -1390,10 +1424,41 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
graphyVM.getSpaceJob(from, scene.spaceList)
|
|
|
}
|
|
|
|
|
|
- private fun initEquipChoose(list: List<SpaceEqModel>) {
|
|
|
+ private fun initEquipChoose(list: ArrayList<SpaceEqModel>) {
|
|
|
//流式布局
|
|
|
equipWwv.removeAllViews()
|
|
|
- for (model in list) {
|
|
|
+ var equipList = ArrayList<SpaceEqModel>()
|
|
|
+ CollectionUtil.addAll(equipList as Collection<Any>?, MutableList(list.size) {})
|
|
|
+ Collections.copy(equipList, list)
|
|
|
+// equipList = deepClone(list) as ArrayList<SpaceEqModel>
|
|
|
+ if (onlySpace.isChecked) {
|
|
|
+ val iterator = equipList.iterator()
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ val item = iterator.next()
|
|
|
+ val childIterator = item.children.iterator()
|
|
|
+ while (childIterator.hasNext()) {
|
|
|
+ val child = childIterator.next()
|
|
|
+ var position = gson.fromJson(child.position, Position::class.java)
|
|
|
+ val isContain = Lasso.isPolygonContainsPoint(scene.choseSpace!!.mPoints, android.graphics.Point(position.x.toFloat().toInt(), position.y.toFloat().toInt()))
|
|
|
+ if (!isContain) {
|
|
|
+ childIterator.remove()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (CommonUtils.IsNull(item.children)) {
|
|
|
+ iterator.remove()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(major)) {
|
|
|
+ val iterator = equipList.iterator()
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ val item = iterator.next()
|
|
|
+ if (!item.type!!.startsWith(major)) {
|
|
|
+ iterator.remove()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (model in equipList) {
|
|
|
val textview = TextView(this)
|
|
|
textview.apply {
|
|
|
setText(model.typeName + "-" + model.type + "(${model.children.size})")
|
|
@@ -1404,27 +1469,27 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
if (equipClassList.contains(model.type)) {
|
|
|
model.isCheck = false
|
|
|
}
|
|
|
- if (model.isCheck) {
|
|
|
- background = resources.getDrawable(R.drawable.shape_filter_normal)
|
|
|
- textColor = resources.getColor(R.color.grey_900)
|
|
|
- } else {
|
|
|
+ if (!model.isCheck || checkAll.isChecked) {
|
|
|
background = resources.getDrawable(R.drawable.shape_filter_selected)
|
|
|
textColor = resources.getColor(R.color.white)
|
|
|
+ } else {
|
|
|
+ background = resources.getDrawable(R.drawable.shape_filter_normal)
|
|
|
+ textColor = resources.getColor(R.color.grey_900)
|
|
|
}
|
|
|
setOnClickListener {
|
|
|
model.isCheck = !model.isCheck
|
|
|
- if (model.isCheck) {
|
|
|
- equipClassList.remove(model.type!!)
|
|
|
- textview.background =
|
|
|
- resources.getDrawable(R.drawable.shape_filter_normal)
|
|
|
- textview.textColor = resources.getColor(R.color.grey_900)
|
|
|
- } else {
|
|
|
+ if (!model.isCheck || checkAll.isChecked) {
|
|
|
equipClassList.add(model.type!!)
|
|
|
textview.background =
|
|
|
resources.getDrawable(R.drawable.shape_filter_selected)
|
|
|
textview.textColor = resources.getColor(R.color.white)
|
|
|
+ } else {
|
|
|
+ equipClassList.remove(model.type!!)
|
|
|
+ textview.background =
|
|
|
+ resources.getDrawable(R.drawable.shape_filter_normal)
|
|
|
+ textview.textColor = resources.getColor(R.color.grey_900)
|
|
|
}
|
|
|
- refreshEquip(list)
|
|
|
+ refreshEquip(equipList)
|
|
|
}
|
|
|
equipWwv.addView(this)
|
|
|
}
|
|
@@ -1518,26 +1583,40 @@ class GraphyActivity : BaseActivity(), ICaptureStatusListener, ICameraChangedCal
|
|
|
return ois.readObject()
|
|
|
}
|
|
|
|
|
|
+ @Throws(Exception::class)
|
|
|
+ fun deepClone(data: ArrayList<SpaceEqModel>): Any? {
|
|
|
+ // 序列化
|
|
|
+ val bos = ByteArrayOutputStream()
|
|
|
+ val oos = ObjectOutputStream(bos)
|
|
|
+ oos.writeObject(data)
|
|
|
+ // 反序列化
|
|
|
+ val bis = ByteArrayInputStream(bos.toByteArray())
|
|
|
+ val ois = ObjectInputStream(bis)
|
|
|
+ return ois.readObject()
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 刷新地图上设备
|
|
|
*/
|
|
|
private fun refreshEquip(list: List<SpaceEqModel>) {
|
|
|
graphyHelper.removeAllEquip()
|
|
|
for (model in list) {
|
|
|
- if (!model.children.isEmpty() && !model.isCheck) {
|
|
|
+ if (!model.children.isEmpty() && (!model.isCheck || checkAll.isChecked)) {
|
|
|
for (child in model.children) {
|
|
|
+ val position = gson.fromJson(child.position, Position::class.java)
|
|
|
val point = Point()
|
|
|
- var position = gson.fromJson(child.position, Position::class.java)
|
|
|
point.mX = position.x.toFloat()
|
|
|
point.mY = -position.y.toFloat()
|
|
|
+ val isContains = Lasso.isPolygonContainsPoint(scene.choseSpace!!.mPoints, android.graphics.Point(point.mX.toInt(), -point.mY.toInt()))
|
|
|
point.remark = child.remark
|
|
|
point.type = model.type
|
|
|
point.equipState = child.type
|
|
|
point.equipType = child.type
|
|
|
point.position = child.position
|
|
|
point.deviceId = child.deviceId
|
|
|
-
|
|
|
- graphyHelper.addEquip(point)
|
|
|
+ if (((onlySpace.isChecked && isContains) || !onlySpace.isChecked) && (TextUtils.isEmpty(major) || point.type!!.startsWith(major))) {
|
|
|
+ graphyHelper.addEquip(point)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|