use of com.qcadoo.mes.technologies.constants.MrpAlgorithm in project mes by qcadoo.
the class MaterialRequirementPdfService method addDataSeries.
private void addDataSeries(final Document document, final Entity materialRequirement, final Map<String, HeaderAlignment> headersWithAlignments) throws DocumentException {
List<Entity> orders = materialRequirement.getManyToManyField(MaterialRequirementFields.ORDERS);
MrpAlgorithm algorithm = MrpAlgorithm.parseString(materialRequirement.getStringField(MaterialRequirementFields.MRP_ALGORITHM));
Map<Long, BigDecimal> neededProductQuantities = basicProductionCountingService.getNeededProductQuantities(orders, algorithm);
List<String> headers = Lists.newLinkedList(headersWithAlignments.keySet());
PdfPTable table = pdfHelper.createTableWithHeader(headersWithAlignments.size(), headers, true, defaultOrderHeaderColumnWidth, headersWithAlignments);
List<Entity> products = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT).find().add(SearchRestrictions.in("id", neededProductQuantities.keySet())).list().getEntities();
products.sort(Comparator.comparing(p -> p.getStringField(ProductFields.NUMBER)));
for (Entity product : products) {
table.addCell(new Phrase(product.getStringField(ProductFields.NUMBER), FontUtils.getDejavuRegular7Dark()));
table.addCell(new Phrase(product.getStringField(ProductFields.NAME), FontUtils.getDejavuRegular7Dark()));
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
table.addCell(new Phrase(numberService.format(neededProductQuantities.get(product.getId())), FontUtils.getDejavuBold7Dark()));
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
String unit = product.getStringField(ProductFields.UNIT);
if (Objects.isNull(unit)) {
table.addCell(new Phrase("", FontUtils.getDejavuRegular7Dark()));
} else {
table.addCell(new Phrase(unit, FontUtils.getDejavuRegular7Dark()));
}
}
document.add(table);
}
use of com.qcadoo.mes.technologies.constants.MrpAlgorithm in project mes by qcadoo.
the class MaterialRequirementXlsService method addSimpleSeries.
private void addSimpleSeries(final HSSFSheet sheet, final Entity materialRequirement) {
int rowNum = 1;
List<Entity> orders = materialRequirement.getManyToManyField(MaterialRequirementFields.ORDERS);
MrpAlgorithm algorithm = MrpAlgorithm.parseString(materialRequirement.getStringField(MaterialRequirementFields.MRP_ALGORITHM));
Map<Long, BigDecimal> neededProductQuantities = basicProductionCountingService.getNeededProductQuantities(orders, algorithm);
List<Entity> products = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT).find().add(SearchRestrictions.in("id", neededProductQuantities.keySet())).list().getEntities();
products.sort(Comparator.comparing(p -> p.getStringField(ProductFields.NUMBER)));
for (Entity product : products) {
HSSFRow row = sheet.createRow(rowNum++);
row.createCell(0).setCellValue(product.getStringField(ProductFields.NUMBER));
row.createCell(1).setCellValue(product.getStringField(ProductFields.NAME));
row.createCell(2).setCellValue(numberService.setScaleWithDefaultMathContext(neededProductQuantities.get(product.getId())).doubleValue());
String unit = product.getStringField(ProductFields.UNIT);
if (Objects.isNull(unit)) {
row.createCell(3).setCellValue("");
} else {
row.createCell(3).setCellValue(unit);
}
}
sheet.autoSizeColumn((short) 0);
sheet.autoSizeColumn((short) 1);
sheet.autoSizeColumn((short) 2);
sheet.autoSizeColumn((short) 3);
}
Aggregations