Search in sources :

Example 1 with ReportColumn

use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.

the class PPSReportXlsService method addSeriesOfProductionLine.

private void addSeriesOfProductionLine(final HSSFSheet sheet, final Entity report, final PPSReportXlsStyleContainer styleContainer, final List<ReportColumn> columns) {
    List<Entity> productionPerShifts = ppsReportXlsHelper.getProductionPerShiftForReport(report);
    List<Entity> shifts = shiftsService.getShifts();
    DateTime dateFrom = new DateTime(report.getDateField(PPSReportFields.DATE_FROM));
    Shift shiftFirst = new Shift(shifts.get(0), dateFrom, false);
    List<TimeRange> ranges = shiftFirst.findWorkTimeAt(new LocalDate(report.getDateField(PPSReportFields.DATE_FROM)));
    if (ranges.isEmpty()) {
        return;
    }
    LocalTime startTime = ranges.get(0).getFrom();
    if (productionPerShifts.isEmpty()) {
        return;
    }
    productionPerShifts.sort(new EntityProductionPerShiftsComparator());
    String oldProductionLineNumber = "";
    String newProductionLineNumber;
    int rowNum = 6;
    boolean isFirstRow;
    boolean greyBg = false;
    for (Entity productionPerShift : productionPerShifts) {
        Entity order = ppsReportXlsHelper.getOrder(productionPerShift);
        Entity changeover = ppsReportXlsHelper.getChangeover(order);
        Entity productionLine = ppsReportXlsHelper.getProductionLine(productionPerShift);
        newProductionLineNumber = productionLine.getStringField(ProductionLineFields.NUMBER);
        isFirstRow = !oldProductionLineNumber.equals(newProductionLineNumber);
        if (isFirstRow) {
            greyBg = !greyBg;
        }
        if (changeover != null && isChangeOverOnThisPrint(order, report, startTime)) {
            HSSFRow row = sheet.createRow(rowNum++);
            int colIndex = 0;
            for (ReportColumn column : columns) {
                HSSFCell cell = row.createCell(colIndex);
                if (isFirstRow) {
                    cell.setCellValue(column.getFirstRowChangeoverValue(productionPerShift));
                } else {
                    cell.setCellValue(column.getChangeoverValue(productionPerShift));
                }
                colIndex++;
            }
            isFirstRow = false;
            addSeriesForChangeOver(sheet, report, row, changeover, order, styleContainer, columns);
        }
        HSSFRow row = sheet.createRow(rowNum++);
        int colIndex = 0;
        for (ReportColumn column : columns) {
            HSSFCell cell = row.createCell(colIndex);
            if (isFirstRow) {
                Object firstRowValue = column.getFirstRowValue(productionPerShift);
                if (firstRowValue instanceof Double) {
                    cell.setCellValue((Double) firstRowValue);
                    cell.setCellType(CellType.NUMERIC);
                } else {
                    cell.setCellValue((String) firstRowValue);
                }
            } else {
                Object value = column.getValue(productionPerShift);
                if (value instanceof Double) {
                    cell.setCellValue((Double) value);
                    cell.setCellType(CellType.NUMERIC);
                } else {
                    cell.setCellValue((String) value);
                }
            }
            if (greyBg) {
                if (columns.size() == colIndex - 1) {
                    column.setGreyDataStyleEnd(cell, styleContainer);
                } else {
                    column.setGreyDataStyle(cell, styleContainer);
                }
            } else {
                if (columns.size() == colIndex - 1) {
                    column.setWhiteDataStyleEnd(cell, styleContainer);
                } else {
                    column.setWhiteDataStyle(cell, styleContainer);
                }
            }
            colIndex++;
        }
        addSeriesOfDailyProgress(sheet, report, row, productionPerShift, greyBg, styleContainer, columns);
        oldProductionLineNumber = newProductionLineNumber;
    }
    setColumnWidths(sheet, columns);
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) Entity(com.qcadoo.model.api.Entity) ReportColumn(com.qcadoo.mes.productionPerShift.report.columns.ReportColumn) EntityProductionPerShiftsComparator(com.qcadoo.mes.productionPerShift.report.print.utils.EntityProductionPerShiftsComparator) LocalTime(org.joda.time.LocalTime) HSSFRow(org.apache.poi.hssf.usermodel.HSSFRow) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) TimeRange(com.qcadoo.commons.dateTime.TimeRange) HSSFCell(org.apache.poi.hssf.usermodel.HSSFCell)

