Search in sources :

Example 1 with OperationProductColumn

use of com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn in project mes by qcadoo.

the class OperationProductInTable method prepareOperationProductsValue.

private List<OperationProductHelper> prepareOperationProductsValue(Entity order, final List<Entity> operationProducts, final Set<Map.Entry<OperationProductColumn, ColumnAlignment>> alignments) {
    List<OperationProductHelper> operationProductsValue = Lists.newArrayList();
    for (Entity operationProduct : operationProducts) {
        OperationProductHelper operationProductHelper = new OperationProductHelper();
        List<OperationProductColumnHelper> operationProductColumnHelpers = Lists.newArrayList();
        for (Map.Entry<OperationProductColumn, ColumnAlignment> e : alignments) {
            String columnValue = e.getKey().getColumnValue(operationProduct);
            if (StringUtils.isEmpty(columnValue)) {
                columnValue = e.getKey().getColumnValueForOrder(order, operationProduct);
            }
            OperationProductColumnHelper operationProductColumnHelper = new OperationProductColumnHelper(e.getValue(), columnValue, e.getKey().getIdentifier());
            operationProductColumnHelpers.add(operationProductColumnHelper);
        }
        operationProductHelper.setOperationProductColumnHelpers(operationProductColumnHelpers);
        operationProductsValue.add(operationProductHelper);
    }
    return operationProductsValue;
}
Also used : Entity(com.qcadoo.model.api.Entity) ColumnAlignment(com.qcadoo.mes.columnExtension.constants.ColumnAlignment) OperationProductColumn(com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with OperationProductColumn

use of com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn in project mes by qcadoo.

the class OperationProductInTable method print.

public void print(final Entity workPlan, final GroupingContainer groupingContainer, final OrderOperationComponent orderOperationComponent, final Document document, final Locale locale) throws DocumentException {
    Entity order = orderOperationComponent.getOrder();
    Entity operationComponent = orderOperationComponent.getOperationComponent();
    Map<Long, Map<OperationProductColumn, ColumnAlignment>> map = groupingContainer.getOperationComponentIdProductInColumnToAlignment();
    Map<OperationProductColumn, ColumnAlignment> operationProductColumnAlignmentMap = map.get(operationComponent.getId());
    int columnCount = operationProductColumnAlignmentMap.size();
    Map<String, HeaderAlignment> headerAlignments = new HashMap<>(columnCount);
    List<String> headers = new ArrayList<>(columnCount);
    fill(locale, operationProductColumnAlignmentMap, headers, headerAlignments);
    PdfPTable table = pdfHelper.createTableWithHeader(columnCount, headers, false, headerAlignments);
    PdfPCell defaultCell = table.getDefaultCell();
    List<OperationProductHelper> operationProductsValue = prepareOperationProductsValue(order, orderOperationComponent.getProductionCountingQuantitiesIn(), operationProductColumnAlignmentMap.entrySet());
    operationProductsValue = workPlansService.sortByColumn(workPlan, operationProductsValue, headers);
    for (OperationProductHelper operationProduct : operationProductsValue) {
        for (OperationProductColumnHelper e : operationProduct.getOperationProductColumnHelpers()) {
            alignColumn(defaultCell, e.getColumnAlignment());
            table.addCell(operationProductPhrase(e.getValue()));
        }
    }
    int additionalRows = workPlansService.getAdditionalRowsFromParameter(ParameterFieldsWP.ADDITIONAL_INPUT_ROWS);
    for (int i = 0; i < additionalRows; i++) {
        for (Map.Entry<OperationProductColumn, ColumnAlignment> e : operationProductColumnAlignmentMap.entrySet()) {
            alignColumn(defaultCell, e.getValue());
            table.addCell(" ");
        }
    }
    table.setSpacingAfter(18);
    table.setSpacingBefore(9);
    document.add(table);
}
Also used : Entity(com.qcadoo.model.api.Entity) ColumnAlignment(com.qcadoo.mes.columnExtension.constants.ColumnAlignment) PdfPCell(com.lowagie.text.pdf.PdfPCell) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PdfPTable(com.lowagie.text.pdf.PdfPTable) HeaderAlignment(com.qcadoo.report.api.pdf.HeaderAlignment) OperationProductColumn(com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with OperationProductColumn

use of com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn in project mes by qcadoo.

the class WorkPlanColumnServiceImpl method getOperationProductColumns.

private Map<Long, Map<OperationProductColumn, ColumnAlignment>> getOperationProductColumns(final Entity workPlan, final ProductDirection productDirection) {
    Map<Long, Map<OperationProductColumn, ColumnAlignment>> operationComponentIdWithOperationProductColumnAndAlignment = Maps.newHashMap();
    Map<String, OperationProductColumn> identifierOperationProductColumn = applicationContext.getBeansOfType(OperationProductColumn.class);
    List<Entity> orders = getWorkPlanOrders(workPlan);
    for (Entity order : orders) {
        Entity technology = getOrderTechnology(order);
        List<Entity> operationComponents = getSortedTechnologyOperationComponents(technology);
        for (Entity operationComponent : operationComponents) {
            List<Entity> columns = getOperationProductColumns(productDirection);
            Map<OperationProductColumn, ColumnAlignment> operationProductColumnWithAlignment = Maps.newLinkedHashMap();
            for (Entity column : columns) {
                String identifier = getIdentifier(column);
                ColumnAlignment alignment = getColumnAlignment(column);
                OperationProductColumn key = identifierOperationProductColumn.get(identifier);
                if (Objects.nonNull(key)) {
                    operationProductColumnWithAlignment.put(key, alignment);
                }
            }
            operationComponentIdWithOperationProductColumnAndAlignment.put(operationComponent.getId(), operationProductColumnWithAlignment);
        }
    }
    return operationComponentIdWithOperationProductColumnAndAlignment;
}
Also used : Entity(com.qcadoo.model.api.Entity) ColumnAlignment(com.qcadoo.mes.columnExtension.constants.ColumnAlignment) OperationProductColumn(com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn) Map(java.util.Map)

Example 4 with OperationProductColumn

use of com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn in project mes by qcadoo.

the class OperationProductOutTable method print.

public void print(final Entity workPlan, final GroupingContainer groupingContainer, final OrderOperationComponent orderOperationComponent, final Document document, final Locale locale) throws DocumentException {
    Entity operationComponent = orderOperationComponent.getOperationComponent();
    Map<Long, Map<OperationProductColumn, ColumnAlignment>> map = groupingContainer.getOperationComponentIdProductOutColumnToAlignment();
    Map<OperationProductColumn, ColumnAlignment> operationProductColumnAlignmentMap = map.get(operationComponent.getId());
    int columnCount = operationProductColumnAlignmentMap.size();
    Map<String, HeaderAlignment> headerAlignments = new HashMap<String, HeaderAlignment>(columnCount);
    List<String> headers = new ArrayList<String>(columnCount);
    fill(locale, operationProductColumnAlignmentMap, headers, headerAlignments);
    PdfPTable table = pdfHelper.createTableWithHeader(columnCount, headers, false, headerAlignments);
    PdfPCell defaultCell = table.getDefaultCell();
    List<OperationProductHelper> operationProductsValue = prepareOperationProductsValue(orderOperationComponent.getProductionCountingQuantitiesOut(), operationProductColumnAlignmentMap.entrySet());
    operationProductsValue = workPlansService.sortByColumn(workPlan, operationProductsValue, headers);
    for (OperationProductHelper operationProduct : operationProductsValue) {
        for (OperationProductColumnHelper e : operationProduct.getOperationProductColumnHelpers()) {
            alignColumn(defaultCell, e.getColumnAlignment());
            table.addCell(operationProductPhrase(e.getValue()));
        }
    }
    int additionalRows = workPlansService.getAdditionalRowsFromParameter(ParameterFieldsWP.ADDITIONAL_OUTPUT_ROWS);
    for (int i = 0; i < additionalRows; i++) {
        for (Map.Entry<OperationProductColumn, ColumnAlignment> e : operationProductColumnAlignmentMap.entrySet()) {
            alignColumn(defaultCell, e.getValue());
            table.addCell(" ");
        }
    }
    table.setSpacingAfter(18);
    table.setSpacingBefore(9);
    document.add(table);
}
Also used : Entity(com.qcadoo.model.api.Entity) ColumnAlignment(com.qcadoo.mes.columnExtension.constants.ColumnAlignment) PdfPCell(com.lowagie.text.pdf.PdfPCell) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PdfPTable(com.lowagie.text.pdf.PdfPTable) HeaderAlignment(com.qcadoo.report.api.pdf.HeaderAlignment) OperationProductColumn(com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with OperationProductColumn

use of com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn in project mes by qcadoo.

the class OperationProductOutTable method prepareOperationProductsValue.

private List<OperationProductHelper> prepareOperationProductsValue(final List<Entity> operationProducts, final Set<Map.Entry<OperationProductColumn, ColumnAlignment>> alignments) {
    List<OperationProductHelper> operationProductsValue = Lists.newArrayList();
    for (Entity operationProduct : operationProducts) {
        OperationProductHelper operationProductHelper = new OperationProductHelper();
        List<OperationProductColumnHelper> operationProductColumnHelpers = Lists.newArrayList();
        for (Map.Entry<OperationProductColumn, ColumnAlignment> e : alignments) {
            OperationProductColumnHelper operationProductColumnHelper = new OperationProductColumnHelper(e.getValue(), e.getKey().getColumnValue(operationProduct), e.getKey().getIdentifier());
            operationProductColumnHelpers.add(operationProductColumnHelper);
        }
        operationProductHelper.setOperationProductColumnHelpers(operationProductColumnHelpers);
        operationProductsValue.add(operationProductHelper);
    }
    return operationProductsValue;
}
Also used : Entity(com.qcadoo.model.api.Entity) ColumnAlignment(com.qcadoo.mes.columnExtension.constants.ColumnAlignment) OperationProductColumn(com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ColumnAlignment (com.qcadoo.mes.columnExtension.constants.ColumnAlignment)5 OperationProductColumn (com.qcadoo.mes.workPlans.pdf.document.operation.product.column.OperationProductColumn)5 Entity (com.qcadoo.model.api.Entity)5 Map (java.util.Map)5 HashMap (java.util.HashMap)4 PdfPCell (com.lowagie.text.pdf.PdfPCell)2 PdfPTable (com.lowagie.text.pdf.PdfPTable)2 HeaderAlignment (com.qcadoo.report.api.pdf.HeaderAlignment)2 ArrayList (java.util.ArrayList)2