|
@@ -1,6 +1,5 @@
|
|
|
package cn.iocoder.yudao.module.iot.dal.dataobject.tdengine;
|
|
|
|
|
|
-
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelProperty;
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.ThingModelRespVO;
|
|
|
import cn.iocoder.yudao.module.iot.controller.admin.thinkmodelfunction.thingModel.dataType.ThingModelDataType;
|
|
@@ -9,21 +8,26 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+/**
|
|
|
+ * FieldParser 类用于解析和转换物模型字段到 TDengine 字段
|
|
|
+ *
|
|
|
+ */
|
|
|
public class FieldParser {
|
|
|
|
|
|
/**
|
|
|
* 物模型到td数据类型映射
|
|
|
*/
|
|
|
- private static final HashMap<String, String> TYPE_MAPPING = new HashMap<>() {{
|
|
|
- put("INT", "INT");
|
|
|
- put("FLOAT", "FLOAT");
|
|
|
- put("DOUBLE", "DOUBLE");
|
|
|
- put("BOOL", "BOOL");
|
|
|
- put("ENUM", "NCHAR");
|
|
|
- put("TEXT", "NCHAR");
|
|
|
- put("DATE", "NCHAR");
|
|
|
- }};
|
|
|
-
|
|
|
+ private static final HashMap<String, String> TYPE_MAPPING = new HashMap<>() {
|
|
|
+ {
|
|
|
+ put("INT", "INT");
|
|
|
+ put("FLOAT", "FLOAT");
|
|
|
+ put("DOUBLE", "DOUBLE");
|
|
|
+ put("BOOL", "BOOL");
|
|
|
+ put("ENUM", "NCHAR");
|
|
|
+ put("TEXT", "NCHAR");
|
|
|
+ put("DATE", "NCHAR");
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
/**
|
|
|
* 将物模型字段转换为td字段
|
|
@@ -57,9 +61,8 @@ public class FieldParser {
|
|
|
/**
|
|
|
* 将从库中查出来的字段信息转换为td字段对象
|
|
|
*/
|
|
|
- public static List<TdField> parse(List rows) {
|
|
|
- return (List<TdField>) rows.stream().map((r) -> {
|
|
|
- List row = (List) r;
|
|
|
+ public static List<TdField> parse(List<List<Object>> rows) {
|
|
|
+ return rows.stream().map(row -> {
|
|
|
String type = row.get(1).toString().toUpperCase();
|
|
|
return new TdField(
|
|
|
row.get(0).toString(),
|
|
@@ -72,9 +75,9 @@ public class FieldParser {
|
|
|
* 获取字段字义
|
|
|
*/
|
|
|
public static String getFieldDefine(TdField field) {
|
|
|
- return "`" + field.getName() + "`" + " " + (field.getLength() > 0 ?
|
|
|
- String.format("%s(%d)", field.getType(), field.getLength())
|
|
|
- : field.getType());
|
|
|
+ return "`" + field.getName() + "`" + " "
|
|
|
+ + (field.getLength() > 0 ? String.format("%s(%d)", field.getType(), field.getLength())
|
|
|
+ : field.getType());
|
|
|
}
|
|
|
|
|
|
}
|