use of com.qcadoo.mes.materialFlowResources.print.helper.Position in project mes by qcadoo.
the class DispositionOrderPdfService method addPositionsTable.
private void addPositionsTable(Document document, Entity documentEntity, Locale locale) throws DocumentException {
List<Integer> headerWidthsList = new ArrayList<>(Arrays.asList(25, 50, 50, 50, 65, 90, 40, 35));
int numOfColumns = 8;
if (acceptanceOfDocumentBeforePrinting) {
headerWidthsList.add(45);
numOfColumns++;
}
int[] headerWidths = headerWidthsList.stream().mapToInt(i -> i).toArray();
Map<String, HeaderAlignment> headerValues = getPositionsTableHeaderLabels(locale);
PdfPTable positionsTable = pdfHelper.createTableWithHeader(numOfColumns, Lists.newArrayList(headerValues.keySet()), false, headerWidths, headerValues);
positionsTable.getDefaultCell().disableBorderSide(PdfPCell.RIGHT);
positionsTable.getDefaultCell().disableBorderSide(PdfPCell.LEFT);
positionsTable.setHeaderRows(1);
List<Entity> positions = PositionDataProvider.getPositions(documentEntity);
PositionsHolder positionsHolder = new PositionsHolder(numberService);
fillPositions(positionsHolder, positions);
List<Position> _positions = positionsHolder.getPositions();
if (acceptanceOfDocumentBeforePrinting) {
Collections.sort(_positions, new Comparator<Position>() {
@Override
public int compare(Position p1, Position p2) {
return ComparisonChain.start().compare(p1.getTargetPallet(), p2.getTargetPallet()).compare(p1.getStorageLocation(), p2.getStorageLocation()).result();
}
});
} else {
Collections.sort(_positions, new Comparator<Position>() {
@Override
public int compare(Position p1, Position p2) {
return ComparisonChain.start().compare(p1.getStorageLocation(), p2.getStorageLocation()).result();
}
});
}
Integer index = 1;
for (Position position : _positions) {
positionsTable.addCell(createCell(index.toString(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getStorageLocation(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getPalletNumber(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getTypeOfPallet(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getAdditionalCodeAndBatch(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getProductName(), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(PositionDataProvider.quantity(position.getQuantity()), Element.ALIGN_LEFT));
positionsTable.addCell(createCell(position.getUnit(), Element.ALIGN_LEFT));
if (acceptanceOfDocumentBeforePrinting) {
positionsTable.addCell(createCell(position.getTargetPallet(), Element.ALIGN_LEFT));
}
index++;
}
positionsTable.setSpacingAfter(20);
document.add(positionsTable);
}
Aggregations