From 08d0efb835550dfc185231a4f6a8486f46c95ab3 Mon Sep 17 00:00:00 2001 From: yamelsenih Date: Tue, 30 Jul 2024 01:02:41 -0400 Subject: [PATCH] - Fixed error with page and record count - Fixed error with value for String inside export to XLSX --- src/main/java/org/spin/report_engine/data/ReportInfo.java | 7 +++++-- .../java/org/spin/report_engine/export/XlsxExporter.java | 6 +++++- .../java/org/spin/report_engine/service/ReportBuilder.java | 4 +++- src/main/java/org/spin/report_engine/service/Service.java | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/spin/report_engine/data/ReportInfo.java b/src/main/java/org/spin/report_engine/data/ReportInfo.java index b615780..239432f 100644 --- a/src/main/java/org/spin/report_engine/data/ReportInfo.java +++ b/src/main/java/org/spin/report_engine/data/ReportInfo.java @@ -209,7 +209,6 @@ private Comparator getSortingValue(boolean summaryAtEnd) { } public ReportInfo completeInfo() { - recordCount = rows.size(); groupedRows = summaryHandler.getAsRows(); List completeRows = Stream.concat(getRows().stream(), groupedRows.stream()) .sorted(getSortingValue(false)) @@ -285,7 +284,6 @@ private void processAllChildren(Row parent) { return row.getLevel() > parent.getLevel() && compareRows(parent, row, groupLevels.size()); }).forEach(row -> { children.add(row); - System.err.println(row); }); } @@ -317,6 +315,11 @@ public int getReportViewId() { public long getRecordCount() { return recordCount; } + + public ReportInfo withRecordCount(int recordCount) { + this.recordCount = recordCount; + return this; + } public ReportInfo withReportViewId(int reportViewId) { this.reportViewId = reportViewId; diff --git a/src/main/java/org/spin/report_engine/export/XlsxExporter.java b/src/main/java/org/spin/report_engine/export/XlsxExporter.java index 0257bdf..0730a6f 100644 --- a/src/main/java/org/spin/report_engine/export/XlsxExporter.java +++ b/src/main/java/org/spin/report_engine/export/XlsxExporter.java @@ -200,7 +200,11 @@ public String export(ReportInfo reportInfo) { String value = Util.stripDiacritics(cell.getDisplayValue()); sheetCell.setCellValue(sheet.getWorkbook().getCreationHelper().createRichTextString(value)); } else { - String value = Util.stripDiacritics(cell.getDisplayValue()); + String value = cell.getDisplayValue(); + if(Util.isEmpty(value)) { + value = (String) obj; + } + value = Util.stripDiacritics(value); sheetCell.setCellValue(sheet.getWorkbook().getCreationHelper().createRichTextString(value)); } } diff --git a/src/main/java/org/spin/report_engine/service/ReportBuilder.java b/src/main/java/org/spin/report_engine/service/ReportBuilder.java index 970f22c..663b5c4 100644 --- a/src/main/java/org/spin/report_engine/service/ReportBuilder.java +++ b/src/main/java/org/spin/report_engine/service/ReportBuilder.java @@ -49,6 +49,7 @@ import org.spin.report_engine.mapper.DefaultMapping; import org.spin.report_engine.mapper.IColumnMapping; import org.spin.report_engine.util.ClassLoaderMapping; +import org.spin.service.grpc.util.db.CountUtil; import org.spin.service.grpc.util.db.ParameterUtil; import org.spin.service.grpc.util.query.Filter; @@ -172,7 +173,8 @@ private ReportInfo get(String transactionName) { MPrintFormat printFormat = new MPrintFormat(Env.getCtx(), getPrintFormatId(), null); PrintFormat format = PrintFormat.newInstance(printFormat); QueryDefinition queryDefinition = format.getQuery().withConditions(conditions).withInstanceId(getInstanceId()).withLimit(limit, offset).buildQuery(); - ReportInfo reportInfo = ReportInfo.newInstance(format, queryDefinition).withReportViewId(getReportViewId()).withInstanceId(getInstanceId()); + int count = CountUtil.countRecords(queryDefinition.getCompleteQuery(), format.getTableName(), queryDefinition.getParameters()); + ReportInfo reportInfo = ReportInfo.newInstance(format, queryDefinition).withReportViewId(getReportViewId()).withInstanceId(getInstanceId()).withRecordCount(count); DB.runResultSet(transactionName, queryDefinition.getCompleteQuery(), queryDefinition.getParameters(), resulset -> { while (resulset.next()) { format.getItems().forEach(item -> { diff --git a/src/main/java/org/spin/report_engine/service/Service.java b/src/main/java/org/spin/report_engine/service/Service.java index 0374692..55414fb 100644 --- a/src/main/java/org/spin/report_engine/service/Service.java +++ b/src/main/java/org/spin/report_engine/service/Service.java @@ -239,7 +239,7 @@ private static Report.Builder convertReport(ReportInfo reportInfo, int limit, in // Set page token String nexPageToken = null; if(LimitUtil.isValidNextPageToken((int) reportInfo.getRecordCount(), offset, limit)) { - nexPageToken = LimitUtil.getPagePrefix(SessionManager.getSessionUuid()) + (pageNumber + 1); + nexPageToken = LimitUtil.getPagePrefix("") + String.valueOf(pageNumber + 1); } builder.setNextPageToken( ValueManager.validateNull(nexPageToken)