Commit f930f31fababd8b6a0ecdde4d34a253d123ea244

Authored by puhui999
1 parent c5894765

【功能完善】IoT: 产品物模型属性相关

Showing 39 changed files with 425 additions and 419 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/IotThinkModelFunctionController.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/IotProductThingModelController.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 5 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionPageReqVO;
7   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionRespVO;
8   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionSaveReqVO;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionPageReqVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionRespVO;
  8 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionSaveReqVO;
9 9 import cn.iocoder.yudao.module.iot.convert.thinkmodelfunction.IotThinkModelFunctionConvert;
10   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
  10 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
11 11 import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService;
12 12 import io.swagger.v3.oas.annotations.Operation;
13 13 import io.swagger.v3.oas.annotations.Parameter;
... ... @@ -26,7 +26,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
26 26 @RestController
27 27 @RequestMapping("/iot/think-model-function")
28 28 @Validated
29   -public class IotThinkModelFunctionController {
  29 +public class IotProductThingModelController {
30 30  
31 31 @Resource
32 32 private IotThinkModelFunctionService thinkModelFunctionService;
... ... @@ -60,7 +60,7 @@ public class IotThinkModelFunctionController {
60 60 @Parameter(name = "id", description = "编号", required = true)
61 61 @PreAuthorize("@ss.hasPermission('iot:think-model-function:query')")
62 62 public CommonResult<IotThinkModelFunctionRespVO> getThinkModelFunction(@RequestParam("id") Long id) {
63   - IotThinkModelFunctionDO function = thinkModelFunctionService.getThinkModelFunction(id);
  63 + IotProductThingModelDO function = thinkModelFunctionService.getThinkModelFunction(id);
64 64 return success(IotThinkModelFunctionConvert.INSTANCE.convert(function));
65 65 }
66 66  
... ... @@ -69,7 +69,7 @@ public class IotThinkModelFunctionController {
69 69 @Parameter(name = "productId", description = "产品ID", required = true, example = "1024")
70 70 @PreAuthorize("@ss.hasPermission('iot:think-model-function:query')")
71 71 public CommonResult<List<IotThinkModelFunctionRespVO>> getThinkModelFunctionListByProductId(@RequestParam("productId") Long productId) {
72   - List<IotThinkModelFunctionDO> list = thinkModelFunctionService.getThinkModelFunctionListByProductId(productId);
  72 + List<IotProductThingModelDO> list = thinkModelFunctionService.getThinkModelFunctionListByProductId(productId);
73 73 return success(IotThinkModelFunctionConvert.INSTANCE.convertList(list));
74 74 }
75 75  
... ... @@ -77,7 +77,7 @@ public class IotThinkModelFunctionController {
77 77 @Operation(summary = "获得产品物模型分页")
78 78 @PreAuthorize("@ss.hasPermission('iot:think-model-function:query')")
79 79 public CommonResult<PageResult<IotThinkModelFunctionRespVO>> getThinkModelFunctionPage(@Valid IotThinkModelFunctionPageReqVO pageReqVO) {
80   - PageResult<IotThinkModelFunctionDO> pageResult = thinkModelFunctionService.getThinkModelFunctionPage(pageReqVO);
  80 + PageResult<IotProductThingModelDO> pageResult = thinkModelFunctionService.getThinkModelFunctionPage(pageReqVO);
81 81 return success(BeanUtils.toBean(pageResult, IotThinkModelFunctionRespVO.class));
82 82 }
83 83  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/IotThinkModelFunctionController.http renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/IotThinkModelFunctionController.http
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/ThingModelEvent.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/ThingModelEvent.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel;
2 2  
3   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArgument;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArgument;
4 4 import lombok.Data;
5 5 import java.util.List;
6 6  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/ThingModelProperty.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel;
  2 +
  3 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelDataSpecs;
  4 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelAccessModeEnum;
  5 +import lombok.Data;
  6 +
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * 物模型中的属性
  11 + *
  12 + * dataSpecs 和 dataSpecsList 之中必须传入且只能传入一个
  13 + *
  14 + * @author HUIHUI
  15 + */
  16 +@Data
  17 +public class ThingModelProperty {
  18 +
  19 + /**
  20 + * 属性标识符
  21 + */
  22 + private String identifier;
  23 + /**
  24 + * 属性名称
  25 + */
  26 + private String name;
  27 + /**
  28 + * 属性描述
  29 + */
  30 + private String description;
  31 + /**
  32 + * 云端可以对该属性进行的操作类型
  33 + * 关联枚举 {@link IotProductThingModelAccessModeEnum}
  34 + */
  35 + private String accessMode;
  36 + /**
  37 + * 是否是标准品类的必选服务。
  38 + *
  39 + * - true:是
  40 + * - false:否
  41 + */
  42 + private Boolean required;
  43 + /**
  44 + * 数据类型,与 dataSpecs 的 dataType 保持一致
  45 + */
  46 + private String dataType;
  47 + /**
  48 + * 数据类型(dataType)为非列表型(int、float、double、text、date、array)的数据规范存储在 dataSpecs 中
  49 + */
  50 + private ThingModelDataSpecs dataSpecs;
  51 + /**
  52 + * 数据类型(dataType)为列表型(enum、bool、struct)的数据规范存储在 dataSpecsList 中
  53 + */
  54 + private List<ThingModelDataSpecs> dataSpecsList;
  55 +
  56 +}
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/ThingModelRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/ThingModelRespVO.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel;
2 2  
3 3 import lombok.*;
4 4  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/ThingModelService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/ThingModelService.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel;
2 2  
3   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArgument;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArgument;
4 4 import lombok.Data;
5 5 import java.util.List;
6 6  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelArgument.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelArgument.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
2 2  
3 3 import lombok.Data;
4 4  
... ... @@ -7,7 +7,7 @@ public class ThingModelArgument {
7 7  
8 8 private String identifier;
9 9 private String name;
10   - private ThingModelDataType dataType;
  10 + private ThingModelDataSpecs dataType;
11 11 /**
12 12 * 用于区分输入或输出参数,"input" 或 "output"
13 13 */
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelArrayDataSpecs.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 物模型数据类型为数组的 DataSpec 定义
  9 + *
  10 + * @author HUIHUI
  11 + */
  12 +@Data
  13 +public class ThingModelArrayDataSpecs extends ThingModelDataSpecs {
  14 +
  15 + /**
  16 + * 数组中的元素个数。
  17 + */
  18 + private Long size;
  19 + /**
  20 + * 数组中的元素的数据类型。可选值:struct、int、float、double 或 text。
  21 + */
  22 + private String childDataType;
  23 + /**
  24 + * 数据类型(dataType)为非列表型(int、float、double、text、date、array)的数据规范存储在 dataSpecs 中。
  25 + * 仅当 dataType 不是列表型时,才传入此字段。
  26 + */
  27 + private ThingModelDataSpecs dataSpecs;
  28 + /**
  29 + * 数据类型(dataType)为列表型(enum、bool、struct)的数据规范存储在 dataSpecsList 中。
  30 + * 仅当 dataType 是列表型时,才传入此字段。
  31 + */
  32 + private List<ThingModelDataSpecs> dataSpecsList;
  33 +
  34 +}
  35 +
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelBoolOrEnumDataSpecs.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  2 +
  3 +import lombok.Data;
  4 +import lombok.EqualsAndHashCode;
  5 +
  6 +/**
  7 + * 物模型数据类型为布尔型或枚举型的 DataSpec 定义
  8 + *
  9 + * 数据类型,取值为 bool 或 enum。
  10 + *
  11 + * @author HUIHUI
  12 + */
  13 +@Data
  14 +@EqualsAndHashCode(callSuper = true)
  15 +public class ThingModelBoolOrEnumDataSpecs extends ThingModelDataSpecs {
  16 +
  17 + /**
  18 + * 枚举项的名称。
  19 + * 可包含中文、大小写英文字母、数字、下划线(_)和短划线(-)。
  20 + * 必须以中文、英文字母或数字开头,长度不超过 20 个字符。
  21 + */
  22 + private String name;
  23 + /**
  24 + * 枚举值。
  25 + */
  26 + private Integer value;
  27 +
  28 +}
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelDataSpecs.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonSubTypes;
  4 +import com.fasterxml.jackson.annotation.JsonTypeInfo;
  5 +import lombok.Data;
  6 +
  7 +/**
  8 + * 抽象类 ThingModelDataSpecs
  9 + *
  10 + * 用于表示物模型数据的通用类型,根据具体的 "dataType" 字段动态映射到对应的子类。
  11 + * 提供多态支持,适用于不同类型的数据结构序列化和反序列化场景。
  12 + *
  13 + * @author HUIHUI
  14 + */
  15 +@Data
  16 +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "dataType", visible = true)
  17 +@JsonSubTypes({
  18 + @JsonSubTypes.Type(value = ThingModelNumericDataSpec.class, name = "int"),
  19 + @JsonSubTypes.Type(value = ThingModelNumericDataSpec.class, name = "float"),
  20 + @JsonSubTypes.Type(value = ThingModelNumericDataSpec.class, name = "double"),
  21 + @JsonSubTypes.Type(value = ThingModelDateOrTextDataSpecs.class, name = "text"),
  22 + @JsonSubTypes.Type(value = ThingModelDateOrTextDataSpecs.class, name = "date"),
  23 + @JsonSubTypes.Type(value = ThingModelBoolOrEnumDataSpecs.class, name = "bool"),
  24 + @JsonSubTypes.Type(value = ThingModelBoolOrEnumDataSpecs.class, name = "enum"),
  25 + @JsonSubTypes.Type(value = ThingModelArrayDataSpecs.class, name = "array")
  26 +})
  27 +public abstract class ThingModelDataSpecs {
  28 +
  29 + /**
  30 + * 数据类型
  31 + */
  32 + private String dataType;
  33 +
  34 +}
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelDateOrTextDataSpecs.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * 物模型数据类型为时间型或文本型的 DataSpec 定义
  7 + *
  8 + * 数据类型,取值为 date 或 text。
  9 + *
  10 + * @author HUIHUI
  11 + */
  12 +@Data
  13 +public class ThingModelDateOrTextDataSpecs extends ThingModelDataSpecs {
  14 +
  15 + /**
  16 + * 数据长度,单位为字节。取值不能超过 2048。
  17 + * 当 dataType 为 text 时,需传入该参数。
  18 + */
  19 + private Long length;
  20 + /**
  21 + * 默认值,可选参数,用于存储默认值。
  22 + */
  23 + private String defaultValue;
  24 +
  25 +}
  26 +
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelNumericDataSpec.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * 物模型数据类型为数值的 DataSpec 定义
  7 + *
  8 + * 数据类型,取值为 int、float 或 double。
  9 + *
  10 + * @author HUIHUI
  11 + */
  12 +@Data
  13 +public class ThingModelNumericDataSpec extends ThingModelDataSpecs {
  14 +
  15 + /**
  16 + * 最大值,需转为字符串类型。值必须与 dataType 类型一致。
  17 + * 例如,当 dataType 为 int 时,取值为 "200",而不是 200。
  18 + */
  19 + private String max;
  20 + /**
  21 + * 最小值,需转为字符串类型。值必须与 dataType 类型一致。
  22 + * 例如,当 dataType 为 int 时,取值为 "0",而不是 0。
  23 + */
  24 + private String min;
  25 + /**
  26 + * 步长,需转为字符串类型。值必须与 dataType 类型一致。
  27 + * 例如,当 dataType 为 int 时,取值为 "10",而不是 10。
  28 + */
  29 + private String step;
  30 + /**
  31 + * 精度。当 dataType 为 float 或 double 时可选传入。
  32 + */
  33 + private String precise;
  34 + /**
  35 + * 默认值,可传入用于存储的默认值。
  36 + */
  37 + private String defaultValue;
  38 + /**
  39 + * 单位的符号。
  40 + */
  41 + private String unit;
  42 + /**
  43 + * 单位的名称。
  44 + */
  45 + private String unitName;
  46 +
  47 +}
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/vo/IotThinkModelFunctionPageReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotThinkModelFunctionPageReqVO.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 4 import cn.iocoder.yudao.framework.common.validation.InEnum;
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/vo/IotThinkModelFunctionRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotThinkModelFunctionRespVO.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo;
2 2  
3   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelEvent;
4   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty;
5   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelService;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelEvent;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelService;
6 6 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
7 7 import com.alibaba.excel.annotation.ExcelProperty;
8 8 import io.swagger.v3.oas.annotations.media.Schema;
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/vo/IotThinkModelFunctionSaveReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotThinkModelFunctionSaveReqVO.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo;
2 2  
3 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
4   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelEvent;
5   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty;
6   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelService;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelEvent;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelService;
7 7 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
8 8 import io.swagger.v3.oas.annotations.media.Schema;
9 9 import jakarta.validation.constraints.NotEmpty;
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/ThingModelProperty.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel;
2   -
3   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelDataType;
4   -import lombok.Data;
5   -
6   -import java.util.List;
7   -
8   -@Data
9   -public class ThingModelProperty {
10   -
11   - /**
12   - * 属性标识符
13   - */
14   - private String identifier;
15   - /**
16   - * 属性名称
17   - */
18   - private String name;
19   - /**
20   - * 属性描述
21   - */
22   - private String description;
23   -
24   - private String accessMode; // "rw"、"r"、"w"
25   - private Boolean required;
26   - private ThingModelDataType dataSpecs;
27   - private List<ThingModelDataType> dataSpecsList;
28   -
29   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelArraySpecs.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -
5   -@Data
6   -public class ThingModelArraySpecs {
7   -
8   - /**
9   - * 数组长度
10   - */
11   - private int size;
12   - /**
13   - * 数组元素的类型
14   - */
15   - private ThingModelDataType item;
16   -
17   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelArrayType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -
5   -// TODO @haohao:这个是不是和别的类,不太统一哈
6   -@Data
7   -public class ThingModelArrayType extends ThingModelDataType {
8   -
9   - private ThingModelArraySpecs specs;
10   -
11   -}
12   -
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelBoolType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -import lombok.EqualsAndHashCode;
5   -
6   -@Data
7   -@EqualsAndHashCode(callSuper = true)
8   -public class ThingModelBoolType extends ThingModelDataType {
9   -
10   - // Bool 类型一般不需要额外的 specs
11   -
12   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelDataType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import com.fasterxml.jackson.annotation.JsonSubTypes;
4   -import com.fasterxml.jackson.annotation.JsonTypeInfo;
5   -import lombok.Data;
6   -
7   -@Data
8   -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "dataType", visible = true)
9   -@JsonSubTypes({
10   - @JsonSubTypes.Type(value = ThingModelIntType.class, name = "int"),
11   - @JsonSubTypes.Type(value = ThingModelFloatType.class, name = "float"),
12   - @JsonSubTypes.Type(value = ThingModelDoubleType.class, name = "double"),
13   - @JsonSubTypes.Type(value = ThingModelTextType.class, name = "text"),
14   - @JsonSubTypes.Type(value = ThingModelDateType.class, name = "date"),
15   - @JsonSubTypes.Type(value = ThingModelBoolType.class, name = "bool"),
16   - @JsonSubTypes.Type(value = ThingModelEnumType.class, name = "enum"),
17   - @JsonSubTypes.Type(value = ThingModelStructType.class, name = "struct"),
18   - @JsonSubTypes.Type(value = ThingModelArrayType.class, name = "array")
19   -})
20   -public abstract class ThingModelDataType {
21   -
22   - private String dataType;
23   -
24   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelDateType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -
5   -@Data
6   -public class ThingModelDateType extends ThingModelDataType {
7   -
8   - // Date 类型一般不需要额外的 specs
9   -
10   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelDoubleType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -
5   -@Data
6   -public class ThingModelDoubleType extends ThingModelDataType {
7   - private ThingModelDoubleSpecs specs;
8   -}
9   -
10   -@Data
11   -class ThingModelDoubleSpecs {
12   -
13   - private Double min;
14   - private Double max;
15   - private Double step;
16   - private String unit;
17   -
18   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelEnumType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -
5   -import java.util.Map;
6   -
7   -@Data
8   -public class ThingModelEnumType extends ThingModelDataType {
9   -
10   - /**
11   - * 枚举值和描述的键值对
12   - */
13   - private Map<String, String> specs;
14   -
15   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelFloatType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -import lombok.EqualsAndHashCode;
5   -
6   -@Data
7   -@EqualsAndHashCode(callSuper = true)
8   -public class ThingModelFloatType extends ThingModelDataType {
9   - private ThingModelFloatSpecs specs;
10   -}
11   -
12   -@Data
13   -class ThingModelFloatSpecs {
14   -
15   - private Float min;
16   - private Float max;
17   - private Float step;
18   - private String unit;
19   -
20   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelIntType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -
5   -@Data
6   -public class ThingModelIntType extends ThingModelDataType {
7   - private ThingModelIntSpecs specs;
8   -}
9   -
10   -@Data
11   -class ThingModelIntSpecs {
12   -
13   - private Integer min;
14   - private Integer max;
15   - private Integer step;
16   - private String unit;
17   -
18   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelStructField.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -
5   -@Data
6   -public class ThingModelStructField {
7   -
8   - private String identifier;
9   - private String name;
10   - private ThingModelDataType dataType;
11   - private String description;
12   -
13   -}
14 0 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelStructType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -
5   -import java.util.List;
6   -
7   -@Data
8   -public class ThingModelStructType extends ThingModelDataType {
9   -
10   - private List<ThingModelStructField> specs;
11   -
12   -}
13   -
14   -
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelTextType.java deleted
1   -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType;
2   -
3   -import lombok.Data;
4   -
5   -@Data
6   -public class ThingModelTextType extends ThingModelDataType {
7   -
8   - private ThingModelTextSpecs specs;
9   -
10   -}
11   -
12   -@Data
13   -class ThingModelTextSpecs {
14   -
15   - /**
16   - * 最大长度
17   - */
18   - private Integer length;
19   -
20   -}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/thinkmodelfunction/IotThinkModelFunctionConvert.java
1 1 package cn.iocoder.yudao.module.iot.convert.thinkmodelfunction;
2 2  
3   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelEvent;
4   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty;
5   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelService;
6   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionRespVO;
7   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionSaveReqVO;
8   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelEvent;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelService;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionRespVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionSaveReqVO;
  8 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
9 9 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
10 10 import org.mapstruct.Mapper;
11 11 import org.mapstruct.Mapping;
... ... @@ -23,7 +23,7 @@ public interface IotThinkModelFunctionConvert {
23 23 @Mapping(target = "property", expression = "java(convertToProperty(bean))")
24 24 @Mapping(target = "event", expression = "java(convertToEvent(bean))")
25 25 @Mapping(target = "service", expression = "java(convertToService(bean))")
26   - IotThinkModelFunctionDO convert(IotThinkModelFunctionSaveReqVO bean);
  26 + IotProductThingModelDO convert(IotThinkModelFunctionSaveReqVO bean);
27 27  
28 28 default ThingModelProperty convertToProperty(IotThinkModelFunctionSaveReqVO bean) {
29 29 if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
... ... @@ -50,8 +50,8 @@ public interface IotThinkModelFunctionConvert {
50 50 @Mapping(target = "property", source = "property")
51 51 @Mapping(target = "event", source = "event")
52 52 @Mapping(target = "service", source = "service")
53   - IotThinkModelFunctionRespVO convert(IotThinkModelFunctionDO bean);
  53 + IotThinkModelFunctionRespVO convert(IotProductThingModelDO bean);
54 54  
55 55 // 批量转换
56   - List<IotThinkModelFunctionRespVO> convertList(List<IotThinkModelFunctionDO> list);
  56 + List<IotThinkModelFunctionRespVO> convertList(List<IotProductThingModelDO> list);
57 57 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/device/IotDeviceDataDO.java
1 1 package cn.iocoder.yudao.module.iot.dal.dataobject.device;
2 2  
3 3 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
4   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
  4 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
5 5 import lombok.AllArgsConstructor;
6 6 import lombok.Builder;
7 7 import lombok.Data;
... ... @@ -30,7 +30,7 @@ public class IotDeviceDataDO {
30 30 /**
31 31 * 物模型编号
32 32 * <p>
33   - * 关联 {@link IotThinkModelFunctionDO#getId()}
  33 + * 关联 {@link IotProductThingModelDO#getId()}
34 34 */
35 35 private Long thinkModelFunctionId;
36 36  
... ... @@ -51,21 +51,21 @@ public class IotDeviceDataDO {
51 51 /**
52 52 * 属性标识符
53 53 * <p>
54   - * 关联 {@link IotThinkModelFunctionDO#getIdentifier()}
  54 + * 关联 {@link IotProductThingModelDO#getIdentifier()}
55 55 */
56 56 private String identifier;
57 57  
58 58 /**
59 59 * 属性名称
60 60 * <p>
61   - * 关联 {@link IotThinkModelFunctionDO#getName()}
  61 + * 关联 {@link IotProductThingModelDO#getName()}
62 62 */
63 63 private String name;
64 64  
65 65 /**
66 66 * 数据类型
67 67 * <p>
68   - * 关联 {@link IotThinkModelFunctionDO#getProperty()#getDataType()}
  68 + * 关联 {@link IotProductThingModelDO#getProperty()#getDataType()}
69 69 */
70 70 private String dataType;
71 71  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/thinkmodelfunction/IotThinkModelFunctionDO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/productthingmodel/IotProductThingModelDO.java
1   -package cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction;
  1 +package cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel;
2 2  
3 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
4   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelEvent;
5   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty;
6   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelService;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelEvent;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelService;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
8 8 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
9 9 import com.baomidou.mybatisplus.annotation.KeySequence;
... ... @@ -19,7 +19,7 @@ import lombok.NoArgsConstructor;
19 19 /**
20 20 * IoT 产品物模型功能 DO
21 21 * <p>
22   - * 每个 {@link IotProductDO} 和 {@link IotThinkModelFunctionDO} 是“一对多”的关系,它的每个属性、事件、服务都对应一条记录
  22 + * 每个 {@link IotProductDO} 和 {@link IotProductThingModelDO} 是“一对多”的关系,它的每个属性、事件、服务都对应一条记录
23 23 *
24 24 * @author 芋道源码
25 25 */
... ... @@ -29,7 +29,7 @@ import lombok.NoArgsConstructor;
29 29 @Builder
30 30 @NoArgsConstructor
31 31 @AllArgsConstructor
32   -public class IotThinkModelFunctionDO extends BaseDO {
  32 +public class IotProductThingModelDO extends BaseDO {
33 33  
34 34 /**
35 35 * 物模型功能编号
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/tdengine/FieldParser.java
1 1 package cn.iocoder.yudao.module.iot.dal.dataobject.tdengine;
2 2  
3   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty;
4   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelRespVO;
5   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelDataType;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelRespVO;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelDataSpecs;
6 6  
7 7 import java.util.HashMap;
8 8 import java.util.List;
... ... @@ -36,17 +36,19 @@ public class FieldParser {
36 36 */
37 37 public static TdFieldDO parse(ThingModelProperty property) {
38 38 String fieldName = property.getIdentifier().toLowerCase();
39   - ThingModelDataType type = property.getDataType();
40   -
41   - // 将物模型字段类型映射为td字段类型
42   - String fType = TYPE_MAPPING.get(type.getDataType().toUpperCase());
43   -
44   - // 如果字段类型为NCHAR,默认长度为64
45   - int dataLength = 0;
46   - if ("NCHAR".equals(fType)) {
47   - dataLength = 64;
48   - }
49   - return new TdFieldDO(fieldName, fType, dataLength);
  39 + //// TODO @puhui999: 需要重构
  40 + //ThingModelDataSpecs type = property.getDataType();
  41 + //
  42 + //// 将物模型字段类型映射为td字段类型
  43 + //String fType = TYPE_MAPPING.get(type.getDataType().toUpperCase());
  44 + //
  45 + //// 如果字段类型为NCHAR,默认长度为64
  46 + //int dataLength = 0;
  47 + //if ("NCHAR".equals(fType)) {
  48 + // dataLength = 64;
  49 + //}
  50 + //return new TdFieldDO(fieldName, fType, dataLength);
  51 + return null;
50 52 }
51 53  
52 54 /**
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/thinkmodelfunction/IotThinkModelFunctionMapper.java
... ... @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction;
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionPageReqVO;
7   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionPageReqVO;
  7 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
8 8 import org.apache.ibatis.annotations.Mapper;
9 9  
10 10 import java.util.List;
... ... @@ -15,48 +15,48 @@ import java.util.List;
15 15 * @author 芋道源码
16 16 */
17 17 @Mapper
18   -public interface IotThinkModelFunctionMapper extends BaseMapperX<IotThinkModelFunctionDO> {
19   -
20   - default PageResult<IotThinkModelFunctionDO> selectPage(IotThinkModelFunctionPageReqVO reqVO) {
21   - return selectPage(reqVO, new LambdaQueryWrapperX<IotThinkModelFunctionDO>()
22   - .eqIfPresent(IotThinkModelFunctionDO::getIdentifier, reqVO.getIdentifier())
23   - .likeIfPresent(IotThinkModelFunctionDO::getName, reqVO.getName())
24   - .eqIfPresent(IotThinkModelFunctionDO::getType, reqVO.getType())
25   - .eqIfPresent(IotThinkModelFunctionDO::getProductId, reqVO.getProductId())
26   - .notIn(IotThinkModelFunctionDO::getIdentifier, "get", "set", "post")
27   - .orderByDesc(IotThinkModelFunctionDO::getId));
  18 +public interface IotThinkModelFunctionMapper extends BaseMapperX<IotProductThingModelDO> {
  19 +
  20 + default PageResult<IotProductThingModelDO> selectPage(IotThinkModelFunctionPageReqVO reqVO) {
  21 + return selectPage(reqVO, new LambdaQueryWrapperX<IotProductThingModelDO>()
  22 + .eqIfPresent(IotProductThingModelDO::getIdentifier, reqVO.getIdentifier())
  23 + .likeIfPresent(IotProductThingModelDO::getName, reqVO.getName())
  24 + .eqIfPresent(IotProductThingModelDO::getType, reqVO.getType())
  25 + .eqIfPresent(IotProductThingModelDO::getProductId, reqVO.getProductId())
  26 + .notIn(IotProductThingModelDO::getIdentifier, "get", "set", "post")
  27 + .orderByDesc(IotProductThingModelDO::getId));
28 28 }
29 29  
30   - default IotThinkModelFunctionDO selectByProductIdAndIdentifier(Long productId, String identifier) {
31   - return selectOne(IotThinkModelFunctionDO::getProductId, productId,
32   - IotThinkModelFunctionDO::getIdentifier, identifier);
  30 + default IotProductThingModelDO selectByProductIdAndIdentifier(Long productId, String identifier) {
  31 + return selectOne(IotProductThingModelDO::getProductId, productId,
  32 + IotProductThingModelDO::getIdentifier, identifier);
33 33 }
34 34  
35   - default List<IotThinkModelFunctionDO> selectListByProductId(Long productId) {
36   - return selectList(IotThinkModelFunctionDO::getProductId, productId);
  35 + default List<IotProductThingModelDO> selectListByProductId(Long productId) {
  36 + return selectList(IotProductThingModelDO::getProductId, productId);
37 37 }
38 38  
39   - default List<IotThinkModelFunctionDO> selectListByProductIdAndType(Long productId, Integer type) {
40   - return selectList(IotThinkModelFunctionDO::getProductId, productId,
41   - IotThinkModelFunctionDO::getType, type);
  39 + default List<IotProductThingModelDO> selectListByProductIdAndType(Long productId, Integer type) {
  40 + return selectList(IotProductThingModelDO::getProductId, productId,
  41 + IotProductThingModelDO::getType, type);
42 42 }
43 43  
44   - default List<IotThinkModelFunctionDO> selectListByProductIdAndIdentifiersAndTypes(Long productId,
45   - List<String> identifiers,
46   - List<Integer> types) {
47   - return selectList(new LambdaQueryWrapperX<IotThinkModelFunctionDO>()
48   - .eq(IotThinkModelFunctionDO::getProductId, productId)
49   - .in(IotThinkModelFunctionDO::getIdentifier, identifiers)
50   - .in(IotThinkModelFunctionDO::getType, types));
  44 + default List<IotProductThingModelDO> selectListByProductIdAndIdentifiersAndTypes(Long productId,
  45 + List<String> identifiers,
  46 + List<Integer> types) {
  47 + return selectList(new LambdaQueryWrapperX<IotProductThingModelDO>()
  48 + .eq(IotProductThingModelDO::getProductId, productId)
  49 + .in(IotProductThingModelDO::getIdentifier, identifiers)
  50 + .in(IotProductThingModelDO::getType, types));
51 51 }
52 52  
53   - default IotThinkModelFunctionDO selectByProductIdAndName(Long productId, String name) {
54   - return selectOne(IotThinkModelFunctionDO::getProductId, productId,
55   - IotThinkModelFunctionDO::getName, name);
  53 + default IotProductThingModelDO selectByProductIdAndName(Long productId, String name) {
  54 + return selectOne(IotProductThingModelDO::getProductId, productId,
  55 + IotProductThingModelDO::getName, name);
56 56 }
57 57  
58   - default List<IotThinkModelFunctionDO> selectListByProductKey(String productKey) {
59   - return selectList(IotThinkModelFunctionDO::getProductKey, productKey);
  58 + default List<IotProductThingModelDO> selectListByProductKey(String productKey) {
  59 + return selectList(IotProductThingModelDO::getProductKey, productKey);
60 60 }
61 61  
62 62 }
63 63 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceDataServiceImpl.java
... ... @@ -7,9 +7,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
7 7 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataPageReqVO;
8 8 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
9 9 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO;
  10 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
10 11 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.SelectVisualDO;
11 12 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
12   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
13 13 import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO;
14 14 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper;
15 15 import cn.iocoder.yudao.module.iot.enums.IotConstants;
... ... @@ -73,7 +73,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
73 73 // 1. 获取设备信息
74 74 IotDeviceDO device = deviceService.getDevice(deviceDataReqVO.getDeviceId());
75 75 // 2. 获取设备属性最新数据
76   - List<IotThinkModelFunctionDO> thinkModelFunctionList = thinkModelFunctionService.getThinkModelFunctionListByProductKey(device.getProductKey());
  76 + List<IotProductThingModelDO> thinkModelFunctionList = thinkModelFunctionService.getThinkModelFunctionListByProductKey(device.getProductKey());
77 77 thinkModelFunctionList = thinkModelFunctionList.stream()
78 78 .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType()
79 79 .equals(function.getType())).toList();
... ... @@ -90,6 +90,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
90 90 .toList();
91 91 }
92 92 // 4. 获取设备属性最新数据
  93 + // TODO @puhui999: 需要重构
93 94 thinkModelFunctionList.forEach(function -> {
94 95 IotDeviceDataDO deviceData = deviceDataRedisDAO.get(device.getProductKey(), device.getDeviceName(), function.getIdentifier());
95 96 if (deviceData == null) {
... ... @@ -100,7 +101,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
100 101 deviceData.setDeviceId(deviceDataReqVO.getDeviceId());
101 102 deviceData.setThinkModelFunctionId(function.getId());
102 103 deviceData.setName(function.getName());
103   - deviceData.setDataType(function.getProperty().getDataType().getDataType());
  104 + //deviceData.setDataType(function.getProperty().getDataType().getDataType());
104 105 }
105 106 list.add(deviceData);
106 107 });
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotSuperTableService.java
... ... @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.service.tdengine;
2 2  
3 3  
4 4 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
5   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
  5 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
6 6  
7 7 import java.util.List;
8 8  
... ... @@ -14,5 +14,5 @@ public interface IotSuperTableService {
14 14 /**
15 15 * 创建超级表数据模型
16 16 */
17   - void createSuperTableDataModel(IotProductDO product, List<IotThinkModelFunctionDO> functionList);
  17 + void createSuperTableDataModel(IotProductDO product, List<IotProductThingModelDO> functionList);
18 18 }
19 19 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotSuperTableServiceImpl.java
... ... @@ -2,13 +2,13 @@ package cn.iocoder.yudao.module.iot.service.tdengine;
2 2  
3 3 import cn.hutool.core.bean.BeanUtil;
4 4 import cn.hutool.core.collection.CollUtil;
5   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty;
6   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelRespVO;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelRespVO;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
8 8 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser;
9 9 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO;
10 10 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO;
11   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
  11 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
12 12 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper;
13 13 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
14 14 import jakarta.annotation.Resource;
... ... @@ -33,7 +33,7 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
33 33 private String url;
34 34  
35 35 @Override
36   - public void createSuperTableDataModel(IotProductDO product, List<IotThinkModelFunctionDO> functionList) {
  36 + public void createSuperTableDataModel(IotProductDO product, List<IotProductThingModelDO> functionList) {
37 37 ThingModelRespVO thingModel = buildThingModel(product, functionList);
38 38  
39 39 if (thingModel.getModel() == null || CollUtil.isEmpty(thingModel.getModel().getProperties())) {
... ... @@ -210,7 +210,7 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
210 210 /**
211 211 * 构建物模型
212 212 */
213   - private ThingModelRespVO buildThingModel(IotProductDO product, List<IotThinkModelFunctionDO> functionList) {
  213 + private ThingModelRespVO buildThingModel(IotProductDO product, List<IotProductThingModelDO> functionList) {
214 214 ThingModelRespVO thingModel = new ThingModelRespVO();
215 215 thingModel.setId(product.getId());
216 216 thingModel.setProductKey(product.getProductKey());
... ... @@ -231,7 +231,7 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
231 231 /**
232 232 * 构建物模型属性
233 233 */
234   - private ThingModelProperty buildThingModelProperty(IotThinkModelFunctionDO function) {
  234 + private ThingModelProperty buildThingModelProperty(IotProductThingModelDO function) {
235 235 ThingModelProperty property = BeanUtil.copyProperties(function, ThingModelProperty.class);
236 236 property.setDataType(function.getProperty().getDataType());
237 237 return property;
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageServiceImpl.java
... ... @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser;
11 11 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO;
12 12 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO;
13 13 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
14   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
  14 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
15 15 import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO;
16 16 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper;
17 17 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper;
... ... @@ -71,7 +71,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
71 71  
72 72 // 2. 获取设备属性并进行物模型校验,过滤非物模型属性
73 73 Map<String, Object> params = thingModelMessage.dataToMap();
74   - List<IotThinkModelFunctionDO> functionList = getValidFunctionList(thingModelMessage.getProductKey());
  74 + List<IotProductThingModelDO> functionList = getValidFunctionList(thingModelMessage.getProductKey());
75 75 if (functionList.isEmpty()) {
76 76 return;
77 77 }
... ... @@ -90,7 +90,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
90 90 .build());
91 91 }
92 92  
93   - private List<IotThinkModelFunctionDO> getValidFunctionList(String productKey) {
  93 + private List<IotProductThingModelDO> getValidFunctionList(String productKey) {
94 94 return iotThinkModelFunctionService
95 95 .getThinkModelFunctionListByProductKey(productKey)
96 96 .stream()
... ... @@ -98,13 +98,13 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
98 98 .toList();
99 99 }
100 100  
101   - private List<TdFieldDO> filterAndCollectValidFields(Map<String, Object> params, List<IotThinkModelFunctionDO> functionList, IotDeviceDO device, Long time) {
  101 + private List<TdFieldDO> filterAndCollectValidFields(Map<String, Object> params, List<IotProductThingModelDO> functionList, IotDeviceDO device, Long time) {
102 102 // 1. 获取属性标识符集合
103   - Set<String> propertyIdentifiers = CollectionUtils.convertSet(functionList, IotThinkModelFunctionDO::getIdentifier);
  103 + Set<String> propertyIdentifiers = CollectionUtils.convertSet(functionList, IotProductThingModelDO::getIdentifier);
104 104  
105 105 // 2. 构建属性标识符和属性的映射
106   - Map<String, IotThinkModelFunctionDO> functionMap = functionList.stream()
107   - .collect(Collectors.toMap(IotThinkModelFunctionDO::getIdentifier, function -> function));
  106 + Map<String, IotProductThingModelDO> functionMap = functionList.stream()
  107 + .collect(Collectors.toMap(IotProductThingModelDO::getIdentifier, function -> function));
108 108  
109 109 // 3. 过滤并收集有效的属性字段
110 110 List<TdFieldDO> schemaFieldValues = new ArrayList<>();
... ... @@ -124,21 +124,22 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
124 124 * 缓存设备属性
125 125 *
126 126 * @param device 设备信息
127   - * @param iotThinkModelFunctionDO 物模型属性
  127 + * @param iotProductThingModelDO 物模型属性
128 128 * @param val 属性值
129 129 * @param time 时间
130 130 */
131   - private void setDeviceDataCache(IotDeviceDO device, IotThinkModelFunctionDO iotThinkModelFunctionDO, Object val, Long time) {
  131 + private void setDeviceDataCache(IotDeviceDO device, IotProductThingModelDO iotProductThingModelDO, Object val, Long time) {
  132 + // TODO @puhui999: 需要重构
132 133 IotDeviceDataDO deviceData = IotDeviceDataDO.builder()
133 134 .productKey(device.getProductKey())
134 135 .deviceName(device.getDeviceName())
135   - .identifier(iotThinkModelFunctionDO.getIdentifier())
  136 + .identifier(iotProductThingModelDO.getIdentifier())
136 137 .value(val != null ? val.toString() : null)
137 138 .updateTime(DateUtil.toLocalDateTime(new Date(time)))
138 139 .deviceId(device.getId())
139   - .thinkModelFunctionId(iotThinkModelFunctionDO.getId())
140   - .name(iotThinkModelFunctionDO.getName())
141   - .dataType(iotThinkModelFunctionDO.getProperty().getDataType().getDataType())
  140 + .thinkModelFunctionId(iotProductThingModelDO.getId())
  141 + .name(iotProductThingModelDO.getName())
  142 + //.dataType(iotProductThingModelDO.getProperty().getDataType().getDataType())
142 143 .build();
143 144 deviceDataRedisDAO.set(deviceData);
144 145 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thinkmodelfunction/IotThinkModelFunctionService.java
1 1 package cn.iocoder.yudao.module.iot.service.thinkmodelfunction;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionPageReqVO;
5   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionSaveReqVO;
6   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionPageReqVO;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionSaveReqVO;
  6 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
7 7 import jakarta.validation.Valid;
8 8  
9 9 import java.util.List;
... ... @@ -44,7 +44,7 @@ public interface IotThinkModelFunctionService {
44 44 * @param id 编号
45 45 * @return 产品物模型
46 46 */
47   - IotThinkModelFunctionDO getThinkModelFunction(Long id);
  47 + IotProductThingModelDO getThinkModelFunction(Long id);
48 48  
49 49 /**
50 50 * 获得产品物模型列表
... ... @@ -52,7 +52,7 @@ public interface IotThinkModelFunctionService {
52 52 * @param productId 产品编号
53 53 * @return 产品物模型列表
54 54 */
55   - List<IotThinkModelFunctionDO> getThinkModelFunctionListByProductId(Long productId);
  55 + List<IotProductThingModelDO> getThinkModelFunctionListByProductId(Long productId);
56 56  
57 57 /**
58 58 * 获得产品物模型分页
... ... @@ -60,7 +60,7 @@ public interface IotThinkModelFunctionService {
60 60 * @param pageReqVO 分页查询
61 61 * @return 产品物模型分页
62 62 */
63   - PageResult<IotThinkModelFunctionDO> getThinkModelFunctionPage(IotThinkModelFunctionPageReqVO pageReqVO);
  63 + PageResult<IotProductThingModelDO> getThinkModelFunctionPage(IotThinkModelFunctionPageReqVO pageReqVO);
64 64  
65 65 /**
66 66 * 创建超级表数据模型
... ... @@ -75,5 +75,5 @@ public interface IotThinkModelFunctionService {
75 75 * @param productKey 产品 Key
76 76 * @return 产品物模型列表
77 77 */
78   - List<IotThinkModelFunctionDO> getThinkModelFunctionListByProductKey(String productKey);
  78 + List<IotProductThingModelDO> getThinkModelFunctionListByProductKey(String productKey);
79 79 }
80 80 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thinkmodelfunction/IotThinkModelFunctionServiceImpl.java
... ... @@ -4,23 +4,20 @@ import cn.hutool.core.collection.CollUtil;
4 4 import cn.hutool.core.util.ObjectUtil;
5 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 6 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
7   -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
8   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelEvent;
9   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty;
10   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelService;
11   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArgument;
12   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArraySpecs;
13   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelArrayType;
14   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelTextType;
15   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionPageReqVO;
16   -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionSaveReqVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelEvent;
  8 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
  9 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelService;
  10 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArgument;
  11 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArrayDataSpecs;
  12 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelDateOrTextDataSpecs;
  13 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionPageReqVO;
  14 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionSaveReqVO;
17 15 import cn.iocoder.yudao.module.iot.convert.thinkmodelfunction.IotThinkModelFunctionConvert;
18 16 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
19   -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;
  17 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
20 18 import cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction.IotThinkModelFunctionMapper;
21   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelAccessModeEnum;
22   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
23 19 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum;
  20 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
24 21 import cn.iocoder.yudao.module.iot.service.product.IotProductService;
25 22 import cn.iocoder.yudao.module.iot.service.tdengine.IotSuperTableService;
26 23 import jakarta.annotation.Resource;
... ... @@ -70,7 +67,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
70 67 validateProductStatus(createReqVO.getProductId());
71 68  
72 69 // 5. 插入数据库
73   - IotThinkModelFunctionDO function = IotThinkModelFunctionConvert.INSTANCE.convert(createReqVO);
  70 + IotProductThingModelDO function = IotThinkModelFunctionConvert.INSTANCE.convert(createReqVO);
74 71 thinkModelFunctionMapper.insert(function);
75 72  
76 73 // 6. 如果创建的是属性,需要更新默认的事件和服务
... ... @@ -98,14 +95,14 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
98 95 }
99 96  
100 97 private void validateNameUnique(Long productId, String name) {
101   - IotThinkModelFunctionDO function = thinkModelFunctionMapper.selectByProductIdAndName(productId, name);
  98 + IotProductThingModelDO function = thinkModelFunctionMapper.selectByProductIdAndName(productId, name);
102 99 if (function != null) {
103 100 throw exception(THINK_MODEL_FUNCTION_NAME_EXISTS);
104 101 }
105 102 }
106 103  
107 104 private void validateIdentifierUnique(Long productId, String identifier) {
108   - IotThinkModelFunctionDO function = thinkModelFunctionMapper.selectByProductIdAndIdentifier(productId, identifier);
  105 + IotProductThingModelDO function = thinkModelFunctionMapper.selectByProductIdAndIdentifier(productId, identifier);
109 106 if (function != null) {
110 107 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS);
111 108 }
... ... @@ -124,7 +121,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
124 121 validateProductStatus(updateReqVO.getProductId());
125 122  
126 123 // 4. 更新数据库
127   - IotThinkModelFunctionDO thinkModelFunction = IotThinkModelFunctionConvert.INSTANCE.convert(updateReqVO);
  124 + IotProductThingModelDO thinkModelFunction = IotThinkModelFunctionConvert.INSTANCE.convert(updateReqVO);
128 125 thinkModelFunctionMapper.updateById(thinkModelFunction);
129 126  
130 127 // 5. 如果更新的是属性,需要更新默认的事件和服务
... ... @@ -134,7 +131,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
134 131 }
135 132  
136 133 private void validateIdentifierUniqueForUpdate(Long id, Long productId, String identifier) {
137   - IotThinkModelFunctionDO function = thinkModelFunctionMapper.selectByProductIdAndIdentifier(productId, identifier);
  134 + IotProductThingModelDO function = thinkModelFunctionMapper.selectByProductIdAndIdentifier(productId, identifier);
138 135 if (function != null && ObjectUtil.notEqual(function.getId(), id)) {
139 136 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS);
140 137 }
... ... @@ -144,7 +141,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
144 141 @Transactional(rollbackFor = Exception.class)
145 142 public void deleteThinkModelFunction(Long id) {
146 143 // 1. 校验功能是否存在
147   - IotThinkModelFunctionDO functionDO = thinkModelFunctionMapper.selectById(id);
  144 + IotProductThingModelDO functionDO = thinkModelFunctionMapper.selectById(id);
148 145 if (functionDO == null) {
149 146 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS);
150 147 }
... ... @@ -173,17 +170,17 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
173 170 }
174 171  
175 172 @Override
176   - public IotThinkModelFunctionDO getThinkModelFunction(Long id) {
  173 + public IotProductThingModelDO getThinkModelFunction(Long id) {
177 174 return thinkModelFunctionMapper.selectById(id);
178 175 }
179 176  
180 177 @Override
181   - public List<IotThinkModelFunctionDO> getThinkModelFunctionListByProductId(Long productId) {
  178 + public List<IotProductThingModelDO> getThinkModelFunctionListByProductId(Long productId) {
182 179 return thinkModelFunctionMapper.selectListByProductId(productId);
183 180 }
184 181  
185 182 @Override
186   - public PageResult<IotThinkModelFunctionDO> getThinkModelFunctionPage(IotThinkModelFunctionPageReqVO pageReqVO) {
  183 + public PageResult<IotProductThingModelDO> getThinkModelFunctionPage(IotThinkModelFunctionPageReqVO pageReqVO) {
187 184 return thinkModelFunctionMapper.selectPage(pageReqVO);
188 185 }
189 186  
... ... @@ -193,14 +190,14 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
193 190 IotProductDO product = productService.getProduct(productId);
194 191  
195 192 // 2. 查询产品的物模型功能列表
196   - List<IotThinkModelFunctionDO> functionList = thinkModelFunctionMapper.selectListByProductId(productId);
  193 + List<IotProductThingModelDO> functionList = thinkModelFunctionMapper.selectListByProductId(productId);
197 194  
198 195 // 3. 生成 TDengine 的数据模型
199 196 dbStructureDataService.createSuperTableDataModel(product, functionList);
200 197 }
201 198  
202 199 @Override
203   - public List<IotThinkModelFunctionDO> getThinkModelFunctionListByProductKey(String productKey) {
  200 + public List<IotProductThingModelDO> getThinkModelFunctionListByProductKey(String productKey) {
204 201 return thinkModelFunctionMapper.selectListByProductKey(productKey);
205 202 }
206 203  
... ... @@ -209,45 +206,45 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
209 206 */
210 207 public void createDefaultEventsAndServices(Long productId, String productKey) {
211 208 // 1. 获取当前属性列表
212   - List<IotThinkModelFunctionDO> propertyList = thinkModelFunctionMapper
  209 + List<IotProductThingModelDO> propertyList = thinkModelFunctionMapper
213 210 .selectListByProductIdAndType(productId, IotProductThingModelTypeEnum.PROPERTY.getType());
214 211  
215 212 // 2. 生成新的事件和服务列表
216   - List<IotThinkModelFunctionDO> newFunctionList = new ArrayList<>();
  213 + List<IotProductThingModelDO> newFunctionList = new ArrayList<>();
217 214 // 生成属性上报事件
218 215 ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList);
219 216 if (propertyPostEvent != null) {
220   - IotThinkModelFunctionDO eventFunction = buildEventFunctionDO(productId, productKey, propertyPostEvent);
  217 + IotProductThingModelDO eventFunction = buildEventFunctionDO(productId, productKey, propertyPostEvent);
221 218 newFunctionList.add(eventFunction);
222 219 }
223 220 // 生成属性设置服务
224 221 ThingModelService propertySetService = generatePropertySetService(propertyList);
225 222 if (propertySetService != null) {
226   - IotThinkModelFunctionDO setServiceFunction = buildServiceFunctionDO(productId, productKey, propertySetService);
  223 + IotProductThingModelDO setServiceFunction = buildServiceFunctionDO(productId, productKey, propertySetService);
227 224 newFunctionList.add(setServiceFunction);
228 225 }
229 226 // 生成属性获取服务
230 227 ThingModelService propertyGetService = generatePropertyGetService(propertyList);
231 228 if (propertyGetService != null) {
232   - IotThinkModelFunctionDO getServiceFunction = buildServiceFunctionDO(productId, productKey, propertyGetService);
  229 + IotProductThingModelDO getServiceFunction = buildServiceFunctionDO(productId, productKey, propertyGetService);
233 230 newFunctionList.add(getServiceFunction);
234 231 }
235 232  
236 233 // 3. 获取数据库中的默认的旧事件和服务列表
237   - List<IotThinkModelFunctionDO> oldFunctionList = thinkModelFunctionMapper.selectListByProductIdAndIdentifiersAndTypes(
  234 + List<IotProductThingModelDO> oldFunctionList = thinkModelFunctionMapper.selectListByProductIdAndIdentifiersAndTypes(
238 235 productId,
239 236 Arrays.asList("post", "set", "get"),
240 237 Arrays.asList(IotProductThingModelTypeEnum.EVENT.getType(), IotProductThingModelTypeEnum.SERVICE.getType())
241 238 );
242 239  
243 240 // 3.1 使用 diffList 方法比较新旧列表
244   - List<List<IotThinkModelFunctionDO>> diffResult = diffList(oldFunctionList, newFunctionList,
  241 + List<List<IotProductThingModelDO>> diffResult = diffList(oldFunctionList, newFunctionList,
245 242 // 继续使用 identifier 和 type 进行比较:这样可以准确地匹配对应的功能对象。
246 243 (oldFunc, newFunc) -> Objects.equals(oldFunc.getIdentifier(), newFunc.getIdentifier())
247 244 && Objects.equals(oldFunc.getType(), newFunc.getType()));
248   - List<IotThinkModelFunctionDO> createList = diffResult.get(0); // 需要新增的
249   - List<IotThinkModelFunctionDO> updateList = diffResult.get(1); // 需要更新的
250   - List<IotThinkModelFunctionDO> deleteList = diffResult.get(2); // 需要删除的
  245 + List<IotProductThingModelDO> createList = diffResult.get(0); // 需要新增的
  246 + List<IotProductThingModelDO> updateList = diffResult.get(1); // 需要更新的
  247 + List<IotProductThingModelDO> deleteList = diffResult.get(2); // 需要删除的
251 248  
252 249 // 3.2 批量执行数据库操作
253 250 // 新增数据库中的新事件和服务列表
... ... @@ -258,14 +255,14 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
258 255 if (CollUtil.isNotEmpty(updateList)) {
259 256 // 首先,为每个需要更新的对象设置其对应的 ID
260 257 updateList.forEach(updateFunc -> {
261   - IotThinkModelFunctionDO oldFunc = findFunctionByIdentifierAndType(
  258 + IotProductThingModelDO oldFunc = findFunctionByIdentifierAndType(
262 259 oldFunctionList, updateFunc.getIdentifier(), updateFunc.getType());
263 260 if (oldFunc != null) {
264 261 updateFunc.setId(oldFunc.getId());
265 262 }
266 263 });
267 264 // 过滤掉没有设置 ID 的对象
268   - List<IotThinkModelFunctionDO> validUpdateList = updateList.stream()
  265 + List<IotProductThingModelDO> validUpdateList = updateList.stream()
269 266 .filter(func -> func.getId() != null)
270 267 .collect(Collectors.toList());
271 268 // 执行批量更新
... ... @@ -276,7 +273,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
276 273  
277 274 // 删除数据库中的旧事件和服务列表
278 275 if (CollUtil.isNotEmpty(deleteList)) {
279   - Set<Long> idsToDelete = CollectionUtils.convertSet(deleteList, IotThinkModelFunctionDO::getId);
  276 + Set<Long> idsToDelete = CollectionUtils.convertSet(deleteList, IotProductThingModelDO::getId);
280 277 thinkModelFunctionMapper.deleteByIds(idsToDelete);
281 278 }
282 279 }
... ... @@ -284,8 +281,8 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
284 281 /**
285 282 * 根据标识符和类型查找功能对象
286 283 */
287   - private IotThinkModelFunctionDO findFunctionByIdentifierAndType(List<IotThinkModelFunctionDO> functionList,
288   - String identifier, Integer type) {
  284 + private IotProductThingModelDO findFunctionByIdentifierAndType(List<IotProductThingModelDO> functionList,
  285 + String identifier, Integer type) {
289 286 return CollUtil.findOne(functionList, func ->
290 287 Objects.equals(func.getIdentifier(), identifier) && Objects.equals(func.getType(), type));
291 288 }
... ... @@ -293,8 +290,8 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
293 290 /**
294 291 * 构建事件功能对象
295 292 */
296   - private IotThinkModelFunctionDO buildEventFunctionDO(Long productId, String productKey, ThingModelEvent event) {
297   - return new IotThinkModelFunctionDO()
  293 + private IotProductThingModelDO buildEventFunctionDO(Long productId, String productKey, ThingModelEvent event) {
  294 + return new IotProductThingModelDO()
298 295 .setProductId(productId)
299 296 .setProductKey(productKey)
300 297 .setIdentifier(event.getIdentifier())
... ... @@ -307,8 +304,8 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
307 304 /**
308 305 * 构建服务功能对象
309 306 */
310   - private IotThinkModelFunctionDO buildServiceFunctionDO(Long productId, String productKey, ThingModelService service) {
311   - return new IotThinkModelFunctionDO()
  307 + private IotProductThingModelDO buildServiceFunctionDO(Long productId, String productKey, ThingModelService service) {
  308 + return new IotProductThingModelDO()
312 309 .setProductId(productId)
313 310 .setProductKey(productKey)
314 311 .setIdentifier(service.getIdentifier())
... ... @@ -321,7 +318,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
321 318 /**
322 319 * 生成属性上报事件
323 320 */
324   - private ThingModelEvent generatePropertyPostEvent(List<IotThinkModelFunctionDO> propertyList) {
  321 + private ThingModelEvent generatePropertyPostEvent(List<IotProductThingModelDO> propertyList) {
325 322 if (CollUtil.isEmpty(propertyList)) {
326 323 return null;
327 324 }
... ... @@ -335,12 +332,13 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
335 332  
336 333 // 将属性列表转换为事件的输出参数
337 334 List<ThingModelArgument> outputData = new ArrayList<>();
338   - for (IotThinkModelFunctionDO functionDO : propertyList) {
  335 + // TODO @puhui999: 需要重构
  336 + for (IotProductThingModelDO functionDO : propertyList) {
339 337 ThingModelProperty property = functionDO.getProperty();
340 338 ThingModelArgument arg = new ThingModelArgument()
341 339 .setIdentifier(property.getIdentifier())
342 340 .setName(property.getName())
343   - .setDataType(property.getDataType())
  341 + //.setDataType(property.getDataType())
344 342 .setDescription(property.getDescription())
345 343 .setDirection("output"); // 设置为输出参数
346 344 outputData.add(arg);
... ... @@ -352,24 +350,24 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
352 350 /**
353 351 * 生成属性设置服务
354 352 */
355   - private ThingModelService generatePropertySetService(List<IotThinkModelFunctionDO> propertyList) {
  353 + private ThingModelService generatePropertySetService(List<IotProductThingModelDO> propertyList) {
356 354 if (propertyList == null || propertyList.isEmpty()) {
357 355 return null;
358 356 }
359 357  
360 358 List<ThingModelArgument> inputData = new ArrayList<>();
361 359 // TODO @puhui999: 需要重构
362   - for (IotThinkModelFunctionDO functionDO : propertyList) {
  360 + for (IotProductThingModelDO functionDO : propertyList) {
363 361 ThingModelProperty property = functionDO.getProperty();
364   - if (IotProductThingModelAccessModeEnum.WRITE.getMode().equals(property.getAccessMode()) || IotProductThingModelAccessModeEnum.READ_WRITE.getMode().equals(property.getAccessMode())) {
365   - ThingModelArgument arg = new ThingModelArgument()
366   - .setIdentifier(property.getIdentifier())
367   - .setName(property.getName())
368   - .setDataType(property.getDataType())
369   - .setDescription(property.getDescription())
370   - .setDirection("input"); // 设置为输入参数
371   - inputData.add(arg);
372   - }
  362 + //if (IotProductThingModelAccessModeEnum.WRITE.getMode().equals(property.getAccessMode()) || IotProductThingModelAccessModeEnum.READ_WRITE.getMode().equals(property.getAccessMode())) {
  363 + // ThingModelArgument arg = new ThingModelArgument()
  364 + // .setIdentifier(property.getIdentifier())
  365 + // .setName(property.getName())
  366 + // .setDataType(property.getDataType())
  367 + // .setDescription(property.getDescription())
  368 + // .setDirection("input"); // 设置为输入参数
  369 + // inputData.add(arg);
  370 + //}
373 371 }
374 372 if (inputData.isEmpty()) {
375 373 // 如果没有可写属性,不生成属性设置服务
... ... @@ -391,24 +389,24 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
391 389 /**
392 390 * 生成属性获取服务
393 391 */
394   - private ThingModelService generatePropertyGetService(List<IotThinkModelFunctionDO> propertyList) {
  392 + private ThingModelService generatePropertyGetService(List<IotProductThingModelDO> propertyList) {
395 393 if (propertyList == null || propertyList.isEmpty()) {
396 394 return null;
397 395 }
398   -
  396 + // TODO @puhui999: 需要重构
399 397 List<ThingModelArgument> outputData = new ArrayList<>();
400   - for (IotThinkModelFunctionDO functionDO : propertyList) {
  398 + for (IotProductThingModelDO functionDO : propertyList) {
401 399 ThingModelProperty property = functionDO.getProperty();
402   - if (ObjectUtils.equalsAny(property.getAccessMode(),
403   - IotProductThingModelAccessModeEnum.READ.getMode(), IotProductThingModelAccessModeEnum.READ_WRITE.getMode())) {
404   - ThingModelArgument arg = new ThingModelArgument()
405   - .setIdentifier(property.getIdentifier())
406   - .setName(property.getName())
407   - .setDataType(property.getDataType())
408   - .setDescription(property.getDescription())
409   - .setDirection("output"); // 设置为输出参数
410   - outputData.add(arg);
411   - }
  400 + //if (ObjectUtils.equalsAny(property.getAccessMode(),
  401 + // IotProductThingModelAccessModeEnum.READ.getMode(), IotProductThingModelAccessModeEnum.READ_WRITE.getMode())) {
  402 + // ThingModelArgument arg = new ThingModelArgument()
  403 + // .setIdentifier(property.getIdentifier())
  404 + // .setName(property.getName())
  405 + // .setDataType(property.getDataType())
  406 + // .setDescription(property.getDescription())
  407 + // .setDirection("output"); // 设置为输出参数
  408 + // outputData.add(arg);
  409 + //}
412 410 }
413 411 if (outputData.isEmpty()) {
414 412 // 如果没有可读属性,不生成属性获取服务
... ... @@ -430,13 +428,13 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
430 428 .setDirection("input"); // 设置为输入参数
431 429  
432 430 // 创建数组类型,元素类型为文本类型(字符串)
433   - ThingModelArrayType arrayType = new ThingModelArrayType();
  431 + ThingModelArrayDataSpecs arrayType = new ThingModelArrayDataSpecs();
434 432 arrayType.setDataType("array");
435   - ThingModelArraySpecs arraySpecs = new ThingModelArraySpecs();
436   - ThingModelTextType textType = new ThingModelTextType();
  433 + //ThingModelArraySpecs arraySpecs = new ThingModelArraySpecs();
  434 + ThingModelDateOrTextDataSpecs textType = new ThingModelDateOrTextDataSpecs();
437 435 textType.setDataType("text");
438   - arraySpecs.setItem(textType);
439   - arrayType.setSpecs(arraySpecs);
  436 + //arraySpecs.setItem(textType);
  437 + //arrayType.setSpecs(arraySpecs);
440 438 inputArg.setDataType(arrayType);
441 439  
442 440 service.setInputData(Collections.singletonList(inputArg));
... ...