fix status val

This commit is contained in:
2025-08-09 20:14:20 +02:00
parent 3a3b63e360
commit cfb185e029
4 changed files with 25 additions and 21 deletions

View File

@@ -45,7 +45,7 @@ async def worker(worker_id: int, cfg: object, pool: object) -> None:
if record: if record:
id, unit_type, tool_type, unit_name, tool_name = [x.lower().replace(" ", "_") if isinstance(x, str) else x for x in record] id, unit_type, tool_type, unit_name, tool_name = [x.lower().replace(" ", "_") if isinstance(x, str) else x for x in record]
if tool_type.lower() != "gd": # i tool GD non devono essere elaborati if tool_type.lower() != "gd": # i tool GD non devono essere elaborati
tool_elab_info = await get_tool_info(WorkflowFlags.DATA_ELABORATED, tool_name.upper(), unit_name.upper(), pool) tool_elab_info = await get_tool_info(WorkflowFlags.DATA_ELABORATED, unit_name.upper(), tool_name.upper(), pool)
if tool_elab_info: if tool_elab_info:
if tool_elab_info['statustools'].lower() in cfg.elab_status: if tool_elab_info['statustools'].lower() in cfg.elab_status:
logger.info(f"Elaborazione id {id} per {unit_name} {tool_name} ") logger.info(f"Elaborazione id {id} per {unit_name} {tool_name} ")

View File

@@ -42,7 +42,7 @@ async def worker(worker_id: int, cfg: object, pool: object) -> None:
if record: if record:
id, unit_type, tool_type, unit_name, tool_name = [x.lower().replace(" ", "_") if isinstance(x, str) else x for x in 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, tool_name, pool) 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']: if fase == WorkflowFlags.SENT_ELAB_DATA and tool_elab_info['ftp_send']:
timestamp_matlab_elab = get_elab_timestamp(id, pool) 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 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:

View File

@@ -1,11 +1,11 @@
class WorkflowFlags: class WorkflowFlags:
CSV_RECEIVED = 0 # 0000 CSV_RECEIVED = 0 # 0000
DATA_LOADED = 1 # 0001 DATA_LOADED = 1 # 0001
DATA_ELABORATED = 2 # 0010 START_ELAB = 2 # 0010
SENT_RAW_DATA = 4 # 0100 DATA_ELABORATED = 4 # 0100
SENT_ELAB_DATA = 8 # 1000 SENT_RAW_DATA = 8 # 1000
DUMMY_ELABORATED = 16 # 10000 SENT_ELAB_DATA = 16 # 10000
START_ELAB = 32 # 100000 DUMMY_ELABORATED = 32 # 100000
# Mappatura flag -> colonna timestamp # Mappatura flag -> colonna timestamp
FLAG_TO_TIMESTAMP = { FLAG_TO_TIMESTAMP = {

View File

@@ -42,8 +42,10 @@ async def get_tool_info(next_status: int, unit: str, tool: str, pool: object) ->
tuple: A dictionary-like object (aiomysql.DictCursor result) containing the tool information, tuple: A dictionary-like object (aiomysql.DictCursor result) containing the tool information,
or None if no information is found for the given unit and tool. or None if no information is found for the given unit and tool.
""" """
async with pool.acquire() as conn: async with pool.acquire() as conn:
async with conn.cursor(aiomysql.DictCursor) as cur: async with conn.cursor(aiomysql.DictCursor) as cur:
try:
await cur.execute(f""" await cur.execute(f"""
SELECT {sub_select[next_status]} SELECT {sub_select[next_status]}
FROM matfuncs AS m FROM matfuncs AS m
@@ -60,6 +62,8 @@ async def get_tool_info(next_status: int, unit: str, tool: str, pool: object) ->
return None return None
else: else:
return result return result
except Exception as e:
logger.error(f"Error: {e}")
async def get_data_as_csv(cfg: dict, id_recv: int, unit: str, tool: str, matlab_timestamp: float, pool: object) -> str: async def get_data_as_csv(cfg: dict, id_recv: int, unit: str, tool: str, matlab_timestamp: float, pool: object) -> str: