|
@@ -253,25 +253,27 @@ class ChooseSpaceVM(
|
|
|
val spaces = ArrayList<TunableSpace>()
|
|
|
val equips = ArrayList<ObjectEntity>()
|
|
|
for (rel in rels) {
|
|
|
- val objEntity: ObjectEntity
|
|
|
+ var objEntity: ObjectEntity? = null
|
|
|
if (rel.entity.objFrom == deviceId) {
|
|
|
- objEntity = repo.getObject(rel.entity.objTo!!)!!
|
|
|
+ objEntity = repo.getObject(rel.entity.objTo!!)
|
|
|
} else {
|
|
|
- objEntity = repo.getObject(rel.entity.objFrom!!)!!
|
|
|
+ objEntity = repo.getObject(rel.entity.objFrom!!)
|
|
|
}
|
|
|
- val obj = objEntity.infos!!.asJsonObject
|
|
|
- val info = gson.fromJson(obj, SpaceInfo::class.java)
|
|
|
- equips.add(objEntity)
|
|
|
+ objEntity?.let {
|
|
|
+ val obj = objEntity.infos!!.asJsonObject
|
|
|
+ val info = gson.fromJson(obj, SpaceInfo::class.java)
|
|
|
+ equips.add(objEntity)
|
|
|
// spaces.add(info.outline[0])
|
|
|
|
|
|
- val tunableSpace = TunableSpace()
|
|
|
- tunableSpace.outLine = info.outline
|
|
|
- tunableSpace.name = ObjectNameUtils.getEquipName(objEntity)
|
|
|
- tunableSpace.id = objEntity.id
|
|
|
- val floor = repo.getFloorById(objEntity.floorId!!)
|
|
|
- tunableSpace.floorName = floor.localName
|
|
|
- tunableSpace.floorId = objEntity.floorId
|
|
|
- spaces.add(tunableSpace)
|
|
|
+ val tunableSpace = TunableSpace()
|
|
|
+ tunableSpace.outLine = info.outline
|
|
|
+ tunableSpace.name = ObjectNameUtils.getEquipName(objEntity)
|
|
|
+ tunableSpace.id = objEntity.id
|
|
|
+ val floor = repo.getFloorById(objEntity.floorId!!)
|
|
|
+ tunableSpace.floorName = floor.localName
|
|
|
+ tunableSpace.floorId = objEntity.floorId
|
|
|
+ spaces.add(tunableSpace)
|
|
|
+ }
|
|
|
}
|
|
|
mEmitter.SendDirective(SERVE_AREAS, spaces)
|
|
|
mEmitter.SendDirective(EQUIP_RELATION, rels)
|