123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- from hub import methods, Global
- async def code3001(**sources):
- """
- 查询驾驶人员操作记录列表
- """
- # # --- check ---
- # if not sources.get('page'):
- # return dict(code=1, details=f"something is wrong.")
- # elif not sources.get('size'):
- # return dict(code=2, details=f"something is wrong.")
- #
- # # --- fill d1 ---
- # """
- # VehicleLog: 车辆日志表
- # VehicleLog.pid: 车牌号
- # VehicleLog.start_time_at: 远程驾驶开始时间
- # VehicleLog.end_time_at: 远程驾驶结束时间
- # VehicleLog.driver_name: 驾驶员
- # VehicleLog.cockpit_name: 驾驶舱
- # VehicleLog.create_at: 创建时间
- # """
- # d1 = list()
- page = sources.get('page', 1)
- size = sources.get('size', 10)
- # for item in Global.mdb.get_all('VehicleInfo', sort_field=[('create_at', -1)]):
- #
- # # --- check ---
- # if sources.get('pid') and sources.get('pid') not in item.get('pid'):
- # continue
- #
- # # --- check ---
- # if sources.get('driver_name') and sources.get('driver_name') not in item.get('driver_name'):
- # continue
- #
- # data = {
- # 'uuid': str(item.get('_id')),
- # 'pid': item.get('pid'),
- # 'start_time_at': methods.now_ts(),
- # 'end_time_at': methods.now_ts(),
- # 'driver_name': item.get('driver_name'),
- # 'cockpit_name': item.get('cockpit_name'),
- # }
- # d1.append(data)
- #
- # return dict(code=0, data=d1[(page - 1) * size: page * size], total=len(d1), page=page, size=size)
- d1 = [
- {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '张三',
- 'cockpit_name': '1号舱',
- }, {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '李四',
- 'cockpit_name': '1号舱',
- }, {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '李四',
- 'cockpit_name': '1号舱',
- }, {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '李四',
- 'cockpit_name': '1号舱',
- }, {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '李四',
- 'cockpit_name': '1号舱',
- }, {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '李四',
- 'cockpit_name': '1号舱',
- }, {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '李四',
- 'cockpit_name': '1号舱',
- }, {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '李四',
- 'cockpit_name': '1号舱',
- }, {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '李四',
- 'cockpit_name': '1号舱',
- }, {
- 'uuid': '65dbe96949fbe311a3a01d30',
- 'pid': 'AA112233',
- 'start_time_at': methods.now_ts(),
- 'end_time_at': methods.now_ts() + (3600 * 8),
- 'driver_name': '李四',
- 'cockpit_name': '1号舱',
- }
- ]
- return dict(code=0, data=d1[(page - 1) * size: page * size], total=len(d1), page=page, size=size)
- async def code3002(**sources):
- """
- 下载指定驾驶人员操作日志
- """
- file_name = '2024-03-04.log'
- file_path = f"/home/server/logs/{file_name}"
- return {'file_path': file_path, 'file_name': file_name}
|