Example 2 with ReportColumn

use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.

the class StandardPPSReportColumnService method getReportColumns.

@Override
public List<ReportColumn> getReportColumns() {
    List<ReportColumn> columns = Lists.newLinkedList();
    List<String> sortedColumnNames = getSortedColumnIdentifiers();
    Map<String, ReportColumn> reportColumns = applicationContext.getBeansOfType(ReportColumn.class);
    for (String name : sortedColumnNames) {
        ReportColumn column = reportColumns.get(name);
        if (column != null) {
            columns.add(column);
        }
    }
    return columns;
}
Also used : ReportColumn(com.qcadoo.mes.productionPerShift.report.columns.ReportColumn)

Example 3 with ReportColumn

use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.

the class PPSReportXlsService method createHeaderLineForProduction.

private void createHeaderLineForProduction(final HSSFSheet sheet, final Locale locale, final HSSFRow headerMainLine, final HSSFRow headerProduction, final PPSReportXlsStyleContainer styleContainer, final List<ReportColumn> columns) {
    CreationHelper helper = sheet.getWorkbook().getCreationHelper();
    helper.createDataFormat();
    appendHeaderMainLine(sheet, locale, headerMainLine, styleContainer);
    int columnNumber = 0;
    for (ReportColumn column : columns) {
        HSSFCell cell = headerProduction.createCell(columnNumber);
        cell.setCellValue(column.getHeader(locale));
        column.setHeaderStyle(cell, styleContainer);
        columnNumber++;
    }
    headerProduction.setHeightInPoints(20);
    mergeHeaderCells(sheet, columns.size());
}
Also used : ReportColumn(com.qcadoo.mes.productionPerShift.report.columns.ReportColumn) HSSFCell(org.apache.poi.hssf.usermodel.HSSFCell) CreationHelper(org.apache.poi.ss.usermodel.CreationHelper)

Example 4 with ReportColumn

use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.

the class PPSReportXlsService method setColumnWidths.

private void setColumnWidths(final HSSFSheet sheet, final List<ReportColumn> columns) {
    int index = 0;
    for (ReportColumn column : columns) {
        sheet.setColumnWidth(index, column.getColumnWidth());
        index++;
    }
    for (int columnNumber = columns.size(); columnNumber < columns.size() + 21; columnNumber++) {
        sheet.setColumnWidth(columnNumber, 6 * 256);
    }
}
Also used : ReportColumn(com.qcadoo.mes.productionPerShift.report.columns.ReportColumn)

Example 5 with ReportColumn

use of com.qcadoo.mes.productionPerShift.report.columns.ReportColumn in project mes by qcadoo.

the class PPSReportXlsService method addHeader.

@Override
protected void addHeader(final HSSFSheet sheet, final Locale locale, final Entity report) {
    PPSReportXlsStyleContainer styleContainer = new PPSReportXlsStyleContainer(sheet);
    createHeaderForAuthor(sheet, locale, styleContainer);
    HSSFRow headerMainLine = sheet.createRow(3);
    HSSFRow headerProduction = sheet.createRow(4);
    List<ReportColumn> columns = ppsReportColumnHelper.getReportColumns();
    createHeaderLineForProduction(sheet, locale, headerMainLine, headerProduction, styleContainer, columns);
    createHeaderLineForDaysWithShifts(sheet, locale, headerMainLine, headerProduction, report, styleContainer, columns);
}
Also used : ReportColumn(com.qcadoo.mes.productionPerShift.report.columns.ReportColumn) HSSFRow(org.apache.poi.hssf.usermodel.HSSFRow)

Aggregations

ReportColumn (com.qcadoo.mes.productionPerShift.report.columns.ReportColumn)5 HSSFCell (org.apache.poi.hssf.usermodel.HSSFCell)2 HSSFRow (org.apache.poi.hssf.usermodel.HSSFRow)2 TimeRange (com.qcadoo.commons.dateTime.TimeRange)1 Shift (com.qcadoo.mes.basic.shift.Shift)1 EntityProductionPerShiftsComparator (com.qcadoo.mes.productionPerShift.report.print.utils.EntityProductionPerShiftsComparator)1 Entity (com.qcadoo.model.api.Entity)1 CreationHelper (org.apache.poi.ss.usermodel.CreationHelper)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 LocalTime (org.joda.time.LocalTime)1