|
@@ -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)
|
|
|
}
|
|
|
}
|
|
|
}
|