package com.zhongshu.card.client.model.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.model.base.SuperModel;
import com.zhongshu.card.client.model.org.OrganizationMiniModel;
import com.zhongshu.card.client.model.org.OrganizationSimpleModel;
import com.zhongshu.card.client.model.school.AreaSimpleModel;
import com.zhongshu.card.client.type.DataState;
import com.zhongshu.card.client.type.OnLineState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;

/**
 * @author TRX
 * @date 2024/6/14
 */
@Data
public class DeviceInfoModel extends SuperModel {

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

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

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

    private String deviceTypeStr;

    public String getDeviceTypeStr() {
        if (deviceType != null) {
            return deviceType.getRemark();
        }
        return "";
    }

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

    private String deviceModelStr;

    public String getDeviceModelStr() {
        if (deviceModel != null) {
            return deviceModel.getRemark();
        }
        return "";
    }

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

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

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

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

    @Schema(description = "关联的项目信息")
    private OrganizationSimpleModel projectInfo;

    @Schema(description = "")
    private OrganizationMiniModel organization;

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

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

    public String getBeLongOid() {
        if (organization != null) {
            return organization.getOid();
        }
        return "";
    }

    public String getBeLongName() {
        if (organization != null) {
            return organization.getName();
        }
        return "";
    }

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

    private String onLineStateStr;

    public String getOnLineStateStr() {
        if (onLineState != null) {
            return onLineState.getRemark();
        }
        return "";
    }

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

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

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

    private String stateStr;

    public String getStateStr() {
        if (state != null) {
            return state.getRemark();
        }
        return "";
    }

    @Schema(description = "区域信息")
    private AreaSimpleModel area;

    @Schema(description = "")
    private String areaId;

    public String getAreaId() {
        if (ObjectUtils.isNotEmpty(area)) {
            return area.getId();
        }
        return "";
    }

    private String areaName = "";

    public String getAreaName() {
        if (ObjectUtils.isNotEmpty(area)) {
            return area.getName();
        }
        return "";
    }

    private String areaAllName = "";

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