use of com.qcadoo.mes.cmmsMachineParts.reports.xls.timeUsage.dto.TimeUsageGroupDTO in project mes by qcadoo.
the class TimeUsageXlsService method group.
private List<TimeUsageGroupDTO> group(List<TimeUsageDTO> usages) {
List<TimeUsageGroupDTO> groups = Lists.newLinkedList();
Map<String, List<TimeUsageDTO>> workerMap = usages.stream().collect(Collectors.groupingBy(TimeUsageDTO::getWorker));
for (Entry<String, List<TimeUsageDTO>> entry : workerMap.entrySet()) {
Map<Date, List<TimeUsageDTO>> dateMap = entry.getValue().stream().collect(Collectors.groupingBy(TimeUsageDTO::getStartDate));
for (Date date : dateMap.keySet()) {
TimeUsageGroupDTO timeUsageGroup = new TimeUsageGroupDTO(date, entry.getKey(), dateMap.get(date));
groups.add(timeUsageGroup);
}
}
return groups.stream().sorted((g1, g2) -> {
if (g1.getWorker().equals(g2.getWorker())) {
return g1.getDate().compareTo(g2.getDate());
} else {
return g1.getWorker().compareTo(g2.getWorker());
}
}).collect(Collectors.toList());
}
use of com.qcadoo.mes.cmmsMachineParts.reports.xls.timeUsage.dto.TimeUsageGroupDTO in project mes by qcadoo.
the class TimeUsageXlsService method buildExcelContent.
public void buildExcelContent(final HSSFWorkbook workbook, final HSSFSheet sheet, Map<String, Object> filters, final Locale locale) {
reportStyleFactory = new ReportStyleFactory(workbook);
List<TimeUsageDTO> usages = timeUsageXLSDataProvider.getUsages((Map<String, Object>) filters.get("filtersMap"));
updatePartsAndDescription(usages, locale);
fillHeaderData(workbook, sheet, 0, locale, (Map<String, Object>) filters.get("filtersMap"));
fillHeaderRow(workbook, sheet, 4, locale);
List<TimeUsageGroupDTO> timeUsageGroups = group(usages);
int rowCounter = 5;
for (TimeUsageGroupDTO timeUsageGroupDTO : timeUsageGroups) {
rowCounter = fillTimeUsageRows(workbook, sheet, timeUsageGroupDTO, rowCounter++, locale);
}
setColumnsWidths(sheet);
}
Aggregations