|
@@ -32,8 +32,6 @@ import cn.sagacloud.android.cadengine.FloorScene
|
|
|
import cn.sagacloud.android.cadengine.Lasso
|
|
|
import cn.sagacloud.android.cadengine.items.*
|
|
|
import cn.sagacloud.android.cadengine.types.*
|
|
|
-import cn.sagacloud.android.cadengine.types.Space
|
|
|
-import com.framework.mvvm.model.db.entity.task.InfosforBuild
|
|
|
import com.framework.mvvm.model.db.entity.task.ObjectEntity
|
|
|
import com.google.gson.Gson
|
|
|
import com.sybotan.android.demo.R
|
|
@@ -44,6 +42,7 @@ import com.sybotan.android.demo.bean.result.*
|
|
|
import com.sybotan.android.demo.entitiies.Floor
|
|
|
import com.sybotan.android.demo.retrofit.Constant
|
|
|
import com.sybotan.android.demo.tools.CommonUtils
|
|
|
+import com.sybotan.android.demo.tools.ObjectNameUtils
|
|
|
import com.sybotan.android.demo.tools.ToastUtils
|
|
|
import com.sybotan.android.demo.view.SelectListSinglePopupWindow
|
|
|
import com.sybotan.android.demo.viewmodel.ChooseSpaceVM
|
|
@@ -78,7 +77,7 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
private lateinit var area: ServeAreaItem
|
|
|
private lateinit var centerPoint: PointF
|
|
|
private lateinit var position: Position
|
|
|
- var tunableSpaceList = ArrayList<TunableSpaceItem>()
|
|
|
+ var chooseSpaceList = ArrayList<TunableSpaceItem>()
|
|
|
var spaceIdList = ArrayList<String>()
|
|
|
|
|
|
/** 楼层地图 */
|
|
@@ -94,6 +93,7 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
private lateinit var save: TextView
|
|
|
private lateinit var floorTv: TextView
|
|
|
private lateinit var spaceName: TextView
|
|
|
+ private lateinit var direction: TextView
|
|
|
private lateinit var root: LinearLayout
|
|
|
private lateinit var spaces: ArrayList<ObjectEntity>
|
|
|
|
|
@@ -129,6 +129,7 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
floorTv = findViewById(R.id.floorTv)
|
|
|
root = findViewById(R.id.root)
|
|
|
spaceName = findViewById(R.id.spaceName)
|
|
|
+ direction = findViewById(R.id.direction)
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -151,6 +152,20 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
val equipItem = EquipItem(this, p)
|
|
|
equipItem.zOrder = 100000f
|
|
|
scene.addItem(equipItem)
|
|
|
+ if (groupRelConfigEntity.targetTypes[0].canFrom) {
|
|
|
+ direction.text = "<-"
|
|
|
+ } else {
|
|
|
+ direction.text = "->"
|
|
|
+ }
|
|
|
+ if (groupRelConfigEntity.targetTypes[0].canFrom && groupRelConfigEntity.targetTypes[0].canTo) {
|
|
|
+ direction.setOnClickListener {
|
|
|
+ if (direction.text.equals("->")) {
|
|
|
+ direction.text = "<-"
|
|
|
+ } else {
|
|
|
+ direction.text = "->"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -162,26 +177,18 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
@SuppressLint("SetJavaScriptEnabled")
|
|
|
override fun onSingUp(x: Float, y: Float) {
|
|
|
|
|
|
- for (space in tunableSpaceList) {
|
|
|
+ for (space in chooseSpaceList) {
|
|
|
val isContain = Lasso.isPolygonContainsPoint(space.mPoints, android.graphics.Point(x.toInt(), -y.toInt()))
|
|
|
if (isContain && space.data.floorName == floorTv.text.toString()) {
|
|
|
scene.removeItem(space)
|
|
|
- tunableSpaceList.remove(space)
|
|
|
+ chooseSpaceList.remove(space)
|
|
|
+ spaceIdList.remove(space.data.id)
|
|
|
initSpaceName()
|
|
|
- for (sp in spaces) {
|
|
|
- val info = gson.fromJson(sp.infos, SpaceInfo::class.java)
|
|
|
- val isContains = Lasso.isPolygonContainsPointZ(info.outline!![0][0], android.graphics.Point(x.toInt(), -y.toInt()))
|
|
|
- if (isContains) {
|
|
|
- if (spaceIdList.contains(sp.id)) {
|
|
|
- spaceIdList.remove(sp.id)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ return
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (space in scene.spaceList) {
|
|
|
+ for (space in scene.tunableSpaceList) {
|
|
|
val isContain = Lasso.isPolygonContainsPoint(space.mPoints, android.graphics.Point(x.toInt(), -y.toInt()))
|
|
|
if (isContain) {
|
|
|
val tunableSpace = TunableSpace()
|
|
@@ -191,20 +198,10 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
tunableSpace.floorId = floorId
|
|
|
val item = TunableSpaceItem(tunableSpace)
|
|
|
item.zOrder = 99996f
|
|
|
- tunableSpaceList.add(item)
|
|
|
+ chooseSpaceList.add(item)
|
|
|
scene.addItem(item)
|
|
|
+ spaceIdList.add(space.data.id!!)
|
|
|
initSpaceName()
|
|
|
- for (sp in spaces) {
|
|
|
- val obj = sp.infos!!.asJsonObject
|
|
|
- val info = gson.fromJson(obj, SpaceInfo::class.java)
|
|
|
- if (!obj.keySet().isEmpty()) {
|
|
|
- val isContains = Lasso.isPolygonContainsPointZ(info!!.outline!![0][0], android.graphics.Point(x.toInt(), -y.toInt()))
|
|
|
- if (isContains) {
|
|
|
- spaceIdList.add(sp.id)
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
break
|
|
|
}
|
|
|
}
|
|
@@ -227,16 +224,15 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
floorTv.text = floor.localName
|
|
|
floorId = floor.id
|
|
|
chooseSpaceVM.getFloorMap(floorId)
|
|
|
- chooseSpaceVM.getSpaces(floorId)
|
|
|
}
|
|
|
}
|
|
|
close.setOnClickListener { finish() }
|
|
|
save.setOnClickListener {
|
|
|
- if (CommonUtils.IsNull(tunableSpaceList)) {
|
|
|
+ if (CommonUtils.IsNull(chooseSpaceList)) {
|
|
|
ToastUtils.showMyToast("请绘制服务区域")
|
|
|
return@setOnClickListener
|
|
|
}
|
|
|
- chooseSpaceVM.insRel(deviceId, spaceIdList, groupRelConfigEntity)
|
|
|
+ chooseSpaceVM.insRel(deviceId, spaceIdList, groupRelConfigEntity, direction.text.toString())
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -269,7 +265,7 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
if (space.floorId == floorId) {
|
|
|
scene.addItem(item)
|
|
|
}
|
|
|
- tunableSpaceList.add(item)
|
|
|
+ chooseSpaceList.add(item)
|
|
|
}
|
|
|
initSpaceName()
|
|
|
}
|
|
@@ -290,17 +286,39 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
scene.loadData(floorOfflineData!!)
|
|
|
uiThread {
|
|
|
initSingleTopUp()
|
|
|
- for (space in tunableSpaceList) {
|
|
|
+ for (space in chooseSpaceList) {
|
|
|
if (space.data.floorId == floorId) {
|
|
|
scene.addItem(space)
|
|
|
}
|
|
|
}
|
|
|
initSpaceName()
|
|
|
+ chooseSpaceVM.getSpaces(floorId)
|
|
|
+ graphyView.fitSceneToView()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
ChooseSpaceVM.SPACES -> {
|
|
|
spaces = params as ArrayList<ObjectEntity>
|
|
|
+ for (item in scene.tunableSpaceList) {
|
|
|
+ scene.removeItem(item)
|
|
|
+ }
|
|
|
+ scene.tunableSpaceList.clear()
|
|
|
+ for (space in spaces) {
|
|
|
+ if (space.infos != null && space.infos!!.asJsonObject.keySet().isNotEmpty()) {
|
|
|
+ val info = gson.fromJson(space.infos, SpaceInfo::class.java)
|
|
|
+ if (!CommonUtils.IsNull(info.outline)) {
|
|
|
+ val tunableSpace = TunableSpace()
|
|
|
+ tunableSpace.outLine = info.outline[0]
|
|
|
+ tunableSpace.isShow = true
|
|
|
+ tunableSpace.id = space.id
|
|
|
+ tunableSpace.name = ObjectNameUtils.getEquipName(space.infos)
|
|
|
+ val item = TunableSpaceItem(tunableSpace)
|
|
|
+ item.zOrder = 99995f
|
|
|
+ scene.tunableSpaceList.add(item)
|
|
|
+ scene.addItem(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -313,7 +331,7 @@ class ChooseSpaceActivity : BaseActivity(), DIAware {
|
|
|
val sb = StringBuilder()
|
|
|
val others = ArrayList<SpaceNameModel>()
|
|
|
sb.append(floorTv.text.toString()).append(":")
|
|
|
- for (space in tunableSpaceList) {
|
|
|
+ for (space in chooseSpaceList) {
|
|
|
if (space.data.floorName == floorTv.text.toString()) {
|
|
|
sb.append(space.data.name).append("、")
|
|
|
} else {
|