Commit 741096e20861db1ce978e8b3a06178ed04d587cc
1 parent
db9c4852
【功能完善】IoT: 产品物模型
Showing
14 changed files
with
48 additions
and
62 deletions
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotAccessModeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelAccessModeEnum.java
| 1 | -package cn.iocoder.yudao.module.iot.enums.product; | |
| 1 | +package cn.iocoder.yudao.module.iot.enums.thingmodel; | |
| 2 | 2 | |
| 3 | 3 | import lombok.AllArgsConstructor; |
| 4 | 4 | import lombok.Getter; |
| ... | ... | @@ -10,10 +10,9 @@ import lombok.Getter; |
| 10 | 10 | */ |
| 11 | 11 | @AllArgsConstructor |
| 12 | 12 | @Getter |
| 13 | -public enum IotAccessModeEnum { | |
| 13 | +public enum IotProductThingModelAccessModeEnum { | |
| 14 | 14 | |
| 15 | - READ("r"), | |
| 16 | - WRITE("w"), | |
| 15 | + READ_ONLY("r"), | |
| 17 | 16 | READ_WRITE("rw"); |
| 18 | 17 | |
| 19 | 18 | private final String mode; | ... | ... |
yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/product/IotProductFunctionTypeEnum.java renamed to yudao-module-iot/yudao-module-iot-api/src/main/java/cn/iocoder/yudao/module/iot/enums/thingmodel/IotProductThingModelTypeEnum.java
| 1 | -package cn.iocoder.yudao.module.iot.enums.product; | |
| 1 | +package cn.iocoder.yudao.module.iot.enums.thingmodel; | |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; |
| 4 | 4 | import lombok.AllArgsConstructor; |
| ... | ... | @@ -13,13 +13,13 @@ import java.util.Arrays; |
| 13 | 13 | */ |
| 14 | 14 | @AllArgsConstructor |
| 15 | 15 | @Getter |
| 16 | -public enum IotProductFunctionTypeEnum implements IntArrayValuable { | |
| 16 | +public enum IotProductThingModelTypeEnum implements IntArrayValuable { | |
| 17 | 17 | |
| 18 | 18 | PROPERTY(1, "属性"), |
| 19 | 19 | SERVICE(2, "服务"), |
| 20 | 20 | EVENT(3, "事件"); |
| 21 | 21 | |
| 22 | - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductFunctionTypeEnum::getType).toArray(); | |
| 22 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotProductThingModelTypeEnum::getType).toArray(); | |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * 类型 |
| ... | ... | @@ -30,8 +30,8 @@ public enum IotProductFunctionTypeEnum implements IntArrayValuable { |
| 30 | 30 | */ |
| 31 | 31 | private final String description; |
| 32 | 32 | |
| 33 | - public static IotProductFunctionTypeEnum valueOfType(Integer type) { | |
| 34 | - for (IotProductFunctionTypeEnum value : values()) { | |
| 33 | + public static IotProductThingModelTypeEnum valueOfType(Integer type) { | |
| 34 | + for (IotProductThingModelTypeEnum value : values()) { | |
| 35 | 35 | if (value.getType().equals(type)) { |
| 36 | 36 | return value; |
| 37 | 37 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/ThingModelProperty.java
| ... | ... | @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingMod |
| 3 | 3 | import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelDataType; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | +import java.util.List; | |
| 7 | + | |
| 6 | 8 | @Data |
| 7 | 9 | public class ThingModelProperty { |
| 8 | 10 | |
| ... | ... | @@ -21,7 +23,7 @@ public class ThingModelProperty { |
| 21 | 23 | |
| 22 | 24 | private String accessMode; // "rw"、"r"、"w" |
| 23 | 25 | private Boolean required; |
| 24 | - // TODO @haohao:这个是不是 dataSpecs 和 dataSpecsList?https://help.aliyun.com/zh/iot/developer-reference/api-a99t11 | |
| 25 | - private ThingModelDataType dataType; | |
| 26 | + private ThingModelDataType dataSpecs; | |
| 27 | + private List<ThingModelDataType> dataSpecsList; | |
| 26 | 28 | |
| 27 | 29 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/thingModel/dataType/ThingModelDataType.java
| ... | ... | @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | |
| 7 | 7 | @Data |
| 8 | -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true) | |
| 8 | +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "dataType", visible = true) | |
| 9 | 9 | @JsonSubTypes({ |
| 10 | 10 | @JsonSubTypes.Type(value = ThingModelIntType.class, name = "int"), |
| 11 | 11 | @JsonSubTypes.Type(value = ThingModelFloatType.class, name = "float"), |
| ... | ... | @@ -19,6 +19,6 @@ import lombok.Data; |
| 19 | 19 | }) |
| 20 | 20 | public abstract class ThingModelDataType { |
| 21 | 21 | |
| 22 | - private String type; | |
| 22 | + private String dataType; | |
| 23 | 23 | |
| 24 | 24 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/vo/IotThinkModelFunctionPageReqVO.java
| ... | ... | @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 5 | -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; | |
| 5 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 6 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 7 | 7 | import jakarta.validation.constraints.NotNull; |
| 8 | 8 | import lombok.Data; |
| ... | ... | @@ -22,7 +22,7 @@ public class IotThinkModelFunctionPageReqVO extends PageParam { |
| 22 | 22 | private String name; |
| 23 | 23 | |
| 24 | 24 | @Schema(description = "功能类型", example = "1") |
| 25 | - @InEnum(IotProductFunctionTypeEnum.class) | |
| 25 | + @InEnum(IotProductThingModelTypeEnum.class) | |
| 26 | 26 | private Integer type; |
| 27 | 27 | |
| 28 | 28 | @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED) | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/controller/admin/thinkmodelfunction/vo/IotThinkModelFunctionSaveReqVO.java
| ... | ... | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 4 | import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelEvent; |
| 5 | 5 | import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelService; |
| 7 | -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; | |
| 7 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 8 | 8 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | 9 | import jakarta.validation.constraints.NotEmpty; |
| 10 | 10 | import jakarta.validation.constraints.NotNull; |
| ... | ... | @@ -38,7 +38,7 @@ public class IotThinkModelFunctionSaveReqVO { |
| 38 | 38 | |
| 39 | 39 | @Schema(description = "功能类型", requiredMode = Schema.RequiredMode.REQUIRED) |
| 40 | 40 | @NotNull(message = "功能类型不能为空") |
| 41 | - @InEnum(IotProductFunctionTypeEnum.class) | |
| 41 | + @InEnum(IotProductThingModelTypeEnum.class) | |
| 42 | 42 | private Integer type; |
| 43 | 43 | |
| 44 | 44 | @Schema(description = "属性", requiredMode = Schema.RequiredMode.REQUIRED) | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/device/IotDeviceDataConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.iot.convert.device; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.iot.controller.admin.device.vo.deviceData.IotDeviceDataRespVO; | |
| 4 | -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelEvent; | |
| 5 | -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty; | |
| 6 | -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelService; | |
| 7 | -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionRespVO; | |
| 8 | -import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionSaveReqVO; | |
| 9 | -import cn.iocoder.yudao.module.iot.dal.dataobject.device.IotDeviceDO; | |
| 10 | -import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO; | |
| 11 | -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; | |
| 12 | 3 | import org.mapstruct.Mapper; |
| 13 | -import org.mapstruct.Mapping; | |
| 14 | 4 | import org.mapstruct.factory.Mappers; |
| 15 | 5 | |
| 16 | -import java.util.ArrayList; | |
| 17 | -import java.util.List; | |
| 18 | -import java.util.Map; | |
| 19 | -import java.util.Objects; | |
| 20 | - | |
| 21 | 6 | @Mapper |
| 22 | 7 | public interface IotDeviceDataConvert { |
| 23 | 8 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/convert/thinkmodelfunction/IotThinkModelFunctionConvert.java
| ... | ... | @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingMode |
| 6 | 6 | import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionRespVO; |
| 7 | 7 | import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.vo.IotThinkModelFunctionSaveReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO; |
| 9 | -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; | |
| 9 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 10 | 10 | import org.mapstruct.Mapper; |
| 11 | 11 | import org.mapstruct.Mapping; |
| 12 | 12 | import org.mapstruct.factory.Mappers; |
| ... | ... | @@ -26,21 +26,21 @@ public interface IotThinkModelFunctionConvert { |
| 26 | 26 | IotThinkModelFunctionDO convert(IotThinkModelFunctionSaveReqVO bean); |
| 27 | 27 | |
| 28 | 28 | default ThingModelProperty convertToProperty(IotThinkModelFunctionSaveReqVO bean) { |
| 29 | - if (Objects.equals(bean.getType(), IotProductFunctionTypeEnum.PROPERTY.getType())) { | |
| 29 | + if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { | |
| 30 | 30 | return bean.getProperty(); |
| 31 | 31 | } |
| 32 | 32 | return null; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | default ThingModelEvent convertToEvent(IotThinkModelFunctionSaveReqVO bean) { |
| 36 | - if (Objects.equals(bean.getType(), IotProductFunctionTypeEnum.EVENT.getType())) { | |
| 36 | + if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.EVENT.getType())) { | |
| 37 | 37 | return bean.getEvent(); |
| 38 | 38 | } |
| 39 | 39 | return null; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | default ThingModelService convertToService(IotThinkModelFunctionSaveReqVO bean) { |
| 43 | - if (Objects.equals(bean.getType(), IotProductFunctionTypeEnum.SERVICE.getType())) { | |
| 43 | + if (Objects.equals(bean.getType(), IotProductThingModelTypeEnum.SERVICE.getType())) { | |
| 44 | 44 | return bean.getService(); |
| 45 | 45 | } |
| 46 | 46 | return null; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/tdengine/FieldParser.java
| ... | ... | @@ -39,7 +39,7 @@ public class FieldParser { |
| 39 | 39 | ThingModelDataType type = property.getDataType(); |
| 40 | 40 | |
| 41 | 41 | // 将物模型字段类型映射为td字段类型 |
| 42 | - String fType = TYPE_MAPPING.get(type.getType().toUpperCase()); | |
| 42 | + String fType = TYPE_MAPPING.get(type.getDataType().toUpperCase()); | |
| 43 | 43 | |
| 44 | 44 | // 如果字段类型为NCHAR,默认长度为64 |
| 45 | 45 | int dataLength = 0; | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/dal/dataobject/thinkmodelfunction/IotThinkModelFunctionDO.java
| ... | ... | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingMode |
| 5 | 5 | import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty; |
| 6 | 6 | import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelService; |
| 7 | 7 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 8 | -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; | |
| 8 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 9 | 9 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 10 | 10 | import com.baomidou.mybatisplus.annotation.TableField; |
| 11 | 11 | import com.baomidou.mybatisplus.annotation.TableId; |
| ... | ... | @@ -66,7 +66,7 @@ public class IotThinkModelFunctionDO extends BaseDO { |
| 66 | 66 | /** |
| 67 | 67 | * 功能类型 |
| 68 | 68 | * <p> |
| 69 | - * 枚举 {@link IotProductFunctionTypeEnum} | |
| 69 | + * 枚举 {@link IotProductThingModelTypeEnum} | |
| 70 | 70 | */ |
| 71 | 71 | private Integer type; |
| 72 | 72 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/device/IotDeviceDataServiceImpl.java
| ... | ... | @@ -13,7 +13,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkMod |
| 13 | 13 | import cn.iocoder.yudao.module.iot.dal.redis.deviceData.DeviceDataRedisDAO; |
| 14 | 14 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; |
| 15 | 15 | import cn.iocoder.yudao.module.iot.enums.IotConstants; |
| 16 | -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; | |
| 16 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 17 | 17 | import cn.iocoder.yudao.module.iot.service.tdengine.IotThingModelMessageService; |
| 18 | 18 | import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService; |
| 19 | 19 | import jakarta.annotation.Resource; |
| ... | ... | @@ -75,7 +75,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService { |
| 75 | 75 | // 2. 获取设备属性最新数据 |
| 76 | 76 | List<IotThinkModelFunctionDO> thinkModelFunctionList = thinkModelFunctionService.getThinkModelFunctionListByProductKey(device.getProductKey()); |
| 77 | 77 | thinkModelFunctionList = thinkModelFunctionList.stream() |
| 78 | - .filter(function -> IotProductFunctionTypeEnum.PROPERTY.getType() | |
| 78 | + .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType() | |
| 79 | 79 | .equals(function.getType())).toList(); |
| 80 | 80 | |
| 81 | 81 | // 3. 过滤标识符和属性名称 |
| ... | ... | @@ -100,7 +100,7 @@ public class IotDeviceDataServiceImpl implements IotDeviceDataService { |
| 100 | 100 | deviceData.setDeviceId(deviceDataReqVO.getDeviceId()); |
| 101 | 101 | deviceData.setThinkModelFunctionId(function.getId()); |
| 102 | 102 | deviceData.setName(function.getName()); |
| 103 | - deviceData.setDataType(function.getProperty().getDataType().getType()); | |
| 103 | + deviceData.setDataType(function.getProperty().getDataType().getDataType()); | |
| 104 | 104 | } |
| 105 | 105 | list.add(deviceData); |
| 106 | 106 | }); | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotSuperTableServiceImpl.java
| ... | ... | @@ -10,8 +10,7 @@ import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdFieldDO; |
| 10 | 10 | import cn.iocoder.yudao.module.iot.dal.dataobject.tdengine.TdTableDO; |
| 11 | 11 | import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO; |
| 12 | 12 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper; |
| 13 | -import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; | |
| 14 | -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; | |
| 13 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 15 | 14 | import jakarta.annotation.Resource; |
| 16 | 15 | import lombok.extern.slf4j.Slf4j; |
| 17 | 16 | import org.springframework.beans.factory.annotation.Value; |
| ... | ... | @@ -217,8 +216,8 @@ public class IotSuperTableServiceImpl implements IotSuperTableService { |
| 217 | 216 | thingModel.setProductKey(product.getProductKey()); |
| 218 | 217 | |
| 219 | 218 | List<ThingModelProperty> properties = functionList.stream() |
| 220 | - .filter(function -> IotProductFunctionTypeEnum.PROPERTY.equals( | |
| 221 | - IotProductFunctionTypeEnum.valueOfType(function.getType()))) | |
| 219 | + .filter(function -> IotProductThingModelTypeEnum.PROPERTY.equals( | |
| 220 | + IotProductThingModelTypeEnum.valueOfType(function.getType()))) | |
| 222 | 221 | .map(this::buildThingModelProperty) |
| 223 | 222 | .collect(Collectors.toList()); |
| 224 | 223 | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/tdengine/IotThingModelMessageServiceImpl.java
| ... | ... | @@ -17,7 +17,7 @@ import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDDLMapper; |
| 17 | 17 | import cn.iocoder.yudao.module.iot.dal.tdengine.TdEngineDMLMapper; |
| 18 | 18 | import cn.iocoder.yudao.module.iot.enums.IotConstants; |
| 19 | 19 | import cn.iocoder.yudao.module.iot.enums.device.IotDeviceStatusEnum; |
| 20 | -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; | |
| 20 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 21 | 21 | import cn.iocoder.yudao.module.iot.service.device.IotDeviceService; |
| 22 | 22 | import cn.iocoder.yudao.module.iot.service.thinkmodelfunction.IotThinkModelFunctionService; |
| 23 | 23 | import jakarta.annotation.Resource; |
| ... | ... | @@ -94,7 +94,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ |
| 94 | 94 | return iotThinkModelFunctionService |
| 95 | 95 | .getThinkModelFunctionListByProductKey(productKey) |
| 96 | 96 | .stream() |
| 97 | - .filter(function -> IotProductFunctionTypeEnum.PROPERTY.getType().equals(function.getType())) | |
| 97 | + .filter(function -> IotProductThingModelTypeEnum.PROPERTY.getType().equals(function.getType())) | |
| 98 | 98 | .toList(); |
| 99 | 99 | } |
| 100 | 100 | |
| ... | ... | @@ -138,7 +138,7 @@ public class IotThingModelMessageServiceImpl implements IotThingModelMessageServ |
| 138 | 138 | .deviceId(device.getId()) |
| 139 | 139 | .thinkModelFunctionId(iotThinkModelFunctionDO.getId()) |
| 140 | 140 | .name(iotThinkModelFunctionDO.getName()) |
| 141 | - .dataType(iotThinkModelFunctionDO.getProperty().getDataType().getType()) | |
| 141 | + .dataType(iotThinkModelFunctionDO.getProperty().getDataType().getDataType()) | |
| 142 | 142 | .build(); |
| 143 | 143 | deviceDataRedisDAO.set(deviceData); |
| 144 | 144 | } | ... | ... |
yudao-module-iot/yudao-module-iot-biz/src/main/java/cn/iocoder/yudao/module/iot/service/thinkmodelfunction/IotThinkModelFunctionServiceImpl.java
| ... | ... | @@ -18,8 +18,8 @@ import cn.iocoder.yudao.module.iot.convert.thinkmodelfunction.IotThinkModelFunct |
| 18 | 18 | import cn.iocoder.yudao.module.iot.dal.dataobject.product.IotProductDO; |
| 19 | 19 | import cn.iocoder.yudao.module.iot.dal.dataobject.thinkmodelfunction.IotThinkModelFunctionDO; |
| 20 | 20 | import cn.iocoder.yudao.module.iot.dal.mysql.thinkmodelfunction.IotThinkModelFunctionMapper; |
| 21 | -import cn.iocoder.yudao.module.iot.enums.product.IotAccessModeEnum; | |
| 22 | -import cn.iocoder.yudao.module.iot.enums.product.IotProductFunctionTypeEnum; | |
| 21 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelAccessModeEnum; | |
| 22 | +import cn.iocoder.yudao.module.iot.enums.thingmodel.IotProductThingModelTypeEnum; | |
| 23 | 23 | import cn.iocoder.yudao.module.iot.enums.product.IotProductStatusEnum; |
| 24 | 24 | import cn.iocoder.yudao.module.iot.service.product.IotProductService; |
| 25 | 25 | import cn.iocoder.yudao.module.iot.service.tdengine.IotSuperTableService; |
| ... | ... | @@ -74,7 +74,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 74 | 74 | thinkModelFunctionMapper.insert(function); |
| 75 | 75 | |
| 76 | 76 | // 6. 如果创建的是属性,需要更新默认的事件和服务 |
| 77 | - if (Objects.equals(createReqVO.getType(), IotProductFunctionTypeEnum.PROPERTY.getType())) { | |
| 77 | + if (Objects.equals(createReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { | |
| 78 | 78 | createDefaultEventsAndServices(createReqVO.getProductId(), createReqVO.getProductKey()); |
| 79 | 79 | } |
| 80 | 80 | return function.getId(); |
| ... | ... | @@ -128,7 +128,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 128 | 128 | thinkModelFunctionMapper.updateById(thinkModelFunction); |
| 129 | 129 | |
| 130 | 130 | // 5. 如果更新的是属性,需要更新默认的事件和服务 |
| 131 | - if (Objects.equals(updateReqVO.getType(), IotProductFunctionTypeEnum.PROPERTY.getType())) { | |
| 131 | + if (Objects.equals(updateReqVO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { | |
| 132 | 132 | createDefaultEventsAndServices(updateReqVO.getProductId(), updateReqVO.getProductKey()); |
| 133 | 133 | } |
| 134 | 134 | } |
| ... | ... | @@ -156,7 +156,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 156 | 156 | thinkModelFunctionMapper.deleteById(id); |
| 157 | 157 | |
| 158 | 158 | // 3. 如果删除的是属性,需要更新默认的事件和服务 |
| 159 | - if (Objects.equals(functionDO.getType(), IotProductFunctionTypeEnum.PROPERTY.getType())) { | |
| 159 | + if (Objects.equals(functionDO.getType(), IotProductThingModelTypeEnum.PROPERTY.getType())) { | |
| 160 | 160 | createDefaultEventsAndServices(functionDO.getProductId(), functionDO.getProductKey()); |
| 161 | 161 | } |
| 162 | 162 | } |
| ... | ... | @@ -210,7 +210,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 210 | 210 | public void createDefaultEventsAndServices(Long productId, String productKey) { |
| 211 | 211 | // 1. 获取当前属性列表 |
| 212 | 212 | List<IotThinkModelFunctionDO> propertyList = thinkModelFunctionMapper |
| 213 | - .selectListByProductIdAndType(productId, IotProductFunctionTypeEnum.PROPERTY.getType()); | |
| 213 | + .selectListByProductIdAndType(productId, IotProductThingModelTypeEnum.PROPERTY.getType()); | |
| 214 | 214 | |
| 215 | 215 | // 2. 生成新的事件和服务列表 |
| 216 | 216 | List<IotThinkModelFunctionDO> newFunctionList = new ArrayList<>(); |
| ... | ... | @@ -237,7 +237,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 237 | 237 | List<IotThinkModelFunctionDO> oldFunctionList = thinkModelFunctionMapper.selectListByProductIdAndIdentifiersAndTypes( |
| 238 | 238 | productId, |
| 239 | 239 | Arrays.asList("post", "set", "get"), |
| 240 | - Arrays.asList(IotProductFunctionTypeEnum.EVENT.getType(), IotProductFunctionTypeEnum.SERVICE.getType()) | |
| 240 | + Arrays.asList(IotProductThingModelTypeEnum.EVENT.getType(), IotProductThingModelTypeEnum.SERVICE.getType()) | |
| 241 | 241 | ); |
| 242 | 242 | |
| 243 | 243 | // 3.1 使用 diffList 方法比较新旧列表 |
| ... | ... | @@ -300,7 +300,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 300 | 300 | .setIdentifier(event.getIdentifier()) |
| 301 | 301 | .setName(event.getName()) |
| 302 | 302 | .setDescription(event.getDescription()) |
| 303 | - .setType(IotProductFunctionTypeEnum.EVENT.getType()) | |
| 303 | + .setType(IotProductThingModelTypeEnum.EVENT.getType()) | |
| 304 | 304 | .setEvent(event); |
| 305 | 305 | } |
| 306 | 306 | |
| ... | ... | @@ -314,7 +314,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 314 | 314 | .setIdentifier(service.getIdentifier()) |
| 315 | 315 | .setName(service.getName()) |
| 316 | 316 | .setDescription(service.getDescription()) |
| 317 | - .setType(IotProductFunctionTypeEnum.SERVICE.getType()) | |
| 317 | + .setType(IotProductThingModelTypeEnum.SERVICE.getType()) | |
| 318 | 318 | .setService(service); |
| 319 | 319 | } |
| 320 | 320 | |
| ... | ... | @@ -358,9 +358,10 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | List<ThingModelArgument> inputData = new ArrayList<>(); |
| 361 | + // TODO @puhui999: 需要重构 | |
| 361 | 362 | for (IotThinkModelFunctionDO functionDO : propertyList) { |
| 362 | 363 | ThingModelProperty property = functionDO.getProperty(); |
| 363 | - if (IotAccessModeEnum.WRITE.getMode().equals(property.getAccessMode()) || IotAccessModeEnum.READ_WRITE.getMode().equals(property.getAccessMode())) { | |
| 364 | + if (IotProductThingModelAccessModeEnum.WRITE.getMode().equals(property.getAccessMode()) || IotProductThingModelAccessModeEnum.READ_WRITE.getMode().equals(property.getAccessMode())) { | |
| 364 | 365 | ThingModelArgument arg = new ThingModelArgument() |
| 365 | 366 | .setIdentifier(property.getIdentifier()) |
| 366 | 367 | .setName(property.getName()) |
| ... | ... | @@ -399,7 +400,7 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 399 | 400 | for (IotThinkModelFunctionDO functionDO : propertyList) { |
| 400 | 401 | ThingModelProperty property = functionDO.getProperty(); |
| 401 | 402 | if (ObjectUtils.equalsAny(property.getAccessMode(), |
| 402 | - IotAccessModeEnum.READ.getMode(), IotAccessModeEnum.READ_WRITE.getMode())) { | |
| 403 | + IotProductThingModelAccessModeEnum.READ.getMode(), IotProductThingModelAccessModeEnum.READ_WRITE.getMode())) { | |
| 403 | 404 | ThingModelArgument arg = new ThingModelArgument() |
| 404 | 405 | .setIdentifier(property.getIdentifier()) |
| 405 | 406 | .setName(property.getName()) |
| ... | ... | @@ -430,10 +431,10 @@ public class IotThinkModelFunctionServiceImpl implements IotThinkModelFunctionSe |
| 430 | 431 | |
| 431 | 432 | // 创建数组类型,元素类型为文本类型(字符串) |
| 432 | 433 | ThingModelArrayType arrayType = new ThingModelArrayType(); |
| 433 | - arrayType.setType("array"); | |
| 434 | + arrayType.setDataType("array"); | |
| 434 | 435 | ThingModelArraySpecs arraySpecs = new ThingModelArraySpecs(); |
| 435 | 436 | ThingModelTextType textType = new ThingModelTextType(); |
| 436 | - textType.setType("text"); | |
| 437 | + textType.setDataType("text"); | |
| 437 | 438 | arraySpecs.setItem(textType); |
| 438 | 439 | arrayType.setSpecs(arraySpecs); |
| 439 | 440 | inputArg.setDataType(arrayType); | ... | ... |