From c0c3ce00e5306a57c8a355e6f4ebf6ac0e9526fc Mon Sep 17 00:00:00 2001 From: Eduard Tihomiorv Date: Thu, 9 Oct 2025 11:34:18 +0300 Subject: [PATCH] fix download and xml --- .../org/micord/service/DownloadService.java | 25 +++++++++++---- config/cde-xml/downloadCSV.xml | 32 +++++++++++++++++-- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/config-data-executor/src/main/java/org/micord/service/DownloadService.java b/config-data-executor/src/main/java/org/micord/service/DownloadService.java index 43d96c0..7a750a6 100644 --- a/config-data-executor/src/main/java/org/micord/service/DownloadService.java +++ b/config-data-executor/src/main/java/org/micord/service/DownloadService.java @@ -126,24 +126,37 @@ public class DownloadService { validationResults, limit, offset ); if (query.get(REQUEST_WITH_ADDITIONAL_ID) != null) { + pageIndex--; SqlDownloadBuildQueryResponse response = (SqlDownloadBuildQueryResponse) query.get(REQUEST_WITH_ADDITIONAL_ID); String url = response.getSql(); String paramName = response.getParamName(); Collection> pages = partitionList(response.getParams(), limit); for (List page : pages) { + pageIndex++; String resultSet = "(" + page.stream() .map(s -> "'" + s.trim() + "'") .collect(Collectors.joining(", ")) + ")"; url = url.replace("${" + paramName + "}", resultSet ); - results = new ArrayList<>(executeSqlQuery(connection, url)); - if (results.size() <= 1) { - break; + url = url.replaceAll(";(?=[^;]*$)", " ") + " LIMIT " + limit + " OFFSET " + + offset + ";"; + 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 { diff --git a/config/cde-xml/downloadCSV.xml b/config/cde-xml/downloadCSV.xml index 86869c4..551c7a7 100644 --- a/config/cde-xml/downloadCSV.xml +++ b/config/cde-xml/downloadCSV.xml @@ -42,7 +42,10 @@ - Type_A + По конкретным id + Select system_id_ern from public.recruits where id in ${endpointArguments}; @@ -64,8 +67,8 @@ isEmptyDatesAllowed="true" isIdsFormatted="true" /> - Type_B - 10 + С выделенным подзапросом (100) + 100 Select system_id_ern from public.recruits where id in ${additionalArguments}; @@ -98,5 +101,28 @@ + + + Одним запросом (50) + 50 + + Select system_id_ern from public.recruits; + + + 10.10.31.118 + 5432 + ervu + ervu + org.postgresql.Driver + org.postgresql.xa.PGXADataSource + 50 + person_registry + 4000 + + \ No newline at end of file