package cn.iocoder.yudao.module.iot.controller.admin.device.vo;

import cn.iocoder.yudao.module.iot.controller.admin.devicemodelrules.vo.PointRulesRespVO;
import cn.iocoder.yudao.module.iot.dal.dataobject.devicepointrules.DevicePointRulesDO;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;

@Schema(description = "管理后台 - 物联设备 Response VO")
@Data
@ExcelIgnoreUnannotated
public class DeviceRespVO {

    @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26404")
//    @ExcelProperty("ID")
    private Long id;

    @Schema(description = "设备编号")
    @ExcelProperty("设备编号")
    private String deviceCode;

    @Schema(description = "设备名称", example = "赵六")
    @ExcelProperty("设备名称")
    private String deviceName;

    @Schema(description = "设备类型", example = "2")
//    @ExcelProperty(value = "设备类型", converter = DictConvert.class)
    @DictFormat("iot_device_type") // TODO 代码优化：建议设置到对应的 DictTypeConstants 枚举类中
    private String deviceType;

    @Schema(description = "状态", example = "1")
    @ExcelProperty(value = "连接状态", converter = DictConvert.class)
    @DictFormat("iot_gateway_status") // TODO 代码优化：建议设置到对应的 DictTypeConstants 枚举类中
    private String status;

    @Schema(description = "读主题")
//    @ExcelProperty("读主题")
    private String readTopic;

    @Schema(description = "写主题")
//    @ExcelProperty("写主题")
    private String writeTopic;

    @Schema(description = "网关id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16311")
//    @ExcelProperty("网关id")
    private Long gatewayId;

    @Schema(description = "设备品牌id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24731")
//    @ExcelProperty("设备品牌id")
    private Long deviceBrandId;

    @Schema(description = "离线间隔", requiredMode = Schema.RequiredMode.REQUIRED)
//    @ExcelProperty("离线间隔")
    private Long offLineDuration;

    @Schema(description = "最后上线时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("最后上线时间")
    private LocalDateTime lastOnlineTime;

    @Schema(description = "备注", example = "你说的对")
//    @ExcelProperty("备注")
    private String remark;

    @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
//    @ExcelProperty(value = "是否启用", converter = DictConvert.class)
    @DictFormat("infra_boolean_string") // TODO 代码优化：建议设置到对应的 DictTypeConstants 枚举类中
    private Boolean isEnable;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("创建时间")
    @ColumnWidth(20) // 设置此列的宽度为 20 个字符的宽度
    private LocalDateTime createTime;

    @Schema(description = "关联设备模型", example = "1")
//    @ExcelProperty("关联设备模型")
    private Long deviceModelId;

    @Schema(description = "通讯协议", example = "OPCUA")
    @ExcelProperty("通讯协议")
    private String protocol;

    @Schema(description = "采集周期", example = "30")
    @ExcelProperty("采集周期")
    private Double sampleCycle;

    @Schema(description = "端点url", example = "opc.tcp://127.0.0.1:48401")
    @ExcelProperty("端点url")
    private String url;

    @Schema(description = "用户名", example = "admin")
    @ExcelProperty("用户名")
    private String username;

    @Schema(description = "密码", example = "1234")
    @ExcelProperty("密码")
    private String password;

    @Schema(description = "运行状态")
    @ExcelProperty("运行状态")
    private String operatingStatus;


    @Schema(description = "采集时间")
    @ExcelProperty("采集时间")
    @ColumnWidth(20)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime collectionTime;

    @Schema(description = "关联组织", example = "1")
    private Long org;

    @Schema(description = "mqtt订阅主题")
    private String topic;
}