2021-05-17 16:43:02 +08:00
|
|
|
package io.dataease.provider;
|
|
|
|
|
2021-08-10 19:11:14 +08:00
|
|
|
import com.google.gson.Gson;
|
2021-05-17 16:43:02 +08:00
|
|
|
import io.dataease.base.domain.DatasetTableField;
|
2021-08-09 12:45:01 +08:00
|
|
|
import io.dataease.base.domain.Datasource;
|
2021-05-17 16:43:02 +08:00
|
|
|
import io.dataease.controller.request.chart.ChartExtFilterRequest;
|
2021-08-10 19:11:14 +08:00
|
|
|
import io.dataease.datasource.dto.JdbcDTO;
|
2021-05-21 16:45:21 +08:00
|
|
|
import io.dataease.dto.chart.ChartCustomFilterDTO;
|
2021-05-17 16:43:02 +08:00
|
|
|
import io.dataease.dto.chart.ChartViewFieldDTO;
|
2021-08-10 19:11:14 +08:00
|
|
|
import io.dataease.dto.sqlObj.SQLObj;
|
|
|
|
import io.dataease.provider.pg.PgConstants;
|
2021-05-17 16:43:02 +08:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author gin
|
|
|
|
* @Date 2021/5/17 2:42 下午
|
|
|
|
*/
|
|
|
|
public abstract class QueryProvider {
|
2021-08-09 12:45:01 +08:00
|
|
|
|
2021-05-18 11:24:52 +08:00
|
|
|
public abstract Integer transFieldType(String field);
|
2021-05-17 16:43:02 +08:00
|
|
|
|
|
|
|
public abstract String createSQLPreview(String sql, String orderBy);
|
|
|
|
|
2021-08-09 12:45:01 +08:00
|
|
|
public abstract String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds);
|
2021-05-17 16:43:02 +08:00
|
|
|
|
2021-07-28 18:57:52 +08:00
|
|
|
public abstract String createQuerySQLAsTmp(String sql, List<DatasetTableField> fields, boolean isGroup);
|
2021-05-17 16:43:02 +08:00
|
|
|
|
2021-09-28 16:42:03 +08:00
|
|
|
public abstract String createQueryTableWithPage(String table, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup, Datasource ds);
|
|
|
|
|
|
|
|
public abstract String createQuerySQLWithPage(String sql, List<DatasetTableField> fields, Integer page, Integer pageSize, Integer realSize, boolean isGroup);
|
2021-05-17 16:43:02 +08:00
|
|
|
|
2021-08-09 12:45:01 +08:00
|
|
|
public abstract String createQueryTableWithLimit(String table, List<DatasetTableField> fields, Integer limit, boolean isGroup, Datasource ds);
|
2021-06-30 18:56:12 +08:00
|
|
|
|
2021-07-28 18:57:52 +08:00
|
|
|
public abstract String createQuerySqlWithLimit(String sql, List<DatasetTableField> fields, Integer limit, boolean isGroup);
|
2021-06-30 18:56:12 +08:00
|
|
|
|
2021-08-10 19:11:14 +08:00
|
|
|
public abstract String getSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds);
|
2021-05-17 16:43:02 +08:00
|
|
|
|
2021-05-21 16:45:21 +08:00
|
|
|
public abstract String getSQLAsTmp(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList);
|
2021-05-18 11:24:52 +08:00
|
|
|
|
2021-09-06 14:06:10 +08:00
|
|
|
public abstract String getSQLTableInfo(String table, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds);
|
|
|
|
|
|
|
|
public abstract String getSQLAsTmpTableInfo(String sql, List<ChartViewFieldDTO> xAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, Datasource ds);
|
|
|
|
|
2021-08-10 19:11:14 +08:00
|
|
|
public abstract String getSQLStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack, Datasource ds);
|
2021-07-21 17:36:50 +08:00
|
|
|
|
|
|
|
public abstract String getSQLAsTmpStack(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extStack);
|
|
|
|
|
2021-08-10 19:11:14 +08:00
|
|
|
public abstract String getSQLScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble, Datasource ds);
|
2021-08-06 16:15:59 +08:00
|
|
|
|
|
|
|
public abstract String getSQLAsTmpScatter(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList, List<ChartViewFieldDTO> extBubble);
|
|
|
|
|
2021-05-18 11:24:52 +08:00
|
|
|
public abstract String searchTable(String table);
|
2021-06-11 12:24:19 +08:00
|
|
|
|
|
|
|
public abstract String getSQLSummary(String table, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList);
|
|
|
|
|
2021-09-22 18:46:29 +08:00
|
|
|
public Integer transFieldSize(String type){
|
|
|
|
return 50;
|
|
|
|
};
|
2021-07-21 17:36:50 +08:00
|
|
|
/**
|
|
|
|
* 单指标汇总
|
|
|
|
*
|
|
|
|
* @param sql
|
|
|
|
* @param yAxis
|
|
|
|
* @param customFilter
|
|
|
|
* @param extFilterRequestList
|
|
|
|
* @return
|
|
|
|
*/
|
2021-06-11 12:24:19 +08:00
|
|
|
public abstract String getSQLSummaryAsTmp(String sql, List<ChartViewFieldDTO> yAxis, List<ChartCustomFilterDTO> customFilter, List<ChartExtFilterRequest> extFilterRequestList);
|
2021-07-01 15:52:45 +08:00
|
|
|
|
|
|
|
public abstract String wrapSql(String sql);
|
2021-07-01 18:20:02 +08:00
|
|
|
|
2021-08-10 19:11:14 +08:00
|
|
|
public abstract String createRawQuerySQL(String table, List<DatasetTableField> fields, Datasource ds);
|
2021-07-01 18:20:02 +08:00
|
|
|
|
|
|
|
public abstract String createRawQuerySQLAsTmp(String sql, List<DatasetTableField> fields);
|
2021-08-10 19:11:14 +08:00
|
|
|
|
|
|
|
public void setSchema(SQLObj tableObj, Datasource ds){
|
2021-09-28 16:42:03 +08:00
|
|
|
if(ds != null && !tableObj.getTableName().startsWith("(") && !tableObj.getTableName().endsWith(")")){
|
2021-08-10 19:11:14 +08:00
|
|
|
String schema = new Gson().fromJson(ds.getConfiguration(), JdbcDTO.class).getSchema();
|
|
|
|
schema = String.format( PgConstants.KEYWORD_TABLE, schema);
|
|
|
|
tableObj.setTableName(schema + "." + tableObj.getTableName());
|
|
|
|
}
|
|
|
|
}
|
2021-05-17 16:43:02 +08:00
|
|
|
}
|