package com.framework.mvvm.model.db.entity

import androidx.annotation.NonNull
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import cn.sagacloud.android.cadengine.types.PointZ
import kotlinx.serialization.Contextual
import kotlinx.serialization.Serializable
import org.json.JSONObject

/**
 * 对象表
 * 建筑，楼层，空间，设备
 */

@Entity(tableName = "object")
@Serializable
data class ObjectEntity(
    @NonNull
    @PrimaryKey val id: String,
    @ColumnInfo(name = "name") val name: String,
    @ColumnInfo(name = "project_id") val projectId: String,        // 项目id
    @ColumnInfo(name = "obj_type") val objType: String,            // 对象类型
    @ColumnInfo(name = "class_code") val classCode: String,        // 对象类型编码
    @ColumnInfo(name = "local_id") val localId: String?,            // 对象位置编码
    @ColumnInfo(name = "local_name") val localName: String?,        // 对象位置名称
    @ColumnInfo(name = "group_code") val groupCode: String?,        // 集团编码
    @ColumnInfo(name = "grouping") val grouping: Int?,              // 1 表示单个对象，2 表示对象组
    @ColumnInfo(name = "building_id") val buildingId: String?,      // 建筑id
    @ColumnInfo(name = "floor_id") val floorId: String?,            // 建筑id
    @ColumnInfo(name = "creator") val creator: String?,             // 创建人
    @ColumnInfo(name = "create_app") val createApp: String?,        // 创建对象的应用
    @ColumnInfo(name = "creation_time") val creationTime: Long?,  // 创建时间
    @ColumnInfo(name = "modifier") val modifier: String?,           // 修改人
    @ColumnInfo(name = "modified_time") var modifiedTime: String?,   // 修改时间
    @ColumnInfo(name = "client_device") val clientDevice: String?,  // 标识客户端设备
    @ColumnInfo(name = "client_id") val clientId: String?,          // 客户端生成id
    @ColumnInfo(name = "update_app") val updateApp: String?,        // 更新对象的应用
    @ColumnInfo(name = "upload_flag") var uploadFlag: String?,      // app端上传数据标记
    @ColumnInfo(name = "valid") val valid: Int?,                    // 合法标识: 1 合法, 0 非法
    @ColumnInfo(name = "delivery_state") val deliveryState: Int?,   // BDTP交付状态: 1 已交付, 0 待交付
    @ColumnInfo(name = "d2m_state") val d2mState: Int?,             // 逆向数据的数模同步状态(0:未同步;1:已同步)
    @ColumnInfo(name = "virtual_codes") val virtualCodes: String?,   // 虚点清单: Json 数据格式
    @ColumnInfo(name = "infos")
    @Contextual
    var infos: JSONObject?,               // 信息点数据: Json 数据格式
    @ColumnInfo(name = "str_infos") var strInfos: String?,           // 信息点数据: Json 数据格式
    @ColumnInfo(name = "floor_map") var floorMap: String?,           // 楼层地图
    @ColumnInfo(name = "state") var state: String? = "0"              // 数据状态：0：未处理，1：已处理 2：已上传
)


data class Infos(
    val bimId: String,
    val bimLocation: String,
    val codeType: Int,
    val height: Int,
    val modelId: String,
//    val outline: List<List<List<Outline>>>,
    val schemeId: String,
    val state: String,
    val RoomLocalName: String,
    val unit: String,
    val group: String,
    val label: String,
    val options: ArrayList<Options>,
    val dataType: String,
    val inputType: String,
    val code: String,
    val floorMap: String
)

data class Options(val txt: String, val `val`: String)

data class StrInfos(
    val floorMap: String,
    val state: String,
    val height: Int,
    val outline: ArrayList<ArrayList<ArrayList<PointZ>>>
)

data class StrInfosforBuild(
    val floorMap: String,
    val state: String,
    val height: Int,
)

data class StrInfosforEquip(
    val location: PointZ,
    var zRegion: String,
    var equipCheck: Boolean
)
