feat: Introduce bot-descarga service for PDF downloads and remote bot control. Add Docker configuration, environment variables, and a GUI for agent management. Enhance README with bot details and installation instructions.
This commit is contained in:
+76
-4
@@ -9,8 +9,8 @@ Project ipsextractor {
|
||||
database_type: 'PostgreSQL'
|
||||
Note: '''
|
||||
Base de datos compartida entre todos los microservicios (extraction, cleaning,
|
||||
count-facturas). Cada servicio accede directamente a las tablas que necesita.
|
||||
Las migraciones se gestionan con Alembic (services/extraction/alembic/).
|
||||
count-facturas, bot-descarga). Cada servicio accede directamente a las tablas
|
||||
que necesita. Las migraciones se gestionan con Alembic (services/db/alembic/).
|
||||
Cada servicio es desacoplado; comparten solo la DB como fuente de verdad.
|
||||
'''
|
||||
}
|
||||
@@ -35,6 +35,12 @@ TableGroup counting {
|
||||
count_job_files
|
||||
}
|
||||
|
||||
TableGroup bot_descarga {
|
||||
download_workers
|
||||
download_jobs
|
||||
download_job_events
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Orchestration — trabajo multimodular del usuario
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -61,7 +67,7 @@ Table jobs {
|
||||
Table tasks {
|
||||
id varchar(36) [pk, note: 'UUID v4']
|
||||
job_id varchar(36) [ref: > jobs.id, note: 'FK nullable — compat. con tasks anteriores']
|
||||
type varchar(64) [not null, note: 'counting | extraction | cleaning']
|
||||
type varchar(64) [not null, note: 'counting | extraction | cleaning | downloads']
|
||||
status varchar(32) [not null, default: 'pending', note: 'pending | running | completed | failed']
|
||||
title text
|
||||
request jsonb [not null, default: '{}', note: 'Payload de la petición que originó la tarea']
|
||||
@@ -82,11 +88,77 @@ Table tasks {
|
||||
|
||||
Note: '''
|
||||
Módulo/resultado dentro de un Job. Una task representa la ejecución
|
||||
de un servicio específico (conteo, extracción, limpieza).
|
||||
de un servicio específico (conteo, extracción, limpieza, bot de descarga).
|
||||
job_id es nullable para compatibilidad con tasks creadas antes de jobs.
|
||||
'''
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Bot de descarga — workers remotos + corridas PDF → MinIO
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Table download_workers {
|
||||
id varchar(36) [pk, note: 'ID del agent (ej. PC-01 / zer0)']
|
||||
hostname text [not null, default: '']
|
||||
max_concurrent integer [not null, default: 1]
|
||||
status varchar(32) [not null, note: 'online | offline | busy']
|
||||
last_heartbeat timestamptz [not null]
|
||||
current_job_id varchar(36) [note: 'download_jobs.id en ejecución']
|
||||
|
||||
indexes {
|
||||
status
|
||||
}
|
||||
|
||||
Note: 'PC remota registrada por el agent BotDescarga (heartbeat).'
|
||||
}
|
||||
|
||||
Table download_jobs {
|
||||
id varchar(36) [pk, note: 'UUID v4 de la corrida']
|
||||
job_id varchar(36) [null, ref: > jobs.id, note: 'Job Desktop contenedor']
|
||||
task_id varchar(36) [null, ref: > tasks.id, note: 'Task type=downloads']
|
||||
worker_id varchar(36) [not null, note: 'download_workers.id asignado']
|
||||
status varchar(32) [not null, default: 'pending', note: 'pending | running | completed | failed | cancelled']
|
||||
title text
|
||||
excel_key text [not null, default: '', note: 'Clave MinIO del Excel']
|
||||
downloads_prefix text [not null, default: '', note: 'downloads/{id}/']
|
||||
original_filename text [not null, default: '']
|
||||
cancel_requested boolean [not null, default: false]
|
||||
result jsonb [not null, default: '{}']
|
||||
error text
|
||||
created_at timestamptz [not null]
|
||||
started_at timestamptz
|
||||
finished_at timestamptz
|
||||
|
||||
indexes {
|
||||
job_id
|
||||
task_id
|
||||
worker_id
|
||||
status
|
||||
(worker_id, status) [name: 'ix_download_jobs_worker_status']
|
||||
}
|
||||
|
||||
Note: 'Corrida de descarga remota. PDFs en MinIO bajo downloads/{id}/.'
|
||||
}
|
||||
|
||||
Table download_job_events {
|
||||
id integer [pk, increment]
|
||||
download_job_id varchar(36) [not null, ref: > download_jobs.id]
|
||||
event_type varchar(64) [not null]
|
||||
message text [not null]
|
||||
timestamp timestamptz [not null]
|
||||
radicado varchar(255)
|
||||
nit varchar(64)
|
||||
idx integer
|
||||
total integer
|
||||
metadata jsonb [not null, default: '{}']
|
||||
|
||||
indexes {
|
||||
(download_job_id, id) [name: 'ix_download_job_events_job_id']
|
||||
}
|
||||
|
||||
Note: 'Log incremental de progreso / errores de una corrida.'
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Counting — resultados del servicio de conteo de facturas médicas
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user