calculation.setProductivityLevel(calculationExpression.getPeLevel());
return calculation;
}
private Calculation getCalculation(Long[] pathNodes, BlueprintDetailsDto blueprintDetailsDto, Map<Long, String> priceSetItemTypeIdToPriceMap) {
Calculation calculation = new Calculation();
BlueprintTypeDto blueprintTypeDto = blueprintDetailsDto.getBlueprintTypeDto();
calculation.setBlueprintTypeID(blueprintTypeDto.getBlueprintTypeID());
calculation.setBlueprintTypeName(blueprintTypeDto.getBlueprintTypeName());
calculation.setProductTypeID(blueprintTypeDto.getProductTypeID());
calculation.setProductTypeCategoryID(blueprintTypeDto.getProductCategoryID());
calculation.setProductTypeName(blueprintTypeDto.getProductTypeName());
calculation.setProductGraphicIcon(blueprintTypeDto.getProductGraphicIcon());
calculation.setMaterialLevel(0);
calculation.setProductivityLevel(0);
calculation.setWasteFactor(blueprintTypeDto.getWasteFactor());
calculation.setPrice("0.00");
List<TypeMaterialDto> materialDtos = blueprintDetailsDto.getMaterialDtos();
List<TypeRequirementDto> requirementDtos = blueprintDetailsDto.getManufacturingRequirementDtos();
List<CalculationItem> calculationItems = new ArrayList<CalculationItem>();
for (TypeMaterialDto materialDto : materialDtos) {
CalculationItem calculationItem = new CalculationItem();
PathExpression pathExpression = new PathExpression(pathNodes, calculation.getMaterialLevel(), calculation.getProductivityLevel(), materialDto.getMaterialTypeID());
calculationItem.setPath(pathExpression.getPath());
calculationItem.setItemTypeID(materialDto.getMaterialTypeID());
calculationItem.setItemCategoryID(materialDto.getMaterialTypeCategoryID());
calculationItem.setItemTypeName(materialDto.getMaterialTypeName());
calculationItem.setItemTypeIcon(materialDto.getMaterialTypeGraphicIcon());
calculationItem.setQuantity(materialDto.getQuantity());
calculationItem.setParentQuantity(1L);
calculationItem.setPerfectQuantity(materialDto.getQuantity());
calculationItem.setWasteFactor(blueprintTypeDto.getWasteFactor());
calculationItem.setDamagePerJob("1.00");
String price = priceSetItemTypeIdToPriceMap.get(materialDto.getMaterialTypeID());
calculationItem.setPrice(price == null ? "0.00" : price);
calculationItem.setTotalPrice("0.00");
calculationItem.setTotalPriceForParent("0.00");
calculationItems.add(calculationItem);
}
for (TypeRequirementDto requirementDto : requirementDtos) {
if (requirementDto.getRequiredTypeCategoryID() == 16L) {
continue;
}
CalculationItem calculationItem = new CalculationItem();
PathExpression pathExpression = new PathExpression(pathNodes, requirementDto.getRequiredTypeID());
calculationItem.setPath(pathExpression.getPath());
calculationItem.setItemTypeID(requirementDto.getRequiredTypeID());
calculationItem.setItemCategoryID(requirementDto.getRequiredTypeCategoryID());
calculationItem.setItemTypeName(requirementDto.getRequiredTypeName());
calculationItem.setItemTypeIcon(requirementDto.getRequiredTypeNameGraphicIcon());
calculationItem.setQuantity(requirementDto.getQuantity());
calculationItem.setParentQuantity(1L);
calculationItem.setPerfectQuantity(requirementDto.getQuantity());
calculationItem.setWasteFactor(blueprintTypeDto.getWasteFactor());
calculationItem.setDamagePerJob(requirementDto.getDamagePerJob());
String price = priceSetItemTypeIdToPriceMap.get(requirementDto.getRequiredTypeID());
calculationItem.setPrice(price == null ? "0.00" : price);
calculationItem.setTotalPrice("0.00");
calculationItem.setTotalPriceForParent("0.00");
calculationItems.add(calculationItem);
}
calculation.setItems(calculationItems);
return calculation;
}