@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(); }
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); }
public boolean isEntityTypeSame(final String operationProductComponentModelName) { return isEntityTypeSame(OperationProductComponentEntityType.parseString(operationProductComponentModelName)); }
public Entity getTechnologyOperationComponent() { if ((getTechnologyOperationComponentId() == null) || (getTechnologyOperationComponentDD() == null)) { return null; } else { return getTechnologyOperationComponentDD().get(getTechnologyOperationComponentId()); } }
private boolean shouldSkipAddingProduct(OperationProductComponentHolder operationProductComponentHolder, Map<OperationProductComponentEntityType, Set<Entity>> entityTypeWithAlreadyAddedProducts, String typeOfProductionRecording) { OperationProductComponentEntityType entityType = operationProductComponentHolder.getEntityType(); Entity product = operationProductComponentHolder.getProduct(); return entityTypeWithAlreadyAddedProducts.containsKey(entityType) && entityTypeWithAlreadyAddedProducts.get(entityType).contains(product); }
private void updateProductionCountingQuantities(final Entity order, final OperationProductComponentWithQuantityContainer productComponentQuantities, final Set<OperationProductComponentHolder> nonComponents) { for (Entry<OperationProductComponentHolder, BigDecimal> productComponentQuantity : productComponentQuantities.asMap() .entrySet()) { OperationProductComponentHolder operationProductComponentHolder = productComponentQuantity.getKey(); BigDecimal plannedQuantity = productComponentQuantity.getValue(); Entity technologyOperationComponent = operationProductComponentHolder.getTechnologyOperationComponent(); Entity product = operationProductComponentHolder.getProduct(); String role = getRole(operationProductComponentHolder); boolean isNonComponent = nonComponents.contains(operationProductComponentHolder); updateProductionCountingQuantity(order, technologyOperationComponent, product, role, isNonComponent, plannedQuantity); } updateProductionCountingQuantity(order, getOrderTechnologyOperationComponent(order), order.getBelongsToField(OrderFields.PRODUCT), ProductionCountingQuantityRole.PRODUCED.getStringValue(), false, order.getDecimalField(OrderFields.PLANNED_QUANTITY)); }
Entity operationComponent = operationProductComponentHolder.getTechnologyOperationComponent(); OperationProductComponentEntityType entityType = operationProductComponentHolder.getEntityType(); Entity product = operationProductComponentHolder.getProduct();
@Override public void addProductQuantitiesToList(final Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity, final Map<Long, BigDecimal> productWithQuantities) { OperationProductComponentHolder operationProductComponentHolder = productComponentWithQuantity.getKey(); Entity product = operationProductComponentHolder.getProduct(); BigDecimal newQuantity = productComponentWithQuantity.getValue(); BigDecimal oldQuantity = productWithQuantities.get(product.getId()); if (oldQuantity != null) { newQuantity = newQuantity.add(oldQuantity); } productWithQuantities.put(product.getId(), newQuantity); }
public void addMaterialOperationCost(final Entity costCalculation, final Map<Long, ComponentsCalculationHolder> basicComponentsMap, final Map<OperationProductComponentHolder, BigDecimal> materialQuantitiesByOPC) { MathContext mathContext = numberService.getMathContext(); List<CostCalculationMaterial> list = Lists.newArrayList(); Entity order = costCalculation.getBelongsToField(CostCalculationFields.ORDER); for (Map.Entry<OperationProductComponentHolder, BigDecimal> neededProductQuantity : materialQuantitiesByOPC.entrySet()) { Entity product = neededProductQuantity.getKey().getProduct(); Entity productEntity = productsCostCalculationService.getAppropriateCostNormForProduct(product, order, costCalculation.getStringField(CostCalculationFields.SOURCE_OF_MATERIAL_COSTS)); BigDecimal productQuantity = neededProductQuantity.getValue(); BigDecimal costForGivenQuantity = productsCostCalculationService.calculateProductCostForGivenQuantity(productEntity, productQuantity, costCalculation.getStringField(CostCalculationFields.CALCULATE_MATERIAL_COSTS_MODE)); if (basicComponentsMap.containsKey((neededProductQuantity.getKey().getTechnologyOperationComponentId()))) { ComponentsCalculationHolder cc = basicComponentsMap.get(neededProductQuantity.getKey() .getTechnologyOperationComponentId()); BigDecimal materialCost = BigDecimalUtils.convertNullToZero(cc.getMaterialCost()).add( BigDecimalUtils.convertNullToZero(costForGivenQuantity), mathContext); cc.setMaterialCost(numberService.setScaleWithDefaultMathContext(materialCost, 2)); } } }
public BigDecimal get(final Entity operationProductComponent) { Preconditions.checkNotNull(operationProductComponent, L_MISSING_OPERATION_PRODUCT_COMPONENT_ENTITY); OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder( operationProductComponent); return get(operationProductComponentHolder); }
&& OperationProductComponentEntityType.OPERATION_PRODUCT_IN_COMPONENT.equals(componentHolder.getEntityType()) && (componentHolder.getOperationProductComponentId() != null)) { Entity opic = dataDefinitionService .get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT) .get(componentHolder.getOperationProductComponentId());
public boolean isEntityTypeSame(final OperationProductComponentEntityType operationProductComponentEntityType) { return operationProductComponentEntityType.equals(getEntityType()); }
private void prepareProductionCountingQuantities(final Entity order, final Set<OperationProductComponentHolder> nonComponents, final OperationProductComponentWithQuantityContainer productComponentQuantities, final List<Entity> productionCountingQuantities) { for (Entry<OperationProductComponentHolder, BigDecimal> productComponentQuantity : productComponentQuantities.asMap() .entrySet()) { OperationProductComponentHolder operationProductComponentHolder = productComponentQuantity.getKey(); BigDecimal plannedQuantity = productComponentQuantity.getValue(); Entity technologyOperationComponent = operationProductComponentHolder.getTechnologyOperationComponent(); Entity product = operationProductComponentHolder.getProduct(); String role = getRole(operationProductComponentHolder); boolean isNonComponent = nonComponents.contains(operationProductComponentHolder); Entity productionCountingQuantity = prepareProductionCountingQuantity(order, technologyOperationComponent, product, role, isNonComponent, plannedQuantity); productionCountingQuantities.add(productionCountingQuantity); } if (PluginUtils.isEnabled("productFlowThruDivision")) { fillFlow(productionCountingQuantities, order); } if (parameterService.getParameter().getBooleanField(ParameterFieldsO.CREATE_SET_ELEMENTS_ON_ACCEPT)) { productionCountingQuantitySetService.markIntermediateInProductionCountingQuantities(productionCountingQuantities, false); } }
private Map<OperationProductComponentHolder, BigDecimal> getOperationProductComponentWithQuantities( final OperationProductComponentWithQuantityContainer productComponentWithQuantities, final Set<OperationProductComponentHolder> nonComponents, final boolean onlyComponents, final boolean onlyMaterials) { Map<OperationProductComponentHolder, BigDecimal> productWithQuantities = Maps.newHashMap(); for (Map.Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity : productComponentWithQuantities .asMap().entrySet()) { OperationProductComponentHolder operationProductComponentHolder = productComponentWithQuantity.getKey(); if (onlyComponents && nonComponents.contains(operationProductComponentHolder)) { continue; } if (onlyMaterials) { Entity product = operationProductComponentHolder.getProduct(); if (hasAcceptedMasterTechnology(product)) { continue; } } addOPCQuantitiesToList(productComponentWithQuantity, productWithQuantities); } return productWithQuantities; }
public void remove(final Entity operationProductComponent) { Preconditions.checkNotNull(operationProductComponent, L_MISSING_OPERATION_PRODUCT_COMPONENT_ENTITY); OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder( operationProductComponent); remove(operationProductComponentHolder); }
Entity product = operationProductComponentHolder.getProduct(); Entity technologyOperationComponent = operationProductComponentHolder.getTechnologyOperationComponent();
private Map<Long, BigDecimal> getProductWithoutSubcontractingProduct( final OperationProductComponentWithQuantityContainer productComponentWithQuantities, final Set<OperationProductComponentHolder> nonComponents, final boolean onlyComponents, final boolean onlyMaterials) { Map<Long, BigDecimal> productWithQuantities = Maps.newHashMap(); for (Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity : productComponentWithQuantities .asMap().entrySet()) { OperationProductComponentHolder operationProductComponentHolder = productComponentWithQuantity.getKey(); if (onlyComponents && nonComponents.contains(operationProductComponentHolder)) { continue; } if (onlyMaterials) { Entity product = operationProductComponentHolder.getProduct(); if (hasAcceptedMasterTechnology(product)) { continue; } } addProductQuantitiesToList(productComponentWithQuantity, productWithQuantities); } return productWithQuantities; }
private OperationProductComponentWithQuantityContainer getAllWithSameEntityType( final OperationProductComponentEntityType operationProductComponentEntityType) { OperationProductComponentWithQuantityContainer allWithSameType = new OperationProductComponentWithQuantityContainer(); for (Entry<OperationProductComponentHolder, BigDecimal> operationProductComponentWithQuantity : operationProductComponentWithQuantities .entrySet()) { OperationProductComponentHolder operationProductComponentHolder = operationProductComponentWithQuantity.getKey(); if (operationProductComponentHolder.isEntityTypeSame(operationProductComponentEntityType)) { BigDecimal quantity = operationProductComponentWithQuantity.getValue(); allWithSameType.put(operationProductComponentHolder, quantity); } } return allWithSameType; }
public boolean containsKey(final Entity operationProductComponent) { Preconditions.checkNotNull(operationProductComponent, L_MISSING_OPERATION_PRODUCT_COMPONENT_ENTITY); OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder( operationProductComponent); return containsKey(operationProductComponentHolder); }
public OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesWithoutNonComponents( final OperationProductComponentWithQuantityContainer productComponentWithQuantities, final Set<OperationProductComponentHolder> nonComponents) { for (OperationProductComponentHolder nonComponent : nonComponents) { Entity product = nonComponent.getProduct(); Entity technologyOperationComponent = nonComponent.getTechnologyOperationComponent(); if (technologyOperationComponent != null) { List<Entity> children = technologyOperationComponent.getHasManyField(TechnologyOperationComponentFields.CHILDREN) .find().add(SearchRestrictions.eq(TechnologyOperationComponentFieldsTS.IS_SUBCONTRACTING, true)).list() .getEntities(); boolean isSubcontracting = false; for (Entity child : children) { Entity operationProductOutComponent = child .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS).find() .add(SearchRestrictions.belongsTo(OperationProductOutComponentFields.PRODUCT, product)) .setMaxResults(1).uniqueResult(); if (operationProductOutComponent != null) { isSubcontracting = true; } } if (!isSubcontracting) { productComponentWithQuantities.remove(nonComponent); } } } return productComponentWithQuantities; }