Files
xk-hy-transit-go/internal/logweb/web/runs_record.html
2026-05-28 16:39:51 +08:00

129 lines
4.7 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title>记录详情</title>
<link rel="stylesheet" href="/static/static.css">
</head>
<body>
<div class="wrap">
<header>
<h1>记录详情 #<span id="rid"></span></h1>
<nav class="nav" id="main-nav"></nav>
</header>
<div class="toolbar" id="summary">
<button type="button" class="primary" id="retry" style="display:none">整条重试</button>
</div>
<div class="panel">
<h3>① 拉取(云端组包 payload_json</h3>
<p class="status-msg">云端拉下的原始明文,可能尚未含本机机构字段。</p>
<pre id="payload"></pre>
</div>
<div class="panel">
<h3>校验 validation_errors</h3>
<pre id="errors"></pre>
</div>
<div class="panel">
<h3>② 推送明文(加密前组包 JSON</h3>
<p class="status-msg">BuildUpload 合并 unitID/organID/organName 后、AES 加密前的业务 JSON。</p>
<pre id="push-plain"></pre>
</div>
<div class="panel">
<h3>③ 推送请求(转发头 + 密文摘要)</h3>
<div id="push-req"></div>
</div>
<div class="panel">
<h3>④ 政务云响应</h3>
<div id="responses"></div>
</div>
<div class="panel">
<h3>⑤ 回调(推断 CallbackItem</h3>
<pre id="callback"></pre>
</div>
</div>
<script src="/static/app.js"></script>
<script>
renderMainNav('runs');
const id = qs('id');
document.getElementById('rid').textContent = id;
function showJSON(el, block, emptyHint) {
if (!block || (!block.raw && !block.formatted)) {
el.textContent = emptyHint || '(空)';
return;
}
el.textContent = block.valid && block.formatted ? block.formatted : (block.raw || '(空)');
}
async function load() {
const d = await api('/api/runs/record?id=' + id);
const r = d.record;
const sumEl = document.getElementById('summary');
const retryBtn = document.getElementById('retry');
let info = document.getElementById('summary-info');
if (!info) {
info = document.createElement('span');
info.id = 'summary-info';
sumEl.insertBefore(info, retryBtn);
}
info.innerHTML =
`锚定日 <b>${esc(r.AnchorDate)}</b> | step <b>${esc(d.step)}</b> | batch_id <b>${r.JobID}</b> | ` +
`biz_key <code>${esc(r.BizKey)}</code> | 重试次数 <b>${r.RetryCount || 0}</b> | 上报 ${badge(r.PushStatus)} | 回调 ${badge(d.callback.callback_status, d.callbackStatusLabel)}`;
if (r.PushStatus === 'failed' || r.PushStatus === 'skipped') {
retryBtn.style.display = '';
retryBtn.onclick = async () => {
if (!confirm('整条重试该记录?')) return;
try {
await retryRecord(id, load);
showToast('重试完成', 'ok');
} catch (e) {
showToast(e.message, 'err');
}
};
} else {
retryBtn.style.display = 'none';
}
showJSON(document.getElementById('payload'), d.payload);
showJSON(document.getElementById('errors'), d.errors);
const plainEl = document.getElementById('push-plain');
if (d.pushPlain && d.pushPlain.raw) {
showJSON(plainEl, d.pushPlain);
} else {
plainEl.textContent = '(历史记录未采集推送明文,请重新执行同步后查看)';
}
const reqEl = document.getElementById('push-req');
if (!d.logViews || !d.logViews.length) {
reqEl.innerHTML = '<pre>(无推送日志)</pre>';
} else {
reqEl.innerHTML = d.logViews.map((lv, i) => {
const hdr = lv.headers && lv.headers.valid && lv.headers.formatted ? lv.headers.formatted : (lv.headers && lv.headers.raw) || '(无请求头)';
const cipher = lv.cipherPreview ? `<p class="status-msg">requestBody 密文摘要(前 200 字符):</p><pre>${esc(lv.cipherPreview)}</pre>` : '';
return `<div style="margin-bottom:0.75rem"><b>请求 #${i + 1}</b> 密文 body 长度 ${lv.log.RequestBodyLen} 字节${cipher}<p class="status-msg">转发请求头(不含 secret</p><pre>${esc(hdr)}</pre></div>`;
}).join('');
}
const respEl = document.getElementById('responses');
if (!d.logViews || !d.logViews.length) {
respEl.innerHTML = '<pre>(无)</pre>';
} else {
respEl.innerHTML = d.logViews.map((lv, i) => {
const l = lv.log;
const respText = lv.response && lv.response.valid && lv.response.formatted ? lv.response.formatted : (lv.response && lv.response.raw) || l.Msg || '';
return `<div class="panel" style="margin:0.5rem 0;border:none">
<h3>HTTP ${l.HTTPCode} msgCode ${l.MsgCode && l.MsgCode.Valid ? l.MsgCode.Int64 : '-'} ${l.DurationMs}ms trace ${esc(l.TraceID)}</h3>
<pre>${esc(respText)}</pre>
</div>`;
}).join('');
}
document.getElementById('callback').textContent = JSON.stringify(d.callback, null, 2);
}
load().catch(e => showToast(e.message, 'err'));
</script>
</body>
</html>