Commit fae17e91253fb8e23c6aecf955aa75603f437b15

Authored by puhui999
1 parent 3524bfd3

【功能完善】IOT: ThingModel 服务和事件

yudao-module-iot/yudao-module-iot-biz/pom.xml
@@ -27,13 +27,6 @@ @@ -27,13 +27,6 @@
27 27
28 <dependency> 28 <dependency>
29 <groupId>cn.iocoder.boot</groupId> 29 <groupId>cn.iocoder.boot</groupId>
30 - <artifactId>yudao-module-iot-plugin-api</artifactId>  
31 - <version>0.0.1</version>  
32 - <scope>compile</scope>  
33 - </dependency>  
34 -  
35 - <dependency>  
36 - <groupId>cn.iocoder.boot</groupId>  
37 <artifactId>yudao-spring-boot-starter-biz-tenant</artifactId> 30 <artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
38 </dependency> 31 </dependency>
39 32
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/IotProductThingModelController.http
@@ -176,7 +176,7 @@ tenant-id: {{adminTenentId}} @@ -176,7 +176,7 @@ tenant-id: {{adminTenentId}}
176 Authorization: Bearer {{token}} 176 Authorization: Bearer {{token}}
177 177
178 ### 请求 /iot/product-thing-model/get 接口 => 成功 178 ### 请求 /iot/product-thing-model/get 接口 => 成功
179 -GET {{baseUrl}}/iot/product-thing-model/get?id=40 179 +GET {{baseUrl}}/iot/product-thing-model/get?id=67
180 tenant-id: {{adminTenentId}} 180 tenant-id: {{adminTenentId}}
181 Authorization: Bearer {{token}} 181 Authorization: Bearer {{token}}
182 182
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelEvent.java
@@ -22,11 +22,6 @@ public class ThingModelEvent { @@ -22,11 +22,6 @@ public class ThingModelEvent {
22 */ 22 */
23 private String name; 23 private String name;
24 /** 24 /**
25 - * 事件描述  
26 - */  
27 - // TODO @puhui999: 考虑移除  
28 - private String description;  
29 - /**  
30 * 是否是标准品类的必选事件。 25 * 是否是标准品类的必选事件。
31 * 26 *
32 * - true:是 27 * - true:是
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelInputOutputParam.java
@@ -23,11 +23,6 @@ public class ThingModelInputOutputParam { @@ -23,11 +23,6 @@ public class ThingModelInputOutputParam {
23 */ 23 */
24 private String name; 24 private String name;
25 /** 25 /**
26 - * 参数描述  
27 - */  
28 - // TODO @puhui999: 考虑移除  
29 - private String description;  
30 - /**  
31 * 用于区分输入或输出参数 26 * 用于区分输入或输出参数
32 * 27 *
33 * 关联枚举 {@link IotProductThingModelParamDirectionEnum} 28 * 关联枚举 {@link IotProductThingModelParamDirectionEnum}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelProperty.java
@@ -25,11 +25,6 @@ public class ThingModelProperty { @@ -25,11 +25,6 @@ public class ThingModelProperty {
25 */ 25 */
26 private String name; 26 private String name;
27 /** 27 /**
28 - * 属性描述  
29 - */  
30 - // TODO @puhui999: 考虑移除  
31 - private String description;  
32 - /**  
33 * 云端可以对该属性进行的操作类型 28 * 云端可以对该属性进行的操作类型
34 * 29 *
35 * 枚举 {@link IotProductThingModelAccessModeEnum} 30 * 枚举 {@link IotProductThingModelAccessModeEnum}
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/ThingModelService.java
@@ -22,11 +22,6 @@ public class ThingModelService { @@ -22,11 +22,6 @@ public class ThingModelService {
22 */ 22 */
23 private String name; 23 private String name;
24 /** 24 /**
25 - * 服务描述  
26 - */  
27 - // TODO @puhui999: 考虑移除  
28 - private String description;  
29 - /**  
30 * 是否是标准品类的必选服务。 25 * 是否是标准品类的必选服务。
31 * 26 *
32 * - true:是 27 * - true:是
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thingmodel/model/dataType/ThingModelStructDataSpecs.java
@@ -26,10 +26,6 @@ public class ThingModelStructDataSpecs extends ThingModelDataSpecs { @@ -26,10 +26,6 @@ public class ThingModelStructDataSpecs extends ThingModelDataSpecs {
26 */ 26 */
27 private String name; 27 private String name;
28 /** 28 /**
29 - * 属性描述  
30 - */  
31 - private String description;  
32 - /**  
33 * 云端可以对该属性进行的操作类型 29 * 云端可以对该属性进行的操作类型
34 * 关联枚举 {@link IotProductThingModelAccessModeEnum} 30 * 关联枚举 {@link IotProductThingModelAccessModeEnum}
35 */ 31 */
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thingmodel/IotProductThingModelService.java
@@ -24,13 +24,6 @@ public interface IotProductThingModelService { @@ -24,13 +24,6 @@ public interface IotProductThingModelService {
24 Long createProductThingModel(@Valid IotProductThingModelSaveReqVO createReqVO); 24 Long createProductThingModel(@Valid IotProductThingModelSaveReqVO createReqVO);
25 25
26 /** 26 /**
27 - * 创建超级表数据模型  
28 - *  
29 - * @param productId 产品编号  
30 - */  
31 - void createSuperTableDataModel(Long productId);  
32 -  
33 - /**  
34 * 更新产品物模型 27 * 更新产品物模型
35 * 28 *
36 * @param updateReqVO 更新信息 29 * @param updateReqVO 更新信息
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thingmodel/IotProductThingModelServiceImpl.java
@@ -193,17 +193,17 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ @@ -193,17 +193,17 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
193 // 2.1 生成属性上报事件 193 // 2.1 生成属性上报事件
194 ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList); 194 ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList);
195 if (propertyPostEvent != null) { 195 if (propertyPostEvent != null) {
196 - newThingModelList.add(buildEventThingModelDO(productId, productKey, propertyPostEvent)); 196 + newThingModelList.add(buildEventThingModelDO(productId, productKey, propertyPostEvent, "属性上报事件"));
197 } 197 }
198 // 2.2 生成属性设置服务 198 // 2.2 生成属性设置服务
199 ThingModelService propertySetService = generatePropertySetService(propertyList); 199 ThingModelService propertySetService = generatePropertySetService(propertyList);
200 if (propertySetService != null) { 200 if (propertySetService != null) {
201 - newThingModelList.add(buildServiceThingModelDO(productId, productKey, propertySetService)); 201 + newThingModelList.add(buildServiceThingModelDO(productId, productKey, propertySetService, "属性设置服务"));
202 } 202 }
203 // 2.3 生成属性获取服务 203 // 2.3 生成属性获取服务
204 ThingModelService propertyGetService = generatePropertyGetService(propertyList); 204 ThingModelService propertyGetService = generatePropertyGetService(propertyList);
205 if (propertyGetService != null) { 205 if (propertyGetService != null) {
206 - newThingModelList.add(buildServiceThingModelDO(productId, productKey, propertyGetService)); 206 + newThingModelList.add(buildServiceThingModelDO(productId, productKey, propertyGetService,"属性获取服务"));
207 } 207 }
208 208
209 // 3.1 获取数据库中的默认的旧事件和服务列表 209 // 3.1 获取数据库中的默认的旧事件和服务列表
@@ -246,18 +246,20 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ @@ -246,18 +246,20 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
246 /** 246 /**
247 * 构建事件功能对象 247 * 构建事件功能对象
248 */ 248 */
249 - private IotProductThingModelDO buildEventThingModelDO(Long productId, String productKey, ThingModelEvent event) { 249 + private IotProductThingModelDO buildEventThingModelDO(Long productId, String productKey, ThingModelEvent event,
  250 + String description) {
250 return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey) 251 return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey)
251 - .setIdentifier(event.getIdentifier()).setName(event.getName()).setDescription(event.getDescription()) 252 + .setIdentifier(event.getIdentifier()).setName(event.getName()).setDescription(description)
252 .setType(IotProductThingModelTypeEnum.EVENT.getType()).setEvent(event); 253 .setType(IotProductThingModelTypeEnum.EVENT.getType()).setEvent(event);
253 } 254 }
254 255
255 /** 256 /**
256 * 构建服务功能对象 257 * 构建服务功能对象
257 */ 258 */
258 - private IotProductThingModelDO buildServiceThingModelDO(Long productId, String productKey, ThingModelService service) { 259 + private IotProductThingModelDO buildServiceThingModelDO(Long productId, String productKey, ThingModelService service,
  260 + String description) {
259 return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey) 261 return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey)
260 - .setIdentifier(service.getIdentifier()).setName(service.getName()).setDescription(service.getDescription()) 262 + .setIdentifier(service.getIdentifier()).setName(service.getName()).setDescription(description)
261 .setType(IotProductThingModelTypeEnum.SERVICE.getType()).setService(service); 263 .setType(IotProductThingModelTypeEnum.SERVICE.getType()).setService(service);
262 } 264 }
263 265
@@ -271,8 +273,8 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ @@ -271,8 +273,8 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
271 } 273 }
272 274
273 // 1.2 生成属性上报事件 275 // 1.2 生成属性上报事件
274 - return new ThingModelEvent().setIdentifier("post").setName("属性上报").setDescription("属性上报事件")  
275 - .setType(IotProductThingModelServiceEventTypeEnum.INFO.getType()).setMethod("thing.event.property.post") 276 + return new ThingModelEvent().setIdentifier("post").setName("属性上报").setMethod("thing.event.property.post")
  277 + .setType(IotProductThingModelServiceEventTypeEnum.INFO.getType())
