【功能完善】IOT: ThingModel 服务和事件
This commit is contained in:
parent
3524bfd3b3
commit
fae17e9125
|
@ -25,13 +25,6 @@
|
|||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-module-iot-plugin-api</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-tenant</artifactId>
|
||||
|
|
|
@ -176,7 +176,7 @@ tenant-id: {{adminTenentId}}
|
|||
Authorization: Bearer {{token}}
|
||||
|
||||
### 请求 /iot/product-thing-model/get 接口 => 成功
|
||||
GET {{baseUrl}}/iot/product-thing-model/get?id=40
|
||||
GET {{baseUrl}}/iot/product-thing-model/get?id=67
|
||||
tenant-id: {{adminTenentId}}
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
|
|
|
@ -21,11 +21,6 @@ public class ThingModelEvent {
|
|||
* 事件名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 事件描述
|
||||
*/
|
||||
// TODO @puhui999: 考虑移除
|
||||
private String description;
|
||||
/**
|
||||
* 是否是标准品类的必选事件。
|
||||
*
|
||||
|
|
|
@ -22,11 +22,6 @@ public class ThingModelInputOutputParam {
|
|||
* 参数名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 参数描述
|
||||
*/
|
||||
// TODO @puhui999: 考虑移除
|
||||
private String description;
|
||||
/**
|
||||
* 用于区分输入或输出参数
|
||||
*
|
||||
|
|
|
@ -24,11 +24,6 @@ public class ThingModelProperty {
|
|||
* 属性名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 属性描述
|
||||
*/
|
||||
// TODO @puhui999: 考虑移除
|
||||
private String description;
|
||||
/**
|
||||
* 云端可以对该属性进行的操作类型
|
||||
*
|
||||
|
|
|
@ -21,11 +21,6 @@ public class ThingModelService {
|
|||
* 服务名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 服务描述
|
||||
*/
|
||||
// TODO @puhui999: 考虑移除
|
||||
private String description;
|
||||
/**
|
||||
* 是否是标准品类的必选服务。
|
||||
*
|
||||
|
|
|
@ -25,10 +25,6 @@ public class ThingModelStructDataSpecs extends ThingModelDataSpecs {
|
|||
* 属性名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 属性描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 云端可以对该属性进行的操作类型
|
||||
* 关联枚举 {@link IotProductThingModelAccessModeEnum}
|
||||
|
|
|
@ -23,13 +23,6 @@ public interface IotProductThingModelService {
|
|||
*/
|
||||
Long createProductThingModel(@Valid IotProductThingModelSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 创建超级表数据模型
|
||||
*
|
||||
* @param productId 产品编号
|
||||
*/
|
||||
void createSuperTableDataModel(Long productId);
|
||||
|
||||
/**
|
||||
* 更新产品物模型
|
||||
*
|
||||
|
|
|
@ -193,17 +193,17 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|||
// 2.1 生成属性上报事件
|
||||
ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList);
|
||||
if (propertyPostEvent != null) {
|
||||
newThingModelList.add(buildEventThingModelDO(productId, productKey, propertyPostEvent));
|
||||
newThingModelList.add(buildEventThingModelDO(productId, productKey, propertyPostEvent, "属性上报事件"));
|
||||
}
|
||||
// 2.2 生成属性设置服务
|
||||
ThingModelService propertySetService = generatePropertySetService(propertyList);
|
||||
if (propertySetService != null) {
|
||||
newThingModelList.add(buildServiceThingModelDO(productId, productKey, propertySetService));
|
||||
newThingModelList.add(buildServiceThingModelDO(productId, productKey, propertySetService, "属性设置服务"));
|
||||
}
|
||||
// 2.3 生成属性获取服务
|
||||
ThingModelService propertyGetService = generatePropertyGetService(propertyList);
|
||||
if (propertyGetService != null) {
|
||||
newThingModelList.add(buildServiceThingModelDO(productId, productKey, propertyGetService));
|
||||
newThingModelList.add(buildServiceThingModelDO(productId, productKey, propertyGetService,"属性获取服务"));
|
||||
}
|
||||
|
||||
// 3.1 获取数据库中的默认的旧事件和服务列表
|
||||
|
@ -246,18 +246,20 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|||
/**
|
||||
* 构建事件功能对象
|
||||
*/
|
||||
private IotProductThingModelDO buildEventThingModelDO(Long productId, String productKey, ThingModelEvent event) {
|
||||
private IotProductThingModelDO buildEventThingModelDO(Long productId, String productKey, ThingModelEvent event,
|
||||
String description) {
|
||||
return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey)
|
||||
.setIdentifier(event.getIdentifier()).setName(event.getName()).setDescription(event.getDescription())
|
||||
.setIdentifier(event.getIdentifier()).setName(event.getName()).setDescription(description)
|
||||
.setType(IotProductThingModelTypeEnum.EVENT.getType()).setEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建服务功能对象
|
||||
*/
|
||||
private IotProductThingModelDO buildServiceThingModelDO(Long productId, String productKey, ThingModelService service) {
|
||||
private IotProductThingModelDO buildServiceThingModelDO(Long productId, String productKey, ThingModelService service,
|
||||
String description) {
|
||||
return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey)
|
||||
.setIdentifier(service.getIdentifier()).setName(service.getName()).setDescription(service.getDescription())
|
||||
.setIdentifier(service.getIdentifier()).setName(service.getName()).setDescription(description)
|
||||
.setType(IotProductThingModelTypeEnum.SERVICE.getType()).setService(service);
|
||||
}
|
||||
|
||||
|
@ -271,8 +273,8 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|||
}
|
||||
|
||||
// 1.2 生成属性上报事件
|
||||
return new ThingModelEvent().setIdentifier("post").setName("属性上报").setDescription("属性上报事件")
|
||||
.setType(IotProductThingModelServiceEventTypeEnum.INFO.getType()).setMethod("thing.event.property.post")
|
||||
return new ThingModelEvent().setIdentifier("post").setName("属性上报").setMethod("thing.event.property.post")
|
||||
.setType(IotProductThingModelServiceEventTypeEnum.INFO.getType())
|
||||
.setOutputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.OUTPUT));
|
||||
}
|
||||
|
||||
|
@ -289,8 +291,8 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|||
}
|
||||
|
||||
// 2. 生成属性设置服务
|
||||
return new ThingModelService().setIdentifier("set").setName("属性设置").setDescription("属性设置服务")
|
||||
.setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType()).setMethod("thing.service.property.set")
|
||||
return new ThingModelService().setIdentifier("set").setName("属性设置").setMethod("thing.service.property.set")
|
||||
.setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType())
|
||||
.setInputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.INPUT))
|
||||
.setOutputParams(Collections.emptyList()); // 属性设置服务一般不需要输出参数
|
||||
}
|
||||
|
@ -305,8 +307,8 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|||
}
|
||||
|
||||
// 1.2 生成属性获取服务
|
||||
return new ThingModelService().setIdentifier("get").setName("属性获取").setDescription("属性获取服务")
|
||||
.setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType()).setMethod("thing.service.property.get")
|
||||
return new ThingModelService().setIdentifier("get").setName("属性获取").setMethod("thing.service.property.get")
|
||||
.setCallType(IotProductThingModelServiceCallTypeEnum.ASYNC.getType())
|
||||
.setInputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.INPUT))
|
||||
.setOutputParams(buildInputOutputParam(thingModelList, IotProductThingModelParamDirectionEnum.OUTPUT));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue