use of py.org.fundacionparaguaya.pspserver.reports.dtos.FamilySnapshotDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotReportManagerImpl method listSnapshotByFamily.
@Override
public List<FamilySnapshotDTO> listSnapshotByFamily(SnapshotFilterDTO filters) {
List<FamilySnapshotDTO> toRet = new ArrayList<>();
Sort sort = new Sort(new Sort.Order(Direction.ASC, "createdAt"));
if (filters.getDateFrom() != null && filters.getDateTo() != null && filters.getFamilyId() != null) {
List<SnapshotEconomicEntity> snapshots = snapshotRepository.findAll(where(forFamily(filters.getFamilyId())).and(SnapshotEconomicSpecification.createdAtBetween2Dates(filters.getDateFrom(), filters.getDateTo())), sort);
Map<SurveyEntity, List<SnapshotEconomicEntity>> groupBySurvey = snapshots.stream().collect(Collectors.groupingBy(s -> s.getSurveyDefinition()));
groupBySurvey.forEach((k, v) -> {
FamilySnapshotDTO familySnapshots = new FamilySnapshotDTO(filters.getFamilyId(), k.getTitle());
familySnapshots.setSnapshots(getSnasphots(v));
toRet.add(familySnapshots);
});
}
return toRet;
}
use of py.org.fundacionparaguaya.pspserver.reports.dtos.FamilySnapshotDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class SnapshotReportController method getSnapshotsIndicatorsByFamily.
@GetMapping(path = "/family/indicators", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<List<FamilySnapshotDTO>> getSnapshotsIndicatorsByFamily(@RequestParam(value = "application_id", required = false) Long applicationId, @RequestParam(value = "organization_id", required = false) Long organizationId, @RequestParam(value = "family_id", required = true) Long familyId, @RequestParam(value = "date_from", required = true) String dateFrom, @RequestParam(value = "date_to", required = true) String dateTo) {
SnapshotFilterDTO filters = new SnapshotFilterDTO(applicationId, organizationId, familyId, dateFrom, dateTo);
List<FamilySnapshotDTO> snapshots = familyReportService.listSnapshotByFamily(filters);
return ResponseEntity.ok(snapshots);
}
Aggregations