Casper 1 ヶ月 前
コミット
187dcab685
2 ファイル変更47 行追加12 行削除
  1. 40 6
      sri-server-bg01/api/v6/code3000.py
  2. 7 6
      sri-server-bg01/test/test-3000.py

+ 40 - 6
sri-server-bg01/api/v6/code3000.py

@@ -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']
@@ -139,6 +162,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}

+ 7 - 6
sri-server-bg01/test/test-3000.py

@@ -45,9 +45,10 @@ print(response.json())
 """
 
 # --- test 3002 下载指定驾驶人员操作日志 ---
-# url = 'http://58.34.94.177:29101/v6/api'
-# params = {'code': 3002}
-# response = requests.get(url=url, params=params, headers={'authorization': token})
-# print(response.text)
-# requests.get(url='http://58.34.94.177:29101/v6/api?code=3002').text
-# requests.get(url='http://10.10.60.237:9000/v6/api?code=3002').text
+url = 'http://58.34.94.177:29101/v6/api'
+params = {
+    'code': 3002,
+    'uuid': '65dbe96949fbe311a3a01d30',
+}
+response = requests.get(url=url, params=params, headers={'authorization': token})
+print(response.text)