You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.0 KiB
Python
63 lines
2.0 KiB
Python
def get_where_query_sql(assetnum, worktype):
|
|
where_query = f"""
|
|
where
|
|
(a.asset_unit = '3' OR a.asset_unit='00')
|
|
and a.status in ('COMP', 'CLOSE')
|
|
AND a.asset_assetnum = '{assetnum}'
|
|
{f"AND a.worktype = '{worktype}'" if worktype != 'CM' else "AND a.worktype in ('CM', 'PROACTIVE', 'EM')"}
|
|
{f"AND a.wojp8 != 'S1'" if worktype == 'CM' else ""}
|
|
AND (
|
|
a.description NOT ILIKE '%U4%'
|
|
OR (
|
|
a.description ILIKE '%U3%'
|
|
AND a.description ILIKE '%U4%'
|
|
)
|
|
)
|
|
"""
|
|
# and a.wonum not like 'T%'
|
|
# EM = Emergency Maintainance
|
|
return where_query
|
|
|
|
def get_where_query_sql_labour_cost(assetnum, worktype):
|
|
"""
|
|
Return where query for labour cost using the standardized query.
|
|
The difference is on a.wonum not like T%
|
|
"""
|
|
where_query = f"""
|
|
where
|
|
(a.asset_unit = '3' OR a.asset_unit='00')
|
|
and a.status in ('COMP', 'CLOSE')
|
|
and a.wonum not like 'T%'
|
|
AND a.asset_assetnum = '{assetnum}'
|
|
{f"AND a.worktype = '{worktype}'" if worktype != 'CM' else "AND a.worktype in ('CM', 'PROACTIVE', 'EM')"}
|
|
{f"AND a.wojp8 != 'S1'" if worktype == 'CM' else ""}
|
|
AND (
|
|
a.description NOT ILIKE '%U4%'
|
|
OR (
|
|
a.description ILIKE '%U3%'
|
|
AND a.description ILIKE '%U4%'
|
|
)
|
|
)
|
|
"""
|
|
return where_query
|
|
|
|
def get_where_query_sql_all_worktype(assetnum):
|
|
where_query = f"""
|
|
WHERE
|
|
(a.asset_unit = '3' OR a.asset_unit = '00')
|
|
AND a.status IN ('COMP', 'CLOSE')
|
|
AND a.asset_assetnum = '{assetnum}'
|
|
AND (
|
|
(a.worktype = 'CM' AND a.wojp8 != 'S1')
|
|
OR (a.worktype <> 'CM')
|
|
)
|
|
AND (
|
|
a.description NOT ILIKE '%U4%'
|
|
OR (
|
|
a.description ILIKE '%U3%'
|
|
AND a.description ILIKE '%U4%'
|
|
)
|
|
)
|
|
AND a.worktype in ('CM', 'PROACTIVE', 'EM', 'PDM', 'PM', 'OH')
|
|
"""
|
|
return where_query |