From 54e00916871873d50d804d963a2b7f41a58ca032 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 24 Oct 2024 12:55:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=82=D0=BE=D1=80=D0=BE=D0=B9=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=80=D0=BE=D1=81=20=D0=BF=D1=80=D0=BE=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B2=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/requests.py | 22 ++++++++++++++-- App/Requests/sql/zapros1.sql | 3 ++- App/Requests/sql/zapros2.sql | 10 ++++++++ App/Requests/templates/output.html | 30 ++++++++++++---------- App/Requests/templates/zagotovki_ship.html | 27 +++++++++++++++++++ App/Requests/zapros_menu.json | 3 ++- 6 files changed, 78 insertions(+), 17 deletions(-) create mode 100644 App/Requests/sql/zapros2.sql create mode 100644 App/Requests/templates/zagotovki_ship.html diff --git a/App/Requests/requests.py b/App/Requests/requests.py index bbc3ba3..c92f813 100644 --- a/App/Requests/requests.py +++ b/App/Requests/requests.py @@ -32,8 +32,26 @@ def sklad_zapros(): material = dict(request.form) zagotovki = route(session['db_config'], material, sql_provider, 'zapros1.sql') if zagotovki.status: - categories = ['Вес (в кг.)', 'Цена (в руб.)', 'Количество', 'Дата последнего обновления'] header = f'Заготовки на складе из материала \'{material["material"]}\'' - return render_template('output.html', items=zagotovki.result, titles = categories, object=header) + return render_template('output.html', items=zagotovki.result, object=header) + else: + return zagotovki.error_message + +@requests_bp.route('/req2', methods=['GET', 'POST']) +@check_auth +def zagotovki_ship(): + if request.method == 'GET': + zagotovki = route(session['db_config'], {}, sql_provider, 'zagotovki.sql') + if zagotovki.status: + return render_template('zagotovki_ship.html', materials=zagotovki.result) + else: + return zagotovki.error_message + else: + material = dict(request.form) + zagotovki = route(session['db_config'], material, sql_provider, 'zapros2.sql') + print(zagotovki) + if zagotovki.status: + header = f'Поставленные заготовки из материала \'{material["material"]}\'' + return render_template('output.html', items=zagotovki.result, object=header) else: return zagotovki.error_message \ No newline at end of file diff --git a/App/Requests/sql/zapros1.sql b/App/Requests/sql/zapros1.sql index d2986ef..e377fb5 100644 --- a/App/Requests/sql/zapros1.sql +++ b/App/Requests/sql/zapros1.sql @@ -1,3 +1,4 @@ -SELECT weight, price, count, last_update +SELECT weight AS 'Вес', price AS 'Цена', +count AS 'Количество', last_update AS 'Дата последнего обновления' FROM workpiece WHERE material = '${material}' \ No newline at end of file diff --git a/App/Requests/sql/zapros2.sql b/App/Requests/sql/zapros2.sql new file mode 100644 index 0000000..d234619 --- /dev/null +++ b/App/Requests/sql/zapros2.sql @@ -0,0 +1,10 @@ +SELECT sellers.name AS 'Поставщик', + w.date_of_delivery AS 'Дата поставки', + SUM(wl.count) AS 'Общее количество заготовок', + SUM(wl.price) AS 'Общая стоимость поставленных заготовок' +FROM waybill w +JOIN waybill_lines wl ON w.waybill_id = wl.waybill_id +JOIN workpiece USING(work_id) +JOIN sellers USING(sel_id) +WHERE workpiece.material = '${material}' +GROUP BY sellers.name, w.date_of_delivery; diff --git a/App/Requests/templates/output.html b/App/Requests/templates/output.html index 4a5d64c..c5da12b 100644 --- a/App/Requests/templates/output.html +++ b/App/Requests/templates/output.html @@ -11,20 +11,24 @@

{{ object }}

- - - {% for title in titles %} - + {% if items %} +
{{ title }}
+ + {% for key in items[0].keys() %} + + {% endfor %} + + {% for item in items %} + + {% for value in item.values() %} + + {% endfor %} + {% endfor %} - - {% for item in items %} - - {% for value in item.values() %} - - {% endfor %} - - {% endfor %} -
{{ key }}
{{ value }}
{{ value }}
+ + {% else %} +

Информации не найдено

+ {% endif %}
diff --git a/App/Requests/templates/zagotovki_ship.html b/App/Requests/templates/zagotovki_ship.html new file mode 100644 index 0000000..124b2c7 --- /dev/null +++ b/App/Requests/templates/zagotovki_ship.html @@ -0,0 +1,27 @@ + + + + + Заготовки на складе + + + +
+ +
+ +

Выберите материал

+
+ + +
+
+ +
+ + + diff --git a/App/Requests/zapros_menu.json b/App/Requests/zapros_menu.json index ad205d9..cfc682a 100644 --- a/App/Requests/zapros_menu.json +++ b/App/Requests/zapros_menu.json @@ -1,3 +1,4 @@ [ - {"name": "Материалы заготовок", "url": "requests_bp.sklad_zapros"} + {"name": "Материалы заготовок", "url": "requests_bp.sklad_zapros"}, + {"name": "Поставки заготовок", "url": "requests_bp.zagotovki_ship"} ] \ No newline at end of file