Commit 741096e20861db1ce978e8b3a06178ed04d587cc

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