Commit cb3275b4055b5aeb6e486b940392e3c21afa27e6

Authored by 芋道源码
Committed by Gitee
2 parents 91b817a9 0352dda4

!1164 【代码优化】IOT: 产品物模型代码评审问题优化

Merge pull request !1164 from puhui999/iot
Showing 34 changed files with 449 additions and 454 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelAccessModeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thinkmodel/IotProductThinkModelAccessModeEnum.java
1   -package cn.iocoder.yudao.module.iot.enums.thingmodel;
  1 +package cn.iocoder.yudao.module.iot.enums.thinkmodel;
2 2  
3 3 import lombok.AllArgsConstructor;
4 4 import lombok.Getter;
... ... @@ -10,7 +10,7 @@ import lombok.Getter;
10 10 */
11 11 @AllArgsConstructor
12 12 @Getter
13   -public enum IotProductThingModelAccessModeEnum {
  13 +public enum IotProductThinkModelAccessModeEnum {
14 14  
15 15 READ_ONLY("r"),
16 16 READ_WRITE("rw");
... ...
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelTypeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thinkmodel/IotProductThinkModelTypeEnum.java
1   -package cn.iocoder.yudao.module.iot.enums.thingmodel;
  1 +package cn.iocoder.yudao.module.iot.enums.thinkmodel;
2 2  
3 3 import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
4 4 import lombok.AllArgsConstructor;
... ... @@ -14,13 +14,13 @@ import java.util.Arrays;
14 14 */
15 15 @AllArgsConstructor
16 16 @Getter
17   -public enum IotProductThingModelTypeEnum implements IntArrayValuable {
  17 +public enum IotProductThinkModelTypeEnum implements IntArrayValuable {
18 18  
19 19 PROPERTY(1, "属性"),
20 20 SERVICE(2, "服务"),
21 21 EVENT(3, "事件");
22 22  
23   - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductThingModelTypeEnum::getType).toArray();
  23 + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductThinkModelTypeEnum::getType).toArray();
24 24  
25 25 /**
26 26 * 类型
... ... @@ -31,8 +31,8 @@ public enum IotProductThingModelTypeEnum implements IntArrayValuable {
31 31 */
32 32 private final String description;
33 33  
34   - public static IotProductThingModelTypeEnum valueOfType(Integer type) {
35   - for (IotProductThingModelTypeEnum value : values()) {
  34 + public static IotProductThinkModelTypeEnum valueOfType(Integer type) {
  35 + for (IotProductThinkModelTypeEnum value : values()) {
36 36 if (value.getType().equals(type)) {
37 37 return value;
38 38 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/IotProductThingModelController.http renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/IotProductThingModelController.http
1   -### 请求 /iot/product-thing-model/create 接口 => 成功
2   -POST {{baseUrl}}/iot/product-thing-model/create
  1 +### 请求 /iot/product-think-model/create 接口 => 成功
  2 +POST {{baseUrl}}/iot/product-think-model/create
3 3 Content-Type: application/json
4 4 tenant-id: {{adminTenentId}}
5 5 Authorization: Bearer {{token}}
... ... @@ -30,8 +30,8 @@ Authorization: Bearer {{token}}
30 30 }
31 31 }
32 32  
33   -### 请求 /iot/product-thing-model/create 接口 => 成功
34   -POST {{baseUrl}}/iot/product-thing-model/create
  33 +### 请求 /iot/product-think-model/create 接口 => 成功
  34 +POST {{baseUrl}}/iot/product-think-model/create
35 35 Content-Type: application/json
36 36 tenant-id: {{adminTenentId}}
37 37 Authorization: Bearer {{token}}
... ... @@ -65,8 +65,8 @@ Authorization: Bearer {{token}}
65 65 }
66 66 }
67 67  
68   -### 请求 /iot/product-thing-model/create 接口 => 成功
69   -POST {{baseUrl}}/iot/product-thing-model/create
  68 +### 请求 /iot/product-think-model/create 接口 => 成功
  69 +POST {{baseUrl}}/iot/product-think-model/create
70 70 Content-Type: application/json
71 71 tenant-id: {{adminTenentId}}
72 72 Authorization: Bearer {{token}}
... ... @@ -134,8 +134,8 @@ Authorization: Bearer {{token}}
134 134 }
135 135 }
136 136  
137   -### 请求 /iot/product-thing-model/update 接口 => 成功
138   -PUT {{baseUrl}}/iot/product-thing-model/update
  137 +### 请求 /iot/product-think-model/update 接口 => 成功
  138 +PUT {{baseUrl}}/iot/product-think-model/update
139 139 Content-Type: application/json
140 140 tenant-id: {{adminTenentId}}
141 141 Authorization: Bearer {{token}}
... ... @@ -170,18 +170,18 @@ Authorization: Bearer {{token}}
170 170 }
171 171 }
172 172  
173   -### 请求 /iot/product-thing-model/delete 接口 => 成功
174   -DELETE {{baseUrl}}/iot/product-thing-model/delete?id=36
  173 +### 请求 /iot/product-think-model/delete 接口 => 成功
  174 +DELETE {{baseUrl}}/iot/product-think-model/delete?id=36
175 175 tenant-id: {{adminTenentId}}
176 176 Authorization: Bearer {{token}}
177 177  
178   -### 请求 /iot/product-thing-model/get 接口 => 成功
179   -GET {{baseUrl}}/iot/product-thing-model/get?id=40
  178 +### 请求 /iot/product-think-model/get 接口 => 成功
  179 +GET {{baseUrl}}/iot/product-think-model/get?id=40
180 180 tenant-id: {{adminTenentId}}
181 181 Authorization: Bearer {{token}}
182 182  
183 183  
184   -### 请求 /iot/product-thing-model/list-by-product-id 接口 => 成功
185   -GET {{baseUrl}}/iot/product-thing-model/list-by-product-id?productId=1001
  184 +### 请求 /iot/product-think-model/list-by-product-id 接口 => 成功
  185 +GET {{baseUrl}}/iot/product-think-model/list-by-product-id?productId=1001
186 186 tenant-id: {{adminTenentId}}
187 187 Authorization: Bearer {{token}}
188 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 renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/IotProductThinkModelController.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 5 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
6   -import cn.iocoder.yudao.module.iot.controller.admin.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;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo.IotProductThinkModelPageReqVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo.IotProductThinkModelRespVO;
  8 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo.IotProductThinkModelSaveReqVO;
  9 +import cn.iocoder.yudao.module.iot.convert.thinkmodel.IotProductThinkModelConvert;
  10 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
  11 +import cn.iocoder.yudao.module.iot.service.thinkmodel.IotProductThinkModelService;
12 12 import io.swagger.v3.oas.annotations.Operation;
13 13 import io.swagger.v3.oas.annotations.Parameter;
14 14 import io.swagger.v3.oas.annotations.tags.Tag;
... ... @@ -24,61 +24,61 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
24 24  
25 25 @Tag(name = "管理后台 - IoT 产品物模型")
26 26 @RestController
27   -@RequestMapping("/iot/product-thing-model")
  27 +@RequestMapping("/iot/product-think-model")
