Commit 8454a10cea33f74c1c82fa74f4e5fac9cd654e31

Authored by puhui999
1 parent de78cc92

【代码优化】IOT: ThingModel 评审优化

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