fix download and xml
This commit is contained in:
parent
5e3d0531d2
commit
c0c3ce00e5
2 changed files with 48 additions and 9 deletions
|
|
@ -126,24 +126,37 @@ public class DownloadService {
|
||||||
validationResults, limit, offset
|
validationResults, limit, offset
|
||||||
);
|
);
|
||||||
if (query.get(REQUEST_WITH_ADDITIONAL_ID) != null) {
|
if (query.get(REQUEST_WITH_ADDITIONAL_ID) != null) {
|
||||||
|
pageIndex--;
|
||||||
SqlDownloadBuildQueryResponse response = (SqlDownloadBuildQueryResponse) query.get(REQUEST_WITH_ADDITIONAL_ID);
|
SqlDownloadBuildQueryResponse response = (SqlDownloadBuildQueryResponse) query.get(REQUEST_WITH_ADDITIONAL_ID);
|
||||||
String url = response.getSql();
|
String url = response.getSql();
|
||||||
String paramName = response.getParamName();
|
String paramName = response.getParamName();
|
||||||
Collection<List<String>> pages = partitionList(response.getParams(), limit);
|
Collection<List<String>> pages = partitionList(response.getParams(), limit);
|
||||||
for (List<String> page : pages) {
|
for (List<String> page : pages) {
|
||||||
|
pageIndex++;
|
||||||
String resultSet = "(" + page.stream()
|
String resultSet = "(" + page.stream()
|
||||||
.map(s -> "'" + s.trim() + "'")
|
.map(s -> "'" + s.trim() + "'")
|
||||||
.collect(Collectors.joining(", ")) + ")";
|
.collect(Collectors.joining(", ")) + ")";
|
||||||
url = url.replace("${" + paramName + "}",
|
url = url.replace("${" + paramName + "}",
|
||||||
resultSet
|
resultSet
|
||||||
);
|
);
|
||||||
results = new ArrayList<>(executeSqlQuery(connection, url));
|
url = url.replaceAll(";(?=[^;]*$)", " ") + " LIMIT " + limit + " OFFSET "
|
||||||
if (results.size() <= 1) {
|
+ offset + ";";
|
||||||
break;
|
while (true) {
|
||||||
|
results = new ArrayList<>(executeSqlQuery(connection, url));
|
||||||
|
if (results.size() <= 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
File file = writeSingleSqlCsvFile(results, "download-part" + pageIndex + "-", ".csv");
|
||||||
|
allFiles.add(file);
|
||||||
|
if (results.size() - 1 < limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String oldPagination = " OFFSET " + offset + ";";
|
||||||
|
offset += limit;
|
||||||
|
String newPagination = " OFFSET " + offset + ";";
|
||||||
|
url = url.replace(oldPagination, newPagination);
|
||||||
|
pageIndex++;
|
||||||
}
|
}
|
||||||
File file = writeSingleSqlCsvFile(results, "download-part" + pageIndex + "-", ".csv");
|
|
||||||
allFiles.add(file);
|
|
||||||
pageIndex++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,10 @@
|
||||||
</AqlConnectionParams>
|
</AqlConnectionParams>
|
||||||
</AQLDownloadRequest>
|
</AQLDownloadRequest>
|
||||||
<SQLDownloadRequest>
|
<SQLDownloadRequest>
|
||||||
<DownloadRequestType>Type_A</DownloadRequestType>
|
<DownloadRequestType>По конкретным id</DownloadRequestType>
|
||||||
|
<RequestValidationRules
|
||||||
|
isEmptyDatesAllowed="true"
|
||||||
|
/>
|
||||||
<RequestURL>
|
<RequestURL>
|
||||||
Select system_id_ern from public.recruits where id in ${endpointArguments};
|
Select system_id_ern from public.recruits where id in ${endpointArguments};
|
||||||
</RequestURL>
|
</RequestURL>
|
||||||
|
|
@ -64,8 +67,8 @@
|
||||||
isEmptyDatesAllowed="true"
|
isEmptyDatesAllowed="true"
|
||||||
isIdsFormatted="true"
|
isIdsFormatted="true"
|
||||||
/>
|
/>
|
||||||
<DownloadRequestType>Type_B</DownloadRequestType>
|
<DownloadRequestType>С выделенным подзапросом (100)</DownloadRequestType>
|
||||||
<RequestArgumentLimit>10</RequestArgumentLimit>
|
<RequestArgumentLimit>100</RequestArgumentLimit>
|
||||||
<RequestURL>
|
<RequestURL>
|
||||||
Select system_id_ern from public.recruits where id in ${additionalArguments};
|
Select system_id_ern from public.recruits where id in ${additionalArguments};
|
||||||
</RequestURL>
|
</RequestURL>
|
||||||
|
|
@ -98,5 +101,28 @@
|
||||||
</RequestArgumentConnectionParams>
|
</RequestArgumentConnectionParams>
|
||||||
</RequestArgument>
|
</RequestArgument>
|
||||||
</SQLDownloadRequest>
|
</SQLDownloadRequest>
|
||||||
|
<SQLDownloadRequest>
|
||||||
|
<RequestValidationRules
|
||||||
|
isEmptyIdsAllowed="true"
|
||||||
|
isEmptyDatesAllowed="true"
|
||||||
|
isIdsFormatted="true"
|
||||||
|
/>
|
||||||
|
<DownloadRequestType>Одним запросом (50)</DownloadRequestType>
|
||||||
|
<RequestArgumentLimit>50</RequestArgumentLimit>
|
||||||
|
<RequestURL>
|
||||||
|
Select system_id_ern from public.recruits;
|
||||||
|
</RequestURL>
|
||||||
|
<SqlConnectionParams>
|
||||||
|
<JdbcHost>10.10.31.118</JdbcHost>
|
||||||
|
<JdbcPort>5432</JdbcPort>
|
||||||
|
<JdbcUsername>ervu</JdbcUsername>
|
||||||
|
<JdbcPassword>ervu</JdbcPassword>
|
||||||
|
<JdbcDriverClassName>org.postgresql.Driver</JdbcDriverClassName>
|
||||||
|
<JdbcXaDataSourceClassName>org.postgresql.xa.PGXADataSource</JdbcXaDataSourceClassName>
|
||||||
|
<JdbcXaDataSourcePoolSize>50</JdbcXaDataSourcePoolSize>
|
||||||
|
<JdbcDatabase>person_registry</JdbcDatabase>
|
||||||
|
<JdbcXaDataSourceBorrowConnectionTimeout>4000</JdbcXaDataSourceBorrowConnectionTimeout>
|
||||||
|
</SqlConnectionParams>
|
||||||
|
</SQLDownloadRequest>
|
||||||
|
|
||||||
</Requests>
|
</Requests>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue