mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 18:49:06 +08:00 
			
		
		
		
	【代码评审】IoT:评审 ThingModel 的实现
This commit is contained in:
		| @ -34,11 +34,9 @@ public class FieldParser { | |||||||
|      * @return TdField对象 |      * @return TdField对象 | ||||||
|      */ |      */ | ||||||
|     public static TdFieldDO parse(ThingModelProperty property) { |     public static TdFieldDO parse(ThingModelProperty property) { | ||||||
|         String fieldName = property.getIdentifier().toLowerCase(); |  | ||||||
|  |  | ||||||
|         // 将物模型字段类型映射为 td 字段类型 |         // 将物模型字段类型映射为 td 字段类型 | ||||||
|  |         String fieldName = property.getIdentifier().toLowerCase(); | ||||||
|         String fType = TYPE_MAPPING.get(property.getDataType().toUpperCase()); |         String fType = TYPE_MAPPING.get(property.getDataType().toUpperCase()); | ||||||
|  |  | ||||||
|         // 如果字段类型为NCHAR,默认长度为64 |         // 如果字段类型为NCHAR,默认长度为64 | ||||||
|         int dataLength = 0; |         int dataLength = 0; | ||||||
|         if ("NCHAR".equals(fType)) { |         if ("NCHAR".equals(fType)) { | ||||||
| @ -54,6 +52,7 @@ public class FieldParser { | |||||||
|      * @return 字段列表 |      * @return 字段列表 | ||||||
|      */ |      */ | ||||||
|     public static List<TdFieldDO> parse(ThingModelRespVO thingModel) { |     public static List<TdFieldDO> parse(ThingModelRespVO thingModel) { | ||||||
|  |         // TODO @puhui999:是不是使用 convertList | ||||||
|         return thingModel.getModel().getProperties().stream() |         return thingModel.getModel().getProperties().stream() | ||||||
|                 .map(FieldParser::parse) |                 .map(FieldParser::parse) | ||||||
|                 .collect(Collectors.toList()); |                 .collect(Collectors.toList()); | ||||||
| @ -66,14 +65,12 @@ public class FieldParser { | |||||||
|      * @return 转换后的 TDengine 字段对象列表 |      * @return 转换后的 TDengine 字段对象列表 | ||||||
|      */ |      */ | ||||||
|     public static List<TdFieldDO> parse(List<List<Object>> rows) { |     public static List<TdFieldDO> parse(List<List<Object>> rows) { | ||||||
|  |         // TODO @puhui999:是不是使用 convertList | ||||||
|         return rows.stream().map(row -> { |         return rows.stream().map(row -> { | ||||||
|             String type = row.get(1).toString().toUpperCase(); |             String type = row.get(1).toString().toUpperCase(); | ||||||
|  |             // TODO @puhui999:"NCHAR" 最好枚举下 | ||||||
|             int dataLength = "NCHAR".equals(type) ? Integer.parseInt(row.get(2).toString()) : -1; |             int dataLength = "NCHAR".equals(type) ? Integer.parseInt(row.get(2).toString()) : -1; | ||||||
|             return new TdFieldDO( |             return new TdFieldDO(row.get(0).toString(), type, dataLength); | ||||||
|                     row.get(0).toString(), |  | ||||||
|                     type, |  | ||||||
|                     dataLength |  | ||||||
|             ); |  | ||||||
|         }).collect(Collectors.toList()); |         }).collect(Collectors.toList()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV