Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -702,8 +702,6 @@ def nutri_call():
|
|
702 |
|
703 |
|
704 |
|
705 |
-
from tabulate import tabulate
|
706 |
-
|
707 |
# Входные данные (пример)
|
708 |
INPUT_DATA = {
|
709 |
"fertilizerConstants": {
|
@@ -812,10 +810,38 @@ class NutrientCalculator:
|
|
812 |
'deficits': deficits,
|
813 |
'total_ppm': round(sum(self.actual.values()), 3)
|
814 |
}
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
819 |
|
820 |
@app.route('/calculation', methods=['POST'])
|
821 |
def handle_calculation():
|
@@ -883,7 +909,6 @@ def handle_calculation():
|
|
883 |
|
884 |
|
885 |
|
886 |
-
|
887 |
|
888 |
|
889 |
if __name__ == '__main__':
|
|
|
702 |
|
703 |
|
704 |
|
|
|
|
|
705 |
# Входные данные (пример)
|
706 |
INPUT_DATA = {
|
707 |
"fertilizerConstants": {
|
|
|
810 |
'deficits': deficits,
|
811 |
'total_ppm': round(sum(self.actual.values()), 3)
|
812 |
}
|
813 |
+
|
814 |
+
def generate_report(self, results):
|
815 |
+
"""Генерация текстового отчета"""
|
816 |
+
fert_table = []
|
817 |
+
for name, data in results['fertilizers'].items():
|
818 |
+
fert_table.append([name, f"{data} г"])
|
819 |
+
|
820 |
+
element_table = []
|
821 |
+
for el in sorted(self.target.keys()):
|
822 |
+
element_table.append([
|
823 |
+
el,
|
824 |
+
f"{self.target[el]} ppm",
|
825 |
+
f"{results['actual_profile'][el]} ppm",
|
826 |
+
f"{results['actual_profile'][el] - self.target[el]:+.2f} ppm"
|
827 |
+
])
|
828 |
+
|
829 |
+
report = "РЕКОМЕНДУЕМЫЕ УДОБРЕНИЯ:\n"
|
830 |
+
report += tabulate(fert_table, headers=["Удобрение", "Количество"], tablefmt="grid")
|
831 |
+
|
832 |
+
report += "\n\nБАЛАНС ЭЛЕМЕНТОВ:\n"
|
833 |
+
report += tabulate(element_table,
|
834 |
+
headers=["Элемент", "Цель", "Факт", "Отклонение"],
|
835 |
+
tablefmt="grid")
|
836 |
+
|
837 |
+
report += f"\n\nОбщая концентрация: {results['total_ppm']} ppm"
|
838 |
+
|
839 |
+
if results['deficits']:
|
840 |
+
report += "\n\nВНИМАНИЕ: Обнаружены небольшие отклонения:"
|
841 |
+
for el, diff in results['deficits'].items():
|
842 |
+
report += f"\n- {el}: не хватает {abs(diff)} ppm"
|
843 |
+
|
844 |
+
return report
|
845 |
|
846 |
@app.route('/calculation', methods=['POST'])
|
847 |
def handle_calculation():
|
|
|
909 |
|
910 |
|
911 |
|
|
|
912 |
|
913 |
|
914 |
if __name__ == '__main__':
|