276 .setOutputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.OUTPUT)); 278 .setOutputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.OUTPUT));
277 } 279 }
278 280
@@ -289,8 +291,8 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ @@ -289,8 +291,8 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
289 } 291 }
290 292
291 // 2. 生成属性设置服务 293 // 2. 生成属性设置服务
292 - return new ThingModelService().setIdentifier("set").setName("属性设置").setDescription("属性设置服务")  
293 - .setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType()).setMethod("thing.service.property.set") 294 + return new ThingModelService().setIdentifier("set").setName("属性设置").setMethod("thing.service.property.set")
  295 + .setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType())
294 .setInputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.INPUT)) 296 .setInputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.INPUT))
295 .setOutputParams(Collections.emptyList()); // 属性设置服务一般不需要输出参数 297 .setOutputParams(Collections.emptyList()); // 属性设置服务一般不需要输出参数
296 } 298 }
@@ -305,8 +307,8 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ @@ -305,8 +307,8 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
305 } 307 }
306 308
307 // 1.2 生成属性获取服务 309 // 1.2 生成属性获取服务
308 - return new ThingModelService().setIdentifier("get").setName("属性获取").setDescription("属性获取服务")  
309 - .setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType()).setMethod("thing.service.property.get") 310 + return new ThingModelService().setIdentifier("get").setName("属性获取").setMethod("thing.service.property.get")
  311 + .setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType())
310 .setInputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.INPUT)) 312 .setInputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.INPUT))
311 .setOutputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.OUTPUT)); 313 .setOutputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.OUTPUT));
312 } 314 }