Commit 94cfc4a1b1560ad7dffb850d5cf96609322a01b8
1 parent
ed901bc9
【功能完善】IOT: ThingModel 服务和事件
Showing
8 changed files
with
169 additions
and
37 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelAccessModeEnum.java
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelParamDirectionEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.enums.thingmodel; | |
| 2 | + | |
| 3 | +import lombok.AllArgsConstructor; | |
| 4 | +import lombok.Getter; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * IOT 产品物模型参数是输入参数还是输出参数枚举 | |
| 8 | + * | |
| 9 | + * @author HUIHUI | |
| 10 | + */ | |
| 11 | +@AllArgsConstructor | |
| 12 | +@Getter | |
| 13 | +public enum IotProductThingModelParamDirectionEnum { | |
| 14 | + | |
| 15 | + INPUT("input"), // 输入参数 | |
| 16 | + OUTPUT("output"); // 输出参数 | |
| 17 | + | |
| 18 | + private final String direction; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelServiceCallTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.enums.thingmodel; | |
| 2 | + | |
| 3 | +import lombok.AllArgsConstructor; | |
| 4 | +import lombok.Getter; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * IOT 产品物模型服务调用方式枚举 | |
| 8 | + * | |
| 9 | + * @author HUIHUI | |
| 10 | + */ | |
| 11 | +@AllArgsConstructor | |
| 12 | +@Getter | |
| 13 | +public enum IotProductThingModelServiceCallTypeEnum { | |
| 14 | + | |
| 15 | + ASYNC("async"), // 异步调用 | |
| 16 | + SYNC("sync"); // 同步调用 | |
| 17 | + | |
| 18 | + private final String type; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelServiceEventTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.enums.thingmodel; | |
| 2 | + | |
| 3 | +import lombok.AllArgsConstructor; | |
| 4 | +import lombok.Getter; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * IOT 产品物模型事件类型枚举 | |
| 8 | + * | |
| 9 | + * @author HUIHUI | |
| 10 | + */ | |
| 11 | +@AllArgsConstructor | |
| 12 | +@Getter | |
| 13 | +public enum IotProductThingModelServiceEventTypeEnum { | |
| 14 | + | |
| 15 | + INFO("info"), // 信息 | |
| 16 | + ALERT("alert"), // 告警 | |
| 17 | + ERROR("error"); // 故障 | |
| 18 | + | |
| 19 | + private final String type; | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelEvent.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType.ThingModelArgument; | |
| 3 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelServiceEventTypeEnum; | |
| 4 | 4 | import lombok.Data; |
| 5 | + | |
| 5 | 6 | import java.util.List; |
| 6 | 7 | |
| 8 | +/** | |
| 9 | + * 物模型中的事件 | |
| 10 | + * | |
| 11 | + * @author HUIHUI | |
| 12 | + */ | |
| 7 | 13 | @Data |
| 8 | 14 | public class ThingModelEvent { |
| 9 | 15 | |
| ... | ... | @@ -19,14 +25,28 @@ public class ThingModelEvent { |
| 19 | 25 | * 事件描述 |
| 20 | 26 | */ |
| 21 | 27 | private String description; |
| 22 | - | |
| 28 | + /** | |
| 29 | + * 是否是标准品类的必选事件。 | |
| 30 | + * | |
| 31 | + * - true:是 | |
| 32 | + * - false:否 | |
| 33 | + */ | |
| 34 | + private Boolean required; | |
| 23 | 35 | /** |
| 24 | 36 | * 事件类型 |
| 25 | 37 | * |
| 26 | - * "info"、"alert"、"error" | |
| 38 | + * 关联枚举 {@link IotProductThingModelServiceEventTypeEnum} | |
| 39 | + */ | |
| 40 | + private String eventType; | |
| 41 | + /** | |
| 42 | + * 事件的输出参数 | |
| 43 | + * | |
| 44 | + * 输出参数定义事件调用后返回的结果或反馈信息,用于确认操作结果或提供额外的信息。 | |
| 45 | + */ | |
| 46 | + private List<ThingModelInputOutputParam> outputParams; | |
| 47 | + /** | |
| 48 | + * 标识设备需要执行的具体操作 | |
| 27 | 49 | */ |
| 28 | - private String type; | |
| 29 | - private List<ThingModelArgument> outputData; | |
| 30 | 50 | private String method; |
| 31 | 51 | |
| 32 | 52 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelInputOutputParam.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType.ThingModelDataSpecs; | |
| 4 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelParamDirectionEnum; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * IOT 产品物模型中的服务、事件的输入输出参数 | |
| 11 | + * | |
| 12 | + * @author HUIHUI | |
| 13 | + */ | |
| 14 | +@Data | |
| 15 | +public class ThingModelInputOutputParam { | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * 参数标识符 | |
| 19 | + */ | |
| 20 | + private String identifier; | |
| 21 | + /** | |
| 22 | + * 参数名称 | |
| 23 | + */ | |
| 24 | + private String name; | |
| 25 | + /** | |
| 26 | + * 参数描述 | |
| 27 | + */ | |
| 28 | + private String description; | |
| 29 | + /** | |
| 30 | + * 用于区分输入或输出参数 | |
| 31 | + * | |
| 32 | + * 关联枚举 {@link IotProductThingModelParamDirectionEnum} | |
| 33 | + */ | |
| 34 | + private String direction; | |
| 35 | + /** | |
| 36 | + * 参数的序号。从 0 开始排序,且不能重复。 | |
| 37 | + */ | |
| 38 | + private Integer paraOrder; | |
| 39 | + /** | |
| 40 | + * 参数值的数据类型,与 dataSpecs 的 dataType 保持一致 | |
| 41 | + */ | |
| 42 | + private String dataType; | |
| 43 | + /** | |
| 44 | + * 参数值的数据类型(dataType)为非列表型(int、float、double、text、date、array)的数据规范存储在 dataSpecs 中 | |
| 45 | + */ | |
| 46 | + private ThingModelDataSpecs dataSpecs; | |
| 47 | + /** | |
| 48 | + * 参数值的数据类型(dataType)为列表型(enum、bool、struct)的数据规范存储在 dataSpecsList 中 | |
| 49 | + */ | |
| 50 | + private List<ThingModelDataSpecs> dataSpecsList; | |
| 51 | + | |
| 52 | +} | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelService.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType.ThingModelArgument; | |
| 3 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelServiceCallTypeEnum; | |
| 4 | 4 | import lombok.Data; |
| 5 | + | |
| 5 | 6 | import java.util.List; |
| 6 | 7 | |
| 8 | +/** | |
| 9 | + * 物模型中的服务 | |
| 10 | + * | |
| 11 | + * @author HUIHUI | |
| 12 | + */ | |
| 7 | 13 | @Data |
| 8 | 14 | public class ThingModelService { |
| 9 | 15 | |
| ... | ... | @@ -19,15 +25,34 @@ public class ThingModelService { |
| 19 | 25 | * 服务描述 |
| 20 | 26 | */ |
| 21 | 27 | private String description; |
| 22 | - | |
| 28 | + /** | |
| 29 | + * 是否是标准品类的必选服务。 | |
| 30 | + * | |
| 31 | + * - true:是 | |
| 32 | + * - false:否 | |
| 33 | + */ | |
| 34 | + private Boolean required; | |
| 23 | 35 | /** |
| 24 | 36 | * 调用类型 |
| 25 | 37 | * |
| 26 | - * "sync"、"async" | |
| 38 | + * 关联枚举 {@link IotProductThingModelServiceCallTypeEnum} | |
| 27 | 39 | */ |
| 28 | 40 | private String callType; |
| 29 | - private List<ThingModelArgument> inputData; | |
| 30 | - private List<ThingModelArgument> outputData; | |
| 41 | + /** | |
| 42 | + * 服务的输入参数 | |
| 43 | + * | |
| 44 | + * 输入参数定义服务调用时所需提供的信息,用于控制设备行为或执行特定任务 | |
| 45 | + */ | |
| 46 | + private List<ThingModelInputOutputParam> inputParams; | |
| 47 | + /** | |
| 48 | + * 服务的输出参数 | |
| 49 | + * | |
| 50 | + * 输出参数定义服务调用后返回的结果或反馈信息,用于确认操作结果或提供额外的信息。 | |
| 51 | + */ | |
| 52 | + private List<ThingModelInputOutputParam> outputParams; | |
| 53 | + /** | |
| 54 | + * 标识设备需要执行的具体操作 | |
| 55 | + */ | |
| 31 | 56 | private String method; |
| 32 | 57 | |
| 33 | 58 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/dataType/ThingModelArgument.java deleted
| 1 | -package cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.dataType; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelProperty; | |
| 4 | -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
| 5 | -import lombok.Data; | |
| 6 | - | |
| 7 | -@Data | |
| 8 | -@JsonIgnoreProperties(ignoreUnknown = true) | |
| 9 | -public class ThingModelArgument { | |
| 10 | - | |
| 11 | - public static final String DIRECTION_INPUT = "input"; | |
| 12 | - public static final String DIRECTION_OUTPUT = "output"; | |
| 13 | - | |
| 14 | - private String identifier; | |
| 15 | - private String name; | |
| 16 | - /** | |
| 17 | - * 物模型中的属性 | |
| 18 | - */ | |
| 19 | - private ThingModelProperty property; | |
| 20 | - /** | |
| 21 | - * 用于区分输入或输出参数,"input" 或 "output" | |
| 22 | - */ | |
| 23 | - private String direction; | |
| 24 | - private String description; | |
| 25 | - | |
| 26 | -} |