修复绿波优化任务bug
This commit is contained in:
parent
93eaffa506
commit
c43eed0bec
|
|
@ -564,19 +564,30 @@ class TaskDbHelper(TableDbHelperBase):
|
||||||
task_tp_info_dict[tp_key]['wave_tp_id'] = wave_tp_info_dict[tp_key]
|
task_tp_info_dict[tp_key]['wave_tp_id'] = wave_tp_info_dict[tp_key]
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
update_sql = """
|
# 补充跳过需求确认单没有任务时段信息时需要将
|
||||||
update task.greenwave_task_tp_detail set wave_tp_id = %s where tp_start = %s and tp_end = %s and weekday = %s and task_no = %s and nodeid = %s and area_id = %s
|
if not task_tp_info_dict:
|
||||||
"""
|
insert_list = []
|
||||||
conn, cursor = self.connect()
|
for tp_info in wave_tp_info:
|
||||||
try:
|
insert_list.append((task_no, tp_info['wave_tp_id'], tp_info['tp_start'], tp_info['tp_end'], tp_info['type_str'], tp_info['type_str'], tp_info['weekday'], nodeid, area_id))
|
||||||
for tp_info in task_tp_info_dict.values():
|
insert_sql = """
|
||||||
cursor.execute(update_sql, (tp_info['wave_tp_id'], tp_info['tp_start'], tp_info['tp_end'], tp_info['weekday'], task_no, nodeid, area_id))
|
insert into task.greenwave_task_tp_detail(task_no, wave_tp_id, tp_start, tp_end, coor_dir, priority_coor_dir, weekday, nodeid, area_id) values (%s, %s, %s, %s, %s, %s, %s, %s, %s)
|
||||||
conn.commit()
|
"""
|
||||||
return True
|
ret = self.do_executemany(insert_sql, insert_list)
|
||||||
except Exception as e:
|
return ret == len(insert_list)
|
||||||
conn.rollback()
|
else:
|
||||||
print(e)
|
update_sql = """
|
||||||
return False
|
update task.greenwave_task_tp_detail set wave_tp_id = %s where tp_start = %s and tp_end = %s and weekday = %s and task_no = %s and nodeid = %s and area_id = %s
|
||||||
|
"""
|
||||||
|
conn, cursor = self.connect()
|
||||||
|
try:
|
||||||
|
for tp_info in task_tp_info_dict.values():
|
||||||
|
cursor.execute(update_sql, (tp_info['wave_tp_id'], tp_info['tp_start'], tp_info['tp_end'], tp_info['weekday'], task_no, nodeid, area_id))
|
||||||
|
conn.commit()
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
conn.rollback()
|
||||||
|
print(e)
|
||||||
|
return False
|
||||||
|
|
||||||
def update_stage1_info(self, task_no, waveid, wave_name, task_stage, task_info, wave_crosses):
|
def update_stage1_info(self, task_no, waveid, wave_name, task_stage, task_info, wave_crosses):
|
||||||
conn, cursor = self.connect()
|
conn, cursor = self.connect()
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,14 @@ from email.mime.multipart import MIMEMultipart
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.utils import formataddr
|
from email.utils import formataddr
|
||||||
|
|
||||||
|
from app.eva_common import query_cross_ledger_info
|
||||||
from app.global_source import db_user, db_task
|
from app.global_source import db_user, db_task
|
||||||
from flask import request, send_file
|
from flask import request, send_file
|
||||||
from pypinyin import lazy_pinyin, Style
|
from pypinyin import lazy_pinyin, Style
|
||||||
|
|
||||||
from app.common_worker import *
|
from app.common_worker import *
|
||||||
from app.wave_db_func import gen_type_str, gen_weekday_str
|
from app.wave_db_func import gen_type_str, gen_weekday_str
|
||||||
from proto.phase_grpc import LedgerTaskDetailPhaseState, TaskWaveCrossTpPhaseRPC
|
from proto.phase_grpc import LedgerTaskDetailPhaseState, TaskWaveCrossTpPhaseRPC, CrossPhaseState
|
||||||
from tool.qcos_func import get_client, CosFolderManager
|
from tool.qcos_func import get_client, CosFolderManager
|
||||||
|
|
||||||
ALLOWED_EXTENSION_TASK = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'doc', 'docx', 'xlsx', 'xls', 'pptx', 'ppt'}
|
ALLOWED_EXTENSION_TASK = {'txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'doc', 'docx', 'xlsx', 'xls', 'pptx', 'ppt'}
|
||||||
|
|
@ -65,10 +66,11 @@ def do_query_task_list_parameter(params):
|
||||||
if len(executors)<=0:
|
if len(executors)<=0:
|
||||||
logging.error(' query_task_executor没有数据!')
|
logging.error(' query_task_executor没有数据!')
|
||||||
|
|
||||||
executor_list = []
|
executor_list, usable_user_list = [], []
|
||||||
for executor in executors:
|
for executor in executors:
|
||||||
executor_list.append(executor['user_name'])
|
executor_list.append(executor['user_name'])
|
||||||
res['data']['executor'] = executor_list
|
res['data']['executor'] = executor_list
|
||||||
|
res['data']['usable_user_list'] = executors
|
||||||
|
|
||||||
#需求来源
|
#需求来源
|
||||||
srcs = db_task.query_task_src(nodeid, area_id)
|
srcs = db_task.query_task_src(nodeid, area_id)
|
||||||
|
|
@ -79,6 +81,12 @@ def do_query_task_list_parameter(params):
|
||||||
src_list.append(src['src'])
|
src_list.append(src['src'])
|
||||||
res['data']['task_src'] = src_list
|
res['data']['task_src'] = src_list
|
||||||
|
|
||||||
|
# 20260408 新增路口巡检任务所需参数,当前辖区巡检路口数量
|
||||||
|
routing_crosses = db_tmnet.query_area_routing_focus_cross_num(nodeid, area_id)
|
||||||
|
focus_crosses = [row['crossid'] for row in routing_crosses if row['is_focus'] == 1]
|
||||||
|
res['data']['routing_crosses_num'] = len(routing_crosses)
|
||||||
|
res['data']['focus_crosses_num'] = len(focus_crosses)
|
||||||
|
|
||||||
return json.dumps(res)
|
return json.dumps(res)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1003,7 +1011,7 @@ def do_query_task_detail(params):
|
||||||
wave_name = wave_info['name'] if wave_info else ''
|
wave_name = wave_info['name'] if wave_info else ''
|
||||||
executor = task['executor']
|
executor = task['executor']
|
||||||
creator = task['creatorid']
|
creator = task['creatorid']
|
||||||
greenwave_task_additional_info = gen_greenwave_task_additional_info(taskno, nodeid, area_id, waveid, wave_name, creator, executor)
|
greenwave_task_additional_info = gen_greenwave_task_additional_info(taskno, nodeid, area_id, waveid, wave_name, creator, executor, userid)
|
||||||
task['greenwave_task_additional_info'] = greenwave_task_additional_info
|
task['greenwave_task_additional_info'] = greenwave_task_additional_info
|
||||||
task.pop('update_time')
|
task.pop('update_time')
|
||||||
res['desc'] = ''
|
res['desc'] = ''
|
||||||
|
|
@ -1395,12 +1403,12 @@ def verify_cross_entering_status(params):
|
||||||
if not crossid_list or len(crossid_list) < 1:
|
if not crossid_list or len(crossid_list) < 1:
|
||||||
return json.dumps(make_common_res(6, '缺少crossid_list, 请刷新后重试'))
|
return json.dumps(make_common_res(6, '缺少crossid_list, 请刷新后重试'))
|
||||||
|
|
||||||
cross_enter_status = db_task.query_cross_entering_status(crossid_list)
|
cross_enter_status = query_cross_entering_info(crossid_list, nodeid, area_id, userid)
|
||||||
cross_status_dict = {}
|
cross_status_dict = {}
|
||||||
for row in cross_enter_status:
|
for crossid in cross_enter_status.keys():
|
||||||
cross_status_dict[row['crossid']] = {
|
cross_status_dict[crossid] = {
|
||||||
'ledger_status': row['ledger_status'],
|
'ledger_status': cross_enter_status[crossid]['ledger_status'],
|
||||||
'phase_status': row['phase_status']
|
'phase_status': cross_enter_status[crossid]['phase_status']
|
||||||
}
|
}
|
||||||
verify_res = True
|
verify_res = True
|
||||||
for crossid in crossid_list:
|
for crossid in crossid_list:
|
||||||
|
|
@ -1524,7 +1532,15 @@ def query_wave_task_params(params):
|
||||||
left_coor = 0
|
left_coor = 0
|
||||||
left_coor = int(left_coor)
|
left_coor = int(left_coor)
|
||||||
# 需要查明 路口名称、信号机品牌、 最大相位数量、绿波时段信息、配时方案信息
|
# 需要查明 路口名称、信号机品牌、 最大相位数量、绿波时段信息、配时方案信息
|
||||||
wave_tp_info = []
|
wave_tp_info = [{
|
||||||
|
'wave_tp_id': 0,
|
||||||
|
'type_str': '双向',
|
||||||
|
'weekday_str': '全周',
|
||||||
|
'type': 2,
|
||||||
|
'weekday': '1,2,3,4,5,6,7',
|
||||||
|
'tp_start': '09:00',
|
||||||
|
'tp_end': '17:00'
|
||||||
|
}]
|
||||||
if waveid != '' and srcDir != '':
|
if waveid != '' and srcDir != '':
|
||||||
wave_tp_info = db_wave.query_wave_tp_infos(waveid, srcDir)
|
wave_tp_info = db_wave.query_wave_tp_infos(waveid, srcDir)
|
||||||
wave_tp_info_phase = [{'tp_start': row['tp_start'], 'tp_end': row['tp_end'], 'weekday': row['weekday']} for row in wave_tp_info]
|
wave_tp_info_phase = [{'tp_start': row['tp_start'], 'tp_end': row['tp_end'], 'weekday': row['weekday']} for row in wave_tp_info]
|
||||||
|
|
@ -1565,16 +1581,6 @@ def query_wave_task_params(params):
|
||||||
if srcDir != '':
|
if srcDir != '':
|
||||||
usable_src_dir_list = ['双向', gen_type_str(0, srcDir), gen_type_str(1, srcDir)]
|
usable_src_dir_list = ['双向', gen_type_str(0, srcDir), gen_type_str(1, srcDir)]
|
||||||
task_executor_list = db_task.query_task_executor(nodeid, area_id)
|
task_executor_list = db_task.query_task_executor(nodeid, area_id)
|
||||||
if waveid == '' and wave_name == '':
|
|
||||||
wave_tp_info = [{
|
|
||||||
'wave_tp_id': 0,
|
|
||||||
'type_str': '双向',
|
|
||||||
'weekday_str': '全周',
|
|
||||||
'type': 2,
|
|
||||||
'weekday': '1,2,3,4,5,6,7',
|
|
||||||
'tp_start': '09:00',
|
|
||||||
'tp_end': '17:00'
|
|
||||||
}]
|
|
||||||
res = make_common_res(0, 'ok')
|
res = make_common_res(0, 'ok')
|
||||||
res['data'] = {
|
res['data'] = {
|
||||||
'base_info': {
|
'base_info': {
|
||||||
|
|
@ -1587,7 +1593,7 @@ def query_wave_task_params(params):
|
||||||
'predict_issue_time': predict_issue_time,
|
'predict_issue_time': predict_issue_time,
|
||||||
'wave_status': 1 if waveid != '' else 0,
|
'wave_status': 1 if waveid != '' else 0,
|
||||||
'cross_num': len(wave_crosses),
|
'cross_num': len(wave_crosses),
|
||||||
'slc_company': slc_company_dict[int(slc_company)] if slc_company_res and int(slc_company) in slc_company_dict.keys() else '不统一',
|
'slc_company': slc_company_dict[int(slc_company)] if slc_company and slc_company_res and int(slc_company) in slc_company_dict.keys() else '不统一',
|
||||||
'task_src': task_src,
|
'task_src': task_src,
|
||||||
'max_phase_position': max_phase_position,
|
'max_phase_position': max_phase_position,
|
||||||
'left_coor': left_coor
|
'left_coor': left_coor
|
||||||
|
|
@ -1604,15 +1610,14 @@ def query_wave_task_params(params):
|
||||||
|
|
||||||
|
|
||||||
# 附加信息查询
|
# 附加信息查询
|
||||||
def gen_greenwave_task_additional_info(taskno, nodeid, area_id, waveid, wave_name, creator, executor):
|
def gen_greenwave_task_additional_info(taskno, nodeid, area_id, waveid, wave_name, creator, executor, userid):
|
||||||
# 需求确认单信息
|
# 需求确认单信息
|
||||||
greenwave_task_detail = db_task.query_greenwave_task_requirement_validation_info_sql(taskno)
|
greenwave_task_detail = db_task.query_greenwave_task_requirement_validation_info_sql(taskno)
|
||||||
additional_base_res = db_task.query_wave_task_additional_info_sql(taskno, nodeid, area_id)
|
additional_base_res = db_task.query_wave_task_additional_info_sql(taskno, nodeid, area_id)
|
||||||
stage_info = additional_base_res['task_stage']
|
stage_info = additional_base_res['task_stage']
|
||||||
task_crosses = db_task.query_wave_task_crosses(taskno)
|
task_crosses = db_task.query_wave_task_crosses(taskno)
|
||||||
task_crossid_list = [row['crossid'] for row in task_crosses if row['crossid'] and row['crossid'] != '']
|
task_crossid_list = [row['crossid'] for row in task_crosses if row['crossid'] and row['crossid'] != '']
|
||||||
cross_entering_info = db_task.query_cross_entering_status(task_crossid_list)
|
cross_entering_status_dict = query_cross_entering_info(task_crossid_list, nodeid, area_id, userid)
|
||||||
cross_entering_status_dict = {row['crossid']: row for row in cross_entering_info}
|
|
||||||
task_tp_info = db_task.query_wave_task_tp_info(taskno, nodeid, area_id)
|
task_tp_info = db_task.query_wave_task_tp_info(taskno, nodeid, area_id)
|
||||||
wave_tp_optimize_records = db_wave.query_wave_tp_optimize_records(waveid) if waveid != '' else {}
|
wave_tp_optimize_records = db_wave.query_wave_tp_optimize_records(waveid) if waveid != '' else {}
|
||||||
# tp_check_res = db_task.query_task_check_res(taskno, nodeid, area_id)
|
# tp_check_res = db_task.query_task_check_res(taskno, nodeid, area_id)
|
||||||
|
|
@ -1830,7 +1835,7 @@ def update_greenwave_task_stage_info(params):
|
||||||
wave_tp_info = db_wave.query_wave_tp_infos(waveid, wave_info['srcDir'])
|
wave_tp_info = db_wave.query_wave_tp_infos(waveid, wave_info['srcDir'])
|
||||||
async_tp_info_res = db_task.async_wave_tp_id(wave_tp_info, task_tp_info, task_no, nodeid, area_id)
|
async_tp_info_res = db_task.async_wave_tp_id(wave_tp_info, task_tp_info, task_no, nodeid, area_id)
|
||||||
if not async_tp_info_res:
|
if not async_tp_info_res:
|
||||||
return json.dumps(make_common_res(15, '同步绿波时段表信息失败'))
|
return json.dumps(make_common_res(15, '当前绿波设置的运行时段与需求确认单中要求的协调时段不一致,请按需求确认单中要求调整'))
|
||||||
ret = db_task.update_stage1_info(task_no, waveid, wave_name, stage_info, task_info, wave_crosses)
|
ret = db_task.update_stage1_info(task_no, waveid, wave_name, stage_info, task_info, wave_crosses)
|
||||||
if ret:
|
if ret:
|
||||||
send_confirm_email(userids, f'当前任务到达绿波优化阶段, 请及时处理', task_no, task_info['task_name'], '绿波优化阶段', nodeid, area_id, creator_name, executor_name)
|
send_confirm_email(userids, f'当前任务到达绿波优化阶段, 请及时处理', task_no, task_info['task_name'], '绿波优化阶段', nodeid, area_id, creator_name, executor_name)
|
||||||
|
|
@ -2181,4 +2186,104 @@ def del_greenwave_task_tiny_adjustment_record(params):
|
||||||
return json.dumps(make_common_res(6, '删除失败'))
|
return json.dumps(make_common_res(6, '删除失败'))
|
||||||
|
|
||||||
|
|
||||||
|
# 修改路口配时方案状态及台账录入状态查询逻辑
|
||||||
|
def query_cross_entering_info(cross_list, nodeid, area_id, userid):
|
||||||
|
cross_phase_status_dict, e = CrossPhaseState(int(nodeid), cross_list)
|
||||||
|
check_modify_record_res = False
|
||||||
|
cross_entering_status_dict = {}
|
||||||
|
for crossid in cross_list:
|
||||||
|
ledger_status = 0
|
||||||
|
if 'udc_' not in crossid:
|
||||||
|
check_modify_record_res = db_tmnet.query_cross_user_modify_record(nodeid, crossid)
|
||||||
|
if not check_modify_record_res:
|
||||||
|
cross_entering_status_dict[crossid] = {
|
||||||
|
'phase_status': cross_phase_status_dict[crossid],
|
||||||
|
'ledger_status': ledger_status
|
||||||
|
}
|
||||||
|
cross_ledger_info = query_cross_ledger_info(crossid, nodeid, area_id, userid)
|
||||||
|
if not cross_ledger_info or not cross_ledger_info['data']:
|
||||||
|
cross_entering_status_dict[crossid] = {
|
||||||
|
'phase_status': cross_phase_status_dict[crossid],
|
||||||
|
'ledger_status': ledger_status
|
||||||
|
}
|
||||||
|
|
||||||
|
# 路口基本属性
|
||||||
|
cross_name = cross_ledger_info['data']['ledger']['name']
|
||||||
|
cross_type = cross_ledger_info['data']['ledger']['cross_type']
|
||||||
|
cross_model = str(cross_ledger_info['data']['ledger']['primary']) + '-' + str(cross_ledger_info['data']['ledger']['secondary'])
|
||||||
|
division = cross_ledger_info['data']['ledger']['division']
|
||||||
|
company = cross_ledger_info['data']['ledger']['company']
|
||||||
|
slc_company = cross_ledger_info['data']['ledger']['slc_company']
|
||||||
|
slc_state = cross_ledger_info['data']['ledger']['slc_state']
|
||||||
|
slc_contral_tp = cross_ledger_info['data']['ledger']['slc_contral_tp']
|
||||||
|
slc_contral_model = cross_ledger_info['data']['ledger']['slc_contral_model']
|
||||||
|
internet = cross_ledger_info['data']['ledger']['internet']
|
||||||
|
|
||||||
|
# 路段属性 大都有默认值存在
|
||||||
|
guard_state, right_canaliza_state, sidewalk_state, lane_widening_state, hold_left_state, hold_straight_state, reverse_turn_state, turn_back_state, bicycle_lane_state = 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
roads_info = cross_ledger_info['data']['roads']
|
||||||
|
for dir_info in roads_info.keys():
|
||||||
|
dir_ledger_info = roads_info[dir_info]
|
||||||
|
canaliza = dir_ledger_info['canaliza']
|
||||||
|
guard = canaliza['guard']
|
||||||
|
right_canaliza = canaliza['right_canaliza']
|
||||||
|
sidewalk = canaliza['sidewalk']
|
||||||
|
lane_widening = canaliza['lane_widening']
|
||||||
|
hold_left = canaliza['hold_left']
|
||||||
|
hold_straight = canaliza['hold_straight']
|
||||||
|
reverse_turn = canaliza['reverse_turn']
|
||||||
|
turn_back = canaliza['turn_back']
|
||||||
|
bicycle_lane = canaliza['bicycle_lane']
|
||||||
|
if guard:
|
||||||
|
guard_state = 1
|
||||||
|
if right_canaliza:
|
||||||
|
right_canaliza_state = 1
|
||||||
|
if sidewalk:
|
||||||
|
sidewalk_state = 1
|
||||||
|
if lane_widening:
|
||||||
|
lane_widening_state = 1
|
||||||
|
if hold_left:
|
||||||
|
hold_left_state = 1
|
||||||
|
if hold_straight:
|
||||||
|
hold_straight_state = 1
|
||||||
|
if reverse_turn:
|
||||||
|
reverse_turn_state = 1
|
||||||
|
if turn_back:
|
||||||
|
turn_back_state = 1
|
||||||
|
if bicycle_lane:
|
||||||
|
bicycle_lane_state = 1
|
||||||
|
|
||||||
|
# 信号灯情况
|
||||||
|
light_state, dir_lights = 0, {}
|
||||||
|
light_infos = cross_ledger_info['data']['light_infos']
|
||||||
|
valid_dirs = [src_dir for src_dir in roads_info.keys() if roads_info[src_dir]['roadid'] != '-']
|
||||||
|
for light_info in light_infos:
|
||||||
|
srcDir = light_info['srcDir']
|
||||||
|
if srcDir not in dir_lights.keys():
|
||||||
|
dir_lights[srcDir] = []
|
||||||
|
dir_lights[srcDir].append(light_info['light_type'])
|
||||||
|
for dir in valid_dirs:
|
||||||
|
if dir in dir_lights.keys() and bool({0, 1, 2, 3, 4} & set(dir_lights[dir])):
|
||||||
|
light_state += 1
|
||||||
|
|
||||||
|
fields = [
|
||||||
|
cross_name, cross_type, cross_model, division, company,
|
||||||
|
slc_company, slc_state, slc_contral_tp, slc_contral_model,
|
||||||
|
internet, guard_state, right_canaliza_state, sidewalk_state,
|
||||||
|
lane_widening_state, hold_left_state, hold_straight_state,
|
||||||
|
reverse_turn_state, turn_back_state, bicycle_lane_state
|
||||||
|
]
|
||||||
|
if slc_state in (2, 4, 5):
|
||||||
|
light_state = len(valid_dirs)
|
||||||
|
if all(f is not None and f != "" for f in fields) and light_state == len(valid_dirs):
|
||||||
|
ledger_status = 2
|
||||||
|
else:
|
||||||
|
ledger_status = 1
|
||||||
|
cross_entering_status_dict[crossid] = {
|
||||||
|
'phase_status': cross_phase_status_dict[crossid],
|
||||||
|
'ledger_status': ledger_status
|
||||||
|
}
|
||||||
|
return cross_entering_status_dict
|
||||||
|
|
||||||
|
|
||||||
# 路口巡检任务相关内容:20260407
|
# 路口巡检任务相关内容:20260407
|
||||||
|
|
|
||||||
|
|
@ -756,4 +756,15 @@ class TmnetDbHelper(TableDbHelperBase):
|
||||||
return res[0]['city_name'], res[0]['area_name']
|
return res[0]['city_name'], res[0]['area_name']
|
||||||
return '', ''
|
return '', ''
|
||||||
|
|
||||||
|
def query_cross_user_modify_record(self, nodeid, crossid):
|
||||||
|
sql = """
|
||||||
|
select * from tmnet.cross_ledger_update_info where nodeid = %s and crossid = '%s'
|
||||||
|
""" % (nodeid, crossid)
|
||||||
|
res = self.do_select(sql)
|
||||||
|
return False if len(res) == 0 or not res else True
|
||||||
|
|
||||||
|
def query_area_routing_focus_cross_num(self, nodeid, area_id):
|
||||||
|
sql = """
|
||||||
|
select crossid, is_routing_inspection, is_focus from tmnet.bound_crosses where nodeid = %s and area_id = %s
|
||||||
|
""" % (nodeid, area_id)
|
||||||
|
return self.do_select(sql)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue