DmitrMakeev commited on
Commit
93875c9
·
verified ·
1 Parent(s): 1c19879

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -911,7 +911,7 @@ def handle_calculation():
911
 
912
  # 3. Устанавливаем константы из запроса
913
  TOTAL_NITROGEN = float(profile_data.get('TOTAL_NITROG', 125.0))
914
- NO3_RATIO = float(profile_data.get('NO3_RAT', 8.25)) # Берем как есть, без деления на 100
915
  VOLUME_LITERS = float(profile_data.get('liters', 100))
916
  NH4_RATIO = 1.00 # Фиксированное значение
917
 
@@ -966,11 +966,16 @@ def handle_calculation():
966
  # 8. Выполняем расчет
967
  results = calculator.calculate()
968
 
969
- # 9. Формируем ответ
 
 
 
 
 
970
  response = {
971
  'actual_profile': {k: round(v, 2) for k, v in calculator.actual_profile.items()},
972
  'fertilizers': results,
973
- 'total_ec': calculator.calculate_ec(),
974
  'total_ppm': round(sum(calculator.actual_profile.values()), 2),
975
  'nitrogen_ratios': {
976
  'NO3_RATIO': NO3_RATIO,
 
911
 
912
  # 3. Устанавливаем константы из запроса
913
  TOTAL_NITROGEN = float(profile_data.get('TOTAL_NITROG', 125.0))
914
+ NO3_RATIO = float(profile_data.get('NO3_RAT', 8.25))
915
  VOLUME_LITERS = float(profile_data.get('liters', 100))
916
  NH4_RATIO = 1.00 # Фиксированное значение
917
 
 
966
  # 8. Выполняем расчет
967
  results = calculator.calculate()
968
 
969
+ # 9. Округляем значения граммов до 3 знаков после запятой
970
+ for fert_data in results.values():
971
+ if 'граммы' in fert_data:
972
+ fert_data['граммы'] = round(fert_data['граммы'], 3)
973
+
974
+ # 10. Формируем ответ
975
  response = {
976
  'actual_profile': {k: round(v, 2) for k, v in calculator.actual_profile.items()},
977
  'fertilizers': results,
978
+ 'total_ec': round(calculator.calculate_ec(), 2),
979
  'total_ppm': round(sum(calculator.actual_profile.values()), 2),
980
  'nitrogen_ratios': {
981
  'NO3_RATIO': NO3_RATIO,