fix status val
This commit is contained in:
@@ -45,7 +45,7 @@ async def worker(worker_id: int, cfg: object, pool: object) -> None:
|
||||
if 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
|
||||
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['statustools'].lower() in cfg.elab_status:
|
||||
logger.info(f"Elaborazione id {id} per {unit_name} {tool_name} ")
|
||||
|
||||
@@ -42,7 +42,7 @@ async def worker(worker_id: int, cfg: object, pool: object) -> None:
|
||||
|
||||
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, 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']:
|
||||
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:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class WorkflowFlags:
|
||||
CSV_RECEIVED = 0 # 0000
|
||||
DATA_LOADED = 1 # 0001
|
||||
DATA_ELABORATED = 2 # 0010
|
||||
SENT_RAW_DATA = 4 # 0100
|
||||
SENT_ELAB_DATA = 8 # 1000
|
||||
DUMMY_ELABORATED = 16 # 10000
|
||||
START_ELAB = 32 # 100000
|
||||
START_ELAB = 2 # 0010
|
||||
DATA_ELABORATED = 4 # 0100
|
||||
SENT_RAW_DATA = 8 # 1000
|
||||
SENT_ELAB_DATA = 16 # 10000
|
||||
DUMMY_ELABORATED = 32 # 100000
|
||||
|
||||
# Mappatura flag -> colonna timestamp
|
||||
FLAG_TO_TIMESTAMP = {
|
||||
|
||||
@@ -42,24 +42,28 @@ 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,
|
||||
or None if no information is found for the given unit and tool.
|
||||
"""
|
||||
|
||||
async with pool.acquire() as conn:
|
||||
async with conn.cursor(aiomysql.DictCursor) as cur:
|
||||
await cur.execute(f"""
|
||||
SELECT {sub_select[next_status]}
|
||||
FROM matfuncs AS m
|
||||
INNER JOIN tools AS t ON t.matfunc = m.id
|
||||
INNER JOIN units AS u ON u.id = t.unit_id
|
||||
INNER JOIN statustools AS s ON t.statustool_id = s.id
|
||||
WHERE t.name = '{tool}' AND u.name = '{unit}';
|
||||
""")
|
||||
try:
|
||||
await cur.execute(f"""
|
||||
SELECT {sub_select[next_status]}
|
||||
FROM matfuncs AS m
|
||||
INNER JOIN tools AS t ON t.matfunc = m.id
|
||||
INNER JOIN units AS u ON u.id = t.unit_id
|
||||
INNER JOIN statustools AS s ON t.statustool_id = s.id
|
||||
WHERE t.name = '{tool}' AND u.name = '{unit}';
|
||||
""")
|
||||
|
||||
result = await cur.fetchone()
|
||||
result = await cur.fetchone()
|
||||
|
||||
if not result:
|
||||
logger.error(f"{unit} - {tool}: Tool info not found.")
|
||||
return None
|
||||
else:
|
||||
return result
|
||||
if not result:
|
||||
logger.error(f"{unit} - {tool}: Tool info not found.")
|
||||
return None
|
||||
else:
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user