|
@@ -5,14 +5,14 @@ import cn.hutool.core.util.ObjectUtil;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelEvent;
|
|
import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelEvent;
|
|
-import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelInputOutputParam;
|
|
|
|
|
|
+import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelParam;
|
|
import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelService;
|
|
import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.model.ThingModelService;
|
|
-import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelPageReqVO;
|
|
|
|
-import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotProductThingModelSaveReqVO;
|
|
|
|
-import cn.iocoder.yudao.module.iot.convert.thingmodel.IotProductThingModelConvert;
|
|
|
|
|
|
+import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelPageReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.iot.controller.admin.thingmodel.vo.IotThingModelSaveReqVO;
|
|
|
|
+import cn.iocoder.yudao.module.iot.convert.thingmodel.IotThingModelConvert;
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
|
|
import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO;
|
|
-import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotProductThingModelDO;
|
|
|
|
-import cn.iocoder.yudao.module.iot.dal.mysql.thingmodel.IotProductThingModelMapper;
|
|
|
|
|
|
+import cn.iocoder.yudao.module.iot.dal.dataobject.thingmodel.IotThingModelDO;
|
|
|
|
+import cn.iocoder.yudao.module.iot.dal.mysql.thingmodel.IotThingModelMapper;
|
|
import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum;
|
|
import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum;
|
|
import cn.iocoder.yudao.module.iot.enums.thingmodel.*;
|
|
import cn.iocoder.yudao.module.iot.enums.thingmodel.*;
|
|
import cn.iocoder.yudao.module.iot.service.product.IotProductService;
|
|
import cn.iocoder.yudao.module.iot.service.product.IotProductService;
|
|
@@ -36,17 +36,17 @@ import static cn.iocoder.yudao.module.iot.enums.ErrorCodeConstants.*;
|
|
@Service
|
|
@Service
|
|
@Validated
|
|
@Validated
|
|
@Slf4j
|
|
@Slf4j
|
|
-public class IotProductThingModelServiceImpl implements IotProductThingModelService {
|
|
|
|
|
|
+public class IotThingModelServiceImpl implements IotThingModelService {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private IotProductThingModelMapper productThingModelMapper;
|
|
|
|
|
|
+ private IotThingModelMapper thingModelMapper;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private IotProductService productService;
|
|
private IotProductService productService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public Long createProductThingModel(IotProductThingModelSaveReqVO createReqVO) {
|
|
|
|
|
|
+ public Long createThingModel(IotThingModelSaveReqVO createReqVO) {
|
|
// 1. 校验功能标识符在同一产品下是否唯一
|
|
// 1. 校验功能标识符在同一产品下是否唯一
|
|
validateIdentifierUnique(createReqVO.getProductId(), createReqVO.getIdentifier());
|
|
validateIdentifierUnique(createReqVO.getProductId(), createReqVO.getIdentifier());
|
|
|
|
|
|
@@ -60,11 +60,11 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
validateProductStatus(createReqVO.getProductId());
|
|
validateProductStatus(createReqVO.getProductId());
|
|
|
|
|
|
// 5. 插入数据库
|
|
// 5. 插入数据库
|
|
- IotProductThingModelDO thingModel = IotProductThingModelConvert.INSTANCE.convert(createReqVO);
|
|
|
|
- productThingModelMapper.insert(thingModel);
|
|
|
|
|
|
+ IotThingModelDO thingModel = IotThingModelConvert.INSTANCE.convert(createReqVO);
|
|
|
|
+ thingModelMapper.insert(thingModel);
|
|
|
|
|
|
// 6. 如果创建的是属性,需要更新默认的事件和服务
|
|
// 6. 如果创建的是属性,需要更新默认的事件和服务
|
|
- if (Objects.equals(createReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
|
|
|
|
|
|
+ if (Objects.equals(createReqVO.getType(), IotThingModelTypeEnum.PROPERTY.getType())) {
|
|
createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey());
|
|
createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey());
|
|
}
|
|
}
|
|
// TODO @puhui999: 服务和事件的情况 method 怎么设置?在前端设置还是后端设置?
|
|
// TODO @puhui999: 服务和事件的情况 method 怎么设置?在前端设置还是后端设置?
|
|
@@ -73,7 +73,7 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public void updateProductThingModel(IotProductThingModelSaveReqVO updateReqVO) {
|
|
|
|
|
|
+ public void updateThingModel(IotThingModelSaveReqVO updateReqVO) {
|
|
// 1. 校验功能是否存在
|
|
// 1. 校验功能是否存在
|
|
validateProductThingModelMapperExists(updateReqVO.getId());
|
|
validateProductThingModelMapperExists(updateReqVO.getId());
|
|
|
|
|
|
@@ -84,20 +84,20 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
validateProductStatus(updateReqVO.getProductId());
|
|
validateProductStatus(updateReqVO.getProductId());
|
|
|
|
|
|
// 4. 更新数据库
|
|
// 4. 更新数据库
|
|
- IotProductThingModelDO thingModel = IotProductThingModelConvert.INSTANCE.convert(updateReqVO);
|
|
|
|
- productThingModelMapper.updateById(thingModel);
|
|
|
|
|
|
+ IotThingModelDO thingModel = IotThingModelConvert.INSTANCE.convert(updateReqVO);
|
|
|
|
+ thingModelMapper.updateById(thingModel);
|
|
|
|
|
|
// 5. 如果更新的是属性,需要更新默认的事件和服务
|
|
// 5. 如果更新的是属性,需要更新默认的事件和服务
|
|
- if (Objects.equals(updateReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
|
|
|
|
|
|
+ if (Objects.equals(updateReqVO.getType(), IotThingModelTypeEnum.PROPERTY.getType())) {
|
|
createDefaultEventsAndServices(updateReqVO.getProductId(), updateReqVO.getProductKey());
|
|
createDefaultEventsAndServices(updateReqVO.getProductId(), updateReqVO.getProductKey());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
- public void deleteProductThingModel(Long id) {
|
|
|
|
|
|
+ public void deleteThingModel(Long id) {
|
|
// 1. 校验功能是否存在
|
|
// 1. 校验功能是否存在
|
|
- IotProductThingModelDO thingModel = productThingModelMapper.selectById(id);
|
|
|
|
|
|
+ IotThingModelDO thingModel = thingModelMapper.selectById(id);
|
|
if (thingModel == null) {
|
|
if (thingModel == null) {
|
|
throw exception(THING_MODEL_NOT_EXISTS);
|
|
throw exception(THING_MODEL_NOT_EXISTS);
|
|
}
|
|
}
|
|
@@ -106,32 +106,32 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
validateProductStatus(thingModel.getProductId());
|
|
validateProductStatus(thingModel.getProductId());
|
|
|
|
|
|
// 2. 删除功能
|
|
// 2. 删除功能
|
|
- productThingModelMapper.deleteById(id);
|
|
|
|
|
|
+ thingModelMapper.deleteById(id);
|
|
|
|
|
|
// 3. 如果删除的是属性,需要更新默认的事件和服务
|
|
// 3. 如果删除的是属性,需要更新默认的事件和服务
|
|
- if (Objects.equals(thingModel.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) {
|
|
|
|
|
|
+ if (Objects.equals(thingModel.getType(), IotThingModelTypeEnum.PROPERTY.getType())) {
|
|
createDefaultEventsAndServices(thingModel.getProductId(), thingModel.getProductKey());
|
|
createDefaultEventsAndServices(thingModel.getProductId(), thingModel.getProductKey());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public IotProductThingModelDO getProductThingModel(Long id) {
|
|
|
|
- return productThingModelMapper.selectById(id);
|
|
|
|
|
|
+ public IotThingModelDO getThingModel(Long id) {
|
|
|
|
+ return thingModelMapper.selectById(id);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<IotProductThingModelDO> getProductThingModelListByProductId(Long productId) {
|
|
|
|
- return productThingModelMapper.selectListByProductId(productId);
|
|
|
|
|
|
+ public List<IotThingModelDO> getThingModelListByProductId(Long productId) {
|
|
|
|
+ return thingModelMapper.selectListByProductId(productId);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public PageResult<IotProductThingModelDO> getProductThingModelPage(IotProductThingModelPageReqVO pageReqVO) {
|
|
|
|
- return productThingModelMapper.selectPage(pageReqVO);
|
|
|
|
|
|
+ public PageResult<IotThingModelDO> getProductThingModelPage(IotThingModelPageReqVO pageReqVO) {
|
|
|
|
+ return thingModelMapper.selectPage(pageReqVO);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<IotProductThingModelDO> getProductThingModelListByProductKey(String productKey) {
|
|
|
|
- return productThingModelMapper.selectListByProductKey(productKey);
|
|
|
|
|
|
+ public List<IotThingModelDO> getProductThingModelListByProductKey(String productKey) {
|
|
|
|
+ return thingModelMapper.selectListByProductKey(productKey);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -140,13 +140,13 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
* @param id 功能编号
|
|
* @param id 功能编号
|
|
*/
|
|
*/
|
|
private void validateProductThingModelMapperExists(Long id) {
|
|
private void validateProductThingModelMapperExists(Long id) {
|
|
- if (productThingModelMapper.selectById(id) == null) {
|
|
|
|
|
|
+ if (thingModelMapper.selectById(id) == null) {
|
|
throw exception(THING_MODEL_NOT_EXISTS);
|
|
throw exception(THING_MODEL_NOT_EXISTS);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void validateIdentifierUniqueForUpdate(Long id, Long productId, String identifier) {
|
|
private void validateIdentifierUniqueForUpdate(Long id, Long productId, String identifier) {
|
|
- IotProductThingModelDO thingModel = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
|
|
|
|
|
|
+ IotThingModelDO thingModel = thingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
|
|
if (thingModel != null && ObjectUtil.notEqual(thingModel.getId(), id)) {
|
|
if (thingModel != null && ObjectUtil.notEqual(thingModel.getId(), id)) {
|
|
throw exception(THING_MODEL_IDENTIFIER_EXISTS);
|
|
throw exception(THING_MODEL_IDENTIFIER_EXISTS);
|
|
}
|
|
}
|
|
@@ -167,14 +167,14 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
}
|
|
}
|
|
|
|
|
|
private void validateNameUnique(Long productId, String name) {
|
|
private void validateNameUnique(Long productId, String name) {
|
|
- IotProductThingModelDO thingModel = productThingModelMapper.selectByProductIdAndName(productId, name);
|
|
|
|
|
|
+ IotThingModelDO thingModel = thingModelMapper.selectByProductIdAndName(productId, name);
|
|
if (thingModel != null) {
|
|
if (thingModel != null) {
|
|
throw exception(THING_MODEL_NAME_EXISTS);
|
|
throw exception(THING_MODEL_NAME_EXISTS);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void validateIdentifierUnique(Long productId, String identifier) {
|
|
private void validateIdentifierUnique(Long productId, String identifier) {
|
|
- IotProductThingModelDO thingModel = productThingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
|
|
|
|
|
|
+ IotThingModelDO thingModel = thingModelMapper.selectByProductIdAndIdentifier(productId, identifier);
|
|
if (thingModel != null) {
|
|
if (thingModel != null) {
|
|
throw exception(THING_MODEL_IDENTIFIER_EXISTS);
|
|
throw exception(THING_MODEL_IDENTIFIER_EXISTS);
|
|
}
|
|
}
|
|
@@ -185,11 +185,11 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
*/
|
|
*/
|
|
public void createDefaultEventsAndServices(Long productId, String productKey) {
|
|
public void createDefaultEventsAndServices(Long productId, String productKey) {
|
|
// 1. 获取当前属性列表
|
|
// 1. 获取当前属性列表
|
|
- List<IotProductThingModelDO> propertyList = productThingModelMapper
|
|
|
|
- .selectListByProductIdAndType(productId, IotProductThingModelTypeEnum.PROPERTY.getType());
|
|
|
|
|
|
+ List<IotThingModelDO> propertyList = thingModelMapper
|
|
|
|
+ .selectListByProductIdAndType(productId, IotThingModelTypeEnum.PROPERTY.getType());
|
|
|
|
|
|
// 2. 生成新的事件和服务列表
|
|
// 2. 生成新的事件和服务列表
|
|
- List<IotProductThingModelDO> newThingModelList = new ArrayList<>();
|
|
|
|
|
|
+ List<IotThingModelDO> newThingModelList = new ArrayList<>();
|
|
// 2.1 生成属性上报事件
|
|
// 2.1 生成属性上报事件
|
|
ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList);
|
|
ThingModelEvent propertyPostEvent = generatePropertyPostEvent(propertyList);
|
|
if (propertyPostEvent != null) {
|
|
if (propertyPostEvent != null) {
|
|
@@ -207,10 +207,10 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
}
|
|
}
|
|
|
|
|
|
// 3.1 获取数据库中的默认的旧事件和服务列表
|
|
// 3.1 获取数据库中的默认的旧事件和服务列表
|
|
- List<IotProductThingModelDO> oldThingModelList = productThingModelMapper.selectListByProductIdAndIdentifiersAndTypes(
|
|
|
|
|
|
+ List<IotThingModelDO> oldThingModelList = thingModelMapper.selectListByProductIdAndIdentifiersAndTypes(
|
|
productId,
|
|
productId,
|
|
Arrays.asList("post", "set", "get"),
|
|
Arrays.asList("post", "set", "get"),
|
|
- Arrays.asList(IotProductThingModelTypeEnum.EVENT.getType(), IotProductThingModelTypeEnum.SERVICE.getType())
|
|
|
|
|
|
+ Arrays.asList(IotThingModelTypeEnum.EVENT.getType(), IotThingModelTypeEnum.SERVICE.getType())
|
|
);
|
|
);
|
|
// 3.2 创建默认的事件和服务
|
|
// 3.2 创建默认的事件和服务
|
|
createDefaultEventsAndServices(oldThingModelList, newThingModelList);
|
|
createDefaultEventsAndServices(oldThingModelList, newThingModelList);
|
|
@@ -219,9 +219,9 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
/**
|
|
/**
|
|
* 创建默认的事件和服务
|
|
* 创建默认的事件和服务
|
|
*/
|
|
*/
|
|
- private void createDefaultEventsAndServices(List<IotProductThingModelDO> oldThingModelList, List<IotProductThingModelDO> newThingModelList) {
|
|
|
|
|
|
+ private void createDefaultEventsAndServices(List<IotThingModelDO> oldThingModelList, List<IotThingModelDO> newThingModelList) {
|
|
// 1.1 使用 diffList 方法比较新旧列表
|
|
// 1.1 使用 diffList 方法比较新旧列表
|
|
- List<List<IotProductThingModelDO>> diffResult = diffList(oldThingModelList, newThingModelList,
|
|
|
|
|
|
+ List<List<IotThingModelDO>> diffResult = diffList(oldThingModelList, newThingModelList,
|
|
(oldVal, newVal) -> {
|
|
(oldVal, newVal) -> {
|
|
// 继续使用 identifier 和 type 进行比较:这样可以准确地匹配对应的功能对象。
|
|
// 继续使用 identifier 和 type 进行比较:这样可以准确地匹配对应的功能对象。
|
|
boolean same = Objects.equals(oldVal.getIdentifier(), newVal.getIdentifier())
|
|
boolean same = Objects.equals(oldVal.getIdentifier(), newVal.getIdentifier())
|
|
@@ -233,40 +233,40 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
});
|
|
});
|
|
// 1.2 批量添加、修改、删除
|
|
// 1.2 批量添加、修改、删除
|
|
if (CollUtil.isNotEmpty(diffResult.get(0))) {
|
|
if (CollUtil.isNotEmpty(diffResult.get(0))) {
|
|
- productThingModelMapper.insertBatch(diffResult.get(0));
|
|
|
|
|
|
+ thingModelMapper.insertBatch(diffResult.get(0));
|
|
}
|
|
}
|
|
if (CollUtil.isNotEmpty(diffResult.get(1))) {
|
|
if (CollUtil.isNotEmpty(diffResult.get(1))) {
|
|
- productThingModelMapper.updateBatch(diffResult.get(1));
|
|
|
|
|
|
+ thingModelMapper.updateBatch(diffResult.get(1));
|
|
}
|
|
}
|
|
if (CollUtil.isNotEmpty(diffResult.get(2))) {
|
|
if (CollUtil.isNotEmpty(diffResult.get(2))) {
|
|
- productThingModelMapper.deleteByIds(convertSet(diffResult.get(2), IotProductThingModelDO::getId));
|
|
|
|
|
|
+ thingModelMapper.deleteByIds(convertSet(diffResult.get(2), IotThingModelDO::getId));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 构建事件功能对象
|
|
* 构建事件功能对象
|
|
*/
|
|
*/
|
|
- private IotProductThingModelDO buildEventThingModelDO(Long productId, String productKey, ThingModelEvent event,
|
|
|
|
- String description) {
|
|
|
|
- return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey)
|
|
|
|
|
|
+ private IotThingModelDO buildEventThingModelDO(Long productId, String productKey, ThingModelEvent event,
|
|
|
|
+ String description) {
|
|
|
|
+ return new IotThingModelDO().setProductId(productId).setProductKey(productKey)
|
|
.setIdentifier(event.getIdentifier()).setName(event.getName()).setDescription(description)
|
|
.setIdentifier(event.getIdentifier()).setName(event.getName()).setDescription(description)
|
|
- .setType(IotProductThingModelTypeEnum.EVENT.getType()).setEvent(event);
|
|
|
|
|
|
+ .setType(IotThingModelTypeEnum.EVENT.getType()).setEvent(event);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 构建服务功能对象
|
|
* 构建服务功能对象
|
|
*/
|
|
*/
|
|
- private IotProductThingModelDO buildServiceThingModelDO(Long productId, String productKey, ThingModelService service,
|
|
|
|
- String description) {
|
|
|
|
- return new IotProductThingModelDO().setProductId(productId).setProductKey(productKey)
|
|
|
|
|
|
+ private IotThingModelDO buildServiceThingModelDO(Long productId, String productKey, ThingModelService service,
|
|
|
|
+ String description) {
|
|
|
|
+ return new IotThingModelDO().setProductId(productId).setProductKey(productKey)
|
|
.setIdentifier(service.getIdentifier()).setName(service.getName()).setDescription(description)
|
|
.setIdentifier(service.getIdentifier()).setName(service.getName()).setDescription(description)
|
|
- .setType(IotProductThingModelTypeEnum.SERVICE.getType()).setService(service);
|
|
|
|
|
|
+ .setType(IotThingModelTypeEnum.SERVICE.getType()).setService(service);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生成属性上报事件
|
|
* 生成属性上报事件
|
|
*/
|
|
*/
|
|
- private ThingModelEvent generatePropertyPostEvent(List<IotProductThingModelDO> thingModelList) {
|
|
|
|
|
|
+ private ThingModelEvent generatePropertyPostEvent(List<IotThingModelDO> thingModelList) {
|
|
// 1.1 没有属性则不生成
|
|
// 1.1 没有属性则不生成
|
|
if (CollUtil.isEmpty(thingModelList)) {
|
|
if (CollUtil.isEmpty(thingModelList)) {
|
|
return null;
|
|
return null;
|
|
@@ -274,17 +274,17 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
|
|
|
|
// 1.2 生成属性上报事件
|
|
// 1.2 生成属性上报事件
|
|
return new ThingModelEvent().setIdentifier("post").setName("属性上报").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));
|
|
|
|
|
|
+ .setType(IotThingModelServiceEventTypeEnum.INFO.getType())
|
|
|
|
+ .setOutputParams(buildInputOutputParam(thingModelList, IotThingModelParamDirectionEnum.OUTPUT));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生成属性设置服务
|
|
* 生成属性设置服务
|
|
*/
|
|
*/
|
|
- private ThingModelService generatePropertySetService(List<IotProductThingModelDO> thingModelList) {
|
|
|
|
|
|
+ private ThingModelService generatePropertySetService(List<IotThingModelDO> thingModelList) {
|
|
// 1.1 过滤出所有可写属性
|
|
// 1.1 过滤出所有可写属性
|
|
thingModelList = filterList(thingModelList, thingModel ->
|
|
thingModelList = filterList(thingModelList, thingModel ->
|
|
- IotProductThingModelAccessModeEnum.READ_WRITE.getMode().equals(thingModel.getProperty().getAccessMode()));
|
|
|
|
|
|
+ IotThingModelAccessModeEnum.READ_WRITE.getMode().equals(thingModel.getProperty().getAccessMode()));
|
|
// 1.2 没有可写属性则不生成
|
|
// 1.2 没有可写属性则不生成
|
|
if (CollUtil.isEmpty(thingModelList)) {
|
|
if (CollUtil.isEmpty(thingModelList)) {
|
|
return null;
|
|
return null;
|
|
@@ -292,15 +292,15 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
|
|
|
|
// 2. 生成属性设置服务
|
|
// 2. 生成属性设置服务
|
|
return new ThingModelService().setIdentifier("set").setName("属性设置").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))
|
|
|
|
|
|
+ .setCallType(IotThingModelServiceCallTypeEnum.ASYNC.getType())
|
|
|
|
+ .setInputParams(buildInputOutputParam(thingModelList, IotThingModelParamDirectionEnum.INPUT))
|
|
.setOutputParams(Collections.emptyList()); // 属性设置服务一般不需要输出参数
|
|
.setOutputParams(Collections.emptyList()); // 属性设置服务一般不需要输出参数
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生成属性获取服务
|
|
* 生成属性获取服务
|
|
*/
|
|
*/
|
|
- private ThingModelService generatePropertyGetService(List<IotProductThingModelDO> thingModelList) {
|
|
|
|
|
|
+ private ThingModelService generatePropertyGetService(List<IotThingModelDO> thingModelList) {
|
|
// 1.1 没有属性则不生成
|
|
// 1.1 没有属性则不生成
|
|
if (CollUtil.isEmpty(thingModelList)) {
|
|
if (CollUtil.isEmpty(thingModelList)) {
|
|
return null;
|
|
return null;
|
|
@@ -308,9 +308,9 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
|
|
|
|
// 1.2 生成属性获取服务
|
|
// 1.2 生成属性获取服务
|
|
return new ThingModelService().setIdentifier("get").setName("属性获取").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));
|
|
|
|
|
|
+ .setCallType(IotThingModelServiceCallTypeEnum.ASYNC.getType())
|
|
|
|
+ .setInputParams(buildInputOutputParam(thingModelList, IotThingModelParamDirectionEnum.INPUT))
|
|
|
|
+ .setOutputParams(buildInputOutputParam(thingModelList, IotThingModelParamDirectionEnum.OUTPUT));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -319,10 +319,10 @@ public class IotProductThingModelServiceImpl implements IotProductThingModelServ
|
|
* @param thingModelList 属性列表
|
|
* @param thingModelList 属性列表
|
|
* @return 输入/输出参数列表
|
|
* @return 输入/输出参数列表
|
|
*/
|
|
*/
|
|
- private List<ThingModelInputOutputParam> buildInputOutputParam(List<IotProductThingModelDO> thingModelList,
|
|
|
|
- IotProductThingModelParamDirectionEnum directionEnum) {
|
|
|
|
|
|
+ private List<ThingModelParam> buildInputOutputParam(List<IotThingModelDO> thingModelList,
|
|
|
|
+ IotThingModelParamDirectionEnum directionEnum) {
|
|
return convertList(thingModelList, thingModel ->
|
|
return convertList(thingModelList, thingModel ->
|
|
- BeanUtils.toBean(thingModel.getProperty(), ThingModelInputOutputParam.class).setParaOrder(0) // TODO @puhui999: 先搞个默认值看看怎么个事
|
|
|
|
|
|
+ BeanUtils.toBean(thingModel.getProperty(), ThingModelParam.class).setParaOrder(0) // TODO @puhui999: 先搞个默认值看看怎么个事
|
|
.setDirection(directionEnum.getDirection()));
|
|
.setDirection(directionEnum.getDirection()));
|
|
}
|
|
}
|
|
|
|
|