class DeviceTagEntity extends GenericEntity<String> {

    @Column(length = 64, nullable = false, updatable = false)
    @NotBlank(message = "[deviceId]不能为空", groups = CreateGroup.class)
    @Schema(description = "设备ID")
    private String deviceId;

    @Column(length = 32, updatable = false, nullable = false)
    @NotBlank(message = "[key]不能为空", groups = CreateGroup.class)
    @Schema(description = "标签标识")
    private String key;

    @Column
    @Schema(description = "标签名称")
    private String name;

    @Column(length = 256, nullable = false)
    @NotNull(message = "[value]不能为空", groups = CreateGroup.class)
    @Length(max = 256, message = "[value]长度不能大于256", groups = CreateGroup.class)
    @Schema(description = "标签值")
    private String value;

    @Column(length = 32, nullable = false)
    @DefaultValue("string")
    @Schema(description = "类型", defaultValue = "string")
    private String type;

    @Column(updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(description = "创建时间(只读)")
    private Date createTime;

    @Column
    @Schema(description = "说明")
    private String description;

    private DataType dataType;

    public static DeviceTagEntity of(PropertyMetadata property) {
       DeviceTagEntity entity = new DeviceTagEntity();
        entity.setKey(property.getId());
        entity.setName(property.getName());
        entity.setType(property.getValueType().getId());
        entity.setDescription(property.getDescription());
        entity.setCreateTime(new Date());
        entity.setDataType(property.getValueType());
        return entity;
    }


    //以物模型标签基础数据为准，重构数据库保存的可能已过时的标签数据
    public DeviceTagEntity restructure(DeviceTagEntity tag) {
        this.setDataType(tag.getDataType());
        this.setName(tag.getName());
        this.setType(tag.getType());
        this.setKey(tag.getKey());
        this.setDescription(tag.getDescription());
        return this;
    }

    public static DeviceTagEntity of(PropertyMetadata property, Object value) {<FILL_FUNCTION_BODY>}


    public static String createTagId(String deviceId, String key) {
        return DigestUtils.md5Hex(deviceId + ":" + key);
    }
}

        DeviceTagEntity tag = of(property);

        DataType type = property.getValueType();
        if (type instanceof Converter) {
            Object newValue = ((Converter<?>) type).convert(value);
            if (newValue != null) {
                value = newValue;
            }
        }

        String stringValue;
        switch (type.getId()) {
            //结构体和数组类型转为json字符串
            case ObjectType.ID:
            case ArrayType.ID:
                stringValue = JSON.toJSONString(value);
                break;
            default:
                stringValue = String.valueOf(value);
        }

        tag.setValue(stringValue);
        return tag;
    
<no_super_class>