refactor: Implement equipment data services with dynamic SQL query generation and category rollup logic.

main
MrWaradana 3 weeks ago
parent c630d0b135
commit 389449d10a

@ -130,7 +130,7 @@ async def _fetch_joined_maximo_records(
JOINED_MAXIMO_SQL = text( JOINED_MAXIMO_SQL = text(
f""" f"""
SELECT * SELECT *, a.wonum
FROM public.wo_maximo a FROM public.wo_maximo a
LEFT JOIN public.wo_maximo_labtrans b LEFT JOIN public.wo_maximo_labtrans b
ON b.wonum = a.wonum ON b.wonum = a.wonum

@ -2,6 +2,7 @@ def get_where_query_sql(assetnum, worktype):
where_query = f""" where_query = f"""
where where
a.asset_unit = '3' a.asset_unit = '3'
AND a.asset_unit='00'
and a.wonum not like 'T%' and a.wonum not like 'T%'
AND a.asset_assetnum = '{assetnum}' AND a.asset_assetnum = '{assetnum}'
{f"AND a.worktype = '{worktype}'" if worktype != 'CM' else "AND a.worktype in ('CM', 'PROACTIVE', 'EM')"} {f"AND a.worktype = '{worktype}'" if worktype != 'CM' else "AND a.worktype in ('CM', 'PROACTIVE', 'EM')"}
@ -21,6 +22,7 @@ def get_where_query_sql_all_worktype(assetnum):
where_query = f""" where_query = f"""
where where
a.asset_unit = '3' a.asset_unit = '3'
AND a.asset_unit='00'
and a.wonum not like 'T%' and a.wonum not like 'T%'
AND a.asset_assetnum = '{assetnum}' AND a.asset_assetnum = '{assetnum}'
AND ( AND (

Loading…
Cancel
Save