cross_doctor/app/db_cross_delay.py

51 lines
2.2 KiB
Python
Raw Permalink Normal View History

# -*- coding: utf-8 -*-
# @Author: Owl
# @Date: 2025/10/10 16:17
# @Description:
from app.db_func_base import *
class CrossDbHelper(TableDbHelperBase):
def __init__(self, pool):
self.db_pool = pool
self.DB_Name = 'ledger'
def query_cross_usable_date_sql(self, crossid, nodeid):
sql = f"""
select distinct day from traffic_{nodeid}.cross_delay where crossid = '{crossid}'
"""
return self.do_select(sql)
def query_cross_delay_info(self, crossid, nodeid, date_list, tp_start):
date_list = ','.join(["'" + str(item) + "'" for item in date_list])
sql = f"""
select * from traffic_{nodeid}.cross_delay where crossid = '{crossid}' and day in ({date_list}) and tp_start = '{tp_start}' order by day
"""
return self.do_select(sql)
def query_cross_delay_whole_day_hours(self, crossid, nodeid, query_date):
sql = f"""
select * from traffic_{nodeid}.cross_delay where crossid = '{crossid}' and day = '{query_date}' and tp_start like 'h%' order by CAST(REGEXP_SUBSTR(tp_start, '[0-9]+') AS UNSIGNED)
"""
return self.do_select(sql)
def query_cross_examine_records(self, start_hm, first_date, crossid, end_date):
sql = """
select * from cross_doctor_matedata.cross_phase_problems_record where crossid = '%s' and start_hm = '%s' and first_date <= %s and (end_date >= '%s' or end_date is null)
""" % (crossid, start_hm, first_date, end_date)
2025-11-03 18:45:50 +08:00
return self.do_select(sql)
2025-11-11 11:14:22 +08:00
def query_cross_examine_records_nostarthm(self, first_date, crossid, end_date):
sql = """
select * from cross_doctor_matedata.cross_phase_problems_record where crossid = '%s' and first_date <= %s and (end_date >= '%s' or end_date is null)
""" % (crossid, first_date, end_date)
return self.do_select(sql)
2025-11-11 11:42:02 +08:00
def update_cross_examine_record_state_sql(self, crossid, first_date, end_date, start_hm, state):
2025-11-03 18:45:50 +08:00
sql = """
2025-11-11 11:42:02 +08:00
update cross_doctor_matedata.cross_phase_problems_record set state = '%s', end_date = '%s' where crossid = '%s' and first_date = '%s' and start_hm = %s
""" % (state, end_date, crossid, first_date, start_hm)
2025-11-04 15:34:41 +08:00
return self.do_execute(sql)