diff --git a/index.cfm b/index.cfm
index 6592ab6..d3fd4f9 100644
--- a/index.cfm
+++ b/index.cfm
@@ -75,7 +75,7 @@

-
Сверка договоров — LLM AI-driven Event Sourcing v1.0.155 — Lucee
+
Сверка договоров — LLM AI-driven Event Sourcing v1.0.156 — Lucee
@@ -339,26 +339,15 @@ fileInput.addEventListener('change', async function() {
if (!contractId && zf.contract_id) contractId = zf.contract_id;
renderTable();
- // Авто-парсинг
- var zIsPdf = zf.filename && zf.filename.toLowerCase().endsWith('.pdf');
- if (zIsPdf && zf.PARSED && zf.PARSED.STATUS === 'parsed') {
+ // Авто-парсинг: VM Python парсит ВСЁ
+ var zpr = zf.parsed;
+ if (zpr && zpr.status === 'parsed') {
fileQueue[zIdx].parsed = true;
- fileQueue[zIdx].status = '✓ ' + zf.PARSED.ELEMENT_COUNT + ' эл.';
- } else if (zIsPdf) {
- fileQueue[zIdx].status = '✗ ' + ((zf.PARSED && zf.PARSED.ERROR) || 'ошибка') + '';
+ fileQueue[zIdx].status = '✓ ' + zpr.element_count + ' эл.';
+ } else if (zpr && zpr.status === 'error') {
+ fileQueue[zIdx].status = '✗ ' + (zpr.error || 'ошибка парсинга') + '';
} else {
- try {
- var zpr = await fetch('/parser.cfm?doc_id=' + zf.doc_id);
- var zpd = await zpr.json();
- if (zpd.OK && zpd.STATUS === 'parsed') {
- fileQueue[zIdx].parsed = true;
- fileQueue[zIdx].status = '✓ ' + zpd.ELEMENT_COUNT + ' эл.';
- } else {
- fileQueue[zIdx].status = '✗ ' + (zpd.ERROR_COUNT > 0 ? (zpd.ERRORS && zpd.ERRORS[0] || 'ошибка') : 'ошибка') + '';
- }
- } catch(zpe) {
- fileQueue[zIdx].status = '✗ парсинг: сеть';
- }
+ fileQueue[zIdx].status = '✗ Неизвестная ошибка';
}
renderTable();
}
@@ -390,40 +379,25 @@ fileInput.addEventListener('change', async function() {
fileQueue[rowIdx].status = '↑ ' + pct + '%';
renderTable();
});
- if (resp && resp.CONTRACT_ID) contractId = resp.CONTRACT_ID;
- fileQueue[rowIdx].doc_id = resp.DOC_ID;
+ // Python API returns lowercase keys (doc_id, contract_id, parsed)
+ if (resp && resp.contract_id) contractId = resp.contract_id;
+ fileQueue[rowIdx].doc_id = resp.doc_id;
fileQueue[rowIdx].status = '✓';
fileQueue[rowIdx].uploaded = true;
- // Авто-парсинг: PDF → VM, остальное → Lucee parser.cfm
- var isPdf = f.name.toLowerCase().endsWith('.pdf');
+ // Авто-парсинг: VM Python парсит ВСЁ (PDF + DOCX + DOC)
var t0 = Date.now();
- if (isPdf && resp.PARSED && resp.PARSED.STATUS === 'parsed') {
+ var pr = resp.parsed;
+ if (pr && pr.status === 'parsed') {
var elapsed = ((Date.now() - t0) / 1000).toFixed(1);
fileQueue[rowIdx].parsed = true;
- fileQueue[rowIdx].parseInfo = resp.PARSED;
- fileQueue[rowIdx].status = '✓ ' + resp.PARSED.ELEMENT_COUNT + ' эл. (' + elapsed + 'с)';
- } else if (isPdf) {
- fileQueue[rowIdx].status = '✗ ' + ((resp.PARSED && resp.PARSED.ERROR) || 'ошибка') + '';
+ fileQueue[rowIdx].parseInfo = pr;
+ fileQueue[rowIdx].status = '✓ ' + pr.element_count + ' эл. (' + elapsed + 'с)';
+ } else if (pr && pr.status === 'error') {
+ fileQueue[rowIdx].status = '✗ ' + (pr.error || 'ошибка парсинга') + '';
+ fileQueue[rowIdx].parseInfo = pr;
} else {
- // DOCX/DOC → Lucee Apache POI
- fileQueue[rowIdx].status = '⏳ парсинг...';
- renderTable();
- try {
- var pr = await fetch('/parser.cfm?doc_id=' + resp.DOC_ID);
- var pd = await pr.json();
- var elapsed = ((Date.now() - t0) / 1000).toFixed(1);
- if (pd.OK && pd.STATUS === 'parsed') {
- fileQueue[rowIdx].parsed = true;
- fileQueue[rowIdx].parseInfo = pd;
- fileQueue[rowIdx].status = '✓ ' + pd.ELEMENT_COUNT + ' эл. (' + elapsed + 'с)';
- } else {
- fileQueue[rowIdx].status = '✗ ' + (pd.ERROR_COUNT > 0 ? (pd.ERRORS && pd.ERRORS[0] || 'ошибка') : 'ошибка') + '';
- fileQueue[rowIdx].parseInfo = pd;
- }
- } catch(pe) {
- fileQueue[rowIdx].status = '✗ парсинг: сеть';
- }
+ fileQueue[rowIdx].status = '✗ Неизвестная ошибка';
}
} catch(err) {
fileQueue[rowIdx].status = '✗ ' + err.message + '';