Merge branch 'dev' into pr@dev_one_dot_x

This commit is contained in:
dataeaseShu 2023-11-30 17:44:41 +08:00
commit 6dd352ae26
13 changed files with 82 additions and 24 deletions

View File

@ -34,7 +34,6 @@ public class DriverMgmController {
@ApiOperation("驱动列表")
@PostMapping("/list")
public List<DriverDTO> listDeDriver() throws Exception{
checkPermission();
return driverService.list();
}
@ -57,7 +56,6 @@ public class DriverMgmController {
@ApiOperation("驱动列表")
@GetMapping("/list/{type}")
public List<DriverDTO> listDeDriver(@PathVariable String type) throws Exception{
checkPermission();
return listDeDriver().stream().filter(driverDTO -> driverDTO.getType().equalsIgnoreCase(type)).collect(Collectors.toList());
}

View File

@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
@ -239,7 +241,12 @@ public class ApiProvider extends Provider {
String rootPath;
if (response.startsWith("[")) {
rootPath = "$[*]";
JSONArray jsonArray = JSONObject.parseArray(response);
JsonNode jsonArray = null;
try {
jsonArray = new ObjectMapper().readTree(response);
} catch (Exception e) {
e.printStackTrace();
}
for (Object o : jsonArray) {
handleStr(apiDefinition, o.toString(), fields, rootPath);
}

View File

@ -344,8 +344,10 @@ public class EsQueryProvider extends QueryProvider {
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) {
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
} else {
if (y.getDeType() == 2 || y.getDeType() == 3) {
if (y.getDeType() == 2) {
originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()), "bigint");
} else if (y.getDeType() == 3) {
originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName()), "float");
} else {
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
}

View File

@ -1379,6 +1379,9 @@ public class ChartViewService {
if (StringUtils.isEmpty(cValue)) {
continue;
}
if (sum.equals(new BigDecimal(0))) {
continue;
}
item[dataIndex] = new BigDecimal(cValue)
.divide(sum, 8, RoundingMode.HALF_UP)
.toString();

View File

@ -1115,7 +1115,25 @@ public class DataSetTableService {
}
}
private String handlePlainSelect(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception {
private void handleSelectItems(PlainSelect plainSelect, String dsType) throws Exception {
List<SelectItem> selectItems = new ArrayList<>();
for (SelectItem selectItem : plainSelect.getSelectItems()) {
try {
SelectExpressionItem selectExpressionItem = (SelectExpressionItem) selectItem;
if (selectExpressionItem.getExpression() instanceof SubSelect) {
SubSelect subSelect = (SubSelect) selectExpressionItem.getExpression();
Select select = (Select) CCJSqlParserUtil.parse(removeVariables(subSelect.getSelectBody().toString(), dsType));
subSelect.setSelectBody(select.getSelectBody());
((SelectExpressionItem) selectItem).setExpression(subSelect);
}
} catch (Exception e) {
}
selectItems.add(selectItem);
}
plainSelect.setSelectItems(selectItems);
}
private void handleFromItems(PlainSelect plainSelect, String dsType) throws Exception {
FromItem fromItem = plainSelect.getFromItem();
if (fromItem instanceof SubSelect) {
SelectBody selectBody = ((SubSelect) fromItem).getSelectBody();
@ -1123,7 +1141,9 @@ public class DataSetTableService {
Select subSelectTmp = (Select) CCJSqlParserUtil.parse(removeVariables(selectBody.toString(), dsType));
subSelect.setSelectBody(subSelectTmp.getSelectBody());
if (dsType.equals(DatasourceTypes.oracle.getType())) {
subSelect.setAlias(new Alias(fromItem.getAlias().toString(), false));
if (fromItem.getAlias() != null) {
subSelect.setAlias(new Alias(fromItem.getAlias().toString(), false));
}
} else {
if (fromItem.getAlias() == null) {
throw new Exception("Failed to parse sql, Every derived table must have its own alias");
@ -1132,6 +1152,9 @@ public class DataSetTableService {
}
plainSelect.setFromItem(subSelect);
}
}
private void handleJoins(PlainSelect plainSelect, String dsType) throws Exception {
List<Join> joins = plainSelect.getJoins();
if (joins != null) {
List<Join> joinsList = new ArrayList<>();
@ -1157,6 +1180,9 @@ public class DataSetTableService {
}
plainSelect.setJoins(joinsList);
}
}
private String handleWhere(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception {
Expression expr = plainSelect.getWhere();
if (expr == null) {
return handleWith(plainSelect, statementSelect, dsType);
@ -1198,6 +1224,14 @@ public class DataSetTableService {
return builder.toString();
}
private String handlePlainSelect(PlainSelect plainSelect, Select statementSelect, String dsType) throws Exception {
handleSelectItems(plainSelect, dsType);
handleFromItems(plainSelect, dsType);
handleJoins(plainSelect, dsType);
return handleWhere(plainSelect, statementSelect, dsType);
}
public Map<String, Object> getDBPreview(DataSetTableRequest dataSetTableRequest) throws Exception {
Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId());
if (ds == null) {
@ -1626,8 +1660,17 @@ public class DataSetTableService {
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
String[] array = fields.stream()
.map(f -> table + "." + f.getDataeaseName() + " AS "
+ TableUtils.fieldName(tableId + "_" + f.getDataeaseName()))
.map(f -> {
String s = "";
if (f == null) {
DEException.throwException(
Translator.get("i18n_ds_error"));
} else {
s = table + "." + f.getDataeaseName() + " AS "
+ TableUtils.fieldName(tableId + "_" + f.getDataeaseName());
}
return s;
})
.toArray(String[]::new);
checkedInfo.put(table, array);
checkedFields.addAll(fields);
@ -2753,13 +2796,13 @@ public class DataSetTableService {
if (StringUtils.isEmpty(s)) {
throw new RuntimeException(Translator.get("i18n_excel_empty_column"));
}
if(hashSet.contains(s)){
if (hashSet.contains(s)) {
repeat.add(s);
}else {
} else {
hashSet.add(s);
}
}
if(CollectionUtils.isNotEmpty(repeat)){
if (CollectionUtils.isNotEmpty(repeat)) {
DataEaseException.throwException(Translator.get("i18n_excel_field_repeat") + "" + String.valueOf(repeat));
}
}

View File

@ -136,6 +136,7 @@ export function panelDataPrepare(componentData, componentStyle, callback) {
}
if (item.type === 'custom') {
item.options.manualModify = false
item.options.loaded = false
}
if (item.filters && item.filters.length > 0) {
item.filters = []

View File

@ -382,6 +382,8 @@ export default {
componentId: this.element.id,
val: (this.value && Array.isArray(this.value)) ? this.value.join(',') : this.value
})
this.element.options.loaded = true
this.$store.commit('setComponentWithId', this.element)
}
},
refreshLoad() {

View File

@ -1945,7 +1945,7 @@ export default {
please_input_max_pool_size: 'Please enter the maximum number of connections',
please_input_max_idle_time: 'Please enter the maximum idle (seconds)',
please_input_acquire_increment: 'Please enter the growth number',
please_input_query_timeout: 'Please enter query timeout',
please_input_query_timeout: 'Please enter query timeoutValid range [1 - 300]',
please_input_connect_timeout: 'Please enter the connection timeout (seconds)',
no_less_then_0: 'Parameters in advanced settings cannot be less than zero',
port_no_less_then_0: 'Port cannot be less than zero',

View File

@ -1937,7 +1937,7 @@ export default {
please_input_max_pool_size: '請輸入最大連接數',
please_input_max_idle_time: '請輸入最大空閑(秒)',
please_input_acquire_increment: '請輸入增長數',
please_input_query_timeout: '請輸入查詢超時',
please_input_query_timeout: '請輸入查詢超時請填寫1-300正整數',
please_input_connect_timeout: '請輸輸入連接超時(秒)',
no_less_then_0: '高級設置中的參數不能小於零',
port_no_less_then_0: '端口不能小於零',

View File

@ -1937,7 +1937,7 @@ export default {
please_input_max_pool_size: '请输入最大连接数',
please_input_max_idle_time: '请输入最大空闲(秒)',
please_input_acquire_increment: '请输入增长数',
please_input_query_timeout: '请输入查询超时',
please_input_query_timeout: '请输入查询超时,填写1-300正整数',
please_input_connect_timeout: '请输入连接超时(秒)',
no_less_then_0: '高级设置中的参数不能小于零',
port_no_less_then_0: '端口不能小于零',

View File

@ -90,7 +90,8 @@ export const buildCanvasIdMap = panelItems => {
const cacheCondition = (cb, obj) => {
obj.cb = cb
}
export const buildViewKeyFilters = (panelItems, result) => {
export const buildViewKeyFilters = (panelItems, result, isEdit = false) => {
if (!(panelItems && panelItems.length > 0)) {
return result
}
@ -112,7 +113,7 @@ export const buildViewKeyFilters = (panelItems, result) => {
// 进行过滤时 如果过滤组件在主画布 则条件适用于所有画布视图 否则需要过滤组件和视图在相同画布
if (element.canvasId === 'canvas-main' || element.canvasId === canvasIdMap[viewId]) {
const vidMatch = viewIdMatch(condition.viewIds, viewId)
if (vidMatch && selectFirst) {
if (vidMatch && selectFirst && !element.options.loaded) {
const obj = {}
const promise = new Promise(resolve => {
cacheCondition(cbParam => {
@ -139,10 +140,9 @@ export const buildViewKeyFilters = (panelItems, result) => {
})
return result
}
export const buildFilterMap = panelItems => {
export const buildFilterMap = (panelItems, isEdit = false) => {
let result = buildViewKeyMap(panelItems)
result = buildViewKeyFilters(panelItems, result)
result = buildViewKeyFilters(panelItems, result, isEdit)
return result
}

View File

@ -999,8 +999,7 @@ export default {
{
required: true,
validator: this.isNumber,
message: i18n.t('datasource.please_input_query_timeout'),
trigger: 'blur'
trigger: ['blur', 'change']
}
],
dataPath: [
@ -1160,7 +1159,6 @@ export default {
callback()
},
isNumber(rule, value, callback) {
console.log(value)
if (!value) {
callback(new Error(i18n.t('datasource.please_input_query_timeout')))
return
@ -1169,7 +1167,11 @@ export default {
var reg = /^\d+$/;
isNumber = reg.test(value);
if (!isNumber) {
callback(new Error(i18n.t('chart.value_error')))
callback(new Error(i18n.t('datasource.please_input_query_timeout')))
return
}
if(value <= 0 || value > 300){
callback(new Error(i18n.t('datasource.please_input_query_timeout')))
return
}
callback()

View File

@ -946,7 +946,7 @@ export default {
this.tData.forEach((item) => {
if (item.id === this.form.type) {
item.children.forEach((child) => {
if (this.formType === 'modify' && child.id === this.form.id) {
if (child.id === this.form.id) {
return
}
const configuration = JSON.parse(child.configuration)