From 0210db82e6c41e061359d4770296b6498b90db75 Mon Sep 17 00:00:00 2001 From: junjie Date: Fri, 9 Apr 2021 22:42:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=95=B0=E6=8D=AE=E9=9B=86):=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E6=89=A9?= =?UTF-8?q?=E5=B1=95=EF=BC=8C=E6=95=B0=E5=80=BC=E5=8C=BA=E5=88=86=20?= =?UTF-8?q?=E6=95=B4=E5=9E=8B=E4=B8=8E=E6=B5=AE=E7=82=B9=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/DataSetTableService.java | 5 ++-- .../io/dataease/service/spark/SparkCalc.java | 26 ++++++++++++++----- .../db/migration/V9__dataset_tables.sql | 2 +- frontend/src/views/dataset/data/ViewTable.vue | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) 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 @@