This commit is contained in:
@@ -274,4 +274,4 @@ wdm/
|
||||
```
|
||||
|
||||
Wichtig: `docker compose` muss aus dem Projektwurzel-Verzeichnis heraus
|
||||
aufgerufen werden (dort, wo `docker-compose.yml` liegt), nicht aus `build/`.
|
||||
aufgerufen werden (dort, wo `docker-compose.yml` liegt), nicht aus `build/`.
|
||||
|
||||
+33
-2
@@ -189,6 +189,32 @@ def insert_mde_ohne_rate(cur, maschine_id, auftragsnummer, produziert, status, p
|
||||
)
|
||||
|
||||
|
||||
def get_letzter_h_avg(cur, maschine_id, auftragsnummer):
|
||||
"""Letzter bekannter Stück/Std-Wert (h_avg) für diesen Auftrag, egal
|
||||
welchen Status der Eintrag hatte. 0, falls noch keine Buchung existiert."""
|
||||
cur.execute(
|
||||
'SELECT h_avg FROM "MDE" WHERE maschine_id = %s AND "order" = %s '
|
||||
'ORDER BY timestamp DESC, id DESC LIMIT 1',
|
||||
(maschine_id, auftragsnummer),
|
||||
)
|
||||
row = cur.fetchone()
|
||||
return row["h_avg"] if row and row["h_avg"] is not None else 0
|
||||
|
||||
|
||||
def insert_mde_start(cur, maschine_id, auftragsnummer, produziert):
|
||||
"""Für den "start"-Buchhaltungseintrag beim (erstmaligen) Start bzw. beim
|
||||
Fortsetzen nach einer Pause: in der Pause wurde nicht produziert, eine
|
||||
frisch berechnete Rate würde die Pausenzeit mit einrechnen und dadurch
|
||||
einen künstlich niedrigen Wert erzeugen. Stattdessen wird einfach der
|
||||
zuletzt bekannte Stück/Std-Wert unverändert übernommen."""
|
||||
h_avg = get_letzter_h_avg(cur, maschine_id, auftragsnummer)
|
||||
cur.execute(
|
||||
'INSERT INTO "MDE" (maschine_id, "timestamp", "order", produziert, status, h_date, h_avg) '
|
||||
"VALUES (%s, %s, %s, %s, 'start', now(), %s)",
|
||||
(maschine_id, now_ts(), auftragsnummer, produziert, h_avg),
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------
|
||||
# Auftragsimport (Excel)
|
||||
# ---------------------------------------------------------------------
|
||||
@@ -331,6 +357,7 @@ def machine_main(maschine_id):
|
||||
title=maschine["name"] or f"Maschine {maschine_id}",
|
||||
subtitle=maschine["standort"] or "",
|
||||
maschine=maschine,
|
||||
maschine_badge_id=maschine["id"],
|
||||
auftrag=auftrag,
|
||||
status_label=STATUS_LABEL.get(auftrag["status"], auftrag["status"]) if auftrag else "",
|
||||
soll_fmt=fmt_num(soll),
|
||||
@@ -362,6 +389,7 @@ def machine_auswahl(maschine_id):
|
||||
title="Auftragsauswahl",
|
||||
subtitle=maschine["name"] or "",
|
||||
maschine=maschine,
|
||||
maschine_badge_id=maschine["id"],
|
||||
auftraege=auftraege,
|
||||
)
|
||||
|
||||
@@ -388,7 +416,7 @@ def machine_auswahl_waehlen(maschine_id):
|
||||
(ts, auftrag_id),
|
||||
)
|
||||
bisherige = get_letzte_produktion(cur, maschine_id, auftrag["auftragsnummer"])
|
||||
insert_mde(cur, maschine_id, auftrag["auftragsnummer"], bisherige, "start")
|
||||
insert_mde_start(cur, maschine_id, auftrag["auftragsnummer"], bisherige)
|
||||
|
||||
return redirect(url_for("machine_main", maschine_id=maschine_id))
|
||||
|
||||
@@ -402,7 +430,8 @@ def _meldung_view(maschine_id, ziel_status, eingabe_einheiten=None, eingabe_abwe
|
||||
if not auftrag:
|
||||
return render_template(
|
||||
"machine_main.html", title=maschine["name"] or f"Maschine {maschine_id}",
|
||||
subtitle=maschine["standort"] or "", maschine=maschine, auftrag=None,
|
||||
subtitle=maschine["standort"] or "", maschine=maschine,
|
||||
maschine_badge_id=maschine["id"], auftrag=None,
|
||||
error="Kein aktiver Auftrag.",
|
||||
)
|
||||
bisherige = get_letzte_produktion(cur, maschine_id, auftrag["auftragsnummer"])
|
||||
@@ -421,6 +450,7 @@ def _meldung_view(maschine_id, ziel_status, eingabe_einheiten=None, eingabe_abwe
|
||||
title=titel,
|
||||
subtitle=maschine["name"] or "",
|
||||
maschine=maschine,
|
||||
maschine_badge_id=maschine["id"],
|
||||
bisherige_fmt=fmt_num(bisherige),
|
||||
soll_fmt=fmt_num(auftrag["einheiten"]),
|
||||
abweichungen=abweichungen,
|
||||
@@ -494,6 +524,7 @@ def machine_beenden_confirm(maschine_id):
|
||||
title="Auftrag beenden",
|
||||
subtitle=maschine["name"] or "",
|
||||
maschine=maschine,
|
||||
maschine_badge_id=maschine["id"],
|
||||
soll_fmt=fmt_num(auftrag["einheiten"]),
|
||||
bisherige_fmt=fmt_num(bisherige),
|
||||
)
|
||||
|
||||
@@ -22,4 +22,4 @@
|
||||
</div>
|
||||
{% if maschine_badge_id %}<div class="machine-id-badge">M{{ maschine_badge_id }}</div>{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -61,4 +61,4 @@
|
||||
</table>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user