Search in sources :

Example 1 with TimeUsageGroupDTO

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());
}
Also used : EventFieldsForTypeFactory(com.qcadoo.mes.cmmsMachineParts.plannedEvents.factory.EventFieldsForTypeFactory) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) org.apache.poi.hssf.usermodel(org.apache.poi.hssf.usermodel) Date(java.util.Date) QcadooSecurityConstants(com.qcadoo.security.constants.QcadooSecurityConstants) Autowired(org.springframework.beans.factory.annotation.Autowired) SimpleDateFormat(java.text.SimpleDateFormat) TranslationService(com.qcadoo.localization.api.TranslationService) DateUtils(com.qcadoo.localization.api.utils.DateUtils) Collectors(java.util.stream.Collectors) PlannedEventType(com.qcadoo.mes.cmmsMachineParts.constants.PlannedEventType) PlannedEventFields(com.qcadoo.mes.cmmsMachineParts.constants.PlannedEventFields) org.apache.poi.ss.usermodel(org.apache.poi.ss.usermodel) FieldsForType(com.qcadoo.mes.cmmsMachineParts.plannedEvents.fieldsForType.FieldsForType) Entity(com.qcadoo.model.api.Entity) List(java.util.List) Lists(com.google.common.collect.Lists) TimeUsageDTO(com.qcadoo.mes.cmmsMachineParts.reports.xls.timeUsage.dto.TimeUsageDTO) Service(org.springframework.stereotype.Service) Locale(java.util.Locale) Map(java.util.Map) Entry(java.util.Map.Entry) SecurityService(com.qcadoo.security.api.SecurityService) TimeUsageGroupDTO(com.qcadoo.mes.cmmsMachineParts.reports.xls.timeUsage.dto.TimeUsageGroupDTO) List(java.util.List) TimeUsageGroupDTO(com.qcadoo.mes.cmmsMachineParts.reports.xls.timeUsage.dto.TimeUsageGroupDTO) Date(java.util.Date)

Example 2 with TimeUsageGroupDTO

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);
}
Also used : TimeUsageDTO(com.qcadoo.mes.cmmsMachineParts.reports.xls.timeUsage.dto.TimeUsageDTO) TimeUsageGroupDTO(com.qcadoo.mes.cmmsMachineParts.reports.xls.timeUsage.dto.TimeUsageGroupDTO)

Aggregations

TimeUsageDTO (com.qcadoo.mes.cmmsMachineParts.reports.xls.timeUsage.dto.TimeUsageDTO)2 TimeUsageGroupDTO (com.qcadoo.mes.cmmsMachineParts.reports.xls.timeUsage.dto.TimeUsageGroupDTO)2 Lists (com.google.common.collect.Lists)1 TranslationService (com.qcadoo.localization.api.TranslationService)1 DateUtils (com.qcadoo.localization.api.utils.DateUtils)1 PlannedEventFields (com.qcadoo.mes.cmmsMachineParts.constants.PlannedEventFields)1 PlannedEventType (com.qcadoo.mes.cmmsMachineParts.constants.PlannedEventType)1 EventFieldsForTypeFactory (com.qcadoo.mes.cmmsMachineParts.plannedEvents.factory.EventFieldsForTypeFactory)1 FieldsForType (com.qcadoo.mes.cmmsMachineParts.plannedEvents.fieldsForType.FieldsForType)1 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)1 Entity (com.qcadoo.model.api.Entity)1 SecurityService (com.qcadoo.security.api.SecurityService)1 QcadooSecurityConstants (com.qcadoo.security.constants.QcadooSecurityConstants)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Collectors (java.util.stream.Collectors)1