提交 e3099e9c authored 作者: junjie's avatar junjie

feat(视图):视图指标增加数量字段

上级 9302d0f0
...@@ -256,7 +256,7 @@ public class ChartViewService { ...@@ -256,7 +256,7 @@ public class ChartViewService {
public String transMysqlSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartExtFilterRequest> extFilterRequestList) { public String transMysqlSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartExtFilterRequest> extFilterRequestList) {
// 字段汇总 排序等 // 字段汇总 排序等
String[] field = yAxis.stream().map(y -> "CAST(" + y.getSummary() + "(" + y.getOriginName() + ") AS DECIMAL(20,2)) AS _" + y.getSummary() + "_" + y.getOriginName()).toArray(String[]::new); String[] field = yAxis.stream().map(y -> "CAST(" + y.getSummary() + "(" + y.getOriginName() + ") AS DECIMAL(20,2)) AS _" + y.getSummary() + "_" + (StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName())).toArray(String[]::new);
String[] group = xAxis.stream().map(ChartViewFieldDTO::getOriginName).toArray(String[]::new); String[] group = xAxis.stream().map(ChartViewFieldDTO::getOriginName).toArray(String[]::new);
String[] order = yAxis.stream().filter(y -> StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none")) String[] order = yAxis.stream().filter(y -> StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none"))
.map(y -> "_" + y.getSummary() + "_" + y.getOriginName() + " " + y.getSort()).toArray(String[]::new); .map(y -> "_" + y.getSummary() + "_" + y.getOriginName() + " " + y.getSort()).toArray(String[]::new);
......
...@@ -135,6 +135,19 @@ public class DataSetTableService { ...@@ -135,6 +135,19 @@ public class DataSetTableService {
dimension.add(field); dimension.add(field);
} }
}); });
// quota add count
DatasetTableField count = DatasetTableField.builder()
.id("count")
.tableId(dataSetTableRequest.getId())
.originName("*")
.name("记录数*")
.type("INT")
.checked(true)
.columnIndex(999)
.deType(2)
.build();
quota.add(count);
Map<String, List<DatasetTableField>> map = new HashMap<>(); Map<String, List<DatasetTableField>> map = new HashMap<>();
map.put("dimension", dimension); map.put("dimension", dimension);
map.put("quota", quota); map.put("quota", quota);
......
...@@ -699,7 +699,8 @@ export default { ...@@ -699,7 +699,8 @@ export default {
area_mode: '面积', area_mode: '面积',
rose_radius: '圆角', rose_radius: '圆角',
view_name: '视图名称', view_name: '视图名称',
name_can_not_empty: '名称不能为空' name_can_not_empty: '名称不能为空',
custom_count: '记录数'
}, },
dataset: { dataset: {
datalist: '数据集', datalist: '数据集',
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
<el-dropdown trigger="click" size="mini" @command="clickItem"> <el-dropdown trigger="click" size="mini" @command="clickItem">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
<el-tag size="small" class="item-axis"> <el-tag size="small" class="item-axis">
{{ item.name }}<span v-if="item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span><i class="el-icon-arrow-down el-icon--right" /> <span>{{ item.name }}</span>
<span v-if="item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span>
<i class="el-icon-arrow-down el-icon--right" />
</el-tag> </el-tag>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item> <el-dropdown-item>
...@@ -17,17 +19,17 @@ ...@@ -17,17 +19,17 @@
<i class="el-icon-arrow-right el-icon--right" /> <i class="el-icon-arrow-right el-icon--right" />
</span> </span>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeSummary('sum')">{{ $t('chart.sum') }}</el-dropdown-item> <el-dropdown-item v-if="item.id === 'count'" :command="beforeSummary('count')">{{ $t('chart.count') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('count')">{{ $t('chart.count') }}</el-dropdown-item> <el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('sum')">{{ $t('chart.sum') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('avg')">{{ $t('chart.avg') }}</el-dropdown-item> <el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('avg')">{{ $t('chart.avg') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('max')">{{ $t('chart.max') }}</el-dropdown-item> <el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('max')">{{ $t('chart.max') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('min')">{{ $t('chart.min') }}</el-dropdown-item> <el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('min')">{{ $t('chart.min') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('stddev_pop')">{{ $t('chart.stddev_pop') }}</el-dropdown-item> <el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('stddev_pop')">{{ $t('chart.stddev_pop') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('var_pop')">{{ $t('chart.var_pop') }}</el-dropdown-item> <el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('var_pop')">{{ $t('chart.var_pop') }}</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item> <el-dropdown-item v-if="item.id !== 'count'">
<el-dropdown placement="right-start" size="mini" style="width: 100%" @command="quickCalc"> <el-dropdown placement="right-start" size="mini" style="width: 100%" @command="quickCalc">
<span class="el-dropdown-link inner-dropdown-menu"> <span class="el-dropdown-link inner-dropdown-menu">
<span> <span>
......
<template> <template>
<el-row style="height: 100%;overflow-y: hidden;width: 100%;"> <el-row style="height: 100%;overflow-y: hidden;width: 100%;">
<!-- <span v-show="false">{{ vId }}</span>--> <!-- <span v-show="false">{{ vId }}</span>-->
<el-row style="height: 40px;background-color: white" class="padding-lr"> <el-row style="height: 40px;background-color: white" class="padding-lr">
<el-popover <el-popover
placement="right-start" placement="right-start"
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" /> <svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" /> <svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" /> <svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
{{ item.name }} <span>{{ item.name }}</span>
</span> </span>
</transition-group> </transition-group>
</draggable> </draggable>
...@@ -368,8 +368,12 @@ export default { ...@@ -368,8 +368,12 @@ export default {
// }) // })
view.yaxis.forEach(function(ele) { view.yaxis.forEach(function(ele) {
if (!ele.summary || ele.summary === '') { if (!ele.summary || ele.summary === '') {
if (ele.id === 'count') {
ele.summary = 'count'
} else {
ele.summary = 'sum' ele.summary = 'sum'
} }
}
if (!ele.sort || ele.sort === '') { if (!ele.sort || ele.sort === '') {
ele.sort = 'none' ele.sort = 'none'
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论