package com.zhongshu.card.server.core.domain.devices;

import com.github.microservice.models.device.DeviceAboutInfo;
import com.github.microservice.models.type.DeviceSpecType;
import com.github.microservice.models.type.DeviceType;
import com.zhongshu.card.client.type.DataState;
import com.zhongshu.card.client.type.OnLineState;
import com.zhongshu.card.server.core.domain.base.SuperMain;
import com.zhongshu.card.server.core.domain.org.Organization;
import com.zhongshu.card.server.core.domain.school.Area;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * 物联网设备信息
 *
 * @author TRX
 * @date 2024/5/14
 */
@Data
@Document
@NoArgsConstructor
@AllArgsConstructor
public class DeviceInfo extends SuperMain {

    @Indexed
    @Schema(description = "设备ID、设备号")
    private String deviceId;

    @Schema(description = "设备名称")
    private String deviceName;

    @Schema(description = "关联的项目code")
    private String projectInfoCode;

    @Schema(description = "关联的项目Name")
    private String projectInfoName;

    @Schema(description = "所属机构")
    @DBRef(lazy = true)
    private Organization organization;

    @Schema(description = "所属机构oid")
    private String beLongOid;

    @Schema(description = "所属机构name")
    private String beLongName;

    @Schema(description = "设备类型，如 消费机 门禁机")
    private DeviceType deviceType;

    @Schema(description = "设备型号")
    private DeviceSpecType deviceModel;

    @Schema(description = "网关号")
    private String gateWayId;

    @Schema(description = "网关名称")
    private String gateWayName;

    @Schema(description = "是否在线")
    private OnLineState onLineState = OnLineState.OnLine;

    @Schema(description = "最上线时间")
    private Long lastOnlineTime;

    @Schema(description = "设备IP地址")
    private String ip;

    @Schema(description = "数据状态")
    private DataState state = DataState.Enable;

    @Schema(description = "区域信息")
    @DBRef(lazy = true)
    private Area area;

    @Schema(description = "区域ID")
    private String areaId;

    @Schema(description = "区域所有上级ID路径，如：a1/a12/a123")
    private String areaPaths = "";

    @Schema(description = "是否开放使用")
    private Boolean isOpenUse = Boolean.FALSE;

    @Schema(description = "设备关联的扩展信息")
    private DeviceAboutInfo aboutInfo;

}
