Commit 0ce665ea27c586b9adb106f2baaafad01b385516

Authored by 芋道源码
Committed by Gitee
2 parents ce491230 9e987680

!1162 【功能完善】IoT: 产品物模型

Merge pull request !1162 from puhui999/iot
Showing 48 changed files with 912 additions and 769 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotAccessModeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelAccessModeEnum.java
1 -package cn.iocoder.yudao.module.iot.enums.product; 1 +package cn.iocoder.yudao.module.iot.enums.thingmodel;
2 2
3 import lombok.AllArgsConstructor; 3 import lombok.AllArgsConstructor;
4 import lombok.Getter; 4 import lombok.Getter;
@@ -10,10 +10,9 @@ import lombok.Getter; @@ -10,10 +10,9 @@ import lombok.Getter;
10 */ 10 */
11 @AllArgsConstructor 11 @AllArgsConstructor
12 @Getter 12 @Getter
13 -public enum IotAccessModeEnum { 13 +public enum IotProductThingModelAccessModeEnum {
14 14
15 - READ("r"),  
16 - WRITE("w"), 15 + READ_ONLY("r"),
17 READ_WRITE("rw"); 16 READ_WRITE("rw");
18 17
19 private final String mode; 18 private final String mode;
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductFunctionTypeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelTypeEnum.java
1 -package cn.iocoder.yudao.module.iot.enums.product; 1 +package cn.iocoder.yudao.module.iot.enums.thingmodel;
2 2
3 import cn.iocoder.yudao.framework.common.core.IntArrayValuable; 3 import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
4 import lombok.AllArgsConstructor; 4 import lombok.AllArgsConstructor;
@@ -13,13 +13,13 @@ import java.util.Arrays; @@ -13,13 +13,13 @@ import java.util.Arrays;
13 */ 13 */
14 @AllArgsConstructor 14 @AllArgsConstructor
15 @Getter 15 @Getter
16 -public enum IotProductFunctionTypeEnum implements IntArrayValuable { 16 +public enum IotProductThingModelTypeEnum implements IntArrayValuable {
17 17
18 PROPERTY(1, "属性"), 18 PROPERTY(1, "属性"),
19 SERVICE(2, "服务"), 19 SERVICE(2, "服务"),
20 EVENT(3, "事件"); 20 EVENT(3, "事件");
21 21
22 - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductFunctionTypeEnum::getType).toArray(); 22 + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductThingModelTypeEnum::getType).toArray();
23 23
24 /** 24 /**
25 * 类型 25 * 类型
@@ -30,8 +30,8 @@ public enum IotProductFunctionTypeEnum implements IntArrayValuable { @@ -30,8 +30,8 @@ public enum IotProductFunctionTypeEnum implements IntArrayValuable {
30 */ 30 */
31 private final String description; 31 private final String description;
32 32
33 - public static IotProductFunctionTypeEnum valueOfType(Integer type) {  
34 - for (IotProductFunctionTypeEnum value : values()) { 33 + public static IotProductThingModelTypeEnum valueOfType(Integer type) {
  34 + for (IotProductThingModelTypeEnum value : values()) {
35 if (value.getType().equals(type)) { 35 if (value.getType().equals(type)) {
36 return value; 36 return value;
37 } 37 }
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/IotProductThingModelController.http 0 → 100644
  1 +### 请求 /iot/product-thing-model/create 接口 => 成功
  2 +POST {{baseUrl}}/iot/product-thing-model/create
  3 +Content-Type: application/json
  4 +tenant-id: {{adminTenentId}}
  5 +Authorization: Bearer {{token}}
  6 +
  7 +{
  8 + "productId": 12,
  9 + "productKey": "CJVS54fObwZJ9Qe5CJVS54fObwZJ9Qe5",
  10 + "identifier": "Temperature",
  11 + "name": "温度",
  12 + "description": "当前温度值",
  13 + "type": 1,
  14 + "property": {
  15 + "identifier": "Temperature",
  16 + "name": "温度",
  17 + "accessMode": "r",
  18 + "required": true,
  19 + "dataType": "int",
  20 + "dataSpecs": {
  21 + "dataType": "int",
  22 + "max": "200",
  23 + "min": "0",
  24 + "step": "10",
  25 + "defaultValue": "30",
  26 + "unit": "%",
  27 + "unitName": "百分比"
  28 + },
  29 + "description": "当前温度值"
  30 + }
  31 +}
  32 +
  33 +### 请求 /iot/product-thing-model/create 接口 => 成功
  34 +POST {{baseUrl}}/iot/product-thing-model/create
  35 +Content-Type: application/json
  36 +tenant-id: {{adminTenentId}}
  37 +Authorization: Bearer {{token}}
  38 +
  39 +{
  40 + "productId": 12,
  41 + "productKey": "CJVS54fObwZJ9Qe5CJVS54fObwZJ9Qe5",
  42 + "identifier": "switch",
  43 + "name": "开关",
  44 + "description": "温度计开关",
  45 + "type": 1,
  46 + "property": {
  47 + "identifier": "switch",
  48 + "name": "开关",
  49 + "description": "温度计开关",
  50 + "accessMode": "rw",
  51 + "required": true,
  52 + "dataType": "bool",
  53 + "dataSpecsList": [
  54 + {
  55 + "dataType": "bool",
  56 + "name": "关",
  57 + "value": 0
  58 + },
  59 + {
  60 + "dataType": "bool",
  61 + "name": "开",
  62 + "value": 1
  63 + }
  64 + ]
  65 + }
  66 +}
  67 +
  68 +### 请求 /iot/product-thing-model/create 接口 => 成功
  69 +POST {{baseUrl}}/iot/product-thing-model/create
  70 +Content-Type: application/json
  71 +tenant-id: {{adminTenentId}}
  72 +Authorization: Bearer {{token}}
  73 +
  74 +{
  75 + "productId": 12,
  76 + "productKey": "CJVS54fObwZJ9Qe5CJVS54fObwZJ9Qe5",
  77 + "identifier": "argb",
  78 + "name": "温度计 argb 颜色",
  79 + "description": "温度计 argb 颜色",
  80 + "type": 1,
  81 + "property": {
  82 + "identifier": "argb",
  83 + "name": "温度计 argb 颜色",
  84 + "description": "温度计 argb 颜色",
  85 + "accessMode": "rw",
  86 + "required": true,
  87 + "dataType": "array",
  88 + "dataSpecs": {
  89 + "dataType": "array",
  90 + "size": 10,
  91 + "childDataType": "struct",
  92 + "dataSpecsList": [
  93 + {
  94 + "identifier": "switch",
  95 + "name": "开关",
  96 + "description": "温度计开关",
  97 + "accessMode": "rw",
  98 + "required": true,
  99 + "dataType": "struct",
  100 + "childDataType": "bool",
  101 + "dataSpecsList": [
  102 + {
  103 + "dataType": "bool",
  104 + "name": "关",
  105 + "value": 0
  106 + },
  107 + {
  108 + "dataType": "bool",
  109 + "name": "开",
  110 + "value": 1
  111 + }
  112 + ]
  113 + },
  114 + {
  115 + "identifier": "Temperature",
  116 + "name": "温度",
  117 + "accessMode": "r",
  118 + "required": true,
  119 + "dataType": "struct",
  120 + "childDataType": "int",
  121 + "dataSpecs": {
  122 + "dataType": "int",
  123 + "max": "200",
  124 + "min": "0",
  125 + "step": "10",
  126 + "defaultValue": "30",
  127 + "unit": "%",
  128 + "unitName": "百分比"
  129 + },
  130 + "description": "当前温度值"
  131 + }
  132 + ]
  133 + }
  134 + }
  135 +}
  136 +
  137 +### 请求 /iot/product-thing-model/update 接口 => 成功
  138 +PUT {{baseUrl}}/iot/product-thing-model/update
  139 +Content-Type: application/json
  140 +tenant-id: {{adminTenentId}}
  141 +Authorization: Bearer {{token}}
  142 +
  143 +{
  144 + "id": 33,
  145 + "productId": 12,
  146 + "productKey": "CJVS54fObwZJ9Qe5CJVS54fObwZJ9Qe5",
  147 + "identifier": "switch",
  148 + "name": "开关",
  149 + "description": "温度计开关",
  150 + "type": 1,
  151 + "property": {
  152 + "identifier": "switch",
  153 + "name": "开关",
  154 + "description": "温度计开关",
  155 + "accessMode": "r",
  156 + "required": true,
  157 + "dataType": "bool",
  158 + "dataSpecsList": [
  159 + {
  160 + "dataType": "bool",
  161 + "name": "关",
  162 + "value": 0
  163 + },
  164 + {
  165 + "dataType": "bool",
  166 + "name": "开",
  167 + "value": 1
  168 + }
  169 + ]
  170 + }
  171 +}
  172 +
  173 +### 请求 /iot/product-thing-model/delete 接口 => 成功
  174 +DELETE {{baseUrl}}/iot/product-thing-model/delete?id=36
  175 +tenant-id: {{adminTenentId}}
  176 +Authorization: Bearer {{token}}
  177 +
  178 +### 请求 /iot/product-thing-model/get 接口 => 成功
  179 +GET {{baseUrl}}/iot/product-thing-model/get?id=40
  180 +tenant-id: {{adminTenentId}}
  181 +Authorization: Bearer {{token}}
  182 +
  183 +
  184 +### 请求 /iot/product-thing-model/list-by-product-id 接口 => 成功
  185 +GET {{baseUrl}}/iot/product-thing-model/list-by-product-id?productId=1001
  186 +tenant-id: {{adminTenentId}}
  187 +Authorization: Bearer {{token}}
0 \ No newline at end of file 188 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/IotProductThingModelController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelPageReqVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelRespVO;
  8 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelSaveReqVO;
  9 +import cn.iocoder.yudao.module.iot.convert.productthingmodel.IotProductThingModelConvert;
  10 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
  11 +import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
  12 +import io.swagger.v3.oas.annotations.Operation;
  13 +import io.swagger.v3.oas.annotations.Parameter;
  14 +import io.swagger.v3.oas.annotations.tags.Tag;
  15 +import jakarta.annotation.Resource;
  16 +import jakarta.validation.Valid;
  17 +import org.springframework.security.access.prepost.PreAuthorize;
  18 +import org.springframework.validation.annotation.Validated;
  19 +import org.springframework.web.bind.annotation.*;
  20 +
  21 +import java.util.List;
  22 +
  23 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  24 +
  25 +@Tag(name = "管理后台 - IoT 产品物模型")
  26 +@RestController
  27 +@RequestMapping("/iot/product-thing-model")
  28 +@Validated
  29 +public class IotProductThingModelController {
  30 +
  31 + @Resource
  32 + private IotProductThingModelService thinkModelFunctionService;
  33 +
  34 + @PostMapping("/create")
  35 + @Operation(summary = "创建产品物模型")
  36 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:create')")
  37 + public CommonResult<Long> createProductThingModel(@Valid @RequestBody IotProductThingModelSaveReqVO createReqVO) {
  38 + return success(thinkModelFunctionService.createProductThingModel(createReqVO));
  39 + }
  40 +
  41 + @PutMapping("/update")
  42 + @Operation(summary = "更新产品物模型")
  43 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:update')")
  44 + public CommonResult<Boolean> updateProductThingModel(@Valid @RequestBody IotProductThingModelSaveReqVO updateReqVO) {
  45 + thinkModelFunctionService.updateProductThingModel(updateReqVO);
  46 + return success(true);
  47 + }
  48 +
  49 + @DeleteMapping("/delete")
  50 + @Operation(summary = "删除产品物模型")
  51 + @Parameter(name = "id", description = "编号", required = true)
  52 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:delete')")
  53 + public CommonResult<Boolean> deleteProductThingModel(@RequestParam("id") Long id) {
  54 + thinkModelFunctionService.deleteProductThingModel(id);
  55 + return success(true);
  56 + }
  57 +
  58 + @GetMapping("/get")
  59 + @Operation(summary = "获得产品物模型")
  60 + @Parameter(name = "id", description = "编号", required = true)
  61 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:query')")
  62 + public CommonResult<IotProductThingModelRespVO> getProductThingModel(@RequestParam("id") Long id) {
  63 + IotProductThingModelDO function = thinkModelFunctionService.getProductThingModel(id);
  64 + return success(IotProductThingModelConvert.INSTANCE.convert(function));
  65 + }
  66 +
  67 + @GetMapping("/list-by-product-id")
  68 + @Operation(summary = "获得产品物模型")
  69 + @Parameter(name = "productId", description = "产品ID", required = true, example = "1024")
  70 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:query')")
  71 + public CommonResult<List<IotProductThingModelRespVO>> getProductThingModelListByProductId(@RequestParam("productId") Long productId) {
  72 + List<IotProductThingModelDO> list = thinkModelFunctionService.getProductThingModelListByProductId(productId);
  73 + return success(IotProductThingModelConvert.INSTANCE.convertList(list));
  74 + }
  75 +
  76 + @GetMapping("/page")
  77 + @Operation(summary = "获得产品物模型分页")
  78 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:query')")
  79 + public CommonResult<PageResult<IotProductThingModelRespVO>> getProductThingModelPage(@Valid IotProductThingModelPageReqVO pageReqVO) {
  80 + PageResult<IotProductThingModelDO> pageResult = thinkModelFunctionService.getProductThingModelPage(pageReqVO);
  81 + return success(BeanUtils.toBean(pageResult, IotProductThingModelRespVO.class));
  82 + }
  83 +
  84 +}
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 import lombok.Data; 4 import lombok.Data;
5 import java.util.List; 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 import lombok.*; 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 import lombok.Data; 4 import lombok.Data;
5 import java.util.List; 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 import lombok.Data; 3 import lombok.Data;
4 4
@@ -7,7 +7,7 @@ public class ThingModelArgument { @@ -7,7 +7,7 @@ public class ThingModelArgument {
7 7
8 private String identifier; 8 private String identifier;
9 private String name; 9 private String name;
10 - private ThingModelDataType dataType; 10 + private ThingModelDataSpecs dataType;
11 /** 11 /**
12 * 用于区分输入或输出参数,"input" 或 "output" 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 cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
  4 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * 物模型数据类型为数组的 DataSpec 定义
  12 + *
  13 + * @author HUIHUI
  14 + */
  15 +@Data
  16 +@EqualsAndHashCode(callSuper = true)
  17 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
  18 +public class ThingModelArrayDataSpecs extends ThingModelDataSpecs {
  19 +
  20 + /**
  21 + * 数组中的元素个数。
  22 + */
  23 + private Integer size;
  24 + /**
  25 + * 数组中的元素的数据类型。可选值:struct、int、float、double 或 text。
  26 + */
  27 + private String childDataType;
  28 + /**
  29 + * 数据类型(childDataType)为列表型 struct 的数据规范存储在 dataSpecsList 中。
  30 + * 此时 struct 取值范围为:int、float、double、text、date、enum、bool
  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 com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
  6 +
  7 +/**
  8 + * 物模型数据类型为布尔型或枚举型的 DataSpec 定义
  9 + *
  10 + * 数据类型,取值为 bool 或 enum。
  11 + *
  12 + * @author HUIHUI
  13 + */
  14 +@Data
  15 +@EqualsAndHashCode(callSuper = true)
  16 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
  17 +public class ThingModelBoolOrEnumDataSpecs extends ThingModelDataSpecs {
  18 +
  19 + /**
  20 + * 枚举项的名称。
  21 + * 可包含中文、大小写英文字母、数字、下划线(_)和短划线(-)。
  22 + * 必须以中文、英文字母或数字开头,长度不超过 20 个字符。
  23 + */
  24 + private String name;
  25 + /**
  26 + * 枚举值。
  27 + */
  28 + private Integer value;
  29 +
  30 +}
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 + @JsonSubTypes.Type(value = ThingModelStructDataSpecs.class, name = "struct")
  27 +})
  28 +public abstract class ThingModelDataSpecs {
  29 +
  30 + /**
  31 + * 数据类型
  32 + */
  33 + private String dataType;
  34 +
  35 +}
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 com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
  6 +
  7 +/**
  8 + * 物模型数据类型为时间型或文本型的 DataSpec 定义
  9 + *
  10 + * 数据类型,取值为 date 或 text。
  11 + *
  12 + * @author HUIHUI
  13 + */
  14 +@Data
  15 +@EqualsAndHashCode(callSuper = true)
  16 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
  17 +public class ThingModelDateOrTextDataSpecs extends ThingModelDataSpecs {
  18 +
  19 + /**
  20 + * 数据长度,单位为字节。取值不能超过 2048。
  21 + * 当 dataType 为 text 时,需传入该参数。
  22 + */
  23 + private Long length;
  24 + /**
  25 + * 默认值,可选参数,用于存储默认值。
  26 + */
  27 + private String defaultValue;
  28 +
  29 +}
  30 +
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 com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
  6 +
  7 +/**
  8 + * 物模型数据类型为数值的 DataSpec 定义
  9 + *
  10 + * 数据类型,取值为 int、float 或 double。
  11 + *
  12 + * @author HUIHUI
  13 + */
  14 +@Data
  15 +@EqualsAndHashCode(callSuper = true)
  16 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
  17 +public class ThingModelNumericDataSpec extends ThingModelDataSpecs {
  18 +
  19 + /**
  20 + * 最大值,需转为字符串类型。值必须与 dataType 类型一致。
  21 + * 例如,当 dataType 为 int 时,取值为 "200",而不是 200。
  22 + */
  23 + private String max;
  24 + /**
  25 + * 最小值,需转为字符串类型。值必须与 dataType 类型一致。
  26 + * 例如,当 dataType 为 int 时,取值为 "0",而不是 0。
  27 + */
  28 + private String min;
  29 + /**
  30 + * 步长,需转为字符串类型。值必须与 dataType 类型一致。
  31 + * 例如,当 dataType 为 int 时,取值为 "10",而不是 10。
  32 + */
  33 + private String step;
  34 + /**
  35 + * 精度。当 dataType 为 float 或 double 时可选传入。
  36 + */
  37 + private String precise;
  38 + /**
  39 + * 默认值,可传入用于存储的默认值。
  40 + */
  41 + private String defaultValue;
  42 + /**
  43 + * 单位的符号。
  44 + */
  45 + private String unit;
  46 + /**
  47 + * 单位的名称。
  48 + */
  49 + private String unitName;
  50 +
  51 +}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelStructDataSpecs.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  2 +
  3 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelAccessModeEnum;
  4 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * 物模型数据类型为 struct 的 DataSpec 定义
  12 + *
  13 + * @author HUIHUI
  14 + */
  15 +@Data
  16 +@EqualsAndHashCode(callSuper = true)
  17 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
  18 +public class ThingModelStructDataSpecs extends ThingModelDataSpecs {
  19 +
  20 + /**
  21 + * 属性标识符
  22 + */
  23 + private String identifier;
  24 + /**
  25 + * 属性名称
  26 + */
  27 + private String name;
  28 + /**
  29 + * 属性描述
  30 + */
  31 + private String description;
  32 + /**
  33 + * 云端可以对该属性进行的操作类型
  34 + * 关联枚举 {@link IotProductThingModelAccessModeEnum}
  35 + */
  36 + private String accessMode;
  37 + /**
  38 + * 是否是标准品类的必选服务。
  39 + *
  40 + * - true:是
  41 + * - false:否
  42 + */
  43 + private Boolean required;
  44 + /**
  45 + * struct 数据的数据类型
  46 + */
  47 + private String childDataType;
  48 + /**
  49 + * 数据类型(dataType)为非列表型(int、float、double、text、date、array)的数据规范存储在 dataSpecs 中
  50 + */
  51 + private ThingModelDataSpecs dataSpecs;
  52 + /**
  53 + * 数据类型(dataType)为列表型(enum、bool、struct)的数据规范存储在 dataSpecsList 中
  54 + */
  55 + private List<ThingModelDataSpecs> dataSpecsList;
  56 +
  57 +}
  58 +
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/IotProductThingModelPageReqVO.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.framework.common.pojo.PageParam; 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 import cn.iocoder.yudao.framework.common.validation.InEnum; 4 import cn.iocoder.yudao.framework.common.validation.InEnum;
5 -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; 5 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
6 import io.swagger.v3.oas.annotations.media.Schema; 6 import io.swagger.v3.oas.annotations.media.Schema;
7 import jakarta.validation.constraints.NotNull; 7 import jakarta.validation.constraints.NotNull;
8 import lombok.Data; 8 import lombok.Data;
@@ -13,7 +13,7 @@ import lombok.ToString; @@ -13,7 +13,7 @@ import lombok.ToString;
13 @Data 13 @Data
14 @EqualsAndHashCode(callSuper = true) 14 @EqualsAndHashCode(callSuper = true)
15 @ToString(callSuper = true) 15 @ToString(callSuper = true)
16 -public class IotThinkModelFunctionPageReqVO extends PageParam { 16 +public class IotProductThingModelPageReqVO extends PageParam {
17 17
18 @Schema(description = "功能标识") 18 @Schema(description = "功能标识")
19 private String identifier; 19 private String identifier;
@@ -22,7 +22,7 @@ public class IotThinkModelFunctionPageReqVO extends PageParam { @@ -22,7 +22,7 @@ public class IotThinkModelFunctionPageReqVO extends PageParam {
22 private String name; 22 private String name;
23 23
24 @Schema(description = "功能类型", example = "1") 24 @Schema(description = "功能类型", example = "1")
25 - @InEnum(IotProductFunctionTypeEnum.class) 25 + @InEnum(IotProductThingModelTypeEnum.class)
26 private Integer type; 26 private Integer type;
27 27
28 @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED) 28 @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED)
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/IotProductThingModelRespVO.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 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; 6 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
7 import com.alibaba.excel.annotation.ExcelProperty; 7 import com.alibaba.excel.annotation.ExcelProperty;
8 import io.swagger.v3.oas.annotations.media.Schema; 8 import io.swagger.v3.oas.annotations.media.Schema;
@@ -13,7 +13,7 @@ import java.time.LocalDateTime; @@ -13,7 +13,7 @@ import java.time.LocalDateTime;
13 @Schema(description = "管理后台 - IoT 产品物模型 Response VO") 13 @Schema(description = "管理后台 - IoT 产品物模型 Response VO")
14 @Data 14 @Data
15 @ExcelIgnoreUnannotated 15 @ExcelIgnoreUnannotated
16 -public class IotThinkModelFunctionRespVO { 16 +public class IotProductThingModelRespVO {
17 17
18 @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21816") 18 @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21816")
19 @ExcelProperty("产品ID") 19 @ExcelProperty("产品ID")
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/IotProductThingModelSaveReqVO.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.framework.common.validation.InEnum; 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;  
7 -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; 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 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
8 import io.swagger.v3.oas.annotations.media.Schema; 8 import io.swagger.v3.oas.annotations.media.Schema;
9 import jakarta.validation.constraints.NotEmpty; 9 import jakarta.validation.constraints.NotEmpty;
10 import jakarta.validation.constraints.NotNull; 10 import jakarta.validation.constraints.NotNull;
@@ -12,7 +12,7 @@ import lombok.Data; @@ -12,7 +12,7 @@ import lombok.Data;
12 12
13 @Schema(description = "管理后台 - IoT 产品物模型新增/修改 Request VO") 13 @Schema(description = "管理后台 - IoT 产品物模型新增/修改 Request VO")
14 @Data 14 @Data
15 -public class IotThinkModelFunctionSaveReqVO { 15 +public class IotProductThingModelSaveReqVO {
16 16
17 @Schema(description = "编号", example = "1") 17 @Schema(description = "编号", example = "1")
18 private Long id; 18 private Long id;
@@ -38,7 +38,7 @@ public class IotThinkModelFunctionSaveReqVO { @@ -38,7 +38,7 @@ public class IotThinkModelFunctionSaveReqVO {
38 38
39 @Schema(description = "功能类型", requiredMode = Schema.RequiredMode.REQUIRED) 39 @Schema(description = "功能类型", requiredMode = Schema.RequiredMode.REQUIRED)
40 @NotNull(message = "功能类型不能为空") 40 @NotNull(message = "功能类型不能为空")
41 - @InEnum(IotProductFunctionTypeEnum.class) 41 + @InEnum(IotProductThingModelTypeEnum.class)
42 private Integer type; 42 private Integer type;
43 43
44 @Schema(description = "属性", requiredMode = Schema.RequiredMode.REQUIRED) 44 @Schema(description = "属性", requiredMode = Schema.RequiredMode.REQUIRED)
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/IotThinkModelFunctionController.http deleted
1 -### 请求 /iot/think-model-function/create 接口 => 成功  
2 -POST {{baseUrl}}/iot/think-model-function/create  
3 -Content-Type: application/json  
4 -tenant-id: {{adminTenentId}}  
5 -Authorization: Bearer {{token}}  
6 -  
7 -{  
8 - "productId": 1001,  
9 - "productKey": "smart-sensor-001",  
10 - "identifier": "Temperature",  
11 - "name": "温度",  
12 - "description": "当前温度值",  
13 - "type": 1,  
14 - "property": {  
15 - "identifier": "Temperature",  
16 - "name": "温度",  
17 - "accessMode": "r",  
18 - "required": true,  
19 - "dataType": {  
20 - "type": "float",  
21 - "specs": {  
22 - "min": -10.0,  
23 - "max": 100.0,  
24 - "step": 0.1,  
25 - "unit": "℃"  
26 - }  
27 - },  
28 - "description": "当前温度值"  
29 - }  
30 -}  
31 -  
32 -### 请求 /iot/think-model-function/create 接口 => 成功  
33 -POST {{baseUrl}}/iot/think-model-function/create  
34 -Content-Type: application/json  
35 -tenant-id: {{adminTenentId}}  
36 -Authorization: Bearer {{token}}  
37 -  
38 -{  
39 - "productId": 1001,  
40 - "productKey": "smart-sensor-001",  
41 - "identifier": "Humidity",  
42 - "name": "湿度",  
43 - "description": "当前湿度值",  
44 - "type": 1,  
45 - "property": {  
46 - "identifier": "Humidity",  
47 - "name": "湿度",  
48 - "accessMode": "r",  
49 - "required": true,  
50 - "dataType": {  
51 - "type": "float",  
52 - "specs": {  
53 - "min": 0.0,  
54 - "max": 100.0,  
55 - "step": 0.1,  
56 - "unit": "%"  
57 - }  
58 - },  
59 - "description": "当前湿度值"  
60 - }  
61 -}  
62 -  
63 -  
64 -  
65 -  
66 -### 请求 /iot/think-model-function/update 接口 => 成功  
67 -PUT {{baseUrl}}/iot/think-model-function/update  
68 -Content-Type: application/json  
69 -tenant-id: {{adminTenentId}}  
70 -Authorization: Bearer {{token}}  
71 -  
72 -{  
73 - "id": 11,  
74 - "productId": 1001,  
75 - "productKey": "smart-sensor-001",  
76 - "identifier": "Temperature",  
77 - "name": "温度",  
78 - "description": "当前温度值",  
79 - "type": 1,  
80 - "property": {  
81 - "identifier": "Temperature",  
82 - "name": "温度",  
83 - "accessMode": "r",  
84 - "required": true,  
85 - "dataType": {  
86 - "type": "float",  
87 - "specs": {  
88 - "min": -111.0,  
89 - "max": 222.0,  
90 - "step": 0.1,  
91 - "unit": "℃"  
92 - }  
93 - },  
94 - "description": "当前温度值"  
95 - }  
96 -}  
97 -  
98 -### 请求 /iot/think-model-function/delete 接口 => 成功  
99 -DELETE {{baseUrl}}/iot/think-model-function/delete?id=7  
100 -tenant-id: {{adminTenentId}}  
101 -Authorization: Bearer {{token}}  
102 -  
103 -### 请求 /iot/think-model-function/get 接口 => 成功  
104 -GET {{baseUrl}}/iot/think-model-function/get?id=10  
105 -tenant-id: {{adminTenentId}}  
106 -Authorization: Bearer {{token}}  
107 -  
108 -  
109 -### 请求 /iot/think-model-function/list-by-product-id 接口 => 成功  
110 -GET {{baseUrl}}/iot/think-model-function/list-by-product-id?productId=1001  
111 -tenant-id: {{adminTenentId}}  
112 -Authorization: Bearer {{token}}  
113 \ No newline at end of file 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/IotThinkModelFunctionController.java deleted
1 -package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.CommonResult;  
4 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
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;  
9 -import cn.iocoder.yudao.module.iot.convert.thinkmodelfunction.IotThinkModelFunctionConvert;  
10 -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;  
11 -import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService;  
12 -import io.swagger.v3.oas.annotations.Operation;  
13 -import io.swagger.v3.oas.annotations.Parameter;  
14 -import io.swagger.v3.oas.annotations.tags.Tag;  
15 -import jakarta.annotation.Resource;  
16 -import jakarta.validation.Valid;  
17 -import org.springframework.security.access.prepost.PreAuthorize;  
18 -import org.springframework.validation.annotation.Validated;  
19 -import org.springframework.web.bind.annotation.*;  
20 -  
21 -import java.util.List;  
22 -  
23 -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;  
24 -  
25 -@Tag(name = "管理后台 - IoT 产品物模型")  
26 -@RestController  
27 -@RequestMapping("/iot/think-model-function")  
28 -@Validated  
29 -public class IotThinkModelFunctionController {  
30 -  
31 - @Resource  
32 - private IotThinkModelFunctionService thinkModelFunctionService;  
33 -  
34 - @PostMapping("/create")  
35 - @Operation(summary = "创建产品物模型")  
36 - @PreAuthorize("@ss.hasPermission('iot:think-model-function:create')")  
37 - public CommonResult<Long> createThinkModelFunction(@Valid @RequestBody IotThinkModelFunctionSaveReqVO createReqVO) {  
38 - return success(thinkModelFunctionService.createThinkModelFunction(createReqVO));  
39 - }  
40 -  
41 - @PutMapping("/update")  
42 - @Operation(summary = "更新产品物模型")  
43 - @PreAuthorize("@ss.hasPermission('iot:think-model-function:update')")  
44 - public CommonResult<Boolean> updateThinkModelFunction(@Valid @RequestBody IotThinkModelFunctionSaveReqVO updateReqVO) {  
45 - thinkModelFunctionService.updateThinkModelFunction(updateReqVO);  
46 - return success(true);  
47 - }  
48 -  
49 - @DeleteMapping("/delete")  
50 - @Operation(summary = "删除产品物模型")  
51 - @Parameter(name = "id", description = "编号", required = true)  
52 - @PreAuthorize("@ss.hasPermission('iot:think-model-function:delete')")  
53 - public CommonResult<Boolean> deleteThinkModelFunction(@RequestParam("id") Long id) {  
54 - thinkModelFunctionService.deleteThinkModelFunction(id);  
55 - return success(true);  
56 - }  
57 -  
58 - @GetMapping("/get")  
59 - @Operation(summary = "获得产品物模型")  
60 - @Parameter(name = "id", description = "编号", required = true)  
61 - @PreAuthorize("@ss.hasPermission('iot:think-model-function:query')")  
62 - public CommonResult<IotThinkModelFunctionRespVO> getThinkModelFunction(@RequestParam("id") Long id) {  
63 - IotThinkModelFunctionDO function = thinkModelFunctionService.getThinkModelFunction(id);  
64 - return success(IotThinkModelFunctionConvert.INSTANCE.convert(function));  
65 - }  
66 -  
67 - @GetMapping("/list-by-product-id")  
68 - @Operation(summary = "获得产品物模型")  
69 - @Parameter(name = "productId", description = "产品ID", required = true, example = "1024")  
70 - @PreAuthorize("@ss.hasPermission('iot:think-model-function:query')")  
71 - public CommonResult<List<IotThinkModelFunctionRespVO>> getThinkModelFunctionListByProductId(@RequestParam("productId") Long productId) {  
72 - List<IotThinkModelFunctionDO> list = thinkModelFunctionService.getThinkModelFunctionListByProductId(productId);  
73 - return success(IotThinkModelFunctionConvert.INSTANCE.convertList(list));  
74 - }  
75 -  
76 - @GetMapping("/page")  
77 - @Operation(summary = "获得产品物模型分页")  
78 - @PreAuthorize("@ss.hasPermission('iot:think-model-function:query')")  
79 - public CommonResult<PageResult<IotThinkModelFunctionRespVO>> getThinkModelFunctionPage(@Valid IotThinkModelFunctionPageReqVO pageReqVO) {  
80 - PageResult<IotThinkModelFunctionDO> pageResult = thinkModelFunctionService.getThinkModelFunctionPage(pageReqVO);  
81 - return success(BeanUtils.toBean(pageResult, IotThinkModelFunctionRespVO.class));  
82 - }  
83 -  
84 -}  
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 -@Data  
7 -public class ThingModelProperty {  
8 -  
9 - /**  
10 - * 属性标识符  
11 - */  
12 - private String identifier;  
13 - /**  
14 - * 属性名称  
15 - */  
16 - private String name;  
17 - /**  
18 - * 属性描述  
19 - */  
20 - private String description;  
21 -  
22 - private String accessMode; // "rw"、"r"、"w"  
23 - private Boolean required;  
24 - // TODO @haohao:这个是不是 dataSpecs 和 dataSpecsList?https://help.aliyun.com/zh/iot/developer-reference/api-a99t11  
25 - private ThingModelDataType dataType;  
26 -  
27 -}  
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 = "type", 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 type;  
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 \ No newline at end of file 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/device/IotDeviceDataConvert.java
1 package cn.iocoder.yudao.module.iot.convert.device; 1 package cn.iocoder.yudao.module.iot.convert.device;
2 2
3 -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataRespVO;  
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;  
7 -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionRespVO;  
8 -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionSaveReqVO;  
9 -import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;  
10 -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;  
11 -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum;  
12 import org.mapstruct.Mapper; 3 import org.mapstruct.Mapper;
13 -import org.mapstruct.Mapping;  
14 import org.mapstruct.factory.Mappers; 4 import org.mapstruct.factory.Mappers;
15 5
16 -import java.util.ArrayList;  
17 -import java.util.List;  
18 -import java.util.Map;  
19 -import java.util.Objects;  
20 -  
21 @Mapper 6 @Mapper
22 public interface IotDeviceDataConvert { 7 public interface IotDeviceDataConvert {
23 8
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/productthingmodel/IotProductThingModelConvert.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.convert.productthingmodel;
  2 +
  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.IotProductThingModelRespVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelSaveReqVO;
  8 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
  9 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
  10 +import org.mapstruct.Mapper;
  11 +import org.mapstruct.Mapping;
  12 +import org.mapstruct.Named;
  13 +import org.mapstruct.factory.Mappers;
  14 +
  15 +import java.util.List;
  16 +import java.util.Objects;
  17 +
  18 +@Mapper
  19 +public interface IotProductThingModelConvert {
  20 +
  21 + IotProductThingModelConvert INSTANCE = Mappers.getMapper(IotProductThingModelConvert.class);
  22 +
  23 + // 将 SaveReqVO 转换为 DO
  24 + @Mapping(target = "property", expression = "java(convertToProperty(bean))")
  25 + @Mapping(target = "event", expression = "java(convertToEvent(bean))")
  26 + @Mapping(target = "service", expression = "java(convertToService(bean))")
  27 + IotProductThingModelDO convert(IotProductThingModelSaveReqVO bean);
  28 +
  29 + // 将 DO 转换为 RespVO
  30 + @Mapping(target = "property", source = "property")
  31 + @Mapping(target = "event", source = "event")
  32 + @Mapping(target = "service", source = "service")
  33 + IotProductThingModelRespVO convert(IotProductThingModelDO bean);
  34 +
  35 + // 批量转换
  36 + List<IotProductThingModelRespVO> convertList(List<IotProductThingModelDO> list);
  37 +
  38 + @Named("convertToProperty")
  39 + default ThingModelProperty convertToProperty(IotProductThingModelSaveReqVO bean) {
  40 + if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
  41 + return bean.getProperty();
  42 + }
  43 + return null;
  44 + }
  45 +
  46 + @Named("convertToEvent")
  47 + default ThingModelEvent convertToEvent(IotProductThingModelSaveReqVO bean) {
  48 + if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.EVENT.getType())) {
  49 + return bean.getEvent();
  50 + }
  51 + return null;
  52 + }
  53 +
  54 + @Named("convertToService")
  55 + default ThingModelService convertToService(IotProductThingModelSaveReqVO bean) {
  56 + if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.SERVICE.getType())) {
  57 + return bean.getService();
  58 + }
  59 + return null;
  60 + }
  61 +
  62 +}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/thinkmodelfunction/IotThinkModelFunctionConvert.java deleted
1 -package cn.iocoder.yudao.module.iot.convert.thinkmodelfunction;  
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;  
9 -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum;  
10 -import org.mapstruct.Mapper;  
11 -import org.mapstruct.Mapping;  
12 -import org.mapstruct.factory.Mappers;  
13 -  
14 -import java.util.List;  
15 -import java.util.Objects;  
16 -  
17 -@Mapper  
18 -public interface IotThinkModelFunctionConvert {  
19 -  
20 - IotThinkModelFunctionConvert INSTANCE = Mappers.getMapper(IotThinkModelFunctionConvert.class);  
21 -  
22 - // 将 SaveReqVO 转换为 DO  
23 - @Mapping(target = "property", expression = "java(convertToProperty(bean))")  
24 - @Mapping(target = "event", expression = "java(convertToEvent(bean))")  
25 - @Mapping(target = "service", expression = "java(convertToService(bean))")  
26 - IotThinkModelFunctionDO convert(IotThinkModelFunctionSaveReqVO bean);  
27 -  
28 - default ThingModelProperty convertToProperty(IotThinkModelFunctionSaveReqVO bean) {  
29 - if (Objects.equals(bean.getType(), IotProductFunctionTypeEnum.PROPERTY.getType())) {  
30 - return bean.getProperty();  
31 - }  
32 - return null;  
33 - }  
34 -  
35 - default ThingModelEvent convertToEvent(IotThinkModelFunctionSaveReqVO bean) {  
36 - if (Objects.equals(bean.getType(), IotProductFunctionTypeEnum.EVENT.getType())) {  
37 - return bean.getEvent();  
38 - }  
39 - return null;  
40 - }  
41 -  
42 - default ThingModelService convertToService(IotThinkModelFunctionSaveReqVO bean) {  
43 - if (Objects.equals(bean.getType(), IotProductFunctionTypeEnum.SERVICE.getType())) {  
44 - return bean.getService();  
45 - }  
46 - return null;  
47 - }  
48 -  
49 - // 将 DO 转换为 RespVO  
50 - @Mapping(target = "property", source = "property")  
51 - @Mapping(target = "event", source = "event")  
52 - @Mapping(target = "service", source = "service")  
53 - IotThinkModelFunctionRespVO convert(IotThinkModelFunctionDO bean);  
54 -  
55 - // 批量转换  
56 - List<IotThinkModelFunctionRespVO> convertList(List<IotThinkModelFunctionDO> list);  
57 -}  
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/device/IotDeviceDataDO.java
1 package cn.iocoder.yudao.module.iot.dal.dataobject.device; 1 package cn.iocoder.yudao.module.iot.dal.dataobject.device;
2 2
3 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; 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 import lombok.AllArgsConstructor; 5 import lombok.AllArgsConstructor;
6 import lombok.Builder; 6 import lombok.Builder;
7 import lombok.Data; 7 import lombok.Data;
@@ -30,7 +30,7 @@ public class IotDeviceDataDO { @@ -30,7 +30,7 @@ public class IotDeviceDataDO {
30 /** 30 /**
31 * 物模型编号 31 * 物模型编号
32 * <p> 32 * <p>
33 - * 关联 {@link IotThinkModelFunctionDO#getId()} 33 + * 关联 {@link IotProductThingModelDO#getId()}
34 */ 34 */
35 private Long thinkModelFunctionId; 35 private Long thinkModelFunctionId;
36 36
@@ -51,21 +51,21 @@ public class IotDeviceDataDO { @@ -51,21 +51,21 @@ public class IotDeviceDataDO {
51 /** 51 /**
52 * 属性标识符 52 * 属性标识符
53 * <p> 53 * <p>
54 - * 关联 {@link IotThinkModelFunctionDO#getIdentifier()} 54 + * 关联 {@link IotProductThingModelDO#getIdentifier()}
55 */ 55 */
56 private String identifier; 56 private String identifier;
57 57
58 /** 58 /**
59 * 属性名称 59 * 属性名称
60 * <p> 60 * <p>
61 - * 关联 {@link IotThinkModelFunctionDO#getName()} 61 + * 关联 {@link IotProductThingModelDO#getName()}
62 */ 62 */
63 private String name; 63 private String name;
64 64
65 /** 65 /**
66 * 数据类型 66 * 数据类型
67 * <p> 67 * <p>
68 - * 关联 {@link IotThinkModelFunctionDO#getProperty()#getDataType()} 68 + * 关联 {@link IotProductThingModelDO#getProperty()#getDataType()}
69 */ 69 */
70 private String dataType; 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 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; 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 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; 7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
8 -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; 8 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
9 import com.baomidou.mybatisplus.annotation.KeySequence; 9 import com.baomidou.mybatisplus.annotation.KeySequence;
10 import com.baomidou.mybatisplus.annotation.TableField; 10 import com.baomidou.mybatisplus.annotation.TableField;
11 import com.baomidou.mybatisplus.annotation.TableId; 11 import com.baomidou.mybatisplus.annotation.TableId;
@@ -19,17 +19,17 @@ import lombok.NoArgsConstructor; @@ -19,17 +19,17 @@ import lombok.NoArgsConstructor;
19 /** 19 /**
20 * IoT 产品物模型功能 DO 20 * IoT 产品物模型功能 DO
21 * <p> 21 * <p>
22 - * 每个 {@link IotProductDO} 和 {@link IotThinkModelFunctionDO} 是“一对多”的关系,它的每个属性、事件、服务都对应一条记录 22 + * 每个 {@link IotProductDO} 和 {@link IotProductThingModelDO} 是“一对多”的关系,它的每个属性、事件、服务都对应一条记录
23 * 23 *
24 * @author 芋道源码 24 * @author 芋道源码
25 */ 25 */
26 -@TableName(value = "iot_think_model_function", autoResultMap = true)  
27 -@KeySequence("iot_think_model_function_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 26 +@TableName(value = "iot_product_thing_model", autoResultMap = true)
  27 +@KeySequence("iot_product_thing_model_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
28 @Data 28 @Data
29 @Builder 29 @Builder
30 @NoArgsConstructor 30 @NoArgsConstructor
31 @AllArgsConstructor 31 @AllArgsConstructor
32 -public class IotThinkModelFunctionDO extends BaseDO { 32 +public class IotProductThingModelDO extends BaseDO {
33 33
34 /** 34 /**
35 * 物模型功能编号 35 * 物模型功能编号
@@ -66,7 +66,7 @@ public class IotThinkModelFunctionDO extends BaseDO { @@ -66,7 +66,7 @@ public class IotThinkModelFunctionDO extends BaseDO {
66 /** 66 /**
67 * 功能类型 67 * 功能类型
68 * <p> 68 * <p>
69 - * 枚举 {@link IotProductFunctionTypeEnum} 69 + * 枚举 {@link IotProductThingModelTypeEnum}
70 */ 70 */
71 private Integer type; 71 private Integer type;
72 72
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/tdengine/FieldParser.java
1 package cn.iocoder.yudao.module.iot.dal.dataobject.tdengine; 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 import java.util.HashMap; 7 import java.util.HashMap;
8 import java.util.List; 8 import java.util.List;
@@ -36,17 +36,19 @@ public class FieldParser { @@ -36,17 +36,19 @@ public class FieldParser {
36 */ 36 */
37 public static TdFieldDO parse(ThingModelProperty property) { 37 public static TdFieldDO parse(ThingModelProperty property) {
38 String fieldName = property.getIdentifier().toLowerCase(); 38 String fieldName = property.getIdentifier().toLowerCase();
39 - ThingModelDataType type = property.getDataType();  
40 -  
41 - // 将物模型字段类型映射为td字段类型  
42 - String fType = TYPE_MAPPING.get(type.getType().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/IotProductThingModelMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelPageReqVO;
  7 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * IoT 产品物模型 Mapper
  14 + *
  15 + * @author 芋道源码
  16 + */
  17 +@Mapper
  18 +public interface IotProductThingModelMapper extends BaseMapperX<IotProductThingModelDO> {
  19 +
  20 + default PageResult<IotProductThingModelDO> selectPage(IotProductThingModelPageReqVO 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 + }
  29 +
  30 + default IotProductThingModelDO selectByProductIdAndIdentifier(Long productId, String identifier) {
  31 + return selectOne(IotProductThingModelDO::getProductId, productId,
  32 + IotProductThingModelDO::getIdentifier, identifier);
  33 + }
  34 +
  35 + default List<IotProductThingModelDO> selectListByProductId(Long productId) {
  36 + return selectList(IotProductThingModelDO::getProductId, productId);
  37 + }
  38 +
  39 + default List<IotProductThingModelDO> selectListByProductIdAndType(Long productId, Integer type) {
  40 + return selectList(IotProductThingModelDO::getProductId, productId,
  41 + IotProductThingModelDO::getType, type);
  42 + }
  43 +
  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 + }
  52 +
  53 + default IotProductThingModelDO selectByProductIdAndName(Long productId, String name) {
  54 + return selectOne(IotProductThingModelDO::getProductId, productId,
  55 + IotProductThingModelDO::getName, name);
  56 + }
  57 +
  58 + default List<IotProductThingModelDO> selectListByProductKey(String productKey) {
  59 + return selectList(IotProductThingModelDO::getProductKey, productKey);
  60 + }
  61 +
  62 +}
0 \ No newline at end of file 63 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/thinkmodelfunction/IotThinkModelFunctionMapper.java deleted
1 -package cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction;  
2 -  
3 -import cn.iocoder.yudao.framework.common.pojo.PageResult;  
4 -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;  
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;  
8 -import org.apache.ibatis.annotations.Mapper;  
9 -  
10 -import java.util.List;  
11 -  
12 -/**  
13 - * IoT 产品物模型 Mapper  
14 - *  
15 - * @author 芋道源码  
16 - */  
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));  
28 - }  
29 -  
30 - default IotThinkModelFunctionDO selectByProductIdAndIdentifier(Long productId, String identifier) {  
31 - return selectOne(IotThinkModelFunctionDO::getProductId, productId,  
32 - IotThinkModelFunctionDO::getIdentifier, identifier);  
33 - }  
34 -  
35 - default List<IotThinkModelFunctionDO> selectListByProductId(Long productId) {  
36 - return selectList(IotThinkModelFunctionDO::getProductId, productId);  
37 - }  
38 -  
39 - default List<IotThinkModelFunctionDO> selectListByProductIdAndType(Long productId, Integer type) {  
40 - return selectList(IotThinkModelFunctionDO::getProductId, productId,  
41 - IotThinkModelFunctionDO::getType, type);  
42 - }  
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));  
51 - }  
52 -  
53 - default IotThinkModelFunctionDO selectByProductIdAndName(Long productId, String name) {  
54 - return selectOne(IotThinkModelFunctionDO::getProductId, productId,  
55 - IotThinkModelFunctionDO::getName, name);  
56 - }  
57 -  
58 - default List<IotThinkModelFunctionDO> selectListByProductKey(String productKey) {  
59 - return selectList(IotThinkModelFunctionDO::getProductKey, productKey);  
60 - }  
61 -  
62 -}  
63 \ No newline at end of file 0 \ 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,15 +7,15 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -7,15 +7,15 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
7 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataPageReqVO; 7 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataPageReqVO;
8 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; 8 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
9 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO; 9 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO;
  10 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
10 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.SelectVisualDO; 11 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.SelectVisualDO;
11 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage; 12 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
12 -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;  
13 import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; 13 import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO;
14 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; 14 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper;
15 import cn.iocoder.yudao.module.iot.enums.IotConstants; 15 import cn.iocoder.yudao.module.iot.enums.IotConstants;
16 -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; 16 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
17 import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService; 17 import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService;
18 -import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService; 18 +import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
19 import jakarta.annotation.Resource; 19 import jakarta.annotation.Resource;
20 import jakarta.validation.Valid; 20 import jakarta.validation.Valid;
21 import lombok.extern.slf4j.Slf4j; 21 import lombok.extern.slf4j.Slf4j;
@@ -40,7 +40,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService { @@ -40,7 +40,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
40 @Resource 40 @Resource
41 private IotThingModelMessageService thingModelMessageService; 41 private IotThingModelMessageService thingModelMessageService;
42 @Resource 42 @Resource
43 - private IotThinkModelFunctionService thinkModelFunctionService; 43 + private IotProductThingModelService thinkModelFunctionService;
44 @Resource 44 @Resource
45 private TdEngineDMLMapper tdEngineDMLMapper; 45 private TdEngineDMLMapper tdEngineDMLMapper;
46 46
@@ -73,9 +73,9 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService { @@ -73,9 +73,9 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
73 // 1. 获取设备信息 73 // 1. 获取设备信息
74 IotDeviceDO device = deviceService.getDevice(deviceDataReqVO.getDeviceId()); 74 IotDeviceDO device = deviceService.getDevice(deviceDataReqVO.getDeviceId());
75 // 2. 获取设备属性最新数据 75 // 2. 获取设备属性最新数据
76 - List<IotThinkModelFunctionDO> thinkModelFunctionList = thinkModelFunctionService.getThinkModelFunctionListByProductKey(device.getProductKey()); 76 + List<IotProductThingModelDO> thinkModelFunctionList = thinkModelFunctionService.getProductThingModelListByProductKey(device.getProductKey());
77 thinkModelFunctionList = thinkModelFunctionList.stream() 77 thinkModelFunctionList = thinkModelFunctionList.stream()
78 - .filter(function -> IotProductFunctionTypeEnum.PROPERTY.getType() 78 + .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType()
79 .equals(function.getType())).toList(); 79 .equals(function.getType())).toList();
80 80
81 // 3. 过滤标识符和属性名称 81 // 3. 过滤标识符和属性名称
@@ -90,6 +90,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService { @@ -90,6 +90,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
90 .toList(); 90 .toList();
91 } 91 }
92 // 4. 获取设备属性最新数据 92 // 4. 获取设备属性最新数据
  93 + // TODO @puhui999: 需要重构
93 thinkModelFunctionList.forEach(function -> { 94 thinkModelFunctionList.forEach(function -> {
94 IotDeviceDataDO deviceData = deviceDataRedisDAO.get(device.getProductKey(), device.getDeviceName(), function.getIdentifier()); 95 IotDeviceDataDO deviceData = deviceDataRedisDAO.get(device.getProductKey(), device.getDeviceName(), function.getIdentifier());
95 if (deviceData == null) { 96 if (deviceData == null) {
@@ -100,7 +101,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService { @@ -100,7 +101,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
100 deviceData.setDeviceId(deviceDataReqVO.getDeviceId()); 101 deviceData.setDeviceId(deviceDataReqVO.getDeviceId());
101 deviceData.setThinkModelFunctionId(function.getId()); 102 deviceData.setThinkModelFunctionId(function.getId());
102 deviceData.setName(function.getName()); 103 deviceData.setName(function.getName());
103 - deviceData.setDataType(function.getProperty().getDataType().getType()); 104 + //deviceData.setDataType(function.getProperty().getDataType().getDataType());
104 } 105 }
105 list.add(deviceData); 106 list.add(deviceData);
106 }); 107 });
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/IotProductServiceImpl.java
@@ -7,7 +7,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.product.vo.product.IotProduc @@ -7,7 +7,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.product.vo.product.IotProduc
7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; 7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
8 import cn.iocoder.yudao.module.iot.dal.mysql.product.IotProductMapper; 8 import cn.iocoder.yudao.module.iot.dal.mysql.product.IotProductMapper;
9 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum; 9 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum;
10 -import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService; 10 +import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
11 import com.baomidou.dynamic.datasource.annotation.DSTransactional; 11 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
12 import jakarta.annotation.Resource; 12 import jakarta.annotation.Resource;
13 import org.springframework.context.annotation.Lazy; 13 import org.springframework.context.annotation.Lazy;
@@ -34,7 +34,7 @@ public class IotProductServiceImpl implements IotProductService { @@ -34,7 +34,7 @@ public class IotProductServiceImpl implements IotProductService {
34 34
35 @Resource 35 @Resource
36 @Lazy 36 @Lazy
37 - private IotThinkModelFunctionService thinkModelFunctionService; 37 + private IotProductThingModelService thinkModelFunctionService;
38 38
39 @Override 39 @Override
40 public Long createProduct(IotProductSaveReqVO createReqVO) { 40 public Long createProduct(IotProductSaveReqVO createReqVO) {
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thinkmodelfunction/IotThinkModelFunctionService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/productthingmodel/IotProductThingModelService.java
1 -package cn.iocoder.yudao.module.iot.service.thinkmodelfunction; 1 +package cn.iocoder.yudao.module.iot.service.productthingmodel;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.IotProductThingModelPageReqVO;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelSaveReqVO;
  6 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
7 import jakarta.validation.Valid; 7 import jakarta.validation.Valid;
8 8
9 import java.util.List; 9 import java.util.List;
@@ -13,7 +13,7 @@ import java.util.List; @@ -13,7 +13,7 @@ import java.util.List;
13 * 13 *
14 * @author 芋道源码 14 * @author 芋道源码
15 */ 15 */
16 -public interface IotThinkModelFunctionService { 16 +public interface IotProductThingModelService {
17 17
18 /** 18 /**
19 * 创建产品物模型 19 * 创建产品物模型
@@ -21,7 +21,7 @@ public interface IotThinkModelFunctionService { @@ -21,7 +21,7 @@ public interface IotThinkModelFunctionService {
21 * @param createReqVO 创建信息 21 * @param createReqVO 创建信息
22 * @return 编号 22 * @return 编号
23 */ 23 */
24 - Long createThinkModelFunction(@Valid IotThinkModelFunctionSaveReqVO createReqVO); 24 + Long createProductThingModel(@Valid IotProductThingModelSaveReqVO createReqVO);
25 25
26 26
27 /** 27 /**
@@ -29,14 +29,14 @@ public interface IotThinkModelFunctionService { @@ -29,14 +29,14 @@ public interface IotThinkModelFunctionService {
29 * 29 *
30 * @param updateReqVO 更新信息 30 * @param updateReqVO 更新信息
31 */ 31 */
32 - void updateThinkModelFunction(@Valid IotThinkModelFunctionSaveReqVO updateReqVO); 32 + void updateProductThingModel(@Valid IotProductThingModelSaveReqVO updateReqVO);
33 33
34 /** 34 /**
35 * 删除产品物模型 35 * 删除产品物模型
36 * 36 *
37 * @param id 编号 37 * @param id 编号
38 */ 38 */
39 - void deleteThinkModelFunction(Long id); 39 + void deleteProductThingModel(Long id);
40 40
41 /** 41 /**
42 * 获得产品物模型 42 * 获得产品物模型
@@ -44,7 +44,7 @@ public interface IotThinkModelFunctionService { @@ -44,7 +44,7 @@ public interface IotThinkModelFunctionService {
44 * @param id 编号 44 * @param id 编号
45 * @return 产品物模型 45 * @return 产品物模型
46 */ 46 */
47 - IotThinkModelFunctionDO getThinkModelFunction(Long id); 47 + IotProductThingModelDO getProductThingModel(Long id);
48 48
49 /** 49 /**
50 * 获得产品物模型列表 50 * 获得产品物模型列表
@@ -52,7 +52,7 @@ public interface IotThinkModelFunctionService { @@ -52,7 +52,7 @@ public interface IotThinkModelFunctionService {
52 * @param productId 产品编号 52 * @param productId 产品编号
53 * @return 产品物模型列表 53 * @return 产品物模型列表
54 */ 54 */
55 - List<IotThinkModelFunctionDO> getThinkModelFunctionListByProductId(Long productId); 55 + List<IotProductThingModelDO> getProductThingModelListByProductId(Long productId);
56 56
57 /** 57 /**
58 * 获得产品物模型分页 58 * 获得产品物模型分页
@@ -60,7 +60,7 @@ public interface IotThinkModelFunctionService { @@ -60,7 +60,7 @@ public interface IotThinkModelFunctionService {
60 * @param pageReqVO 分页查询 60 * @param pageReqVO 分页查询
61 * @return 产品物模型分页 61 * @return 产品物模型分页
62 */ 62 */
63 - PageResult<IotThinkModelFunctionDO> getThinkModelFunctionPage(IotThinkModelFunctionPageReqVO pageReqVO); 63 + PageResult<IotProductThingModelDO> getProductThingModelPage(IotProductThingModelPageReqVO pageReqVO);
64 64
65 /** 65 /**
66 * 创建超级表数据模型 66 * 创建超级表数据模型
@@ -75,5 +75,6 @@ public interface IotThinkModelFunctionService { @@ -75,5 +75,6 @@ public interface IotThinkModelFunctionService {
75 * @param productKey 产品 Key 75 * @param productKey 产品 Key
76 * @return 产品物模型列表 76 * @return 产品物模型列表
77 */ 77 */
78 - List<IotThinkModelFunctionDO> getThinkModelFunctionListByProductKey(String productKey); 78 + List<IotProductThingModelDO> getProductThingModelListByProductKey(String productKey);
  79 +
79 } 80 }
80 \ No newline at end of file 81 \ 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 renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/productthingmodel/IotProductThingModelServiceImpl.java
1 -package cn.iocoder.yudao.module.iot.service.thinkmodelfunction; 1 +package cn.iocoder.yudao.module.iot.service.productthingmodel;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.util.ObjectUtil; 4 import cn.hutool.core.util.ObjectUtil;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; 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;  
17 -import cn.iocoder.yudao.module.iot.convert.thinkmodelfunction.IotThinkModelFunctionConvert; 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.IotProductThingModelPageReqVO;
  14 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelSaveReqVO;
  15 +import cn.iocoder.yudao.module.iot.convert.productthingmodel.IotProductThingModelConvert;
18 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; 16 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
19 -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO;  
20 -import cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction.IotThinkModelFunctionMapper;  
21 -import cn.iocoder.yudao.module.iot.enums.product.IotAccessModeEnum;  
22 -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; 17 +import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
  18 +import cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction.IotProductThingModelMapper;
23 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum; 19 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum;
  20 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
24 import cn.iocoder.yudao.module.iot.service.product.IotProductService; 21 import cn.iocoder.yudao.module.iot.service.product.IotProductService;
25 import cn.iocoder.yudao.module.iot.service.tdengine.IotSuperTableService; 22 import cn.iocoder.yudao.module.iot.service.tdengine.IotSuperTableService;
26 import jakarta.annotation.Resource; 23 import jakarta.annotation.Resource;
@@ -44,10 +41,10 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*; @@ -44,10 +41,10 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
44 @Service 41 @Service
45 @Validated 42 @Validated
46 @Slf4j 43 @Slf4j
47 -public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionService { 44 +public class IotProductThingModelServiceImpl implements IotProductThingModelService {
48 45
49 @Resource 46 @Resource
50 - private IotThinkModelFunctionMapper thinkModelFunctionMapper; 47 + private IotProductThingModelMapper productThingModelMapper;
51 48
52 @Resource 49 @Resource
53 private IotProductService productService; 50 private IotProductService productService;
@@ -56,7 +53,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -56,7 +53,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
56 53
57 @Override 54 @Override
58 @Transactional(rollbackFor = Exception.class) 55 @Transactional(rollbackFor = Exception.class)
59 - public Long createThinkModelFunction(IotThinkModelFunctionSaveReqVO createReqVO) { 56 + public Long createProductThingModel(IotProductThingModelSaveReqVO createReqVO) {
60 // 1. 校验功能标识符在同一产品下是否唯一 57 // 1. 校验功能标识符在同一产品下是否唯一
61 validateIdentifierUnique(createReqVO.getProductId(), createReqVO.getIdentifier()); 58 validateIdentifierUnique(createReqVO.getProductId(), createReqVO.getIdentifier());
62 59
@@ -70,12 +67,12 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -70,12 +67,12 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
70 validateProductStatus(createReqVO.getProductId()); 67 validateProductStatus(createReqVO.getProductId());
71 68
72 // 5. 插入数据库 69 // 5. 插入数据库
73 - IotThinkModelFunctionDO function = IotThinkModelFunctionConvert.INSTANCE.convert(createReqVO);  
74 - thinkModelFunctionMapper.insert(function); 70 + IotProductThingModelDO function = IotProductThingModelConvert.INSTANCE.convert(createReqVO);
  71 + productThingModelMapper.insert(function);
75 72
76 // 6. 如果创建的是属性,需要更新默认的事件和服务 73 // 6. 如果创建的是属性,需要更新默认的事件和服务
77 - if (Objects.equals(createReqVO.getType(), IotProductFunctionTypeEnum.PROPERTY.getType())) {  
78 - createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey()); 74 + if (Objects.equals(createReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
  75 + //createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey());
79 } 76 }
80 return function.getId(); 77 return function.getId();
81 } 78 }
@@ -98,14 +95,14 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -98,14 +95,14 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
98 } 95 }
99 96
100 private void validateNameUnique(Long productId, String name) { 97 private void validateNameUnique(Long productId, String name) {
101 - IotThinkModelFunctionDO function = thinkModelFunctionMapper.selectByProductIdAndName(productId, name); 98 + IotProductThingModelDO function = productThingModelMapper.selectByProductIdAndName(productId, name);
102 if (function != null) { 99 if (function != null) {
103 throw exception(THINK_MODEL_FUNCTION_NAME_EXISTS); 100 throw exception(THINK_MODEL_FUNCTION_NAME_EXISTS);
104 } 101 }
105 } 102 }
106 103
107 private void validateIdentifierUnique(Long productId, String identifier) { 104 private void validateIdentifierUnique(Long productId, String identifier) {
108 - IotThinkModelFunctionDO function = thinkModelFunctionMapper.selectByProductIdAndIdentifier(productId, identifier); 105 + IotProductThingModelDO function = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
109 if (function != null) { 106 if (function != null) {
110 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS); 107 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS);
111 } 108 }
@@ -113,9 +110,9 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -113,9 +110,9 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
113 110
114 @Override 111 @Override
115 @Transactional(rollbackFor = Exception.class) 112 @Transactional(rollbackFor = Exception.class)
116 - public void updateThinkModelFunction(IotThinkModelFunctionSaveReqVO updateReqVO) { 113 + public void updateProductThingModel(IotProductThingModelSaveReqVO updateReqVO) {
117 // 1. 校验功能是否存在 114 // 1. 校验功能是否存在
118 - validateThinkModelFunctionExists(updateReqVO.getId()); 115 + validateproductThingModelMapperExists(updateReqVO.getId());
119 116
120 // 2. 校验功能标识符是否唯一 117 // 2. 校验功能标识符是否唯一
121 validateIdentifierUniqueForUpdate(updateReqVO.getId(), updateReqVO.getProductId(), updateReqVO.getIdentifier()); 118 validateIdentifierUniqueForUpdate(updateReqVO.getId(), updateReqVO.getProductId(), updateReqVO.getIdentifier());
@@ -124,17 +121,17 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -124,17 +121,17 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
124 validateProductStatus(updateReqVO.getProductId()); 121 validateProductStatus(updateReqVO.getProductId());
125 122
126 // 4. 更新数据库 123 // 4. 更新数据库
127 - IotThinkModelFunctionDO thinkModelFunction = IotThinkModelFunctionConvert.INSTANCE.convert(updateReqVO);  
128 - thinkModelFunctionMapper.updateById(thinkModelFunction); 124 + IotProductThingModelDO productThingModelDO = IotProductThingModelConvert.INSTANCE.convert(updateReqVO);
  125 + productThingModelMapper.updateById(productThingModelDO);
129 126
130 // 5. 如果更新的是属性,需要更新默认的事件和服务 127 // 5. 如果更新的是属性,需要更新默认的事件和服务
131 - if (Objects.equals(updateReqVO.getType(), IotProductFunctionTypeEnum.PROPERTY.getType())) { 128 + if (Objects.equals(updateReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
132 createDefaultEventsAndServices(updateReqVO.getProductId(), updateReqVO.getProductKey()); 129 createDefaultEventsAndServices(updateReqVO.getProductId(), updateReqVO.getProductKey());
133 } 130 }
134 } 131 }
135 132
136 private void validateIdentifierUniqueForUpdate(Long id, Long productId, String identifier) { 133 private void validateIdentifierUniqueForUpdate(Long id, Long productId, String identifier) {
137 - IotThinkModelFunctionDO function = thinkModelFunctionMapper.selectByProductIdAndIdentifier(productId, identifier); 134 + IotProductThingModelDO function = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
138 if (function != null && ObjectUtil.notEqual(function.getId(), id)) { 135 if (function != null && ObjectUtil.notEqual(function.getId(), id)) {
139 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS); 136 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS);
140 } 137 }
@@ -142,9 +139,9 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -142,9 +139,9 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
142 139
143 @Override 140 @Override
144 @Transactional(rollbackFor = Exception.class) 141 @Transactional(rollbackFor = Exception.class)
145 - public void deleteThinkModelFunction(Long id) { 142 + public void deleteProductThingModel(Long id) {
146 // 1. 校验功能是否存在 143 // 1. 校验功能是否存在
147 - IotThinkModelFunctionDO functionDO = thinkModelFunctionMapper.selectById(id); 144 + IotProductThingModelDO functionDO = productThingModelMapper.selectById(id);
148 if (functionDO == null) { 145 if (functionDO == null) {
149 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS); 146 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS);
150 } 147 }
@@ -153,10 +150,10 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -153,10 +150,10 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
153 validateProductStatus(functionDO.getProductId()); 150 validateProductStatus(functionDO.getProductId());
154 151
155 // 2. 删除功能 152 // 2. 删除功能
156 - thinkModelFunctionMapper.deleteById(id); 153 + productThingModelMapper.deleteById(id);
157 154
158 // 3. 如果删除的是属性,需要更新默认的事件和服务 155 // 3. 如果删除的是属性,需要更新默认的事件和服务
159 - if (Objects.equals(functionDO.getType(), IotProductFunctionTypeEnum.PROPERTY.getType())) { 156 + if (Objects.equals(functionDO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
160 createDefaultEventsAndServices(functionDO.getProductId(), functionDO.getProductKey()); 157 createDefaultEventsAndServices(functionDO.getProductId(), functionDO.getProductKey());
161 } 158 }
162 } 159 }
@@ -166,25 +163,25 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -166,25 +163,25 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
166 * 163 *
167 * @param id 功能编号 164 * @param id 功能编号
168 */ 165 */
169 - private void validateThinkModelFunctionExists(Long id) {  
170 - if (thinkModelFunctionMapper.selectById(id) == null) { 166 + private void validateproductThingModelMapperExists(Long id) {
  167 + if (productThingModelMapper.selectById(id) == null) {
171 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS); 168 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS);
172 } 169 }
173 } 170 }
174 171
175 @Override 172 @Override
176 - public IotThinkModelFunctionDO getThinkModelFunction(Long id) {  
177 - return thinkModelFunctionMapper.selectById(id); 173 + public IotProductThingModelDO getProductThingModel(Long id) {
  174 + return productThingModelMapper.selectById(id);
178 } 175 }
179 176
180 @Override 177 @Override
181 - public List<IotThinkModelFunctionDO> getThinkModelFunctionListByProductId(Long productId) {  
182 - return thinkModelFunctionMapper.selectListByProductId(productId); 178 + public List<IotProductThingModelDO> getProductThingModelListByProductId(Long productId) {
  179 + return productThingModelMapper.selectListByProductId(productId);
183 } 180 }
184 181
185 @Override 182 @Override
186 - public PageResult<IotThinkModelFunctionDO> getThinkModelFunctionPage(IotThinkModelFunctionPageReqVO pageReqVO) {  
187 - return thinkModelFunctionMapper.selectPage(pageReqVO); 183 + public PageResult<IotProductThingModelDO> getProductThingModelPage(IotProductThingModelPageReqVO pageReqVO) {
  184 + return productThingModelMapper.selectPage(pageReqVO);
188 } 185 }
189 186
190 @Override 187 @Override
@@ -193,99 +190,100 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -193,99 +190,100 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
193 IotProductDO product = productService.getProduct(productId); 190 IotProductDO product = productService.getProduct(productId);
194 191
195 // 2. 查询产品的物模型功能列表 192 // 2. 查询产品的物模型功能列表
196 - List<IotThinkModelFunctionDO> functionList = thinkModelFunctionMapper.selectListByProductId(productId); 193 + List<IotProductThingModelDO> functionList = productThingModelMapper.selectListByProductId(productId);
197 194
198 // 3. 生成 TDengine 的数据模型 195 // 3. 生成 TDengine 的数据模型
199 dbStructureDataService.createSuperTableDataModel(product, functionList); 196 dbStructureDataService.createSuperTableDataModel(product, functionList);
200 } 197 }
201 198
202 @Override 199 @Override
203 - public List<IotThinkModelFunctionDO> getThinkModelFunctionListByProductKey(String productKey) {  
204 - return thinkModelFunctionMapper.selectListByProductKey(productKey); 200 + public List<IotProductThingModelDO> getProductThingModelListByProductKey(String productKey) {
  201 + return productThingModelMapper.selectListByProductKey(productKey);
205 } 202 }
206 203
  204 + // TODO @puhui999: 需要重构
207 /** 205 /**
208 * 创建默认的事件和服务 206 * 创建默认的事件和服务
209 */ 207 */
210 public void createDefaultEventsAndServices(Long productId, String productKey) { 208 public void createDefaultEventsAndServices(Long productId, String productKey) {
211 // 1. 获取当前属性列表 209 // 1. 获取当前属性列表
212 - List<IotThinkModelFunctionDO> propertyList = thinkModelFunctionMapper  
213 - .selectListByProductIdAndType(productId, IotProductFunctionTypeEnum.PROPERTY.getType()); 210 + List<IotProductThingModelDO> propertyList = productThingModelMapper
  211 + .selectListByProductIdAndType(productId, IotProductThingModelTypeEnum.PROPERTY.getType());
214 212
215 // 2. 生成新的事件和服务列表 213 // 2. 生成新的事件和服务列表
216 - List<IotThinkModelFunctionDO> newFunctionList = new ArrayList<>(); 214 + List<IotProductThingModelDO> newFunctionList = new ArrayList<>();
217 // 生成属性上报事件 215 // 生成属性上报事件
218 ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList); 216 ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList);
219 if (propertyPostEvent != null) { 217 if (propertyPostEvent != null) {
220 - IotThinkModelFunctionDO eventFunction = buildEventFunctionDO(productId, productKey, propertyPostEvent); 218 + IotProductThingModelDO eventFunction = buildEventFunctionDO(productId, productKey, propertyPostEvent);
221 newFunctionList.add(eventFunction); 219 newFunctionList.add(eventFunction);
222 } 220 }
223 // 生成属性设置服务 221 // 生成属性设置服务
224 ThingModelService propertySetService = generatePropertySetService(propertyList); 222 ThingModelService propertySetService = generatePropertySetService(propertyList);
225 if (propertySetService != null) { 223 if (propertySetService != null) {
226 - IotThinkModelFunctionDO setServiceFunction = buildServiceFunctionDO(productId, productKey, propertySetService); 224 + IotProductThingModelDO setServiceFunction = buildServiceFunctionDO(productId, productKey, propertySetService);
227 newFunctionList.add(setServiceFunction); 225 newFunctionList.add(setServiceFunction);
228 } 226 }
229 // 生成属性获取服务 227 // 生成属性获取服务
230 ThingModelService propertyGetService = generatePropertyGetService(propertyList); 228 ThingModelService propertyGetService = generatePropertyGetService(propertyList);
231 if (propertyGetService != null) { 229 if (propertyGetService != null) {
232 - IotThinkModelFunctionDO getServiceFunction = buildServiceFunctionDO(productId, productKey, propertyGetService); 230 + IotProductThingModelDO getServiceFunction = buildServiceFunctionDO(productId, productKey, propertyGetService);
233 newFunctionList.add(getServiceFunction); 231 newFunctionList.add(getServiceFunction);
234 } 232 }
235 233
236 // 3. 获取数据库中的默认的旧事件和服务列表 234 // 3. 获取数据库中的默认的旧事件和服务列表
237 - List<IotThinkModelFunctionDO> oldFunctionList = thinkModelFunctionMapper.selectListByProductIdAndIdentifiersAndTypes( 235 + List<IotProductThingModelDO> oldFunctionList = productThingModelMapper.selectListByProductIdAndIdentifiersAndTypes(
238 productId, 236 productId,
239 Arrays.asList("post", "set", "get"), 237 Arrays.asList("post", "set", "get"),
240 - Arrays.asList(IotProductFunctionTypeEnum.EVENT.getType(), IotProductFunctionTypeEnum.SERVICE.getType()) 238 + Arrays.asList(IotProductThingModelTypeEnum.EVENT.getType(), IotProductThingModelTypeEnum.SERVICE.getType())
241 ); 239 );
242 240
243 // 3.1 使用 diffList 方法比较新旧列表 241 // 3.1 使用 diffList 方法比较新旧列表
244 - List<List<IotThinkModelFunctionDO>> diffResult = diffList(oldFunctionList, newFunctionList, 242 + List<List<IotProductThingModelDO>> diffResult = diffList(oldFunctionList, newFunctionList,
245 // 继续使用 identifier 和 type 进行比较:这样可以准确地匹配对应的功能对象。 243 // 继续使用 identifier 和 type 进行比较:这样可以准确地匹配对应的功能对象。
246 (oldFunc, newFunc) -> Objects.equals(oldFunc.getIdentifier(), newFunc.getIdentifier()) 244 (oldFunc, newFunc) -> Objects.equals(oldFunc.getIdentifier(), newFunc.getIdentifier())
247 && Objects.equals(oldFunc.getType(), newFunc.getType())); 245 && 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); // 需要删除的 246 + List<IotProductThingModelDO> createList = diffResult.get(0); // 需要新增的
  247 + List<IotProductThingModelDO> updateList = diffResult.get(1); // 需要更新的
  248 + List<IotProductThingModelDO> deleteList = diffResult.get(2); // 需要删除的
251 249
252 // 3.2 批量执行数据库操作 250 // 3.2 批量执行数据库操作
253 // 新增数据库中的新事件和服务列表 251 // 新增数据库中的新事件和服务列表
254 if (CollUtil.isNotEmpty(createList)) { 252 if (CollUtil.isNotEmpty(createList)) {
255 - thinkModelFunctionMapper.insertBatch(createList); 253 + productThingModelMapper.insertBatch(createList);
256 } 254 }
257 // 更新数据库中的事件和服务列表 255 // 更新数据库中的事件和服务列表
258 if (CollUtil.isNotEmpty(updateList)) { 256 if (CollUtil.isNotEmpty(updateList)) {
259 // 首先,为每个需要更新的对象设置其对应的 ID 257 // 首先,为每个需要更新的对象设置其对应的 ID
260 updateList.forEach(updateFunc -> { 258 updateList.forEach(updateFunc -> {
261 - IotThinkModelFunctionDO oldFunc = findFunctionByIdentifierAndType( 259 + IotProductThingModelDO oldFunc = findFunctionByIdentifierAndType(
262 oldFunctionList, updateFunc.getIdentifier(), updateFunc.getType()); 260 oldFunctionList, updateFunc.getIdentifier(), updateFunc.getType());
263 if (oldFunc != null) { 261 if (oldFunc != null) {
264 updateFunc.setId(oldFunc.getId()); 262 updateFunc.setId(oldFunc.getId());
265 } 263 }
266 }); 264 });
267 // 过滤掉没有设置 ID 的对象 265 // 过滤掉没有设置 ID 的对象
268 - List<IotThinkModelFunctionDO> validUpdateList = updateList.stream() 266 + List<IotProductThingModelDO> validUpdateList = updateList.stream()
269 .filter(func -> func.getId() != null) 267 .filter(func -> func.getId() != null)
270 .collect(Collectors.toList()); 268 .collect(Collectors.toList());
271 // 执行批量更新 269 // 执行批量更新
272 if (CollUtil.isNotEmpty(validUpdateList)) { 270 if (CollUtil.isNotEmpty(validUpdateList)) {
273 - thinkModelFunctionMapper.updateBatch(validUpdateList); 271 + productThingModelMapper.updateBatch(validUpdateList);
274 } 272 }
275 } 273 }
276 274
277 // 删除数据库中的旧事件和服务列表 275 // 删除数据库中的旧事件和服务列表
278 if (CollUtil.isNotEmpty(deleteList)) { 276 if (CollUtil.isNotEmpty(deleteList)) {
279 - Set<Long> idsToDelete = CollectionUtils.convertSet(deleteList, IotThinkModelFunctionDO::getId);  
280 - thinkModelFunctionMapper.deleteByIds(idsToDelete); 277 + Set<Long> idsToDelete = CollectionUtils.convertSet(deleteList, IotProductThingModelDO::getId);
  278 + productThingModelMapper.deleteByIds(idsToDelete);
281 } 279 }
282 } 280 }
283 281
284 /** 282 /**
285 * 根据标识符和类型查找功能对象 283 * 根据标识符和类型查找功能对象
286 */ 284 */
287 - private IotThinkModelFunctionDO findFunctionByIdentifierAndType(List<IotThinkModelFunctionDO> functionList,  
288 - String identifier, Integer type) { 285 + private IotProductThingModelDO findFunctionByIdentifierAndType(List<IotProductThingModelDO> functionList,
  286 + String identifier, Integer type) {
289 return CollUtil.findOne(functionList, func -> 287 return CollUtil.findOne(functionList, func ->
290 Objects.equals(func.getIdentifier(), identifier) && Objects.equals(func.getType(), type)); 288 Objects.equals(func.getIdentifier(), identifier) && Objects.equals(func.getType(), type));
291 } 289 }
@@ -293,35 +291,35 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -293,35 +291,35 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
293 /** 291 /**
294 * 构建事件功能对象 292 * 构建事件功能对象
295 */ 293 */
296 - private IotThinkModelFunctionDO buildEventFunctionDO(Long productId, String productKey, ThingModelEvent event) {  
297 - return new IotThinkModelFunctionDO() 294 + private IotProductThingModelDO buildEventFunctionDO(Long productId, String productKey, ThingModelEvent event) {
  295 + return new IotProductThingModelDO()
298 .setProductId(productId) 296 .setProductId(productId)
299 .setProductKey(productKey) 297 .setProductKey(productKey)
300 .setIdentifier(event.getIdentifier()) 298 .setIdentifier(event.getIdentifier())
301 .setName(event.getName()) 299 .setName(event.getName())
302 .setDescription(event.getDescription()) 300 .setDescription(event.getDescription())
303 - .setType(IotProductFunctionTypeEnum.EVENT.getType()) 301 + .setType(IotProductThingModelTypeEnum.EVENT.getType())
304 .setEvent(event); 302 .setEvent(event);
305 } 303 }
306 304
307 /** 305 /**
308 * 构建服务功能对象 306 * 构建服务功能对象
309 */ 307 */
310 - private IotThinkModelFunctionDO buildServiceFunctionDO(Long productId, String productKey, ThingModelService service) {  
311 - return new IotThinkModelFunctionDO() 308 + private IotProductThingModelDO buildServiceFunctionDO(Long productId, String productKey, ThingModelService service) {
  309 + return new IotProductThingModelDO()
312 .setProductId(productId) 310 .setProductId(productId)
313 .setProductKey(productKey) 311 .setProductKey(productKey)
314 .setIdentifier(service.getIdentifier()) 312 .setIdentifier(service.getIdentifier())
315 .setName(service.getName()) 313 .setName(service.getName())
316 .setDescription(service.getDescription()) 314 .setDescription(service.getDescription())
317 - .setType(IotProductFunctionTypeEnum.SERVICE.getType()) 315 + .setType(IotProductThingModelTypeEnum.SERVICE.getType())
318 .setService(service); 316 .setService(service);
319 } 317 }
320 318
321 /** 319 /**
322 * 生成属性上报事件 320 * 生成属性上报事件
323 */ 321 */
324 - private ThingModelEvent generatePropertyPostEvent(List<IotThinkModelFunctionDO> propertyList) { 322 + private ThingModelEvent generatePropertyPostEvent(List<IotProductThingModelDO> propertyList) {
325 if (CollUtil.isEmpty(propertyList)) { 323 if (CollUtil.isEmpty(propertyList)) {
326 return null; 324 return null;
327 } 325 }
@@ -335,12 +333,13 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -335,12 +333,13 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
335 333
336 // 将属性列表转换为事件的输出参数 334 // 将属性列表转换为事件的输出参数
337 List<ThingModelArgument> outputData = new ArrayList<>(); 335 List<ThingModelArgument> outputData = new ArrayList<>();
338 - for (IotThinkModelFunctionDO functionDO : propertyList) { 336 + // TODO @puhui999: 需要重构
  337 + for (IotProductThingModelDO functionDO : propertyList) {
339 ThingModelProperty property = functionDO.getProperty(); 338 ThingModelProperty property = functionDO.getProperty();
340 ThingModelArgument arg = new ThingModelArgument() 339 ThingModelArgument arg = new ThingModelArgument()
341 .setIdentifier(property.getIdentifier()) 340 .setIdentifier(property.getIdentifier())
342 .setName(property.getName()) 341 .setName(property.getName())
343 - .setDataType(property.getDataType()) 342 + //.setDataType(property.getDataType())
344 .setDescription(property.getDescription()) 343 .setDescription(property.getDescription())
345 .setDirection("output"); // 设置为输出参数 344 .setDirection("output"); // 设置为输出参数
346 outputData.add(arg); 345 outputData.add(arg);
@@ -352,23 +351,24 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -352,23 +351,24 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
352 /** 351 /**
353 * 生成属性设置服务 352 * 生成属性设置服务
354 */ 353 */
355 - private ThingModelService generatePropertySetService(List<IotThinkModelFunctionDO> propertyList) { 354 + private ThingModelService generatePropertySetService(List<IotProductThingModelDO> propertyList) {
356 if (propertyList == null || propertyList.isEmpty()) { 355 if (propertyList == null || propertyList.isEmpty()) {
357 return null; 356 return null;
358 } 357 }
359 358
360 List<ThingModelArgument> inputData = new ArrayList<>(); 359 List<ThingModelArgument> inputData = new ArrayList<>();
361 - for (IotThinkModelFunctionDO functionDO : propertyList) { 360 + // TODO @puhui999: 需要重构
  361 + for (IotProductThingModelDO functionDO : propertyList) {
362 ThingModelProperty property = functionDO.getProperty(); 362 ThingModelProperty property = functionDO.getProperty();
363 - if (IotAccessModeEnum.WRITE.getMode().equals(property.getAccessMode()) || IotAccessModeEnum.READ_WRITE.getMode().equals(property.getAccessMode())) {  
364 - ThingModelArgument arg = new ThingModelArgument()  
365 - .setIdentifier(property.getIdentifier())  
366 - .setName(property.getName())  
367 - .setDataType(property.getDataType())  
368 - .setDescription(property.getDescription())  
369 - .setDirection("input"); // 设置为输入参数  
370 - inputData.add(arg);  
371 - } 363 + //if (IotProductThingModelAccessModeEnum.WRITE.getMode().equals(property.getAccessMode()) || IotProductThingModelAccessModeEnum.READ_WRITE.getMode().equals(property.getAccessMode())) {
  364 + // ThingModelArgument arg = new ThingModelArgument()
  365 + // .setIdentifier(property.getIdentifier())
  366 + // .setName(property.getName())
  367 + // .setDataType(property.getDataType())
  368 + // .setDescription(property.getDescription())
  369 + // .setDirection("input"); // 设置为输入参数
  370 + // inputData.add(arg);
  371 + //}
372 } 372 }
373 if (inputData.isEmpty()) { 373 if (inputData.isEmpty()) {
374 // 如果没有可写属性,不生成属性设置服务 374 // 如果没有可写属性,不生成属性设置服务
@@ -390,24 +390,24 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -390,24 +390,24 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
390 /** 390 /**
391 * 生成属性获取服务 391 * 生成属性获取服务
392 */ 392 */
393 - private ThingModelService generatePropertyGetService(List<IotThinkModelFunctionDO> propertyList) { 393 + private ThingModelService generatePropertyGetService(List<IotProductThingModelDO> propertyList) {
394 if (propertyList == null || propertyList.isEmpty()) { 394 if (propertyList == null || propertyList.isEmpty()) {
395 return null; 395 return null;
396 } 396 }
397 - 397 + // TODO @puhui999: 需要重构
398 List<ThingModelArgument> outputData = new ArrayList<>(); 398 List<ThingModelArgument> outputData = new ArrayList<>();
399 - for (IotThinkModelFunctionDO functionDO : propertyList) { 399 + for (IotProductThingModelDO functionDO : propertyList) {
400 ThingModelProperty property = functionDO.getProperty(); 400 ThingModelProperty property = functionDO.getProperty();
401 - if (ObjectUtils.equalsAny(property.getAccessMode(),  
402 - IotAccessModeEnum.READ.getMode(), IotAccessModeEnum.READ_WRITE.getMode())) {  
403 - ThingModelArgument arg = new ThingModelArgument()  
404 - .setIdentifier(property.getIdentifier())  
405 - .setName(property.getName())  
406 - .setDataType(property.getDataType())  
407 - .setDescription(property.getDescription())  
408 - .setDirection("output"); // 设置为输出参数  
409 - outputData.add(arg);  
410 - } 401 + //if (ObjectUtils.equalsAny(property.getAccessMode(),
  402 + // IotProductThingModelAccessModeEnum.READ.getMode(), IotProductThingModelAccessModeEnum.READ_WRITE.getMode())) {
  403 + // ThingModelArgument arg = new ThingModelArgument()
  404 + // .setIdentifier(property.getIdentifier())
  405 + // .setName(property.getName())
  406 + // .setDataType(property.getDataType())
  407 + // .setDescription(property.getDescription())
  408 + // .setDirection("output"); // 设置为输出参数
  409 + // outputData.add(arg);
  410 + //}
411 } 411 }
412 if (outputData.isEmpty()) { 412 if (outputData.isEmpty()) {
413 // 如果没有可读属性,不生成属性获取服务 413 // 如果没有可读属性,不生成属性获取服务
@@ -429,13 +429,13 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -429,13 +429,13 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
429 .setDirection("input"); // 设置为输入参数 429 .setDirection("input"); // 设置为输入参数
430 430
431 // 创建数组类型,元素类型为文本类型(字符串) 431 // 创建数组类型,元素类型为文本类型(字符串)
432 - ThingModelArrayType arrayType = new ThingModelArrayType();  
433 - arrayType.setType("array");  
434 - ThingModelArraySpecs arraySpecs = new ThingModelArraySpecs();  
435 - ThingModelTextType textType = new ThingModelTextType();  
436 - textType.setType("text");  
437 - arraySpecs.setItem(textType);  
438 - arrayType.setSpecs(arraySpecs); 432 + ThingModelArrayDataSpecs arrayType = new ThingModelArrayDataSpecs();
  433 + arrayType.setDataType("array");
  434 + //ThingModelArraySpecs arraySpecs = new ThingModelArraySpecs();
  435 + ThingModelDateOrTextDataSpecs textType = new ThingModelDateOrTextDataSpecs();
  436 + textType.setDataType("text");
  437 + //arraySpecs.setItem(textType);
  438 + //arrayType.setSpecs(arraySpecs);
439 inputArg.setDataType(arrayType); 439 inputArg.setDataType(arrayType);
440 440
441 service.setInputData(Collections.singletonList(inputArg)); 441 service.setInputData(Collections.singletonList(inputArg));
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,7 +2,7 @@ package cn.iocoder.yudao.module.iot.service.tdengine;
2 2
3 3
4 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; 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 import java.util.List; 7 import java.util.List;
8 8
@@ -14,5 +14,5 @@ public interface IotSuperTableService { @@ -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 \ No newline at end of file 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,16 +2,15 @@ package cn.iocoder.yudao.module.iot.service.tdengine; @@ -2,16 +2,15 @@ package cn.iocoder.yudao.module.iot.service.tdengine;
2 2
3 import cn.hutool.core.bean.BeanUtil; 3 import cn.hutool.core.bean.BeanUtil;
4 import cn.hutool.core.collection.CollUtil; 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 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; 7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
8 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser; 8 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser;
9 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO; 9 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO;
10 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO; 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 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper; 12 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper;
13 -import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper;  
14 -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; 13 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
15 import jakarta.annotation.Resource; 14 import jakarta.annotation.Resource;
16 import lombok.extern.slf4j.Slf4j; 15 import lombok.extern.slf4j.Slf4j;
17 import org.springframework.beans.factory.annotation.Value; 16 import org.springframework.beans.factory.annotation.Value;
@@ -34,7 +33,7 @@ public class IotSuperTableServiceImpl implements IotSuperTableService { @@ -34,7 +33,7 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
34 private String url; 33 private String url;
35 34
36 @Override 35 @Override
37 - public void createSuperTableDataModel(IotProductDO product, List<IotThinkModelFunctionDO> functionList) { 36 + public void createSuperTableDataModel(IotProductDO product, List<IotProductThingModelDO> functionList) {
38 ThingModelRespVO thingModel = buildThingModel(product, functionList); 37 ThingModelRespVO thingModel = buildThingModel(product, functionList);
39 38
40 if (thingModel.getModel() == null || CollUtil.isEmpty(thingModel.getModel().getProperties())) { 39 if (thingModel.getModel() == null || CollUtil.isEmpty(thingModel.getModel().getProperties())) {
@@ -211,14 +210,14 @@ public class IotSuperTableServiceImpl implements IotSuperTableService { @@ -211,14 +210,14 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
211 /** 210 /**
212 * 构建物模型 211 * 构建物模型
213 */ 212 */
214 - private ThingModelRespVO buildThingModel(IotProductDO product, List<IotThinkModelFunctionDO> functionList) { 213 + private ThingModelRespVO buildThingModel(IotProductDO product, List<IotProductThingModelDO> functionList) {
215 ThingModelRespVO thingModel = new ThingModelRespVO(); 214 ThingModelRespVO thingModel = new ThingModelRespVO();
216 thingModel.setId(product.getId()); 215 thingModel.setId(product.getId());
217 thingModel.setProductKey(product.getProductKey()); 216 thingModel.setProductKey(product.getProductKey());
218 217
219 List<ThingModelProperty> properties = functionList.stream() 218 List<ThingModelProperty> properties = functionList.stream()
220 - .filter(function -> IotProductFunctionTypeEnum.PROPERTY.equals(  
221 - IotProductFunctionTypeEnum.valueOfType(function.getType()))) 219 + .filter(function -> IotProductThingModelTypeEnum.PROPERTY.equals(
  220 + IotProductThingModelTypeEnum.valueOfType(function.getType())))
222 .map(this::buildThingModelProperty) 221 .map(this::buildThingModelProperty)
223 .collect(Collectors.toList()); 222 .collect(Collectors.toList());
224 223
@@ -232,7 +231,7 @@ public class IotSuperTableServiceImpl implements IotSuperTableService { @@ -232,7 +231,7 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
232 /** 231 /**
233 * 构建物模型属性 232 * 构建物模型属性
234 */ 233 */
235 - private ThingModelProperty buildThingModelProperty(IotThinkModelFunctionDO function) { 234 + private ThingModelProperty buildThingModelProperty(IotProductThingModelDO function) {
236 ThingModelProperty property = BeanUtil.copyProperties(function, ThingModelProperty.class); 235 ThingModelProperty property = BeanUtil.copyProperties(function, ThingModelProperty.class);
237 property.setDataType(function.getProperty().getDataType()); 236 property.setDataType(function.getProperty().getDataType());
238 return property; 237 return property;
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageServiceImpl.java
@@ -11,15 +11,15 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser; @@ -11,15 +11,15 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser;
11 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO; 11 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO;
12 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO; 12 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO;
13 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage; 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 import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; 15 import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO;
16 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper; 16 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper;
17 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; 17 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper;
18 import cn.iocoder.yudao.module.iot.enums.IotConstants; 18 import cn.iocoder.yudao.module.iot.enums.IotConstants;
19 import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStatusEnum; 19 import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStatusEnum;
20 -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; 20 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
21 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; 21 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
22 -import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService; 22 +import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
23 import jakarta.annotation.Resource; 23 import jakarta.annotation.Resource;
24 import lombok.extern.slf4j.Slf4j; 24 import lombok.extern.slf4j.Slf4j;
25 import org.springframework.beans.factory.annotation.Value; 25 import org.springframework.beans.factory.annotation.Value;
@@ -47,7 +47,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ @@ -47,7 +47,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
47 private String url; 47 private String url;
48 48
49 @Resource 49 @Resource
50 - private IotThinkModelFunctionService iotThinkModelFunctionService; 50 + private IotProductThingModelService iotProductThingModelService;
51 @Resource 51 @Resource
52 private IotDeviceService iotDeviceService; 52 private IotDeviceService iotDeviceService;
53 @Resource 53 @Resource
@@ -71,7 +71,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ @@ -71,7 +71,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
71 71
72 // 2. 获取设备属性并进行物模型校验,过滤非物模型属性 72 // 2. 获取设备属性并进行物模型校验,过滤非物模型属性
73 Map<String, Object> params = thingModelMessage.dataToMap(); 73 Map<String, Object> params = thingModelMessage.dataToMap();
74 - List<IotThinkModelFunctionDO> functionList = getValidFunctionList(thingModelMessage.getProductKey()); 74 + List<IotProductThingModelDO> functionList = getValidFunctionList(thingModelMessage.getProductKey());
75 if (functionList.isEmpty()) { 75 if (functionList.isEmpty()) {
76 return; 76 return;
77 } 77 }
@@ -90,21 +90,21 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ @@ -90,21 +90,21 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
90 .build()); 90 .build());
91 } 91 }
92 92
93 - private List<IotThinkModelFunctionDO> getValidFunctionList(String productKey) {  
94 - return iotThinkModelFunctionService  
95 - .getThinkModelFunctionListByProductKey(productKey) 93 + private List<IotProductThingModelDO> getValidFunctionList(String productKey) {
  94 + return iotProductThingModelService
  95 + .getProductThingModelListByProductKey(productKey)
96 .stream() 96 .stream()
97 - .filter(function -> IotProductFunctionTypeEnum.PROPERTY.getType().equals(function.getType())) 97 + .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(function.getType()))
98 .toList(); 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 // 1. 获取属性标识符集合 102 // 1. 获取属性标识符集合
103 - Set<String> propertyIdentifiers = CollectionUtils.convertSet(functionList, IotThinkModelFunctionDO::getIdentifier); 103 + Set<String> propertyIdentifiers = CollectionUtils.convertSet(functionList, IotProductThingModelDO::getIdentifier);
104 104
105 // 2. 构建属性标识符和属性的映射 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 // 3. 过滤并收集有效的属性字段 109 // 3. 过滤并收集有效的属性字段
110 List<TdFieldDO> schemaFieldValues = new ArrayList<>(); 110 List<TdFieldDO> schemaFieldValues = new ArrayList<>();
@@ -124,21 +124,22 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ @@ -124,21 +124,22 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
124 * 缓存设备属性 124 * 缓存设备属性
125 * 125 *
126 * @param device 设备信息 126 * @param device 设备信息
127 - * @param iotThinkModelFunctionDO 物模型属性 127 + * @param iotProductThingModelDO 物模型属性
128 * @param val 属性值 128 * @param val 属性值
129 * @param time 时间 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 IotDeviceDataDO deviceData = IotDeviceDataDO.builder() 133 IotDeviceDataDO deviceData = IotDeviceDataDO.builder()
133 .productKey(device.getProductKey()) 134 .productKey(device.getProductKey())
134 .deviceName(device.getDeviceName()) 135 .deviceName(device.getDeviceName())
135 - .identifier(iotThinkModelFunctionDO.getIdentifier()) 136 + .identifier(iotProductThingModelDO.getIdentifier())
136 .value(val != null ? val.toString() : null) 137 .value(val != null ? val.toString() : null)
137 .updateTime(DateUtil.toLocalDateTime(new Date(time))) 138 .updateTime(DateUtil.toLocalDateTime(new Date(time)))
138 .deviceId(device.getId()) 139 .deviceId(device.getId())
139 - .thinkModelFunctionId(iotThinkModelFunctionDO.getId())  
140 - .name(iotThinkModelFunctionDO.getName())  
141 - .dataType(iotThinkModelFunctionDO.getProperty().getDataType().getType()) 140 + .thinkModelFunctionId(iotProductThingModelDO.getId())
  141 + .name(iotProductThingModelDO.getName())
  142 + //.dataType(iotProductThingModelDO.getProperty().getDataType().getDataType())
142 .build(); 143 .build();
143 deviceDataRedisDAO.set(deviceData); 144 deviceDataRedisDAO.set(deviceData);
144 } 145 }