|
|
@@ -0,0 +1,100 @@
|
|
|
+package org.jetlinks.community.device.entity;
|
|
|
+
|
|
|
+import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import lombok.Getter;
|
|
|
+import lombok.NoArgsConstructor;
|
|
|
+import lombok.Setter;
|
|
|
+import org.hswebframework.ezorm.rdb.mapping.annotation.*;
|
|
|
+import org.hswebframework.web.api.crud.entity.GenericEntity;
|
|
|
+import org.hswebframework.web.validator.CreateGroup;
|
|
|
+import org.jetlinks.community.device.enums.DeviceProductState;
|
|
|
+import org.jetlinks.community.device.enums.DirectiveState;
|
|
|
+import org.jetlinks.core.message.DeviceMessage;
|
|
|
+import org.jetlinks.core.message.MessageType;
|
|
|
+import javax.persistence.Column;
|
|
|
+import javax.persistence.Index;
|
|
|
+import javax.persistence.Table;
|
|
|
+import javax.validation.constraints.NotBlank;
|
|
|
+import java.sql.JDBCType;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author lifang
|
|
|
+ * @version 1.0.0
|
|
|
+ * @ClassName DeviceDirectivesEntity.java
|
|
|
+ * @Description 设备下发指令消息
|
|
|
+ * @createTime 2021年11月23日 15:16:00
|
|
|
+ */
|
|
|
+@Getter
|
|
|
+@Setter
|
|
|
+@AllArgsConstructor
|
|
|
+@NoArgsConstructor
|
|
|
+@Table(name = "dev_device_directives",indexes = {
|
|
|
+ @Index(name = "directives_device_id", columnList = "device_id,message_id",unique = true),
|
|
|
+})
|
|
|
+public class DeviceDirectivesEntity extends GenericEntity<String> {
|
|
|
+
|
|
|
+ @Comment("产品id")
|
|
|
+ @Column(name = "product_id",nullable = false)
|
|
|
+ @Schema(description = "产品id")
|
|
|
+ private String productId;
|
|
|
+
|
|
|
+ @Comment("设备id")
|
|
|
+ @Column(name = "device_id",nullable = false)
|
|
|
+ @Schema(description = "设备id")
|
|
|
+ private String deviceId;
|
|
|
+
|
|
|
+ @Comment("消息id")
|
|
|
+ @Column(name = "message_id",nullable = false)
|
|
|
+ @Schema(description = "消息id")
|
|
|
+ private String messageId;
|
|
|
+
|
|
|
+ @Comment("消息发送时间")
|
|
|
+ @Column(name = "send_timestamp",nullable = false)
|
|
|
+ @Schema(description = "消息发送时间")
|
|
|
+ private Long sendTimestamp;
|
|
|
+
|
|
|
+ @Comment("消息类型")
|
|
|
+ @Column(name = "message_type",nullable = false)
|
|
|
+ @NotBlank(message = "消息类型不能为空", groups = CreateGroup.class)
|
|
|
+ private String messageType;
|
|
|
+
|
|
|
+ @Comment("错误原因")
|
|
|
+ @Column(name = "last_error")
|
|
|
+ @Schema(description = "错误原因")
|
|
|
+ private String lastError;
|
|
|
+
|
|
|
+ @Comment("回复内容")
|
|
|
+ @Column(name = "reply_message")
|
|
|
+ @ColumnType(jdbcType = JDBCType.CLOB)
|
|
|
+ @Schema(description = "回复内容")
|
|
|
+ @JsonCodec
|
|
|
+ private DeviceMessage replyMessage;
|
|
|
+
|
|
|
+ @Comment("下发指令")
|
|
|
+ @Column(name = "send_message")
|
|
|
+ @ColumnType(jdbcType = JDBCType.CLOB)
|
|
|
+ @Schema(description = "下发指令")
|
|
|
+ @JsonCodec
|
|
|
+ private DeviceMessage sendMessage;
|
|
|
+
|
|
|
+ @Column(name = "state",length = 16)
|
|
|
+ @EnumCodec
|
|
|
+ @ColumnType(javaType = String.class)
|
|
|
+ @DefaultValue("wait")
|
|
|
+ @Schema(
|
|
|
+ description = "状态(只读)"
|
|
|
+ ,accessMode = Schema.AccessMode.READ_ONLY
|
|
|
+ , defaultValue = "wait"
|
|
|
+ )
|
|
|
+ private DirectiveState state;
|
|
|
+
|
|
|
+ public static DeviceDirectivesEntity of(String productId,
|
|
|
+ String deviceId,
|
|
|
+ String messageId,
|
|
|
+ long sendTimestamp,
|
|
|
+ String messageType, DeviceMessage sendMessage) {
|
|
|
+ return new DeviceDirectivesEntity(productId,deviceId,messageId,sendTimestamp,messageType,null,null,sendMessage,null);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|