diff --git a/src/main/java/org/spin/report_engine/data/SummaryHandler.java b/src/main/java/org/spin/report_engine/data/SummaryHandler.java index 8b5cb6c..c46df95 100644 --- a/src/main/java/org/spin/report_engine/data/SummaryHandler.java +++ b/src/main/java/org/spin/report_engine/data/SummaryHandler.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; import org.spin.report_engine.format.PrintFormatItem; @@ -37,9 +38,9 @@ public class SummaryHandler { private SummaryHandler(List printFormatItems) { groupedItems = printFormatItems.stream().filter(item -> item.isGroupBy()).sorted(Comparator.comparing(PrintFormatItem::getSortSequence)).collect(Collectors.toList()); summarizedItems = printFormatItems.stream().filter(printItem -> { - if(printItem.isHideGrandTotal()) { - return false; - } +// if(printItem.isHideGrandTotal()) { +// return false; +// } return printItem.isAveraged() || printItem.isCounted() || printItem.isMaxCalc() || printItem.isMinCalc() || printItem.isSummarized() || printItem.isVarianceCalc(); }).collect(Collectors.toList()); summary = new HashMap>>(); @@ -110,16 +111,24 @@ public Map>> getSummary() { public List getAsRows() { List rows = new ArrayList(); + AtomicBoolean isFirst = new AtomicBoolean(true); groupedItems.forEach(groupItem -> { Map> groupTotals = Optional.ofNullable(summary.get(groupItem.getPrintFormatItemId())).orElse(new HashMap>()); groupTotals.keySet().forEach(groupValueRow -> { Map summaryValue = groupTotals.get(groupValueRow); - summarizedItems.forEach(sumItem -> { + summarizedItems.stream().filter(printItem -> { + if(printItem.isHideGrandTotal() && isFirst.get()) { + return false; + } + return true; + }) + .forEach(sumItem -> { SummaryFunction function = summaryValue.get(sumItem.getPrintFormatItemId()); groupValueRow.withCell(sumItem.getPrintFormatItemId(), Cell.newInstance().withValue(function.getValue(SummaryFunction.F_SUM)).withFunction(function)); }); rows.add(groupValueRow.withSummaryRow(true)); }); + isFirst.set(false); }); return rows; }