forked from github/dataease
Merge branch 'dev' into pr@dev@feat_sub_dim_sort
# Conflicts: # core/backend/src/main/java/io/dataease/service/chart/ChartViewService.java
This commit is contained in:
commit
fbbb434860
@ -6,6 +6,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
@ -18,7 +19,6 @@ import io.dataease.auth.annotation.DePermissionProxy;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.dto.PermissionProxy;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
|
@ -2,7 +2,7 @@ package io.dataease.auth.aop;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import io.dataease.auth.annotation.SqlInjectValidator;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.KeywordRequest;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -47,7 +47,7 @@ public class SqlInjectAop {
|
||||
String[] value = annotation.value();
|
||||
boolean illegal = isIllegal(value, request.getOrders());
|
||||
if (illegal) {
|
||||
DEException.throwException("Illegal sort exp");
|
||||
DataEaseException.throwException("Illegal sort exp");
|
||||
}
|
||||
return point.proceed(args);
|
||||
} catch (Throwable e) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.auth.filter;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
@ -10,8 +9,6 @@ import io.dataease.commons.license.DefaultLicenseService;
|
||||
import io.dataease.commons.license.F2CLicenseResponse;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.web.filter.AccessControlFilter;
|
||||
|
@ -13,12 +13,11 @@ import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.auth.util.RsaUtil;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.controller.sys.request.LdapAddRequest;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.util.PluginUtils;
|
||||
import io.dataease.plugins.xpack.cas.service.CasXpackService;
|
||||
@ -328,7 +327,7 @@ public class AuthServer implements AuthApi {
|
||||
oidcXpackService.logout(idToken);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("oidc_logout_error");
|
||||
DataEaseException.throwException("oidc_logout_error");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -349,7 +348,7 @@ public class AuthServer implements AuthApi {
|
||||
result = casXpackService.logout();
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("cas_logout_error");
|
||||
DataEaseException.throwException("cas_logout_error");
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
@ -8,7 +8,6 @@ import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.constants.ParamConstants;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.ext.AuthMapper;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SysLoginLimit;
|
||||
@ -16,6 +15,7 @@ import io.dataease.plugins.common.base.domain.SysLoginLimitExample;
|
||||
import io.dataease.plugins.common.base.domain.SysUser;
|
||||
import io.dataease.plugins.common.base.mapper.SysLoginLimitMapper;
|
||||
import io.dataease.plugins.common.base.mapper.SysUserMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.service.PluginCommonService;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.util.PluginUtils;
|
||||
|
@ -11,7 +11,7 @@ import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.entity.TokenInfo.TokenInfoBuilder;
|
||||
import io.dataease.commons.model.OnlineUserModel;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
@ -1,24 +0,0 @@
|
||||
package io.dataease.commons.exception;
|
||||
|
||||
public class DEException extends RuntimeException {
|
||||
|
||||
private DEException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
private DEException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public static void throwException(String message) {
|
||||
throw new DEException(message);
|
||||
}
|
||||
|
||||
public static DEException getException(String message) {
|
||||
throw new DEException(message);
|
||||
}
|
||||
|
||||
public static void throwException(Throwable t) {
|
||||
throw new DEException(t);
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package io.dataease.commons.filter;
|
||||
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.holder.ThreadLocalContextHolder;
|
||||
import io.dataease.commons.wrapper.XssAndSqlHttpServletRequestWrapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
@ -54,7 +54,7 @@ public class SqlFilter implements Filter {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
String msg = ThreadLocalContextHolder.getData().toString();
|
||||
DEException.throwException(msg);
|
||||
DataEaseException.throwException(msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -63,7 +63,7 @@ public class SqlFilter implements Filter {
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
String msg = ThreadLocalContextHolder.getData().toString();
|
||||
DEException.throwException(msg);
|
||||
DataEaseException.throwException(msg);
|
||||
return;
|
||||
}
|
||||
chain.doFilter(xssRequest, response);
|
||||
|
@ -1,9 +1,9 @@
|
||||
package io.dataease.commons.license;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.plugins.common.base.domain.License;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -103,10 +103,10 @@ public class DefaultLicenseService {
|
||||
public License readLicense() {
|
||||
License license = innerLicenseService.getLicense(LICENSE_ID);
|
||||
if (license == null) {
|
||||
DEException.throwException("i18n_no_license_record");
|
||||
DataEaseException.throwException("i18n_no_license_record");
|
||||
}
|
||||
if (StringUtils.isBlank(license.getLicense())) {
|
||||
DEException.throwException("i18n_license_is_empty");
|
||||
DataEaseException.throwException("i18n_license_is_empty");
|
||||
}
|
||||
return license;
|
||||
}
|
||||
@ -114,7 +114,7 @@ public class DefaultLicenseService {
|
||||
// 创建或更新License
|
||||
private void writeLicense(String licenseKey, F2CLicenseResponse response) {
|
||||
if (StringUtils.isBlank(licenseKey)) {
|
||||
DEException.throwException("i18n_license_is_empty");
|
||||
DataEaseException.throwException("i18n_license_is_empty");
|
||||
}
|
||||
License license = new License();
|
||||
license.setId(LICENSE_ID);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.dataease.commons.utils;
|
||||
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@ -47,11 +47,11 @@ public class DeFileUtils {
|
||||
public static void validateFile(MultipartFile file) {
|
||||
String name = getFileNameNoEx(file.getOriginalFilename());
|
||||
if (StringUtils.contains(name, "./")) {
|
||||
DEException.throwException("file path invalid");
|
||||
DataEaseException.throwException("file path invalid");
|
||||
}
|
||||
String suffix = getExtensionName(file.getOriginalFilename());
|
||||
if (!StringUtils.equalsIgnoreCase(suffix, "zip")) {
|
||||
DEException.throwException("please upload valid zip file");
|
||||
DataEaseException.throwException("please upload valid zip file");
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -3,8 +3,7 @@ package io.dataease.commons.utils;
|
||||
import static io.dataease.commons.constants.StaticResourceConstants.*;
|
||||
|
||||
import cn.hutool.core.codec.Base64Encoder;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.Assert;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package io.dataease.controller;
|
||||
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.license.DefaultLicenseService;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.service.panel.PanelLinkService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -74,7 +74,7 @@ public class IndexController {
|
||||
response.sendRedirect(url);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e.getMessage());
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ public class IndexController {
|
||||
response.sendRedirect(url);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e.getMessage());
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,13 +4,13 @@ import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.auth.annotation.DePermission;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.ResourceAuthLevel;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.response.ChartViewField4Type;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTable;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.service.chart.ChartViewFieldService;
|
||||
import io.dataease.service.dataset.DataSetTableService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -48,7 +48,7 @@ public class ChartViewFieldController {
|
||||
BeanUtils.copyProperties(chartViewField, datasetTableField);
|
||||
dataSetTableService.getPreviewData(dataSetTableRequest, 1, 1, Collections.singletonList(datasetTableField), null);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_calc_field_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_calc_field_error"));
|
||||
}
|
||||
return chartViewFieldService.save(chartViewField);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import io.dataease.auth.annotation.DePermissions;
|
||||
import io.dataease.auth.filter.F2CLinkFilter;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.ResourceAuthLevel;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.controller.request.dataset.DataSetTableRequest;
|
||||
import io.dataease.controller.request.dataset.MultFieldValuesRequest;
|
||||
import io.dataease.controller.response.DatasetTableField4Type;
|
||||
@ -18,6 +17,7 @@ import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTable;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
import io.dataease.plugins.datasource.query.QueryProvider;
|
||||
import io.dataease.plugins.xpack.auth.dto.request.ColumnPermissionItem;
|
||||
@ -167,7 +167,7 @@ public class DataSetTableFieldController {
|
||||
BeanUtils.copyProperties(datasetTable, dataSetTableRequest);
|
||||
dataSetTableService.getPreviewData(dataSetTableRequest, 1, 1, Collections.singletonList(datasetTableField), null);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_calc_field_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_calc_field_error"));
|
||||
}
|
||||
return dataSetTableFieldsService.save(datasetTableField);
|
||||
}
|
||||
|
@ -19,10 +19,6 @@ import io.dataease.dto.DatasourceDTO;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.dto.datasource.DBTableDTO;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.base.domain.DatasourceExample;
|
||||
import io.dataease.plugins.common.dto.datasource.DataSourceType;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.service.datasource.DatasourceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -36,7 +32,6 @@ import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Api(tags = "数据源:数据源管理")
|
||||
|
@ -3,16 +3,19 @@ package io.dataease.controller.datasource;
|
||||
|
||||
import io.dataease.auth.annotation.DeLog;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.dto.DriverDTO;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.DeDriver;
|
||||
import io.dataease.plugins.common.base.domain.DeDriverDetails;
|
||||
import io.dataease.plugins.common.dto.datasource.DataSourceType;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.service.datasource.DriverService;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -56,7 +59,25 @@ public class DriverMgmController {
|
||||
@ApiOperation("驱动列表")
|
||||
@GetMapping("/list/{type}")
|
||||
public List<DriverDTO> listDeDriver(@PathVariable String type) throws Exception {
|
||||
return listDeDriver().stream().filter(driverDTO -> driverDTO.getType().equalsIgnoreCase(type)).collect(Collectors.toList());
|
||||
List<DriverDTO> driverDTOS = listDeDriver().stream().filter(driverDTO -> driverDTO.getType().equalsIgnoreCase(type)).collect(Collectors.toList());
|
||||
DriverDTO driverDTO = new DriverDTO();
|
||||
driverDTO.setId("default");
|
||||
driverDTO.setName("default");
|
||||
driverDTO.setDriverClass("default");
|
||||
SpringContextUtil.getApplicationContext().getBeansOfType(DataSourceType.class).values().forEach(dataSourceType -> {
|
||||
if (dataSourceType.getType().equalsIgnoreCase(type)) {
|
||||
driverDTO.setSurpportVersions(dataSourceType.getSurpportVersions());
|
||||
}
|
||||
});
|
||||
driverDTOS.add(driverDTO);
|
||||
driverDTOS.forEach(driverDTO1 -> {
|
||||
if (StringUtils.isEmpty(driverDTO1.getSurpportVersions())) {
|
||||
driverDTO1.setNameAlias(driverDTO1.getName());
|
||||
} else {
|
||||
driverDTO1.setNameAlias(driverDTO1.getName() + "(" + driverDTO1.getSurpportVersions() + ")");
|
||||
}
|
||||
});
|
||||
return driverDTOS;
|
||||
}
|
||||
|
||||
@RequiresPermissions("datasource:read")
|
||||
@ -119,7 +140,7 @@ public class DriverMgmController {
|
||||
|
||||
private void checkPermission() throws Exception {
|
||||
if (!AuthUtils.getUser().getIsAdmin()) {
|
||||
DEException.throwException(Translator.get("I18N_NO_DRIVER_PERMISSION"));
|
||||
DataEaseException.throwException(Translator.get("I18N_NO_DRIVER_PERMISSION"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.controller.panel;
|
||||
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
||||
import io.dataease.dto.panel.PanelComponentDTO;
|
||||
import io.dataease.dto.panel.PanelViewTableDTO;
|
||||
import io.dataease.service.panel.PanelViewService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -29,4 +30,10 @@ public class PanelViewController {
|
||||
public List<PanelViewTableDTO> detailList(@PathVariable String panelId) throws Exception {
|
||||
return panelViewService.detailList(panelId);
|
||||
}
|
||||
|
||||
@ApiOperation("组件信息")
|
||||
@GetMapping("/getComponentInfo/{panelId}")
|
||||
public PanelComponentDTO getComponentInfo(@PathVariable String panelId) throws Exception {
|
||||
return panelViewService.getComponentInfo(panelId);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package io.dataease.controller.sys;
|
||||
import io.dataease.commons.license.DefaultLicenseService;
|
||||
import io.dataease.commons.license.F2CLicenseResponse;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -12,7 +12,6 @@ import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.ResourceAuthLevel;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
@ -21,11 +20,11 @@ import io.dataease.controller.sys.request.*;
|
||||
import io.dataease.controller.sys.response.AuthBindDTO;
|
||||
import io.dataease.controller.sys.response.RoleUserItem;
|
||||
import io.dataease.controller.sys.response.SysUserGridResponse;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SysRole;
|
||||
import io.dataease.plugins.common.base.domain.SysUser;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.KeywordRequest;
|
||||
import io.dataease.service.sys.SysRoleService;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
@ -72,7 +71,7 @@ public class SysUserController {
|
||||
public Long transAccount(@RequestBody TransAccountRequest request) {
|
||||
String account = request.getAccount();
|
||||
if (StringUtils.isBlank(account)) {
|
||||
DEException.throwException("account can not be null");
|
||||
DataEaseException.throwException("account can not be null");
|
||||
}
|
||||
return sysUserService.uidByAccount(account);
|
||||
}
|
||||
@ -297,7 +296,7 @@ public class SysUserController {
|
||||
|
||||
Boolean valid = StringUtils.equals(WECOM, type) || StringUtils.equals(DINGTALK, type) || StringUtils.equals(LARK, type) || StringUtils.equals(LARKSUITE, type);
|
||||
if (!valid) {
|
||||
DEException.throwException("only [wecom, dingtalk, lark, larksuite] is valid");
|
||||
DataEaseException.throwException("only [wecom, dingtalk, lark, larksuite] is valid");
|
||||
}
|
||||
Long userId = AuthUtils.getUser().getUserId();
|
||||
SysUserAssist sysUserAssist = sysUserService.assistInfo(userId);
|
||||
|
@ -6,4 +6,5 @@ import lombok.Data;
|
||||
@Data
|
||||
public class DriverDTO extends DeDriver {
|
||||
private String typeDesc;
|
||||
private String nameAlias;
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package io.dataease.dto.panel;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: wangjiahao
|
||||
* Date: 2021-03-05
|
||||
* Description:
|
||||
*/
|
||||
@Data
|
||||
public class PanelComponentDTO {
|
||||
|
||||
private String bashComponentData;
|
||||
|
||||
private List<PanelViewTableDTO> panelViewTables;
|
||||
|
||||
public PanelComponentDTO(String bashComponentData, List<PanelViewTableDTO> panelViewTables) {
|
||||
this.bashComponentData = bashComponentData;
|
||||
this.panelViewTables = panelViewTables;
|
||||
}
|
||||
}
|
@ -17,6 +17,9 @@ public class PanelViewTableDTO extends ChartViewWithBLOBs {
|
||||
@ApiModelProperty("仪表板ID")
|
||||
private String panelId;
|
||||
|
||||
@ApiModelProperty("仪表板数据")
|
||||
private String basePanelData;
|
||||
|
||||
private List<DatasetTableField> tableFields;
|
||||
|
||||
|
||||
|
@ -4,7 +4,8 @@ import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
|
||||
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
@ -1,24 +0,0 @@
|
||||
package io.dataease.exception;
|
||||
|
||||
public class DataEaseException extends RuntimeException {
|
||||
|
||||
private DataEaseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
private DataEaseException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
public static void throwException(String message) {
|
||||
throw new DataEaseException(message);
|
||||
}
|
||||
|
||||
public static DataEaseException getException(String message) {
|
||||
throw new DataEaseException(message);
|
||||
}
|
||||
|
||||
public static void throwException(Throwable t) {
|
||||
throw new DataEaseException(t);
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package io.dataease.exception;
|
||||
|
||||
/**
|
||||
* @author jianxing.chen
|
||||
*/
|
||||
public class ExcelException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ExcelException(String message, Exception e) {
|
||||
super(message, e);
|
||||
}
|
||||
|
||||
public ExcelException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ import com.alibaba.fastjson.serializer.ObjectSerializer;
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.context.MessageSource;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package io.dataease.job.sechedule;
|
||||
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.quartz.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -0,0 +1,45 @@
|
||||
package io.dataease.listener;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.SysStartupJob;
|
||||
import io.dataease.plugins.common.base.mapper.SysStartupJobMapper;
|
||||
import io.dataease.plugins.common.util.ClassloaderResponsity;
|
||||
import io.dataease.service.chart.ChartViewOldDataMergeService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Author Junjun
|
||||
*/
|
||||
@Component
|
||||
public class ChartFilterMergeListener implements ApplicationListener<ApplicationReadyEvent> {
|
||||
private final Logger logger = LoggerFactory.getLogger(ClassloaderResponsity.class);
|
||||
public static final String JOB_ID = "chartFilterMerge";
|
||||
@Resource
|
||||
private SysStartupJobMapper sysStartupJobMapper;
|
||||
@Resource
|
||||
private ChartViewOldDataMergeService chartViewOldDataMergeService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
|
||||
logger.info("====chart filter merge [start]====");
|
||||
|
||||
SysStartupJob sysStartupJob = sysStartupJobMapper.selectByPrimaryKey(JOB_ID);
|
||||
if (ObjectUtils.isNotEmpty(sysStartupJob) && StringUtils.equalsIgnoreCase(sysStartupJob.getStatus(), "ready")) {
|
||||
logger.info("====chart filter merge [doing]====");
|
||||
|
||||
chartViewOldDataMergeService.mergeOldData();
|
||||
chartViewOldDataMergeService.mergeCacheOldData();
|
||||
|
||||
sysStartupJob.setStatus("done");
|
||||
sysStartupJobMapper.updateByPrimaryKey(sysStartupJob);
|
||||
}
|
||||
logger.info("====chart filter merge [end]====");
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@ package io.dataease.map.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.map.dto.entity.AreaEntity;
|
||||
@ -10,6 +9,7 @@ import io.dataease.map.dto.request.MapNodeRequest;
|
||||
import io.dataease.map.utils.MapUtils;
|
||||
import io.dataease.plugins.common.base.domain.AreaMappingGlobal;
|
||||
import io.dataease.plugins.common.base.domain.AreaMappingGlobalExample;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@ -199,10 +199,10 @@ public class MapService {
|
||||
long size = file.getSize();
|
||||
String name = file.getOriginalFilename();
|
||||
if (size / 1024 / 1024 > 30) {
|
||||
DEException.throwException("large file that exceed 30M is not supported");
|
||||
DataEaseException.throwException("large file that exceed 30M is not supported");
|
||||
}
|
||||
if (!StringUtils.endsWith(name, ".json")) {
|
||||
DEException.throwException("only json file supported");
|
||||
DataEaseException.throwException("only json file supported");
|
||||
}
|
||||
}
|
||||
@Transactional
|
||||
@ -231,11 +231,11 @@ public class MapService {
|
||||
}else if (plevel == 4) {
|
||||
example.createCriteria().andCityCodeEqualTo(pCode).andCountyCodeEqualTo(code);
|
||||
} else {
|
||||
DEException.throwException("只支持3级行政区");
|
||||
DataEaseException.throwException("只支持3级行政区");
|
||||
}
|
||||
List<AreaMappingGlobal> lists = MapUtils.selectByExample(example);
|
||||
if (CollectionUtil.isNotEmpty(lists)) {
|
||||
DEException.throwException("区域代码已存在");
|
||||
DataEaseException.throwException("区域代码已存在");
|
||||
}
|
||||
|
||||
example.clear();
|
||||
@ -314,7 +314,7 @@ public class MapService {
|
||||
MapUtils.addNode(node);
|
||||
}
|
||||
} else {
|
||||
DEException.throwException("只支持3级行政区");
|
||||
DataEaseException.throwException("只支持3级行政区");
|
||||
}
|
||||
uploadMapFile(file, code);
|
||||
CacheUtils.removeAll("sys_map_areas_global");
|
||||
|
@ -5,10 +5,10 @@ import com.github.pagehelper.PageHelper;
|
||||
import io.dataease.auth.annotation.DePermission;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.ResourceAuthLevel;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeRequest;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
@ -34,11 +34,11 @@ public class RowPermissionsTreeController {
|
||||
@PostMapping("save")
|
||||
public void save(@RequestBody DataSetRowPermissionsTreeDTO request) {
|
||||
if (StringUtils.isEmpty(request.getAuthTargetType())) {
|
||||
DEException.throwException(Translator.get("i18n_row_permission_type_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_row_permission_type_error"));
|
||||
}
|
||||
if (!StringUtils.equalsIgnoreCase(request.getAuthTargetType(), "sysParams")) {
|
||||
if (ObjectUtils.isEmpty(request.getAuthTargetId())) {
|
||||
DEException.throwException(Translator.get("i18n_row_permission_id"));
|
||||
DataEaseException.throwException(Translator.get("i18n_row_permission_id"));
|
||||
}
|
||||
}
|
||||
RowPermissionTreeService rowPermissionTreeService = SpringContextUtil.getBean(RowPermissionTreeService.class);
|
||||
|
@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -23,7 +24,6 @@ import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
@ -53,12 +53,12 @@ public class SSOServer {
|
||||
try {
|
||||
Map<String, OidcXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((OidcXpackService.class));
|
||||
if (beansOfType.keySet().size() == 0) {
|
||||
DEException.throwException("缺少oidc插件");
|
||||
DataEaseException.throwException("缺少oidc插件");
|
||||
}
|
||||
oidcXpackService = SpringContextUtil.getBean(OidcXpackService.class);
|
||||
Boolean supportOIDC = oidcXpackService.isSupportOIDC();
|
||||
if (!supportOIDC) {
|
||||
DEException.throwException("未开启oidc");
|
||||
DataEaseException.throwException("未开启oidc");
|
||||
}
|
||||
Map<String, String> config = config(oidcXpackService);
|
||||
SSOToken ssoToken = oidcXpackService.requestSsoToken(config, code, state);
|
||||
|
@ -2,6 +2,7 @@ package io.dataease.plugins.server;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.xpack.theme.dto.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -12,7 +13,6 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
@ -49,11 +49,11 @@ public class ThemeServer {
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
if (ObjectUtils.isNotEmpty(e.getMessage()) && e.getMessage().indexOf("theme_name_repeat") != -1) {
|
||||
DEException.throwException(Translator.get("theme_name_repeat"));
|
||||
DataEaseException.throwException(Translator.get("theme_name_repeat"));
|
||||
} else if (ObjectUtils.isNotEmpty(e.getMessage()) && e.getMessage().indexOf("theme_name_empty") != -1) {
|
||||
DEException.throwException(Translator.get("theme_name_empty"));
|
||||
DataEaseException.throwException(Translator.get("theme_name_empty"));
|
||||
} else {
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,11 +71,11 @@ public class ThemeServer {
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
if (ObjectUtils.isNotEmpty(e.getMessage()) && e.getMessage().indexOf("theme_name_repeat") != -1) {
|
||||
DEException.throwException(Translator.get("theme_name_repeat"));
|
||||
DataEaseException.throwException(Translator.get("theme_name_repeat"));
|
||||
} else if (ObjectUtils.isNotEmpty(e.getMessage()) && e.getMessage().indexOf("theme_name_empty") != -1) {
|
||||
DEException.throwException(Translator.get("theme_name_empty"));
|
||||
DataEaseException.throwException(Translator.get("theme_name_empty"));
|
||||
} else {
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.ResourceAuthLevel;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.commons.utils.PageUtils;
|
||||
@ -20,6 +19,7 @@ import io.dataease.commons.utils.Pager;
|
||||
import io.dataease.controller.sys.response.DeptNodeResponse;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.dept.dto.request.*;
|
||||
import io.dataease.plugins.xpack.dept.dto.response.DeptUserItemDTO;
|
||||
@ -191,7 +191,7 @@ public class XDeptServer {
|
||||
public void unBindUser(@RequestBody XpackDeptBindRequest request) {
|
||||
DeptXpackService deptService = SpringContextUtil.getBean(DeptXpackService.class);
|
||||
if (CollectionUtil.isEmpty(request.getUserIds())) {
|
||||
DEException.throwException("userIds can not be empty");
|
||||
DataEaseException.throwException("userIds can not be empty");
|
||||
}
|
||||
request.getUserIds().forEach(userId -> {
|
||||
SysLogDTO sysLogDTO = DeLogUtils.buildBindRoleUserLog(request.getDeptId(), userId, SysLogConstants.OPERATE_TYPE.UNBIND, SysLogConstants.SOURCE_TYPE.DEPT);
|
||||
|
@ -5,13 +5,12 @@ import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.dingtalk.dto.response.DingQrResult;
|
||||
import io.dataease.plugins.xpack.dingtalk.dto.response.DingUserEntity;
|
||||
@ -87,19 +86,19 @@ public class XDingtalkServer {
|
||||
try {
|
||||
Map<String, DingtalkXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((DingtalkXpackService.class));
|
||||
if (beansOfType.keySet().size() == 0) {
|
||||
DEException.throwException("缺少钉钉插件");
|
||||
DataEaseException.throwException("缺少钉钉插件");
|
||||
}
|
||||
dingtalkXpackService = SpringContextUtil.getBean(DingtalkXpackService.class);
|
||||
Boolean isOpen = dingtalkXpackService.isOpen();
|
||||
if (!isOpen) {
|
||||
DEException.throwException("未开启钉钉");
|
||||
DataEaseException.throwException("未开启钉钉");
|
||||
}
|
||||
DingUserEntity dingUserEntity = withoutLogin ? dingtalkXpackService.userInfoWithoutLogin(code) : dingtalkXpackService.userInfo(code);
|
||||
String username = dingUserEntity.getUserid();
|
||||
SysUserEntity sysUserEntity = authUserService.getUserByDingtalkId(username);
|
||||
if (null == sysUserEntity) {
|
||||
if (authUserService.checkScanCreateLimit())
|
||||
DEException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
|
||||
DataEaseException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
|
||||
String email = StringUtils.isNotBlank(dingUserEntity.getOrg_email()) ? dingUserEntity.getOrg_email() : StringUtils.isNotBlank(dingUserEntity.getEmail()) ? dingUserEntity.getEmail() : (username + "@dingtalk.work");
|
||||
sysUserService.validateExistUser(username, dingUserEntity.getName(), email);
|
||||
sysUserService.saveDingtalkCUser(dingUserEntity, email);
|
||||
@ -162,7 +161,7 @@ public class XDingtalkServer {
|
||||
response.sendRedirect(url);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,7 +187,7 @@ public class XDingtalkServer {
|
||||
}
|
||||
Boolean isOpen = authUserService.supportDingtalk();
|
||||
if (!isOpen) {
|
||||
DEException.throwException("未开启钉钉");
|
||||
DataEaseException.throwException("未开启钉钉");
|
||||
}
|
||||
dingtalkXpackService = SpringContextUtil.getBean(DingtalkXpackService.class);
|
||||
DingUserEntity dingUserEntity = dingtalkXpackService.userInfo(code);
|
||||
|
@ -7,13 +7,13 @@ import com.github.pagehelper.PageHelper;
|
||||
import io.dataease.auth.annotation.DeRateLimiter;
|
||||
import io.dataease.auth.annotation.SqlInjectValidator;
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.model.excel.ExcelSheetModel;
|
||||
import io.dataease.commons.pool.PriorityThreadPoolExecutor;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskInstance;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.email.dto.request.*;
|
||||
import io.dataease.plugins.xpack.email.dto.response.XpackTaskEntity;
|
||||
@ -172,7 +172,7 @@ public class XEmailTaskServer {
|
||||
return emailXpackService.printPdf(url, currentToken, buildPixel(request.getPixel()), request.isShowPageNo(), false);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("预览失败,请联系管理员");
|
||||
DataEaseException.throwException("预览失败,请联系管理员");
|
||||
}
|
||||
return null;
|
||||
}, 0);
|
||||
@ -191,7 +191,7 @@ public class XEmailTaskServer {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("预览失败,请联系管理员");
|
||||
DataEaseException.throwException("预览失败,请联系管理员");
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -210,7 +210,7 @@ public class XEmailTaskServer {
|
||||
return emailXpackService.print(url, currentToken, buildPixel(request.getPixel()), request.getExtWaitTime());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("预览失败,请联系管理员");
|
||||
DataEaseException.throwException("预览失败,请联系管理员");
|
||||
}
|
||||
return null;
|
||||
}, 0);
|
||||
@ -229,7 +229,7 @@ public class XEmailTaskServer {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("预览失败,请联系管理员");
|
||||
DataEaseException.throwException("预览失败,请联系管理员");
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -250,7 +250,7 @@ public class XEmailTaskServer {
|
||||
return emailXpackService.print(url, token, buildPixel(request.getPixel()), request.getExtWaitTime());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("预览失败,请联系管理员");
|
||||
DataEaseException.throwException("预览失败,请联系管理员");
|
||||
}
|
||||
return null;
|
||||
}, 0);
|
||||
@ -268,7 +268,7 @@ public class XEmailTaskServer {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException("预览失败,请联系管理员");
|
||||
DataEaseException.throwException("预览失败,请联系管理员");
|
||||
}
|
||||
return null;
|
||||
|
||||
@ -285,7 +285,7 @@ public class XEmailTaskServer {
|
||||
emailXpackService.delete(taskId);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ public class XEmailTaskServer {
|
||||
emailXpackService.batchDel(taskIds);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,14 +5,13 @@ import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkAppUserEntity;
|
||||
@ -104,12 +103,12 @@ public class XLarkServer {
|
||||
try {
|
||||
Map<String, LarkXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((LarkXpackService.class));
|
||||
if (beansOfType.keySet().size() == 0) {
|
||||
DEException.throwException("缺少飞书插件");
|
||||
DataEaseException.throwException("缺少飞书插件");
|
||||
}
|
||||
larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
Boolean isOpen = larkXpackService.isOpen();
|
||||
if (!isOpen) {
|
||||
DEException.throwException("未开启飞书");
|
||||
DataEaseException.throwException("未开启飞书");
|
||||
}
|
||||
LarkUserInfo larkUserInfo = null;
|
||||
if (withoutLogin) {
|
||||
@ -123,7 +122,7 @@ public class XLarkServer {
|
||||
SysUserEntity sysUserEntity = authUserService.getUserByLarkId(username);
|
||||
if (null == sysUserEntity) {
|
||||
if (authUserService.checkScanCreateLimit())
|
||||
DEException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
|
||||
DataEaseException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
|
||||
String email = StringUtils.isNotBlank(larkUserInfo.getEmail()) ? larkUserInfo.getEmail() : (username + "@lark.work");
|
||||
sysUserService.validateExistUser(username, larkUserInfo.getName(), email);
|
||||
sysUserService.saveLarkCUser(larkUserInfo, email);
|
||||
@ -180,7 +179,7 @@ public class XLarkServer {
|
||||
response.sendRedirect(url);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +204,7 @@ public class XLarkServer {
|
||||
|
||||
Boolean isOpen = authUserService.supportLark();
|
||||
if (!isOpen) {
|
||||
DEException.throwException("未开启飞书");
|
||||
DataEaseException.throwException("未开启飞书");
|
||||
}
|
||||
larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
LarkUserInfo larkUserInfo = larkXpackService.userInfo(code, state, true);
|
||||
|
@ -5,13 +5,12 @@ import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkQrResult;
|
||||
@ -88,12 +87,12 @@ public class XLarksuiteServer {
|
||||
try {
|
||||
Map<String, LarksuiteXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((LarksuiteXpackService.class));
|
||||
if (beansOfType.keySet().size() == 0) {
|
||||
DEException.throwException("缺少国际飞书插件");
|
||||
DataEaseException.throwException("缺少国际飞书插件");
|
||||
}
|
||||
larksuiteXpackService = SpringContextUtil.getBean(LarksuiteXpackService.class);
|
||||
Boolean isOpen = larksuiteXpackService.isOpen();
|
||||
if (!isOpen) {
|
||||
DEException.throwException("未开启国际飞书");
|
||||
DataEaseException.throwException("未开启国际飞书");
|
||||
}
|
||||
LarksuiteUserResult larksuiteUserResult = larksuiteXpackService.userInfo(code, state, false);
|
||||
UserData larkUserInfo = larksuiteUserResult.getData();
|
||||
@ -101,7 +100,7 @@ public class XLarksuiteServer {
|
||||
SysUserEntity sysUserEntity = authUserService.getUserByLarksuiteId(username);
|
||||
if (null == sysUserEntity) {
|
||||
if (authUserService.checkScanCreateLimit())
|
||||
DEException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
|
||||
DataEaseException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
|
||||
String email = StringUtils.isNotBlank(larkUserInfo.getEmail()) ? larkUserInfo.getEmail() : (username + "@larksuite.work");
|
||||
sysUserService.validateExistUser(username, larkUserInfo.getName(), email);
|
||||
sysUserService.saveLarksuiteCUser(larkUserInfo, email);
|
||||
@ -148,7 +147,7 @@ public class XLarksuiteServer {
|
||||
response.sendRedirect(url);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,7 +172,7 @@ public class XLarksuiteServer {
|
||||
|
||||
Boolean isOpen = authUserService.supportLarksuite();
|
||||
if (!isOpen) {
|
||||
DEException.throwException("未开启国际飞书");
|
||||
DataEaseException.throwException("未开启国际飞书");
|
||||
}
|
||||
larksuiteXpackService = SpringContextUtil.getBean(LarksuiteXpackService.class);
|
||||
LarksuiteUserResult larksuiteUserResult = larksuiteXpackService.userInfo(code, state, true);
|
||||
|
@ -6,13 +6,12 @@ import io.dataease.auth.entity.TokenInfo;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.util.JWTUtils;
|
||||
import io.dataease.commons.constants.SysLogConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.DeLogUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.display.dto.response.SysSettingDto;
|
||||
|
||||
@ -98,12 +97,12 @@ public class XWecomServer {
|
||||
try {
|
||||
Map<String, WecomXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((WecomXpackService.class));
|
||||
if (beansOfType.keySet().size() == 0) {
|
||||
DEException.throwException("缺少企业微信插件");
|
||||
DataEaseException.throwException("缺少企业微信插件");
|
||||
}
|
||||
wecomXpackService = SpringContextUtil.getBean(WecomXpackService.class);
|
||||
Boolean isOpen = wecomXpackService.isOpen();
|
||||
if (!isOpen) {
|
||||
DEException.throwException("未开启企业微信");
|
||||
DataEaseException.throwException("未开启企业微信");
|
||||
}
|
||||
WecomAuthResult authResult = wecomXpackService.auth(code);
|
||||
|
||||
@ -113,7 +112,7 @@ public class XWecomServer {
|
||||
SysUserEntity sysUserEntity = authUserService.getUserByWecomId(userId);
|
||||
if (null == sysUserEntity) {
|
||||
if (authUserService.checkScanCreateLimit())
|
||||
DEException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
|
||||
DataEaseException.throwException(Translator.get("I18N_PROHIBIT_SCANNING_TO_CREATE_USER"));
|
||||
Object emailObj = ObjectUtils.isEmpty(userMap.get("biz_mail")) ? userMap.get("email") : userMap.get("biz_mail");
|
||||
String email = ObjectUtils.isEmpty(emailObj) ? (userId + "@wecom.work") : emailObj.toString();
|
||||
sysUserService.validateExistUser(userId, userMap.get("name").toString(), email);
|
||||
@ -170,7 +169,7 @@ public class XWecomServer {
|
||||
response.sendRedirect(url);
|
||||
} catch (IOException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +195,7 @@ public class XWecomServer {
|
||||
|
||||
Boolean supportWecom = authUserService.supportWecom();
|
||||
if (!supportWecom) {
|
||||
DEException.throwException("未开启企业微信");
|
||||
DataEaseException.throwException("未开启企业微信");
|
||||
return;
|
||||
}
|
||||
wecomXpackService = SpringContextUtil.getBean(WecomXpackService.class);
|
||||
|
@ -34,6 +34,7 @@ public class ProviderFactory implements ApplicationContextAware {
|
||||
dataSourceType.setKeywordPrefix(d.getKeywordPrefix());
|
||||
dataSourceType.setAliasSuffix(d.getAliasSuffix());
|
||||
dataSourceType.setAliasPrefix(d.getAliasPrefix());
|
||||
dataSourceType.setSurpportVersions(d.getSurpportVersions());
|
||||
beanFactory.registerSingleton(d.getType(), dataSourceType);
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,11 @@ import io.dataease.controller.request.datasource.es.EsResponse;
|
||||
import io.dataease.controller.request.datasource.es.Request;
|
||||
import io.dataease.controller.request.datasource.es.RequestWithCursor;
|
||||
import io.dataease.dto.datasource.EsConfiguration;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.constants.datasource.EsSqlLConstants;
|
||||
import io.dataease.plugins.common.dto.datasource.TableDesc;
|
||||
import io.dataease.plugins.common.dto.datasource.TableField;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
import io.dataease.provider.query.es.EsQueryProvider;
|
||||
|
@ -5,15 +5,18 @@ import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.dto.datasource.*;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.base.domain.DeDriver;
|
||||
import io.dataease.plugins.common.base.mapper.DeDriverMapper;
|
||||
import io.dataease.plugins.common.constants.DatasourceTypes;
|
||||
import io.dataease.plugins.common.constants.datasource.MySQLConstants;
|
||||
import io.dataease.plugins.common.dto.datasource.DataSourceType;
|
||||
import io.dataease.plugins.common.dto.datasource.TableField;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.datasource.entity.JdbcConfiguration;
|
||||
import io.dataease.plugins.datasource.provider.DefaultJdbcProvider;
|
||||
import io.dataease.plugins.datasource.provider.ExtendedJdbcClassLoader;
|
||||
@ -21,6 +24,7 @@ import io.dataease.plugins.datasource.query.QueryProvider;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
@ -510,16 +514,23 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
}
|
||||
|
||||
Connection conn;
|
||||
String surpportVersions = null;
|
||||
String driverClassName;
|
||||
ExtendedJdbcClassLoader jdbcClassLoader;
|
||||
if (isDefaultClassLoader(customDriver)) {
|
||||
driverClassName = defaultDriver;
|
||||
jdbcClassLoader = extendedJdbcClassLoader;
|
||||
for (DataSourceType value : SpringContextUtil.getApplicationContext().getBeansOfType(DataSourceType.class).values()) {
|
||||
if(value.getType().equalsIgnoreCase(datasourceRequest.getDatasource().getType())){
|
||||
surpportVersions = value.getSurpportVersions();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (deDriver == null) {
|
||||
deDriver = deDriverMapper.selectByPrimaryKey(customDriver);
|
||||
}
|
||||
driverClassName = deDriver.getDriverClass();
|
||||
surpportVersions = deDriver.getSurpportVersions();
|
||||
jdbcClassLoader = getCustomJdbcClassLoader(deDriver);
|
||||
}
|
||||
|
||||
@ -534,6 +545,12 @@ public class JdbcProvider extends DefaultJdbcProvider {
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(classLoader);
|
||||
}
|
||||
|
||||
if(StringUtils.isNotEmpty(surpportVersions) && surpportVersions.split(",").length > 0){
|
||||
if(! Arrays.asList(surpportVersions.split(",")).contains(String.valueOf(conn.getMetaData().getDatabaseMajorVersion()))){
|
||||
DataEaseException.throwException("当前驱动不支持此版本!");
|
||||
};
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.provider.engine.doris;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -18,7 +17,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -93,12 +95,12 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -192,7 +194,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
st_sql.add("groups", xFields);
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -268,37 +270,37 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sql + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sql + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -362,7 +364,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -407,7 +409,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + "," + pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -416,7 +418,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -458,7 +460,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -499,22 +501,22 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sql + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -581,7 +583,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -626,12 +628,12 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + table + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -719,7 +721,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -764,17 +766,123 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + table + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
} else {
|
||||
originField = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(DorisConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(DorisConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) {
|
||||
st_sql.add("useAliasForGroup", true);
|
||||
st_sql.add("groups", xFields);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(DorisConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(DorisConstants.KEYWORD_TABLE, table))
|
||||
@ -811,7 +919,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -849,7 +957,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sql + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -953,6 +1061,81 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
|
||||
} else {
|
||||
originName = String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
|
||||
whereName = String.format(DorisConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : DorisConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(DorisConstants.FROM_UNIXTIME, cast, DorisConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(DorisConstants.CAST, originName, DorisConstants.DEFAULT_FLOAT_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(DorisConstants.UNIX_TIMESTAMP, originName) + "*1000";
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 0) {
|
||||
whereName = String.format(DorisConstants.CAST, originName, DorisConstants.VARCHAR);
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in")) {
|
||||
whereValue = "('" + StringUtils.join(value, "','") + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(DorisConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
return createSQLPreview("SELECT * FROM " + String.format(DorisConstants.KEYWORD_TABLE, tableName), null);
|
||||
@ -1424,7 +1607,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1433,7 +1616,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1465,7 +1648,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.provider.engine.mysql;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -18,7 +17,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -94,12 +96,12 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MysqlConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -163,7 +165,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
@ -238,37 +240,37 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sql + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sql + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MysqlConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -333,7 +335,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -375,7 +377,111 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MysqlConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 计算字段和视图字段,规则为 函数([原始字段id]),这边把[原始字段id] 换成 表名.原始字段id
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
} else {
|
||||
originField = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(MysqlConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(MysqlConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(MysqlConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + "," + pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -384,7 +490,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MysqlConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -422,7 +528,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -460,22 +566,22 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sql + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MysqlConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -542,7 +648,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -584,12 +690,12 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + table + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MysqlConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -677,7 +783,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -719,7 +825,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + table + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@ -729,7 +835,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MysqlConstants.KEYWORD_TABLE, table))
|
||||
@ -766,7 +872,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -804,7 +910,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sql + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -908,6 +1014,81 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
|
||||
} else {
|
||||
originName = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getDataeaseName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5 || field.getDeExtractType() == 1) {
|
||||
whereName = String.format(MysqlConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : MysqlConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(MysqlConstants.CAST, originName, MysqlConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(MysqlConstants.FROM_UNIXTIME, cast, MysqlConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(MysqlConstants.CAST, originName, MysqlConstants.DEFAULT_FLOAT_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(MysqlConstants.UNIX_TIMESTAMP, originName) + "*1000";
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 0 && field.getDeExtractType() == 0) {
|
||||
whereName = String.format(MysqlConstants.CAST, originName, MysqlConstants.CHAR);
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in")) {
|
||||
whereValue = "('" + StringUtils.join(value, "','") + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(MysqlConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
return createSQLPreview("SELECT * FROM " + String.format(MysqlConstants.KEYWORD_TABLE, tableName), null);
|
||||
@ -957,6 +1138,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String transCustomFilterList(SQLObj tableObj, List<ChartFieldCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
@ -1372,7 +1554,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1381,7 +1563,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1413,7 +1595,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -3,11 +3,12 @@ package io.dataease.provider.query.api;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.query.QueryProvider;
|
||||
@ -41,97 +42,107 @@ public class ApiProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String s, List<DatasetTableField> list, boolean b, Datasource datasource, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String s, List<DatasetTableField> list, boolean b, Datasource datasource, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String s, List<DatasetTableField> list, boolean b, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String s, List<DatasetTableField> list, boolean b, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String s, List<DatasetTableField> list, Integer integer, Integer integer1, Integer integer2, boolean b, Datasource datasource, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String s, List<DatasetTableField> list, Integer integer, Integer integer1, Integer integer2, boolean b, Datasource datasource, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String s, List<DatasetTableField> list, Integer integer, Integer integer1, Integer integer2, boolean b, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String s, List<DatasetTableField> list, Integer integer, Integer integer1, Integer integer2, boolean b, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String s, List<DatasetTableField> list, Integer integer, boolean b, Datasource datasource, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String s, List<DatasetTableField> list, Integer integer, boolean b, Datasource datasource, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String s, List<DatasetTableField> list, Integer integer, boolean b, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String s, List<DatasetTableField> list, Integer integer, boolean b, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, List<ChartFieldCustomFilterDTO> list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
public String getSQL(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, FilterTreeObj list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String s, List<DatasetTableField> list, boolean b, Datasource datasource, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> list2, Long limit, String keyword) {
|
||||
public String createQuerySQL(String s, List<DatasetTableField> list, boolean b, Datasource datasource, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> list2, Long limit, String keyword) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String s, List<DatasetTableField> list, boolean b, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> list2, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String s, List<DatasetTableField> list, boolean b, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> list2, Long limit, String keyword) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, List<ChartFieldCustomFilterDTO> list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
public String getSQLAsTmp(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, FilterTreeObj list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String s, List<ChartViewFieldDTO> list, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list2, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
public String getSQLTableInfo(String s, List<ChartViewFieldDTO> list, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list2, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String s, List<ChartViewFieldDTO> list, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list2, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
public String getSQLAsTmpTableInfo(String s, List<ChartViewFieldDTO> list, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list2, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, List<ChartFieldCustomFilterDTO> list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, List<ChartViewFieldDTO> list4, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
public String getSQLStack(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, FilterTreeObj list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, List<ChartViewFieldDTO> list4, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, List<ChartFieldCustomFilterDTO> list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, List<ChartViewFieldDTO> list4, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
public String getSQLAsTmpStack(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, FilterTreeObj list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, List<ChartViewFieldDTO> list4, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, List<ChartFieldCustomFilterDTO> list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, List<ChartViewFieldDTO> list4, List<ChartViewFieldDTO> extGroup, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
public String getSQLScatter(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, FilterTreeObj list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, List<ChartViewFieldDTO> list4, List<ChartViewFieldDTO> extGroup, Datasource datasource, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, List<ChartFieldCustomFilterDTO> list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, List<ChartViewFieldDTO> list4, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
public String getSQLAsTmpScatter(String s, List<ChartViewFieldDTO> list, List<ChartViewFieldDTO> list1, FilterTreeObj list2, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list3, List<ChartViewFieldDTO> list4, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String s, List<ChartViewFieldDTO> list, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list2, ChartViewWithBLOBs chartViewWithBLOBs, Datasource datasource) {
|
||||
public String getSQLSummary(String s, List<ChartViewFieldDTO> list, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list2, ChartViewWithBLOBs chartViewWithBLOBs, Datasource datasource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String s, List<ChartViewFieldDTO> list, List<ChartFieldCustomFilterDTO> list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list2, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
public String getSQLSummaryAsTmp(String s, List<ChartViewFieldDTO> list, FilterTreeObj list1, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> list2, ChartViewWithBLOBs chartViewWithBLOBs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -154,4 +165,9 @@ public class ApiProvider extends QueryProvider {
|
||||
public String transTreeItem(SQLObj sqlObj, DatasetRowPermissionsTreeItem datasetRowPermissionsTreeItem) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.provider.query.ck;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
@ -17,7 +16,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -62,6 +64,9 @@ public class CKQueryProvider extends QueryProvider {
|
||||
if (field.indexOf("DATETIME64") > -1) {
|
||||
field = "DATETIME64";
|
||||
}
|
||||
if (field.indexOf("DECIMAL") > -1) {
|
||||
field = "DECIMAL";
|
||||
}
|
||||
switch (field) {
|
||||
case "STRING":
|
||||
case "VARCHAR":
|
||||
@ -122,12 +127,12 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -191,7 +196,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -273,37 +278,37 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -367,7 +372,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -409,7 +414,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + "," + pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -419,11 +424,11 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -461,7 +466,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -499,18 +504,18 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -577,7 +582,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -619,12 +624,12 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -712,7 +717,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -754,17 +759,119 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(CKConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(CKConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(CKConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(CKConstants.KEYWORD_TABLE, table))
|
||||
@ -801,7 +908,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -839,7 +946,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -972,6 +1079,98 @@ public class CKQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(CKConstants.toDateTime, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(CKConstants.toFloat64, originName);
|
||||
whereName = String.format(CKConstants.toDateTime, cast);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(CKConstants.toFloat64, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(CKConstants.toInt32, String.format(CKConstants.toDateTime, originName)) + "*1000";
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in")) {
|
||||
whereValue = "('" + StringUtils.join(value, "','") + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
whereValue = String.format(CKConstants.toDateTime, "'" + value + "'");
|
||||
} else {
|
||||
whereValue = String.format(CKConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
}
|
||||
SQLObj build;
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME && StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue("is null")
|
||||
.build();
|
||||
} else if (field.getDeType() == DeTypeConstants.DE_TIME && StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue("is not null")
|
||||
.build();
|
||||
} else {
|
||||
build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
}
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
return createSQLPreview("SELECT * FROM " + String.format(CKConstants.KEYWORD_TABLE, tableName), null);
|
||||
@ -1422,7 +1621,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1431,7 +1630,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1463,7 +1662,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package io.dataease.provider.query.db2;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.dto.datasource.Db2Configuration;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
@ -18,7 +17,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -91,12 +93,12 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(Db2Constants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -167,7 +169,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -254,39 +256,39 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
Integer size = (page - 1) * pageSize + realSize;
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree) + String.format(" fetch first %s rows only ", size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree) + String.format(" fetch first %s rows only ", limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + String.format(" fetch first %s rows only ", limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
Integer size = (page - 1) * pageSize + realSize;
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + String.format(" fetch first %s rows only ", size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(Db2Constants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -351,7 +353,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -392,7 +394,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(Db2Constants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -432,7 +434,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -470,12 +472,12 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + "," + pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -485,18 +487,18 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(Db2Constants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -564,7 +566,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -606,12 +608,12 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(Db2Constants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -700,7 +702,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -742,17 +744,121 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(Db2Constants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(Db2Constants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(Db2Constants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(Db2Constants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(Db2Constants.KEYWORD_TABLE, table))
|
||||
@ -790,7 +896,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -828,7 +934,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -965,6 +1071,98 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
|
||||
if (StringUtils.isNotEmpty(field.getDateFormat())) {
|
||||
originName = String.format(Db2Constants.TO_DATE, originName, field.getDateFormat());
|
||||
} else {
|
||||
originName = String.format(Db2Constants.STR_TO_DATE, originName);
|
||||
}
|
||||
whereName = String.format(Db2Constants.DATE_FORMAT, originName, Db2Constants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT) {
|
||||
String cast = String.format(Db2Constants.CAST, originName, Db2Constants.DEFAULT_INT_FORMAT);
|
||||
whereName = String.format(Db2Constants.FROM_UNIXTIME, cast, Db2Constants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
if (field.getType().equalsIgnoreCase("TIME")) {
|
||||
whereName = String.format(Db2Constants.FORMAT_TIME, originName, Db2Constants.DEFAULT_DATE_FORMAT);
|
||||
} else if (field.getType().equalsIgnoreCase("DATE")) {
|
||||
whereName = String.format(Db2Constants.FORMAT_DATE, originName, Db2Constants.DEFAULT_DATE_FORMAT);
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(Db2Constants.CAST, originName, Db2Constants.DEFAULT_FLOAT_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(Db2Constants.UNIX_TIMESTAMP, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
if (field.getDeType().equals(DeTypeConstants.DE_TIME)) {
|
||||
whereValue = String.format(Db2Constants.DATE_FORMAT, "'" + value + "'", Db2Constants.DEFAULT_DATE_FORMAT);
|
||||
} else if (field.getDeType().equals(DeTypeConstants.DE_FLOAT)) {
|
||||
whereValue = value;
|
||||
} else {
|
||||
whereValue = String.format(Db2Constants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
return createSQLPreview("SELECT * FROM " + String.format(Db2Constants.KEYWORD_TABLE, tableName), null);
|
||||
@ -1007,6 +1205,13 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tableObj
|
||||
* @param requestList
|
||||
* @return
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public String transCustomFilterList(SQLObj tableObj, List<ChartFieldCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
@ -1410,7 +1615,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1419,7 +1624,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1451,7 +1656,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -4,9 +4,9 @@ import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.constants.datasource.MySQLConstants;
|
||||
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.datasource.entity.PageInfo;
|
||||
import io.dataease.provider.query.mysql.MysqlQueryProvider;
|
||||
@ -20,7 +20,7 @@ import java.util.List;
|
||||
@Service("dorisQueryProvider")
|
||||
public class DorisQueryProvider extends MysqlQueryProvider {
|
||||
|
||||
public String getSQLWithPage(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + "," + pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, true) + limit;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.provider.query.es;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -16,7 +15,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -121,12 +123,12 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -187,7 +189,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -266,37 +268,37 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -370,7 +372,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -413,12 +415,12 @@ public class EsQueryProvider extends QueryProvider {
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -455,7 +457,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -493,12 +495,12 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -573,7 +575,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -615,12 +617,12 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -716,7 +718,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -758,17 +760,124 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
if (x.getDeType() == 2 || x.getDeType() == 3) {
|
||||
originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()), "double");
|
||||
} else {
|
||||
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(EsSqlLConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(EsSqlLConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(EsSqlLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(EsSqlLConstants.KEYWORD_TABLE, table))
|
||||
@ -809,7 +918,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -847,7 +956,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -952,6 +1061,82 @@ public class EsQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(EsSqlLConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : EsSqlLConstants.DEFAULT_DATE_FORMAT, EsSqlLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_BOOL) {
|
||||
String cast = String.format(EsSqlLConstants.CAST, originName, "timestamp");
|
||||
whereName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(EsSqlLConstants.CAST, originName, "double");
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(EsSqlLConstants.CAST, originName, "bigint");
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(EsSqlLConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
return createSQLPreview("SELECT * FROM " + String.format(EsSqlLConstants.KEYWORD_TABLE, tableName), null);
|
||||
@ -994,6 +1179,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String transCustomFilterList(SQLObj tableObj, List<ChartFieldCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
@ -1328,7 +1514,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1337,7 +1523,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1369,7 +1555,7 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.provider.query.hive;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -16,7 +15,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -83,12 +85,12 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(HiveConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -148,7 +150,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -226,37 +228,37 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(HiveConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -320,7 +322,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -362,7 +364,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + " , " + pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -371,7 +373,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(HiveConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -409,7 +411,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -447,23 +449,23 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(HiveConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -530,7 +532,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -572,12 +574,12 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(HiveConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -665,7 +667,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -707,17 +709,119 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(HiveConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(HiveConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(HiveConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(HiveConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(HiveConstants.KEYWORD_TABLE, table))
|
||||
@ -754,7 +858,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -792,7 +896,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -908,6 +1012,81 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(HiveConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : HiveConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(HiveConstants.CAST, originName, HiveConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(HiveConstants.FROM_UNIXTIME, cast, HiveConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(HiveConstants.CAST, originName, HiveConstants.DEFAULT_FLOAT_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(HiveConstants.UNIX_TIMESTAMP, originName) + "*1000";
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(HiveConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
return createSQLPreview("SELECT * FROM " + String.format(HiveConstants.KEYWORD_TABLE, tableName), null);
|
||||
@ -950,6 +1129,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String transCustomFilterList(SQLObj tableObj, List<ChartFieldCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
@ -1340,7 +1520,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1349,7 +1529,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1381,7 +1561,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.provider.query.impala;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -16,7 +15,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -80,12 +82,12 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(ImpalaConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -145,7 +147,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -180,12 +182,12 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@ -233,27 +235,27 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(ImpalaConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -317,7 +319,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -358,7 +360,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(ImpalaConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -396,7 +398,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -441,7 +443,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + pageInfo.getPageSize() + " OFFSET " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -451,23 +453,23 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(ImpalaConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -534,7 +536,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -576,12 +578,12 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(ImpalaConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -669,7 +671,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -711,17 +713,119 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(ImpalaConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(ImpalaConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(ImpalaConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(ImpalaConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(ImpalaConstants.KEYWORD_TABLE, table))
|
||||
@ -758,7 +862,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -796,7 +900,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -916,6 +1020,85 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == DeTypeConstants.DE_TIME) {
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_STRING || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(ImpalaConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : ImpalaConstants.DEFAULT_DATE_FORMAT, ImpalaConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(ImpalaConstants.CAST, originName, ImpalaConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(ImpalaConstants.FROM_UNIXTIME, cast, ImpalaConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_TIME) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(ImpalaConstants.CAST, originName, ImpalaConstants.DEFAULT_FLOAT_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(ImpalaConstants.UNIX_TIMESTAMP, originName) + "*1000";
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
if (field.getDeExtractType() == DeTypeConstants.DE_INT || field.getDeExtractType() == DeTypeConstants.DE_FLOAT || field.getDeExtractType() == DeTypeConstants.DE_BOOL) {
|
||||
whereValue = String.format(ImpalaConstants.WHERE_NUMBER_VALUE_VALUE, value);
|
||||
} else {
|
||||
whereValue = String.format(ImpalaConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
return createSQLPreview("SELECT * FROM " + String.format(ImpalaConstants.KEYWORD_TABLE, tableName), null);
|
||||
@ -958,6 +1141,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String transCustomFilterList(SQLObj tableObj, List<ChartFieldCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
@ -1329,7 +1513,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1338,7 +1522,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1370,7 +1554,7 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.provider.query.mongodb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -16,7 +15,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -93,12 +95,12 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MongoConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -135,7 +137,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
st_sql.add("notUseAs", true);
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -171,12 +173,12 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@ -198,27 +200,27 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MongoConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -281,7 +283,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -328,7 +330,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + " , " + pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -337,7 +339,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MongoConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -374,7 +376,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -415,23 +417,23 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MongoConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -497,7 +499,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -544,12 +546,12 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MongoConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -636,7 +638,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -683,17 +685,132 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MongoConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yFields = new ArrayList<>();
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(yAxis)) {
|
||||
for (int i = 0; i < yAxis.size(); i++) {
|
||||
ChartViewFieldDTO y = yAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(y.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
} else {
|
||||
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(MongoConstants.ALIAS_FIX, String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i));
|
||||
// 处理纵轴字段
|
||||
yFields.add(getYFields(y, originField, fieldAlias));
|
||||
// 处理纵轴过滤
|
||||
yWheres.add(getYWheres(y, originField, fieldAlias));
|
||||
// 处理纵轴排序
|
||||
if (StringUtils.isNotEmpty(y.getSort()) && Utils.joinSort(y.getSort())) {
|
||||
yOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(y.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) {
|
||||
st_sql.add("groups", xFields);
|
||||
st_sql.add("notUseAs", true);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(yFields)) {
|
||||
st_sql.add("aggregators", yFields);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(MongoConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MongoConstants.KEYWORD_TABLE, table))
|
||||
@ -730,7 +847,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -770,7 +887,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -857,6 +974,60 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == DeTypeConstants.DE_INT) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == DeTypeConstants.DE_TIME) {
|
||||
originName = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
whereName = originName;
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = value;
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
if (field.getDeType() == DeTypeConstants.DE_STRING) {
|
||||
whereValue = String.format(MongoConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
return createSQLPreview("SELECT * FROM " + String.format(MongoConstants.KEYWORD_TABLE, tableName), null);
|
||||
@ -899,6 +1070,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String transCustomFilterList(SQLObj tableObj, List<ChartFieldCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
@ -1165,7 +1337,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1174,7 +1346,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1206,7 +1378,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.dataease.provider.query.mysql;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -18,7 +17,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -96,12 +98,12 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@ -157,7 +159,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -246,7 +248,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
@ -280,32 +282,32 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT 0," + limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + (page - 1) * pageSize + "," + realSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -368,7 +370,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -410,12 +412,115 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MysqlConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 计算字段和视图字段,规则为 函数([原始字段id]),这边把[原始字段id] 换成 表名.原始字段id
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
} else {
|
||||
originField = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(MysqlConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(MysqlConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(MysqlConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, false), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + "," + pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, false) + limit;
|
||||
@ -424,7 +529,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, boolean needOrder) {
|
||||
public String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, boolean needOrder) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -461,7 +566,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -506,18 +611,18 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -583,7 +688,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -625,12 +730,12 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -717,7 +822,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -759,7 +864,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@ -769,7 +874,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(MySQLConstants.KEYWORD_TABLE, table))
|
||||
@ -806,7 +911,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -844,7 +949,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -962,6 +1067,81 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(MySQLConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : MysqlConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(MySQLConstants.FROM_UNIXTIME, cast, MySQLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(MySQLConstants.CAST, originName, MySQLConstants.DEFAULT_FLOAT_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(MySQLConstants.UNIX_TIMESTAMP, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(MySQLConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
return createSQLPreview("SELECT * FROM " + String.format(MySQLConstants.KEYWORD_TABLE, tableName), null);
|
||||
@ -1004,6 +1184,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String transCustomFilterList(SQLObj tableObj, List<ChartFieldCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
@ -1439,7 +1620,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1448,7 +1629,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1480,7 +1661,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package io.dataease.provider.query.oracle;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.dto.datasource.OracleConfiguration;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
@ -18,7 +17,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -26,6 +28,7 @@ import io.dataease.plugins.datasource.entity.JdbcConfiguration;
|
||||
import io.dataease.plugins.datasource.entity.PageInfo;
|
||||
import io.dataease.plugins.datasource.query.QueryProvider;
|
||||
import io.dataease.plugins.datasource.query.Utils;
|
||||
import io.dataease.service.chart.ChartFilterTreeService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -59,6 +62,8 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
|
||||
@Resource
|
||||
private DatasetTableFieldMapper datasetTableFieldMapper;
|
||||
@Resource
|
||||
private ChartFilterTreeService chartFilterTreeService;
|
||||
|
||||
@Override
|
||||
public Integer transFieldType(String field) {
|
||||
@ -107,7 +112,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
|
||||
@ -122,7 +127,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -157,12 +162,12 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@ -282,12 +287,12 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
List<SQLObj> xFields = xFields(table, fields);
|
||||
|
||||
return MessageFormat.format("SELECT {0} FROM ( SELECT DE_TMP.*, rownum r FROM ( {1} ) DE_TMP WHERE rownum <= {2} ) WHERE r > {3} ",
|
||||
@ -295,25 +300,25 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
List<SQLObj> xFields = xFields("(" + sqlFix(sql) + ")", fields);
|
||||
return MessageFormat.format("SELECT {0} FROM ( SELECT DE_TMP.*, rownum r FROM ( {1} ) DE_TMP WHERE rownum <= {2} ) WHERE r > {3} ",
|
||||
sqlColumn(xFields), createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree), Integer.valueOf(page * realSize).toString(), Integer.valueOf((page - 1) * pageSize).toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
return String.format("SELECT * from %s WHERE rownum <= %s ", schema + "." + String.format(OracleConstants.KEYWORD_TABLE, table), limit.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return String.format("SELECT * from %s WHERE rownum <= %s ", "(" + sqlFix(sql) + ")", limit.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
|
||||
@ -377,7 +382,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -419,7 +424,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> orgXAxis, List<ChartFieldCustomFilterDTO> OrgFieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> orgXAxis, FilterTreeObj OrgFieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
List<ChartViewFieldDTO> xAxis = new ArrayList<>();
|
||||
orgXAxis.forEach(chartViewFieldDTO -> {
|
||||
xAxis.add(chartViewFieldDTO);
|
||||
@ -428,11 +433,10 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
chartViewFieldDTO.setOriginName("ROWNUM");
|
||||
xAxis.add(chartViewFieldDTO);
|
||||
|
||||
|
||||
List<ChartFieldCustomFilterDTO> fieldCustomFilter = new ArrayList<>();
|
||||
for (ChartFieldCustomFilterDTO chartFieldCustomFilterDTO : OrgFieldCustomFilter) {
|
||||
fieldCustomFilter.add(chartFieldCustomFilterDTO);
|
||||
}
|
||||
// for (ChartFieldCustomFilterDTO chartFieldCustomFilterDTO : OrgFieldCustomFilter) {
|
||||
// fieldCustomFilter.add(chartFieldCustomFilterDTO);
|
||||
// }
|
||||
ChartFieldCustomFilterDTO chartFieldCustomFilterDTO = new ChartFieldCustomFilterDTO();
|
||||
DatasetTableField datasetTableField = new DatasetTableField();
|
||||
datasetTableField.setOriginName("ROWNUM");
|
||||
@ -440,21 +444,32 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
chartFieldCustomFilterDTO.setField(datasetTableField);
|
||||
|
||||
List<ChartCustomFilterItemDTO> filterItemDTOS = new ArrayList<>();
|
||||
if (pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) {
|
||||
ChartCustomFilterItemDTO itemDTO = new ChartCustomFilterItemDTO();
|
||||
itemDTO.setTerm("le");
|
||||
itemDTO.setValue(String.valueOf(pageInfo.getGoPage() * pageInfo.getPageSize()));
|
||||
filterItemDTOS.add(itemDTO);
|
||||
}
|
||||
chartFieldCustomFilterDTO.setFilter(filterItemDTOS);
|
||||
fieldCustomFilter.add(chartFieldCustomFilterDTO);
|
||||
|
||||
if (isTable) {
|
||||
return "SELECT * FROM (" + sqlFix(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view)) + ") DE_RESULT_TMP " + " WHERE DE_ROWNUM > " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize();
|
||||
if (pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) {
|
||||
return "SELECT * FROM (" + sqlFix(originalTableInfo(table, xAxis, OrgFieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, fieldCustomFilter)) + ") DE_RESULT_TMP " + " WHERE DE_ROWNUM > " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize();
|
||||
} else {
|
||||
return "SELECT * FROM (" + sqlFix(originalTableInfo("(" + sqlFix(table) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view)) + ") DE_RESULT_TMP " + " WHERE DE_ROWNUM > " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize();
|
||||
return "SELECT * FROM (" + sqlFix(originalTableInfo(table, xAxis, OrgFieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, fieldCustomFilter)) + ") DE_RESULT_TMP ";
|
||||
}
|
||||
|
||||
} else {
|
||||
if (pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) {
|
||||
return "SELECT * FROM (" + sqlFix(originalTableInfo("(" + sqlFix(table) + ")", xAxis, OrgFieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, fieldCustomFilter)) + ") DE_RESULT_TMP " + " WHERE DE_ROWNUM > " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize();
|
||||
} else {
|
||||
return "SELECT * FROM (" + sqlFix(originalTableInfo("(" + sqlFix(table) + ")", xAxis, OrgFieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, fieldCustomFilter)) + ") DE_RESULT_TMP ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, List<ChartFieldCustomFilterDTO> oldWheres) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
|
||||
@ -499,11 +514,13 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 处理oracle翻页where
|
||||
String oldWhere = transCustomFilterList(tableObj, oldWheres);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
@ -511,6 +528,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
if (oldWhere != null) wheres.add(oldWhere);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
@ -537,22 +555,22 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, null), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
|
||||
@ -619,7 +637,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -661,12 +679,12 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
|
||||
@ -754,7 +772,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -796,17 +814,120 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(OracleConstants.ALIAS_FIX, String.format(TABLE_ALIAS_PREFIX, 0)))
|
||||
.build();
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(OracleConstants.ALIAS_FIX, String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i));
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(OracleConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(OracleConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(OracleConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(OracleConstants.KEYWORD_TABLE, table))
|
||||
@ -844,7 +965,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -881,7 +1002,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -1069,6 +1190,86 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(OracleConstants.TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_INT_FORMAT) + "/1000";
|
||||
whereName = String.format(OracleConstants.FROM_UNIXTIME, cast, OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(OracleConstants.CAST, originName, OracleConstants.DEFAULT_FLOAT_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(OracleConstants.UNIX_TIMESTAMP, originName) + "*1000";
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
if (field.getDeType() == 1) {
|
||||
whereValue = String.format(OracleConstants.TO_DATE, "'" + value + "'", StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : OracleConstants.DEFAULT_DATE_FORMAT);
|
||||
} else {
|
||||
whereValue = String.format(OracleConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
@ -1522,7 +1723,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1531,7 +1732,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1563,7 +1764,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package io.dataease.provider.query.pg;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -18,7 +17,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -109,12 +111,12 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -176,7 +178,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -255,37 +257,37 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + limit + " offset 0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + limit + " offset 0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -349,7 +351,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -391,7 +393,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + pageInfo.getPageSize() + " offset " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -400,7 +402,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -438,7 +440,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -476,23 +478,23 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -559,7 +561,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -601,12 +603,12 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -694,7 +696,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -736,17 +738,120 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(PgConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(PgConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(PgConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
@ -784,7 +889,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -822,7 +927,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -942,6 +1047,81 @@ public class PgQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : PgConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(PgConstants.CAST, originName, "bigint");
|
||||
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.CAST, originName, PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(PgConstants.UNIX_TIMESTAMP, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(PgConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
@ -986,6 +1166,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String transCustomFilterList(SQLObj tableObj, List<ChartFieldCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
@ -1338,7 +1519,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1347,7 +1528,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1379,7 +1560,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package io.dataease.provider.query.redshift;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -16,7 +15,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -115,12 +117,12 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -182,7 +184,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -261,37 +263,37 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + realSize + " offset " + (page - 1) * pageSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, null, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + limit + " offset 0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree) + " LIMIT " + limit + " offset 0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -355,7 +357,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -398,12 +400,12 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " LIMIT " + pageInfo.getPageSize() + " offset " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() : "");
|
||||
if (isTable) {
|
||||
return originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -414,11 +416,11 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return sqlLimit(originalTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view), view);
|
||||
}
|
||||
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
private String originalTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(RedshiftConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -455,7 +457,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -493,12 +495,12 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -565,7 +567,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -607,12 +609,12 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -700,7 +702,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -742,17 +744,120 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(PgConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(PgConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(PgConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
return sqlLimit(st.render(), view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(PgConstants.KEYWORD_TABLE, table))
|
||||
@ -790,7 +895,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -828,7 +933,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -944,6 +1049,77 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.STR_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : PgConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(PgConstants.CAST, originName, "bigint");
|
||||
whereName = String.format(PgConstants.FROM_UNIXTIME, cast);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(PgConstants.CAST, originName, PgConstants.DEFAULT_FLOAT_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(PgConstants.UNIX_TIMESTAMP, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = PgConstants.WHERE_VALUE_NULL;
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereTerm = String.format(whereTerm, originName);
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
whereValue = String.format(PgConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
@ -984,6 +1160,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String transCustomFilterList(SQLObj tableObj, List<ChartFieldCustomFilterDTO> requestList) {
|
||||
if (CollectionUtils.isEmpty(requestList)) {
|
||||
return null;
|
||||
@ -1319,7 +1496,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1328,7 +1505,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1360,7 +1537,7 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package io.dataease.provider.query.sqlserver;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
@ -17,7 +16,10 @@ import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
@ -99,17 +101,17 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree);
|
||||
}
|
||||
|
||||
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||
}
|
||||
|
||||
@ -124,7 +126,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -221,7 +223,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
st_sql.add("isGroup", isGroup);
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
@ -299,31 +301,31 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
Integer size = (page - 1) * pageSize + realSize;
|
||||
return String.format("SELECT top %s * from ( %s ) AS DE_SQLSERVER_TMP ", size.toString(), createQuerySQL(table, fields, isGroup, ds, fieldCustomFilter, rowPermissionsTree));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
return String.format("SELECT top %s * from %s ", limit.toString(), schema + "." + String.format(SqlServerSQLConstants.KEYWORD_TABLE, table));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
Integer size = (page - 1) * pageSize + realSize;
|
||||
return String.format("SELECT top %s * from ( %s ) AS DE_SQLSERVER_TMP ", size.toString(), createQuerySQLAsTmp(sql, fields, isGroup, fieldCustomFilter, rowPermissionsTree));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
public String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
|
||||
return String.format("SELECT top %s * from ( %s ) as DE_SQLSERVER_TMP ", limit.toString(), sqlFix(sql));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -387,7 +389,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -433,11 +435,11 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return originTableInfo(table, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, true);
|
||||
}
|
||||
|
||||
public String originTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, boolean needOrder) {
|
||||
public String originTableInfo(String table, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, boolean needOrder) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -475,7 +477,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -523,12 +525,12 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
return st.render();
|
||||
}
|
||||
|
||||
public String originSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, boolean needOrder) {
|
||||
public String originSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, boolean needOrder) {
|
||||
return originTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view, needOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLWithPage(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
public String getSQLWithPage(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view, PageInfo pageInfo) {
|
||||
String limit = ((pageInfo.getGoPage() != null && pageInfo.getPageSize() != null) ? " OFFSET " + (pageInfo.getGoPage() - 1) * pageInfo.getPageSize() + " ROW FETCH NEXT " + pageInfo.getPageSize() + " ROW ONLY " : "");
|
||||
if (isTable) {
|
||||
return getSQLTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view) + limit;
|
||||
@ -538,18 +540,18 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
return getSQLTableInfo("(" + sqlFix(sql) + ")", xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmp(String sql, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQL("(" + sqlFix(sql) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -635,7 +637,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -681,12 +683,12 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLStack("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
@ -774,7 +776,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -820,17 +822,124 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
public String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, List<ChartViewFieldDTO> extGroup, ChartViewWithBLOBs view) {
|
||||
return getSQLScatter("(" + sqlFix(table) + ")", xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extBubble, extGroup, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds, ChartViewWithBLOBs view) {
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||
.build();
|
||||
setSchema(tableObj, ds);
|
||||
List<SQLObj> xFields = new ArrayList<>();
|
||||
List<SQLObj> xOrders = new ArrayList<>();
|
||||
|
||||
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
|
||||
List<String> yWheres = new ArrayList<>();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(xAxis)) {
|
||||
for (int i = 0; i < xAxis.size(); i++) {
|
||||
ChartViewFieldDTO x = xAxis.get(i);
|
||||
String originField;
|
||||
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originField = calcFieldRegex(x.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
|
||||
originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
} else {
|
||||
originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
|
||||
}
|
||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
||||
|
||||
if (i == baseXAxis.size()) {// 起止时间
|
||||
String fieldName = String.format(SqlServerSQLConstants.AGG_FIELD, "min", originField);
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
|
||||
} else if (i == baseXAxis.size() + 1) {
|
||||
String fieldName = String.format(SqlServerSQLConstants.AGG_FIELD, "max", originField);
|
||||
|
||||
yFields.add(getXFields(x, fieldName, fieldAlias));
|
||||
|
||||
yWheres.add(getYWheres(x, originField, fieldAlias));
|
||||
} else {
|
||||
// 处理横轴字段
|
||||
xFields.add(getXFields(x, originField, fieldAlias));
|
||||
}
|
||||
|
||||
// 处理横轴排序
|
||||
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
|
||||
xOrders.add(SQLObj.builder()
|
||||
.orderField(originField)
|
||||
.orderAlias(fieldAlias)
|
||||
.orderDirection(x.getSort())
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
List<SQLObj> yOrders = new ArrayList<>();
|
||||
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
||||
// 构建sql所有参数
|
||||
List<SQLObj> fields = new ArrayList<>();
|
||||
fields.addAll(xFields);
|
||||
fields.addAll(yFields);
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (extWheres != null) wheres.add(extWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
List<SQLObj> groups = new ArrayList<>();
|
||||
groups.addAll(xFields);
|
||||
// 外层再次套sql
|
||||
List<SQLObj> orders = new ArrayList<>();
|
||||
orders.addAll(xOrders);
|
||||
orders.addAll(yOrders);
|
||||
List<String> aggWheres = new ArrayList<>();
|
||||
aggWheres.addAll(yWheres.stream().filter(ObjectUtils::isNotEmpty).collect(Collectors.toList()));
|
||||
|
||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||
ST st_sql = stg.getInstanceOf("querySql");
|
||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
||||
if (CollectionUtils.isNotEmpty(yFields)) st_sql.add("aggregators", yFields);
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
||||
String sql = st_sql.render();
|
||||
|
||||
ST st = stg.getInstanceOf("querySql");
|
||||
SQLObj tableSQL = SQLObj.builder()
|
||||
.tableName(String.format(SqlServerSQLConstants.BRACKETS, sql))
|
||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 1))
|
||||
.build();
|
||||
if (CollectionUtils.isNotEmpty(aggWheres)) st.add("filters", aggWheres);
|
||||
if (CollectionUtils.isNotEmpty(orders)) st.add("orders", orders);
|
||||
if (ObjectUtils.isNotEmpty(tableSQL)) st.add("table", tableSQL);
|
||||
if (StringUtils.equalsIgnoreCase(view.getResultMode(), "custom")) {
|
||||
SQLObj limitFiled = SQLObj.builder().limitFiled("top " + view.getResultCount() + " ").build();
|
||||
st.add("limitFiled", limitFiled);
|
||||
}
|
||||
return st.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLAsTmpRangeBar(String table, List<ChartViewFieldDTO> baseXAxis, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, ChartViewWithBLOBs view) {
|
||||
return getSQLRangeBar("(" + table + ")", baseXAxis, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, extStack, null, view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String searchTable(String table) {
|
||||
return "SELECT table_name FROM information_schema.TABLES WHERE table_name ='" + table + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
public String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view, Datasource ds) {
|
||||
// 字段汇总 排序等
|
||||
SQLObj tableObj = SQLObj.builder()
|
||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
||||
@ -868,7 +977,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
}
|
||||
// 处理视图中字段过滤
|
||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
||||
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
|
||||
// 处理仪表板字段过滤
|
||||
String extWheres = transExtFilterList(tableObj, extFilterRequestList);
|
||||
// row permissions tree
|
||||
@ -910,7 +1019,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
public String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, ChartViewWithBLOBs view) {
|
||||
return getSQLSummary("(" + sqlFix(sql) + ")", yAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, view, null);
|
||||
}
|
||||
|
||||
@ -1030,6 +1139,91 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String transTreeItem(SQLObj tableObj, FilterTreeItem item) {
|
||||
String res = null;
|
||||
DatasetTableField field = item.getField();
|
||||
if (ObjectUtils.isEmpty(field)) {
|
||||
return null;
|
||||
}
|
||||
String whereName = "";
|
||||
String originName;
|
||||
if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 2) {
|
||||
// 解析origin name中有关联的字段生成sql表达式
|
||||
originName = calcFieldRegex(field.getOriginName(), tableObj);
|
||||
} else if (ObjectUtils.isNotEmpty(field.getExtField()) && field.getExtField() == 1) {
|
||||
originName = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
} else {
|
||||
originName = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), field.getOriginName());
|
||||
}
|
||||
if (field.getDeType() == 1) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(SqlServerSQLConstants.STRING_TO_DATE, originName, StringUtils.isNotEmpty(field.getDateFormat()) ? field.getDateFormat() : SqlServerSQLConstants.DEFAULT_DATE_FORMAT);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originName + "/1000");
|
||||
whereName = String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else if (field.getDeType() == 2 || field.getDeType() == 3) {
|
||||
if (field.getDeExtractType() == 0 || field.getDeExtractType() == 5) {
|
||||
whereName = String.format(SqlServerSQLConstants.CONVERT, SqlServerSQLConstants.DEFAULT_FLOAT_FORMAT, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == 1) {
|
||||
whereName = String.format(SqlServerSQLConstants.UNIX_TIMESTAMP, originName);
|
||||
}
|
||||
if (field.getDeExtractType() == 2 || field.getDeExtractType() == 3 || field.getDeExtractType() == 4) {
|
||||
whereName = originName;
|
||||
}
|
||||
} else {
|
||||
whereName = originName;
|
||||
}
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getFilterType(), "enum")) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
res = "(" + whereName + " IN ('" + String.join("','", item.getEnumValue()) + "'))";
|
||||
}
|
||||
} else {
|
||||
String value = item.getValue();
|
||||
String whereTerm = transMysqlFilterTerm(item.getTerm());
|
||||
String whereValue = "";
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(item.getTerm(), "null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_null")) {
|
||||
whereValue = "";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getTerm(), "not_empty")) {
|
||||
whereValue = "''";
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "in") || StringUtils.containsIgnoreCase(item.getTerm(), "not in")) {
|
||||
if (field.getType().equalsIgnoreCase("NVARCHAR")) {
|
||||
whereValue = "(" + Arrays.asList(value.split(",")).stream().map(str -> {
|
||||
return "N" + "'" + str + "'";
|
||||
}).collect(Collectors.joining(",")) + ")";
|
||||
} else {
|
||||
whereValue = "('" + String.join("','", value.split(",")) + "')";
|
||||
}
|
||||
} else if (StringUtils.containsIgnoreCase(item.getTerm(), "like")) {
|
||||
whereValue = "'%" + value + "%'";
|
||||
} else {
|
||||
if (field.getType().equalsIgnoreCase("NVARCHAR")) {
|
||||
whereValue = String.format(SqlServerSQLConstants.WHERE_VALUE_VALUE_CH, value);
|
||||
} else {
|
||||
whereValue = String.format(SqlServerSQLConstants.WHERE_VALUE_VALUE, value);
|
||||
}
|
||||
}
|
||||
SQLObj build = SQLObj.builder()
|
||||
.whereField(whereName)
|
||||
.whereTermAndValue(whereTerm + whereValue)
|
||||
.build();
|
||||
res = build.getWhereField() + " " + build.getWhereTermAndValue();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convertTableToSql(String tableName, Datasource ds) {
|
||||
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcConfiguration.class).getSchema();
|
||||
@ -1479,7 +1673,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1488,7 +1682,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
@ -1520,7 +1714,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1542,7 +1736,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResultCount(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
public String getResultCount(boolean isTable, String sql, List<ChartViewFieldDTO> xAxis, FilterTreeObj fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds, ChartViewWithBLOBs view) {
|
||||
if (isTable) {
|
||||
return "SELECT COUNT(*) AS count from (" + originTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterRequestList, ds, view, false) + ") COUNT_TEMP";
|
||||
} else {
|
||||
|
@ -2,13 +2,13 @@ package io.dataease.service;
|
||||
|
||||
|
||||
import io.dataease.commons.constants.FileType;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.plugins.common.base.domain.FileContent;
|
||||
import io.dataease.plugins.common.base.domain.FileContentExample;
|
||||
import io.dataease.plugins.common.base.domain.FileMetadata;
|
||||
import io.dataease.plugins.common.base.domain.FileMetadataExample;
|
||||
import io.dataease.plugins.common.base.mapper.FileContentMapper;
|
||||
import io.dataease.plugins.common.base.mapper.FileMetadataMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -60,7 +60,7 @@ public class FileService {
|
||||
try {
|
||||
fileContent.setFile(file.getBytes());
|
||||
} catch (IOException e) {
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
fileContentMapper.insert(fileContent);
|
||||
|
||||
|
@ -0,0 +1,60 @@
|
||||
package io.dataease.service.chart;
|
||||
|
||||
import io.dataease.plugins.common.base.mapper.DatasetTableFieldMapper;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.provider.query.SQLUtils;
|
||||
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.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author Junjun
|
||||
*/
|
||||
@Service
|
||||
public class ChartFilterTreeService {
|
||||
@Resource
|
||||
private DatasetTableFieldMapper datasetTableFieldMapper;
|
||||
|
||||
public void searchFieldAndSet(FilterTreeObj tree) {
|
||||
if (ObjectUtils.isNotEmpty(tree)) {
|
||||
if (ObjectUtils.isNotEmpty(tree.getItems())) {
|
||||
for (FilterTreeItem item : tree.getItems()) {
|
||||
if (ObjectUtils.isNotEmpty(item)) {
|
||||
if (StringUtils.equalsIgnoreCase(item.getType(), "item") || ObjectUtils.isEmpty(item.getSubTree())) {
|
||||
item.setField(datasetTableFieldMapper.selectByPrimaryKey(item.getFieldId()));
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getType(), "tree") || (ObjectUtils.isNotEmpty(item.getSubTree()) && StringUtils.isNotEmpty(item.getSubTree().getLogic()))) {
|
||||
searchFieldAndSet(item.getSubTree());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FilterTreeObj charReplace(FilterTreeObj tree) {
|
||||
if (ObjectUtils.isNotEmpty(tree)) {
|
||||
if (ObjectUtils.isNotEmpty(tree.getItems())) {
|
||||
for (FilterTreeItem item : tree.getItems()) {
|
||||
if (ObjectUtils.isNotEmpty(item)) {
|
||||
if (StringUtils.equalsIgnoreCase(item.getType(), "item") || ObjectUtils.isEmpty(item.getSubTree())) {
|
||||
if (CollectionUtils.isNotEmpty(item.getEnumValue())) {
|
||||
List<String> collect = item.getEnumValue().stream().map(SQLUtils::transKeyword).collect(Collectors.toList());
|
||||
item.setEnumValue(collect);
|
||||
}
|
||||
item.setValue(SQLUtils.transKeyword(item.getValue()));
|
||||
} else if (StringUtils.equalsIgnoreCase(item.getType(), "tree") || (ObjectUtils.isNotEmpty(item.getSubTree()) && StringUtils.isNotEmpty(item.getSubTree().getLogic()))) {
|
||||
charReplace(item.getSubTree());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package io.dataease.service.chart;
|
||||
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.TableUtils;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewField;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewFieldExample;
|
||||
import io.dataease.plugins.common.base.mapper.ChartViewFieldMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -79,7 +79,7 @@ public class ChartViewFieldService {
|
||||
}
|
||||
List<ChartViewField> datasetTableFields = chartViewFieldMapper.selectByExample(chartViewFieldExample);
|
||||
if (CollectionUtils.isNotEmpty(datasetTableFields)) {
|
||||
DEException.throwException(Translator.get("i18n_field_name_repeat"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_name_repeat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,255 @@
|
||||
package io.dataease.service.chart;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewCacheExample;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewCacheWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewExample;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.mapper.ChartViewCacheMapper;
|
||||
import io.dataease.plugins.common.base.mapper.ChartViewMapper;
|
||||
import io.dataease.plugins.common.dto.chart.ChartCustomFilterItemDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeItem;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author Junjun
|
||||
*/
|
||||
@Service
|
||||
public class ChartViewOldDataMergeService {
|
||||
|
||||
private final static Gson gson = new Gson();
|
||||
|
||||
@Resource
|
||||
private ChartViewMapper chartViewMapper;
|
||||
@Resource
|
||||
private ChartViewCacheMapper chartViewCacheMapper;
|
||||
|
||||
/**
|
||||
* 视图过滤器重构,合并老数据,将list变成tree
|
||||
*/
|
||||
public void mergeOldData() {
|
||||
// 获取所有视图数据
|
||||
// 把一个视图中的过滤器,即customFilter字段进行重构
|
||||
// 之前是以list形式储存,一个字段是一个item
|
||||
// 现在把一个字段当做tree中的一个节点
|
||||
// 节点中如果是logic且length>1,保留and或or,每一条都变成一个子节点;如果是枚举或只有1条,则当做and处理并保留值
|
||||
// 最后把字段之间通过and的逻辑合并
|
||||
List<ChartViewWithBLOBs> chartViewWithBLOBs = chartViewMapper.selectByExampleWithBLOBs(new ChartViewExample());
|
||||
if (CollectionUtils.isEmpty(chartViewWithBLOBs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ChartViewWithBLOBs view : chartViewWithBLOBs) {
|
||||
Type filterTokenType = new TypeToken<List<ChartFieldCustomFilterDTO>>() {
|
||||
}.getType();
|
||||
List<ChartFieldCustomFilterDTO> fieldCustomFilter = gson.fromJson(view.getCustomFilter(), filterTokenType);
|
||||
if (CollectionUtils.isEmpty(fieldCustomFilter)) {
|
||||
// 将 '[]' 转换成 '{}'
|
||||
view.setCustomFilter("{}");
|
||||
} else {
|
||||
FilterTreeObj tree = new FilterTreeObj();
|
||||
tree.setItems(new ArrayList<>());
|
||||
if (fieldCustomFilter.size() == 1) {
|
||||
ChartFieldCustomFilterDTO filterDTO = fieldCustomFilter.get(0);
|
||||
tree.setLogic(filterDTO.getLogic());
|
||||
if (StringUtils.equalsIgnoreCase(filterDTO.getFilterType(), "enum")) {
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("item");
|
||||
item.setFieldId(filterDTO.getId());
|
||||
item.setFilterType(filterDTO.getFilterType());
|
||||
item.setEnumValue(filterDTO.getEnumCheckField());
|
||||
tree.getItems().add(item);
|
||||
} else {
|
||||
List<ChartCustomFilterItemDTO> filter = filterDTO.getFilter();
|
||||
if (CollectionUtils.isEmpty(filter)) {
|
||||
continue;
|
||||
}
|
||||
for (ChartCustomFilterItemDTO f : filter) {
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("item");
|
||||
item.setFieldId(filterDTO.getId());
|
||||
item.setFilterType(filterDTO.getFilterType());
|
||||
item.setTerm(f.getTerm());
|
||||
item.setValue(f.getValue());
|
||||
item.setEnumValue(new ArrayList<>());
|
||||
tree.getItems().add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tree.setLogic("and");
|
||||
for (ChartFieldCustomFilterDTO dto : fieldCustomFilter) {
|
||||
if (StringUtils.equalsIgnoreCase(dto.getFilterType(), "enum")) {
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("item");
|
||||
item.setFieldId(dto.getId());
|
||||
item.setFilterType(dto.getFilterType());
|
||||
item.setEnumValue(dto.getEnumCheckField());
|
||||
tree.getItems().add(item);
|
||||
} else {
|
||||
List<ChartCustomFilterItemDTO> filter = dto.getFilter();
|
||||
if (CollectionUtils.isEmpty(filter)) {
|
||||
continue;
|
||||
}
|
||||
if (filter.size() == 1) {
|
||||
ChartCustomFilterItemDTO f = filter.get(0);
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("item");
|
||||
item.setFieldId(dto.getId());
|
||||
item.setFilterType(dto.getFilterType());
|
||||
item.setTerm(f.getTerm());
|
||||
item.setValue(f.getValue());
|
||||
item.setEnumValue(new ArrayList<>());
|
||||
tree.getItems().add(item);
|
||||
} else {
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("tree");
|
||||
item.setEnumValue(new ArrayList<>());
|
||||
FilterTreeObj subTree = new FilterTreeObj();
|
||||
subTree.setLogic(dto.getLogic());
|
||||
subTree.setItems(new ArrayList<>());
|
||||
for (ChartCustomFilterItemDTO f : filter) {
|
||||
FilterTreeItem itemTree = new FilterTreeItem();
|
||||
itemTree.setType("item");
|
||||
itemTree.setFieldId(dto.getId());
|
||||
itemTree.setFilterType(dto.getFilterType());
|
||||
itemTree.setTerm(f.getTerm());
|
||||
itemTree.setValue(f.getValue());
|
||||
itemTree.setEnumValue(new ArrayList<>());
|
||||
subTree.getItems().add(itemTree);
|
||||
}
|
||||
item.setSubTree(subTree);
|
||||
tree.getItems().add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
view.setCustomFilter(gson.toJson(tree));
|
||||
}
|
||||
|
||||
try {
|
||||
chartViewMapper.updateByPrimaryKeyWithBLOBs(view);
|
||||
} catch (Exception e) {
|
||||
// do nothing,to continue
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mergeCacheOldData() {
|
||||
// 获取所有视图数据
|
||||
// 把一个视图中的过滤器,即customFilter字段进行重构
|
||||
// 之前是以list形式储存,一个字段是一个item
|
||||
// 现在把一个字段当做tree中的一个节点
|
||||
// 节点中如果是logic且length>1,保留and或or,每一条都变成一个子节点;如果是枚举或只有1条,则当做and处理并保留值
|
||||
// 最后把字段之间通过and的逻辑合并
|
||||
List<ChartViewCacheWithBLOBs> chartViewWithBLOBs = chartViewCacheMapper.selectByExampleWithBLOBs(new ChartViewCacheExample());
|
||||
if (CollectionUtils.isEmpty(chartViewWithBLOBs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ChartViewCacheWithBLOBs view : chartViewWithBLOBs) {
|
||||
Type filterTokenType = new TypeToken<List<ChartFieldCustomFilterDTO>>() {
|
||||
}.getType();
|
||||
List<ChartFieldCustomFilterDTO> fieldCustomFilter = gson.fromJson(view.getCustomFilter(), filterTokenType);
|
||||
if (CollectionUtils.isEmpty(fieldCustomFilter)) {
|
||||
// 将 '[]' 转换成 '{}'
|
||||
view.setCustomFilter("{}");
|
||||
} else {
|
||||
FilterTreeObj tree = new FilterTreeObj();
|
||||
tree.setItems(new ArrayList<>());
|
||||
if (fieldCustomFilter.size() == 1) {
|
||||
ChartFieldCustomFilterDTO filterDTO = fieldCustomFilter.get(0);
|
||||
tree.setLogic(filterDTO.getLogic());
|
||||
if (StringUtils.equalsIgnoreCase(filterDTO.getFilterType(), "enum")) {
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("item");
|
||||
item.setFieldId(filterDTO.getId());
|
||||
item.setFilterType(filterDTO.getFilterType());
|
||||
item.setEnumValue(filterDTO.getEnumCheckField());
|
||||
tree.getItems().add(item);
|
||||
} else {
|
||||
List<ChartCustomFilterItemDTO> filter = filterDTO.getFilter();
|
||||
if (CollectionUtils.isEmpty(filter)) {
|
||||
continue;
|
||||
}
|
||||
for (ChartCustomFilterItemDTO f : filter) {
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("item");
|
||||
item.setFieldId(filterDTO.getId());
|
||||
item.setFilterType(filterDTO.getFilterType());
|
||||
item.setTerm(f.getTerm());
|
||||
item.setValue(f.getValue());
|
||||
item.setEnumValue(new ArrayList<>());
|
||||
tree.getItems().add(item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tree.setLogic("and");
|
||||
for (ChartFieldCustomFilterDTO dto : fieldCustomFilter) {
|
||||
if (StringUtils.equalsIgnoreCase(dto.getFilterType(), "enum")) {
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("item");
|
||||
item.setFieldId(dto.getId());
|
||||
item.setFilterType(dto.getFilterType());
|
||||
item.setEnumValue(dto.getEnumCheckField());
|
||||
tree.getItems().add(item);
|
||||
} else {
|
||||
List<ChartCustomFilterItemDTO> filter = dto.getFilter();
|
||||
if (CollectionUtils.isEmpty(filter)) {
|
||||
continue;
|
||||
}
|
||||
if (filter.size() == 1) {
|
||||
ChartCustomFilterItemDTO f = filter.get(0);
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("item");
|
||||
item.setFieldId(dto.getId());
|
||||
item.setFilterType(dto.getFilterType());
|
||||
item.setTerm(f.getTerm());
|
||||
item.setValue(f.getValue());
|
||||
item.setEnumValue(new ArrayList<>());
|
||||
tree.getItems().add(item);
|
||||
} else {
|
||||
FilterTreeItem item = new FilterTreeItem();
|
||||
item.setType("tree");
|
||||
item.setEnumValue(new ArrayList<>());
|
||||
FilterTreeObj subTree = new FilterTreeObj();
|
||||
subTree.setLogic(dto.getLogic());
|
||||
subTree.setItems(new ArrayList<>());
|
||||
for (ChartCustomFilterItemDTO f : filter) {
|
||||
FilterTreeItem itemTree = new FilterTreeItem();
|
||||
itemTree.setType("item");
|
||||
itemTree.setFieldId(dto.getId());
|
||||
itemTree.setFilterType(dto.getFilterType());
|
||||
itemTree.setTerm(f.getTerm());
|
||||
itemTree.setValue(f.getValue());
|
||||
itemTree.setEnumValue(new ArrayList<>());
|
||||
subTree.getItems().add(itemTree);
|
||||
}
|
||||
item.setSubTree(subTree);
|
||||
tree.getItems().add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
view.setCustomFilter(gson.toJson(tree));
|
||||
}
|
||||
|
||||
try {
|
||||
chartViewCacheMapper.updateByPrimaryKeyWithBLOBs(view);
|
||||
} catch (Exception e) {
|
||||
// do nothing,to continue
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.commons.constants.CommonConstants;
|
||||
import io.dataease.commons.constants.JdbcConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.model.PluginViewSetImpl;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
@ -21,7 +20,6 @@ import io.dataease.dto.chart.*;
|
||||
import io.dataease.dto.dataset.DataSetTableDTO;
|
||||
import io.dataease.dto.dataset.DataSetTableUnionDTO;
|
||||
import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.ext.ExtChartGroupMapper;
|
||||
import io.dataease.ext.ExtChartViewMapper;
|
||||
import io.dataease.ext.ExtPanelGroupExtendDataMapper;
|
||||
@ -35,12 +33,12 @@ import io.dataease.plugins.common.base.mapper.PanelViewMapper;
|
||||
import io.dataease.plugins.common.constants.DatasetType;
|
||||
import io.dataease.plugins.common.constants.DatasourceTypes;
|
||||
import io.dataease.plugins.common.constants.datasource.SQLConstants;
|
||||
import io.dataease.plugins.common.dto.chart.ChartCustomFilterItemDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartFieldCompareDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.dataset.SqlVariableDetails;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
@ -48,6 +46,7 @@ import io.dataease.plugins.datasource.entity.PageInfo;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
import io.dataease.plugins.datasource.query.QueryProvider;
|
||||
import io.dataease.plugins.view.entity.*;
|
||||
import io.dataease.plugins.view.entity.filter.PluginFilterTreeObj;
|
||||
import io.dataease.plugins.view.service.ViewPluginService;
|
||||
import io.dataease.plugins.xpack.auth.dto.request.ColumnPermissionItem;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
@ -123,6 +122,8 @@ public class ChartViewService {
|
||||
private PermissionsTreeService permissionsTreeService;
|
||||
@Resource
|
||||
private DatasetTableFieldMapper datasetTableFieldMapper;
|
||||
@Resource
|
||||
private ChartFilterTreeService chartFilterTreeService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ChartViewService.class);
|
||||
|
||||
@ -344,7 +345,7 @@ public class ChartViewService {
|
||||
}
|
||||
List<ChartViewFieldDTO> xAxis = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
if (StringUtils.equalsIgnoreCase(view.getType(), "table-pivot")
|
||||
if (StringUtils.equalsAnyIgnoreCase(view.getType(), "table-pivot", "bar-time-range")
|
||||
|| StringUtils.containsIgnoreCase(view.getType(), "group")
|
||||
|| ("antv".equalsIgnoreCase(view.getRender()) && "line".equalsIgnoreCase(view.getType()))) {
|
||||
List<ChartViewFieldDTO> xAxisExt = gson.fromJson(view.getXAxisExt(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
@ -371,7 +372,7 @@ public class ChartViewService {
|
||||
}
|
||||
List<ChartViewFieldDTO> extBubble = gson.fromJson(view.getExtBubble(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
List<ChartFieldCustomFilterDTO> fieldCustomFilter = new ArrayList<ChartFieldCustomFilterDTO>();
|
||||
FilterTreeObj fieldCustomFilter = new FilterTreeObj();// todo 等前端过滤组件传递过滤配置
|
||||
List<ChartViewFieldDTO> drill = new ArrayList<ChartViewFieldDTO>();
|
||||
|
||||
|
||||
@ -387,18 +388,16 @@ public class ChartViewService {
|
||||
//将没有权限的列删掉
|
||||
List<String> dataeaseNames = columnPermissionFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.toList());
|
||||
dataeaseNames.add("*");
|
||||
fieldCustomFilter = fieldCustomFilter.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
|
||||
extStack = extStack.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
|
||||
extBubble = extBubble.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
|
||||
drill = drill.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
|
||||
// fieldCustomFilter = fieldCustomFilter.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
|
||||
extStack = extStack.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
|
||||
extBubble = extBubble.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
|
||||
drill = drill.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
|
||||
|
||||
|
||||
//行权限
|
||||
List<DataSetRowPermissionsTreeDTO> rowPermissionsTree = permissionsTreeService.getRowPermissionsTree(fields, table, requestList.getUser());
|
||||
|
||||
for (ChartFieldCustomFilterDTO ele : fieldCustomFilter) {
|
||||
ele.setField(dataSetTableFieldsService.get(ele.getId()));
|
||||
}
|
||||
chartFilterTreeService.searchFieldAndSet(fieldCustomFilter);
|
||||
|
||||
if (CollectionUtils.isEmpty(xAxis) && CollectionUtils.isEmpty(yAxis)) {
|
||||
return new ArrayList<String[]>();
|
||||
@ -502,6 +501,11 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLScatter(dataTableInfoDTO.getTable(), xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extBubble, extStack, ds, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLTableInfo(dataTableInfoDTO.getTable(), xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
List<ChartViewFieldDTO> xAxisBase = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
datasourceRequest.setQuery(qp.getSQLRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, ds, view));
|
||||
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQL(dataTableInfoDTO.getTable(), xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
}
|
||||
@ -516,6 +520,11 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpScatter(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extBubble, extStack, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
List<ChartViewFieldDTO> xAxisBase = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view));
|
||||
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmp(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view));
|
||||
}
|
||||
@ -531,6 +540,11 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpScatter(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extBubble, extStack, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
}else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
List<ChartViewFieldDTO> xAxisBase = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view));
|
||||
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmp(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view));
|
||||
}
|
||||
@ -547,6 +561,11 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpScatter(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extBubble, extStack, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
List<ChartViewFieldDTO> xAxisBase = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmpRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view));
|
||||
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQLAsTmp(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view));
|
||||
}
|
||||
@ -572,6 +591,11 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLScatter(tableName, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extBubble, extStack, ds, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLTableInfo(tableName, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
List<ChartViewFieldDTO> xAxisBase = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType());
|
||||
datasourceRequest.setQuery(qp.getSQLRangeBar(tableName, xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, ds, view));
|
||||
|
||||
} else {
|
||||
datasourceRequest.setQuery(qp.getSQL(tableName, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
}
|
||||
@ -610,8 +634,8 @@ public class ChartViewService {
|
||||
}
|
||||
Type tokenType = new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType();
|
||||
Type filterTokenType = new TypeToken<List<ChartFieldCustomFilterDTO>>() {
|
||||
}.getType();
|
||||
// Type filterTokenType = new TypeToken<List<ChartFieldCustomFilterDTO>>() {
|
||||
// }.getType();
|
||||
|
||||
List<ChartViewFieldDTO> viewFields = gson.fromJson(view.getViewFields(), tokenType);
|
||||
final Map<String, List<ChartViewFieldDTO>> extFieldsMap = new LinkedHashMap<>();
|
||||
@ -658,7 +682,7 @@ public class ChartViewService {
|
||||
extStack.addAll(xAxisExt);
|
||||
}
|
||||
List<ChartViewFieldDTO> extBubble = gson.fromJson(view.getExtBubble(), tokenType);
|
||||
List<ChartFieldCustomFilterDTO> fieldCustomFilter = gson.fromJson(view.getCustomFilter(), filterTokenType);
|
||||
FilterTreeObj fieldCustomFilter = gson.fromJson(view.getCustomFilter(), FilterTreeObj.class);
|
||||
List<ChartViewFieldDTO> drill = gson.fromJson(view.getDrillFields(), tokenType);
|
||||
|
||||
// 视图计算字段,用dataeaseName作为唯一标识
|
||||
@ -680,7 +704,7 @@ public class ChartViewService {
|
||||
//将没有权限的列删掉
|
||||
List<String> dataeaseNames = columnPermissionFields.stream().map(DatasetTableField::getDataeaseName).collect(Collectors.toList());
|
||||
dataeaseNames.add("*");
|
||||
fieldCustomFilter = fieldCustomFilter.stream().filter(item -> chartViewFieldNameList.contains(item.getDataeaseName()) || (!desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName()))).collect(Collectors.toList());
|
||||
// fieldCustomFilter = fieldCustomFilter.stream().filter(item -> chartViewFieldNameList.contains(item.getDataeaseName()) || (!desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName()))).collect(Collectors.toList());
|
||||
extStack = extStack.stream().filter(item -> chartViewFieldNameList.contains(item.getDataeaseName()) || (!desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName()))).collect(Collectors.toList());
|
||||
extBubble = extBubble.stream().filter(item -> chartViewFieldNameList.contains(item.getDataeaseName()) || (!desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName()))).collect(Collectors.toList());
|
||||
drill = drill.stream().filter(item -> chartViewFieldNameList.contains(item.getDataeaseName()) || (!desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName()))).collect(Collectors.toList());
|
||||
@ -688,9 +712,10 @@ public class ChartViewService {
|
||||
//行权限
|
||||
List<DataSetRowPermissionsTreeDTO> rowPermissionsTree = permissionsTreeService.getRowPermissionsTree(fields, table, chartExtRequest.getUser());
|
||||
|
||||
for (ChartFieldCustomFilterDTO ele : fieldCustomFilter) {
|
||||
/*for (ChartFieldCustomFilterDTO ele : fieldCustomFilter) {
|
||||
ele.setField(dataSetTableFieldsService.get(ele.getId()));
|
||||
}
|
||||
}*/
|
||||
chartFilterTreeService.searchFieldAndSet(fieldCustomFilter);
|
||||
|
||||
if (CollectionUtils.isEmpty(xAxis) && CollectionUtils.isEmpty(yAxis)) {
|
||||
return emptyChartViewDTO(view);
|
||||
@ -1014,7 +1039,7 @@ public class ChartViewService {
|
||||
}
|
||||
|
||||
// 处理过滤条件中的单引号
|
||||
fieldCustomFilter = fieldCustomFilter.stream().peek(ele -> {
|
||||
/*fieldCustomFilter = fieldCustomFilter.stream().peek(ele -> {
|
||||
if (CollectionUtils.isNotEmpty(ele.getEnumCheckField())) {
|
||||
List<String> collect = ele.getEnumCheckField().stream().map(SQLUtils::transKeyword).collect(Collectors.toList());
|
||||
ele.setEnumCheckField(collect);
|
||||
@ -1023,7 +1048,8 @@ public class ChartViewService {
|
||||
List<ChartCustomFilterItemDTO> collect = ele.getFilter().stream().peek(f -> f.setValue(SQLUtils.transKeyword(f.getValue()))).collect(Collectors.toList());
|
||||
ele.setFilter(collect);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}).collect(Collectors.toList());*/
|
||||
fieldCustomFilter = chartFilterTreeService.charReplace(fieldCustomFilter);
|
||||
|
||||
extFilterList = extFilterList.stream().peek(ele -> {
|
||||
if (CollectionUtils.isNotEmpty(ele.getValue())) {
|
||||
@ -1103,6 +1129,8 @@ public class ChartViewService {
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
querySql = qp.getSQLWithPage(true, dataTableInfoDTO.getTable(), xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view, pageInfo);
|
||||
totalPageSql = qp.getResultCount(true, dataTableInfoDTO.getTable(), xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view);
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
querySql = qp.getSQLRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, ds, view);
|
||||
} else {
|
||||
querySql = qp.getSQL(dataTableInfoDTO.getTable(), xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view);
|
||||
if (containDetailField(view) && CollectionUtils.isNotEmpty(viewFields)) {
|
||||
@ -1126,6 +1154,10 @@ public class ChartViewService {
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
querySql = qp.getSQLWithPage(false, sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view, pageInfo);
|
||||
totalPageSql = qp.getResultCount(false, sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view);
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
|
||||
querySql = qp.getSQLAsTmpRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view);
|
||||
|
||||
} else {
|
||||
querySql = qp.getSQLAsTmp(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view);
|
||||
if (containDetailField(view) && CollectionUtils.isNotEmpty(viewFields)) {
|
||||
@ -1150,6 +1182,9 @@ public class ChartViewService {
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
querySql = qp.getSQLWithPage(false, sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view, pageInfo);
|
||||
totalPageSql = qp.getResultCount(false, sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view);
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
querySql = qp.getSQLAsTmpRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view);
|
||||
|
||||
} else {
|
||||
querySql = qp.getSQLAsTmp(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view);
|
||||
if (containDetailField(view) && CollectionUtils.isNotEmpty(viewFields)) {
|
||||
@ -1174,6 +1209,10 @@ public class ChartViewService {
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
querySql = qp.getSQLWithPage(false, sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view, pageInfo);
|
||||
totalPageSql = qp.getResultCount(false, sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view);
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
|
||||
querySql = qp.getSQLAsTmpRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view);
|
||||
|
||||
} else {
|
||||
querySql = qp.getSQLAsTmp(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view);
|
||||
if (containDetailField(view) && CollectionUtils.isNotEmpty(viewFields)) {
|
||||
@ -1228,6 +1267,10 @@ public class ChartViewService {
|
||||
datasourceRequest.setQuery(qp.getSQLScatter(tableName, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extBubble, extStack, ds, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
|
||||
datasourceRequest.setQuery(qp.getSQLTableInfo(tableName, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
|
||||
|
||||
datasourceRequest.setQuery(qp.getSQLRangeBar(tableName, xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, ds, view));
|
||||
|
||||
}else {
|
||||
datasourceRequest.setQuery(qp.getSQL(tableName, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
|
||||
if (containDetailField(view) && CollectionUtils.isNotEmpty(viewFields)) {
|
||||
@ -1540,7 +1583,7 @@ public class ChartViewService {
|
||||
return dto;
|
||||
}
|
||||
|
||||
private PluginViewParam buildPluginParam(Map<String, List<ChartViewFieldDTO>> fieldMap, List<ChartFieldCustomFilterDTO> customFilters, List<ChartExtFilterRequest> extFilters, Datasource ds, DatasetTable table, ChartViewDTO view, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, ChartExtRequest chartExtRequest) {
|
||||
private PluginViewParam buildPluginParam(Map<String, List<ChartViewFieldDTO>> fieldMap, FilterTreeObj customFilters, List<ChartExtFilterRequest> extFilters, Datasource ds, DatasetTable table, ChartViewDTO view, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, ChartExtRequest chartExtRequest) {
|
||||
PluginViewParam pluginViewParam = new PluginViewParam();
|
||||
PluginViewSetImpl pluginViewSet = BeanUtils.copyBean(new PluginViewSetImpl(), table);
|
||||
pluginViewSet.setDsType(ds.getType());
|
||||
@ -1550,7 +1593,7 @@ public class ChartViewService {
|
||||
PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view);
|
||||
|
||||
|
||||
List<PluginChartFieldCustomFilter> fieldFilters = customFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartFieldCustomFilter.class)).collect(Collectors.toList());
|
||||
PluginFilterTreeObj fieldFilters = gson.fromJson(gson.toJson(customFilters), PluginFilterTreeObj.class);
|
||||
List<PluginChartExtFilter> panelFilters = extFilters.stream().map(filter -> gson.fromJson(gson.toJson(filter), PluginChartExtFilter.class)).collect(Collectors.toList());
|
||||
|
||||
List<PluginViewField> pluginViewFields = fieldMap.entrySet().stream().flatMap(entry -> entry.getValue().stream().map(field -> {
|
||||
@ -1573,7 +1616,7 @@ public class ChartViewService {
|
||||
Map<String, ViewPluginService> beanMap = SpringContextUtil.getApplicationContext().getBeansOfType(ViewPluginService.class);
|
||||
|
||||
if (beanMap.keySet().size() == 0) {
|
||||
DEException.throwException("没有此插件");
|
||||
DataEaseException.throwException("没有此插件");
|
||||
|
||||
}
|
||||
ViewPluginService viewPluginService = null;
|
||||
@ -1583,7 +1626,7 @@ public class ChartViewService {
|
||||
return viewPluginService;
|
||||
}
|
||||
}
|
||||
if (null == viewPluginService) DEException.throwException("没有此插件");
|
||||
if (null == viewPluginService) DataEaseException.throwException("没有此插件");
|
||||
return viewPluginService;
|
||||
}
|
||||
|
||||
@ -2113,7 +2156,7 @@ public class ChartViewService {
|
||||
if (ObjectUtils.isNotEmpty(datasetTableField)) {
|
||||
if (datasetTableField.getDeType() == 0 || datasetTableField.getDeType() == 1 || datasetTableField.getDeType() == 5) {
|
||||
if (!StringUtils.containsIgnoreCase(summary, "count")) {
|
||||
DEException.throwException(Translator.get("i18n_gauge_field_change"));
|
||||
DataEaseException.throwException(Translator.get("i18n_gauge_field_change"));
|
||||
}
|
||||
}
|
||||
ChartViewFieldDTO dto = new ChartViewFieldDTO();
|
||||
@ -2121,7 +2164,7 @@ public class ChartViewService {
|
||||
dto.setSummary(summary);
|
||||
return dto;
|
||||
} else {
|
||||
DEException.throwException(Translator.get("i18n_gauge_field_delete"));
|
||||
DataEaseException.throwException(Translator.get("i18n_gauge_field_delete"));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.service.chart;
|
||||
|
||||
import com.google.gson.internal.LinkedTreeMap;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -9,7 +10,6 @@ import org.springframework.stereotype.Service;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import io.dataease.auth.annotation.DePermissionProxy;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.model.excel.ExcelSheetModel;
|
||||
import io.dataease.commons.utils.ExcelUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
@ -91,7 +91,7 @@ public class ViewExportExcel {
|
||||
chartViewDTO = chartViewService.getData(viewId, request);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage());
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
String title = Optional.ofNullable(chartViewDTO.getTitle()).orElse(chartViewDTO.getName());
|
||||
Map<String, Object> chart = chartViewDTO.getData();
|
||||
|
@ -13,16 +13,17 @@ import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.constants.DatasetType;
|
||||
import io.dataease.plugins.common.constants.datasource.SQLConstants;
|
||||
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
|
||||
import io.dataease.plugins.common.dto.chart.ChartViewFieldFilterDTO;
|
||||
import io.dataease.plugins.common.dto.sqlObj.SQLObj;
|
||||
import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.util.BeanUtils;
|
||||
import io.dataease.plugins.common.util.ConstantsUtil;
|
||||
import io.dataease.plugins.datasource.query.QueryProvider;
|
||||
import io.dataease.plugins.view.entity.*;
|
||||
import io.dataease.plugins.view.entity.filter.PluginFilterTreeObj;
|
||||
import io.dataease.plugins.view.service.ViewPluginBaseService;
|
||||
import io.dataease.provider.ProviderFactory;
|
||||
import io.dataease.service.dataset.DataSetTableService;
|
||||
@ -33,7 +34,9 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.dataease.plugins.common.constants.datasource.SQLConstants.TABLE_ALIAS_PREFIX;
|
||||
@ -76,11 +79,11 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String customWhere(String dsType, List<PluginChartFieldCustomFilter> list, PluginViewSQL pluginViewSQL) {
|
||||
public String customWhere(String dsType, PluginFilterTreeObj obj, PluginViewSQL pluginViewSQL) {
|
||||
QueryProvider queryProvider = ProviderFactory.getQueryProvider(dsType);
|
||||
String methodName = "transCustomFilterList";
|
||||
String methodName = "transChartFilterTrees";
|
||||
SQLObj sqlObj = BeanUtils.copyBean(SQLObj.builder().build(), pluginViewSQL);
|
||||
List<ChartFieldCustomFilterDTO> filters = list.stream().map(item -> gson.fromJson(gson.toJson(item), ChartFieldCustomFilterDTO.class)).collect(Collectors.toList());
|
||||
FilterTreeObj filters = gson.fromJson(gson.toJson(obj), FilterTreeObj.class);
|
||||
Object o;
|
||||
if ((o = execProviderMethod(queryProvider, methodName, sqlObj, filters)) != null) {
|
||||
return (String) o;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package io.dataease.service.chart.build;
|
||||
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.dto.chart.FilterParamTO;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.service.chart.FilterBuildTemplate;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@ -160,7 +160,7 @@ public abstract class TimeBuild extends FilterBuildTemplate {
|
||||
Method setMethod = instance.getClass().getMethod("set", int.class, int.class);
|
||||
setMethod.invoke(instance, fieldFlag, value);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
@ -1333,7 +1333,7 @@ public class ChartDataBuild {
|
||||
|
||||
StringBuilder xField = new StringBuilder();
|
||||
if (isDrill) {
|
||||
xField.append(row[xAxis.size() - 1]);
|
||||
xField.append(row[xAxis.size() - 1 - 2]); // 由于起止时间字段是放到最后的yField里去查询的,所以要再减两个
|
||||
} else {
|
||||
for (int i = 0; i < xAxisBase.size(); i++) {
|
||||
if (i == xAxisBase.size() - 1) {
|
||||
@ -1360,24 +1360,25 @@ public class ChartDataBuild {
|
||||
|
||||
List<String> values = new ArrayList<>();
|
||||
|
||||
if (row[xAxisBase.size()] == null || row[xAxisBase.size() + 1] == null) {
|
||||
// 由于起止时间字段是放到最后的yField里去查询的,所以拿倒数两个
|
||||
if (row[xAxis.size() - 1] == null || row[xAxis.size() - 2] == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
values.add(row[xAxisBase.size()]);
|
||||
values.add(row[xAxisBase.size() + 1]);
|
||||
values.add(row[xAxis.size() - 2]);
|
||||
values.add(row[xAxis.size() - 1]);
|
||||
obj.put("values", values);
|
||||
|
||||
|
||||
try {
|
||||
Date date = sdf.parse(row[xAxisBase.size()]);
|
||||
Date date = sdf.parse(row[xAxis.size() - 2]);
|
||||
if (date != null) {
|
||||
dates.add(date);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
try {
|
||||
Date date = sdf.parse(row[xAxisBase.size() + 1]);
|
||||
Date date = sdf.parse(row[xAxis.size() - 1]);
|
||||
if (date != null) {
|
||||
dates.add(date);
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package io.dataease.service.dataset;
|
||||
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.TableUtils;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
import io.dataease.plugins.common.base.mapper.DatasetTableFieldMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -58,7 +58,7 @@ public class DataSetTableFieldsService {
|
||||
}
|
||||
List<DatasetTableField> datasetTableFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
if (CollectionUtils.isNotEmpty(datasetTableFields)) {
|
||||
DEException.throwException(Translator.get("i18n_field_name_repeat"));
|
||||
DataEaseException.throwException(Translator.get("i18n_field_name_repeat"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ import com.google.gson.reflect.TypeToken;
|
||||
import io.dataease.auth.annotation.DeCleaner;
|
||||
import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.commons.constants.*;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.*;
|
||||
import io.dataease.controller.ResultHolder;
|
||||
import io.dataease.controller.dataset.request.DataSetTaskInstanceGridRequest;
|
||||
@ -30,7 +29,6 @@ import io.dataease.dto.dataset.*;
|
||||
import io.dataease.dto.dataset.union.UnionDTO;
|
||||
import io.dataease.dto.dataset.union.UnionItemDTO;
|
||||
import io.dataease.dto.dataset.union.UnionParamDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.ext.ExtDataSetGroupMapper;
|
||||
import io.dataease.ext.ExtDataSetTableMapper;
|
||||
import io.dataease.ext.UtilMapper;
|
||||
@ -44,6 +42,7 @@ import io.dataease.plugins.common.constants.DeTypeConstants;
|
||||
import io.dataease.plugins.common.dto.dataset.SqlVariableDetails;
|
||||
import io.dataease.plugins.common.dto.datasource.DataSourceType;
|
||||
import io.dataease.plugins.common.dto.datasource.TableField;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeObj;
|
||||
@ -643,7 +642,7 @@ public class DataSetTableService {
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@ -653,7 +652,7 @@ public class DataSetTableService {
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
// check doris table
|
||||
@ -680,7 +679,7 @@ public class DataSetTableService {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields,
|
||||
@ -688,7 +687,7 @@ public class DataSetTableService {
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -722,7 +721,7 @@ public class DataSetTableService {
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setPageable(false);
|
||||
@ -731,7 +730,7 @@ public class DataSetTableService {
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
// check doris table
|
||||
@ -751,7 +750,7 @@ public class DataSetTableService {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields,
|
||||
@ -759,7 +758,7 @@ public class DataSetTableService {
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "excel")) {
|
||||
@ -780,7 +779,7 @@ public class DataSetTableService {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setQuery(qp.createQueryTableWithLimit(table, fields,
|
||||
@ -788,7 +787,7 @@ public class DataSetTableService {
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
DataSetTaskInstanceGridRequest request = new DataSetTaskInstanceGridRequest();
|
||||
request.setTableId(List.of(dataSetTableRequest.getId()));
|
||||
@ -818,7 +817,7 @@ public class DataSetTableService {
|
||||
sql = getCustomSQLDatasource(dt, list, ds);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(
|
||||
@ -834,7 +833,7 @@ public class DataSetTableService {
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setPageable(false);
|
||||
@ -843,7 +842,7 @@ public class DataSetTableService {
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
Datasource ds = engineService.getDeEngine();
|
||||
@ -859,7 +858,7 @@ public class DataSetTableService {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@ -868,14 +867,14 @@ public class DataSetTableService {
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.equalsIgnoreCase(datasetTable.getType(), "union")) {
|
||||
if (datasetTable.getMode() == 0) {
|
||||
Datasource ds = datasourceMapper.selectByPrimaryKey(dataSetTableRequest.getDataSourceId());
|
||||
if (ObjectUtils.isEmpty(ds)) {
|
||||
DEException.throwException(Translator.get("i18n_datasource_delete"));
|
||||
DataEaseException.throwException(Translator.get("i18n_datasource_delete"));
|
||||
}
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(ds.getType());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
@ -888,7 +887,7 @@ public class DataSetTableService {
|
||||
sql = (String) getUnionSQLDatasource(dt, ds).get("sql");
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
|
||||
datasourceRequest.setQuery(
|
||||
@ -904,7 +903,7 @@ public class DataSetTableService {
|
||||
data.addAll(datasourceProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
datasourceRequest.setPageable(false);
|
||||
@ -913,7 +912,7 @@ public class DataSetTableService {
|
||||
dataSetPreviewPage.setTotal(datasourceProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
Datasource ds = engineService.getDeEngine();
|
||||
@ -929,7 +928,7 @@ public class DataSetTableService {
|
||||
data.addAll(jdbcProvider.getData(datasourceRequest));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@ -938,7 +937,7 @@ public class DataSetTableService {
|
||||
dataSetPreviewPage.setTotal(jdbcProvider.getData(datasourceRequest).size());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
DEException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_error") + "->" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1559,7 +1558,7 @@ public class DataSetTableService {
|
||||
DatasetTableField sourceField = dataSetTableFieldsService.get(dto.getSourceTableFieldId());
|
||||
DatasetTableField targetField = dataSetTableFieldsService.get(dto.getTargetTableFieldId());
|
||||
if (ObjectUtils.isEmpty(sourceField) || ObjectUtils.isEmpty(targetField)) {
|
||||
DEException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
DataEaseException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
}
|
||||
|
||||
join.append(convertUnionTypeToSQL(dto.getSourceUnionRelation()))
|
||||
@ -1627,7 +1626,7 @@ public class DataSetTableService {
|
||||
DatasetTableField sourceField = dataSetTableFieldsService.get(dto.getSourceTableFieldId());
|
||||
DatasetTableField targetField = dataSetTableFieldsService.get(dto.getTargetTableFieldId());
|
||||
if (ObjectUtils.isEmpty(sourceField) || ObjectUtils.isEmpty(targetField)) {
|
||||
DEException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
DataEaseException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
}
|
||||
DatasetTable sourceTable = datasetTableMapper.selectByPrimaryKey(dto.getSourceTableId());
|
||||
String sourceTableName = new Gson().fromJson(sourceTable.getInfo(), DataTableInfoDTO.class)
|
||||
@ -1692,14 +1691,14 @@ public class DataSetTableService {
|
||||
String table = TableUtils.tableName(tableId);
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(tableId);
|
||||
if (ObjectUtils.isEmpty(datasetTable)) {
|
||||
DEException.throwException(
|
||||
DataEaseException.throwException(
|
||||
Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
if (user != null && !user.getIsAdmin()) {
|
||||
DataSetTableDTO withPermission = getWithPermission(datasetTable.getId(), user.getUserId());
|
||||
if (ObjectUtils.isEmpty(withPermission.getPrivileges()) || !withPermission.getPrivileges().contains("use")) {
|
||||
DEException.throwException(
|
||||
DataEaseException.throwException(
|
||||
Translator.get("i18n_dataset_no_permission") + String.format(":table name [%s]", withPermission.getName()));
|
||||
}
|
||||
}
|
||||
@ -1709,7 +1708,7 @@ public class DataSetTableService {
|
||||
.map(f -> {
|
||||
String s = "";
|
||||
if (f == null) {
|
||||
DEException.throwException(
|
||||
DataEaseException.throwException(
|
||||
Translator.get("i18n_ds_error"));
|
||||
} else {
|
||||
s = table + "." + f.getDataeaseName() + " AS "
|
||||
@ -1743,7 +1742,7 @@ public class DataSetTableService {
|
||||
DatasetTableField pField = dataSetTableFieldsService.get(u.getParentField().getId());
|
||||
DatasetTableField cField = dataSetTableFieldsService.get(u.getCurrentField().getId());
|
||||
if (ObjectUtils.isEmpty(pField) || ObjectUtils.isEmpty(cField)) {
|
||||
DEException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
DataEaseException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
}
|
||||
DatasetTable parentTable = datasetTableMapper.selectByPrimaryKey(pField.getTableId());
|
||||
DatasetTable currentTable = datasetTableMapper.selectByPrimaryKey(cField.getTableId());
|
||||
@ -1769,7 +1768,7 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(f)) {
|
||||
DEException.throwException(Translator.get("i18n_union_ds_no_checked"));
|
||||
DataEaseException.throwException(Translator.get("i18n_union_ds_no_checked"));
|
||||
}
|
||||
sql = MessageFormat.format("SELECT {0} FROM {1}", f,
|
||||
TableUtils.tableName(union.get(0).getCurrentDs().getId())) + join.toString();
|
||||
@ -1797,7 +1796,7 @@ public class DataSetTableService {
|
||||
String table = TableUtils.tableName(tableId);
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(tableId);
|
||||
if (ObjectUtils.isEmpty(datasetTable)) {
|
||||
DEException.throwException(
|
||||
DataEaseException.throwException(
|
||||
Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
List<DatasetTableField> fields = dataSetTableFieldsService.getListByIdsEach(unionDTO.getCurrentDsField());
|
||||
@ -1832,7 +1831,7 @@ public class DataSetTableService {
|
||||
if (StringUtils.isNotEmpty(schema) && (StringUtils.equalsIgnoreCase(ds.getType(), DatasourceTypes.db2.getType()) ||
|
||||
StringUtils.equalsIgnoreCase(ds.getType(), DatasourceTypes.sqlServer.getType()) ||
|
||||
StringUtils.equalsIgnoreCase(ds.getType(), DatasourceTypes.oracle.getType()) ||
|
||||
StringUtils.equalsIgnoreCase(ds.getType(), DatasourceTypes.kingbase.getType()) ||
|
||||
StringUtils.equalsIgnoreCase(ds.getType(), "kingbase") ||
|
||||
StringUtils.equalsIgnoreCase(ds.getType(), DatasourceTypes.pg.getType()))) {
|
||||
joinPrefix = String.format(keyword, schema) + ".";
|
||||
}
|
||||
@ -1852,14 +1851,14 @@ public class DataSetTableService {
|
||||
String table = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
String tableId = unionDTO.getCurrentDs().getId();
|
||||
if (ObjectUtils.isEmpty(datasetTable)) {
|
||||
DEException.throwException(
|
||||
DataEaseException.throwException(
|
||||
Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
CurrentUserDto user = AuthUtils.getUser();
|
||||
if (user != null && !user.getIsAdmin()) {
|
||||
DataSetTableDTO withPermission = getWithPermission(datasetTable.getId(), user.getUserId());
|
||||
if (ObjectUtils.isEmpty(withPermission.getPrivileges()) || !withPermission.getPrivileges().contains("use")) {
|
||||
DEException.throwException(
|
||||
DataEaseException.throwException(
|
||||
Translator.get("i18n_dataset_no_permission") + String.format(":table name [%s]", withPermission.getName()));
|
||||
}
|
||||
}
|
||||
@ -1894,7 +1893,7 @@ public class DataSetTableService {
|
||||
DatasetTableField pField = dataSetTableFieldsService.get(u.getParentField().getId());
|
||||
DatasetTableField cField = dataSetTableFieldsService.get(u.getCurrentField().getId());
|
||||
if (ObjectUtils.isEmpty(pField) || ObjectUtils.isEmpty(cField)) {
|
||||
DEException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
DataEaseException.throwException(Translator.get("i18n_dataset_field_delete"));
|
||||
}
|
||||
DatasetTable parentTable = datasetTableMapper.selectByPrimaryKey(pField.getTableId());
|
||||
String parentTableName = new Gson().fromJson(parentTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
@ -1923,7 +1922,7 @@ public class DataSetTableService {
|
||||
}
|
||||
}
|
||||
if (StringUtils.isEmpty(f)) {
|
||||
DEException.throwException(Translator.get("i18n_union_ds_no_checked"));
|
||||
DataEaseException.throwException(Translator.get("i18n_union_ds_no_checked"));
|
||||
}
|
||||
sql = MessageFormat.format("SELECT {0} FROM {1}", f, joinPrefix + String.format(keyword, tableName)) + join.toString();
|
||||
} else {
|
||||
@ -1957,7 +1956,7 @@ public class DataSetTableService {
|
||||
DatasetTable datasetTable = datasetTableMapper.selectByPrimaryKey(unionDTO.getCurrentDs().getId());
|
||||
String tableId = unionDTO.getCurrentDs().getId();
|
||||
if (ObjectUtils.isEmpty(datasetTable)) {
|
||||
DEException.throwException(
|
||||
DataEaseException.throwException(
|
||||
Translator.get("i18n_custom_ds_delete") + String.format(":table id [%s]", tableId));
|
||||
}
|
||||
String table = new Gson().fromJson(datasetTable.getInfo(), DataTableInfoDTO.class).getTable();
|
||||
|
@ -7,13 +7,13 @@ import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.controller.dataset.request.DataSetTaskInstanceGridRequest;
|
||||
import io.dataease.dto.dataset.DataSetTaskDTO;
|
||||
import io.dataease.dto.dataset.DataSetTaskLogDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.ext.ExtDataSetTaskMapper;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableTaskLog;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableTaskLogExample;
|
||||
import io.dataease.plugins.common.base.mapper.DatasetTableTaskLogMapper;
|
||||
import io.dataease.plugins.common.base.mapper.DatasetTableTaskMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.service.system.SystemParameterService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -8,13 +8,12 @@ import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.controller.dataset.request.DatasetTaskGridRequest;
|
||||
import io.dataease.controller.request.dataset.DataSetTaskRequest;
|
||||
import io.dataease.dto.dataset.DataSetTaskDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.ext.ExtDataSetTaskMapper;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.job.sechedule.ScheduleManager;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
import io.dataease.plugins.common.base.mapper.DatasetTableMapper;
|
||||
import io.dataease.plugins.common.base.mapper.DatasetTableTaskMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.service.ScheduleService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
@ -9,7 +9,6 @@ import io.dataease.controller.request.datasource.ApiDefinition;
|
||||
import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import io.dataease.dto.dataset.ExcelSheetData;
|
||||
import io.dataease.dto.datasource.*;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.ext.ExtChartViewMapper;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
@ -17,6 +16,7 @@ import io.dataease.plugins.common.constants.DatasetType;
|
||||
import io.dataease.plugins.common.constants.DatasourceTypes;
|
||||
import io.dataease.plugins.common.constants.DeTypeConstants;
|
||||
import io.dataease.plugins.common.dto.datasource.TableField;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.datasource.entity.JdbcConfiguration;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
@ -1274,7 +1274,7 @@ public class ExtractDataService {
|
||||
String excelCompletion = "";
|
||||
|
||||
for (DatasetTableField datasetTableField : datasetTableFields) {
|
||||
if (datasetTableField.getDeExtractType().equals(DeTypeConstants.DE_BINARY)) {
|
||||
if (datasetTableField.getDeExtractType().equals(DeTypeConstants.DE_BINARY) || datasetTableField.getType().equalsIgnoreCase("blob")) {
|
||||
handleBinaryTypeCode.append("\n").append(handleBinaryType.replace("FIELD", datasetTableField.getDataeaseName()));
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package io.dataease.service.dataset.impl.direct;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.model.BaseTreeNode;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
@ -12,13 +11,13 @@ import io.dataease.dto.dataset.DataSetTableUnionDTO;
|
||||
import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||
import io.dataease.dto.dataset.DeSortDTO;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTable;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.Datasource;
|
||||
import io.dataease.plugins.common.constants.DatasetType;
|
||||
import io.dataease.plugins.common.dto.chart.ChartFieldCustomFilterDTO;
|
||||
import io.dataease.plugins.common.dto.datasource.DeSortField;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.chart.filter.FilterTreeObj;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.datasource.provider.Provider;
|
||||
@ -119,11 +118,11 @@ public class DirectFieldService implements DataSetFieldService {
|
||||
final List<String> allTableFieldIds = fields.stream().map(DatasetTableField::getId).collect(Collectors.toList());
|
||||
boolean multi = fieldIds.stream().anyMatch(item -> !allTableFieldIds.contains(item));
|
||||
if (multi && needMapping) {
|
||||
DEException.throwException(Translator.get("i18n_dataset_cross_multiple"));
|
||||
DataEaseException.throwException(Translator.get("i18n_dataset_cross_multiple"));
|
||||
}
|
||||
|
||||
List<DatasetTableField> permissionFields = fields;
|
||||
List<ChartFieldCustomFilterDTO> customFilter = new ArrayList<>();
|
||||
FilterTreeObj customFilter = new FilterTreeObj();
|
||||
List<DataSetRowPermissionsTreeDTO> rowPermissionsTree = new ArrayList<>();
|
||||
if (userPermissions) {
|
||||
//列权限
|
||||
|
@ -9,7 +9,6 @@ import io.dataease.auth.annotation.DeCleaner;
|
||||
import io.dataease.commons.constants.DePermissionType;
|
||||
import io.dataease.commons.constants.RedisConstants;
|
||||
import io.dataease.commons.constants.SysAuthConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.model.AuthURD;
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
@ -39,6 +38,7 @@ import io.dataease.plugins.common.constants.DatasourceTypes;
|
||||
import io.dataease.plugins.common.dto.datasource.DataSourceType;
|
||||
import io.dataease.plugins.common.dto.datasource.TableDesc;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.datasource.DatasourceRequest;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.datasource.entity.JdbcConfiguration;
|
||||
@ -371,11 +371,9 @@ public class DatasourceService {
|
||||
String datasourceStatus = null;
|
||||
try {
|
||||
Provider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
|
||||
System.out.println(datasourceProvider.getClass());
|
||||
DatasourceRequest datasourceRequest = new DatasourceRequest();
|
||||
datasourceRequest.setDatasource(datasource);
|
||||
datasourceStatus = datasourceProvider.checkStatus(datasourceRequest);
|
||||
System.out.println(datasourceStatus);
|
||||
if (datasource.getType().equalsIgnoreCase("api")) {
|
||||
List<ApiDefinition> apiDefinitionList = new Gson().fromJson(datasource.getConfiguration(), new TypeToken<List<ApiDefinition>>() {
|
||||
}.getType());
|
||||
@ -499,7 +497,7 @@ public class DatasourceService {
|
||||
criteria.andIdNotEqualTo(id);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(datasourceMapper.selectByExample(example))) {
|
||||
DEException.throwException(Translator.get("i18n_ds_name_exists"));
|
||||
DataEaseException.throwException(Translator.get("i18n_ds_name_exists"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class DriverService {
|
||||
|
||||
public List<DriverDTO> list() throws Exception {
|
||||
List<DriverDTO> driverDTOS = new ArrayList<>();
|
||||
deDriverMapper.selectByExample(null).forEach(deDriver -> {
|
||||
deDriverMapper.selectByExampleWithBLOBs(null).forEach(deDriver -> {
|
||||
DriverDTO driverDTO = new DriverDTO();
|
||||
BeanUtils.copyBean(driverDTO, deDriver);
|
||||
datasourceService.types().forEach(dataSourceType -> {
|
||||
@ -81,10 +81,9 @@ public class DriverService {
|
||||
}
|
||||
DeDriverExample example = new DeDriverExample();
|
||||
example.createCriteria().andNameEqualTo(deDriver.getName());
|
||||
if(CollectionUtil.isNotEmpty(deDriverMapper.selectByExample(example))){
|
||||
if(CollectionUtil.isNotEmpty(deDriverMapper.selectByExampleWithBLOBs(example))){
|
||||
throw new RuntimeException(Translator.get("I18N_DRIVER_REPEAT_NAME"));
|
||||
}
|
||||
|
||||
deDriver.setCreateTime(System.currentTimeMillis());
|
||||
deDriver.setId(UUID.randomUUID().toString());
|
||||
deDriverMapper.insert(deDriver);
|
||||
@ -92,7 +91,7 @@ public class DriverService {
|
||||
}
|
||||
|
||||
public DeDriver update(DeDriver deDriver) {
|
||||
deDriverMapper.updateByPrimaryKey(deDriver);
|
||||
deDriverMapper.updateByPrimaryKeyWithBLOBs(deDriver);
|
||||
return deDriver;
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,10 @@ package io.dataease.service.panel;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.dto.chart.ChartViewDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.base.domain.PanelGroupExtendData;
|
||||
import io.dataease.plugins.common.base.domain.PanelGroupExtendDataExample;
|
||||
import io.dataease.plugins.common.base.mapper.PanelGroupExtendDataMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -26,13 +26,13 @@ import io.dataease.dto.panel.PanelExport2App;
|
||||
import io.dataease.dto.panel.PanelGroupDTO;
|
||||
import io.dataease.dto.panel.PanelTemplateFileDTO;
|
||||
import io.dataease.dto.panel.po.PanelViewInsertDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.ext.*;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
import io.dataease.plugins.common.base.mapper.*;
|
||||
import io.dataease.plugins.common.constants.DeTypeConstants;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.service.chart.ChartViewService;
|
||||
import io.dataease.service.dataset.DataSetGroupService;
|
||||
import io.dataease.service.dataset.DataSetTableService;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package io.dataease.service.panel;
|
||||
|
||||
import io.dataease.controller.request.panel.PanelSubjectRequest;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.base.domain.PanelSubject;
|
||||
import io.dataease.plugins.common.base.domain.PanelSubjectExample;
|
||||
import io.dataease.plugins.common.base.mapper.PanelSubjectMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
|
@ -6,12 +6,12 @@ import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.controller.request.panel.PanelTemplateRequest;
|
||||
import io.dataease.dto.panel.PanelTemplateDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.PanelTemplate;
|
||||
import io.dataease.plugins.common.base.domain.PanelTemplateExample;
|
||||
import io.dataease.plugins.common.base.domain.PanelTemplateWithBLOBs;
|
||||
import io.dataease.plugins.common.base.mapper.PanelTemplateMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.service.staticResource.StaticResourceService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -2,6 +2,7 @@ package io.dataease.service.panel;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import io.dataease.dto.panel.PanelComponentDTO;
|
||||
import io.dataease.ext.ExtChartViewMapper;
|
||||
import io.dataease.ext.ExtPanelGroupMapper;
|
||||
import io.dataease.ext.ExtPanelViewMapper;
|
||||
@ -15,6 +16,7 @@ import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.PanelGroupWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.PanelView;
|
||||
import io.dataease.plugins.common.base.domain.PanelViewExample;
|
||||
import io.dataease.plugins.common.base.mapper.PanelGroupMapper;
|
||||
import io.dataease.plugins.common.base.mapper.PanelViewMapper;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@ -45,6 +47,9 @@ public class PanelViewService {
|
||||
@Resource
|
||||
private ExtChartViewMapper extChartViewMapper;
|
||||
|
||||
@Resource
|
||||
private PanelGroupMapper panelGroupMapper;
|
||||
|
||||
private final static String SCENE_TYPE = "scene";
|
||||
|
||||
public List<PanelViewDto> groups() {
|
||||
@ -152,6 +157,11 @@ public class PanelViewService {
|
||||
return extPanelViewMapper.getPanelViewDetails(panelId);
|
||||
}
|
||||
|
||||
public PanelComponentDTO getComponentInfo(String panelId){
|
||||
PanelGroupWithBLOBs panelGroup = panelGroupMapper.selectByPrimaryKey(panelId);
|
||||
return new PanelComponentDTO(panelGroup.getPanelData(),detailList(panelId));
|
||||
}
|
||||
|
||||
public List<PanelView> findPanelViews(String copyId) {
|
||||
PanelViewExample panelViewExample = new PanelViewExample();
|
||||
panelViewExample.createCriteria().andCopyIdEqualTo(copyId);
|
||||
|
@ -3,12 +3,11 @@ package io.dataease.service.staticResource;
|
||||
import cn.hutool.core.codec.Base64Decoder;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.FileUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.StaticResourceUtils;
|
||||
import io.dataease.controller.request.resource.StaticResourceRequest;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
@ -16,7 +15,6 @@ import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
@ -42,7 +40,7 @@ public class StaticResourceService {
|
||||
Assert.notNull(file, "Multipart file must not be null");
|
||||
try {
|
||||
if (!isImage(file)) {
|
||||
DEException.throwException("Multipart file must be image");
|
||||
DataEaseException.throwException("Multipart file must be image");
|
||||
}
|
||||
String originName = file.getOriginalFilename();
|
||||
String newFileName = fileId + originName.substring(originName.lastIndexOf("."), originName.length());
|
||||
|
@ -4,7 +4,6 @@ import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ZipUtil;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
import io.dataease.commons.utils.DeFileUtils;
|
||||
import io.dataease.commons.utils.IPUtils;
|
||||
@ -15,6 +14,7 @@ import io.dataease.i18n.Translator;
|
||||
import io.dataease.listener.util.CacheUtils;
|
||||
import io.dataease.plugins.common.base.domain.MyPlugin;
|
||||
import io.dataease.plugins.common.base.mapper.MyPluginMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.request.KeywordRequest;
|
||||
import io.dataease.plugins.config.LoadjarUtil;
|
||||
import io.dataease.plugins.entity.PluginOperate;
|
||||
@ -90,7 +90,7 @@ public class PluginService {
|
||||
DeFileUtils.deleteFile(folder);
|
||||
// 需要删除文件
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
//3.解析plugin.json 失败则 直接返回错误 删除文件
|
||||
File folderFile = new File(folder);
|
||||
@ -100,14 +100,14 @@ public class PluginService {
|
||||
DeFileUtils.deleteFile(folder);
|
||||
String msg = "缺少插件描述文件【plugin.json】";
|
||||
LogUtil.error(msg);
|
||||
DEException.throwException(msg);
|
||||
DataEaseException.throwException(msg);
|
||||
}
|
||||
MyPluginDTO myPlugin = formatJsonFile(jsonFiles[0]);
|
||||
|
||||
if (!versionMatch(myPlugin.getRequire())) {
|
||||
String msg = "当前插件要求系统版本最低为:" + myPlugin.getRequire();
|
||||
LogUtil.error(msg);
|
||||
DEException.throwException(msg);
|
||||
DataEaseException.throwException(msg);
|
||||
}
|
||||
//4.加载jar包 失败则 直接返回错误 删除文件
|
||||
File[] jarFiles = folderFile.listFiles(this::isPluginJar);
|
||||
@ -116,13 +116,13 @@ public class PluginService {
|
||||
DeFileUtils.deleteFile(folder);
|
||||
String msg = "缺少插件jar文件";
|
||||
LogUtil.error(msg);
|
||||
DEException.throwException(msg);
|
||||
DataEaseException.throwException(msg);
|
||||
}
|
||||
|
||||
if (pluginExist(myPlugin)) {
|
||||
String msg = "插件【" + myPlugin.getName() + "】已存在,请先卸载";
|
||||
LogUtil.error(msg);
|
||||
DEException.throwException(msg);
|
||||
DataEaseException.throwException(msg);
|
||||
}
|
||||
String targetDir = null;
|
||||
try {
|
||||
@ -144,7 +144,7 @@ public class PluginService {
|
||||
deleteJarFile(myPlugin);
|
||||
}
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
} finally {
|
||||
DeFileUtils.deleteFile(pluginDir + "temp/");
|
||||
DeFileUtils.deleteFile(folder);
|
||||
@ -229,7 +229,7 @@ public class PluginService {
|
||||
if (ObjectUtils.isEmpty(myPlugin)) {
|
||||
String msg = "当前插件不存在";
|
||||
LogUtil.error(msg);
|
||||
DEException.throwException(msg);
|
||||
DataEaseException.throwException(msg);
|
||||
}
|
||||
myPlugin = deleteJarFile(myPlugin);
|
||||
CacheUtils.removeAll(AuthConstants.USER_CACHE_NAME);
|
||||
@ -238,7 +238,7 @@ public class PluginService {
|
||||
|
||||
if (myPlugin.getCategory().equalsIgnoreCase("datasource") && !forUpdate) {
|
||||
if (CollectionUtils.isNotEmpty(datasourceService.selectByType(myPlugin.getDsType()))) {
|
||||
DEException.throwException(Translator.get("i18n_plugin_not_allow_delete"));
|
||||
DataEaseException.throwException(Translator.get("i18n_plugin_not_allow_delete"));
|
||||
}
|
||||
loadjarUtil.deleteModule(myPlugin.getModuleName() + "-" + myPlugin.getVersion());
|
||||
}
|
||||
@ -254,7 +254,7 @@ public class PluginService {
|
||||
|
||||
if (myPlugin.getCategory().equalsIgnoreCase("datasource")) {
|
||||
if (CollectionUtils.isNotEmpty(datasourceService.selectByType(myPlugin.getDsType()))) {
|
||||
DEException.throwException(Translator.get("i18n_plugin_not_allow_delete"));
|
||||
DataEaseException.throwException(Translator.get("i18n_plugin_not_allow_delete"));
|
||||
}
|
||||
loadjarUtil.deleteModule(myPlugin.getModuleName() + "-" + myPlugin.getVersion());
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import io.dataease.auth.api.dto.CurrentUserDto;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.service.ExtAuthService;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
|
||||
import io.dataease.commons.utils.AuthUtils;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.CodingUtil;
|
||||
@ -18,6 +18,7 @@ import io.dataease.plugins.common.base.mapper.SysUserAssistMapper;
|
||||
import io.dataease.plugins.common.base.mapper.SysUserMapper;
|
||||
import io.dataease.plugins.common.base.mapper.SysUsersRolesMapper;
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.xpack.dingtalk.dto.response.DingUserEntity;
|
||||
import io.dataease.plugins.xpack.lark.dto.entity.LarkUserInfo;
|
||||
import io.dataease.plugins.xpack.larksuite.dto.entity.UserData;
|
||||
@ -389,17 +390,17 @@ public class SysUserService {
|
||||
|
||||
if (ObjectUtils.isEmpty(user)) {
|
||||
String msg = "I18N_USER_DONOT_EXIST";
|
||||
DEException.throwException(Translator.get(msg));
|
||||
DataEaseException.throwException(Translator.get(msg));
|
||||
}
|
||||
if (!StringUtils.equals(CodingUtil.md5(request.getPassword()), user.getPassword())) {
|
||||
String msg = "I18N_USER_SOURCE_PWD_ERROR";
|
||||
DEException.throwException(Translator.get(msg));
|
||||
DataEaseException.throwException(Translator.get(msg));
|
||||
}
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setUserId(user.getUserId());
|
||||
if (!request.getNewPassword().matches("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).{8,30}$")) {
|
||||
String msg = "I18N_USER_PWD_FORMAT_ERROR";
|
||||
DEException.throwException(Translator.get(msg));
|
||||
DataEaseException.throwException(Translator.get(msg));
|
||||
}
|
||||
sysUser.setPassword(CodingUtil.md5(request.getNewPassword()));
|
||||
return sysUserMapper.updateByPrimaryKeySelective(sysUser);
|
||||
@ -445,7 +446,7 @@ public class SysUserService {
|
||||
@Transactional
|
||||
public int delete(Long userId) {
|
||||
if (userId.equals(1L)) {
|
||||
DEException.throwException(Translator.get("I18n_del_admin_tips"));
|
||||
DataEaseException.throwException(Translator.get("I18n_del_admin_tips"));
|
||||
}
|
||||
extAuthService.clearUserResource(userId);
|
||||
deleteUserRoles(userId);
|
||||
|
@ -14,12 +14,12 @@ import io.dataease.controller.sys.request.LogGridRequest;
|
||||
import io.dataease.dto.SysLogDTO;
|
||||
import io.dataease.dto.SysLogGridDTO;
|
||||
import io.dataease.dto.log.FolderItem;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.ext.ExtSysLogMapper;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SysLogExample;
|
||||
import io.dataease.plugins.common.base.domain.SysLogWithBLOBs;
|
||||
import io.dataease.plugins.common.base.mapper.SysLogMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.service.system.SystemParameterService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
|
@ -2,7 +2,7 @@ package io.dataease.service.system;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import io.dataease.commons.constants.ParamConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
|
||||
import io.dataease.commons.utils.CommonBeanFactory;
|
||||
import io.dataease.commons.utils.EncryptUtils;
|
||||
import io.dataease.commons.utils.LogUtil;
|
||||
@ -11,6 +11,7 @@ import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.SystemParameter;
|
||||
import io.dataease.plugins.common.base.domain.SystemParameterExample;
|
||||
import io.dataease.plugins.common.base.mapper.SystemParameterMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -78,7 +79,7 @@ public class EmailService {
|
||||
driver.send(mimeMessage);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(Translator.get("connection_failed"));
|
||||
DataEaseException.throwException(Translator.get("connection_failed"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +110,7 @@ public class EmailService {
|
||||
driver.send(mimeMessage);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +140,7 @@ public class EmailService {
|
||||
driver.send(mimeMessage);
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(e);
|
||||
DataEaseException.throwException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -314,7 +315,7 @@ public class EmailService {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
String key = "connection_failed";
|
||||
if (isAdmin) key = "connection_failed_admin";
|
||||
DEException.throwException(Translator.get(key));
|
||||
DataEaseException.throwException(Translator.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -326,7 +327,7 @@ public class EmailService {
|
||||
javaMailSender.testConnection();
|
||||
} catch (MessagingException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(Translator.get("connection_failed"));
|
||||
DataEaseException.throwException(Translator.get("connection_failed"));
|
||||
}
|
||||
testSendEmail(email, javaMailSender, true);
|
||||
}
|
||||
@ -353,7 +354,7 @@ public class EmailService {
|
||||
javaMailSender.testConnection();
|
||||
} catch (MessagingException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
DEException.throwException(Translator.get("connection_failed"));
|
||||
DataEaseException.throwException(Translator.get("connection_failed"));
|
||||
}
|
||||
testSendEmail(recipients, javaMailSender, false);
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
package io.dataease.service.system;
|
||||
|
||||
import io.dataease.commons.constants.ParamConstants;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.commons.utils.EncryptUtils;
|
||||
import io.dataease.controller.sys.response.BasicInfo;
|
||||
import io.dataease.dto.SystemParameterDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.ext.ExtSystemParameterMapper;
|
||||
import io.dataease.plugins.common.base.domain.FileMetadata;
|
||||
import io.dataease.plugins.common.base.domain.SystemParameter;
|
||||
import io.dataease.plugins.common.base.domain.SystemParameterExample;
|
||||
import io.dataease.plugins.common.base.mapper.SystemParameterMapper;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.util.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.cas.dto.CasSaveResult;
|
||||
import io.dataease.plugins.xpack.cas.service.CasXpackService;
|
||||
@ -196,9 +196,9 @@ public class SystemParameterService {
|
||||
@Transactional
|
||||
public void resetCas() {
|
||||
Map<String, CasXpackService> beansOfType = SpringContextUtil.getApplicationContext().getBeansOfType((CasXpackService.class));
|
||||
if (beansOfType.keySet().size() == 0) DEException.throwException("当前未启用CAS");
|
||||
if (beansOfType.keySet().size() == 0) DataEaseException.throwException("当前未启用CAS");
|
||||
CasXpackService casXpackService = SpringContextUtil.getBean(CasXpackService.class);
|
||||
if (ObjectUtils.isEmpty(casXpackService)) DEException.throwException("当前未启用CAS");
|
||||
if (ObjectUtils.isEmpty(casXpackService)) DataEaseException.throwException("当前未启用CAS");
|
||||
|
||||
String loginTypePk = "basic.loginType";
|
||||
SystemParameter loginTypeParameter = systemParameterMapper.selectByPrimaryKey(loginTypePk);
|
||||
@ -345,7 +345,7 @@ public class SystemParameterService {
|
||||
// It's an image (only BMP, GIF, JPG and PNG are recognized).
|
||||
ImageIO.read(input).toString();
|
||||
} catch (Exception e) {
|
||||
DEException.throwException("Uploaded images do not meet the image format requirements");
|
||||
DataEaseException.throwException("Uploaded images do not meet the image format requirements");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import io.dataease.dto.panel.PanelTemplateFileDTO;
|
||||
import io.dataease.dto.templateMarket.MarketBaseResponse;
|
||||
import io.dataease.dto.templateMarket.TemplateCategory;
|
||||
import io.dataease.dto.templateMarket.TemplateMarketDTO;
|
||||
import io.dataease.exception.DataEaseException;
|
||||
import io.dataease.plugins.common.exception.DataEaseException;
|
||||
import io.dataease.service.system.SystemParameterService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -14,3 +14,9 @@ ALTER TABLE `sys_task_email`
|
||||
|
||||
ALTER TABLE `sys_task_email`
|
||||
MODIFY COLUMN `reci_users` longtext NULL COMMENT '接收人账号' AFTER `conditions`;
|
||||
|
||||
ALTER TABLE de_driver ADD COLUMN `surpport_versions` LONGTEXT NULL AFTER `desc`;
|
||||
|
||||
BEGIN;
|
||||
INSERT INTO `sys_startup_job` VALUES ('chartFilterMerge', 'chartFilterMerge', 'ready');
|
||||
COMMIT;
|
||||
|
@ -26,7 +26,7 @@ export function queryTargetPanelJumpInfo(requestInfo) {
|
||||
url: '/linkJump/queryTargetPanelJumpInfo',
|
||||
method: 'post',
|
||||
data: requestInfo,
|
||||
loading: true
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,6 @@ export function getOuterParamsInfo(panelId) {
|
||||
return request({
|
||||
url: '/outerParams/getOuterParamsInfo/' + panelId,
|
||||
method: 'get',
|
||||
loading: true
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
@ -3,6 +3,15 @@ import request from '@/utils/request'
|
||||
export function detailList(panelId) {
|
||||
return request({
|
||||
url: '/panel/view/detailList/' + panelId,
|
||||
method: 'get'
|
||||
method: 'get',
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
export function getComponentInfo(panelId) {
|
||||
return request({
|
||||
url: '/panel/view/getComponentInfo/' + panelId,
|
||||
method: 'get',
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
|
||||
<div
|
||||
id="fullscreenElement"
|
||||
:class="containerClass"
|
||||
>
|
||||
|
||||
@ -36,6 +37,15 @@
|
||||
style="width: 12px;height: 12px"
|
||||
icon-class="link-down"
|
||||
/>{{ $t('panel.down') }}</span></el-button>
|
||||
<el-button
|
||||
id="fullscreenElement"
|
||||
size="mini"
|
||||
@click="toggleFullscreen"
|
||||
>
|
||||
<span><svg-icon
|
||||
style="width: 12px;height: 12px"
|
||||
:icon-class="fullscreenState?'public_fullscreen_exit':'public_fullscreen'"
|
||||
/>{{ fullscreenState?$t('panel.fullscreen_exit'): $t('panel.fullscreen_preview') }}</span></el-button>
|
||||
</el-button-group>
|
||||
</div>
|
||||
|
||||
@ -66,7 +76,8 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
fullscreenElement: null,
|
||||
fullscreenState: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -99,7 +110,37 @@ export default {
|
||||
'componentData'
|
||||
])
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.fullscreenElement = document.getElementById('fullscreenElement')
|
||||
document.addEventListener('fullscreenchange', this.handleFullscreenChange)
|
||||
},
|
||||
beforeDestroy() {
|
||||
// 在组件销毁前移除事件监听器
|
||||
document.removeEventListener('fullscreenchange', this.handleFullscreenChange)
|
||||
},
|
||||
methods: {
|
||||
handleFullscreenChange() {
|
||||
// 在全屏状态变化时触发此方法
|
||||
if (document.fullscreenElement) {
|
||||
this.fullscreenState = true
|
||||
} else {
|
||||
this.fullscreenState = false
|
||||
}
|
||||
},
|
||||
toggleFullscreen() {
|
||||
if (!document.fullscreenElement) {
|
||||
// 如果当前不是全屏状态,则启动全屏
|
||||
document.documentElement.requestFullscreen().catch(error => {
|
||||
console.error('Request fullscreen failed:', error)
|
||||
})
|
||||
} else {
|
||||
// 如果当前是全屏状态,则退出全屏
|
||||
document.exitFullscreen().catch(error => {
|
||||
console.error('Exit fullscreen failed:', error)
|
||||
})
|
||||
}
|
||||
},
|
||||
clearAllLinkage() {
|
||||
this.$store.commit('clearPanelLinkageInfo')
|
||||
bus.$emit('clear_panel_linkage', { viewId: 'all' })
|
||||
|
@ -24,6 +24,7 @@
|
||||
<el-select
|
||||
v-model="itemLinkage.sourceField"
|
||||
size="mini"
|
||||
filterable
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
@ -63,6 +64,7 @@
|
||||
<div class="select-filed">
|
||||
<el-select
|
||||
v-model="itemLinkage.targetField"
|
||||
filterable
|
||||
size="mini"
|
||||
placeholder="请选择"
|
||||
>
|
||||
|
@ -878,6 +878,7 @@ export default {
|
||||
this.element.filters = this.filters?.length ? JSON.parse(JSON.stringify(this.filters)) : []
|
||||
}
|
||||
method(id, this.panelInfo.id, requestInfo).then(response => {
|
||||
try {
|
||||
// 将视图传入echart组件
|
||||
if (response.success) {
|
||||
this.chart = response.data
|
||||
@ -919,11 +920,17 @@ export default {
|
||||
this.requestStatus = 'success'
|
||||
this.httpRequest.status = true
|
||||
} else {
|
||||
console.error('err2-' + JSON.stringify(response))
|
||||
console.error('err3-' + JSON.stringify(response))
|
||||
this.requestStatus = 'error'
|
||||
this.message = response.message
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('err2-' + JSON.stringify(response))
|
||||
this.requestStatus = 'error'
|
||||
this.message = e.message
|
||||
}
|
||||
this.isFirstLoad = false
|
||||
|
||||
return true
|
||||
}).catch(err => {
|
||||
console.error('err-' + err)
|
||||
|
@ -45,6 +45,7 @@
|
||||
</div> -->
|
||||
<div class="first-element">
|
||||
<div
|
||||
v-clickoutside="lostFocus"
|
||||
:class="element.component === 'de-select-grid' ? 'first-element-grid-container': ''"
|
||||
:style="deSelectGridBg"
|
||||
class="first-element-container"
|
||||
@ -77,10 +78,14 @@
|
||||
|
||||
<script>
|
||||
import inputStyleMixin from '@/components/widget/deWidget/inputStyleMixin'
|
||||
import clickoutside from 'element-ui/src/utils/clickoutside.js'
|
||||
import { mapState } from 'vuex'
|
||||
|
||||
export default {
|
||||
name: 'DeOutWidget',
|
||||
directives: {
|
||||
clickoutside
|
||||
},
|
||||
mixins: [inputStyleMixin],
|
||||
props: {
|
||||
canvasId: {
|
||||
@ -196,6 +201,9 @@ export default {
|
||||
this.$set(this.element.style, 'innerBgColor', innerBgColor || '')
|
||||
},
|
||||
methods: {
|
||||
lostFocus() {
|
||||
this.$refs['deOutWidget'].onScroll?.()
|
||||
},
|
||||
filterLoaded(p) {
|
||||
this.$emit('filter-loaded', p)
|
||||
},
|
||||
|
3
core/frontend/src/icons/svg/icon-filter_outlined.svg
Normal file
3
core/frontend/src/icons/svg/icon-filter_outlined.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg width="12" height="12" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 5.71552V10.75C8 10.8881 7.88807 11 7.75 11H7.25C7.11193 11 7 10.8881 7 10.75V5.5C7 5.42652 7.01585 5.35674 7.04432 5.2939C7.08231 5.19959 7.15031 5.11653 7.24423 5.06046L10 3.41546V2H2V3.4329L4.67252 5.03056C4.86366 5.10083 5 5.28449 5 5.5V9C5 9.13807 4.88807 9.25 4.75 9.25H4.25C4.11193 9.25 4 9.13807 4 9V5.73259L1.23691 4.08079C1.17489 4.04371 1.12421 3.99484 1.08604 3.93873C1.03333 3.8929 1 3.82534 1 3.75V1.5C1 1.22386 1.22386 1 1.5 1H10.5C10.6381 1 10.7631 1.05596 10.8536 1.14645C10.944 1.23693 11 1.36193 11 1.5V3.59655C11.0039 3.63166 11.0038 3.6669 11 3.70162V3.75C11 3.83421 10.9584 3.90869 10.8946 3.95399C10.86 3.99642 10.8176 4.03363 10.7679 4.06329L8 5.71552Z" />
|
||||
</svg>
|
After Width: | Height: | Size: 824 B |
1
core/frontend/src/icons/svg/public_fullscreen.svg
Normal file
1
core/frontend/src/icons/svg/public_fullscreen.svg
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1703040908390" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6856" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M358.4 768H426.666667v85.333333H213.333333v-213.333333h85.333334v68.266667l128-128 59.733333 59.733333-128 128z m345.6 0l-128-128 59.733333-59.733333 132.266667 132.266666V640h85.333333v213.333333h-213.333333v-85.333333h64zM358.4 298.666667l128 128-59.733333 59.733333-128-128V426.666667H213.333333V213.333333h213.333334v85.333334H358.4z m345.6 0H640V213.333333h213.333333v213.333334h-85.333333V354.133333l-132.266667 132.266667-59.733333-59.733333 128-128z" p-id="6857"></path></svg>
|
After Width: | Height: | Size: 818 B |
1
core/frontend/src/icons/svg/public_fullscreen_exit.svg
Normal file
1
core/frontend/src/icons/svg/public_fullscreen_exit.svg
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1703040914733" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6995" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M298.666667 631.466667H226.133333v-81.066667h217.6v204.8h-85.333333v-68.266667l-128 128L170.666667 759.466667l128-128z m422.4 0l128 128-59.733334 59.733333-128-128v68.266667h-85.333333V554.666667h217.6v81.066666h-72.533333zM298.666667 341.333333L187.733333 230.4 243.2 170.666667l115.2 115.2V217.6h85.333333v204.8H226.133333V341.333333H298.666667z m430.933333 0h64v81.066667h-217.6V217.6h85.333333v72.533333L780.8 170.666667l59.733333 59.733333L729.6 341.333333z" p-id="6996"></path></svg>
|
After Width: | Height: | Size: 824 B |
@ -2240,6 +2240,7 @@ export default {
|
||||
export_to_app: 'Export to App',
|
||||
preview: 'Preview',
|
||||
fullscreen_preview: 'Fullscreen Preview',
|
||||
fullscreen_exit: 'Fullscreen Exit',
|
||||
new_tab_preview: 'New Tab Preview',
|
||||
select_panel_from_left: 'Please select Dashboard from left',
|
||||
template_nale: 'Template name',
|
||||
|
@ -2231,6 +2231,7 @@ export default {
|
||||
export_to_app: '導出爲應用',
|
||||
preview: '預覽',
|
||||
fullscreen_preview: '全屏預覽',
|
||||
fullscreen_exit: '退出全屏',
|
||||
new_tab_preview: '新Tab頁預覽',
|
||||
select_panel_from_left: '請從左側選擇儀表闆',
|
||||
template_name: '模闆名稱',
|
||||
|
@ -1872,7 +1872,9 @@ export default {
|
||||
show_info: '驱动信息',
|
||||
file_name: '文件名',
|
||||
version: '版本',
|
||||
please_set_driverClass: '请指定驱动类'
|
||||
please_set_driverClass: '请指定驱动类',
|
||||
please_set_surpportVersions: '请输入支持的数据库大版本',
|
||||
surpportVersions: '支持版本'
|
||||
},
|
||||
datasource: {
|
||||
data_source_configuration: '数据源配置',
|
||||
@ -2232,6 +2234,7 @@ export default {
|
||||
export_to_app: '导出为应用',
|
||||
preview: '预览',
|
||||
fullscreen_preview: '全屏预览',
|
||||
fullscreen_exit: '退出全屏',
|
||||
new_tab_preview: '新Tab页预览',
|
||||
select_panel_from_left: '请从左侧选择仪表板',
|
||||
template_nale: '模板名称',
|
||||
|
@ -422,7 +422,7 @@ const data = {
|
||||
}
|
||||
state.componentData[index] = element
|
||||
}
|
||||
if (!element.type || element.type !== 'view') continue
|
||||
if (!element.type || (element.type !== 'view' && element.type !== 'custom')) continue
|
||||
const currentFilters = element.linkageFilters || [] // 当前联动filter
|
||||
// 联动的视图情况历史条件
|
||||
// const currentFilters = []
|
||||
@ -434,7 +434,7 @@ const data = {
|
||||
targetInfoList.forEach(targetInfo => {
|
||||
const targetInfoArray = targetInfo.split('#')
|
||||
const targetViewId = targetInfoArray[0] // 目标视图
|
||||
if (element.propValue.viewId === targetViewId) { // 如果目标视图 和 当前循环组件id相等 则进行条件增减
|
||||
if (element.type === 'view' && element.propValue.viewId === targetViewId) { // 如果目标视图 和 当前循环组件id相等 则进行条件增减
|
||||
const targetFieldId = targetInfoArray[1] // 目标视图列ID
|
||||
const condition = new Condition('', targetFieldId, 'eq', [dimension.value], [targetViewId])
|
||||
condition.sourceViewId = viewId
|
||||
@ -450,10 +450,23 @@ const data = {
|
||||
// !filterExist && vValid && currentFilters.push(condition)
|
||||
currentFilters.push(condition)
|
||||
}
|
||||
if (element.type === 'custom' && element.id === targetViewId) { // 过滤组件处理
|
||||
element.options.value = dimension.value
|
||||
// 去掉动态时间
|
||||
if (element.options.manualModify) {
|
||||
element.options.manualModify = false
|
||||
}
|
||||
// 去掉首选项
|
||||
if (element.options?.attrs?.selectFirst) {
|
||||
element.options.attrs.selectFirst = false
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
if (element.type === 'view') {
|
||||
element.linkageFilters = currentFilters
|
||||
}
|
||||
state.componentData[index] = element
|
||||
}
|
||||
},
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user