2025-10-20 11:54:43 +08:00
|
|
|
# -*- 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)
|
|
|
|
|
|
2025-10-27 10:35:25 +08:00
|
|
|
def query_cross_delay_info(self, crossid, nodeid, date_list, tp_start):
|
2025-10-20 19:04:53 +08:00
|
|
|
date_list = ','.join(["'" + str(item) + "'" for item in date_list])
|
2025-10-20 11:54:43 +08:00
|
|
|
sql = f"""
|
2025-10-27 10:35:25 +08:00
|
|
|
select * from traffic_{nodeid}.cross_delay where crossid = '{crossid}' and day in ({date_list}) and tp_start = '{tp_start}' order by day
|
2025-10-20 11:54:43 +08:00
|
|
|
"""
|
|
|
|
|
return self.do_select(sql)
|
2025-10-27 10:35:25 +08:00
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
2025-10-30 20:18:58 +08:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
def update_cross_examine_record_state(self, crossid, first_date, start_hm, state):
|
|
|
|
|
sql = """
|
|
|
|
|
update cross_doctor_matedata.cross_phase_problems_record set state = '%s' where crossid = '%s' and first_date = '%s' and start_hm = %s
|
|
|
|
|
""" % (state, crossid, first_date, start_hm)
|
|
|
|
|
return self.do_update(sql)
|