Fix error display: show TNS response separately, default filter contrato=011
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
da99a446f1
commit
e477aa2bea
@@ -234,13 +234,18 @@ async def test_enviar(request: Request, user: dict = Depends(get_current_user)):
|
|||||||
examenes = [r.get("COD_EXAMEN", "") for r in grupo_rows]
|
examenes = [r.get("COD_EXAMEN", "") for r in grupo_rows]
|
||||||
try:
|
try:
|
||||||
r = await client.post(endpoint_rda, json=rda_json, headers=headers)
|
r = await client.post(endpoint_rda, json=rda_json, headers=headers)
|
||||||
|
raw_resp = r.text
|
||||||
try:
|
try:
|
||||||
data = r.json()
|
data = r.json()
|
||||||
ok_rda = (data.get("status") or (data.get("data") or {}).get("success", False)) if isinstance(data, dict) else False
|
ok_rda = bool(data.get("status") or (data.get("data") or {}).get("success", False)) if isinstance(data, dict) else False
|
||||||
msg_rda = ((data.get("data") or {}).get("response") or data.get("message") or r.text[:200])
|
msg_rda = (
|
||||||
|
((data.get("data") or {}).get("response"))
|
||||||
|
or data.get("message")
|
||||||
|
or raw_resp[:300]
|
||||||
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
ok_rda = r.status_code < 300
|
ok_rda = r.status_code < 300
|
||||||
msg_rda = r.text[:200]
|
msg_rda = raw_resp[:300]
|
||||||
pasos.append({
|
pasos.append({
|
||||||
"tipo": "rda",
|
"tipo": "rda",
|
||||||
"idrecepcion": id_rec,
|
"idrecepcion": id_rec,
|
||||||
@@ -251,6 +256,7 @@ async def test_enviar(request: Request, user: dict = Depends(get_current_user)):
|
|||||||
"status": r.status_code,
|
"status": r.status_code,
|
||||||
"ok": ok_rda,
|
"ok": ok_rda,
|
||||||
"mensaje": msg_rda,
|
"mensaje": msg_rda,
|
||||||
|
"respuesta_tns": raw_resp,
|
||||||
"json_enviado": rda_json,
|
"json_enviado": rda_json,
|
||||||
})
|
})
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<div class="px-6 py-4 border-b border-gray-200 flex items-center justify-between">
|
<div class="px-6 py-4 border-b border-gray-200 flex items-center justify-between">
|
||||||
<h3 class="font-semibold text-gray-800"><i class="fas fa-list mr-2 text-blue-500"></i>Candidatos disponibles</h3>
|
<h3 class="font-semibold text-gray-800"><i class="fas fa-list mr-2 text-blue-500"></i>Candidatos disponibles</h3>
|
||||||
<div class="flex gap-2 items-center flex-wrap">
|
<div class="flex gap-2 items-center flex-wrap">
|
||||||
<input id="filtro-contrato" type="text" placeholder="Contrato (ej: 011)"
|
<input id="filtro-contrato" type="text" placeholder="Contrato (ej: 011)" value="011"
|
||||||
class="px-3 py-1.5 border border-gray-300 rounded-lg text-sm w-32">
|
class="px-3 py-1.5 border border-gray-300 rounded-lg text-sm w-32">
|
||||||
<input id="filtro-articulos" type="text" placeholder="Artículos (ej: CH4,TSH,GLI)"
|
<input id="filtro-articulos" type="text" placeholder="Artículos (ej: CH4,TSH,GLI)"
|
||||||
class="px-3 py-1.5 border border-gray-300 rounded-lg text-sm w-56"
|
class="px-3 py-1.5 border border-gray-300 rounded-lg text-sm w-56"
|
||||||
@@ -189,6 +189,9 @@ async function enviarRDA() {
|
|||||||
} else {
|
} else {
|
||||||
const jsonStr = JSON.stringify(p.json_enviado || {}, null, 2);
|
const jsonStr = JSON.stringify(p.json_enviado || {}, null, 2);
|
||||||
const uid = 'json_' + p.idrecepcion;
|
const uid = 'json_' + p.idrecepcion;
|
||||||
|
const uid2 = 'resp_' + p.idrecepcion;
|
||||||
|
let respTns = '';
|
||||||
|
try { respTns = JSON.stringify(JSON.parse(p.respuesta_tns || '{}'), null, 2); } catch(e) { respTns = p.respuesta_tns || ''; }
|
||||||
html += `
|
html += `
|
||||||
<div class="rounded-lg border ${p.ok ? 'border-green-200 bg-green-50' : 'border-red-200 bg-red-50'}">
|
<div class="rounded-lg border ${p.ok ? 'border-green-200 bg-green-50' : 'border-red-200 bg-red-50'}">
|
||||||
<div class="flex items-start gap-3 p-3">
|
<div class="flex items-start gap-3 p-3">
|
||||||
@@ -198,16 +201,21 @@ async function enviarRDA() {
|
|||||||
IDRECEPCION <span class="font-mono text-blue-700">${p.idrecepcion}</span>
|
IDRECEPCION <span class="font-mono text-blue-700">${p.idrecepcion}</span>
|
||||||
· Factura <span class="font-mono">${p.factura}</span>
|
· Factura <span class="font-mono">${p.factura}</span>
|
||||||
· Contrato <span class="font-mono text-purple-700">${p.contrato}</span>
|
· Contrato <span class="font-mono text-purple-700">${p.contrato}</span>
|
||||||
|
<span class="text-gray-400 text-xs ml-1">HTTP ${p.status || '?'}</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="text-xs text-gray-500 mt-0.5">Exámenes: ${(p.examenes || []).join(', ')}</p>
|
<p class="text-xs text-gray-500 mt-0.5">Exámenes: ${(p.examenes || []).join(', ')}</p>
|
||||||
<div class="mt-1.5 px-3 py-2 rounded ${p.ok ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800'} text-sm font-medium break-words">
|
<div class="mt-2 px-3 py-2 rounded-lg border ${p.ok ? 'border-green-300 bg-green-100 text-green-900' : 'border-red-300 bg-red-100 text-red-900'} text-sm font-semibold">
|
||||||
${p.ok ? '✅' : '❌'} ${p.mensaje || '(sin mensaje)'}
|
${p.mensaje || '(sin mensaje de TNS)'}
|
||||||
</div>
|
</div>
|
||||||
${!p.ok ? `<p class="text-xs text-gray-400 mt-1">HTTP ${p.status || '?'}</p>` : ''}
|
|
||||||
</div>
|
</div>
|
||||||
<button onclick="document.getElementById('${uid}').classList.toggle('hidden')"
|
<div class="flex flex-col gap-1 shrink-0">
|
||||||
class="px-2 py-1 text-xs bg-gray-100 hover:bg-gray-200 text-gray-600 rounded shrink-0">Ver JSON</button>
|
<button onclick="document.getElementById('${uid2}').classList.toggle('hidden')"
|
||||||
|
class="px-2 py-1 text-xs bg-yellow-100 hover:bg-yellow-200 text-yellow-800 rounded">Resp. TNS</button>
|
||||||
|
<button onclick="document.getElementById('${uid}').classList.toggle('hidden')"
|
||||||
|
class="px-2 py-1 text-xs bg-gray-100 hover:bg-gray-200 text-gray-600 rounded">JSON env.</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<pre id="${uid2}" class="hidden mx-3 mb-1 p-3 bg-yellow-950 text-yellow-200 rounded text-xs overflow-x-auto whitespace-pre-wrap">${respTns.replace(/</g,'<')}</pre>
|
||||||
<pre id="${uid}" class="hidden mx-3 mb-3 p-3 bg-gray-900 text-green-300 rounded text-xs overflow-x-auto whitespace-pre-wrap">${jsonStr.replace(/</g,'<')}</pre>
|
<pre id="${uid}" class="hidden mx-3 mb-3 p-3 bg-gray-900 text-green-300 rounded text-xs overflow-x-auto whitespace-pre-wrap">${jsonStr.replace(/</g,'<')}</pre>
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user