use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesServiceImplBPCOverrideUtil method getProductComponentWithQuantities.
private OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final Entity order) {
OperationProductComponentWithQuantityContainer productComponentWithQuantities = new OperationProductComponentWithQuantityContainer();
List<Entity> productionCountingQuantities = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY).find().add(SearchRestrictions.belongsTo(ProductionCountingQuantityFields.ORDER, order)).list().getEntities();
for (Entity productionCountingQuantity : productionCountingQuantities) {
Entity technologyOperationComponent = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.TECHNOLOGY_OPERATION_COMPONENT);
Entity product = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.PRODUCT);
String role = productionCountingQuantity.getStringField(ProductionCountingQuantityFields.ROLE);
BigDecimal plannedQuantity = productionCountingQuantity.getDecimalField(ProductionCountingQuantityFields.PLANNED_QUANTITY);
OperationProductComponentEntityType entityType = getEntityType(role);
ProductMaterialType productMaterialType = ProductMaterialType.parseString(productionCountingQuantity.getStringField(ProductionCountingQuantityFields.TYPE_OF_MATERIAL));
Entity productInputType = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.TECHNOLOGY_INPUT_PRODUCT_TYPE);
Entity attribute = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.ATTRIBUTE);
OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder(product, technologyOperationComponent, productInputType, attribute, productionCountingQuantity, entityType, productMaterialType);
productComponentWithQuantities.put(operationProductComponentHolder, plannedQuantity);
}
return productComponentWithQuantities;
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ModelCardPdfService method getQuantitiesInStock.
private Map<Long, Map<Long, BigDecimal>> getQuantitiesInStock(Set<OperationProductComponentHolder> operationProductComponentHolders) {
Map<Long, Entity> warehouses = com.google.common.collect.Maps.newHashMap();
Map<Long, List<Entity>> warehouseProducts = com.google.common.collect.Maps.newHashMap();
for (OperationProductComponentHolder operationProductComponentHolder : operationProductComponentHolders) {
Entity product = operationProductComponentHolder.getProduct();
Entity operationProductComponent = operationProductComponentHolder.getOperationProductComponent();
Entity warehouse = operationProductComponent.getBelongsToField(OperationProductInComponentFieldsPFTD.COMPONENTS_LOCATION);
if (!warehouses.containsKey(warehouse.getId())) {
warehouses.put(warehouse.getId(), warehouse);
}
if (Objects.isNull(product)) {
List<Entity> productBySizeGroups = getProductBySizeGroups(operationProductComponent.getId());
for (Entity productBySizeGroup : productBySizeGroups) {
Entity materialBySizeGroup = productBySizeGroup.getBelongsToField(ProductBySizeGroupFields.PRODUCT);
addProductToWarehouse(warehouseProducts, warehouse, materialBySizeGroup);
}
} else {
addProductToWarehouse(warehouseProducts, warehouse, product);
}
}
Map<Long, Map<Long, BigDecimal>> quantitiesInStock = com.google.common.collect.Maps.newHashMap();
for (Map.Entry<Long, List<Entity>> entry : warehouseProducts.entrySet()) {
quantitiesInStock.put(entry.getKey(), materialFlowResourcesService.getQuantitiesForProductsAndLocation(entry.getValue(), warehouses.get(entry.getKey())));
}
return quantitiesInStock;
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ModelCardPdfService method buildPdfContent.
@Override
protected void buildPdfContent(Document document, Entity modelCard, Locale locale) throws DocumentException {
String documentTitle = translationService.translate("productFlowThruDivision.modelCard.report.header", locale, modelCard.getStringField(ModelCardFields.NAME));
String documentAuthor = translationService.translate("qcadooReport.commons.generatedBy.label", locale);
pdfHelper.addDocumentHeader(document, StringUtils.EMPTY, documentTitle, documentAuthor, modelCard.getDateField(ModelCardFields.DATE));
Entity parameter = parameterService.getParameter();
Entity productAttribute = parameter.getBelongsToField(ParameterFieldsPFTD.PRODUCT_ATTRIBUTE);
Entity materialAttribute = parameter.getBelongsToField(ParameterFieldsPFTD.MATERIAL_ATTRIBUTE);
for (Entity modelCardProduct : modelCard.getHasManyField(ModelCardFields.MODEL_CARD_PRODUCTS)) {
Entity product = modelCardProduct.getBelongsToField(ModelCardProductFields.PRODUCT);
boolean forFamily = Objects.isNull(product.getBelongsToField(ProductFields.PARENT));
Entity technology = modelCardProduct.getBelongsToField(ModelCardProductFields.TECHNOLOGY);
BigDecimal quantity = modelCardProduct.getDecimalField(ModelCardProductFields.QUANTITY);
Map<OperationProductComponentHolder, BigDecimal> neededQuantities = productQuantitiesService.getNeededProductQuantities(technology, product, quantity);
Map<Long, Map<Long, BigDecimal>> quantitiesInStock = getQuantitiesInStock(neededQuantities.keySet());
List<ModelCardMaterialEntry> entries = newArrayList();
for (Map.Entry<OperationProductComponentHolder, BigDecimal> neededProductQuantity : neededQuantities.entrySet()) {
mapToModelCardMaterialEntry(modelCard, quantitiesInStock, entries, neededProductQuantity, forFamily, quantity, locale);
}
List<ModelCardMaterialEntry> groupedEntries = groupMaterials(entries);
regroupProductWithSizeGroup(groupedEntries);
BigDecimal materialUnitCostsSum = getMaterialUnitCostsSum(groupedEntries);
List<ModelCardMaterialEntry> sortedEntries = groupedEntries.stream().sorted(Comparator.comparing(ModelCardMaterialEntry::getNodeNumber, new NodeNumberComparator().reversed()).thenComparing(ModelCardMaterialEntry::getPriority).thenComparing(ModelCardMaterialEntry::getSizeGroupId, nullsFirst(naturalOrder()))).collect(Collectors.toList());
addProductTable(document, modelCardProduct, productAttribute, materialUnitCostsSum, locale);
addMaterialsTable(document, sortedEntries, materialAttribute, locale);
document.newPage();
}
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesWithComponentsServiceImpl method addOPCQuantitiesToList.
public void addOPCQuantitiesToList(final Map.Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity, final Map<OperationProductComponentHolder, BigDecimal> productWithQuantities) {
OperationProductComponentHolder operationProductComponentHolder = productComponentWithQuantity.getKey();
BigDecimal quantity = productComponentWithQuantity.getValue();
productWithQuantities.put(operationProductComponentHolder, quantity);
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesServiceImpl method addProductQuantitiesToList.
@Override
public void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity, final Map<Long, BigDecimal> productWithQuantities) {
OperationProductComponentHolder operationProductComponentHolder = productComponentWithQuantity.getKey();
Entity product = operationProductComponentHolder.getProduct();
if (product != null) {
BigDecimal newQuantity = productComponentWithQuantity.getValue();
BigDecimal oldQuantity = productWithQuantities.get(product.getId());
if (Objects.nonNull(oldQuantity)) {
newQuantity = newQuantity.add(oldQuantity);
}
productWithQuantities.put(product.getId(), newQuantity);
}
}
Aggregations