fix send ftp e api

This commit is contained in:
2025-08-10 16:47:04 +02:00
parent cfb185e029
commit dbe2e7f5a7
2 changed files with 206 additions and 23 deletions

View File

@@ -9,10 +9,10 @@ from utils.config import loader_send_data as setting
from utils.database import WorkflowFlags
from utils.csv.loaders import get_next_csv_atomic
from utils.orchestrator_utils import run_orchestrator, worker_context
from utils.database.loader_action import update_status, unlock
from utils.database.action_query import get_data_as_csv, get_tool_info, get_elab_timestamp
from utils.database.action_query import process_workflow_record
from utils.general import alterna_valori
#from utils.ftp.elab_send import send_csv_to_customer
#from utils.ftp.send_data import ftp_send_elab_csv_to_customer, api_send_elab_csv_to_customer, ftp_send_raw_csv_to_customer, api_send_raw_csv_to_customer
# Initialize the logger for this module
@@ -41,22 +41,8 @@ async def worker(worker_id: int, cfg: object, pool: object) -> None:
record = await get_next_csv_atomic(pool, cfg.dbrectable, status, fase)
if record:
id, unit_type, tool_type, unit_name, tool_name = [x.lower().replace(" ", "_") if isinstance(x, str) else x for x in record]
tool_elab_info = await get_tool_info(fase, unit_name.upper(), tool_name.upper(), pool)
if fase == WorkflowFlags.SENT_ELAB_DATA and tool_elab_info['ftp_send']:
timestamp_matlab_elab = get_elab_timestamp(id, pool)
if not tool_elab_info["duedate"] or tool_elab_info["duedate"] in ('0000-00-00 00:00:00', '') or tool_elab_info["duedate"] > timestamp_matlab_elab:
if elab_csv := await get_data_as_csv(cfg, id, unit_name, tool_name, timestamp_matlab_elab, pool):
print(elab_csv)
#if await send_csv_to_customer(cfg, id, unit_name, tool_name, elab_csv, pool):
if True:
await update_status(cfg, id, WorkflowFlags.SENT_ELAB_DATA, pool)
else:
logger.info(f"id {id} - {unit_name} - {tool_name} {tool_elab_info['duedate']}: ftp put didn't executed because due date reached.")
elif fase == WorkflowFlags.SENT_RAW_DATA and tool_elab_info['ftp_send_raw']:
...
await unlock(cfg, id, pool)
await process_workflow_record(record, fase, cfg, pool)
await asyncio.sleep(ELAB_PROCESSING_DELAY)
else:
logger.info("Nessun record disponibile")
await asyncio.sleep(NO_RECORD_SLEEP)