提交 0210db82 authored 作者: junjie's avatar junjie

feat(数据集):数据集字段类型扩展,数值区分 整型与浮点型

上级 5b60ea57
......@@ -113,7 +113,7 @@ public class DataSetTableService {
List<DatasetTableField> quota = new ArrayList<>();
fields.forEach(field -> {
if (field.getDeType() == 2) {
if (field.getDeType() == 2 || field.getDeType() == 3) {
quota.add(field);
} else {
dimension.add(field);
......@@ -360,10 +360,11 @@ public class DataSetTableService {
case "MEDIUMINT":
case "INTEGER":
case "BIGINT":
return 2;// 整型
case "FLOAT":
case "DOUBLE":
case "DECIMAL":
return 2;// 数值
return 3;// 浮点
default:
return 0;
}
......
......@@ -74,25 +74,35 @@ public class SparkCalc {
Result result = tuple2Iterator.next()._2;
List<Object> list = new ArrayList<>();
xAxis.forEach(x -> {
String l = Bytes.toString(result.getValue(column_family.getBytes(), x.getOriginName().getBytes()));
if (x.getDeType() == 0 || x.getDeType() == 1) {
list.add(Bytes.toString(result.getValue(column_family.getBytes(), x.getOriginName().getBytes())));
list.add(l);
} else if (x.getDeType() == 2) {
String l = Bytes.toString(result.getValue(column_family.getBytes(), x.getOriginName().getBytes()));
if (StringUtils.isEmpty(l)) {
l = "0";
}
list.add(l.contains(".") ? Double.parseDouble(l) : Long.parseLong(l));
list.add(Long.valueOf(l));
} else if (x.getDeType() == 3) {
if (StringUtils.isEmpty(l)) {
l = "0.0";
}
list.add(Double.valueOf(l));
}
});
yAxis.forEach(y -> {
String l = Bytes.toString(result.getValue(column_family.getBytes(), y.getOriginName().getBytes()));
if (y.getDeType() == 0 || y.getDeType() == 1) {
list.add(Bytes.toString(result.getValue(column_family.getBytes(), y.getOriginName().getBytes())));
list.add(l);
} else if (y.getDeType() == 2) {
String l = Bytes.toString(result.getValue(column_family.getBytes(), y.getOriginName().getBytes()));
if (StringUtils.isEmpty(l)) {
l = "0";
}
list.add(l.contains(".") ? Double.parseDouble(l) : Long.parseLong(l));
list.add(Long.valueOf(l));
} else if (y.getDeType() == 3) {
if (StringUtils.isEmpty(l)) {
l = "0.0";
}
list.add(Double.valueOf(l));
}
});
iterator.add(RowFactory.create(list.toArray()));
......@@ -107,6 +117,8 @@ public class SparkCalc {
structFields.add(DataTypes.createStructField(x.getOriginName(), DataTypes.StringType, true));
} else if (x.getDeType() == 2) {
structFields.add(DataTypes.createStructField(x.getOriginName(), DataTypes.LongType, true));
} else if (x.getDeType() == 3) {
structFields.add(DataTypes.createStructField(x.getOriginName(), DataTypes.DoubleType, true));
}
});
yAxis.forEach(y -> {
......@@ -114,6 +126,8 @@ public class SparkCalc {
structFields.add(DataTypes.createStructField(y.getOriginName(), DataTypes.StringType, true));
} else if (y.getDeType() == 2) {
structFields.add(DataTypes.createStructField(y.getOriginName(), DataTypes.LongType, true));
} else if (y.getDeType() == 3) {
structFields.add(DataTypes.createStructField(y.getOriginName(), DataTypes.DoubleType, true));
}
});
StructType structType = DataTypes.createStructType(structFields);
......
......@@ -22,7 +22,7 @@ CREATE TABLE IF NOT EXISTS `dataset_table_field`
`origin_name` varchar(255) NOT NULL COMMENT '原始名',
`name` varchar(255) NOT NULL COMMENT '字段名',
`type` varchar(50) NOT NULL COMMENT '原始字段类型',
`de_type` int(10) NOT NULL COMMENT 'dataease字段类型:0-文本,1-时间,2-数值...',
`de_type` int(10) NOT NULL COMMENT 'dataease字段类型:0-文本,1-时间,2-整型数值,3-浮点数值...',
`checked` tinyint(1) NOT NULL DEFAULT true COMMENT '是否选中',
`column_index` int(10) NOT NULL COMMENT '列位置',
`last_sync_time` bigint(13) COMMENT '同步时间',
......
......@@ -38,7 +38,7 @@
<template slot-scope="scope">
<span v-if="scope.row.deType === 0">{{ $t('dataset.text') }}</span>
<span v-if="scope.row.deType === 1">{{ $t('dataset.time') }}</span>
<span v-if="scope.row.deType === 2">{{ $t('dataset.value') }}</span>
<span v-if="scope.row.deType === 2 || scope.row.deType === 3">{{ $t('dataset.value') }}</span>
</template>
</el-table-column>
<el-table-column property="name" :label="$t('dataset.field_name')" width="180">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论