action_tool.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. import base64
  2. import os
  3. import time
  4. from func.action_func import del_key_vague
  5. from task.task_job import callback_task
  6. from tools import loggerKit, redis_client
  7. import scene.oprator.atom_data
  8. from tools.pic_base64_util import pic_to_base64
  9. """
  10. 检查任务状态
  11. :param task_id 任务id
  12. :param data 客户端请求的参数字典
  13. :param target_app app标识
  14. :param package_name APP id
  15. :param target_version APP 版本
  16. :param timeout 超时时间 s
  17. :param sleep_time 休眠时间 s
  18. """
  19. def check_result_status(
  20. task_id,
  21. data,
  22. target_app,
  23. target_version,
  24. package_name,
  25. timeout=30,
  26. sleep_time=10
  27. ):
  28. # 获取设备id
  29. device_id = data.get("deviceID")
  30. # 获取 指令结构体
  31. result = data.get("result")
  32. # 指令结构体不为None
  33. if result is not None:
  34. # 获取指令执行结果
  35. perform_action_result = result.get("performActionResult")
  36. if perform_action_result is None or perform_action_result == "failure":
  37. # 指令执行结果为:None 或 失败
  38. return make_fail_result(device_id, task_id)
  39. if perform_action_result == "stop":
  40. # 指令执行结果为:终止
  41. return make_stop_result(device_id, task_id)
  42. else:
  43. return None
  44. else:
  45. """
  46. 启动指令
  47. 启动app
  48. """
  49. return make_task_start_app(
  50. data,
  51. target_app=target_app,
  52. target_version=target_version,
  53. package_name=package_name,
  54. timeout=timeout,
  55. sleep_time=sleep_time
  56. )
  57. """
  58. 启动APP任务
  59. :param data 客户端请求的参数字典
  60. :param target_app app标识
  61. :param target_version 目标APP的指定版本
  62. :param package_name 目标APP的id
  63. :param timeout 超时时间 s
  64. :param sleep_time 休眠时间 s
  65. """
  66. def make_task_start_app(
  67. data,
  68. target_app,
  69. target_version,
  70. package_name,
  71. timeout=30,
  72. sleep_time=10
  73. ):
  74. # 获取设备id
  75. device_id = data.get("deviceID")
  76. # 生成新的任务id
  77. action_id = make_new_task_id()
  78. # 生成app启动json
  79. action_dict = scene.oprator.atom_data.start_app(
  80. request_id=action_id,
  81. target_app=target_app,
  82. target_version=target_version,
  83. package_name=package_name,
  84. timeout=timeout,
  85. sleep_time=sleep_time
  86. )
  87. # 更新redis
  88. update_redis_step(device_id, action_id, 1, 9)
  89. # 记录日志
  90. log_msg(device_id, "action0_id", action_id)
  91. # 返回生成app启动json字典
  92. log_msg_return(device_id, action_dict)
  93. return action_dict
  94. """
  95. 关闭APP任务
  96. :param task_id 任务id
  97. :param data 客户端请求的参数字典
  98. :param target_app app标识
  99. :param target_version 目标APP的指定版本
  100. :param package_name 目标APP的id
  101. :param timeout 超时时间 s
  102. :param sleep_time 休眠时间 s
  103. """
  104. def make_task_stop_app(
  105. task_id,
  106. data,
  107. step_index,
  108. target_app,
  109. target_version,
  110. package_name,
  111. timeout=30,
  112. sleep_time=10
  113. ):
  114. # 获取设备id
  115. device_id = data.get("deviceID")
  116. # 生成新的任务id
  117. action_id = make_new_task_id()
  118. # 生成app启动json
  119. action_dict = scene.oprator.atom_data.stop_app(
  120. request_id=action_id,
  121. target_app=target_app,
  122. target_version=target_version,
  123. package_name=package_name,
  124. timeout=timeout,
  125. sleep_time=sleep_time
  126. )
  127. # 更新redis
  128. update_redis_step(device_id, action_id, 1, step_index)
  129. # 记录日志
  130. log_msg(device_id, "action0_id", action_id)
  131. # 返回生成app启动json字典
  132. log_msg_return(device_id, action_dict)
  133. end_task(device_id, task_id)
  134. return action_dict
  135. """
  136. 点击原生控件任务
  137. 需指定控件id,从weditor中抓取
  138. :param data 客户端请求的参数字典
  139. :param step_index 当前指定到第几步
  140. :param target_app app标识
  141. :param target_version 目标APP的指定版本
  142. :param package_name 目标APP的id
  143. :param control_ids
  144. :param control_id 控件的唯一id
  145. :param item_index
  146. :param timeout 超时时间 s
  147. :param sleep_time 休眠时间 s
  148. """
  149. def make_task_click_widget(
  150. data,
  151. step_index,
  152. target_app,
  153. target_version,
  154. package_name,
  155. control_ids="",
  156. control_id="",
  157. item_index=0,
  158. timeout=30,
  159. sleep_time=10
  160. ):
  161. # 获取设备id
  162. device_id = data.get("deviceID")
  163. # 获取指令id
  164. perform_action_id = data.get("performActionId")
  165. # 获取 指令结构体
  166. result = data.get("result")
  167. # 获取任务执行状态
  168. perform_action_result = result.get("performActionResult")
  169. step_id = read_redis_step_id(device_id, perform_action_id, step_index)
  170. # 获取redis缓存的操作id
  171. last_action_id = read_redis_last_operate_id(device_id)
  172. # 判断是否可以执行该步骤
  173. if can_execute_step(step_id, last_action_id, perform_action_id, perform_action_result):
  174. # 生成新的任务id
  175. action_id = make_new_task_id()
  176. # 记录日志
  177. log_msg(device_id, f"action{step_index}_id_{load_log_mark(step_index)}", int(last_action_id))
  178. action_dict = scene.oprator.atom_data.single_click_by_control(
  179. action_id,
  180. target_app=target_app,
  181. target_version=target_version,
  182. package_name=package_name,
  183. control_ids=control_ids,
  184. control_id=control_id,
  185. item_index=item_index,
  186. timeout=timeout,
  187. sleep_time=sleep_time
  188. )
  189. # 更新redis
  190. update_redis_step(device_id, action_id, step_index + 1, step_index)
  191. # 记录日志
  192. log_msg(device_id, f"action{step_index}_id", action_id)
  193. # 返回新生成的操作json字典
  194. log_msg_return(device_id, action_dict)
  195. return action_dict
  196. else:
  197. return None
  198. """
  199. 点击文本
  200. :param data 客户端请求的参数字典
  201. :param step_index 当前指定到第几步
  202. :param target_app app标识
  203. :param package_name 目标APP的id
  204. :param target_version 目标APP的指定版本
  205. :param text 要点击的文本
  206. :param timeout 超时时间 s
  207. :param sleep_time 休眠时间 s
  208. """
  209. def make_task_click_text(
  210. data,
  211. step_index,
  212. target_app,
  213. package_name,
  214. target_version,
  215. text,
  216. timeout=30,
  217. sleep_time=10
  218. ):
  219. # 获取设备id
  220. device_id = data.get("deviceID")
  221. # 获取指令id
  222. perform_action_id = data.get("performActionId")
  223. # 获取 指令结构体
  224. result = data.get("result")
  225. # 获取任务执行状态
  226. perform_action_result = result.get("performActionResult")
  227. step_id = read_redis_step_id(device_id, perform_action_id, step_index)
  228. # 获取redis缓存的操作id
  229. last_action_id = read_redis_last_operate_id(device_id)
  230. # 判断是否可以执行该步骤
  231. if can_execute_step(step_id, last_action_id, perform_action_id, perform_action_result):
  232. # 生成新的任务id
  233. action_id = make_new_task_id()
  234. # 记录日志
  235. log_msg(device_id, f"action{step_index}_id_{load_log_mark(step_index)}", int(last_action_id))
  236. # 生成点击图片字典
  237. action_dict = scene.oprator.atom_data.single_click_by_text(
  238. request_id=action_id,
  239. target_app=target_app,
  240. target_version=target_version,
  241. package_name=package_name,
  242. text=text,
  243. timeout=timeout,
  244. sleep_time=sleep_time
  245. )
  246. # 更新redis
  247. update_redis_step(device_id, action_id, step_index + 1, step_index)
  248. # 记录日志
  249. log_msg(device_id, f"action{step_index}_id", action_id)
  250. # 返回新生成的操作json字典
  251. log_msg_return(device_id, action_dict)
  252. return action_dict
  253. else:
  254. return None
  255. """
  256. 滑动屏幕任务
  257. :param data 客户端请求的参数字典
  258. :param step_index 当前指定到第几步
  259. :param target_app app标识
  260. :param package_name 目标APP的id
  261. :param target_version 目标APP的指定版本
  262. :param scale 滑动比例
  263. :param direction 滑动方向
  264. :param timeout 超时时间 s
  265. :param sleep_time 休眠时间 s
  266. """
  267. def make_task_swipe_screen(
  268. data,
  269. step_index,
  270. target_app,
  271. package_name,
  272. target_version,
  273. scale=0.5,
  274. direction="up",
  275. timeout=30,
  276. sleep_time=10
  277. ):
  278. # 获取设备id
  279. device_id = data.get("deviceID")
  280. # 获取指令id
  281. perform_action_id = data.get("performActionId")
  282. # 获取 指令结构体
  283. result = data.get("result")
  284. # 获取任务执行状态
  285. perform_action_result = result.get("performActionResult")
  286. step = read_redis_step_id(device_id, perform_action_id, step_index)
  287. # 获取redis缓存的操作id
  288. last_action_id = read_redis_last_operate_id(device_id)
  289. # 判断是否可以执行该步骤
  290. if can_execute_step(step, last_action_id, perform_action_id, perform_action_result):
  291. # 生成新的任务id
  292. action_id = make_new_task_id()
  293. # 记录日志
  294. log_msg(device_id, f"action{step_index}_id_{load_log_mark(step_index)}", int(last_action_id))
  295. # 生成滑动屏幕操作json
  296. action_dict = scene.oprator.atom_data.swipe_screen(
  297. request_id=action_id,
  298. target_app=target_app,
  299. target_version=target_version,
  300. package_name=package_name,
  301. scale=scale,
  302. timeout=timeout,
  303. sleep_time=sleep_time,
  304. direction=direction
  305. )
  306. # 更新redis
  307. update_redis_step(device_id, action_id, step_index + 1, step_index)
  308. # 记录日志
  309. log_msg(device_id, f"action{step_index}_id", action_id)
  310. # 返回新生成的操作json字典
  311. log_msg_return(device_id, action_dict)
  312. return action_dict
  313. else:
  314. return None
  315. """
  316. 连续滑动屏幕任务
  317. :param data 客户端请求的参数字典
  318. :param step_index 当前指定到第几步
  319. :param target_app app标识
  320. :param package_name 目标APP的id
  321. :param target_version 目标APP的指定版本
  322. :param scale 滑动比例
  323. :param direction 滑动方向
  324. :param timeout 超时时间 s
  325. :param sleep_time 休眠时间 s
  326. """
  327. def make_task_continual_swipe_screen(
  328. data,
  329. step_index,
  330. target_app,
  331. package_name,
  332. target_version,
  333. scale=0.5,
  334. direction="up",
  335. is_need_loop=False,
  336. loop_count=1,
  337. timeout=30,
  338. sleep_time=10
  339. ):
  340. # 获取设备id
  341. device_id = data.get("deviceID")
  342. # 获取指令id
  343. perform_action_id = data.get("performActionId")
  344. # 获取 指令结构体
  345. result = data.get("result")
  346. # 获取任务执行状态
  347. perform_action_result = result.get("performActionResult")
  348. step = read_redis_step_id(device_id, perform_action_id, step_index)
  349. # 获取redis缓存的操作id
  350. last_action_id = read_redis_last_operate_id(device_id)
  351. # 判断是否可以执行该步骤
  352. if can_execute_step(step, last_action_id, perform_action_id, perform_action_result):
  353. # 生成新的任务id
  354. action_id = make_new_task_id()
  355. # 记录日志
  356. log_msg(device_id, f"action{step_index}_id_{load_log_mark(step_index)}", int(last_action_id))
  357. # 生成滑动屏幕操作json
  358. action_dict = scene.oprator.atom_data.swipe_screen(
  359. request_id=action_id,
  360. target_app=target_app,
  361. target_version=target_version,
  362. package_name=package_name,
  363. scale=scale,
  364. timeout=timeout,
  365. sleep_time=sleep_time,
  366. direction=direction
  367. )
  368. if is_need_loop == False:
  369. # 更新redis
  370. update_redis_step(device_id, action_id, step_index + 1, step_index)
  371. else:
  372. loop_key = loop_key_format(device_id, str(step_index))
  373. cur_loop_count = redis_client.get(loop_key)
  374. if cur_loop_count == None:
  375. cur_loop_count = 0
  376. else:
  377. cur_loop_count = int(cur_loop_count)
  378. if cur_loop_count < loop_count:
  379. update_redis_step(device_id, action_id, step_index, step_index)
  380. cur_loop_count += 1
  381. redis_client.set(loop_key, cur_loop_count)
  382. else :
  383. update_redis_step(device_id, action_id, step_index + 1, step_index)
  384. # 记录日志
  385. log_msg(device_id, f"action{step_index}_id", action_id)
  386. # 返回新生成的操作json字典
  387. log_msg_return(device_id, action_dict)
  388. return action_dict
  389. else:
  390. return None
  391. """
  392. 点击图片任务,通过图片识别触发
  393. 需指定图片的文件路径
  394. :param data 客户端请求的参数字典
  395. :param step_index 当前指定到第几步
  396. :param target_app app标识
  397. :param package_name 目标APP的id
  398. :param target_version 目标APP的指定版本
  399. :param pic_base64 图片的base64字符串
  400. :param timeout 超时时间 s
  401. :param sleep_time 休眠时间 s
  402. """
  403. def make_task_click_image(
  404. data,
  405. step_index,
  406. target_app,
  407. package_name,
  408. target_version,
  409. pic_base64,
  410. timeout=30,
  411. sleep_time=10
  412. ):
  413. # 获取设备id
  414. device_id = data.get("deviceID")
  415. # 获取指令id
  416. perform_action_id = data.get("performActionId")
  417. # 获取 指令结构体
  418. result = data.get("result")
  419. # 获取任务执行状态
  420. perform_action_result = result.get("performActionResult")
  421. step_id = read_redis_step_id(device_id, perform_action_id, step_index)
  422. # 获取redis缓存的操作id
  423. last_action_id = read_redis_last_operate_id(device_id)
  424. # 判断是否可以执行该步骤
  425. if can_execute_step(step_id, last_action_id, perform_action_id, perform_action_result):
  426. # 生成新的任务id
  427. action_id = make_new_task_id()
  428. # 记录日志
  429. log_msg(device_id, f"action{step_index}_id_{load_log_mark(step_index)}", int(last_action_id))
  430. # 生成点击图片字典
  431. action_dict = scene.oprator.atom_data.click_pic(
  432. request_id=action_id,
  433. target_app=target_app,
  434. target_version=target_version,
  435. package_name=package_name,
  436. pic_base64=pic_base64,
  437. timeout=timeout,
  438. sleep_time=sleep_time
  439. )
  440. # 更新redis
  441. update_redis_step(device_id, action_id, step_index + 1, step_index)
  442. # 记录日志
  443. log_msg(device_id, f"action{step_index}_id", action_id)
  444. # 返回新生成的操作json字典
  445. log_msg_return(device_id, action_dict)
  446. return action_dict
  447. else:
  448. return None
  449. """
  450. 返回上一页
  451. :param data 客户端请求的参数字典
  452. :param step_index 当前指定到第几步
  453. :param target_app app标识
  454. :param package_name 目标APP的id
  455. :param target_version 目标APP的指定版本
  456. :param timeout 超时时间 s
  457. :param sleep_time 休眠时间 s
  458. """
  459. def make_task_click_back(
  460. data,
  461. step_index,
  462. target_app,
  463. package_name,
  464. target_version,
  465. timeout=30,
  466. sleep_time=10
  467. ):
  468. # 获取设备id
  469. device_id = data.get("deviceID")
  470. # 获取指令id
  471. perform_action_id = data.get("performActionId")
  472. # 获取 指令结构体
  473. result = data.get("result")
  474. # 获取任务执行状态
  475. perform_action_result = result.get("performActionResult")
  476. step_id = read_redis_step_id(device_id, perform_action_id, step_index)
  477. # 获取redis缓存的操作id
  478. last_action_id = read_redis_last_operate_id(device_id)
  479. # 判断是否可以执行该步骤
  480. if can_execute_step(step_id, last_action_id, perform_action_id, perform_action_result):
  481. # 生成新的任务id
  482. action_id = make_new_task_id()
  483. # 记录日志
  484. log_msg(device_id, f"action{step_index}_id_{load_log_mark(step_index)}", int(last_action_id))
  485. # 生成点击图片字典
  486. action_dict = scene.oprator.atom_data.back_last_page(
  487. request_id=action_id,
  488. target_app=target_app,
  489. target_version=target_version,
  490. package_name=package_name,
  491. timeout=timeout,
  492. sleep_time=sleep_time
  493. )
  494. # 更新redis
  495. update_redis_step(device_id, action_id, step_index + 1, step_index)
  496. # 记录日志
  497. log_msg(device_id, f"action{step_index}_id", action_id)
  498. # 返回新生成的操作json字典
  499. log_msg_return(device_id, action_dict)
  500. return action_dict
  501. else:
  502. return None
  503. """
  504. 根据id输入文本内容
  505. :param data 客户端请求的参数字典
  506. :param step_index 当前指定到第几步
  507. :param target_app app标识
  508. :param package_name 目标APP的id
  509. :param target_version 目标APP的指定版本
  510. :param control_id 控件的id
  511. :param content 要输入的文本
  512. :param timeout 超时时间 s
  513. :param sleep_time 休眠时间 s
  514. """
  515. def make_task_send_text(
  516. data,
  517. step_index,
  518. target_app,
  519. package_name,
  520. target_version,
  521. control_id,
  522. content,
  523. timeout=30,
  524. sleep_time=10
  525. ):
  526. # 获取设备id
  527. device_id = data.get("deviceID")
  528. # 获取指令id
  529. perform_action_id = data.get("performActionId")
  530. # 获取 指令结构体
  531. result = data.get("result")
  532. # 获取任务执行状态
  533. perform_action_result = result.get("performActionResult")
  534. step_id = read_redis_step_id(device_id, perform_action_id, step_index)
  535. # 获取redis缓存的操作id
  536. last_action_id = read_redis_last_operate_id(device_id)
  537. # 判断是否可以执行该步骤
  538. if can_execute_step(step_id, last_action_id, perform_action_id, perform_action_result):
  539. # 生成新的任务id
  540. action_id = make_new_task_id()
  541. # 记录日志
  542. log_msg(device_id, f"action{step_index}_id_{load_log_mark(step_index)}", int(last_action_id))
  543. # 生成点击图片字典
  544. action_dict = scene.oprator.atom_data.send_text_by_control(
  545. request_id=action_id,
  546. target_app=target_app,
  547. target_version=target_version,
  548. package_name=package_name,
  549. control_id=control_id,
  550. content=content,
  551. timeout=timeout,
  552. sleep_time=sleep_time
  553. )
  554. # 更新redis
  555. update_redis_step(device_id, action_id, step_index + 1, step_index)
  556. # 记录日志
  557. log_msg(device_id, f"action{step_index}_id", action_id)
  558. # 返回新生成的操作json字典
  559. log_msg_return(device_id, action_dict)
  560. return action_dict
  561. else:
  562. return None
  563. """
  564. 生成日志标记
  565. """
  566. def load_log_mark(step):
  567. log_mark = "mem"
  568. if step == 1:
  569. log_mark = "start"
  570. return log_mark
  571. """
  572. 生成新的任务id
  573. """
  574. def make_new_task_id():
  575. return int(round(time.time() * 1000))
  576. """
  577. 记录格式化日志
  578. """
  579. def log_msg(device_id, msg, action_id):
  580. loggerKit.info("设备:{0}, {1}:{2}", device_id, msg, action_id)
  581. """
  582. 记录返回内容
  583. """
  584. def log_msg_return(device_id, result):
  585. loggerKit.info("返回数据:{0}, {1}", device_id, result)
  586. """
  587. 判断是否可以执行某个步骤
  588. """
  589. def can_execute_step(step_id, last_action_id, perform_action_id, perform_action_result):
  590. if step_id is not None and \
  591. int(step_id) == 1 and \
  592. last_action_id is not None and \
  593. int(perform_action_id) == int(last_action_id) and \
  594. perform_action_result == "success":
  595. return True
  596. else:
  597. return False
  598. """
  599. 根据图片名返回图片base64字符串
  600. """
  601. def read_pic_base64_string(pic_path):
  602. with open(pic_path, "rb") as image_file:
  603. try:
  604. encoded_string = "data:image/png;base64," + base64.b64encode(image_file.read()).decode('utf-8')
  605. except Exception as e:
  606. print(f"img_to_base64 error:{e}")
  607. return encoded_string
  608. """
  609. 更新redis任务id状态
  610. """
  611. def update_redis_step(device_id, action_id, set_step, del_setp):
  612. """
  613. 每次操作完成后会将对应的操作唯一id存储到redis
  614. 并且返回给手机端 手机端下次带着上个操作id来执行下一个操作
  615. """
  616. redis_client.delete(step_key_format(f"{device_id}_{action_id}", del_setp))
  617. redis_client.set(operate_key_format(device_id), action_id)
  618. redis_client.set(step_key_format(f"{device_id}_{action_id}", set_step), "1")
  619. """
  620. 生成redis操作key
  621. """
  622. def operate_key_format(key):
  623. return f"{key}operate"
  624. """
  625. 生成redis步骤key
  626. """
  627. def step_key_format(key, step):
  628. return f"{key}_step{step}"
  629. """
  630. 生成redis循环key
  631. """
  632. def loop_key_format(key, step):
  633. return f"{key}_loop{step}"
  634. """
  635. 生成终止json返回数据
  636. """
  637. def make_stop_result(device_id, task_id):
  638. return make_result(device_id, task_id, -2, "指令被用户终止")
  639. """
  640. 生成失败json返回数据
  641. """
  642. def make_fail_result(device_id, task_id):
  643. return make_result(device_id, task_id, -2, "fail, performActionResult is null")
  644. """
  645. 生成json返回数据
  646. """
  647. def make_result(device_id, task_id, code, message):
  648. return_dict = {
  649. "data": "",
  650. "code": str(code),
  651. "message": message
  652. }
  653. # del_key_vague(device_id)
  654. callback_task(500, '指令执行失败', task_id, device_id, 0, None)
  655. return return_dict
  656. """
  657. 读取redis最后一次operate的id
  658. """
  659. def read_redis_last_operate_id(device_id):
  660. return redis_client.get(device_id + "operate")
  661. """
  662. 读取redis某一步的操作id
  663. """
  664. def read_redis_step_id(device_id, action_id, step):
  665. if action_id == "" or action_id == None:
  666. return redis_client.get(f"{device_id}_step{step}")
  667. else:
  668. return redis_client.get(f"{device_id}_{action_id}_step{step}")
  669. """
  670. 结束任务,恢复任务状态
  671. """
  672. def end_task(device_id, task_id):
  673. del_key_vague(device_id)
  674. # 回调任务中心修改任务状态
  675. callback_task(None, None, task_id, device_id, 1, None)