DmitrMakeev commited on
Commit
b348c9a
·
verified ·
1 Parent(s): e332b4a

Update nutri_call.html

Browse files
Files changed (1) hide show
  1. nutri_call.html +17 -12
nutri_call.html CHANGED
@@ -1094,26 +1094,32 @@ function updateNitrogenFields(data) {
1094
 
1095
 
1096
 
1097
- // Функция для расчета соотношения NPK
1098
  function updateNPK(data) {
1099
- console.log("=== РАСЧЕТ СООТНОШЕНИЯ NPK ===");
1100
 
1101
  // Извлекаем значения из actual_profile
1102
- const nValue = data.actual_profile["N (NH4+)"] + data.actual_profile["N (NO3-)"];
1103
- const pValue = data.actual_profile["P"];
1104
- const kValue = data.actual_profile["K"];
1105
 
1106
  // Проверяем, что значения существуют
1107
- if (nValue !== undefined && pValue !== undefined && kValue !== undefined) {
1108
  console.log(`Значения NPK: N=${nValue}, P=${pValue}, K=${kValue}`);
1109
 
 
 
 
 
 
 
 
1110
  // Находим минимальное значение
1111
- const minValue = Math.min(nValue, pValue, kValue);
1112
 
1113
  // Рассчитываем соотношение
1114
- const nRatio = Math.round(nValue / minValue);
1115
- const pRatio = Math.round(pValue / minValue);
1116
- const kRatio = Math.round(kValue / minValue);
1117
 
1118
  console.log(`Соотношение NPK: ${nRatio}:${pRatio}:${kRatio}`);
1119
 
@@ -1122,7 +1128,7 @@ function updateNPK(data) {
1122
  document.getElementById("npk-p-value").textContent = pRatio;
1123
  document.getElementById("npk-k-value").textContent = kRatio;
1124
  } else {
1125
- console.error("Ошибка: Значения NPK не найдены в ответе сервера.");
1126
  }
1127
  }
1128
 
@@ -1130,7 +1136,6 @@ function updateNPK(data) {
1130
 
1131
 
1132
 
1133
-
1134
  function calculateOxidePercentages(data) {
1135
  console.log("=== РАСЧЕТ ПРОЦЕНТОВ ОКСИДОВ ===");
1136
 
 
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
 
 
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
 
 
1136
 
1137
 
1138
 
 
1139
  function calculateOxidePercentages(data) {
1140
  console.log("=== РАСЧЕТ ПРОЦЕНТОВ ОКСИДОВ ===");
1141