Corrige Gantt, adiciona escala de voo real e ajusta solver (v0.9)

- visualizar_resultado: barras Gantt via go.Scatter lines (renderizacao
  garantida), yaxis range fixo para FAB 2800 visivel, largura minima 2h
- oamrp_v3: parser --escala para Escala de Voo Modelo 1 (CSV real),
  coordenadas de 26 bases, time-limit default 5min, imports timedelta/date

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Cesa-V
2026-06-16 09:34:14 -03:00
parent 3756f961a8
commit 83a2dac624
4 changed files with 177 additions and 33 deletions

View File

@@ -234,7 +234,7 @@ def _construir_gantt(linhas: list[dict]) -> str:
)
shapes = []
hover_traces = []
bar_traces = []
for r in linhas:
k = r["aeronave"]
@@ -246,20 +246,15 @@ def _construir_gantt(linhas: list[dict]) -> str:
except Exception:
continue
ini_dt = datetime.fromisoformat(ini)
fim_dt = datetime.fromisoformat(fim)
if (fim_dt - ini_dt).total_seconds() < 2 * 3600:
fim_dt = ini_dt + timedelta(hours=2)
yi = y_pos[k]
cor = _cor_gantt(r)
status = r["status"]
shapes.append(dict(
type="rect", xref="x", yref="y",
x0=ini, x1=fim,
y0=yi - 0.4, y1=yi + 0.4,
fillcolor=cor,
line=dict(color="white", width=0.5),
opacity=1.0 if status == "inspecao" else 0.85,
layer="above",
))
if status == "inspecao":
txt = (
f"<b>FAB {k}</b> — Inspeção {r['om']}<br>"
@@ -276,10 +271,16 @@ def _construir_gantt(linhas: list[dict]) -> str:
f"Chegada: {fim[:16].replace('T',' ')}Z<br>"
f"Duração: {r['dur_h']}h"
)
hover_traces.append(go.Scatter(
x=[ini, fim], y=[yi, yi], mode="markers",
marker=dict(size=0.1, color=cor, opacity=0),
hovertext=[txt, txt], hoverinfo="text", showlegend=False,
# Barra como linha horizontal grossa — renderiza garantido no eixo de datas
bar_traces.append(go.Scatter(
x=[ini_dt, fim_dt],
y=[yi, yi],
mode="lines",
line=dict(color=cor, width=64),
hovertext=[txt, txt],
hoverinfo="text",
showlegend=False,
))
# Divisões diárias
@@ -318,7 +319,7 @@ def _construir_gantt(linhas: list[dict]) -> str:
name=nome, showlegend=True,
))
for t in hover_traces:
for t in bar_traces:
fig.add_trace(t)
fig.update_layout(
@@ -333,6 +334,7 @@ def _construir_gantt(linhas: list[dict]) -> str:
tickvals=list(range(len(aeronaves_ord))),
ticktext=[f"FAB {k}" for k in aeronaves_ord],
showgrid=False,
range=[-0.5, len(aeronaves_ord) - 0.5],
),
height=max(300, 120 + 80 * len(aeronaves_ord)),
plot_bgcolor="white",