package com.zhongshu.card.client.model.devices;

import com.github.microservice.types.deviceUse.DeviceType;
import com.zhongshu.card.client.model.base.SuperModel;
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 DeviceInfoStoreModel 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 String gateWayId;

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

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

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

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

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

    @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 Boolean isOpenUse = Boolean.FALSE;
}
