|
@@ -20,6 +20,24 @@ async def code3001(**sources):
|
|
|
log_file_name_list = [i.split('\\')[-1] for i in log_file_list]
|
|
|
log_file_uuid_list = [i.split('.')[0] for i in log_file_name_list]
|
|
|
|
|
|
+ # --- fill d2 ---
|
|
|
+ d2 = dict()
|
|
|
+ """
|
|
|
+ VehicleInfo: 车辆信息表
|
|
|
+ VehicleInfo.pid: 车牌号
|
|
|
+ VehicleInfo.type: 车型号
|
|
|
+ VehicleInfo.host_address: 工控机地址
|
|
|
+ VehicleInfo.rtk_address: rtk地址
|
|
|
+ VehicleInfo.cpe_address: cpe地址
|
|
|
+ VehicleInfo.release_at: 出厂时期
|
|
|
+ VehicleInfo.state: 当前状态 (1:离线 2:在线空闲 3: 现场驾驶中 4: 远程驾驶中)
|
|
|
+ VehicleInfo.permit_state: 遥操状态 (0:允许 1:禁用)
|
|
|
+ VehicleInfo.update_at: 更新时间
|
|
|
+ """
|
|
|
+ for item in Global.mdb.get_all('VehicleInfo'):
|
|
|
+ ipv4 = int(f"{item.get('host_address').replace('.', '')}")
|
|
|
+ d2[ipv4] = item.get('pid')
|
|
|
+
|
|
|
# --- fill d1 ---
|
|
|
"""
|
|
|
UserWorkRecordList: 用户操作记录
|
|
@@ -44,11 +62,16 @@ async def code3001(**sources):
|
|
|
item['start_time_at'] = item.get('start_at')
|
|
|
item['end_time_at'] = item.get('end_at')
|
|
|
item['cockpit_name'] = item.get('cockpit_id')
|
|
|
- item['pid'] = item.get('vehicle_id')
|
|
|
+
|
|
|
+ # --- check ---
|
|
|
+ item['driver_name'] = item.get('user_uuid')
|
|
|
if len('67174cf9cd36d7a6def99cae') == len(item.get('user_uuid')):
|
|
|
item['driver_name'] = Global.mdb.get_one_by_id('UserInfo', item.get('user_uuid')).get('name')
|
|
|
- else:
|
|
|
- item['driver_name'] = item.get('user_uuid')
|
|
|
+
|
|
|
+ # --- check ---
|
|
|
+ item['pid'] = item.get('vehicle_id')
|
|
|
+ if int(item.get('vehicle_id')) in d2:
|
|
|
+ item['pid'] = d2.get(int(item.get('vehicle_id')))
|
|
|
|
|
|
# --- update --
|
|
|
del item['_id']
|
|
@@ -141,6 +164,17 @@ async def code3002(**sources):
|
|
|
"""
|
|
|
下载指定驾驶人员操作日志
|
|
|
"""
|
|
|
- log_uuid = '671754598302fc6fd344819f'
|
|
|
- file_path = os.path.join(save_dir, f'{log_uuid}.log')
|
|
|
- return {'file_path': file_path, 'file_name': '2024-12-12.log'}
|
|
|
+ if not sources.get('uuid'):
|
|
|
+ return dict(code=1, details=f"not found uuid.")
|
|
|
+ # log_uuid = '671754598302fc6fd344819f'
|
|
|
+ # if sources.get('uuid'):
|
|
|
+ # log_uuid = sources.get('uuid')
|
|
|
+ methods.debug_log('code3000.code3002|145:', f"#log_uuid: {sources.get('uuid')}")
|
|
|
+ file_path = os.path.join(save_dir, f"{sources.get('uuid')}.log")
|
|
|
+
|
|
|
+ # --- get file_name ---
|
|
|
+ item = Global.mdb.get_one_by_id('UserWorkRecordList', sources.get('uuid'))
|
|
|
+ start_at = methods.ts_to_string(item.get('start_at'), '%Y%m%d%H%M%S')
|
|
|
+ end_at = methods.ts_to_string(item.get('end_at'), '%Y%m%d%H%M%S')
|
|
|
+ file_name = f"{start_at}-{end_at}.log"
|
|
|
+ return {'file_path': file_path, 'file_name': file_name}
|