use of com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType 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;
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType in project mes by qcadoo.
the class ProductQuantitiesServiceImplBPCOverrideUtil method fillNonComponents.
private void fillNonComponents(final Set<OperationProductComponentHolder> nonComponents, final Entity order) {
List<Entity> productionCountingQuantities = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY).find().add(SearchRestrictions.belongsTo(ProductionCountingQuantityFields.ORDER, order)).add(SearchRestrictions.eq(ProductionCountingQuantityFields.IS_NON_COMPONENT, true)).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);
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);
nonComponents.add(operationProductComponentHolder);
}
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType 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.OperationProductComponentEntityType in project mes by qcadoo.
the class OperationProductsExtractor method shouldSkipAddingProduct.
private boolean shouldSkipAddingProduct(OperationProductComponentHolder operationProductComponentHolder, Map<OperationProductComponentEntityType, Set<Entity>> entityTypeWithAlreadyAddedProducts, String typeOfProductionRecording) {
if (cumulated(typeOfProductionRecording) && operationProductComponentHolder.getProductMaterialType().getStringValue().equals(TechnologyService.L_02_INTERMEDIATE)) {
return true;
}
OperationProductComponentEntityType entityType = operationProductComponentHolder.getEntityType();
Entity product = operationProductComponentHolder.getProduct();
return entityTypeWithAlreadyAddedProducts.containsKey(entityType) && entityTypeWithAlreadyAddedProducts.get(entityType).contains(product);
}
Aggregations