public Entity fromOperationProductComponentHolder(final OperationProductComponentHolder operationProductComponentHolder) { String modelName = operationProductComponentHolder.getEntityType().getStringValue(); ProductionCountingQuantityRole role = null; String typeOfMaterial = operationProductComponentHolder.getProductMaterialType().getStringValue(); if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(modelName)) { role = ProductionCountingQuantityRole.USED; } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(modelName)) { role = ProductionCountingQuantityRole.PRODUCED; } else { throw new IllegalArgumentException(String.format("Unsupported operation component type: %s", modelName)); } Entity product = operationProductComponentHolder.getProduct(); return fromProduct(product, role, typeOfMaterial); }
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)); OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder(product, technologyOperationComponent, productionCountingQuantity, entityType, productMaterialType); nonComponents.add(operationProductComponentHolder); } }
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)); OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder(product, technologyOperationComponent, productionCountingQuantity, entityType, productMaterialType); productComponentWithQuantities.put(operationProductComponentHolder, plannedQuantity); } return productComponentWithQuantities; }
@Around("shouldSkipAddingProduct(operationProductComponentHolder,entityTypeWithAlreadyAddedProducts,typeOfProductionRecording)") public boolean aroundShouldSkipAddingProduct(final ProceedingJoinPoint pjp, OperationProductComponentHolder operationProductComponentHolder, Map<OperationProductComponentEntityType, Set<Entity>> entityTypeWithAlreadyAddedProducts, String typeOfProductionRecording) throws Throwable { if (cumulated(typeOfProductionRecording)) { Entity product = operationProductComponentHolder.getProduct(); Entity toc = operationProductComponentHolder.getTechnologyOperationComponent(); if (toc != null) { Entity technology = toc.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); if (operationProductComponentHolder.getProductMaterialType().getStringValue().equals(TechnologyService.L_02_INTERMEDIATE)) { boolean isProductToSkip = !productionTrackingListenerService.isOperationProductComponentToRegister( operationProductComponentHolder, product, toc); if (isProductToSkip) { return true; } } } } return (boolean) pjp.proceed(); }