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)
|
|
|
|
|
|
2025-11-14 14:46:15 +08:00
|
|
|
def query_cross_examine_record_detail(self, start_hm, first_date, crossid):
|
|
|
|
|
sql = """
|
|
|
|
|
select * from cross_doctor_matedata.cross_phase_problems_record_detail where crossid = '%s' and start_hm = '%s' and first_date = %s
|
|
|
|
|
""" % (crossid, start_hm, first_date)
|
|
|
|
|
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-12 14:54:47 +08:00
|
|
|
update cross_doctor_matedata.cross_phase_problems_record set final_state = '%s', end_date = '%s' where crossid = '%s' and first_date = '%s' and start_hm = %s
|
2025-11-11 11:42:02 +08:00
|
|
|
""" % (state, end_date, crossid, first_date, start_hm)
|
2025-11-04 15:34:41 +08:00
|
|
|
return self.do_execute(sql)
|