Marius Mutu 650e98539e feat(sync): add SSE live feed, unified logs page, fix Oracle connection
- Add SSE event bus in sync_service (subscribe/unsubscribe/_emit)
- Add GET /api/sync/stream SSE endpoint for real-time sync progress
- Rewrite logs.html: unified runs table + live feed + summary + filters
- Rewrite logs.js: SSE EventSource client, run selection, pagination
- Dashboard: clickable runs navigate to /logs?run=, sync started banner
- Remove "Import Comenzi" nav item, delete sync_detail.html
- Add error_message column to sync_runs table with migration
- Fix: export TNS_ADMIN as OS env var so oracledb finds tnsnames.ora
- Fix: use get_oracle_connection() instead of direct pool.acquire()
- Fix: CRM_POLITICI_PRET_ART INSERT to match actual table schema

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 18:08:09 +02:00
2026-03-11 14:36:13 +02:00
2026-03-11 12:32:25 +02:00
2026-03-11 13:45:21 +02:00
2025-08-26 22:59:58 +03:00
2026-03-05 11:54:29 +02:00
2026-03-10 15:23:12 +02:00

GoMag Vending - Import Comenzi Web → ROA Oracle

System automat de import comenzi din platforma GoMag in sistemul ERP ROA Oracle.

Arhitectura

[GoMag API] → [VFP Orchestrator] → [Oracle PL/SQL] → [FastAPI Admin]
     ↓               ↓                    ↑                  ↑
 JSON Orders    Process & Log        Store/Update      Dashboard + Config

Stack Tehnologic

  • Database: Oracle PL/SQL packages (PACK_IMPORT_PARTENERI, PACK_IMPORT_COMENZI)
  • Integrare: Visual FoxPro 9 (gomag-vending.prg, sync-comenzi-web.prg)
  • Admin/Dashboard: FastAPI + Jinja2 + Oracle pool + SQLite
  • Date: Oracle 11g/12c (schema ROA), SQLite (tracking local)

Quick Start

Prerequisite

  • Python 3.10+
  • Oracle Instant Client (optional - suporta si thin mode)

Instalare si pornire

cd api
pip install -r requirements.txt
# Configureaza .env (vezi api/.env.example)
uvicorn app.main:app --host 0.0.0.0 --port 5003 --reload

Deschide http://localhost:5003 in browser.

Testare

Test A - Basic (fara Oracle):

cd api
python test_app_basic.py

Verifica 17 importuri de module + 13 rute GET. Asteptat: 30/30 PASS.

Test C - Integrare Oracle:

python api/test_integration.py

Necesita Oracle activ. Verifica health, mappings CRUD, article search, validation, sync. Asteptat: 9/9 PASS.

Structura Proiect

/
├── api/                          # FastAPI Admin + Database
│   ├── app/                      # Aplicatia FastAPI
│   │   ├── main.py              # Entry point, lifespan, logging
│   │   ├── config.py            # Settings (pydantic-settings, .env)
│   │   ├── database.py          # Oracle pool + SQLite init
│   │   ├── routers/             # Endpoint-uri HTTP
│   │   │   ├── health.py        # /health, /api/health
│   │   │   ├── dashboard.py     # / (dashboard HTML)
│   │   │   ├── mappings.py      # /mappings, /api/mappings
│   │   │   ├── articles.py      # /api/articles/search
│   │   │   ├── validation.py    # /api/validate/*
│   │   │   └── sync.py          # /api/sync/*
│   │   ├── services/            # Business logic
│   │   │   ├── mapping_service  # CRUD ARTICOLE_TERTI
│   │   │   ├── article_service  # Cautare NOM_ARTICOLE
│   │   │   ├── import_service   # Import comanda in Oracle
│   │   │   ├── sync_service     # Orchestrare: JSON→validate→import
│   │   │   ├── validation_service # Validare SKU-uri
│   │   │   ├── order_reader     # Citire JSON-uri din vfp/output/
│   │   │   ├── sqlite_service   # Tracking runs/orders/missing SKUs
│   │   │   └── scheduler_service # APScheduler timer
│   │   ├── templates/           # Jinja2 HTML (dashboard, mappings, etc.)
│   │   └── static/              # CSS + JS
│   ├── database-scripts/        # Oracle SQL scripts
│   ├── test_app_basic.py        # Test A - fara Oracle
│   ├── test_integration.py      # Test C - cu Oracle
│   └── requirements.txt         # Python dependencies
├── vfp/                          # VFP Integration
│   ├── gomag-vending.prg        # Client GoMag API
│   ├── sync-comenzi-web.prg     # Orchestrator VFP
│   └── utils.prg                # Utilitare VFP
├── docs/                         # Documentatie
│   ├── PRD.md                   # Product Requirements
│   └── stories/                 # User Stories
└── logs/                         # Log-uri aplicatie

Configurare (.env)

ORACLE_USER=MARIUSM_AUTO
ORACLE_PASSWORD=********
ORACLE_DSN=ROA_CENTRAL
FORCE_THIN_MODE=true           # sau INSTANTCLIENTPATH=C:\oracle\instantclient
SQLITE_DB_PATH=data/import.db
APP_PORT=5003
LOG_LEVEL=INFO
JSON_OUTPUT_DIR=../vfp/output

Status Implementare

Phase 1: Database Foundation - COMPLET

  • ARTICOLE_TERTI table + Docker setup
  • PACK_IMPORT_PARTENERI package
  • PACK_IMPORT_COMENZI package

Phase 2: VFP Integration - COMPLET

  • gomag-vending.prg (GoMag API client)
  • sync-comenzi-web.prg (orchestrator cu logging)

Phase 3-4: FastAPI Admin + Dashboard - COMPLET

  • Mappings CRUD + CSV import/export
  • Article autocomplete (NOM_ARTICOLE)
  • Pre-validation SKU-uri
  • Import orchestration (JSON→Oracle)
  • Dashboard cu stat cards, sync control, history
  • Missing SKUs management page
  • File logging (logs/sync_comenzi_*.log)

Phase 5: Production - IN PROGRESS

  • File logging
  • Email notifications (SMTP)
  • HTTP Basic Auth
  • NSSM Windows service
Description
No description provided
Readme 3.6 MiB
Languages
PLSQL 63.8%
Python 23.4%
JavaScript 6.4%
HTML 2.9%
PowerShell 1.4%
Other 2%