28 28 @Validated
29   -public class IotProductThingModelController {
  29 +public class IotProductThinkModelController {
30 30  
31 31 @Resource
32   - private IotProductThingModelService thinkModelFunctionService;
  32 + private IotProductThinkModelService thinkModelFunctionService;
33 33  
34 34 @PostMapping("/create")
35 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));
  36 + @PreAuthorize("@ss.hasPermission('iot:product-think-model:create')")
  37 + public CommonResult<Long> createProductThinkModel(@Valid @RequestBody IotProductThinkModelSaveReqVO createReqVO) {
  38 + return success(thinkModelFunctionService.createProductThinkModel(createReqVO));
39 39 }
40 40  
41 41 @PutMapping("/update")
42 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);
  43 + @PreAuthorize("@ss.hasPermission('iot:product-think-model:update')")
  44 + public CommonResult<Boolean> updateProductThinkModel(@Valid @RequestBody IotProductThinkModelSaveReqVO updateReqVO) {
  45 + thinkModelFunctionService.updateProductThinkModel(updateReqVO);
46 46 return success(true);
47 47 }
48 48  
49 49 @DeleteMapping("/delete")
50 50 @Operation(summary = "删除产品物模型")
51 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);
  52 + @PreAuthorize("@ss.hasPermission('iot:product-think-model:delete')")
  53 + public CommonResult<Boolean> deleteProductThinkModel(@RequestParam("id") Long id) {
  54 + thinkModelFunctionService.deleteProductThinkModel(id);
55 55 return success(true);
56 56 }
57 57  
58 58 @GetMapping("/get")
59 59 @Operation(summary = "获得产品物模型")
60 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));
  61 + @PreAuthorize("@ss.hasPermission('iot:product-think-model:query')")
  62 + public CommonResult<IotProductThinkModelRespVO> getProductThinkModel(@RequestParam("id") Long id) {
  63 + IotProductThinkModelDO function = thinkModelFunctionService.getProductThinkModel(id);
  64 + return success(IotProductThinkModelConvert.INSTANCE.convert(function));
65 65 }
66 66  
67 67 @GetMapping("/list-by-product-id")
68 68 @Operation(summary = "获得产品物模型")
69 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));
  70 + @PreAuthorize("@ss.hasPermission('iot:product-think-model:query')")
  71 + public CommonResult<List<IotProductThinkModelRespVO>> getProductThinkModelListByProductId(@RequestParam("productId") Long productId) {
  72 + List<IotProductThinkModelDO> list = thinkModelFunctionService.getProductThinkModelListByProductId(productId);
  73 + return success(IotProductThinkModelConvert.INSTANCE.convertList(list));
74 74 }
75 75  
76 76 @GetMapping("/page")
77 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));
  78 + @PreAuthorize("@ss.hasPermission('iot:product-think-model:query')")
  79 + public CommonResult<PageResult<IotProductThinkModelRespVO>> getProductThinkModelPage(@Valid IotProductThinkModelPageReqVO pageReqVO) {
  80 + PageResult<IotProductThinkModelDO> pageResult = thinkModelFunctionService.getProductThinkModelPage(pageReqVO);
  81 + return success(BeanUtils.toBean(pageResult, IotProductThinkModelRespVO.class));
82 82 }
83 83  
84 84 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/ThingModelEvent.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/ThinkModelEvent.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model;
2 2  
3   -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArgument;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType.ThinkModelArgument;
4 4 import lombok.Data;
5 5 import java.util.List;
6 6  
7 7 @Data
8   -public class ThingModelEvent {
  8 +public class ThinkModelEvent {
9 9  
10 10 /**
11 11 * 事件标识符
... ... @@ -26,7 +26,7 @@ public class ThingModelEvent {
26 26 * "info"、"alert"、"error"
27 27 */
28 28 private String type;
29   - private List<ThingModelArgument> outputData;
  29 + private List<ThinkModelArgument> outputData;
30 30 private String method;
31 31  
32 32 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/ThingModelProperty.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/ThinkModelProperty.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model;
2 2  
3   -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelDataSpecs;
4   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelAccessModeEnum;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType.ThinkModelDataSpecs;
  4 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelAccessModeEnum;
5 5 import lombok.Data;
6 6  
7 7 import java.util.List;
... ... @@ -14,7 +14,7 @@ import java.util.List;
14 14 * @author HUIHUI
15 15 */
16 16 @Data
17   -public class ThingModelProperty {
  17 +public class ThinkModelProperty {
18 18  
19 19 /**
20 20 * 属性标识符
... ... @@ -30,7 +30,7 @@ public class ThingModelProperty {
30 30 private String description;
31 31 /**
32 32 * 云端可以对该属性进行的操作类型
33   - * 关联枚举 {@link IotProductThingModelAccessModeEnum}
  33 + * 关联枚举 {@link IotProductThinkModelAccessModeEnum}
34 34 */
35 35 private String accessMode;
36 36 /**
... ... @@ -47,10 +47,10 @@ public class ThingModelProperty {
47 47 /**
48 48 * 数据类型(dataType)为非列表型(int、float、double、text、date、array)的数据规范存储在 dataSpecs 中
49 49 */
50   - private ThingModelDataSpecs dataSpecs;
  50 + private ThinkModelDataSpecs dataSpecs;
51 51 /**
52 52 * 数据类型(dataType)为列表型(enum、bool、struct)的数据规范存储在 dataSpecsList 中
53 53 */
54   - private List<ThingModelDataSpecs> dataSpecsList;
  54 + private List<ThinkModelDataSpecs> dataSpecsList;
55 55  
56 56 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/ThingModelRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/ThinkModelRespVO.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model;
2 2  
3 3 import lombok.*;
4 4  
... ... @@ -9,7 +9,7 @@ import java.util.List;
9 9 @NoArgsConstructor
10 10 @AllArgsConstructor
11 11 @ToString
12   -public class ThingModelRespVO {
  12 +public class ThinkModelRespVO {
13 13  
14 14 /**
15 15 * 产品编号
... ... @@ -35,16 +35,16 @@ public class ThingModelRespVO {
35 35 /**
36 36 * 属性列表
37 37 */
38   - private List<ThingModelProperty> properties;
  38 + private List<ThinkModelProperty> properties;
39 39  
40 40 /**
41 41 * 服务列表
42 42 */
43   - private List<ThingModelService> services;
  43 + private List<ThinkModelService> services;
44 44  
45 45 /**
46 46 * 事件列表
47 47 */
48   - private List<ThingModelEvent> events;
  48 + private List<ThinkModelEvent> events;
49 49 }
50 50 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/ThingModelService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/ThinkModelService.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model;
2 2  
3   -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArgument;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType.ThinkModelArgument;
4 4 import lombok.Data;
5 5 import java.util.List;
6 6  
7 7 @Data
8   -public class ThingModelService {
  8 +public class ThinkModelService {
9 9  
10 10 /**
11 11 * 服务标识符
... ... @@ -26,8 +26,8 @@ public class ThingModelService {
26 26 * "sync"、"async"
27 27 */
28 28 private String callType;
29   - private List<ThingModelArgument> inputData;
30   - private List<ThingModelArgument> outputData;
  29 + private List<ThinkModelArgument> inputData;
  30 + private List<ThinkModelArgument> outputData;
31 31 private String method;
32 32  
33 33 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelArgument.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/dataType/ThinkModelArgument.java
1   -// TODO @puhui999:productthingmodel 是不是不要这层包了
2   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType;
3 2  
  3 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelProperty;
4 4 import lombok.Data;
5 5  
6 6 @Data
7   -public class ThingModelArgument {
  7 +public class ThinkModelArgument {
8 8  
9 9 private String identifier;
10 10 private String name;
11   - private ThingModelDataSpecs dataType;
  11 + /**
  12 + * 物模型中的属性
  13 + */
  14 + private ThinkModelProperty property;
12 15 /**
13 16 * 用于区分输入或输出参数,"input" 或 "output"
14 17 */
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelArrayDataSpecs.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/dataType/ThinkModelArrayDataSpecs.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType;
2 2  
3 3 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 4 import lombok.Data;
... ... @@ -14,7 +14,7 @@ import java.util.List;
14 14 @Data
15 15 @EqualsAndHashCode(callSuper = true)
16 16 @JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
17   -public class ThingModelArrayDataSpecs extends ThingModelDataSpecs {
  17 +public class ThinkModelArrayDataSpecs extends ThinkModelDataSpecs {
18 18  
19 19 /**
20 20 * 数组中的元素个数。
... ... @@ -28,7 +28,7 @@ public class ThingModelArrayDataSpecs extends ThingModelDataSpecs {
28 28 * 数据类型(childDataType)为列表型 struct 的数据规范存储在 dataSpecsList 中。
29 29 * 此时 struct 取值范围为:int、float、double、text、date、enum、bool
30 30 */
31   - private List<ThingModelDataSpecs> dataSpecsList;
  31 + private List<ThinkModelDataSpecs> dataSpecsList;
32 32  
33 33 }
34 34  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelBoolOrEnumDataSpecs.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/dataType/ThinkModelBoolOrEnumDataSpecs.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType;
2 2  
3 3 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 4 import lombok.Data;
... ... @@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
14 14 @Data
15 15 @EqualsAndHashCode(callSuper = true)
16 16 @JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
17   -public class ThingModelBoolOrEnumDataSpecs extends ThingModelDataSpecs {
  17 +public class ThinkModelBoolOrEnumDataSpecs extends ThinkModelDataSpecs {
18 18  
19 19 /**
20 20 * 枚举项的名称。
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelDataSpecs.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/dataType/ThinkModelDataSpecs.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType;
2 2  
3 3 import com.fasterxml.jackson.annotation.JsonSubTypes;
4 4 import com.fasterxml.jackson.annotation.JsonTypeInfo;
5 5 import lombok.Data;
6 6  
7 7 /**
8   - * 抽象类 ThingModelDataSpecs
  8 + * 抽象类 ThinkModelDataSpecs
9 9 *
10 10 * 用于表示物模型数据的通用类型,根据具体的 "dataType" 字段动态映射到对应的子类。
11 11 * 提供多态支持,适用于不同类型的数据结构序列化和反序列化场景。
... ... @@ -15,17 +15,17 @@ import lombok.Data;
15 15 @Data
16 16 @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "dataType", visible = true)
17 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")
  18 + @JsonSubTypes.Type(value = ThinkModelNumericDataSpec.class, name = "int"),
  19 + @JsonSubTypes.Type(value = ThinkModelNumericDataSpec.class, name = "float"),
  20 + @JsonSubTypes.Type(value = ThinkModelNumericDataSpec.class, name = "double"),
  21 + @JsonSubTypes.Type(value = ThinkModelDateOrTextDataSpecs.class, name = "text"),
  22 + @JsonSubTypes.Type(value = ThinkModelDateOrTextDataSpecs.class, name = "date"),
  23 + @JsonSubTypes.Type(value = ThinkModelBoolOrEnumDataSpecs.class, name = "bool"),
  24 + @JsonSubTypes.Type(value = ThinkModelBoolOrEnumDataSpecs.class, name = "enum"),
  25 + @JsonSubTypes.Type(value = ThinkModelArrayDataSpecs.class, name = "array"),
  26 + @JsonSubTypes.Type(value = ThinkModelStructDataSpecs.class, name = "struct")
27 27 })
28   -public abstract class ThingModelDataSpecs {
  28 +public abstract class ThinkModelDataSpecs {
29 29  
30 30 /**
31 31 * 数据类型
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelDateOrTextDataSpecs.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/dataType/ThinkModelDateOrTextDataSpecs.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType;
2 2  
3 3 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 4 import lombok.Data;
... ... @@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
14 14 @Data
15 15 @EqualsAndHashCode(callSuper = true)
16 16 @JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
17   -public class ThingModelDateOrTextDataSpecs extends ThingModelDataSpecs {
  17 +public class ThinkModelDateOrTextDataSpecs extends ThinkModelDataSpecs {
18 18  
19 19 /**
20 20 * 数据长度,单位为字节。取值不能超过 2048。
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelNumericDataSpec.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/dataType/ThinkModelNumericDataSpec.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType;
2 2  
3 3 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 4 import lombok.Data;
... ... @@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode;
14 14 @Data
15 15 @EqualsAndHashCode(callSuper = true)
16 16 @JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
17   -public class ThingModelNumericDataSpec extends ThingModelDataSpecs {
  17 +public class ThinkModelNumericDataSpec extends ThinkModelDataSpecs {
18 18  
19 19 /**
20 20 * 最大值,需转为字符串类型。值必须与 dataType 类型一致。
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelStructDataSpecs.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/model/dataType/ThinkModelStructDataSpecs.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType;
2 2  
3   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelAccessModeEnum;
  3 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelAccessModeEnum;
4 4 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5 5 import lombok.Data;
6 6 import lombok.EqualsAndHashCode;
... ... @@ -15,7 +15,7 @@ import java.util.List;
15 15 @Data
16 16 @EqualsAndHashCode(callSuper = true)
17 17 @JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
18   -public class ThingModelStructDataSpecs extends ThingModelDataSpecs {
  18 +public class ThinkModelStructDataSpecs extends ThinkModelDataSpecs {
19 19  
20 20 /**
21 21 * 属性标识符
... ... @@ -31,7 +31,7 @@ public class ThingModelStructDataSpecs extends ThingModelDataSpecs {
31 31 private String description;
32 32 /**
33 33 * 云端可以对该属性进行的操作类型
34   - * 关联枚举 {@link IotProductThingModelAccessModeEnum}
  34 + * 关联枚举 {@link IotProductThinkModelAccessModeEnum}
35 35 */
36 36 private String accessMode;
37 37 /**
... ... @@ -48,11 +48,11 @@ public class ThingModelStructDataSpecs extends ThingModelDataSpecs {
48 48 /**
49 49 * 数据类型(dataType)为非列表型(int、float、double、text、date、array)的数据规范存储在 dataSpecs 中
50 50 */
51   - private ThingModelDataSpecs dataSpecs;
  51 + private ThinkModelDataSpecs dataSpecs;
52 52 /**
53 53 * 数据类型(dataType)为列表型(enum、bool、struct)的数据规范存储在 dataSpecsList 中
54 54 */
55   - private List<ThingModelDataSpecs> dataSpecsList;
  55 + private List<ThinkModelDataSpecs> dataSpecsList;
56 56  
57 57 }
58 58  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotProductThingModelPageReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/vo/IotProductThinkModelPageReqVO.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 4 import cn.iocoder.yudao.framework.common.validation.InEnum;
5   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
  5 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelTypeEnum;
6 6 import io.swagger.v3.oas.annotations.media.Schema;
7 7 import jakarta.validation.constraints.NotNull;
8 8 import lombok.Data;
... ... @@ -13,7 +13,7 @@ import lombok.ToString;
13 13 @Data
14 14 @EqualsAndHashCode(callSuper = true)
15 15 @ToString(callSuper = true)
16   -public class IotProductThingModelPageReqVO extends PageParam {
  16 +public class IotProductThinkModelPageReqVO extends PageParam {
17 17  
18 18 @Schema(description = "功能标识")
19 19 private String identifier;
... ... @@ -22,7 +22,7 @@ public class IotProductThingModelPageReqVO extends PageParam {
22 22 private String name;
23 23  
24 24 @Schema(description = "功能类型", example = "1")
25   - @InEnum(IotProductThingModelTypeEnum.class)
  25 + @InEnum(IotProductThinkModelTypeEnum.class)
26 26 private Integer type;
27 27  
28 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/productthingmodel/vo/IotProductThingModelRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/vo/IotProductThinkModelRespVO.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo;
2 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;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelEvent;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelProperty;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelService;
6 6 import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
7 7 import com.alibaba.excel.annotation.ExcelProperty;
8 8 import io.swagger.v3.oas.annotations.media.Schema;
... ... @@ -13,7 +13,7 @@ import java.time.LocalDateTime;
13 13 @Schema(description = "管理后台 - IoT 产品物模型 Response VO")
14 14 @Data
15 15 @ExcelIgnoreUnannotated
16   -public class IotProductThingModelRespVO {
  16 +public class IotProductThinkModelRespVO {
17 17  
18 18 @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21816")
19 19 @ExcelProperty("产品ID")
... ... @@ -39,13 +39,13 @@ public class IotProductThingModelRespVO {
39 39 private Integer type;
40 40  
41 41 @Schema(description = "属性", requiredMode = Schema.RequiredMode.REQUIRED)
42   - private ThingModelProperty property;
  42 + private ThinkModelProperty property;
43 43  
44 44 @Schema(description = "服务", requiredMode = Schema.RequiredMode.REQUIRED)
45   - private ThingModelEvent event;
  45 + private ThinkModelEvent event;
46 46  
47 47 @Schema(description = "事件", requiredMode = Schema.RequiredMode.REQUIRED)
48   - private ThingModelService service;
  48 + private ThinkModelService service;
49 49  
50 50 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
51 51 @ExcelProperty("创建时间")
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotProductThingModelSaveReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodel/vo/IotProductThinkModelSaveReqVO.java
1   -package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo;
  1 +package cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo;
2 2  
3 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
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;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelEvent;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelProperty;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelService;
  7 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelTypeEnum;
8 8 import io.swagger.v3.oas.annotations.media.Schema;
9 9 import jakarta.validation.constraints.NotEmpty;
10 10 import jakarta.validation.constraints.NotNull;
... ... @@ -12,7 +12,7 @@ import lombok.Data;
12 12  
13 13 @Schema(description = "管理后台 - IoT 产品物模型新增/修改 Request VO")
14 14 @Data
15   -public class IotProductThingModelSaveReqVO {
  15 +public class IotProductThinkModelSaveReqVO {
16 16  
17 17 @Schema(description = "编号", example = "1")
18 18 private Long id;
... ... @@ -38,16 +38,16 @@ public class IotProductThingModelSaveReqVO {
38 38  
39 39 @Schema(description = "功能类型", requiredMode = Schema.RequiredMode.REQUIRED)
40 40 @NotNull(message = "功能类型不能为空")
41   - @InEnum(IotProductThingModelTypeEnum.class)
  41 + @InEnum(IotProductThinkModelTypeEnum.class)
42 42 private Integer type;
43 43  
44 44 @Schema(description = "属性", requiredMode = Schema.RequiredMode.REQUIRED)
45   - private ThingModelProperty property;
  45 + private ThinkModelProperty property;
46 46  
47 47 @Schema(description = "服务", requiredMode = Schema.RequiredMode.REQUIRED)
48   - private ThingModelService service;
  48 + private ThinkModelService service;
49 49  
50 50 @Schema(description = "事件", requiredMode = Schema.RequiredMode.REQUIRED)
51   - private ThingModelEvent event;
  51 + private ThinkModelEvent event;
52 52  
53 53 }
54 54 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/device/IotDeviceDataConvert.java
... ... @@ -12,7 +12,7 @@ public interface IotDeviceDataConvert {
12 12 // default List<IotDeviceDataRespVO> convert(Map<String, Object> deviceData, IotDeviceDO device){
13 13 // List<IotDeviceDataRespVO> list = new ArrayList<>();
14 14 // deviceData.forEach((identifier, value) -> {
15   -//// ThingModelProperty property = ThingModelService.INSTANCE.getProperty(device.getProductId(), identifier);
  15 +//// ThinkModelProperty property = ThinkModelService.INSTANCE.getProperty(device.getProductId(), identifier);
16 16 //// if (Objects.isNull(property)) {
17 17 //// return;
18 18 //// }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/productthingmodel/IotProductThingModelConvert.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/thinkmodel/IotProductThinkModelConvert.java
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;
  1 +package cn.iocoder.yudao.module.iot.convert.thinkmodel;
  2 +
  3 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelEvent;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelProperty;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelService;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo.IotProductThinkModelRespVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo.IotProductThinkModelSaveReqVO;
  8 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
  9 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelTypeEnum;
10 10 import org.mapstruct.Mapper;
11 11 import org.mapstruct.Mapping;
12 12 import org.mapstruct.Named;
... ... @@ -16,44 +16,44 @@ import java.util.List;
16 16 import java.util.Objects;
17 17  
18 18 @Mapper
19   -public interface IotProductThingModelConvert {
  19 +public interface IotProductThinkModelConvert {
20 20  
21   - IotProductThingModelConvert INSTANCE = Mappers.getMapper(IotProductThingModelConvert.class);
  21 + IotProductThinkModelConvert INSTANCE = Mappers.getMapper(IotProductThinkModelConvert.class);
22 22  
23 23 // 将 SaveReqVO 转换为 DO
24 24 @Mapping(target = "property", expression = "java(convertToProperty(bean))")
25 25 @Mapping(target = "event", expression = "java(convertToEvent(bean))")
26 26 @Mapping(target = "service", expression = "java(convertToService(bean))")
27   - IotProductThingModelDO convert(IotProductThingModelSaveReqVO bean);
  27 + IotProductThinkModelDO convert(IotProductThinkModelSaveReqVO bean);
28 28  
29 29 // 将 DO 转换为 RespVO
30 30 @Mapping(target = "property", source = "property")
31 31 @Mapping(target = "event", source = "event")
32 32 @Mapping(target = "service", source = "service")
33   - IotProductThingModelRespVO convert(IotProductThingModelDO bean);
  33 + IotProductThinkModelRespVO convert(IotProductThinkModelDO bean);
34 34  
35 35 // 批量转换
36   - List<IotProductThingModelRespVO> convertList(List<IotProductThingModelDO> list);
  36 + List<IotProductThinkModelRespVO> convertList(List<IotProductThinkModelDO> list);
37 37  
38 38 @Named("convertToProperty")
39   - default ThingModelProperty convertToProperty(IotProductThingModelSaveReqVO bean) {
40   - if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
  39 + default ThinkModelProperty convertToProperty(IotProductThinkModelSaveReqVO bean) {
  40 + if (Objects.equals(bean.getType(), IotProductThinkModelTypeEnum.PROPERTY.getType())) {
41 41 return bean.getProperty();
42 42 }
43 43 return null;
44 44 }
45 45  
46 46 @Named("convertToEvent")
47   - default ThingModelEvent convertToEvent(IotProductThingModelSaveReqVO bean) {
48   - if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.EVENT.getType())) {
  47 + default ThinkModelEvent convertToEvent(IotProductThinkModelSaveReqVO bean) {
  48 + if (Objects.equals(bean.getType(), IotProductThinkModelTypeEnum.EVENT.getType())) {
49 49 return bean.getEvent();
50 50 }
51 51 return null;
52 52 }
53 53  
54 54 @Named("convertToService")
55   - default ThingModelService convertToService(IotProductThingModelSaveReqVO bean) {
56   - if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.SERVICE.getType())) {
  55 + default ThinkModelService convertToService(IotProductThinkModelSaveReqVO bean) {
  56 + if (Objects.equals(bean.getType(), IotProductThinkModelTypeEnum.SERVICE.getType())) {
57 57 return bean.getService();
58 58 }
59 59 return null;
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/device/IotDeviceDataDO.java
1 1 package cn.iocoder.yudao.module.iot.dal.dataobject.device;
2 2  
3 3 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
4   -import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
  4 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
5 5 import lombok.AllArgsConstructor;
6 6 import lombok.Builder;
7 7 import lombok.Data;
... ... @@ -30,9 +30,9 @@ public class IotDeviceDataDO {
30 30 /**
31 31 * 物模型编号
32 32 * <p>
33   - * 关联 {@link IotProductThingModelDO#getId()}
  33 + * 关联 {@link IotProductThinkModelDO#getId()}
34 34 */
35   - private Long thinkModelFunctionId;
  35 + private Long thinkModelId;
36 36  
37 37 /**
38 38 * 产品标识
... ... @@ -51,21 +51,21 @@ public class IotDeviceDataDO {
51 51 /**
52 52 * 属性标识符
53 53 * <p>
54   - * 关联 {@link IotProductThingModelDO#getIdentifier()}
  54 + * 关联 {@link IotProductThinkModelDO#getIdentifier()}
55 55 */
56 56 private String identifier;
57 57  
58 58 /**
59 59 * 属性名称
60 60 * <p>
61   - * 关联 {@link IotProductThingModelDO#getName()}
  61 + * 关联 {@link IotProductThinkModelDO#getName()}
62 62 */
63 63 private String name;
64 64  
65 65 /**
66 66 * 数据类型
67 67 * <p>
68   - * 关联 {@link IotProductThingModelDO#getProperty()#getDataType()}
  68 + * 关联 {@link IotProductThinkModelDO#getProperty()#getDataType()}
69 69 */
70 70 private String dataType;
71 71  
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/tdengine/FieldParser.java
1 1 package cn.iocoder.yudao.module.iot.dal.dataobject.tdengine;
2 2  
3   -import cn.iocoder.yudao.module.iot.controller.admin.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;
  3 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelProperty;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelRespVO;
6 5  
7 6 import java.util.HashMap;
8 7 import java.util.List;
... ... @@ -34,21 +33,18 @@ public class FieldParser {
34 33 * @param property 物模型属性
35 34 * @return TdField对象
36 35 */
37   - public static TdFieldDO parse(ThingModelProperty property) {
  36 + public static TdFieldDO parse(ThinkModelProperty property) {
38 37 String fieldName = property.getIdentifier().toLowerCase();
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;
  38 +
  39 + // 将物模型字段类型映射为td字段类型
  40 + String fType = TYPE_MAPPING.get(property.getDataType().toUpperCase());
  41 +
  42 + // 如果字段类型为NCHAR,默认长度为64
  43 + int dataLength = 0;
  44 + if ("NCHAR".equals(fType)) {
  45 + dataLength = 64;
  46 + }
  47 + return new TdFieldDO(fieldName, fType, dataLength);
52 48 }
53 49  
54 50 /**
... ... @@ -57,7 +53,7 @@ public class FieldParser {
57 53 * @param thingModel 物模型响应对象
58 54 * @return 字段列表
59 55 */
60   - public static List<TdFieldDO> parse(ThingModelRespVO thingModel) {
  56 + public static List<TdFieldDO> parse(ThinkModelRespVO thingModel) {
61 57 return thingModel.getModel().getProperties().stream()
62 58 .map(FieldParser::parse)
63 59 .collect(Collectors.toList());
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/tdengine/ThingModelMessage.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/tdengine/ThinkModelMessage.java
... ... @@ -15,7 +15,7 @@ import java.util.Map;
15 15 @NoArgsConstructor
16 16 @AllArgsConstructor
17 17 @Builder
18   -public class ThingModelMessage {
  18 +public class ThinkModelMessage {
19 19  
20 20 /**
21 21 * 消息ID
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/productthingmodel/IotProductThingModelDO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/thinkmodel/IotProductThinkModelDO.java
1   -package cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel;
  1 +package cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel;
2 2  
3 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
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;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelEvent;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelProperty;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelService;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
8   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
  8 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelTypeEnum;
9 9 import com.baomidou.mybatisplus.annotation.KeySequence;
10 10 import com.baomidou.mybatisplus.annotation.TableField;
11 11 import com.baomidou.mybatisplus.annotation.TableId;
... ... @@ -19,17 +19,17 @@ import lombok.NoArgsConstructor;
19 19 /**
20 20 * IoT 产品物模型功能 DO
21 21 * <p>
22   - * 每个 {@link IotProductDO} 和 {@link IotProductThingModelDO} 是“一对多”的关系,它的每个属性、事件、服务都对应一条记录
  22 + * 每个 {@link IotProductDO} 和 {@link IotProductThinkModelDO} 是“一对多”的关系,它的每个属性、事件、服务都对应一条记录
23 23 *
24 24 * @author 芋道源码
25 25 */
26   -@TableName(value = "iot_product_thing_model", autoResultMap = true)
27   -@KeySequence("iot_product_thing_model_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  26 +@TableName(value = "iot_product_think_model", autoResultMap = true)
  27 +@KeySequence("iot_product_think_model_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
28 28 @Data
29 29 @Builder
30 30 @NoArgsConstructor
31 31 @AllArgsConstructor
32   -public class IotProductThingModelDO extends BaseDO {
  32 +public class IotProductThinkModelDO extends BaseDO {
33 33  
34 34 /**
35 35 * 物模型功能编号
... ... @@ -66,7 +66,7 @@ public class IotProductThingModelDO extends BaseDO {
66 66 /**
67 67 * 功能类型
68 68 * <p>
69   - * 枚举 {@link IotProductThingModelTypeEnum}
  69 + * 枚举 {@link IotProductThinkModelTypeEnum}
70 70 */
71 71 private Integer type;
72 72  
... ... @@ -74,18 +74,18 @@ public class IotProductThingModelDO extends BaseDO {
74 74 * 属性
75 75 */
76 76 @TableField(typeHandler = JacksonTypeHandler.class)
77   - private ThingModelProperty property;
  77 + private ThinkModelProperty property;
78 78  
79 79 /**
80 80 * 事件
81 81 */
82 82 @TableField(typeHandler = JacksonTypeHandler.class)
83   - private ThingModelEvent event;
  83 + private ThinkModelEvent event;
84 84  
85 85 /**
86 86 * 服务
87 87 */
88 88 @TableField(typeHandler = JacksonTypeHandler.class)
89   - private ThingModelService service;
  89 + private ThinkModelService service;
90 90  
91 91 }
92 92 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/thinkmodel/IotProductThinkModelMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.dal.mysql.thinkmodel;
  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.thinkmodel.vo.IotProductThinkModelPageReqVO;
  7 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
  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 IotProductThinkModelMapper extends BaseMapperX<IotProductThinkModelDO> {
  19 +
  20 + default PageResult<IotProductThinkModelDO> selectPage(IotProductThinkModelPageReqVO reqVO) {
  21 + return selectPage(reqVO, new LambdaQueryWrapperX<IotProductThinkModelDO>()
  22 + .eqIfPresent(IotProductThinkModelDO::getIdentifier, reqVO.getIdentifier())
  23 + .likeIfPresent(IotProductThinkModelDO::getName, reqVO.getName())
  24 + .eqIfPresent(IotProductThinkModelDO::getType, reqVO.getType())
  25 + .eqIfPresent(IotProductThinkModelDO::getProductId, reqVO.getProductId())
  26 + .notIn(IotProductThinkModelDO::getIdentifier, "get", "set", "post")
  27 + .orderByDesc(IotProductThinkModelDO::getId));
  28 + }
  29 +
  30 + default IotProductThinkModelDO selectByProductIdAndIdentifier(Long productId, String identifier) {
  31 + return selectOne(IotProductThinkModelDO::getProductId, productId,
  32 + IotProductThinkModelDO::getIdentifier, identifier);
  33 + }
  34 +
  35 + default List<IotProductThinkModelDO> selectListByProductId(Long productId) {
  36 + return selectList(IotProductThinkModelDO::getProductId, productId);
  37 + }
  38 +
  39 + default List<IotProductThinkModelDO> selectListByProductIdAndType(Long productId, Integer type) {
  40 + return selectList(IotProductThinkModelDO::getProductId, productId,
  41 + IotProductThinkModelDO::getType, type);
  42 + }
  43 +
  44 + default List<IotProductThinkModelDO> selectListByProductIdAndIdentifiersAndTypes(Long productId,
  45 + List<String> identifiers,
  46 + List<Integer> types) {
  47 + return selectList(new LambdaQueryWrapperX<IotProductThinkModelDO>()
  48 + .eq(IotProductThinkModelDO::getProductId, productId)
  49 + .in(IotProductThinkModelDO::getIdentifier, identifiers)
  50 + .in(IotProductThinkModelDO::getType, types));
  51 + }
  52 +
  53 + default IotProductThinkModelDO selectByProductIdAndName(Long productId, String name) {
  54 + return selectOne(IotProductThinkModelDO::getProductId, productId,
  55 + IotProductThinkModelDO::getName, name);
  56 + }
  57 +
  58 + default List<IotProductThinkModelDO> selectListByProductKey(String productKey) {
  59 + return selectList(IotProductThinkModelDO::getProductKey, productKey);
  60 + }
  61 +
  62 +}
0 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/IotProductThingModelMapper.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.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   -}
63 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 7 import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataPageReqVO;
8 8 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
9 9 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO;
10   -import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
11 10 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.SelectVisualDO;
12   -import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
  11 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThinkModelMessage;
  12 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
13 13 import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO;
14 14 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper;
15 15 import cn.iocoder.yudao.module.iot.enums.IotConstants;
16   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
17   -import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService;
18   -import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
  16 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelTypeEnum;
  17 +import cn.iocoder.yudao.module.iot.service.tdengine.IotThinkModelMessageService;
  18 +import cn.iocoder.yudao.module.iot.service.thinkmodel.IotProductThinkModelService;
19 19 import jakarta.annotation.Resource;
20 20 import jakarta.validation.Valid;
21 21 import lombok.extern.slf4j.Slf4j;
... ... @@ -28,6 +28,8 @@ import java.util.HashMap;
28 28 import java.util.List;
29 29 import java.util.Map;
30 30  
  31 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;
  32 +
31 33 @Slf4j
32 34 @Service
33 35 public class IotDeviceDataServiceImpl implements IotDeviceDataService {
... ... @@ -38,9 +40,9 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
38 40 @Resource
39 41 private IotDeviceService deviceService;
40 42 @Resource
41   - private IotThingModelMessageService thingModelMessageService;
  43 + private IotThinkModelMessageService thingModelMessageService;
42 44 @Resource
43   - private IotProductThingModelService thinkModelFunctionService;
  45 + private IotProductThinkModelService thinkModelFunctionService;
44 46 @Resource
45 47 private TdEngineDMLMapper tdEngineDMLMapper;
46 48  
... ... @@ -54,7 +56,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
54 56 // 2. 解析消息,保存数据
55 57 JSONObject jsonObject = new JSONObject(message);
56 58 log.info("[saveDeviceData][productKey({}) deviceName({}) data({})]", productKey, deviceName, jsonObject);
57   - ThingModelMessage thingModelMessage = ThingModelMessage.builder()
  59 + ThinkModelMessage thingModelMessage = ThinkModelMessage.builder()
58 60 .id(jsonObject.getStr("id"))
59 61 .sys(jsonObject.get("sys"))
60 62 .method(jsonObject.getStr("method"))
... ... @@ -64,7 +66,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
64 66 .deviceName(deviceName)
65 67 .deviceKey(device.getDeviceKey())
66 68 .build();
67   - thingModelMessageService.saveThingModelMessage(device, thingModelMessage);
  69 + thingModelMessageService.saveThinkModelMessage(device, thingModelMessage);
68 70 }
69 71  
70 72 @Override
... ... @@ -73,35 +75,31 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
73 75 // 1. 获取设备信息
74 76 IotDeviceDO device = deviceService.getDevice(deviceDataReqVO.getDeviceId());
75 77 // 2. 获取设备属性最新数据
76   - List<IotProductThingModelDO> thinkModelFunctionList = thinkModelFunctionService.getProductThingModelListByProductKey(device.getProductKey());
77   - thinkModelFunctionList = thinkModelFunctionList.stream()
78   - .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType()
79   - .equals(function.getType())).toList();
  78 + List<IotProductThinkModelDO> thinkModelList = thinkModelFunctionService.getProductThinkModelListByProductKey(device.getProductKey());
  79 + thinkModelList = filterList(thinkModelList, thinkModel -> IotProductThinkModelTypeEnum.PROPERTY.getType()
  80 + .equals(thinkModel.getType()));
80 81  
81 82 // 3. 过滤标识符和属性名称
82 83 if (deviceDataReqVO.getIdentifier() != null) {
83   - thinkModelFunctionList = thinkModelFunctionList.stream()
84   - .filter(function -> function.getIdentifier().toLowerCase().contains(deviceDataReqVO.getIdentifier().toLowerCase()))
85   - .toList();
  84 + thinkModelList = filterList(thinkModelList, thinkModel -> thinkModel.getIdentifier()
  85 + .toLowerCase().contains(deviceDataReqVO.getIdentifier().toLowerCase()));
86 86 }
87 87 if (deviceDataReqVO.getName() != null) {
88   - thinkModelFunctionList = thinkModelFunctionList.stream()
89   - .filter(function -> function.getName().toLowerCase().contains(deviceDataReqVO.getName().toLowerCase()))
90   - .toList();
  88 + thinkModelList = filterList(thinkModelList, thinkModel -> thinkModel.getName()
  89 + .toLowerCase().contains(deviceDataReqVO.getName().toLowerCase()));
91 90 }
92 91 // 4. 获取设备属性最新数据
93   - // TODO @puhui999: 需要重构
94   - thinkModelFunctionList.forEach(function -> {
95   - IotDeviceDataDO deviceData = deviceDataRedisDAO.get(device.getProductKey(), device.getDeviceName(), function.getIdentifier());
  92 + thinkModelList.forEach(thinkModel -> {
  93 + IotDeviceDataDO deviceData = deviceDataRedisDAO.get(device.getProductKey(), device.getDeviceName(), thinkModel.getIdentifier());
96 94 if (deviceData == null) {
97 95 deviceData = new IotDeviceDataDO();
98 96 deviceData.setProductKey(device.getProductKey());
99 97 deviceData.setDeviceName(device.getDeviceName());
100   - deviceData.setIdentifier(function.getIdentifier());
  98 + deviceData.setIdentifier(thinkModel.getIdentifier());
101 99 deviceData.setDeviceId(deviceDataReqVO.getDeviceId());
102   - deviceData.setThinkModelFunctionId(function.getId());
103   - deviceData.setName(function.getName());
104   - //deviceData.setDataType(function.getProperty().getDataType().getDataType());
  100 + deviceData.setThinkModelId(thinkModel.getId());
  101 + deviceData.setName(thinkModel.getName());
  102 + deviceData.setDataType(thinkModel.getProperty().getDataType());
105 103 }
106 104 list.add(deviceData);
107 105 });
... ...
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 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
8 8 import cn.iocoder.yudao.module.iot.dal.mysql.product.IotProductMapper;
9 9 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum;
10   -import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
  10 +import cn.iocoder.yudao.module.iot.service.thinkmodel.IotProductThinkModelService;
11 11 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
12 12 import jakarta.annotation.Resource;
13 13 import org.springframework.context.annotation.Lazy;
... ... @@ -34,7 +34,7 @@ public class IotProductServiceImpl implements IotProductService {
34 34  
35 35 @Resource
36 36 @Lazy
37   - private IotProductThingModelService thinkModelFunctionService;
  37 + private IotProductThinkModelService thinkModelFunctionService;
38 38  
39 39 @Override
40 40 public Long createProduct(IotProductSaveReqVO createReqVO) {
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotSuperTableService.java
... ... @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.service.tdengine;
2 2  
3 3  
4 4 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
5   -import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
  5 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
6 6  
7 7 import java.util.List;
8 8  
... ... @@ -14,5 +14,5 @@ public interface IotSuperTableService {
14 14 /**
15 15 * 创建超级表数据模型
16 16 */
17   - void createSuperTableDataModel(IotProductDO product, List<IotProductThingModelDO> functionList);
  17 + void createSuperTableDataModel(IotProductDO product, List<IotProductThinkModelDO> functionList);
18 18 }
19 19 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotSuperTableServiceImpl.java
... ... @@ -2,15 +2,15 @@ package cn.iocoder.yudao.module.iot.service.tdengine;
2 2  
3 3 import cn.hutool.core.bean.BeanUtil;
4 4 import cn.hutool.core.collection.CollUtil;
5   -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
6   -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelRespVO;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelProperty;
  6 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelRespVO;
7 7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
8 8 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser;
9 9 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO;
10 10 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO;
11   -import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
  11 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
12 12 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper;
13   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
  13 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelTypeEnum;
14 14 import jakarta.annotation.Resource;
15 15 import lombok.extern.slf4j.Slf4j;
16 16 import org.springframework.beans.factory.annotation.Value;
... ... @@ -33,8 +33,8 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
33 33 private String url;
34 34  
35 35 @Override
36   - public void createSuperTableDataModel(IotProductDO product, List<IotProductThingModelDO> functionList) {
37   - ThingModelRespVO thingModel = buildThingModel(product, functionList);
  36 + public void createSuperTableDataModel(IotProductDO product, List<IotProductThinkModelDO> functionList) {
  37 + ThinkModelRespVO thingModel = buildThinkModel(product, functionList);
38 38  
39 39 if (thingModel.getModel() == null || CollUtil.isEmpty(thingModel.getModel().getProperties())) {
40 40 log.warn("物模型属性列表为空,不创建超级表");
... ... @@ -56,7 +56,7 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
56 56 /**
57 57 * 创建超级表
58 58 */
59   - private void createSuperTable(ThingModelRespVO thingModel, Integer deviceType) {
  59 + private void createSuperTable(ThinkModelRespVO thingModel, Integer deviceType) {
60 60 // 解析物模型,获取字段列表
61 61 List<TdFieldDO> schemaFields = new ArrayList<>();
62 62 schemaFields.add(TdFieldDO.builder()
... ... @@ -84,7 +84,7 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
84 84 /**
85 85 * 更新超级表
86 86 */
87   - private void updateSuperTable(ThingModelRespVO thingModel, Integer deviceType) {
  87 + private void updateSuperTable(ThinkModelRespVO thingModel, Integer deviceType) {
88 88 String superTableName = getSuperTableName(deviceType, thingModel.getProductKey());
89 89 try {
90 90 List<TdFieldDO> oldFields = getTableFields(superTableName);
... ... @@ -210,18 +210,18 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
210 210 /**
211 211 * 构建物模型
212 212 */
213   - private ThingModelRespVO buildThingModel(IotProductDO product, List<IotProductThingModelDO> functionList) {
214   - ThingModelRespVO thingModel = new ThingModelRespVO();
  213 + private ThinkModelRespVO buildThinkModel(IotProductDO product, List<IotProductThinkModelDO> functionList) {
  214 + ThinkModelRespVO thingModel = new ThinkModelRespVO();
215 215 thingModel.setId(product.getId());
216 216 thingModel.setProductKey(product.getProductKey());
217 217  
218   - List<ThingModelProperty> properties = functionList.stream()
219   - .filter(function -> IotProductThingModelTypeEnum.PROPERTY.equals(
220   - IotProductThingModelTypeEnum.valueOfType(function.getType())))
221   - .map(this::buildThingModelProperty)
  218 + List<ThinkModelProperty> properties = functionList.stream()
  219 + .filter(function -> IotProductThinkModelTypeEnum.PROPERTY.equals(
  220 + IotProductThinkModelTypeEnum.valueOfType(function.getType())))
  221 + .map(this::buildThinkModelProperty)
222 222 .collect(Collectors.toList());
223 223  
224   - ThingModelRespVO.Model model = new ThingModelRespVO.Model();
  224 + ThinkModelRespVO.Model model = new ThinkModelRespVO.Model();
225 225 model.setProperties(properties);
226 226 thingModel.setModel(model);
227 227  
... ... @@ -231,8 +231,8 @@ public class IotSuperTableServiceImpl implements IotSuperTableService {
231 231 /**
232 232 * 构建物模型属性
233 233 */
234   - private ThingModelProperty buildThingModelProperty(IotProductThingModelDO function) {
235   - ThingModelProperty property = BeanUtil.copyProperties(function, ThingModelProperty.class);
  234 + private ThinkModelProperty buildThinkModelProperty(IotProductThinkModelDO function) {
  235 + ThinkModelProperty property = BeanUtil.copyProperties(function, ThinkModelProperty.class);
236 236 property.setDataType(function.getProperty().getDataType());
237 237 return property;
238 238 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThinkModelMessageService.java
1 1 package cn.iocoder.yudao.module.iot.service.tdengine;
2 2  
3 3 import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO;
4   -import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
  4 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThinkModelMessage;
5 5  
6 6 /**
7 7 * 物模型消息 Service
8 8 */
9   -public interface IotThingModelMessageService {
  9 +public interface IotThinkModelMessageService {
10 10  
11 11 /**
12 12 * 保存物模型消息
... ... @@ -14,5 +14,5 @@ public interface IotThingModelMessageService {
14 14 * @param device 设备
15 15 * @param thingModelMessage 物模型消息
16 16 */
17   - void saveThingModelMessage(IotDeviceDO device, ThingModelMessage thingModelMessage);
  17 + void saveThinkModelMessage(IotDeviceDO device, ThinkModelMessage thingModelMessage);
18 18 }
19 19 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageServiceImpl.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThinkModelMessageServiceImpl.java
... ... @@ -10,16 +10,16 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDataDO;
10 10 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.FieldParser;
11 11 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO;
12 12 import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO;
13   -import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThingModelMessage;
14   -import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
  13 +import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.ThinkModelMessage;
  14 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
15 15 import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO;
16 16 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper;
17 17 import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper;
18 18 import cn.iocoder.yudao.module.iot.enums.IotConstants;
19 19 import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStatusEnum;
20   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
  20 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelTypeEnum;
21 21 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
22   -import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
  22 +import cn.iocoder.yudao.module.iot.service.thinkmodel.IotProductThinkModelService;
23 23 import jakarta.annotation.Resource;
24 24 import lombok.extern.slf4j.Slf4j;
25 25 import org.springframework.beans.factory.annotation.Value;
... ... @@ -33,7 +33,7 @@ import java.util.stream.Collectors;
33 33 */
34 34 @Slf4j
35 35 @Service
36   -public class IotThingModelMessageServiceImpl implements IotThingModelMessageService {
  36 +public class IotThinkModelMessageServiceImpl implements IotThinkModelMessageService {
37 37  
38 38 private static final String TAG_NOTE = "TAG";
39 39 private static final String NOTE = "note";
... ... @@ -47,7 +47,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
47 47 private String url;
48 48  
49 49 @Resource
50   - private IotProductThingModelService iotProductThingModelService;
  50 + private IotProductThinkModelService iotProductThinkModelService;
51 51 @Resource
52 52 private IotDeviceService iotDeviceService;
53 53 @Resource
... ... @@ -61,7 +61,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
61 61 // TODO @haohao:这个方法,可以考虑加下 1. 2. 3. 更有层次感
62 62 @Override
63 63 @TenantIgnore
64   - public void saveThingModelMessage(IotDeviceDO device, ThingModelMessage thingModelMessage) {
  64 + public void saveThinkModelMessage(IotDeviceDO device, ThinkModelMessage thingModelMessage) {
65 65 // 1. 判断设备状态,如果为未激活状态,创建数据表并更新设备状态
66 66 if (IotDeviceStatusEnum.INACTIVE.getStatus().equals(device.getStatus())) {
67 67 createDeviceTable(device.getDeviceType(), device.getProductKey(), device.getDeviceName(), device.getDeviceKey());
... ... @@ -71,7 +71,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
71 71  
72 72 // 2. 获取设备属性并进行物模型校验,过滤非物模型属性
73 73 Map<String, Object> params = thingModelMessage.dataToMap();
74   - List<IotProductThingModelDO> functionList = getValidFunctionList(thingModelMessage.getProductKey());
  74 + List<IotProductThinkModelDO> functionList = getValidFunctionList(thingModelMessage.getProductKey());
75 75 if (functionList.isEmpty()) {
76 76 return;
77 77 }
... ... @@ -90,21 +90,21 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
90 90 .build());
91 91 }
92 92  
93   - private List<IotProductThingModelDO> getValidFunctionList(String productKey) {
94   - return iotProductThingModelService
95   - .getProductThingModelListByProductKey(productKey)
  93 + private List<IotProductThinkModelDO> getValidFunctionList(String productKey) {
  94 + return iotProductThinkModelService
  95 + .getProductThinkModelListByProductKey(productKey)
96 96 .stream()
97   - .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(function.getType()))
  97 + .filter(function -> IotProductThinkModelTypeEnum.PROPERTY.getType().equals(function.getType()))
98 98 .toList();
99 99 }
100 100  
101   - private List<TdFieldDO> filterAndCollectValidFields(Map<String, Object> params, List<IotProductThingModelDO> functionList, IotDeviceDO device, Long time) {
  101 + private List<TdFieldDO> filterAndCollectValidFields(Map<String, Object> params, List<IotProductThinkModelDO> functionList, IotDeviceDO device, Long time) {
102 102 // 1. 获取属性标识符集合
103   - Set<String> propertyIdentifiers = CollectionUtils.convertSet(functionList, IotProductThingModelDO::getIdentifier);
  103 + Set<String> propertyIdentifiers = CollectionUtils.convertSet(functionList, IotProductThinkModelDO::getIdentifier);
104 104  
105 105 // 2. 构建属性标识符和属性的映射
106   - Map<String, IotProductThingModelDO> functionMap = functionList.stream()
107   - .collect(Collectors.toMap(IotProductThingModelDO::getIdentifier, function -> function));
  106 + Map<String, IotProductThinkModelDO> functionMap = functionList.stream()
  107 + .collect(Collectors.toMap(IotProductThinkModelDO::getIdentifier, function -> function));
108 108  
109 109 // 3. 过滤并收集有效的属性字段
110 110 List<TdFieldDO> schemaFieldValues = new ArrayList<>();
... ... @@ -124,22 +124,21 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
124 124 * 缓存设备属性
125 125 *
126 126 * @param device 设备信息
127   - * @param iotProductThingModelDO 物模型属性
  127 + * @param iotProductThinkModelDO 物模型属性
128 128 * @param val 属性值
129 129 * @param time 时间
130 130 */
131   - private void setDeviceDataCache(IotDeviceDO device, IotProductThingModelDO iotProductThingModelDO, Object val, Long time) {
132   - // TODO @puhui999: 需要重构
  131 + private void setDeviceDataCache(IotDeviceDO device, IotProductThinkModelDO iotProductThinkModelDO, Object val, Long time) {
133 132 IotDeviceDataDO deviceData = IotDeviceDataDO.builder()
134 133 .productKey(device.getProductKey())
135 134 .deviceName(device.getDeviceName())
136   - .identifier(iotProductThingModelDO.getIdentifier())
  135 + .identifier(iotProductThinkModelDO.getIdentifier())
137 136 .value(val != null ? val.toString() : null)
138 137 .updateTime(DateUtil.toLocalDateTime(new Date(time)))
139 138 .deviceId(device.getId())
140   - .thinkModelFunctionId(iotProductThingModelDO.getId())
141   - .name(iotProductThingModelDO.getName())
142   - //.dataType(iotProductThingModelDO.getProperty().getDataType().getDataType())
  139 + .thinkModelId(iotProductThinkModelDO.getId())
  140 + .name(iotProductThinkModelDO.getName())
  141 + .dataType(iotProductThinkModelDO.getProperty().getDataType())
143 142 .build();
144 143 deviceDataRedisDAO.set(deviceData);
145 144 }
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/productthingmodel/IotProductThingModelService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thinkmodel/IotProductThinkModelService.java
1   -package cn.iocoder.yudao.module.iot.service.productthingmodel;
  1 +package cn.iocoder.yudao.module.iot.service.thinkmodel;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
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;
  4 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo.IotProductThinkModelPageReqVO;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo.IotProductThinkModelSaveReqVO;
  6 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
7 7 import jakarta.validation.Valid;
8 8  
9 9 import java.util.List;
... ... @@ -13,7 +13,7 @@ import java.util.List;
13 13 *
14 14 * @author 芋道源码
15 15 */
16   -public interface IotProductThingModelService {
  16 +public interface IotProductThinkModelService {
17 17  
18 18 /**
19 19 * 创建产品物模型
... ... @@ -21,21 +21,21 @@ public interface IotProductThingModelService {
21 21 * @param createReqVO 创建信息
22 22 * @return 编号
23 23 */
24   - Long createProductThingModel(@Valid IotProductThingModelSaveReqVO createReqVO);
  24 + Long createProductThinkModel(@Valid IotProductThinkModelSaveReqVO createReqVO);
25 25  
26 26 /**
27 27 * 更新产品物模型
28 28 *
29 29 * @param updateReqVO 更新信息
30 30 */
31   - void updateProductThingModel(@Valid IotProductThingModelSaveReqVO updateReqVO);
  31 + void updateProductThinkModel(@Valid IotProductThinkModelSaveReqVO updateReqVO);
32 32  
33 33 /**
34 34 * 删除产品物模型
35 35 *
36 36 * @param id 编号
37 37 */
38   - void deleteProductThingModel(Long id);
  38 + void deleteProductThinkModel(Long id);
39 39  
40 40 /**
41 41 * 获得产品物模型
... ... @@ -43,7 +43,7 @@ public interface IotProductThingModelService {
43 43 * @param id 编号
44 44 * @return 产品物模型
45 45 */
46   - IotProductThingModelDO getProductThingModel(Long id);
  46 + IotProductThinkModelDO getProductThinkModel(Long id);
47 47  
48 48 /**
49 49 * 获得产品物模型列表
... ... @@ -51,7 +51,7 @@ public interface IotProductThingModelService {
51 51 * @param productId 产品编号
52 52 * @return 产品物模型列表
53 53 */
54   - List<IotProductThingModelDO> getProductThingModelListByProductId(Long productId);
  54 + List<IotProductThinkModelDO> getProductThinkModelListByProductId(Long productId);
55 55  
56 56 /**
57 57 * 获得产品物模型分页
... ... @@ -59,7 +59,7 @@ public interface IotProductThingModelService {
59 59 * @param pageReqVO 分页查询
60 60 * @return 产品物模型分页
61 61 */
62   - PageResult<IotProductThingModelDO> getProductThingModelPage(IotProductThingModelPageReqVO pageReqVO);
  62 + PageResult<IotProductThinkModelDO> getProductThinkModelPage(IotProductThinkModelPageReqVO pageReqVO);
63 63  
64 64 /**
65 65 * 创建超级表数据模型
... ... @@ -74,6 +74,6 @@ public interface IotProductThingModelService {
74 74 * @param productKey 产品 Key
75 75 * @return 产品物模型列表
76 76 */
77   - List<IotProductThingModelDO> getProductThingModelListByProductKey(String productKey);
  77 + List<IotProductThinkModelDO> getProductThinkModelListByProductKey(String productKey);
78 78  
79 79 }
80 80 \ No newline at end of file
... ...
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/productthingmodel/IotProductThingModelServiceImpl.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thinkmodel/IotProductThinkModelServiceImpl.java
1   -package cn.iocoder.yudao.module.iot.service.productthingmodel;
  1 +package cn.iocoder.yudao.module.iot.service.thinkmodel;
2 2  
3 3 import cn.hutool.core.collection.CollUtil;
4 4 import cn.hutool.core.util.ObjectUtil;
5 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 6 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
7   -import cn.iocoder.yudao.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;
  7 +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
  8 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelEvent;
  9 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelProperty;
  10 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.ThinkModelService;
  11 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType.ThinkModelArgument;
  12 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType.ThinkModelArrayDataSpecs;
  13 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.model.dataType.ThinkModelDateOrTextDataSpecs;
  14 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo.IotProductThinkModelPageReqVO;
  15 +import cn.iocoder.yudao.module.iot.controller.admin.thinkmodel.vo.IotProductThinkModelSaveReqVO;
  16 +import cn.iocoder.yudao.module.iot.convert.thinkmodel.IotProductThinkModelConvert;
16 17 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
17   -import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
18   -import cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction.IotProductThingModelMapper;
  18 +import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodel.IotProductThinkModelDO;
  19 +import cn.iocoder.yudao.module.iot.dal.mysql.thinkmodel.IotProductThinkModelMapper;
19 20 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum;
20   -import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
  21 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelAccessModeEnum;
  22 +import cn.iocoder.yudao.module.iot.enums.thinkmodel.IotProductThinkModelTypeEnum;
21 23 import cn.iocoder.yudao.module.iot.service.product.IotProductService;
22 24 import cn.iocoder.yudao.module.iot.service.tdengine.IotSuperTableService;
23 25 import jakarta.annotation.Resource;
... ... @@ -41,10 +43,10 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
41 43 @Service
42 44 @Validated
43 45 @Slf4j
44   -public class IotProductThingModelServiceImpl implements IotProductThingModelService {
  46 +public class IotProductThinkModelServiceImpl implements IotProductThinkModelService {
45 47  
46 48 @Resource
47   - private IotProductThingModelMapper productThingModelMapper;
  49 + private IotProductThinkModelMapper productThinkModelMapper;
48 50  
49 51 @Resource
50 52 private IotProductService productService;
... ... @@ -53,7 +55,7 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
53 55  
54 56 @Override
55 57 @Transactional(rollbackFor = Exception.class)
56   - public Long createProductThingModel(IotProductThingModelSaveReqVO createReqVO) {
  58 + public Long createProductThinkModel(IotProductThinkModelSaveReqVO createReqVO) {
57 59 // 1. 校验功能标识符在同一产品下是否唯一
58 60 validateIdentifierUnique(createReqVO.getProductId(), createReqVO.getIdentifier());
59 61  
... ... @@ -67,12 +69,12 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
67 69 validateProductStatus(createReqVO.getProductId());
68 70  
69 71 // 5. 插入数据库
70   - IotProductThingModelDO function = IotProductThingModelConvert.INSTANCE.convert(createReqVO);
71   - productThingModelMapper.insert(function);
  72 + IotProductThinkModelDO function = IotProductThinkModelConvert.INSTANCE.convert(createReqVO);
  73 + productThinkModelMapper.insert(function);
72 74  
73 75 // 6. 如果创建的是属性,需要更新默认的事件和服务
74   - if (Objects.equals(createReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
75   - //createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey());
  76 + if (Objects.equals(createReqVO.getType(), IotProductThinkModelTypeEnum.PROPERTY.getType())) {
  77 + createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey());
76 78 }
77 79 return function.getId();
78 80 }
... ... @@ -95,14 +97,14 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
95 97 }
96 98  
97 99 private void validateNameUnique(Long productId, String name) {
98   - IotProductThingModelDO function = productThingModelMapper.selectByProductIdAndName(productId, name);
  100 + IotProductThinkModelDO function = productThinkModelMapper.selectByProductIdAndName(productId, name);
99 101 if (function != null) {
100 102 throw exception(THINK_MODEL_FUNCTION_NAME_EXISTS);
101 103 }
102 104 }
103 105  
104 106 private void validateIdentifierUnique(Long productId, String identifier) {
105   - IotProductThingModelDO function = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
  107 + IotProductThinkModelDO function = productThinkModelMapper.selectByProductIdAndIdentifier(productId, identifier);
106 108 if (function != null) {
107 109 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS);
108 110 }
... ... @@ -110,9 +112,9 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
110 112  
111 113 @Override
112 114 @Transactional(rollbackFor = Exception.class)
113   - public void updateProductThingModel(IotProductThingModelSaveReqVO updateReqVO) {
  115 + public void updateProductThinkModel(IotProductThinkModelSaveReqVO updateReqVO) {
114 116 // 1. 校验功能是否存在
115   - validateproductThingModelMapperExists(updateReqVO.getId());
  117 + validateProductThinkModelMapperExists(updateReqVO.getId());
116 118  
117 119 // 2. 校验功能标识符是否唯一
118 120 validateIdentifierUniqueForUpdate(updateReqVO.getId(), updateReqVO.getProductId(), updateReqVO.getIdentifier());
... ... @@ -121,17 +123,17 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
121 123 validateProductStatus(updateReqVO.getProductId());
122 124  
123 125 // 4. 更新数据库
124   - IotProductThingModelDO productThingModelDO = IotProductThingModelConvert.INSTANCE.convert(updateReqVO);
125   - productThingModelMapper.updateById(productThingModelDO);
  126 + IotProductThinkModelDO productThinkModelDO = IotProductThinkModelConvert.INSTANCE.convert(updateReqVO);
  127 + productThinkModelMapper.updateById(productThinkModelDO);
126 128  
127 129 // 5. 如果更新的是属性,需要更新默认的事件和服务
128   - if (Objects.equals(updateReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
  130 + if (Objects.equals(updateReqVO.getType(), IotProductThinkModelTypeEnum.PROPERTY.getType())) {
129 131 createDefaultEventsAndServices(updateReqVO.getProductId(), updateReqVO.getProductKey());
130 132 }
131 133 }
132 134  
133 135 private void validateIdentifierUniqueForUpdate(Long id, Long productId, String identifier) {
134   - IotProductThingModelDO function = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
  136 + IotProductThinkModelDO function = productThinkModelMapper.selectByProductIdAndIdentifier(productId, identifier);
135 137 if (function != null && ObjectUtil.notEqual(function.getId(), id)) {
136 138 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS);
137 139 }
... ... @@ -139,9 +141,9 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
139 141  
140 142 @Override
141 143 @Transactional(rollbackFor = Exception.class)
142   - public void deleteProductThingModel(Long id) {
  144 + public void deleteProductThinkModel(Long id) {
143 145 // 1. 校验功能是否存在
144   - IotProductThingModelDO functionDO = productThingModelMapper.selectById(id);
  146 + IotProductThinkModelDO functionDO = productThinkModelMapper.selectById(id);
145 147 if (functionDO == null) {
146 148 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS);
147 149 }
... ... @@ -150,10 +152,10 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
150 152 validateProductStatus(functionDO.getProductId());
151 153  
152 154 // 2. 删除功能
153   - productThingModelMapper.deleteById(id);
  155 + productThinkModelMapper.deleteById(id);
154 156  
155 157 // 3. 如果删除的是属性,需要更新默认的事件和服务
156   - if (Objects.equals(functionDO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
  158 + if (Objects.equals(functionDO.getType(), IotProductThinkModelTypeEnum.PROPERTY.getType())) {
157 159 createDefaultEventsAndServices(functionDO.getProductId(), functionDO.getProductKey());
158 160 }
159 161 }
... ... @@ -163,25 +165,25 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
163 165 *
164 166 * @param id 功能编号
165 167 */
166   - private void validateproductThingModelMapperExists(Long id) {
167   - if (productThingModelMapper.selectById(id) == null) {
  168 + private void validateProductThinkModelMapperExists(Long id) {
  169 + if (productThinkModelMapper.selectById(id) == null) {
168 170 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS);
169 171 }
170 172 }
171 173  
172 174 @Override
173   - public IotProductThingModelDO getProductThingModel(Long id) {
174   - return productThingModelMapper.selectById(id);
  175 + public IotProductThinkModelDO getProductThinkModel(Long id) {
  176 + return productThinkModelMapper.selectById(id);
175 177 }
176 178  
177 179 @Override
178   - public List<IotProductThingModelDO> getProductThingModelListByProductId(Long productId) {
179   - return productThingModelMapper.selectListByProductId(productId);
  180 + public List<IotProductThinkModelDO> getProductThinkModelListByProductId(Long productId) {
  181 + return productThinkModelMapper.selectListByProductId(productId);
180 182 }
181 183  
182 184 @Override
183   - public PageResult<IotProductThingModelDO> getProductThingModelPage(IotProductThingModelPageReqVO pageReqVO) {
184   - return productThingModelMapper.selectPage(pageReqVO);
  185 + public PageResult<IotProductThinkModelDO> getProductThinkModelPage(IotProductThinkModelPageReqVO pageReqVO) {
  186 + return productThinkModelMapper.selectPage(pageReqVO);
185 187 }
186 188  
187 189 @Override
... ... @@ -190,99 +192,98 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
190 192 IotProductDO product = productService.getProduct(productId);
191 193  
192 194 // 2. 查询产品的物模型功能列表
193   - List<IotProductThingModelDO> functionList = productThingModelMapper.selectListByProductId(productId);
  195 + List<IotProductThinkModelDO> functionList = productThinkModelMapper.selectListByProductId(productId);
194 196  
195 197 // 3. 生成 TDengine 的数据模型
196 198 dbStructureDataService.createSuperTableDataModel(product, functionList);
197 199 }
198 200  
199 201 @Override
200   - public List<IotProductThingModelDO> getProductThingModelListByProductKey(String productKey) {
201   - return productThingModelMapper.selectListByProductKey(productKey);
  202 + public List<IotProductThinkModelDO> getProductThinkModelListByProductKey(String productKey) {
  203 + return productThinkModelMapper.selectListByProductKey(productKey);
202 204 }
203 205  
204   - // TODO @puhui999: 需要重构
205 206 /**
206 207 * 创建默认的事件和服务
207 208 */
208 209 public void createDefaultEventsAndServices(Long productId, String productKey) {
209 210 // 1. 获取当前属性列表
210   - List<IotProductThingModelDO> propertyList = productThingModelMapper
211   - .selectListByProductIdAndType(productId, IotProductThingModelTypeEnum.PROPERTY.getType());
  211 + List<IotProductThinkModelDO> propertyList = productThinkModelMapper
  212 + .selectListByProductIdAndType(productId, IotProductThinkModelTypeEnum.PROPERTY.getType());
212 213  
213 214 // 2. 生成新的事件和服务列表
214   - List<IotProductThingModelDO> newFunctionList = new ArrayList<>();
  215 + List<IotProductThinkModelDO> newFunctionList = new ArrayList<>();
215 216 // 生成属性上报事件
216   - ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList);
  217 + ThinkModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList);
217 218 if (propertyPostEvent != null) {
218   - IotProductThingModelDO eventFunction = buildEventFunctionDO(productId, productKey, propertyPostEvent);
  219 + IotProductThinkModelDO eventFunction = buildEventFunctionDO(productId, productKey, propertyPostEvent);
219 220 newFunctionList.add(eventFunction);
220 221 }
221 222 // 生成属性设置服务
222   - ThingModelService propertySetService = generatePropertySetService(propertyList);
  223 + ThinkModelService propertySetService = generatePropertySetService(propertyList);
223 224 if (propertySetService != null) {
224   - IotProductThingModelDO setServiceFunction = buildServiceFunctionDO(productId, productKey, propertySetService);
  225 + IotProductThinkModelDO setServiceFunction = buildServiceFunctionDO(productId, productKey, propertySetService);
225 226 newFunctionList.add(setServiceFunction);
226 227 }
227 228 // 生成属性获取服务
228   - ThingModelService propertyGetService = generatePropertyGetService(propertyList);
  229 + ThinkModelService propertyGetService = generatePropertyGetService(propertyList);
229 230 if (propertyGetService != null) {
230   - IotProductThingModelDO getServiceFunction = buildServiceFunctionDO(productId, productKey, propertyGetService);
  231 + IotProductThinkModelDO getServiceFunction = buildServiceFunctionDO(productId, productKey, propertyGetService);
231 232 newFunctionList.add(getServiceFunction);
232 233 }
233 234  
234 235 // 3. 获取数据库中的默认的旧事件和服务列表
235   - List<IotProductThingModelDO> oldFunctionList = productThingModelMapper.selectListByProductIdAndIdentifiersAndTypes(
  236 + List<IotProductThinkModelDO> oldFunctionList = productThinkModelMapper.selectListByProductIdAndIdentifiersAndTypes(
236 237 productId,
237 238 Arrays.asList("post", "set", "get"),
238   - Arrays.asList(IotProductThingModelTypeEnum.EVENT.getType(), IotProductThingModelTypeEnum.SERVICE.getType())
  239 + Arrays.asList(IotProductThinkModelTypeEnum.EVENT.getType(), IotProductThinkModelTypeEnum.SERVICE.getType())
239 240 );
240 241  
241 242 // 3.1 使用 diffList 方法比较新旧列表
242   - List<List<IotProductThingModelDO>> diffResult = diffList(oldFunctionList, newFunctionList,
  243 + List<List<IotProductThinkModelDO>> diffResult = diffList(oldFunctionList, newFunctionList,
243 244 // 继续使用 identifier 和 type 进行比较:这样可以准确地匹配对应的功能对象。
244 245 (oldFunc, newFunc) -> Objects.equals(oldFunc.getIdentifier(), newFunc.getIdentifier())
245 246 && Objects.equals(oldFunc.getType(), newFunc.getType()));
246   - List<IotProductThingModelDO> createList = diffResult.get(0); // 需要新增的
247   - List<IotProductThingModelDO> updateList = diffResult.get(1); // 需要更新的
248   - List<IotProductThingModelDO> deleteList = diffResult.get(2); // 需要删除的
  247 + List<IotProductThinkModelDO> createList = diffResult.get(0); // 需要新增的
  248 + List<IotProductThinkModelDO> updateList = diffResult.get(1); // 需要更新的
  249 + List<IotProductThinkModelDO> deleteList = diffResult.get(2); // 需要删除的
249 250  
250 251 // 3.2 批量执行数据库操作
251 252 // 新增数据库中的新事件和服务列表
252 253 if (CollUtil.isNotEmpty(createList)) {
253   - productThingModelMapper.insertBatch(createList);
  254 + productThinkModelMapper.insertBatch(createList);
254 255 }
255 256 // 更新数据库中的事件和服务列表
256 257 if (CollUtil.isNotEmpty(updateList)) {
257 258 // 首先,为每个需要更新的对象设置其对应的 ID
258 259 updateList.forEach(updateFunc -> {
259   - IotProductThingModelDO oldFunc = findFunctionByIdentifierAndType(
  260 + IotProductThinkModelDO oldFunc = findFunctionByIdentifierAndType(
260 261 oldFunctionList, updateFunc.getIdentifier(), updateFunc.getType());
261 262 if (oldFunc != null) {
262 263 updateFunc.setId(oldFunc.getId());
263 264 }
264 265 });
265 266 // 过滤掉没有设置 ID 的对象
266   - List<IotProductThingModelDO> validUpdateList = updateList.stream()
  267 + List<IotProductThinkModelDO> validUpdateList = updateList.stream()
267 268 .filter(func -> func.getId() != null)
268 269 .collect(Collectors.toList());
269 270 // 执行批量更新
270 271 if (CollUtil.isNotEmpty(validUpdateList)) {
271   - productThingModelMapper.updateBatch(validUpdateList);
  272 + productThinkModelMapper.updateBatch(validUpdateList);
272 273 }
273 274 }
274 275  
275 276 // 删除数据库中的旧事件和服务列表
276 277 if (CollUtil.isNotEmpty(deleteList)) {
277   - Set<Long> idsToDelete = CollectionUtils.convertSet(deleteList, IotProductThingModelDO::getId);
278   - productThingModelMapper.deleteByIds(idsToDelete);
  278 + Set<Long> idsToDelete = CollectionUtils.convertSet(deleteList, IotProductThinkModelDO::getId);
  279 + productThinkModelMapper.deleteByIds(idsToDelete);
279 280 }
280 281 }
281 282  
282 283 /**
283 284 * 根据标识符和类型查找功能对象
284 285 */
285   - private IotProductThingModelDO findFunctionByIdentifierAndType(List<IotProductThingModelDO> functionList,
  286 + private IotProductThinkModelDO findFunctionByIdentifierAndType(List<IotProductThinkModelDO> functionList,
286 287 String identifier, Integer type) {
287 288 return CollUtil.findOne(functionList, func ->
288 289 Objects.equals(func.getIdentifier(), identifier) && Objects.equals(func.getType(), type));
... ... @@ -291,40 +292,40 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
291 292 /**
292 293 * 构建事件功能对象
293 294 */
294   - private IotProductThingModelDO buildEventFunctionDO(Long productId, String productKey, ThingModelEvent event) {
295   - return new IotProductThingModelDO()
  295 + private IotProductThinkModelDO buildEventFunctionDO(Long productId, String productKey, ThinkModelEvent event) {
  296 + return new IotProductThinkModelDO()
296 297 .setProductId(productId)
297 298 .setProductKey(productKey)
298 299 .setIdentifier(event.getIdentifier())
299 300 .setName(event.getName())
300 301 .setDescription(event.getDescription())
301   - .setType(IotProductThingModelTypeEnum.EVENT.getType())
  302 + .setType(IotProductThinkModelTypeEnum.EVENT.getType())
302 303 .setEvent(event);
303 304 }
304 305  
305 306 /**
306 307 * 构建服务功能对象
307 308 */
308   - private IotProductThingModelDO buildServiceFunctionDO(Long productId, String productKey, ThingModelService service) {
309   - return new IotProductThingModelDO()
  309 + private IotProductThinkModelDO buildServiceFunctionDO(Long productId, String productKey, ThinkModelService service) {
  310 + return new IotProductThinkModelDO()
310 311 .setProductId(productId)
311 312 .setProductKey(productKey)
312 313 .setIdentifier(service.getIdentifier())
313 314 .setName(service.getName())
314 315 .setDescription(service.getDescription())
315   - .setType(IotProductThingModelTypeEnum.SERVICE.getType())
  316 + .setType(IotProductThinkModelTypeEnum.SERVICE.getType())
316 317 .setService(service);
317 318 }
318 319  
319 320 /**
320 321 * 生成属性上报事件
321 322 */
322   - private ThingModelEvent generatePropertyPostEvent(List<IotProductThingModelDO> propertyList) {
  323 + private ThinkModelEvent generatePropertyPostEvent(List<IotProductThinkModelDO> propertyList) {
323 324 if (CollUtil.isEmpty(propertyList)) {
324 325 return null;
325 326 }
326 327  
327   - ThingModelEvent event = new ThingModelEvent()
  328 + ThinkModelEvent event = new ThinkModelEvent()
328 329 .setIdentifier("post")
329 330 .setName("属性上报")
330 331 .setType("info")
... ... @@ -332,15 +333,13 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
332 333 .setMethod("thing.event.property.post");
333 334  
334 335 // 将属性列表转换为事件的输出参数
335   - List<ThingModelArgument> outputData = new ArrayList<>();
336   - // TODO @puhui999: 需要重构
337   - for (IotProductThingModelDO functionDO : propertyList) {
338   - ThingModelProperty property = functionDO.getProperty();
339   - ThingModelArgument arg = new ThingModelArgument()
340   - .setIdentifier(property.getIdentifier())
341   - .setName(property.getName())
342   - //.setDataType(property.getDataType())
343   - .setDescription(property.getDescription())
  336 + List<ThinkModelArgument> outputData = new ArrayList<>();
  337 + for (IotProductThinkModelDO thinkModel : propertyList) {
  338 + ThinkModelArgument arg = new ThinkModelArgument()
  339 + .setIdentifier(thinkModel.getIdentifier())
  340 + .setName(thinkModel.getName())
  341 + .setProperty(thinkModel.getProperty())
  342 + .setDescription(thinkModel.getDescription())
344 343 .setDirection("output"); // 设置为输出参数
345 344 outputData.add(arg);
346 345 }
... ... @@ -351,24 +350,23 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
351 350 /**
352 351 * 生成属性设置服务
353 352 */
354   - private ThingModelService generatePropertySetService(List<IotProductThingModelDO> propertyList) {
  353 + private ThinkModelService generatePropertySetService(List<IotProductThinkModelDO> propertyList) {
355 354 if (propertyList == null || propertyList.isEmpty()) {
356 355 return null;
357 356 }
358 357  
359   - List<ThingModelArgument> inputData = new ArrayList<>();
360   - // TODO @puhui999: 需要重构
361   - for (IotProductThingModelDO functionDO : propertyList) {
362   - ThingModelProperty property = functionDO.getProperty();
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   - //}
  358 + List<ThinkModelArgument> inputData = new ArrayList<>();
  359 + for (IotProductThinkModelDO thinkModel : propertyList) {
  360 + ThinkModelProperty property = thinkModel.getProperty();
  361 + if (IotProductThinkModelAccessModeEnum.READ_WRITE.getMode().equals(property.getAccessMode())) {
  362 + ThinkModelArgument arg = new ThinkModelArgument()
  363 + .setIdentifier(property.getIdentifier())
  364 + .setName(property.getName())
  365 + .setProperty(property)
  366 + .setDescription(property.getDescription())
  367 + .setDirection("input"); // 设置为输入参数
  368 + inputData.add(arg);
  369 + }
372 370 }
373 371 if (inputData.isEmpty()) {
374 372 // 如果没有可写属性,不生成属性设置服务
... ... @@ -376,7 +374,7 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
376 374 }
377 375  
378 376 // 属性设置服务一般不需要输出参数
379   - return new ThingModelService()
  377 + return new ThinkModelService()
380 378 .setIdentifier("set")
381 379 .setName("属性设置")
382 380 .setCallType("async")
... ... @@ -390,31 +388,31 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
390 388 /**
391 389 * 生成属性获取服务
392 390 */
393   - private ThingModelService generatePropertyGetService(List<IotProductThingModelDO> propertyList) {
  391 + private ThinkModelService generatePropertyGetService(List<IotProductThinkModelDO> propertyList) {
394 392 if (propertyList == null || propertyList.isEmpty()) {
395 393 return null;
396 394 }
397   - // TODO @puhui999: 需要重构
398   - List<ThingModelArgument> outputData = new ArrayList<>();
399   - for (IotProductThingModelDO functionDO : propertyList) {
400   - ThingModelProperty property = functionDO.getProperty();
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   - //}
  395 +
  396 + List<ThinkModelArgument> outputData = new ArrayList<>();
  397 + for (IotProductThinkModelDO functionDO : propertyList) {
  398 + ThinkModelProperty property = functionDO.getProperty();
  399 + if (ObjectUtils.equalsAny(property.getAccessMode(),
  400 + IotProductThinkModelAccessModeEnum.READ_ONLY.getMode(), IotProductThinkModelAccessModeEnum.READ_WRITE.getMode())) {
  401 + ThinkModelArgument arg = new ThinkModelArgument()
  402 + .setIdentifier(property.getIdentifier())
  403 + .setName(property.getName())
  404 + .setProperty(property)
  405 + .setDescription(property.getDescription())
  406 + .setDirection("output"); // 设置为输出参数
  407 + outputData.add(arg);
  408 + }
411 409 }
412 410 if (outputData.isEmpty()) {
413 411 // 如果没有可读属性,不生成属性获取服务
414 412 return null;
415 413 }
416 414  
417   - ThingModelService service = new ThingModelService()
  415 + ThinkModelService service = new ThinkModelService()
418 416 .setIdentifier("get")
419 417 .setName("属性获取")
420 418 .setCallType("async")
... ... @@ -422,21 +420,22 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
422 420 .setMethod("thing.service.property.get");
423 421  
424 422 // 定义输入参数:属性标识符列表
425   - ThingModelArgument inputArg = new ThingModelArgument()
  423 + ThinkModelArgument inputArg = new ThinkModelArgument()
426 424 .setIdentifier("properties")
427 425 .setName("属性标识符列表")
428 426 .setDescription("需要获取的属性标识符列表")
429 427 .setDirection("input"); // 设置为输入参数
430 428  
431   - // 创建数组类型,元素类型为文本类型(字符串)
432   - ThingModelArrayDataSpecs arrayType = new ThingModelArrayDataSpecs();
  429 + // 创建数组类型,元素类型为文本类型(字符串)TODO @puhui999: 还得研究研究
  430 + ThinkModelArrayDataSpecs arrayType = new ThinkModelArrayDataSpecs();
433 431 arrayType.setDataType("array");
434   - //ThingModelArraySpecs arraySpecs = new ThingModelArraySpecs();
435   - ThingModelDateOrTextDataSpecs textType = new ThingModelDateOrTextDataSpecs();
  432 + inputArg.setProperty(new ThinkModelProperty().setIdentifier(inputArg.getIdentifier()).setName(inputArg.getName())
  433 + .setDescription(inputArg.getDescription()).setDataSpecs(arrayType));
  434 +
  435 + ThinkModelDateOrTextDataSpecs textType = new ThinkModelDateOrTextDataSpecs();
436 436 textType.setDataType("text");
437   - //arraySpecs.setItem(textType);
438   - //arrayType.setSpecs(arraySpecs);
439   - inputArg.setDataType(arrayType);
  437 + inputArg.setProperty(new ThinkModelProperty().setIdentifier(inputArg.getIdentifier()).setName(inputArg.getName())
  438 + .setDescription(inputArg.getDescription()).setDataSpecs(textType));
440 439  
441 440 service.setInputData(Collections.singletonList(inputArg));
442 441 service.setOutputData(outputData);
... ...