Commit 9e98768022f004d0a5832e6e65ab3d29c993ab8e

Authored by puhui999
1 parent f930f31f

【功能完善】IoT: 产品物模型 CRUD 接口测试

Showing 20 changed files with 382 additions and 231 deletions
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/IotProductThingModelController.http 0 → 100644
  1 +### 请求 /iot/product-thing-model/create 接口 => 成功
  2 +POST {{baseUrl}}/iot/product-thing-model/create
  3 +Content-Type: application/json
  4 +tenant-id: {{adminTenentId}}
  5 +Authorization: Bearer {{token}}
  6 +
  7 +{
  8 + "productId": 12,
  9 + "productKey": "CJVS54fObwZJ9Qe5CJVS54fObwZJ9Qe5",
  10 + "identifier": "Temperature",
  11 + "name": "温度",
  12 + "description": "当前温度值",
  13 + "type": 1,
  14 + "property": {
  15 + "identifier": "Temperature",
  16 + "name": "温度",
  17 + "accessMode": "r",
  18 + "required": true,
  19 + "dataType": "int",
  20 + "dataSpecs": {
  21 + "dataType": "int",
  22 + "max": "200",
  23 + "min": "0",
  24 + "step": "10",
  25 + "defaultValue": "30",
  26 + "unit": "%",
  27 + "unitName": "百分比"
  28 + },
  29 + "description": "当前温度值"
  30 + }
  31 +}
  32 +
  33 +### 请求 /iot/product-thing-model/create 接口 => 成功
  34 +POST {{baseUrl}}/iot/product-thing-model/create
  35 +Content-Type: application/json
  36 +tenant-id: {{adminTenentId}}
  37 +Authorization: Bearer {{token}}
  38 +
  39 +{
  40 + "productId": 12,
  41 + "productKey": "CJVS54fObwZJ9Qe5CJVS54fObwZJ9Qe5",
  42 + "identifier": "switch",
  43 + "name": "开关",
  44 + "description": "温度计开关",
  45 + "type": 1,
  46 + "property": {
  47 + "identifier": "switch",
  48 + "name": "开关",
  49 + "description": "温度计开关",
  50 + "accessMode": "rw",
  51 + "required": true,
  52 + "dataType": "bool",
  53 + "dataSpecsList": [
  54 + {
  55 + "dataType": "bool",
  56 + "name": "关",
  57 + "value": 0
  58 + },
  59 + {
  60 + "dataType": "bool",
  61 + "name": "开",
  62 + "value": 1
  63 + }
  64 + ]
  65 + }
  66 +}
  67 +
  68 +### 请求 /iot/product-thing-model/create 接口 => 成功
  69 +POST {{baseUrl}}/iot/product-thing-model/create
  70 +Content-Type: application/json
  71 +tenant-id: {{adminTenentId}}
  72 +Authorization: Bearer {{token}}
  73 +
  74 +{
  75 + "productId": 12,
  76 + "productKey": "CJVS54fObwZJ9Qe5CJVS54fObwZJ9Qe5",
  77 + "identifier": "argb",
  78 + "name": "温度计 argb 颜色",
  79 + "description": "温度计 argb 颜色",
  80 + "type": 1,
  81 + "property": {
  82 + "identifier": "argb",
  83 + "name": "温度计 argb 颜色",
  84 + "description": "温度计 argb 颜色",
  85 + "accessMode": "rw",
  86 + "required": true,
  87 + "dataType": "array",
  88 + "dataSpecs": {
  89 + "dataType": "array",
  90 + "size": 10,
  91 + "childDataType": "struct",
  92 + "dataSpecsList": [
  93 + {
  94 + "identifier": "switch",
  95 + "name": "开关",
  96 + "description": "温度计开关",
  97 + "accessMode": "rw",
  98 + "required": true,
  99 + "dataType": "struct",
  100 + "childDataType": "bool",
  101 + "dataSpecsList": [
  102 + {
  103 + "dataType": "bool",
  104 + "name": "关",
  105 + "value": 0
  106 + },
  107 + {
  108 + "dataType": "bool",
  109 + "name": "开",
  110 + "value": 1
  111 + }
  112 + ]
  113 + },
  114 + {
  115 + "identifier": "Temperature",
  116 + "name": "温度",
  117 + "accessMode": "r",
  118 + "required": true,
  119 + "dataType": "struct",
  120 + "childDataType": "int",
  121 + "dataSpecs": {
  122 + "dataType": "int",
  123 + "max": "200",
  124 + "min": "0",
  125 + "step": "10",
  126 + "defaultValue": "30",
  127 + "unit": "%",
  128 + "unitName": "百分比"
  129 + },
  130 + "description": "当前温度值"
  131 + }
  132 + ]
  133 + }
  134 + }
  135 +}
  136 +
  137 +### 请求 /iot/product-thing-model/update 接口 => 成功
  138 +PUT {{baseUrl}}/iot/product-thing-model/update
  139 +Content-Type: application/json
  140 +tenant-id: {{adminTenentId}}
  141 +Authorization: Bearer {{token}}
  142 +
  143 +{
  144 + "id": 33,
  145 + "productId": 12,
  146 + "productKey": "CJVS54fObwZJ9Qe5CJVS54fObwZJ9Qe5",
  147 + "identifier": "switch",
  148 + "name": "开关",
  149 + "description": "温度计开关",
  150 + "type": 1,
  151 + "property": {
  152 + "identifier": "switch",
  153 + "name": "开关",
  154 + "description": "温度计开关",
  155 + "accessMode": "r",
  156 + "required": true,
  157 + "dataType": "bool",
  158 + "dataSpecsList": [
  159 + {
  160 + "dataType": "bool",
  161 + "name": "关",
  162 + "value": 0
  163 + },
  164 + {
  165 + "dataType": "bool",
  166 + "name": "开",
  167 + "value": 1
  168 + }
  169 + ]
  170 + }
  171 +}
  172 +
  173 +### 请求 /iot/product-thing-model/delete 接口 => 成功
  174 +DELETE {{baseUrl}}/iot/product-thing-model/delete?id=36
  175 +tenant-id: {{adminTenentId}}
  176 +Authorization: Bearer {{token}}
  177 +
  178 +### 请求 /iot/product-thing-model/get 接口 => 成功
  179 +GET {{baseUrl}}/iot/product-thing-model/get?id=40
  180 +tenant-id: {{adminTenentId}}
  181 +Authorization: Bearer {{token}}
  182 +
  183 +
  184 +### 请求 /iot/product-thing-model/list-by-product-id 接口 => 成功
  185 +GET {{baseUrl}}/iot/product-thing-model/list-by-product-id?productId=1001
  186 +tenant-id: {{adminTenentId}}
  187 +Authorization: Bearer {{token}}
0 \ No newline at end of file 188 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/IotProductThingModelController.java
@@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel; @@ -3,12 +3,12 @@ package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel;
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.productthingmodel.vo.IotThinkModelFunctionPageReqVO;  
7 -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionRespVO;  
8 -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionSaveReqVO;  
9 -import cn.iocoder.yudao.module.iot.convert.thinkmodelfunction.IotThinkModelFunctionConvert; 6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelPageReqVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelRespVO;
  8 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelSaveReqVO;
  9 +import cn.iocoder.yudao.module.iot.convert.productthingmodel.IotProductThingModelConvert;
