Skip to content

Commit

Permalink
adapt ganglinie service
Browse files Browse the repository at this point in the history
  • Loading branch information
boal committed Nov 21, 2024
1 parent 55aeba2 commit de7570f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
Expand Down Expand Up @@ -94,7 +95,10 @@ protected static void setSeriesIndexForFirstChartPercent(final StepLineSeriesEnt
}

// Refactoring: Synergieeffekt mit ProcessZaehldatenSteplineService nutzen
public LadeZaehldatenSteplineDTO ladeGanglinie(final List<IntervalDto> intervals, final FahrzeugOptionsDTO fahrzeugOptions) {
public LadeZaehldatenSteplineDTO ladeGanglinie(
final List<IntervalDto> intervals,
final FahrzeugOptionsDTO fahrzeugOptions,
final TypeXAxisData typeXAxisData) {
log.debug("#ladeGanglinie");
final var ladeZaehldatenStepline = new LadeZaehldatenSteplineDTO();
ladeZaehldatenStepline.setRangeMax(0);
Expand Down Expand Up @@ -183,7 +187,7 @@ public LadeZaehldatenSteplineDTO ladeGanglinie(final List<IntervalDto> intervals
final var currentXAxisData = ladeZaehldatenStepline.getXAxisDataFirstChart();
final var newXAxisData = ZaehldatenProcessingUtil.checkAndAddToXAxisWhenNotAvailable(
currentXAxisData,
interval.getDatumUhrzeitVon().toLocalTime().toString());
getXAxisData(interval, typeXAxisData));
ladeZaehldatenStepline.setXAxisDataFirstChart(newXAxisData);
});

Expand Down Expand Up @@ -293,4 +297,25 @@ public List<StepLineSeriesEntryBaseDTO> getChosenStepLineSeriesEntries(final Fah

}

protected String getXAxisData(final IntervalDto interval, final TypeXAxisData typeXAxisData) {
StringBuilder xAxisData = new StringBuilder();
if (TypeXAxisData.ZEITPUNKT.equals(typeXAxisData)) {
xAxisData.append(interval.getDatumUhrzeitVon().toLocalTime().toString());
} else {
xAxisData
.append(interval.getDatumUhrzeitVon().toLocalDate().toString())
.append(StringUtils.SPACE)
.append("-")
.append(StringUtils.SPACE)
.append(interval.getDatumUhrzeitBis().toLocalDate().toString());
}
return xAxisData.toString();
}

public enum TypeXAxisData {
ZEITPUNKT,

ZEITRAUM;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public LadeProcessedMesswerteDTO ladeMesswerte(final String messstelleId, final
.toList();

final var processedZaehldaten = new LadeProcessedMesswerteDTO();
processedZaehldaten.setZaehldatenStepline(ganglinieService.ladeGanglinie(intervals, options.getFahrzeuge()));
processedZaehldaten.setZaehldatenStepline(ganglinieService.ladeGanglinie(intervals, options.getFahrzeuge(), GanglinieService.TypeXAxisData.ZEITPUNKT));
processedZaehldaten.setZaehldatenHeatmap(heatmapService.ladeHeatmap(intervals, options));
processedZaehldaten.setZaehldatenTable(listenausgabeService.ladeListenausgabe(intervals, isKfzMessstelle, options));
processedZaehldaten
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void ladeGanglinie() {
optionsFahrzeuge.setBusse(true);
optionsFahrzeuge.setKraftraeder(true);

final var result = ganglinieService.ladeGanglinie(intervals, optionsFahrzeuge);
final var result = ganglinieService.ladeGanglinie(intervals, optionsFahrzeuge, GanglinieService.TypeXAxisData.ZEITPUNKT);

final var expected = new LadeZaehldatenSteplineDTO();
expected.setLegend(List.of("Pkw", "Lkw", "Lz", "Lfw", "Busse", "Krad", "Rad", "Kfz", "SV", "SV %", "GV", "GV %"));
Expand Down

0 comments on commit de7570f

Please sign in to comment.