|
@@ -1,6 +1,8 @@
|
|
|
package org.jetlinks.community.device.entity;
|
|
package org.jetlinks.community.device.entity;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
|
|
|
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.Getter;
|
|
import lombok.Getter;
|
|
@@ -10,13 +12,11 @@ import org.hswebframework.ezorm.rdb.mapping.annotation.*;
|
|
|
import org.hswebframework.web.api.crud.entity.GenericEntity;
|
|
import org.hswebframework.web.api.crud.entity.GenericEntity;
|
|
|
import org.hswebframework.web.dict.Dict;
|
|
import org.hswebframework.web.dict.Dict;
|
|
|
import org.hswebframework.web.dict.EnumDict;
|
|
import org.hswebframework.web.dict.EnumDict;
|
|
|
-import org.hswebframework.web.validator.CreateGroup;
|
|
|
|
|
import org.jetlinks.community.device.enums.DirectiveState;
|
|
import org.jetlinks.community.device.enums.DirectiveState;
|
|
|
-import org.jetlinks.core.message.DeviceMessage;
|
|
|
|
|
|
|
+import org.jetlinks.core.message.CommonDeviceMessage;
|
|
|
import javax.persistence.Column;
|
|
import javax.persistence.Column;
|
|
|
import javax.persistence.Index;
|
|
import javax.persistence.Index;
|
|
|
import javax.persistence.Table;
|
|
import javax.persistence.Table;
|
|
|
-import javax.validation.constraints.NotBlank;
|
|
|
|
|
import java.sql.JDBCType;
|
|
import java.sql.JDBCType;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -28,7 +28,6 @@ import java.sql.JDBCType;
|
|
|
*/
|
|
*/
|
|
|
@Getter
|
|
@Getter
|
|
|
@Setter
|
|
@Setter
|
|
|
-@AllArgsConstructor
|
|
|
|
|
@NoArgsConstructor
|
|
@NoArgsConstructor
|
|
|
@Table(name = "dev_device_directives",indexes = {
|
|
@Table(name = "dev_device_directives",indexes = {
|
|
|
@Index(name = "directives_device_id", columnList = "device_id,message_id",unique = true),
|
|
@Index(name = "directives_device_id", columnList = "device_id,message_id",unique = true),
|
|
@@ -74,13 +73,15 @@ public class DeviceDirectivesEntity extends GenericEntity<String> {
|
|
|
@Column(name = "reply_message")
|
|
@Column(name = "reply_message")
|
|
|
@ColumnType(jdbcType = JDBCType.CLOB)
|
|
@ColumnType(jdbcType = JDBCType.CLOB)
|
|
|
@Schema(description = "回复内容")
|
|
@Schema(description = "回复内容")
|
|
|
- private DeviceMessage replyMessage;
|
|
|
|
|
|
|
+ @JsonCodec
|
|
|
|
|
+ private CommonDeviceMessage replyMessage;
|
|
|
|
|
|
|
|
@Comment("下发指令")
|
|
@Comment("下发指令")
|
|
|
@Column(name = "send_message")
|
|
@Column(name = "send_message")
|
|
|
@ColumnType(jdbcType = JDBCType.CLOB)
|
|
@ColumnType(jdbcType = JDBCType.CLOB)
|
|
|
@Schema(description = "下发指令")
|
|
@Schema(description = "下发指令")
|
|
|
- private DeviceMessage sendMessage;
|
|
|
|
|
|
|
+ @JsonCodec
|
|
|
|
|
+ private CommonDeviceMessage sendMessage;
|
|
|
|
|
|
|
|
@Column(name = "state",length = 16)
|
|
@Column(name = "state",length = 16)
|
|
|
@EnumCodec
|
|
@EnumCodec
|
|
@@ -93,11 +94,23 @@ public class DeviceDirectivesEntity extends GenericEntity<String> {
|
|
|
)
|
|
)
|
|
|
private DirectiveState state;
|
|
private DirectiveState state;
|
|
|
|
|
|
|
|
|
|
+ public DeviceDirectivesEntity(String productId, String deviceId, String messageId, Long sendTimestamp, MessageType messageType, String lastError, CommonDeviceMessage replyMessage, CommonDeviceMessage sendMessage, DirectiveState state) {
|
|
|
|
|
+ this.productId = productId;
|
|
|
|
|
+ this.deviceId = deviceId;
|
|
|
|
|
+ this.messageId = messageId;
|
|
|
|
|
+ this.sendTimestamp = sendTimestamp;
|
|
|
|
|
+ this.messageType = messageType;
|
|
|
|
|
+ this.lastError = lastError;
|
|
|
|
|
+ this.replyMessage = replyMessage;
|
|
|
|
|
+ this.sendMessage = sendMessage;
|
|
|
|
|
+ this.state = state;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static DeviceDirectivesEntity of(String productId,
|
|
public static DeviceDirectivesEntity of(String productId,
|
|
|
String deviceId,
|
|
String deviceId,
|
|
|
String messageId,
|
|
String messageId,
|
|
|
long sendTimestamp,
|
|
long sendTimestamp,
|
|
|
- MessageType messageType, DeviceMessage sendMessage) {
|
|
|
|
|
|
|
+ MessageType messageType, CommonDeviceMessage sendMessage) {
|
|
|
return new DeviceDirectivesEntity(productId,deviceId,messageId,sendTimestamp,messageType,null,null,sendMessage,null);
|
|
return new DeviceDirectivesEntity(productId,deviceId,messageId,sendTimestamp,messageType,null,null,sendMessage,null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -114,5 +127,18 @@ public class DeviceDirectivesEntity extends GenericEntity<String> {
|
|
|
public String getValue() {
|
|
public String getValue() {
|
|
|
return this.name();
|
|
return this.name();
|
|
|
}
|
|
}
|
|
|
|
|
+ public org.jetlinks.core.message.MessageType convertTo(){
|
|
|
|
|
+ if(READ_PROPERTY.equals(this)){
|
|
|
|
|
+ return org.jetlinks.core.message.MessageType.READ_PROPERTY;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(WRITE_PROPERTY.equals(this)){
|
|
|
|
|
+ return org.jetlinks.core.message.MessageType.WRITE_PROPERTY;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(INVOKE_FUNCTION.equals(this)){
|
|
|
|
|
+ return org.jetlinks.core.message.MessageType.INVOKE_FUNCTION;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
}
|
|
}
|