code3000.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. from hub import methods, Global
  2. async def code3001(**sources):
  3. """
  4. 查询驾驶人员操作记录列表
  5. """
  6. # # --- check ---
  7. # if not sources.get('page'):
  8. # return dict(code=1, details=f"something is wrong.")
  9. # elif not sources.get('size'):
  10. # return dict(code=2, details=f"something is wrong.")
  11. #
  12. # # --- fill d1 ---
  13. # """
  14. # VehicleLog: 车辆日志表
  15. # VehicleLog.pid: 车牌号
  16. # VehicleLog.start_time_at: 远程驾驶开始时间
  17. # VehicleLog.end_time_at: 远程驾驶结束时间
  18. # VehicleLog.driver_name: 驾驶员
  19. # VehicleLog.cockpit_name: 驾驶舱
  20. # VehicleLog.create_at: 创建时间
  21. # """
  22. # d1 = list()
  23. page = sources.get('page', 1)
  24. size = sources.get('size', 10)
  25. # for item in Global.mdb.get_all('VehicleInfo', sort_field=[('create_at', -1)]):
  26. #
  27. # # --- check ---
  28. # if sources.get('pid') and sources.get('pid') not in item.get('pid'):
  29. # continue
  30. #
  31. # # --- check ---
  32. # if sources.get('driver_name') and sources.get('driver_name') not in item.get('driver_name'):
  33. # continue
  34. #
  35. # data = {
  36. # 'uuid': str(item.get('_id')),
  37. # 'pid': item.get('pid'),
  38. # 'start_time_at': methods.now_ts(),
  39. # 'end_time_at': methods.now_ts(),
  40. # 'driver_name': item.get('driver_name'),
  41. # 'cockpit_name': item.get('cockpit_name'),
  42. # }
  43. # d1.append(data)
  44. #
  45. # return dict(code=0, data=d1[(page - 1) * size: page * size], total=len(d1), page=page, size=size)
  46. d1 = [
  47. {
  48. 'uuid': '65dbe96949fbe311a3a01d30',
  49. 'pid': 'AA112233',
  50. 'start_time_at': methods.now_ts(),
  51. 'end_time_at': methods.now_ts() + (3600 * 8),
  52. 'driver_name': '张三',
  53. 'cockpit_name': '1号舱',
  54. }, {
  55. 'uuid': '65dbe96949fbe311a3a01d30',
  56. 'pid': 'AA112233',
  57. 'start_time_at': methods.now_ts(),
  58. 'end_time_at': methods.now_ts() + (3600 * 8),
  59. 'driver_name': '李四',
  60. 'cockpit_name': '1号舱',
  61. }, {
  62. 'uuid': '65dbe96949fbe311a3a01d30',
  63. 'pid': 'AA112233',
  64. 'start_time_at': methods.now_ts(),
  65. 'end_time_at': methods.now_ts() + (3600 * 8),
  66. 'driver_name': '李四',
  67. 'cockpit_name': '1号舱',
  68. }, {
  69. 'uuid': '65dbe96949fbe311a3a01d30',
  70. 'pid': 'AA112233',
  71. 'start_time_at': methods.now_ts(),
  72. 'end_time_at': methods.now_ts() + (3600 * 8),
  73. 'driver_name': '李四',
  74. 'cockpit_name': '1号舱',
  75. }, {
  76. 'uuid': '65dbe96949fbe311a3a01d30',
  77. 'pid': 'AA112233',
  78. 'start_time_at': methods.now_ts(),
  79. 'end_time_at': methods.now_ts() + (3600 * 8),
  80. 'driver_name': '李四',
  81. 'cockpit_name': '1号舱',
  82. }, {
  83. 'uuid': '65dbe96949fbe311a3a01d30',
  84. 'pid': 'AA112233',
  85. 'start_time_at': methods.now_ts(),
  86. 'end_time_at': methods.now_ts() + (3600 * 8),
  87. 'driver_name': '李四',
  88. 'cockpit_name': '1号舱',
  89. }, {
  90. 'uuid': '65dbe96949fbe311a3a01d30',
  91. 'pid': 'AA112233',
  92. 'start_time_at': methods.now_ts(),
  93. 'end_time_at': methods.now_ts() + (3600 * 8),
  94. 'driver_name': '李四',
  95. 'cockpit_name': '1号舱',
  96. }, {
  97. 'uuid': '65dbe96949fbe311a3a01d30',
  98. 'pid': 'AA112233',
  99. 'start_time_at': methods.now_ts(),
  100. 'end_time_at': methods.now_ts() + (3600 * 8),
  101. 'driver_name': '李四',
  102. 'cockpit_name': '1号舱',
  103. }, {
  104. 'uuid': '65dbe96949fbe311a3a01d30',
  105. 'pid': 'AA112233',
  106. 'start_time_at': methods.now_ts(),
  107. 'end_time_at': methods.now_ts() + (3600 * 8),
  108. 'driver_name': '李四',
  109. 'cockpit_name': '1号舱',
  110. }, {
  111. 'uuid': '65dbe96949fbe311a3a01d30',
  112. 'pid': 'AA112233',
  113. 'start_time_at': methods.now_ts(),
  114. 'end_time_at': methods.now_ts() + (3600 * 8),
  115. 'driver_name': '李四',
  116. 'cockpit_name': '1号舱',
  117. }
  118. ]
  119. return dict(code=0, data=d1[(page - 1) * size: page * size], total=len(d1), page=page, size=size)
  120. async def code3002(**sources):
  121. """
  122. 下载指定驾驶人员操作日志
  123. """
  124. file_name = '2024-03-04.log'
  125. file_path = f"/home/server/logs/{file_name}"
  126. return {'file_path': file_path, 'file_name': file_name}