diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 83bce948d1..f40e017de8 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -113,7 +113,7 @@ public class DataSetTableService { List 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; } diff --git a/backend/src/main/java/io/dataease/service/spark/SparkCalc.java b/backend/src/main/java/io/dataease/service/spark/SparkCalc.java index 72ef889ab6..85079a66f6 100644 --- a/backend/src/main/java/io/dataease/service/spark/SparkCalc.java +++ b/backend/src/main/java/io/dataease/service/spark/SparkCalc.java @@ -74,25 +74,35 @@ public class SparkCalc { Result result = tuple2Iterator.next()._2; List 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); diff --git a/backend/src/main/resources/db/migration/V9__dataset_tables.sql b/backend/src/main/resources/db/migration/V9__dataset_tables.sql index ea003c2c35..ef38fd1fab 100644 --- a/backend/src/main/resources/db/migration/V9__dataset_tables.sql +++ b/backend/src/main/resources/db/migration/V9__dataset_tables.sql @@ -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 '同步时间', diff --git a/frontend/src/views/dataset/data/ViewTable.vue b/frontend/src/views/dataset/data/ViewTable.vue index 80af214a22..ad0c38e2e4 100644 --- a/frontend/src/views/dataset/data/ViewTable.vue +++ b/frontend/src/views/dataset/data/ViewTable.vue @@ -38,7 +38,7 @@