|
@@ -38,11 +38,11 @@ import java.io.File
|
|
|
* Date: 2021/6/9
|
|
|
*/
|
|
|
class SpaceMapVM(
|
|
|
- app: Application,
|
|
|
- b: BaseViewModelInterface?, activity: BaseActivity?, //建筑id
|
|
|
- private val buildingId: String, //楼层id
|
|
|
- private val floorId: String,
|
|
|
- private val projectId: String
|
|
|
+ app: Application,
|
|
|
+ b: BaseViewModelInterface?, activity: BaseActivity?, //建筑id
|
|
|
+ private val buildingId: String, //楼层id
|
|
|
+ private val floorId: String,
|
|
|
+ private val projectId: String
|
|
|
) : BaseViewModel(app, b, activity), DIAware {
|
|
|
private val gson = Gson()
|
|
|
|
|
@@ -79,30 +79,32 @@ class SpaceMapVM(
|
|
|
val problems = repo.getProblemByAvalible(floorId)
|
|
|
var hasProblem = false
|
|
|
val list: ArrayList<PointF> = ArrayList()
|
|
|
- for (line in spaceJobModel.outline[0]!!) {
|
|
|
- if (line.size < 1) {
|
|
|
- list.add(PointF(line[0].x, line[0].y))
|
|
|
- continue
|
|
|
- }
|
|
|
- for (p in line) {
|
|
|
- list.add(PointF(p.x, p.y))
|
|
|
+ if (!CommonUtils.IsNull(spaceJobModel.outline)) {
|
|
|
+ for (line in spaceJobModel.outline[0]!!) {
|
|
|
+ if (line.size < 1) {
|
|
|
+ list.add(PointF(line[0].x, line[0].y))
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ for (p in line) {
|
|
|
+ list.add(PointF(p.x, p.y))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
for (problem in problems) {
|
|
|
val geomList = gson.fromJson<List<PointF>>(
|
|
|
- problem.geom,
|
|
|
- object : TypeToken<List<PointF?>?>() {}.type
|
|
|
+ problem.geom,
|
|
|
+ object : TypeToken<List<PointF?>?>() {}.type
|
|
|
)
|
|
|
for (gemo in geomList) {
|
|
|
val pointF = if (geomList.size == 1) {
|
|
|
android.graphics.Point(
|
|
|
- gemo.x.toInt(),
|
|
|
- -gemo.y.toInt()
|
|
|
+ gemo.x.toInt(),
|
|
|
+ -gemo.y.toInt()
|
|
|
)
|
|
|
} else {
|
|
|
android.graphics.Point(
|
|
|
- gemo.x.toInt(),
|
|
|
- gemo.y.toInt()
|
|
|
+ gemo.x.toInt(),
|
|
|
+ gemo.y.toInt()
|
|
|
)
|
|
|
}
|
|
|
if (Lasso.isPolygonContainsPoint(list, pointF)) {
|
|
@@ -135,13 +137,13 @@ class SpaceMapVM(
|
|
|
* @param y y坐标
|
|
|
*/
|
|
|
fun addProblem(
|
|
|
- point: PointItem?,
|
|
|
- photos: ArrayList<Photos>,
|
|
|
- content: String,
|
|
|
- x: Float,
|
|
|
- y: Float,
|
|
|
- linePoints: ArrayList<PipeLineItem>,
|
|
|
- isLine: Boolean
|
|
|
+ point: PointItem?,
|
|
|
+ photos: ArrayList<Photos>,
|
|
|
+ content: String,
|
|
|
+ x: Float,
|
|
|
+ y: Float,
|
|
|
+ linePoints: ArrayList<PipeLineItem>,
|
|
|
+ isLine: Boolean
|
|
|
) {
|
|
|
viewModelScope.launch {
|
|
|
//插入问题数据
|
|
@@ -172,16 +174,16 @@ class SpaceMapVM(
|
|
|
}
|
|
|
|
|
|
val problem = ProblemArchEntity(
|
|
|
- id = toString,
|
|
|
- floorId = floorId,
|
|
|
- projectId = projectId,
|
|
|
- buildingId = buildingId,
|
|
|
- geomType = if (array.size == 1) "point" else "line",
|
|
|
- problemState = 1,
|
|
|
- message = content,
|
|
|
- valid = 1,
|
|
|
- state = 0,
|
|
|
- geom = toJson
|
|
|
+ id = toString,
|
|
|
+ floorId = floorId,
|
|
|
+ projectId = projectId,
|
|
|
+ buildingId = buildingId,
|
|
|
+ geomType = if (array.size == 1) "point" else "line",
|
|
|
+ problemState = 1,
|
|
|
+ message = content,
|
|
|
+ valid = 1,
|
|
|
+ state = 0,
|
|
|
+ geom = toJson
|
|
|
)
|
|
|
repo.insProblem(problem)
|
|
|
|
|
@@ -196,17 +198,17 @@ class SpaceMapVM(
|
|
|
}
|
|
|
|
|
|
val file = FileEntity(
|
|
|
- id = uuid,
|
|
|
- bizType = "problem_arch",
|
|
|
- filePath = photo.key,
|
|
|
- fileType = "photo",
|
|
|
- clientPath = photo.path,
|
|
|
- refObjId = toString,
|
|
|
- orderNum = order,
|
|
|
- projectId = projectId,
|
|
|
- buildingId = buildingId,
|
|
|
- floorId = floorId,
|
|
|
- state = 0
|
|
|
+ id = uuid,
|
|
|
+ bizType = "problem_arch",
|
|
|
+ filePath = photo.key,
|
|
|
+ fileType = "photo",
|
|
|
+ clientPath = photo.path,
|
|
|
+ refObjId = toString,
|
|
|
+ orderNum = order,
|
|
|
+ projectId = projectId,
|
|
|
+ buildingId = buildingId,
|
|
|
+ floorId = floorId,
|
|
|
+ state = 0
|
|
|
)
|
|
|
repo.insFile(file)
|
|
|
}
|
|
@@ -233,8 +235,8 @@ class SpaceMapVM(
|
|
|
promodel.id = problem.id
|
|
|
|
|
|
val geomList = gson.fromJson<List<PointF>>(
|
|
|
- problem.geom,
|
|
|
- object : TypeToken<List<PointF?>?>() {}.type
|
|
|
+ problem.geom,
|
|
|
+ object : TypeToken<List<PointF?>?>() {}.type
|
|
|
)
|
|
|
promodel.geomType = problem.geomType
|
|
|
if (problem.geomType!! == "point") {
|
|
@@ -288,15 +290,15 @@ class SpaceMapVM(
|
|
|
pointZ.z = toString.toFloat()
|
|
|
val toJson = gson.toJsonTree(pointZ)
|
|
|
val qrcode = QrCodeEntity(
|
|
|
- id = IdUtil.simpleUUID(),
|
|
|
- qrCode = result!!,
|
|
|
- objId = choseSpace!!.data.id!!,
|
|
|
- projectId = projectId,
|
|
|
- buildingId = buildingId,
|
|
|
- floorId = floorId,
|
|
|
- remark = "wall",
|
|
|
- state = 0,
|
|
|
- location = toJson
|
|
|
+ id = IdUtil.simpleUUID(),
|
|
|
+ qrCode = result!!,
|
|
|
+ objId = choseSpace!!.data.id!!,
|
|
|
+ projectId = projectId,
|
|
|
+ buildingId = buildingId,
|
|
|
+ floorId = floorId,
|
|
|
+ remark = "wall",
|
|
|
+ state = 0,
|
|
|
+ location = toJson
|
|
|
)
|
|
|
repo.insQrcode(qrcode)
|
|
|
mEmitter.SendDirective(BIND_QECODE, null)
|
|
@@ -398,14 +400,14 @@ class SpaceMapVM(
|
|
|
var entity = repo.getServeAreaByObjId(deviceId)
|
|
|
if (entity == null) {
|
|
|
entity = ServeAreaEntity(
|
|
|
- id = IdUtil.simpleUUID(),
|
|
|
- projectId = projectId,
|
|
|
- buildingId = buildingId,
|
|
|
- floorId = floorId,
|
|
|
- state = 0,
|
|
|
- objId = deviceId,
|
|
|
- geomType = "polygon",
|
|
|
- geom = gson.toJsonTree(geom),
|
|
|
+ id = IdUtil.simpleUUID(),
|
|
|
+ projectId = projectId,
|
|
|
+ buildingId = buildingId,
|
|
|
+ floorId = floorId,
|
|
|
+ state = 0,
|
|
|
+ objId = deviceId,
|
|
|
+ geomType = "polygon",
|
|
|
+ geom = gson.toJsonTree(geom),
|
|
|
)
|
|
|
} else {
|
|
|
entity.geom = gson.toJsonTree(geom)
|
|
@@ -425,14 +427,14 @@ class SpaceMapVM(
|
|
|
var entity = repo.getServeAreaByObjId(deviceId)
|
|
|
if (entity == null) {
|
|
|
entity = ServeAreaEntity(
|
|
|
- id = IdUtil.simpleUUID(),
|
|
|
- projectId = projectId,
|
|
|
- buildingId = buildingId,
|
|
|
- floorId = floorId,
|
|
|
- state = 0,
|
|
|
- objId = deviceId,
|
|
|
- geomType = "polygon",
|
|
|
- geom = gson.toJsonTree(geom),
|
|
|
+ id = IdUtil.simpleUUID(),
|
|
|
+ projectId = projectId,
|
|
|
+ buildingId = buildingId,
|
|
|
+ floorId = floorId,
|
|
|
+ state = 0,
|
|
|
+ objId = deviceId,
|
|
|
+ geomType = "polygon",
|
|
|
+ geom = gson.toJsonTree(geom),
|
|
|
)
|
|
|
} else {
|
|
|
entity.geom = gson.toJsonTree(geom)
|
|
@@ -450,14 +452,14 @@ class SpaceMapVM(
|
|
|
val array = entity.geom!!.asJsonArray
|
|
|
if (array[0].isJsonObject) {
|
|
|
val ar = gson.fromJson<List<PointF>>(
|
|
|
- gson.toJson(entity.geom),
|
|
|
- object : TypeToken<List<PointF?>?>() {}.type
|
|
|
+ gson.toJson(entity.geom),
|
|
|
+ object : TypeToken<List<PointF?>?>() {}.type
|
|
|
)
|
|
|
mEmitter.SendDirective(SERVE_AREA, ar)
|
|
|
} else {
|
|
|
val ar = gson.fromJson<List<ArrayList<ArrayList<PointZ>>>>(
|
|
|
- gson.toJson(entity.geom),
|
|
|
- object : TypeToken<List<ArrayList<ArrayList<PointZ>>>>() {}.type
|
|
|
+ gson.toJson(entity.geom),
|
|
|
+ object : TypeToken<List<ArrayList<ArrayList<PointZ>>>>() {}.type
|
|
|
)
|
|
|
mEmitter.SendDirective(SERVE_AREAS, ar)
|
|
|
}
|