Merge branch 'dev' of github.com:dataease/dataease into dev

This commit is contained in:
wangjiahao 2024-01-02 08:57:53 +08:00
commit 832742586c
30 changed files with 125 additions and 54 deletions

View File

@ -103,7 +103,7 @@ curl -sSL https://dataease.oss-cn-hangzhou.aliyuncs.com/quick_start.sh | bash
## License
Copyright (c) 2014-2023 [FIT2CLOUD 飞致云](https://fit2cloud.com/), All rights reserved.
Copyright (c) 2014-2024 [FIT2CLOUD 飞致云](https://fit2cloud.com/), All rights reserved.
Licensed under The GNU General Public License version 3 (GPLv3) (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

View File

@ -1,11 +1,18 @@
package io.dataease.service.chart.build;
import cn.hutool.core.bean.BeanUtil;
import io.dataease.commons.utils.LogUtil;
import io.dataease.controller.dataset.DataSetTableFieldController;
import io.dataease.controller.request.dataset.MultFieldValuesRequest;
import io.dataease.dto.chart.FilterParamTO;
import io.dataease.dto.dataset.DeSortDTO;
import io.dataease.service.chart.FilterBuildTemplate;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -14,6 +21,10 @@ import java.util.stream.Collectors;
@Service("selectWidget")
public class SelectBuild extends FilterBuildTemplate {
@Resource
private DataSetTableFieldController dataSetTableFieldController;
@Override
protected FilterParamTO buildParam(Map<String, Object> component) {
FilterParamTO result = new FilterParamTO();
@ -23,30 +34,34 @@ public class SelectBuild extends FilterBuildTemplate {
Object valueObj = null;
List<String> realValues = null;
if(ObjectUtils.isEmpty(component.get("options"))) return result;
Map<String, Object> options = (Map<String, Object>)component.get("options");
if (ObjectUtils.isEmpty(component.get("options"))) return result;
Map<String, Object> options = (Map<String, Object>) component.get("options");
valueObj = options.get("value");
String defaultValue = "";
Map<String, Object> attrs = (Map<String, Object>) options.get("attrs");
boolean multiple = (boolean) attrs.get("multiple");
if(!ObjectUtils.isEmpty(valueObj)) {
if(valueObj instanceof List) {
if (!ObjectUtils.isEmpty(valueObj)) {
if (valueObj instanceof List) {
defaultValue = "";
}else {
} else {
defaultValue = valueObj.toString();
}
}
if(multiple) {
boolean isSelectFirst = StringUtils.equals("custom", component.get("type").toString()) && ObjectUtils.isNotEmpty(attrs.get("selectFirst")) && (boolean) attrs.get("selectFirst");
if (isSelectFirst) {
defaultValue = getFirst(attrs);
}
if (multiple) {
if (StringUtils.isBlank(defaultValue)) {
realValues = new ArrayList<>();
}else {
} else {
realValues = Arrays.asList(defaultValue.split(","));
}
} else {
if (StringUtils.isBlank(defaultValue)) {
realValues = new ArrayList<>();
}else {
} else {
realValues = Arrays.asList(defaultValue.split(",")).stream().limit(1).collect(Collectors.toList());
}
}
@ -54,4 +69,22 @@ public class SelectBuild extends FilterBuildTemplate {
result.setValue(realValues);
return result;
}
private String getFirst(Map<String, Object> attrs) {
MultFieldValuesRequest request = new MultFieldValuesRequest();
request.setFieldIds(Arrays.stream(attrs.get("fieldId").toString().split(",")).collect(Collectors.toList()));
if (ObjectUtils.isNotEmpty(attrs.get("sort"))) {
DeSortDTO sort = BeanUtil.copyProperties(attrs.get("sort"), DeSortDTO.class);
request.setSort(sort);
}
List<Object> list = null;
try {
list = dataSetTableFieldController.multFieldValues(request);
} catch (Exception e) {
LogUtil.error(e.getMessage());
return null;
}
if (CollectionUtils.isEmpty(list)) return null;
return list.get(0).toString();
}
}

View File

@ -1245,7 +1245,8 @@ public class DataSetTableService {
} catch (Exception e) {
}
if (binaryExpression != null) {
if (!(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getLeftExpression() instanceof InExpression) && hasVariable(binaryExpression.getRightExpression().toString())) {
boolean hasSubBinaryExpression = binaryExpression instanceof AndExpression || binaryExpression instanceof OrExpression;
if (!hasSubBinaryExpression &&!(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getLeftExpression() instanceof InExpression) && hasVariable(binaryExpression.getRightExpression().toString())) {
stringBuilder.append(SubstitutedSql);
} else {
expr.accept(getExpressionDeParser(stringBuilder));
@ -2169,7 +2170,7 @@ public class DataSetTableService {
datasetTableField.setType(field.getFieldType());
datasetTableField.setSize(field.getFieldSize());
datasetTableField.setAccuracy(field.getAccuracy());
if (ObjectUtils.isEmpty(ds)) {
if (StringUtils.isEmpty(datasetTable.getDataSourceId())) {
datasetTableField.setDeExtractType(transFieldType(field.getFieldType()));
} else {
Integer fieldType = qp.transFieldType(field.getFieldType());
@ -2185,7 +2186,7 @@ public class DataSetTableService {
datasetTableField.setDataeaseName(TableUtils.columnName(field.getFieldName()));
}
datasetTableField.setType(field.getFieldType());
if (ObjectUtils.isEmpty(ds)) {
if (StringUtils.isEmpty(datasetTable.getDataSourceId())) {
datasetTableField.setDeType(transFieldType(field.getFieldType()));
datasetTableField.setDeExtractType(transFieldType(field.getFieldType()));
} else {
@ -2980,6 +2981,16 @@ public class DataSetTableService {
}
if (inExpression.getRightExpression() != null) {
getBuffer().append(" ( ");
if (inExpression.getRightExpression() instanceof SubSelect) {
try {
SubSelect subSelect = (SubSelect) inExpression.getRightExpression();
Select select = (Select) CCJSqlParserUtil.parse(removeVariables(subSelect.getSelectBody().toString(), ""));
subSelect.setSelectBody(select.getSelectBody());
inExpression.setRightExpression(subSelect);
}catch (Exception e){
e.printStackTrace();
}
}
inExpression.getRightExpression().accept(this);
getBuffer().append(" )");
}

View File

@ -1045,7 +1045,10 @@ export default {
tableChart.customAttr.color.tableHeaderFontColor = '#7c7e81'
tableChart.customAttr.color.tableFontColor = '#7c7e81'
tableChart.customAttr.color.enableTableCrossBG = false
tableChart.customAttr.size.showTableHeader = true
}
tableChart.customAttr.size.tableColumnFreezeHead = 0
tableChart.customAttr.size.tableRowFreezeHead = 0
tableChart.customAttr.color.tableStripe = true
tableChart.customAttr.size.tablePageMode = 'pull'
tableChart.customStyle.text.show = false

View File

@ -164,8 +164,10 @@ export default {
'defaultValueStr': function(value, old) {
if (value === old) return
this.$nextTick(() => {
this.value = this.fillValueDerfault()
this.changeValue(value)
if (!this.selectFirst) {
this.value = this.fillValueDerfault()
this.changeValue(value)
}
})
},
'element.options.attrs.fieldId': function(value, old) {
@ -363,8 +365,8 @@ export default {
const id = ele.id
const eleVal = ele.options.value.toString()
if (this.inDraw && this.manualModify && this.element.id === id) {
if (this.selectFirst) {
this.fillFirstValue()
if (ele.options.attrs.selectFirst) {
this.fillFirstValue(true)
this.firstChange(this.value)
return
}
@ -503,8 +505,8 @@ export default {
}
return this.value.split(',')
},
fillFirstValue() {
if (!this.selectFirst) {
fillFirstValue(isSelectFirst) {
if (!this.selectFirst && !isSelectFirst) {
return
}
let defaultV = this.data[0].id

View File

@ -72,7 +72,7 @@ class NumberRangeServiceImpl extends WidgetService {
if (val === null || val === '' || typeof val === 'undefined') {
values = element.options.value
} else {
values = val.split(',')
values = Array.isArray(val) ? val : val.split(',')
}
if (values && values.length > 0) {
const min = values[0]

View File

@ -87,7 +87,7 @@ class NumberSelectGridServiceImpl extends WidgetService {
if (val === null || val === '' || typeof val === 'undefined') {
value = this.fillValueDerfault(element)
} else {
value = [val]
value = Array.isArray(val) ? val : val.split(',')
}
const param = {
component: element,

View File

@ -89,7 +89,7 @@ class NumberSelectServiceImpl extends WidgetService {
if (val === null || val === '' || typeof val === 'undefined') {
value = this.fillValueDerfault(element)
} else {
value = [val]
value = Array.isArray(val) ? val : val.split(',')
}
const param = {
component: element,

View File

@ -73,7 +73,7 @@ class TextInputServiceImpl extends WidgetService {
if (!val) {
value = this.fillValueDerfault(element)
} else {
value = [val]
value = Array.isArray(val) ? val : val.split(',')
}
const param = {
component: element,

View File

@ -88,7 +88,7 @@ class TextSelectGridServiceImpl extends WidgetService {
if (!val) {
value = this.fillValueDerfault(element)
} else {
value = [val]
value = Array.isArray(val) ? val : val.split(',')
}
const param = {
component: element,

View File

@ -92,7 +92,7 @@ class TextSelectServiceImpl extends WidgetService {
if (!val) {
value = this.fillValueDerfault(element)
} else {
value = [val]
value = Array.isArray(val) ? val : val.split(',')
}
const param = {
component: element,

View File

@ -91,7 +91,7 @@ class TextSelectTreeServiceImpl extends WidgetService {
if (!val) {
value = this.fillValueDerfault(element)
} else {
value = [val]
value = Array.isArray(val) ? val : val.split(',')
}
const param = {
component: element,

View File

@ -313,7 +313,7 @@ class TimeDateRangeServiceImpl extends WidgetService {
getParam(element, val) {
let timeArr = []
if (val) {
let value = [val]
let value = Array.isArray(val) ? val : val.split(',')
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)
} else if (element.options.attrs.default && element.options.attrs.default.isDynamic) {

View File

@ -170,7 +170,7 @@ class TimeDateServiceImpl extends WidgetService {
getParam(element, val) {
let timeArr = []
if (val) {
let value = [val]
let value = Array.isArray(val) ? val : val.split(',')
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)
} else if (element.options.attrs.default && element.options.attrs.default.isDynamic) {

View File

@ -131,7 +131,7 @@ class TimeMonthServiceImpl extends WidgetService {
getParam(element, val) {
let timeArr = []
if (val) {
let value = [val]
let value = Array.isArray(val) ? val : val.split(',')
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)
} else if (element.options.attrs.default && element.options.attrs.default.isDynamic) {

View File

@ -118,7 +118,7 @@ class TimeYearServiceImpl extends WidgetService {
getParam(element, val) {
let timeArr = []
if (val) {
let value = [val]
let value = Array.isArray(val) ? val : val.split(',')
value = this.formatFilterValue(value)
timeArr = this.formatValues(value, element)
} else if (element.options.attrs.default && element.options.attrs.default.isDynamic) {

View File

@ -1112,6 +1112,7 @@ export default {
desc: 'Descending Order',
sort: 'Sort',
filter: 'Filter',
is_set: 'Is Set',
none: 'None',
background: 'Background',

View File

@ -1112,6 +1112,7 @@ export default {
desc: '降序',
sort: '排序',
filter: '過濾',
is_set: '已設定',
none: '無',
background: '背景',
border: '邊角',

View File

@ -1111,6 +1111,7 @@ export default {
desc: '降序',
sort: '排序',
filter: '过滤',
is_set: '已设置',
none: '无',
background: '背景',
border: '边角',

View File

@ -267,7 +267,7 @@ const hexToRgba = (hex, opacity) => {
}
export function seniorCfg(chart_option, chart) {
if (chart.senior && chart.type && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('mix'))) {
if (chart.senior && chart.type && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('mix') || chart.type.includes('scatter'))) {
const senior = JSON.parse(chart.senior)
if (senior.functionCfg) {
if (senior.functionCfg.sliderShow) {

View File

@ -1043,7 +1043,7 @@ export function getSlider(chart) {
export function getAnalyse(chart) {
let senior = {}
const assistLine = []
if (chart.senior && chart.type && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('mix') || chart.type.includes('area'))) {
if (chart.senior && chart.type && (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('mix') || chart.type.includes('area') || chart.type.includes('scatter'))) {
senior = JSON.parse(chart.senior)
if (senior.assistLine && senior.assistLine.length > 0) {
const customStyle = JSON.parse(chart.customStyle)

View File

@ -576,7 +576,12 @@ function getConditions(chart) {
if (customAttr.color) {
const c = JSON.parse(JSON.stringify(customAttr.color))
valueColor = c.tableFontColor
valueBgColor = hexColorToRGBA(c.tableItemBgColor, c.alpha)
const enableTableCrossBG = c.enableTableCrossBG
if (!enableTableCrossBG) {
valueBgColor = hexColorToRGBA(c.tableItemBgColor, c.alpha)
} else {
valueBgColor = null
}
}
}
@ -594,9 +599,12 @@ function getConditions(chart) {
res.background.push({
field: field.field.dataeaseName,
mapping(value, rowData) {
return {
fill: mappingColor(value, valueBgColor, field, 'backgroundColor', filedValueMap, rowData)
const fill = mappingColor(value, valueBgColor, field, 'backgroundColor', filedValueMap, rowData)
if (fill) {
return { fill }
}
// 返回 null 会使用主题中的背景色
return null
}
})
}

View File

@ -1121,7 +1121,7 @@
<span
v-if="!!view.customFilter.logic"
class="setting"
>已设置</span>
>{{ $t('chart.is_set') }}</span>
<i
class="el-icon-arrow-down el-icon-delete data-area-clear"
@click="deleteTreeFilter"
@ -1136,7 +1136,7 @@
class="svg-background"
icon-class="icon-filter_outlined"
/>
<span>过滤</span>
<span>{{ $t('chart.filter') }}</span>
</div>
</el-row>
<el-row
@ -2106,7 +2106,8 @@ export default {
},
showCfg() {
return includesAny(this.view.type, 'bar', 'line', 'area', 'gauge', 'table', 'liquid') && this.view.type !== 'race-bar' ||
equalsAny(this.view.type, 'text', 'label', 'map', 'buddle-map') || this.view.render === 'echarts' && includesAny(this.view.type, 'mix')
equalsAny(this.view.type, 'text', 'label', 'map', 'buddle-map') || this.view.render === 'echarts' && includesAny(this.view.type, 'mix') ||
this.view.type === 'scatter'
},
showSeniorCfg() {
return includesAny(this.view.type, 'bar', 'line', 'area', 'table') ||
@ -2125,10 +2126,11 @@ export default {
}
return includesAny(this.view.type, 'bar', 'line', 'area', 'gauge', 'liquid') ||
equalsAny(this.view.type, 'text', 'label') ||
(this.view.render === 'antv' && this.view.type.includes('table')) || this.view.render === 'echarts' && includesAny(this.view.type, 'mix')
(this.view.render === 'antv' && this.view.type.includes('table')) || this.view.render === 'echarts' && includesAny(this.view.type, 'mix') ||
this.view.type === 'scatter'
},
showAssistLineCfg() {
return includesAny(this.view.type, 'bar', 'line', 'area', 'mix')
return includesAny(this.view.type, 'bar', 'line', 'area', 'mix') || this.view.type === 'scatter'
},
showThresholdCfg() {
if (this.view.type === 'bidirectional-bar') {

View File

@ -985,9 +985,12 @@ public class PrestoQueryProvider extends QueryProvider {
if (field.getDeExtractType() == 1) {
whereName = String.format(PrestoConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3) {
whereName = originName;
}
if (field.getDeExtractType() == 4) {
whereName = String.format(PrestoConstants.CAST, originName, "bigint");
}
} else {
whereName = originName;
}
@ -1185,9 +1188,12 @@ public class PrestoQueryProvider extends QueryProvider {
if (field.getDeExtractType() == 1) {
whereName = String.format(PrestoConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3) {
whereName = originName;
}
if (field.getDeExtractType() == 4) {
whereName = String.format(PrestoConstants.CAST, originName, "bigint");
}
} else {
whereName = originName;
}
@ -1284,9 +1290,12 @@ public class PrestoQueryProvider extends QueryProvider {
if (field.getDeExtractType() == 1) {
whereName = String.format(PrestoConstants.UNIX_TIMESTAMP, originName);
}
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3) {
whereName = originName;
}
if (field.getDeExtractType() == 4) {
whereName = String.format(PrestoConstants.CAST, originName, "bigint");
}
} else {
whereName = originName;
}

View File

@ -76,7 +76,7 @@
<span
v-if="!!view.customFilter.logic"
class="setting"
>已设置</span>
>{{ $t('chart.is_set') }}</span>
<i
class="el-icon-arrow-down el-icon-delete data-area-clear"
@click="deleteTreeFilter"
@ -91,7 +91,7 @@
class="svg-background"
icon-class="icon-filter_outlined"
/>
<span>过滤</span>
<span>{{ $t('chart.filter') }}</span>
</div>
</el-row>

View File

@ -96,7 +96,7 @@
<span
v-if="!!view.customFilter.logic"
class="setting"
>已设置</span>
>{{ $t('chart.is_set') }}</span>
<i
class="el-icon-arrow-down el-icon-delete data-area-clear"
@click="deleteTreeFilter"
@ -111,7 +111,7 @@
class="svg-background"
icon-class="icon-filter_outlined"
/>
<span>过滤</span>
<span>{{ $t('chart.filter') }}</span>
</div>
</el-row>

View File

@ -116,7 +116,7 @@
<span
v-if="!!view.customFilter.logic"
class="setting"
>已设置</span>
>{{ $t('chart.is_set') }}</span>
<i
class="el-icon-arrow-down el-icon-delete data-area-clear"
@click="deleteTreeFilter"
@ -131,7 +131,7 @@
class="svg-background"
icon-class="icon-filter_outlined"
/>
<span>过滤</span>
<span>{{ $t('chart.filter') }}</span>
</div>
</el-row>
<FilterTree

View File

@ -119,7 +119,7 @@
<span
v-if="!!view.customFilter.logic"
class="setting"
>已设置</span>
>{{ $t('chart.is_set') }}</span>
<i
class="el-icon-arrow-down el-icon-delete data-area-clear"
@click="deleteTreeFilter"
@ -134,7 +134,7 @@
class="svg-background"
icon-class="icon-filter_outlined"
/>
<span>过滤</span>
<span>{{ $t('chart.filter') }}</span>
</div>
</el-row>
<FilterTree

View File

@ -117,7 +117,7 @@
<span
v-if="!!view.customFilter.logic"
class="setting"
>已设置</span>
>{{ $t('chart.is_set') }}</span>
<i
class="el-icon-arrow-down el-icon-delete data-area-clear"
@click="deleteTreeFilter"
@ -132,7 +132,7 @@
class="svg-background"
icon-class="icon-filter_outlined"
/>
<span>过滤</span>
<span>{{ $t('chart.filter') }}</span>
</div>
</el-row>
<FilterTree

View File

@ -117,7 +117,7 @@
<span
v-if="!!view.customFilter.logic"
class="setting"
>已设置</span>
>{{ $t('chart.is_set') }}</span>
<i
class="el-icon-arrow-down el-icon-delete data-area-clear"
@click="deleteTreeFilter"
@ -132,7 +132,7 @@
class="svg-background"
icon-class="icon-filter_outlined"
/>
<span>过滤</span>
<span>{{ $t('chart.filter') }}</span>
</div>
</el-row>
<FilterTree