BP-736 fix wrong aggregation of standby
diff --git a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/reports/ReportController.java b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/reports/ReportController.java
index c1332de..2cbeeff 100644
--- a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/reports/ReportController.java
+++ b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/controller/reports/ReportController.java
@@ -176,7 +176,7 @@
SpErrorEntry ee = SpExceptionEnum.NO_DATA_FOR_REPORT_FOUND.getEntry();
List<StandbyScheduleBody> result = performReportQuery(reportDto);
- LOGGER.info(result.size() + " records found for reporting");
+ LOGGER.debug(result.size() + " records found for reporting");
if (result.isEmpty()) {
// ee.setMessage("Es wurden keine Daten gefunden. Report ohne Inhalt.");
@@ -186,12 +186,12 @@
if (reportDto.getStandByList() != null) {
LOGGER.info("report for " + REPORT_ALL_GROUPS);
- inputDtos = compressResultOnGroups(reportDto, result);
+ inputDtos = compress2ResultOnGroups(reportDto, result);
} else {
StandbyScheduleBody lastBody = null;
// persönlicher Einsatzplan
LOGGER.info("report for " + REPORT_ONE_USER);
- inputDtos = compressResultLevel1(inputDtos, reportDto, result);
+ inputDtos = compress1ResultOnGroups(reportDto, result);
}
}
@@ -282,7 +282,7 @@
return reportInputDataSet;
}
- private List<ReportInputDto> compressResultOnGroups(ReportDto reportDto, List<StandbyScheduleBody> result) {
+ private List<ReportInputDto> compress2ResultOnGroups(ReportDto reportDto, List<StandbyScheduleBody> result) {
List<ReportInputDto> reportInputDataSet = new ArrayList<>();
@@ -318,6 +318,46 @@
}
+ private List<ReportInputDto> compress1ResultOnGroups(ReportDto reportDto, List<StandbyScheduleBody> result) {
+
+ List<ReportInputDto> reportInputDataSet = new ArrayList<>();
+
+ Map<Long, List<StandbyScheduleBody>> groupMap = new HashMap<>();
+
+ // sort by group
+ for (StandbyScheduleBody body : result) {
+
+ Long groupId = body.getStandbyGroup().getId();
+ if (groupMap.containsKey(groupId)) {
+
+ List<StandbyScheduleBody> groupList = groupMap.get(groupId);
+ groupList.add(body);
+ Collections.sort(groupList, (o1, o2) -> o1.getValidFrom().compareTo(o2.getValidFrom()));
+ } else {
+
+ // init all List
+ groupMap.put(groupId, new ArrayList<StandbyScheduleBody>());
+ List<StandbyScheduleBody> groupList = groupMap.get(groupId);
+ groupList.add(body);
+ }
+ }
+
+ Set<Long> keySet = groupMap.keySet();
+
+ for (Long groupId : keySet) {
+
+ List<StandbyScheduleBody> groupList = groupMap.get(groupId);
+ LOGGER.debug("compacting over groupId: " + groupId);
+
+ LOGGER.debug("from " + groupList.size() + " in " + reportInputDataSet.size());
+ compressResultLevel1(reportInputDataSet, reportDto, groupList);
+
+ }
+
+ return reportInputDataSet;
+
+ }
+
private void calcReportStartDate(StandbyScheduleBody body) {
body.setStartDateStr(DateHelper.convertToLocalString(body.getValidFrom(), "EE. dd.MM.yy HH:mm"));
}