feat: Получение cf_2624 из MySQL и блокировка полей при подтверждении данных
- Добавлен сервис CrmMySQLService для прямого подключения к MySQL CRM - Обновлён метод get_draft() для получения cf_2624 напрямую из БД - Реализована блокировка полей (readonly) при contact_data_confirmed = true - Добавлен выбор банка для СБП выплат с динамической загрузкой из API - Обновлена документация по работе с cf_2624 и MySQL - Добавлен network_mode: host в docker-compose для доступа к MySQL - Обновлены компоненты формы для поддержки блокировки полей
This commit is contained in:
104
docs/n8n_nodes/README_SETUP.md
Normal file
104
docs/n8n_nodes/README_SETUP.md
Normal file
@@ -0,0 +1,104 @@
|
||||
# Настройка OCR Status Tracking в n8n
|
||||
|
||||
## Шаги для добавления нод в workflow `fnSo3FTTbQcMjwt3`
|
||||
|
||||
### 1. Открой workflow в n8n
|
||||
https://n8n.clientright.pro/workflow/fnSo3FTTbQcMjwt3
|
||||
|
||||
### 2. Добавь ноды в следующем порядке:
|
||||
|
||||
#### Нода 1: `update_ocr_status` (PostgreSQL)
|
||||
**Расположение:** После `Postgres PGVector Store1`
|
||||
**Позиция:** [3850, 1664]
|
||||
|
||||
**SQL запрос:**
|
||||
```sql
|
||||
UPDATE clpr_claim_documents
|
||||
SET
|
||||
ocr_status = 'ready',
|
||||
ocr_processed_at = NOW()
|
||||
WHERE id = '{{ $('files').item.json.claim_document_id }}'::uuid
|
||||
RETURNING
|
||||
id AS doc_id,
|
||||
claim_id,
|
||||
ocr_status,
|
||||
(SELECT COUNT(*) FROM clpr_claim_documents WHERE claim_id = clpr_claim_documents.claim_id) AS total_docs,
|
||||
(SELECT COUNT(*) FROM clpr_claim_documents WHERE claim_id = clpr_claim_documents.claim_id AND ocr_status = 'ready') AS ready_docs;
|
||||
```
|
||||
|
||||
**Credentials:** `timeweb_bd` (Postgres account 2)
|
||||
|
||||
---
|
||||
|
||||
#### Нода 2: `redis_incr_ready` (Redis)
|
||||
**Расположение:** После `update_ocr_status`
|
||||
**Позиция:** [4100, 1664]
|
||||
|
||||
**Параметры:**
|
||||
- Operation: `incr`
|
||||
- Key: `claim:ocr:ready:{{ $json.claim_id }}`
|
||||
|
||||
**Credentials:** `Redis account`
|
||||
|
||||
---
|
||||
|
||||
#### Нода 3: `check_all_ready` (IF)
|
||||
**Расположение:** После `redis_incr_ready`
|
||||
**Позиция:** [4350, 1664]
|
||||
|
||||
**Условие:**
|
||||
```
|
||||
{{ $('update_ocr_status').item.json.total_docs }} == {{ $('update_ocr_status').item.json.ready_docs }}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### Нода 4: `publish_docs_ready` (Redis)
|
||||
**Расположение:** TRUE выход из `check_all_ready`
|
||||
**Позиция:** [4600, 1550]
|
||||
|
||||
**Параметры:**
|
||||
- Operation: `publish`
|
||||
- Channel: `clpr:claim:docs_ready`
|
||||
- Message:
|
||||
```javascript
|
||||
{{ JSON.stringify({
|
||||
claim_id: $('update_ocr_status').item.json.claim_id,
|
||||
total_docs: $('update_ocr_status').item.json.total_docs,
|
||||
ready_docs: $('update_ocr_status').item.json.ready_docs,
|
||||
timestamp: new Date().toISOString()
|
||||
}) }}
|
||||
```
|
||||
|
||||
**Credentials:** `Redis account`
|
||||
|
||||
---
|
||||
|
||||
### 3. Соединения (Connections)
|
||||
|
||||
```
|
||||
Postgres PGVector Store1 → update_ocr_status
|
||||
update_ocr_status → redis_incr_ready
|
||||
redis_incr_ready → check_all_ready
|
||||
check_all_ready (TRUE) → publish_docs_ready
|
||||
check_all_ready (FALSE) → (конец)
|
||||
```
|
||||
|
||||
### 4. Сохрани и активируй workflow
|
||||
|
||||
---
|
||||
|
||||
## Проверка
|
||||
|
||||
После добавления нод, при обработке документа:
|
||||
1. Статус в `clpr_claim_documents.ocr_status` будет меняться на `'ready'`
|
||||
2. Счётчик в Redis `claim:ocr:ready:{claim_id}` будет инкрементиться
|
||||
3. Когда все документы готовы, событие `clpr:claim:docs_ready` будет опубликовано в Redis
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
37
docs/n8n_nodes/check_all_ready.json
Normal file
37
docs/n8n_nodes/check_all_ready.json
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "check_all_ready",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [4350, 1664],
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict",
|
||||
"version": 2
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "ocr-ready-check-001",
|
||||
"leftValue": "={{ $('update_ocr_status').item.json.total_docs }}",
|
||||
"rightValue": "={{ $('update_ocr_status').item.json.ready_docs }}",
|
||||
"operator": {
|
||||
"type": "number",
|
||||
"operation": "equals"
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
},
|
||||
"options": {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
25
docs/n8n_nodes/publish_docs_ready.json
Normal file
25
docs/n8n_nodes/publish_docs_ready.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "publish_docs_ready",
|
||||
"type": "n8n-nodes-base.redis",
|
||||
"typeVersion": 1,
|
||||
"position": [4600, 1550],
|
||||
"parameters": {
|
||||
"operation": "publish",
|
||||
"channel": "clpr:claim:docs_ready",
|
||||
"messageData": "={{ JSON.stringify({ claim_id: $('update_ocr_status').item.json.claim_id, total_docs: $('update_ocr_status').item.json.total_docs, ready_docs: $('update_ocr_status').item.json.ready_docs, timestamp: new Date().toISOString() }) }}"
|
||||
},
|
||||
"credentials": {
|
||||
"redis": {
|
||||
"id": "F2IkIEYT9O7UTtz9",
|
||||
"name": "Redis account"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
24
docs/n8n_nodes/redis_incr_ready.json
Normal file
24
docs/n8n_nodes/redis_incr_ready.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "redis_incr_ready",
|
||||
"type": "n8n-nodes-base.redis",
|
||||
"typeVersion": 1,
|
||||
"position": [4100, 1664],
|
||||
"parameters": {
|
||||
"operation": "incr",
|
||||
"key": "=claim:ocr:ready:{{ $json.claim_id }}"
|
||||
},
|
||||
"credentials": {
|
||||
"redis": {
|
||||
"id": "F2IkIEYT9O7UTtz9",
|
||||
"name": "Redis account"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
26
docs/n8n_nodes/update_ocr_error.json
Normal file
26
docs/n8n_nodes/update_ocr_error.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "update_ocr_error",
|
||||
"type": "n8n-nodes-base.postgres",
|
||||
"typeVersion": 2.6,
|
||||
"position": [3850, 1850],
|
||||
"parameters": {
|
||||
"operation": "executeQuery",
|
||||
"query": "-- Обновляем статус OCR при ошибке\nUPDATE clpr_claim_documents\nSET \n ocr_status = 'error',\n ocr_error = '{{ $json.error || \"OCR processing failed\" }}',\n ocr_processed_at = NOW()\nWHERE id = '{{ $('files').item.json.claim_document_id }}'::uuid\nRETURNING id, claim_id, ocr_status, ocr_error;",
|
||||
"options": {}
|
||||
},
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "sGJ0fJhU8rz88w3k",
|
||||
"name": "timeweb_bd"
|
||||
}
|
||||
},
|
||||
"onError": "continueRegularOutput"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
25
docs/n8n_nodes/update_ocr_status.json
Normal file
25
docs/n8n_nodes/update_ocr_status.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "update_ocr_status",
|
||||
"type": "n8n-nodes-base.postgres",
|
||||
"typeVersion": 2.6,
|
||||
"position": [3850, 1664],
|
||||
"parameters": {
|
||||
"operation": "executeQuery",
|
||||
"query": "-- Обновляем статус OCR для документа и возвращаем счётчики\nUPDATE clpr_claim_documents\nSET \n ocr_status = 'ready',\n ocr_processed_at = NOW()\nWHERE id = '{{ $('files').item.json.claim_document_id }}'::uuid\nRETURNING \n id AS doc_id,\n claim_id,\n ocr_status,\n (SELECT COUNT(*) FROM clpr_claim_documents WHERE claim_id = clpr_claim_documents.claim_id) AS total_docs,\n (SELECT COUNT(*) FROM clpr_claim_documents WHERE claim_id = clpr_claim_documents.claim_id AND ocr_status = 'ready') AS ready_docs;",
|
||||
"options": {}
|
||||
},
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "sGJ0fJhU8rz88w3k",
|
||||
"name": "timeweb_bd"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user