fix: 识别es 数据类型

This commit is contained in:
taojinlong 2021-09-24 16:42:30 +08:00
parent fb9ccc05e1
commit c74e3863e0
3 changed files with 6 additions and 9 deletions

View File

@ -49,11 +49,12 @@ public class EsProvider extends DatasourceProvider {
List<String[]> list = new LinkedList<>();
try {
EsConfigDTO esConfigDTO = new Gson().fromJson(dsr.getDatasource().getConfiguration(), EsConfigDTO.class);
HttpClientConfig httpClientConfig = new HttpClientConfig();
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
if(StringUtils.isNotEmpty(esConfigDTO.getUsername())){
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
}
Requst requst = new Requst();
requst.setQuery(dsr.getQuery());
requst.setFetch_size(dsr.getFetchSize());

View File

@ -151,7 +151,7 @@ public class EsQueryProvider extends QueryProvider {
String cast = String.format(EsSqlLConstants.CAST, originField, "timestamp");
fieldName = String.format(EsSqlLConstants.DATETIME_FORMAT, cast, EsSqlLConstants.DEFAULT_DATE_FORMAT);
} else if (f.getDeType() == DeTypeConstants.DE_INT) {
fieldName = String.format(EsSqlLConstants.CAST, originField, "timestamp");
fieldName = String.format(EsSqlLConstants.CAST, originField, "bigint");
} else {
fieldName = originField;
}

View File

@ -504,12 +504,8 @@ public class DataSetTableService {
QueryProvider qp = ProviderFactory.getQueryProvider(ds.getType());
datasourceRequest.setQuery(qp.createQuerySQLWithPage(table, fields, page, pageSize, realSize, false, ds));
map.put("sql", datasourceRequest.getQuery());
System.out.println(datasourceRequest.getQuery());
try {
data.addAll(jdbcProvider.getData(datasourceRequest));
for(int i=0;i< data.size(); i++){
System.out.println(data.get(i)[2]);
}
} catch (Exception e) {
e.printStackTrace();
DEException.throwException(e.getMessage());