use of com.qcadoo.mes.productionCounting.constants.TypeOfProductionRecording in project mes by qcadoo.
the class OperationProductsExtractor method getOperationProductComponents.
private List<Entity> getOperationProductComponents(final Entity order, final Entity technologyOperationComponent) {
List<Entity> trackingOperationProductComponents = Lists.newArrayList();
Map<OperationProductComponentEntityType, Set<Entity>> entityTypeWithAlreadyAddedProducts = Maps.newHashMap();
String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
OperationProductComponentWithQuantityContainer productComponentQuantities = productQuantitiesService.getProductComponentQuantities(order);
for (Entry<OperationProductComponentHolder, BigDecimal> productComponentQuantity : productComponentQuantities.asMap().entrySet()) {
OperationProductComponentHolder operationProductComponentHolder = productComponentQuantity.getKey();
if (forEach(typeOfProductionRecording)) {
Entity operationComponent = operationProductComponentHolder.getTechnologyOperationComponent();
if (technologyOperationComponent == null) {
if (operationComponent != null) {
continue;
}
} else {
if ((operationComponent == null) || !technologyOperationComponent.getId().equals(operationComponent.getId())) {
continue;
}
}
} else if (cumulated(typeOfProductionRecording)) {
OperationProductComponentEntityType entityType = operationProductComponentHolder.getEntityType();
Entity product = operationProductComponentHolder.getProduct();
if ((product != null) && (entityType != null)) {
if (shouldSkipAddingProduct(operationProductComponentHolder, entityTypeWithAlreadyAddedProducts, typeOfProductionRecording)) {
if (entityTypeWithAlreadyAddedProducts.containsKey(entityType)) {
continue;
} else {
entityTypeWithAlreadyAddedProducts.put(entityType, Sets.newHashSet());
continue;
}
} else {
if (entityTypeWithAlreadyAddedProducts.containsKey(entityType)) {
Set<Entity> alreadAddedProducts = entityTypeWithAlreadyAddedProducts.get(entityType);
alreadAddedProducts.add(product);
entityTypeWithAlreadyAddedProducts.put(entityType, alreadAddedProducts);
} else {
entityTypeWithAlreadyAddedProducts.put(entityType, Sets.newHashSet(product));
}
}
}
}
Entity trackingOperationProductComponent = trackingOperationComponentBuilder.fromOperationProductComponentHolder(operationProductComponentHolder);
if (forEach(typeOfProductionRecording)) {
Optional<Entity> mabyExist = trackingOperationProductComponents.stream().filter(toc -> toc.getBelongsToField(L_PRODUCT).getId().equals(trackingOperationProductComponent.getBelongsToField(L_PRODUCT).getId())).findAny();
if (!mabyExist.isPresent()) {
trackingOperationProductComponents.add(trackingOperationProductComponent);
}
} else {
trackingOperationProductComponents.add(trackingOperationProductComponent);
}
}
return trackingOperationProductComponents;
}
Aggregations