DmitrMakeev commited on
Commit
41fd23b
·
verified ·
1 Parent(s): 0048867

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -12
app.py CHANGED
@@ -944,21 +944,12 @@ def handle_calculation():
944
  data = request.get_json()
945
 
946
  # Проверка обязательных полей
947
- if not data or 'profileSettings' not in data:
948
  return jsonify({'error': 'Неверный формат данных'}), 400
949
 
950
  # Инициализация калькулятора
951
  calculator = NutrientCalculator(volume_liters=float(data['profileSettings'].get('liters', 100)))
952
 
953
- # Предопределенные константы удобрений
954
- NUTRIENT_CONTENT_IN_FERTILIZERS = {
955
- "Калий азотнокислый": {"N (NO3-)": 0.136, "K": 0.382},
956
- "Аммоний азотнокислый": {"N (NO3-)": 0.17499, "N (NH4+)": 0.17499},
957
- "Сульфат магния": {"Mg": 0.09861, "S": 0.13010},
958
- "Монофосфат калия": {"P": 0.218, "K": 0.275},
959
- "Сульфат кальция": {"Ca": 0.23, "S": 0.186}
960
- }
961
-
962
  # Настройка целевого профиля
963
  calculator.target_profile = {
964
  'P': float(data['profileSettings'].get('P', 31.0)),
@@ -980,8 +971,8 @@ def handle_calculation():
980
  calculator.target_profile['N (NO3-)'] = total_n * (no3_ratio / total_parts)
981
  calculator.target_profile['N (NH4+)'] = total_n * (nh4_ratio / total_parts)
982
 
983
- # Установка предопределенных констант удобрений
984
- calculator.fertilizers = NUTRIENT_CONTENT_IN_FERTILIZERS
985
 
986
  # Выполнение расчета
987
  results = calculator.calculate()
 
944
  data = request.get_json()
945
 
946
  # Проверка обязательных полей
947
+ if not data or 'profileSettings' not in data or 'fertilizerConstants' not in data:
948
  return jsonify({'error': 'Неверный формат данных'}), 400
949
 
950
  # Инициализация калькулятора
951
  calculator = NutrientCalculator(volume_liters=float(data['profileSettings'].get('liters', 100)))
952
 
 
 
 
 
 
 
 
 
 
953
  # Настройка целевого профиля
954
  calculator.target_profile = {
955
  'P': float(data['profileSettings'].get('P', 31.0)),
 
971
  calculator.target_profile['N (NO3-)'] = total_n * (no3_ratio / total_parts)
972
  calculator.target_profile['N (NH4+)'] = total_n * (nh4_ratio / total_parts)
973
 
974
+ # Установка констант удобрений из запроса
975
+ calculator.fertilizers = data['fertilizerConstants']
976
 
977
  # Выполнение расчета
978
  results = calculator.calculate()