10 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO; 10 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
11 -import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService; 11 +import cn.iocoder.yudao.module.iot.service.productthingmodel.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/think-model-function") 27 +@RequestMapping("/iot/product-thing-model")
28 @Validated 28 @Validated
29 public class IotProductThingModelController { 29 public class IotProductThingModelController {
30 30
31 @Resource 31 @Resource
32 - private IotThinkModelFunctionService thinkModelFunctionService; 32 + private IotProductThingModelService thinkModelFunctionService;
33 33
34 @PostMapping("/create") 34 @PostMapping("/create")
35 @Operation(summary = "创建产品物模型") 35 @Operation(summary = "创建产品物模型")
36 - @PreAuthorize("@ss.hasPermission('iot:think-model-function:create')")  
37 - public CommonResult<Long> createThinkModelFunction(@Valid @RequestBody IotThinkModelFunctionSaveReqVO createReqVO) {  
38 - return success(thinkModelFunctionService.createThinkModelFunction(createReqVO)); 36 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:create')")
  37 + public CommonResult<Long> createProductThingModel(@Valid @RequestBody IotProductThingModelSaveReqVO createReqVO) {
  38 + return success(thinkModelFunctionService.createProductThingModel(createReqVO));
39 } 39 }
40 40
41 @PutMapping("/update") 41 @PutMapping("/update")
42 @Operation(summary = "更新产品物模型") 42 @Operation(summary = "更新产品物模型")
43 - @PreAuthorize("@ss.hasPermission('iot:think-model-function:update')")  
44 - public CommonResult<Boolean> updateThinkModelFunction(@Valid @RequestBody IotThinkModelFunctionSaveReqVO updateReqVO) {  
45 - thinkModelFunctionService.updateThinkModelFunction(updateReqVO); 43 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:update')")
  44 + public CommonResult<Boolean> updateProductThingModel(@Valid @RequestBody IotProductThingModelSaveReqVO updateReqVO) {
  45 + thinkModelFunctionService.updateProductThingModel(updateReqVO);
46 return success(true); 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:think-model-function:delete')")  
53 - public CommonResult<Boolean> deleteThinkModelFunction(@RequestParam("id") Long id) {  
54 - thinkModelFunctionService.deleteThinkModelFunction(id); 52 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:delete')")
  53 + public CommonResult<Boolean> deleteProductThingModel(@RequestParam("id") Long id) {
  54 + thinkModelFunctionService.deleteProductThingModel(id);
55 return success(true); 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:think-model-function:query')")  
62 - public CommonResult<IotThinkModelFunctionRespVO> getThinkModelFunction(@RequestParam("id") Long id) {  
63 - IotProductThingModelDO function = thinkModelFunctionService.getThinkModelFunction(id);  
64 - return success(IotThinkModelFunctionConvert.INSTANCE.convert(function)); 61 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:query')")
  62 + public CommonResult<IotProductThingModelRespVO> getProductThingModel(@RequestParam("id") Long id) {
  63 + IotProductThingModelDO function = thinkModelFunctionService.getProductThingModel(id);
  64 + return success(IotProductThingModelConvert.INSTANCE.convert(function));
65 } 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:think-model-function:query')")  
71 - public CommonResult<List<IotThinkModelFunctionRespVO>> getThinkModelFunctionListByProductId(@RequestParam("productId") Long productId) {  
72 - List<IotProductThingModelDO> list = thinkModelFunctionService.getThinkModelFunctionListByProductId(productId);  
73 - return success(IotThinkModelFunctionConvert.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 = thinkModelFunctionService.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:think-model-function:query')")  
79 - public CommonResult<PageResult<IotThinkModelFunctionRespVO>> getThinkModelFunctionPage(@Valid IotThinkModelFunctionPageReqVO pageReqVO) {  
80 - PageResult<IotProductThingModelDO> pageResult = thinkModelFunctionService.getThinkModelFunctionPage(pageReqVO);  
81 - return success(BeanUtils.toBean(pageResult, IotThinkModelFunctionRespVO.class)); 78 + @PreAuthorize("@ss.hasPermission('iot:product-thing-model:query')")
  79 + public CommonResult<PageResult<IotProductThingModelRespVO>> getProductThingModelPage(@Valid IotProductThingModelPageReqVO pageReqVO) {
  80 + PageResult<IotProductThingModelDO> pageResult = thinkModelFunctionService.getProductThingModelPage(pageReqVO);
  81 + return success(BeanUtils.toBean(pageResult, IotProductThingModelRespVO.class));
82 } 82 }
83 83
84 } 84 }
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/IotThinkModelFunctionController.http deleted
1 -### 请求 /iot/think-model-function/create 接口 => 成功  
2 -POST {{baseUrl}}/iot/think-model-function/create  
3 -Content-Type: application/json  
4 -tenant-id: {{adminTenentId}}  
5 -Authorization: Bearer {{token}}  
6 -  
7 -{  
8 - "productId": 1001,  
9 - "productKey": "smart-sensor-001",  
10 - "identifier": "Temperature",  
11 - "name": "温度",  
12 - "description": "当前温度值",  
13 - "type": 1,  
14 - "property": {  
15 - "identifier": "Temperature",  
16 - "name": "温度",  
17 - "accessMode": "r",  
18 - "required": true,  
19 - "dataType": {  
20 - "type": "float",  
21 - "specs": {  
22 - "min": -10.0,  
23 - "max": 100.0,  
24 - "step": 0.1,  
25 - "unit": "℃"  
26 - }  
27 - },  
28 - "description": "当前温度值"  
29 - }  
30 -}  
31 -  
32 -### 请求 /iot/think-model-function/create 接口 => 成功  
33 -POST {{baseUrl}}/iot/think-model-function/create  
34 -Content-Type: application/json  
35 -tenant-id: {{adminTenentId}}  
36 -Authorization: Bearer {{token}}  
37 -  
38 -{  
39 - "productId": 1001,  
40 - "productKey": "smart-sensor-001",  
41 - "identifier": "Humidity",  
42 - "name": "湿度",  
43 - "description": "当前湿度值",  
44 - "type": 1,  
45 - "property": {  
46 - "identifier": "Humidity",  
47 - "name": "湿度",  
48 - "accessMode": "r",  
49 - "required": true,  
50 - "dataType": {  
51 - "type": "float",  
52 - "specs": {  
53 - "min": 0.0,  
54 - "max": 100.0,  
55 - "step": 0.1,  
56 - "unit": "%"  
57 - }  
58 - },  
59 - "description": "当前湿度值"  
60 - }  
61 -}  
62 -  
63 -  
64 -  
65 -  
66 -### 请求 /iot/think-model-function/update 接口 => 成功  
67 -PUT {{baseUrl}}/iot/think-model-function/update  
68 -Content-Type: application/json  
69 -tenant-id: {{adminTenentId}}  
70 -Authorization: Bearer {{token}}  
71 -  
72 -{  
73 - "id": 11,  
74 - "productId": 1001,  
75 - "productKey": "smart-sensor-001",  
76 - "identifier": "Temperature",  
77 - "name": "温度",  
78 - "description": "当前温度值",  
79 - "type": 1,  
80 - "property": {  
81 - "identifier": "Temperature",  
82 - "name": "温度",  
83 - "accessMode": "r",  
84 - "required": true,  
85 - "dataType": {  
86 - "type": "float",  
87 - "specs": {  
88 - "min": -111.0,  
89 - "max": 222.0,  
90 - "step": 0.1,  
91 - "unit": "℃"  
92 - }  
93 - },  
94 - "description": "当前温度值"  
95 - }  
96 -}  
97 -  
98 -### 请求 /iot/think-model-function/delete 接口 => 成功  
99 -DELETE {{baseUrl}}/iot/think-model-function/delete?id=7  
100 -tenant-id: {{adminTenentId}}  
101 -Authorization: Bearer {{token}}  
102 -  
103 -### 请求 /iot/think-model-function/get 接口 => 成功  
104 -GET {{baseUrl}}/iot/think-model-function/get?id=10  
105 -tenant-id: {{adminTenentId}}  
106 -Authorization: Bearer {{token}}  
107 -  
108 -  
109 -### 请求 /iot/think-model-function/list-by-product-id 接口 => 成功  
110 -GET {{baseUrl}}/iot/think-model-function/list-by-product-id?productId=1001  
111 -tenant-id: {{adminTenentId}}  
112 -Authorization: Bearer {{token}}  
113 \ No newline at end of file 0 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelArrayDataSpecs.java
1 package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType; 1 package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
2 2
  3 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
  4 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
3 import lombok.Data; 5 import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
4 7
5 import java.util.List; 8 import java.util.List;
6 9
@@ -10,24 +13,21 @@ import java.util.List; @@ -10,24 +13,21 @@ import java.util.List;
10 * @author HUIHUI 13 * @author HUIHUI
11 */ 14 */
12 @Data 15 @Data
  16 +@EqualsAndHashCode(callSuper = true)
  17 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
13 public class ThingModelArrayDataSpecs extends ThingModelDataSpecs { 18 public class ThingModelArrayDataSpecs extends ThingModelDataSpecs {
14 19
15 /** 20 /**
16 * 数组中的元素个数。 21 * 数组中的元素个数。
17 */ 22 */
18 - private Long size; 23 + private Integer size;
19 /** 24 /**
20 * 数组中的元素的数据类型。可选值:struct、int、float、double 或 text。 25 * 数组中的元素的数据类型。可选值:struct、int、float、double 或 text。
21 */ 26 */
22 private String childDataType; 27 private String childDataType;
23 /** 28 /**
24 - * 数据类型(dataType)为非列表型(int、float、double、text、date、array)的数据规范存储在 dataSpecs 中。  
25 - * 仅当 dataType 不是列表型时,才传入此字段。  
26 - */  
27 - private ThingModelDataSpecs dataSpecs;  
28 - /**  
29 - * 数据类型(dataType)为列表型(enum、bool、struct)的数据规范存储在 dataSpecsList 中。  
30 - * 仅当 dataType 是列表型时,才传入此字段。 29 + * 数据类型(childDataType)为列表型 struct 的数据规范存储在 dataSpecsList 中。
  30 + * 此时 struct 取值范围为:int、float、double、text、date、enum、bool
31 */ 31 */
32 private List<ThingModelDataSpecs> dataSpecsList; 32 private List<ThingModelDataSpecs> dataSpecsList;
33 33
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelBoolOrEnumDataSpecs.java
1 package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType; 1 package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
2 2
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
3 import lombok.Data; 4 import lombok.Data;
4 import lombok.EqualsAndHashCode; 5 import lombok.EqualsAndHashCode;
5 6
@@ -12,6 +13,7 @@ import lombok.EqualsAndHashCode; @@ -12,6 +13,7 @@ import lombok.EqualsAndHashCode;
12 */ 13 */
13 @Data 14 @Data
14 @EqualsAndHashCode(callSuper = true) 15 @EqualsAndHashCode(callSuper = true)
  16 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
15 public class ThingModelBoolOrEnumDataSpecs extends ThingModelDataSpecs { 17 public class ThingModelBoolOrEnumDataSpecs extends ThingModelDataSpecs {
16 18
17 /** 19 /**
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelDataSpecs.java
@@ -22,7 +22,8 @@ import lombok.Data; @@ -22,7 +22,8 @@ import lombok.Data;
22 @JsonSubTypes.Type(value = ThingModelDateOrTextDataSpecs.class, name = "date"), 22 @JsonSubTypes.Type(value = ThingModelDateOrTextDataSpecs.class, name = "date"),
23 @JsonSubTypes.Type(value = ThingModelBoolOrEnumDataSpecs.class, name = "bool"), 23 @JsonSubTypes.Type(value = ThingModelBoolOrEnumDataSpecs.class, name = "bool"),
24 @JsonSubTypes.Type(value = ThingModelBoolOrEnumDataSpecs.class, name = "enum"), 24 @JsonSubTypes.Type(value = ThingModelBoolOrEnumDataSpecs.class, name = "enum"),
25 - @JsonSubTypes.Type(value = ThingModelArrayDataSpecs.class, name = "array") 25 + @JsonSubTypes.Type(value = ThingModelArrayDataSpecs.class, name = "array"),
  26 + @JsonSubTypes.Type(value = ThingModelStructDataSpecs.class, name = "struct")
26 }) 27 })
27 public abstract class ThingModelDataSpecs { 28 public abstract class ThingModelDataSpecs {
28 29
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelDateOrTextDataSpecs.java
1 package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType; 1 package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
2 2
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
3 import lombok.Data; 4 import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
4 6
5 /** 7 /**
6 * 物模型数据类型为时间型或文本型的 DataSpec 定义 8 * 物模型数据类型为时间型或文本型的 DataSpec 定义
@@ -10,6 +12,8 @@ import lombok.Data; @@ -10,6 +12,8 @@ import lombok.Data;
10 * @author HUIHUI 12 * @author HUIHUI
11 */ 13 */
12 @Data 14 @Data
  15 +@EqualsAndHashCode(callSuper = true)
  16 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
13 public class ThingModelDateOrTextDataSpecs extends ThingModelDataSpecs { 17 public class ThingModelDateOrTextDataSpecs extends ThingModelDataSpecs {
14 18
15 /** 19 /**
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelNumericDataSpec.java
1 package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType; 1 package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
2 2
  3 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
3 import lombok.Data; 4 import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
4 6
5 /** 7 /**
6 * 物模型数据类型为数值的 DataSpec 定义 8 * 物模型数据类型为数值的 DataSpec 定义
@@ -10,6 +12,8 @@ import lombok.Data; @@ -10,6 +12,8 @@ import lombok.Data;
10 * @author HUIHUI 12 * @author HUIHUI
11 */ 13 */
12 @Data 14 @Data
  15 +@EqualsAndHashCode(callSuper = true)
  16 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
13 public class ThingModelNumericDataSpec extends ThingModelDataSpecs { 17 public class ThingModelNumericDataSpec extends ThingModelDataSpecs {
14 18
15 /** 19 /**
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/thingmodel/dataType/ThingModelStructDataSpecs.java 0 → 100644
  1 +package cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType;
  2 +
  3 +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelAccessModeEnum;
  4 +import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * 物模型数据类型为 struct 的 DataSpec 定义
  12 + *
  13 + * @author HUIHUI
  14 + */
  15 +@Data
  16 +@EqualsAndHashCode(callSuper = true)
  17 +@JsonIgnoreProperties({"dataType"}) // 忽略子类中的 dataType 字段,从而避免重复。
  18 +public class ThingModelStructDataSpecs extends ThingModelDataSpecs {
  19 +
  20 + /**
  21 + * 属性标识符
  22 + */
  23 + private String identifier;
  24 + /**
  25 + * 属性名称
  26 + */
  27 + private String name;
  28 + /**
  29 + * 属性描述
  30 + */
  31 + private String description;
  32 + /**
  33 + * 云端可以对该属性进行的操作类型
  34 + * 关联枚举 {@link IotProductThingModelAccessModeEnum}
  35 + */
  36 + private String accessMode;
  37 + /**
  38 + * 是否是标准品类的必选服务。
  39 + *
  40 + * - true:是
  41 + * - false:否
  42 + */
  43 + private Boolean required;
  44 + /**
  45 + * struct 数据的数据类型
  46 + */
  47 + private String childDataType;
  48 + /**
  49 + * 数据类型(dataType)为非列表型(int、float、double、text、date、array)的数据规范存储在 dataSpecs 中
  50 + */
  51 + private ThingModelDataSpecs dataSpecs;
  52 + /**
  53 + * 数据类型(dataType)为列表型(enum、bool、struct)的数据规范存储在 dataSpecsList 中
  54 + */
  55 + private List<ThingModelDataSpecs> dataSpecsList;
  56 +
  57 +}
  58 +
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotThinkModelFunctionPageReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotProductThingModelPageReqVO.java
@@ -13,7 +13,7 @@ import lombok.ToString; @@ -13,7 +13,7 @@ import lombok.ToString;
13 @Data 13 @Data
14 @EqualsAndHashCode(callSuper = true) 14 @EqualsAndHashCode(callSuper = true)
15 @ToString(callSuper = true) 15 @ToString(callSuper = true)
16 -public class IotThinkModelFunctionPageReqVO extends PageParam { 16 +public class IotProductThingModelPageReqVO extends PageParam {
17 17
18 @Schema(description = "功能标识") 18 @Schema(description = "功能标识")
19 private String identifier; 19 private String identifier;
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotThinkModelFunctionRespVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotProductThingModelRespVO.java
@@ -13,7 +13,7 @@ import java.time.LocalDateTime; @@ -13,7 +13,7 @@ import java.time.LocalDateTime;
13 @Schema(description = "管理后台 - IoT 产品物模型 Response VO") 13 @Schema(description = "管理后台 - IoT 产品物模型 Response VO")
14 @Data 14 @Data
15 @ExcelIgnoreUnannotated 15 @ExcelIgnoreUnannotated
16 -public class IotThinkModelFunctionRespVO { 16 +public class IotProductThingModelRespVO {
17 17
18 @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21816") 18 @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21816")
19 @ExcelProperty("产品ID") 19 @ExcelProperty("产品ID")
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotThinkModelFunctionSaveReqVO.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/productthingmodel/vo/IotProductThingModelSaveReqVO.java
@@ -12,7 +12,7 @@ import lombok.Data; @@ -12,7 +12,7 @@ import lombok.Data;
12 12
13 @Schema(description = "管理后台 - IoT 产品物模型新增/修改 Request VO") 13 @Schema(description = "管理后台 - IoT 产品物模型新增/修改 Request VO")
14 @Data 14 @Data
15 -public class IotThinkModelFunctionSaveReqVO { 15 +public class IotProductThingModelSaveReqVO {
16 16
17 @Schema(description = "编号", example = "1") 17 @Schema(description = "编号", example = "1")
18 private Long id; 18 private Long id;
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/thinkmodelfunction/IotThinkModelFunctionConvert.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/productthingmodel/IotProductThingModelConvert.java
1 -package cn.iocoder.yudao.module.iot.convert.thinkmodelfunction; 1 +package cn.iocoder.yudao.module.iot.convert.productthingmodel;
2 2
3 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelEvent; 3 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelEvent;
4 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty; 4 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelProperty;
5 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelService; 5 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.ThingModelService;
6 -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionRespVO;  
7 -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionSaveReqVO; 6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelRespVO;
  7 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelSaveReqVO;
8 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO; 8 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
9 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; 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.factory.Mappers; 13 import org.mapstruct.factory.Mappers;
13 14
14 import java.util.List; 15 import java.util.List;
15 import java.util.Objects; 16 import java.util.Objects;
16 17
17 @Mapper 18 @Mapper
18 -public interface IotThinkModelFunctionConvert { 19 +public interface IotProductThingModelConvert {
19 20
20 - IotThinkModelFunctionConvert INSTANCE = Mappers.getMapper(IotThinkModelFunctionConvert.class); 21 + IotProductThingModelConvert INSTANCE = Mappers.getMapper(IotProductThingModelConvert.class);
21 22
22 // 将 SaveReqVO 转换为 DO 23 // 将 SaveReqVO 转换为 DO
23 @Mapping(target = "property", expression = "java(convertToProperty(bean))") 24 @Mapping(target = "property", expression = "java(convertToProperty(bean))")
24 @Mapping(target = "event", expression = "java(convertToEvent(bean))") 25 @Mapping(target = "event", expression = "java(convertToEvent(bean))")
25 @Mapping(target = "service", expression = "java(convertToService(bean))") 26 @Mapping(target = "service", expression = "java(convertToService(bean))")
26 - IotProductThingModelDO convert(IotThinkModelFunctionSaveReqVO bean); 27 + IotProductThingModelDO convert(IotProductThingModelSaveReqVO bean);
27 28
28 - default ThingModelProperty convertToProperty(IotThinkModelFunctionSaveReqVO bean) { 29 + // 将 DO 转换为 RespVO
  30 + @Mapping(target = "property", source = "property")
  31 + @Mapping(target = "event", source = "event")
  32 + @Mapping(target = "service", source = "service")
  33 + IotProductThingModelRespVO convert(IotProductThingModelDO bean);
  34 +
  35 + // 批量转换
  36 + List<IotProductThingModelRespVO> convertList(List<IotProductThingModelDO> list);
  37 +
  38 + @Named("convertToProperty")
  39 + default ThingModelProperty convertToProperty(IotProductThingModelSaveReqVO bean) {
29 if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { 40 if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
30 return bean.getProperty(); 41 return bean.getProperty();
31 } 42 }
32 return null; 43 return null;
33 } 44 }
34 45
35 - default ThingModelEvent convertToEvent(IotThinkModelFunctionSaveReqVO bean) { 46 + @Named("convertToEvent")
  47 + default ThingModelEvent convertToEvent(IotProductThingModelSaveReqVO bean) {
36 if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.EVENT.getType())) { 48 if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.EVENT.getType())) {
37 return bean.getEvent(); 49 return bean.getEvent();
38 } 50 }
39 return null; 51 return null;
40 } 52 }
41 53
42 - default ThingModelService convertToService(IotThinkModelFunctionSaveReqVO bean) { 54 + @Named("convertToService")
  55 + default ThingModelService convertToService(IotProductThingModelSaveReqVO bean) {
43 if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.SERVICE.getType())) { 56 if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.SERVICE.getType())) {
44 return bean.getService(); 57 return bean.getService();
45 } 58 }
46 return null; 59 return null;
47 } 60 }
48 61
49 - // 将 DO 转换为 RespVO  
50 - @Mapping(target = "property", source = "property")  
51 - @Mapping(target = "event", source = "event")  
52 - @Mapping(target = "service", source = "service")  
53 - IotThinkModelFunctionRespVO convert(IotProductThingModelDO bean);  
54 -  
55 - // 批量转换  
56 - List<IotThinkModelFunctionRespVO> convertList(List<IotProductThingModelDO> list);  
57 } 62 }
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/productthingmodel/IotProductThingModelDO.java
@@ -23,8 +23,8 @@ import lombok.NoArgsConstructor; @@ -23,8 +23,8 @@ import lombok.NoArgsConstructor;
23 * 23 *
24 * @author 芋道源码 24 * @author 芋道源码
25 */ 25 */
26 -@TableName(value = "iot_think_model_function", autoResultMap = true)  
27 -@KeySequence("iot_think_model_function_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 26 +@TableName(value = "iot_product_thing_model", autoResultMap = true)
  27 +@KeySequence("iot_product_thing_model_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
28 @Data 28 @Data
29 @Builder 29 @Builder
30 @NoArgsConstructor 30 @NoArgsConstructor
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/thinkmodelfunction/IotThinkModelFunctionMapper.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/mysql/thinkmodelfunction/IotProductThingModelMapper.java
@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction; @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction;
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6 -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionPageReqVO; 6 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelPageReqVO;
7 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO; 7 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
8 import org.apache.ibatis.annotations.Mapper; 8 import org.apache.ibatis.annotations.Mapper;
9 9
@@ -15,9 +15,9 @@ import java.util.List; @@ -15,9 +15,9 @@ import java.util.List;
15 * @author 芋道源码 15 * @author 芋道源码
16 */ 16 */
17 @Mapper 17 @Mapper
18 -public interface IotThinkModelFunctionMapper extends BaseMapperX<IotProductThingModelDO> { 18 +public interface IotProductThingModelMapper extends BaseMapperX<IotProductThingModelDO> {
19 19
20 - default PageResult<IotProductThingModelDO> selectPage(IotThinkModelFunctionPageReqVO reqVO) { 20 + default PageResult<IotProductThingModelDO> selectPage(IotProductThingModelPageReqVO reqVO) {
21 return selectPage(reqVO, new LambdaQueryWrapperX<IotProductThingModelDO>() 21 return selectPage(reqVO, new LambdaQueryWrapperX<IotProductThingModelDO>()
22 .eqIfPresent(IotProductThingModelDO::getIdentifier, reqVO.getIdentifier()) 22 .eqIfPresent(IotProductThingModelDO::getIdentifier, reqVO.getIdentifier())
23 .likeIfPresent(IotProductThingModelDO::getName, reqVO.getName()) 23 .likeIfPresent(IotProductThingModelDO::getName, reqVO.getName())
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceDataServiceImpl.java
@@ -15,7 +15,7 @@ import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; @@ -15,7 +15,7 @@ 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.thingmodel.IotProductThingModelTypeEnum; 16 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
17 import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService; 17 import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService;
18 -import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService; 18 +import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
19 import jakarta.annotation.Resource; 19 import jakarta.annotation.Resource;
20 import jakarta.validation.Valid; 20 import jakarta.validation.Valid;
21 import lombok.extern.slf4j.Slf4j; 21 import lombok.extern.slf4j.Slf4j;
@@ -40,7 +40,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService { @@ -40,7 +40,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
40 @Resource 40 @Resource
41 private IotThingModelMessageService thingModelMessageService; 41 private IotThingModelMessageService thingModelMessageService;
42 @Resource 42 @Resource
43 - private IotThinkModelFunctionService thinkModelFunctionService; 43 + private IotProductThingModelService thinkModelFunctionService;
44 @Resource 44 @Resource
45 private TdEngineDMLMapper tdEngineDMLMapper; 45 private TdEngineDMLMapper tdEngineDMLMapper;
46 46
@@ -73,7 +73,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService { @@ -73,7 +73,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService {
73 // 1. 获取设备信息 73 // 1. 获取设备信息
74 IotDeviceDO device = deviceService.getDevice(deviceDataReqVO.getDeviceId()); 74 IotDeviceDO device = deviceService.getDevice(deviceDataReqVO.getDeviceId());
75 // 2. 获取设备属性最新数据 75 // 2. 获取设备属性最新数据
76 - List<IotProductThingModelDO> thinkModelFunctionList = thinkModelFunctionService.getThinkModelFunctionListByProductKey(device.getProductKey()); 76 + List<IotProductThingModelDO> thinkModelFunctionList = thinkModelFunctionService.getProductThingModelListByProductKey(device.getProductKey());
77 thinkModelFunctionList = thinkModelFunctionList.stream() 77 thinkModelFunctionList = thinkModelFunctionList.stream()
78 .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType() 78 .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType()
79 .equals(function.getType())).toList(); 79 .equals(function.getType())).toList();
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/product/IotProductServiceImpl.java
@@ -7,7 +7,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.product.vo.product.IotProduc @@ -7,7 +7,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.product.vo.product.IotProduc
7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; 7 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
8 import cn.iocoder.yudao.module.iot.dal.mysql.product.IotProductMapper; 8 import cn.iocoder.yudao.module.iot.dal.mysql.product.IotProductMapper;
9 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum; 9 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum;
10 -import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService; 10 +import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
11 import com.baomidou.dynamic.datasource.annotation.DSTransactional; 11 import com.baomidou.dynamic.datasource.annotation.DSTransactional;
12 import jakarta.annotation.Resource; 12 import jakarta.annotation.Resource;
13 import org.springframework.context.annotation.Lazy; 13 import org.springframework.context.annotation.Lazy;
@@ -34,7 +34,7 @@ public class IotProductServiceImpl implements IotProductService { @@ -34,7 +34,7 @@ public class IotProductServiceImpl implements IotProductService {
34 34
35 @Resource 35 @Resource
36 @Lazy 36 @Lazy
37 - private IotThinkModelFunctionService thinkModelFunctionService; 37 + private IotProductThingModelService thinkModelFunctionService;
38 38
39 @Override 39 @Override
40 public Long createProduct(IotProductSaveReqVO createReqVO) { 40 public Long createProduct(IotProductSaveReqVO createReqVO) {
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thinkmodelfunction/IotThinkModelFunctionService.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/productthingmodel/IotProductThingModelService.java
1 -package cn.iocoder.yudao.module.iot.service.thinkmodelfunction; 1 +package cn.iocoder.yudao.module.iot.service.productthingmodel;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionPageReqVO;  
5 -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionSaveReqVO; 4 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelPageReqVO;
  5 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelSaveReqVO;
6 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO; 6 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
7 import jakarta.validation.Valid; 7 import jakarta.validation.Valid;
8 8
@@ -13,7 +13,7 @@ import java.util.List; @@ -13,7 +13,7 @@ import java.util.List;
13 * 13 *
14 * @author 芋道源码 14 * @author 芋道源码
15 */ 15 */
16 -public interface IotThinkModelFunctionService { 16 +public interface IotProductThingModelService {
17 17
18 /** 18 /**
19 * 创建产品物模型 19 * 创建产品物模型
@@ -21,7 +21,7 @@ public interface IotThinkModelFunctionService { @@ -21,7 +21,7 @@ public interface IotThinkModelFunctionService {
21 * @param createReqVO 创建信息 21 * @param createReqVO 创建信息
22 * @return 编号 22 * @return 编号
23 */ 23 */
24 - Long createThinkModelFunction(@Valid IotThinkModelFunctionSaveReqVO createReqVO); 24 + Long createProductThingModel(@Valid IotProductThingModelSaveReqVO createReqVO);
25 25
26 26
27 /** 27 /**
@@ -29,14 +29,14 @@ public interface IotThinkModelFunctionService { @@ -29,14 +29,14 @@ public interface IotThinkModelFunctionService {
29 * 29 *
30 * @param updateReqVO 更新信息 30 * @param updateReqVO 更新信息
31 */ 31 */
32 - void updateThinkModelFunction(@Valid IotThinkModelFunctionSaveReqVO updateReqVO); 32 + void updateProductThingModel(@Valid IotProductThingModelSaveReqVO updateReqVO);
33 33
34 /** 34 /**
35 * 删除产品物模型 35 * 删除产品物模型
36 * 36 *
37 * @param id 编号 37 * @param id 编号
38 */ 38 */
39 - void deleteThinkModelFunction(Long id); 39 + void deleteProductThingModel(Long id);
40 40
41 /** 41 /**
42 * 获得产品物模型 42 * 获得产品物模型
@@ -44,7 +44,7 @@ public interface IotThinkModelFunctionService { @@ -44,7 +44,7 @@ public interface IotThinkModelFunctionService {
44 * @param id 编号 44 * @param id 编号
45 * @return 产品物模型 45 * @return 产品物模型
46 */ 46 */
47 - IotProductThingModelDO getThinkModelFunction(Long id); 47 + IotProductThingModelDO getProductThingModel(Long id);
48 48
49 /** 49 /**
50 * 获得产品物模型列表 50 * 获得产品物模型列表
@@ -52,7 +52,7 @@ public interface IotThinkModelFunctionService { @@ -52,7 +52,7 @@ public interface IotThinkModelFunctionService {
52 * @param productId 产品编号 52 * @param productId 产品编号
53 * @return 产品物模型列表 53 * @return 产品物模型列表
54 */ 54 */
55 - List<IotProductThingModelDO> getThinkModelFunctionListByProductId(Long productId); 55 + List<IotProductThingModelDO> getProductThingModelListByProductId(Long productId);
56 56
57 /** 57 /**
58 * 获得产品物模型分页 58 * 获得产品物模型分页
@@ -60,7 +60,7 @@ public interface IotThinkModelFunctionService { @@ -60,7 +60,7 @@ public interface IotThinkModelFunctionService {
60 * @param pageReqVO 分页查询 60 * @param pageReqVO 分页查询
61 * @return 产品物模型分页 61 * @return 产品物模型分页
62 */ 62 */
63 - PageResult<IotProductThingModelDO> getThinkModelFunctionPage(IotThinkModelFunctionPageReqVO pageReqVO); 63 + PageResult<IotProductThingModelDO> getProductThingModelPage(IotProductThingModelPageReqVO pageReqVO);
64 64
65 /** 65 /**
66 * 创建超级表数据模型 66 * 创建超级表数据模型
@@ -75,5 +75,6 @@ public interface IotThinkModelFunctionService { @@ -75,5 +75,6 @@ public interface IotThinkModelFunctionService {
75 * @param productKey 产品 Key 75 * @param productKey 产品 Key
76 * @return 产品物模型列表 76 * @return 产品物模型列表
77 */ 77 */
78 - List<IotProductThingModelDO> getThinkModelFunctionListByProductKey(String productKey); 78 + List<IotProductThingModelDO> getProductThingModelListByProductKey(String productKey);
  79 +
79 } 80 }
80 \ No newline at end of file 81 \ No newline at end of file
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thinkmodelfunction/IotThinkModelFunctionServiceImpl.java renamed to yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/productthingmodel/IotProductThingModelServiceImpl.java
1 -package cn.iocoder.yudao.module.iot.service.thinkmodelfunction; 1 +package cn.iocoder.yudao.module.iot.service.productthingmodel;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.util.ObjectUtil; 4 import cn.hutool.core.util.ObjectUtil;
@@ -10,12 +10,12 @@ import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel @@ -10,12 +10,12 @@ import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel
10 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArgument; 10 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArgument;
11 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArrayDataSpecs; 11 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelArrayDataSpecs;
12 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelDateOrTextDataSpecs; 12 import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.thingmodel.dataType.ThingModelDateOrTextDataSpecs;
13 -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionPageReqVO;  
14 -import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotThinkModelFunctionSaveReqVO;  
15 -import cn.iocoder.yudao.module.iot.convert.thinkmodelfunction.IotThinkModelFunctionConvert; 13 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelPageReqVO;
  14 +import cn.iocoder.yudao.module.iot.controller.admin.productthingmodel.vo.IotProductThingModelSaveReqVO;
  15 +import cn.iocoder.yudao.module.iot.convert.productthingmodel.IotProductThingModelConvert;
16 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; 16 import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
17 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO; 17 import cn.iocoder.yudao.module.iot.dal.dataobject.productthingmodel.IotProductThingModelDO;
18 -import cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction.IotThinkModelFunctionMapper; 18 +import cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction.IotProductThingModelMapper;
19 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum; 19 import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum;
20 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; 20 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
21 import cn.iocoder.yudao.module.iot.service.product.IotProductService; 21 import cn.iocoder.yudao.module.iot.service.product.IotProductService;
@@ -41,10 +41,10 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*; @@ -41,10 +41,10 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
41 @Service 41 @Service
42 @Validated 42 @Validated
43 @Slf4j 43 @Slf4j
44 -public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionService { 44 +public class IotProductThingModelServiceImpl implements IotProductThingModelService {
45 45
46 @Resource 46 @Resource
47 - private IotThinkModelFunctionMapper thinkModelFunctionMapper; 47 + private IotProductThingModelMapper productThingModelMapper;
48 48
49 @Resource 49 @Resource
50 private IotProductService productService; 50 private IotProductService productService;
@@ -53,7 +53,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -53,7 +53,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
53 53
54 @Override 54 @Override
55 @Transactional(rollbackFor = Exception.class) 55 @Transactional(rollbackFor = Exception.class)
56 - public Long createThinkModelFunction(IotThinkModelFunctionSaveReqVO createReqVO) { 56 + public Long createProductThingModel(IotProductThingModelSaveReqVO createReqVO) {
57 // 1. 校验功能标识符在同一产品下是否唯一 57 // 1. 校验功能标识符在同一产品下是否唯一
58 validateIdentifierUnique(createReqVO.getProductId(), createReqVO.getIdentifier()); 58 validateIdentifierUnique(createReqVO.getProductId(), createReqVO.getIdentifier());
59 59
@@ -67,12 +67,12 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -67,12 +67,12 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
67 validateProductStatus(createReqVO.getProductId()); 67 validateProductStatus(createReqVO.getProductId());
68 68
69 // 5. 插入数据库 69 // 5. 插入数据库
70 - IotProductThingModelDO function = IotThinkModelFunctionConvert.INSTANCE.convert(createReqVO);  
71 - thinkModelFunctionMapper.insert(function); 70 + IotProductThingModelDO function = IotProductThingModelConvert.INSTANCE.convert(createReqVO);
  71 + productThingModelMapper.insert(function);
72 72
73 // 6. 如果创建的是属性,需要更新默认的事件和服务 73 // 6. 如果创建的是属性,需要更新默认的事件和服务
74 if (Objects.equals(createReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { 74 if (Objects.equals(createReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
75 - createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey()); 75 + //createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey());
76 } 76 }
77 return function.getId(); 77 return function.getId();
78 } 78 }
@@ -95,14 +95,14 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -95,14 +95,14 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
95 } 95 }
96 96
97 private void validateNameUnique(Long productId, String name) { 97 private void validateNameUnique(Long productId, String name) {
98 - IotProductThingModelDO function = thinkModelFunctionMapper.selectByProductIdAndName(productId, name); 98 + IotProductThingModelDO function = productThingModelMapper.selectByProductIdAndName(productId, name);
99 if (function != null) { 99 if (function != null) {
100 throw exception(THINK_MODEL_FUNCTION_NAME_EXISTS); 100 throw exception(THINK_MODEL_FUNCTION_NAME_EXISTS);
101 } 101 }
102 } 102 }
103 103
104 private void validateIdentifierUnique(Long productId, String identifier) { 104 private void validateIdentifierUnique(Long productId, String identifier) {
105 - IotProductThingModelDO function = thinkModelFunctionMapper.selectByProductIdAndIdentifier(productId, identifier); 105 + IotProductThingModelDO function = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
106 if (function != null) { 106 if (function != null) {
107 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS); 107 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS);
108 } 108 }
@@ -110,9 +110,9 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -110,9 +110,9 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
110 110
111 @Override 111 @Override
112 @Transactional(rollbackFor = Exception.class) 112 @Transactional(rollbackFor = Exception.class)
113 - public void updateThinkModelFunction(IotThinkModelFunctionSaveReqVO updateReqVO) { 113 + public void updateProductThingModel(IotProductThingModelSaveReqVO updateReqVO) {
114 // 1. 校验功能是否存在 114 // 1. 校验功能是否存在
115 - validateThinkModelFunctionExists(updateReqVO.getId()); 115 + validateproductThingModelMapperExists(updateReqVO.getId());
116 116
117 // 2. 校验功能标识符是否唯一 117 // 2. 校验功能标识符是否唯一
118 validateIdentifierUniqueForUpdate(updateReqVO.getId(), updateReqVO.getProductId(), updateReqVO.getIdentifier()); 118 validateIdentifierUniqueForUpdate(updateReqVO.getId(), updateReqVO.getProductId(), updateReqVO.getIdentifier());
@@ -121,8 +121,8 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -121,8 +121,8 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
121 validateProductStatus(updateReqVO.getProductId()); 121 validateProductStatus(updateReqVO.getProductId());
122 122
123 // 4. 更新数据库 123 // 4. 更新数据库
124 - IotProductThingModelDO thinkModelFunction = IotThinkModelFunctionConvert.INSTANCE.convert(updateReqVO);  
125 - thinkModelFunctionMapper.updateById(thinkModelFunction); 124 + IotProductThingModelDO productThingModelDO = IotProductThingModelConvert.INSTANCE.convert(updateReqVO);
  125 + productThingModelMapper.updateById(productThingModelDO);
126 126
127 // 5. 如果更新的是属性,需要更新默认的事件和服务 127 // 5. 如果更新的是属性,需要更新默认的事件和服务
128 if (Objects.equals(updateReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { 128 if (Objects.equals(updateReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
@@ -131,7 +131,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -131,7 +131,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
131 } 131 }
132 132
133 private void validateIdentifierUniqueForUpdate(Long id, Long productId, String identifier) { 133 private void validateIdentifierUniqueForUpdate(Long id, Long productId, String identifier) {
134 - IotProductThingModelDO function = thinkModelFunctionMapper.selectByProductIdAndIdentifier(productId, identifier); 134 + IotProductThingModelDO function = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
135 if (function != null && ObjectUtil.notEqual(function.getId(), id)) { 135 if (function != null && ObjectUtil.notEqual(function.getId(), id)) {
136 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS); 136 throw exception(THINK_MODEL_FUNCTION_IDENTIFIER_EXISTS);
137 } 137 }
@@ -139,9 +139,9 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -139,9 +139,9 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
139 139
140 @Override 140 @Override
141 @Transactional(rollbackFor = Exception.class) 141 @Transactional(rollbackFor = Exception.class)
142 - public void deleteThinkModelFunction(Long id) { 142 + public void deleteProductThingModel(Long id) {
143 // 1. 校验功能是否存在 143 // 1. 校验功能是否存在
144 - IotProductThingModelDO functionDO = thinkModelFunctionMapper.selectById(id); 144 + IotProductThingModelDO functionDO = productThingModelMapper.selectById(id);
145 if (functionDO == null) { 145 if (functionDO == null) {
146 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS); 146 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS);
147 } 147 }
@@ -150,7 +150,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -150,7 +150,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
150 validateProductStatus(functionDO.getProductId()); 150 validateProductStatus(functionDO.getProductId());
151 151
152 // 2. 删除功能 152 // 2. 删除功能
153 - thinkModelFunctionMapper.deleteById(id); 153 + productThingModelMapper.deleteById(id);
154 154
155 // 3. 如果删除的是属性,需要更新默认的事件和服务 155 // 3. 如果删除的是属性,需要更新默认的事件和服务
156 if (Objects.equals(functionDO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { 156 if (Objects.equals(functionDO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
@@ -163,25 +163,25 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -163,25 +163,25 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
163 * 163 *
164 * @param id 功能编号 164 * @param id 功能编号
165 */ 165 */
166 - private void validateThinkModelFunctionExists(Long id) {  
167 - if (thinkModelFunctionMapper.selectById(id) == null) { 166 + private void validateproductThingModelMapperExists(Long id) {
  167 + if (productThingModelMapper.selectById(id) == null) {
168 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS); 168 throw exception(THINK_MODEL_FUNCTION_NOT_EXISTS);
169 } 169 }
170 } 170 }
171 171
172 @Override 172 @Override
173 - public IotProductThingModelDO getThinkModelFunction(Long id) {  
174 - return thinkModelFunctionMapper.selectById(id); 173 + public IotProductThingModelDO getProductThingModel(Long id) {
  174 + return productThingModelMapper.selectById(id);
175 } 175 }
176 176
177 @Override 177 @Override
178 - public List<IotProductThingModelDO> getThinkModelFunctionListByProductId(Long productId) {  
179 - return thinkModelFunctionMapper.selectListByProductId(productId); 178 + public List<IotProductThingModelDO> getProductThingModelListByProductId(Long productId) {
  179 + return productThingModelMapper.selectListByProductId(productId);
180 } 180 }
181 181
182 @Override 182 @Override
183 - public PageResult<IotProductThingModelDO> getThinkModelFunctionPage(IotThinkModelFunctionPageReqVO pageReqVO) {  
184 - return thinkModelFunctionMapper.selectPage(pageReqVO); 183 + public PageResult<IotProductThingModelDO> getProductThingModelPage(IotProductThingModelPageReqVO pageReqVO) {
  184 + return productThingModelMapper.selectPage(pageReqVO);
185 } 185 }
186 186
187 @Override 187 @Override
@@ -190,23 +190,24 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -190,23 +190,24 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
190 IotProductDO product = productService.getProduct(productId); 190 IotProductDO product = productService.getProduct(productId);
191 191
192 // 2. 查询产品的物模型功能列表 192 // 2. 查询产品的物模型功能列表
193 - List<IotProductThingModelDO> functionList = thinkModelFunctionMapper.selectListByProductId(productId); 193 + List<IotProductThingModelDO> functionList = productThingModelMapper.selectListByProductId(productId);
194 194
195 // 3. 生成 TDengine 的数据模型 195 // 3. 生成 TDengine 的数据模型
196 dbStructureDataService.createSuperTableDataModel(product, functionList); 196 dbStructureDataService.createSuperTableDataModel(product, functionList);
197 } 197 }
198 198
199 @Override 199 @Override
200 - public List<IotProductThingModelDO> getThinkModelFunctionListByProductKey(String productKey) {  
201 - return thinkModelFunctionMapper.selectListByProductKey(productKey); 200 + public List<IotProductThingModelDO> getProductThingModelListByProductKey(String productKey) {
  201 + return productThingModelMapper.selectListByProductKey(productKey);
202 } 202 }
203 203
  204 + // TODO @puhui999: 需要重构
204 /** 205 /**
205 * 创建默认的事件和服务 206 * 创建默认的事件和服务
206 */ 207 */
207 public void createDefaultEventsAndServices(Long productId, String productKey) { 208 public void createDefaultEventsAndServices(Long productId, String productKey) {
208 // 1. 获取当前属性列表 209 // 1. 获取当前属性列表
209 - List<IotProductThingModelDO> propertyList = thinkModelFunctionMapper 210 + List<IotProductThingModelDO> propertyList = productThingModelMapper
210 .selectListByProductIdAndType(productId, IotProductThingModelTypeEnum.PROPERTY.getType()); 211 .selectListByProductIdAndType(productId, IotProductThingModelTypeEnum.PROPERTY.getType());
211 212
212 // 2. 生成新的事件和服务列表 213 // 2. 生成新的事件和服务列表
@@ -231,7 +232,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -231,7 +232,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
231 } 232 }
232 233
233 // 3. 获取数据库中的默认的旧事件和服务列表 234 // 3. 获取数据库中的默认的旧事件和服务列表
234 - List<IotProductThingModelDO> oldFunctionList = thinkModelFunctionMapper.selectListByProductIdAndIdentifiersAndTypes( 235 + List<IotProductThingModelDO> oldFunctionList = productThingModelMapper.selectListByProductIdAndIdentifiersAndTypes(
235 productId, 236 productId,
236 Arrays.asList("post", "set", "get"), 237 Arrays.asList("post", "set", "get"),
237 Arrays.asList(IotProductThingModelTypeEnum.EVENT.getType(), IotProductThingModelTypeEnum.SERVICE.getType()) 238 Arrays.asList(IotProductThingModelTypeEnum.EVENT.getType(), IotProductThingModelTypeEnum.SERVICE.getType())
@@ -249,7 +250,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -249,7 +250,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
249 // 3.2 批量执行数据库操作 250 // 3.2 批量执行数据库操作
250 // 新增数据库中的新事件和服务列表 251 // 新增数据库中的新事件和服务列表
251 if (CollUtil.isNotEmpty(createList)) { 252 if (CollUtil.isNotEmpty(createList)) {
252 - thinkModelFunctionMapper.insertBatch(createList); 253 + productThingModelMapper.insertBatch(createList);
253 } 254 }
254 // 更新数据库中的事件和服务列表 255 // 更新数据库中的事件和服务列表
255 if (CollUtil.isNotEmpty(updateList)) { 256 if (CollUtil.isNotEmpty(updateList)) {
@@ -267,14 +268,14 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe @@ -267,14 +268,14 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe
267 .collect(Collectors.toList()); 268 .collect(Collectors.toList());
268 // 执行批量更新 269 // 执行批量更新
269 if (CollUtil.isNotEmpty(validUpdateList)) { 270 if (CollUtil.isNotEmpty(validUpdateList)) {
270 - thinkModelFunctionMapper.updateBatch(validUpdateList); 271 + productThingModelMapper.updateBatch(validUpdateList);
271 } 272 }
272 } 273 }
273 274
274 // 删除数据库中的旧事件和服务列表 275 // 删除数据库中的旧事件和服务列表
275 if (CollUtil.isNotEmpty(deleteList)) { 276 if (CollUtil.isNotEmpty(deleteList)) {
276 Set<Long> idsToDelete = CollectionUtils.convertSet(deleteList, IotProductThingModelDO::getId); 277 Set<Long> idsToDelete = CollectionUtils.convertSet(deleteList, IotProductThingModelDO::getId);
277 - thinkModelFunctionMapper.deleteByIds(idsToDelete); 278 + productThingModelMapper.deleteByIds(idsToDelete);
278 } 279 }
279 } 280 }
280 281
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageServiceImpl.java
@@ -19,7 +19,7 @@ import cn.iocoder.yudao.module.iot.enums.IotConstants; @@ -19,7 +19,7 @@ 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.thingmodel.IotProductThingModelTypeEnum; 20 import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum;
21 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; 21 import cn.iocoder.yudao.module.iot.service.device.IotDeviceService;
22 -import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService; 22 +import cn.iocoder.yudao.module.iot.service.productthingmodel.IotProductThingModelService;
23 import jakarta.annotation.Resource; 23 import jakarta.annotation.Resource;
24 import lombok.extern.slf4j.Slf4j; 24 import lombok.extern.slf4j.Slf4j;
25 import org.springframework.beans.factory.annotation.Value; 25 import org.springframework.beans.factory.annotation.Value;
@@ -47,7 +47,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ @@ -47,7 +47,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
47 private String url; 47 private String url;
48 48
49 @Resource 49 @Resource
50 - private IotThinkModelFunctionService iotThinkModelFunctionService; 50 + private IotProductThingModelService iotProductThingModelService;
51 @Resource 51 @Resource
52 private IotDeviceService iotDeviceService; 52 private IotDeviceService iotDeviceService;
53 @Resource 53 @Resource
@@ -91,8 +91,8 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ @@ -91,8 +91,8 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ
91 } 91 }
92 92
93 private List<IotProductThingModelDO> getValidFunctionList(String productKey) { 93 private List<IotProductThingModelDO> getValidFunctionList(String productKey) {
94 - return iotThinkModelFunctionService  
95 - .getThinkModelFunctionListByProductKey(productKey) 94 + return iotProductThingModelService
  95 + .getProductThingModelListByProductKey(productKey)
96 .stream() 96 .stream()
97 .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(function.getType())) 97 .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(function.getType()))
98 .toList(); 98 .toList();