DmitrMakeev commited on
Commit
a746ec0
·
verified ·
1 Parent(s): 60c01af

Update nutri_call.html

Browse files
Files changed (1) hide show
  1. nutri_call.html +11 -23
nutri_call.html CHANGED
@@ -1094,41 +1094,29 @@ function updateNitrogenFields(data) {
1094
 
1095
 
1096
 
 
1097
  function updateNPK(data) {
1098
- console.log("=== РАСЧЕТ СООТНОШЕНИЯ NPK В ОКСИДНОЙ ФОРМЕ ===");
1099
-
1100
  // Извлекаем значения из actual_profile
1101
- const nValue = (data.actual_profile["N (NH4+)"] || 0) + (data.actual_profile["N (NO3-)"] || 0);
1102
- const pValue = data.actual_profile["P"] || 0;
1103
- const kValue = data.actual_profile["K"] || 0;
1104
-
1105
  // Проверяем, что значения существуют
1106
- if (nValue > 0 && pValue > 0 && kValue > 0) {
1107
  console.log(`Значения NPK: N=${nValue}, P=${pValue}, K=${kValue}`);
1108
-
1109
- // Переводим в оксидную форму
1110
- const nOxide = nValue * 4.43; // N → NO3
1111
- const pOxide = pValue * 2.29; // P → P2O5
1112
- const kOxide = kValue * 1.2; // K → K2O
1113
-
1114
- console.log(`Оксидная форма: N=${nOxide.toFixed(2)}, P=${pOxide.toFixed(2)}, K=${kOxide.toFixed(2)}`);
1115
-
1116
  // Находим минимальное значение
1117
- const minValue = Math.min(nOxide, pOxide, kOxide);
1118
-
1119
  // Рассчитываем соотношение
1120
- const nRatio = Math.round(nOxide / minValue);
1121
- const pRatio = Math.round(pOxide / minValue);
1122
- const kRatio = Math.round(kOxide / minValue);
1123
-
1124
  console.log(`Соотношение NPK: ${nRatio}:${pRatio}:${kRatio}`);
1125
-
1126
  // Обновляем поля на странице
1127
  document.getElementById("npk-n-value").textContent = nRatio;
1128
  document.getElementById("npk-p-value").textContent = pRatio;
1129
  document.getElementById("npk-k-value").textContent = kRatio;
1130
  } else {
1131
- console.error("Ошибка: Значения NPK не найдены в ответе сервера или равны нулю.");
1132
  }
1133
  }
1134
 
 
1094
 
1095
 
1096
 
1097
+ // Функция для расчета соотношения NPK
1098
  function updateNPK(data) {
1099
+ console.log("=== РАСЧЕТ СООТНОШЕНИЯ NPK ===");
 
1100
  // Извлекаем значения из actual_profile
1101
+ const nValue = data.actual_profile["N (NH4+)"] + data.actual_profile["N (NO3-)"];
1102
+ const pValue = data.actual_profile["P"];
1103
+ const kValue = data.actual_profile["K"];
 
1104
  // Проверяем, что значения существуют
1105
+ if (nValue !== undefined && pValue !== undefined && kValue !== undefined) {
1106
  console.log(`Значения NPK: N=${nValue}, P=${pValue}, K=${kValue}`);
 
 
 
 
 
 
 
 
1107
  // Находим минимальное значение
1108
+ const minValue = Math.min(nValue, pValue, kValue);
 
1109
  // Рассчитываем соотношение
1110
+ const nRatio = Math.round(nValue / minValue);
1111
+ const pRatio = Math.round(pValue / minValue);
1112
+ const kRatio = Math.round(kValue / minValue);
 
1113
  console.log(`Соотношение NPK: ${nRatio}:${pRatio}:${kRatio}`);
 
1114
  // Обновляем поля на странице
1115
  document.getElementById("npk-n-value").textContent = nRatio;
1116
  document.getElementById("npk-p-value").textContent = pRatio;
1117
  document.getElementById("npk-k-value").textContent = kRatio;
1118
  } else {
1119
+ console.error("Ошибка: Значения NPK не найдены в ответе сервера.");
1120
  }
1121
  }
1122