From c4fe57c908533c634d830badca58ca05e3b92555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 22 Jun 2026 09:06:06 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=A0=D0=95=D0=9C=D0=95=D0=9D=D0=9D?= =?UTF-8?q?=D0=AB=D0=99=20=D0=9E=D0=A2=D0=9A=D0=90=D0=A2=20=D0=BA=20v1.0.9?= =?UTF-8?q?1=20=E2=80=94=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BA=D0=B8=20=D0=B4=D0=B5=D0=BF=D0=BB=D0=BE=D1=8F?= =?UTF-8?q?.=20=D0=92=D0=B5=D1=80=D0=BD=D1=83=D1=82=D1=8C=20=D1=87=D0=B5?= =?UTF-8?q?=D1=80=D0=B5=D0=B7=20revert.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apply_events.cfm | 107 ++++++++++++--------------------------- deploy/convert_server.py | 22 ++------ index.cfm | 6 ++- reset_contract.cfm | 29 ----------- 4 files changed, 40 insertions(+), 124 deletions(-) delete mode 100644 reset_contract.cfm diff --git a/apply_events.cfm b/apply_events.cfm index 23e4051..fff3ab2 100644 --- a/apply_events.cfm +++ b/apply_events.cfm @@ -16,14 +16,6 @@ - - - SELECT COUNT(*) as cnt FROM spec_events - WHERE supplement_id = - - - - @@ -32,31 +24,28 @@ - - - - - - + - - INSERT INTO spec_events (contract_id, supplement_id, seq, action, target_hash, comment, status) - SELECT - , - , - + ROW_NUMBER() OVER (), - 'DELETE', - name_hash, - 'full_replace', - 'applied' + + SELECT name_hash, name, price, qty, sum, date_start FROM spec_current WHERE contract_id = - - SELECT COUNT(*) as cnt FROM spec_current - WHERE contract_id = - - + + + + INSERT INTO spec_events (contract_id, supplement_id, seq, action, target_hash, comment, status) + VALUES ( + , + , + , + 'DELETE', + , + 'full_replace', + 'applied' + ) + + DELETE FROM spec_current WHERE contract_id = @@ -65,25 +54,6 @@ - - - - - - - - - - - SELECT name_hash, price, qty, sum, date_start FROM spec_current - WHERE contract_id = - AND name_hash IN (,) - - - - - - @@ -91,9 +61,9 @@ - - - + + + @@ -120,34 +90,25 @@ , , , - , + ) - - - - INSERT INTO spec_events (contract_id, supplement_id, seq, action, new_values, comment, status) - VALUES ( - , - , - , - 'UNRESOLVED', - ::jsonb, - , - 'pending' - ) - - - - + + SELECT price, qty, sum, date_start FROM spec_current + WHERE contract_id = + AND name_hash = + + + + - - - + + + @@ -177,7 +138,6 @@ AND name_hash = - @@ -219,7 +179,6 @@ - diff --git a/deploy/convert_server.py b/deploy/convert_server.py index 0e71e4e..04fabf4 100755 --- a/deploy/convert_server.py +++ b/deploy/convert_server.py @@ -7,13 +7,13 @@ class ThreadingHTTPServer(ThreadingMixIn, HTTPServer): """Многопоточный HTTP-сервер.""" daemon_threads = True from urllib.parse import urlparse, parse_qs -import subprocess, tempfile, os, sys, json, time, re +import subprocess, tempfile, os, sys, json, time import httpx from llm_prompt import build_prompt LLM_URL = "https://api.aillm.ru/v1/chat/completions" -LLM_KEY = os.environ.get("LLM_KEY", "") +LLM_KEY = "sk-ucI5YvOticoOQ9Kuj5K9mQ" LLM_MODEL = "gpt-oss-120b" LUCEE_URL = "https://contractor.luceek8s.dev.nubes.ru" @@ -91,10 +91,6 @@ class Handler(BaseHTTPRequestHandler): if not cid: self.send_error(400, "contract_id required") return - # Validate UUID to prevent SQL injection - if not re.fullmatch(r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}', cid, re.I): - self.send_error(400, "invalid contract_id format") - return self.send_response(200) self.send_header("Content-Type", "text/event-stream; charset=utf-8") @@ -107,12 +103,6 @@ class Handler(BaseHTTPRequestHandler): t0 = time.time() try: - # 0. Сброс предыдущих результатов сравнения - r = httpx.get(f"{LUCEE_URL}/reset_contract.cfm?contract_id={cid}", timeout=10) - if r.status_code != 200: - self._sse({"type": "error", "message": f"reset failed: HTTP {r.status_code}"}) - return - # 1. Список supplements supps = self._lucee_query( f"SELECT s.id, s.type, d.filename FROM supplements s " @@ -150,15 +140,9 @@ class Handler(BaseHTTPRequestHandler): if not docs: continue ej = docs[0]["elements_json"] - # Lucee JSONB может вернуть: строку, dict-обёртку {Value,Type}, или уже список if isinstance(ej, dict) and "Value" in ej: ej = ej["Value"] - if isinstance(ej, str): - elements = json.loads(ej) - elif isinstance(ej, list): - elements = ej - else: - elements = [] + elements = json.loads(ej) # Lucee serializeJSON → UPPERCASE keys, normalize to lowercase elements = [{k.lower(): v for k, v in el.items()} for el in elements] lines = [] diff --git a/index.cfm b/index.cfm index b2ee0d0..45675c5 100644 --- a/index.cfm +++ b/index.cfm @@ -71,14 +71,14 @@
Nubes - Сверка договоров — LLM AI-driven Event Sourcing v1.0.104 — Lucee + Сверка договоров — LLM v1.0.91 — Lucee
- Загрузка договоров/приложений/спецификаций + Загрузка договоров приложений спецификаций
@@ -557,7 +557,9 @@ async function showText(i) { } rightHtml += '
Все элементы:
'; rightHtml += '
' + textify + '
'; + rightHtml += '
doc_id' + (f.doc_id || '—') + '
'; if (f.supp_id) { + rightHtml += '
supp_id' + f.supp_id + '
'; rightHtml += '
Тип ДС' + (f.supp_type || '—') + '
'; } } catch(e) { diff --git a/reset_contract.cfm b/reset_contract.cfm deleted file mode 100644 index cd09040..0000000 --- a/reset_contract.cfm +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - DELETE FROM spec_current - WHERE contract_id = - - - DELETE FROM spec_events - WHERE contract_id = - - - - - - - - - -#serializeJSON(result)#