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

import com.github.microservice.models.device.DeviceAboutInfo;
import com.github.microservice.types.deviceUse.DeviceSpecType;
import com.github.microservice.types.deviceUse.DeviceState;
import com.github.microservice.types.deviceUse.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.OnLineState;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @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 String nickName;

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

    private String deviceTypeStr;

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

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

    private String deviceModelStr;

    public String getDeviceModelStr() {
        if (specType != null) {
            return specType.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 = "收款机构oid")
    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 OrganizationMiniModel beToOrganization;

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

    @Schema(description = "所属机构名称")
    private String beToName;

    public String getBeToName() {
        if (beToOrganization != null) {
            return beToOrganization.getName();
        }
        return "";
    }

    @Schema(description = "账单所属机构")
    private OrganizationMiniModel billOrganization;

    @Schema(description = "账单所属机构oid")
    private String billOid;

    @Schema(description = "账单所属机构名称")
    private String billName;

    public String getBillName() {
        if (ObjectUtils.isNotEmpty(billOrganization)) {
            return billOrganization.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 DeviceState 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;

    @Schema(description = "扩展信息")
    private Map<String, Object> metaInfo = new HashMap<String, Object>();
}
