|
|
@@ -0,0 +1,988 @@
|
|
|
+import json
|
|
|
+import threading
|
|
|
+import time
|
|
|
+
|
|
|
+from flask import Flask, request, make_response
|
|
|
+from task.task_dict import task_dict
|
|
|
+from strategy.rpa_handler import rpa_handler
|
|
|
+from strategy.rpa_atom_handler import rpa_handler as rpa_atom_handler
|
|
|
+
|
|
|
+from flask_restful import Api
|
|
|
+from simplejson import JSONEncoder
|
|
|
+
|
|
|
+from scene.dongchedi.interaction_poc import dong_action, dongcd_stop
|
|
|
+from scene.oprator.atom_data import single_click_by_control, send_text_by_control, single_click_by_text, \
|
|
|
+ get_content_by_control, start_app, stop_app
|
|
|
+from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
+
|
|
|
+from task.task_job import auto_pull_task
|
|
|
+from tools import common_util, loggerKit, redis_client
|
|
|
+from tools.api_route import route
|
|
|
+
|
|
|
+app = Flask(__name__)
|
|
|
+
|
|
|
+# 实例化对象
|
|
|
+api = Api(app)
|
|
|
+
|
|
|
+
|
|
|
+# 404处理
|
|
|
+@app.errorhandler(404)
|
|
|
+def not_found(e):
|
|
|
+ return make_response({'code': 404, 'msg': 'not found'}, 404)
|
|
|
+
|
|
|
+
|
|
|
+datas = [{'id': 1, 'name': 'xag', 'age': 18}, {'id': 2, 'name': 'xingag', 'age': 19}]
|
|
|
+
|
|
|
+
|
|
|
+@route(app, '/', methods=['POST', 'GET'])
|
|
|
+def hello_world():
|
|
|
+ return {'lists': [0, 1, 2, 3, 4, 5]}
|
|
|
+
|
|
|
+
|
|
|
+@route(app, '/index', methods=['GET'])
|
|
|
+def index():
|
|
|
+ return json.dumps(datas)
|
|
|
+
|
|
|
+
|
|
|
+# 异常处理
|
|
|
+@route(app, '/error', methods=['POST', 'GET'])
|
|
|
+def error():
|
|
|
+ a = 99
|
|
|
+ b = 0
|
|
|
+ return a / b # 除0引发异常
|
|
|
+
|
|
|
+
|
|
|
+@route(app, '/start_douyin', methods=['POST'])
|
|
|
+def start_douyin():
|
|
|
+ data = request.json
|
|
|
+ if data is not None \
|
|
|
+ and data.get('keyword') is not None \
|
|
|
+ and data.get('content') is not None \
|
|
|
+ and data.get('device_serials') is not None:
|
|
|
+ keyword = data.get('keyword')
|
|
|
+ content = data.get('content')
|
|
|
+ device_serials = data.get('device_serials')
|
|
|
+ # devices = device_serials.split(',')
|
|
|
+ # 解析 mobile、device
|
|
|
+ strs = device_serials.split(',')
|
|
|
+
|
|
|
+ threads = []
|
|
|
+ i = 0
|
|
|
+ while i < len(strs):
|
|
|
+ devices_mobiles = strs[i]
|
|
|
+ device_mobile = devices_mobiles.split('+')
|
|
|
+ # threads.append(threading.Thread(target=dou_action, args=(device_mobile[1], device_mobile[0], keyword,
|
|
|
+ # content,))) operator_action(devices[i], keyword, content)
|
|
|
+ i += 1
|
|
|
+
|
|
|
+ for t in threads:
|
|
|
+ print(t)
|
|
|
+ t.start()
|
|
|
+
|
|
|
+ else:
|
|
|
+ return 400
|
|
|
+
|
|
|
+ return 200
|
|
|
+
|
|
|
+
|
|
|
+@route(app, '/start_dong', methods=['POST'])
|
|
|
+def start_dong():
|
|
|
+ data = request.json
|
|
|
+ if data is not None \
|
|
|
+ and data.get('keyword') is not None \
|
|
|
+ and data.get('content') is not None \
|
|
|
+ and data.get('device_serials') is not None:
|
|
|
+ keyword = data.get('keyword')
|
|
|
+ content = data.get('content')
|
|
|
+ device_serials = data.get('device_serials')
|
|
|
+ # devices = device_serials.split(',')
|
|
|
+ # 解析 mobile、device
|
|
|
+ strs = device_serials.split(',')
|
|
|
+
|
|
|
+ threads = []
|
|
|
+ i = 0
|
|
|
+ while i < len(strs):
|
|
|
+ devices_mobiles = strs[i]
|
|
|
+ device_mobile = devices_mobiles.split('+')
|
|
|
+ threads.append(
|
|
|
+ threading.Thread(target=dong_action, args=(device_mobile[1], device_mobile[0], keyword, content,)))
|
|
|
+ i += 1
|
|
|
+
|
|
|
+ for t in threads:
|
|
|
+ print(t)
|
|
|
+ t.start()
|
|
|
+
|
|
|
+ else:
|
|
|
+ return 400
|
|
|
+
|
|
|
+ return 200
|
|
|
+
|
|
|
+
|
|
|
+@route(app, '/stop_douyin', methods=['POST'])
|
|
|
+def dou_stop():
|
|
|
+ data = request.json
|
|
|
+ print(data)
|
|
|
+ if data is not None \
|
|
|
+ and data.get('device_serials') is not None:
|
|
|
+ device_serials = data.get('device_serials')
|
|
|
+ if ',' in device_serials:
|
|
|
+ devices = device_serials.split(',')
|
|
|
+ threads = []
|
|
|
+ i = 0
|
|
|
+ while i < len(devices):
|
|
|
+ # threads.append(threading.Thread(target=douyin_stop, args=(devices[i],)))
|
|
|
+ i += 1
|
|
|
+
|
|
|
+ for t in threads:
|
|
|
+ print(t)
|
|
|
+ t.start()
|
|
|
+ else:
|
|
|
+ # douyin_stop(device_serials)
|
|
|
+ pass
|
|
|
+
|
|
|
+ else:
|
|
|
+ return 400
|
|
|
+
|
|
|
+ return 200
|
|
|
+
|
|
|
+
|
|
|
+@route(app, '/stop_dong', methods=['POST'])
|
|
|
+def dong_stop():
|
|
|
+ data = request.json
|
|
|
+ if data is not None \
|
|
|
+ and data.get('device_serials') is not None:
|
|
|
+ device_serials = data.get('device_serials')
|
|
|
+ if ',' in device_serials:
|
|
|
+ devices = device_serials.split(',')
|
|
|
+ threads = []
|
|
|
+ i = 0
|
|
|
+ while i < len(devices):
|
|
|
+ threads.append(threading.Thread(target=dongcd_stop, args=(devices[i],)))
|
|
|
+ i += 1
|
|
|
+
|
|
|
+ for t in threads:
|
|
|
+ print(t)
|
|
|
+ t.start()
|
|
|
+ else:
|
|
|
+ dongcd_stop(device_serials)
|
|
|
+
|
|
|
+ else:
|
|
|
+ return 400
|
|
|
+
|
|
|
+ return 200
|
|
|
+
|
|
|
+
|
|
|
+@route(app, '/get_ip_info', methods=['GET'])
|
|
|
+def get_ip_info():
|
|
|
+ common_util.get_ip_info('58.216.107.91')
|
|
|
+
|
|
|
+
|
|
|
+@route(app, '/get_local_ip', methods=['GET'])
|
|
|
+def query_local_ip():
|
|
|
+ print(common_util.get_ip_info('8.8.8.8'))
|
|
|
+
|
|
|
+
|
|
|
+# 领取任务接口v2
|
|
|
+@route(app, '/api/action_v1', methods=['POST'])
|
|
|
+def do_action_v1():
|
|
|
+ """
|
|
|
+ :param deviceID [必填]设备的ID
|
|
|
+ :param performActionId [非必填]前一条指令的ID
|
|
|
+ :param performActionResult success or failure
|
|
|
+ :param recognizedResult 你好,我是你根据控件Id查到的text内容
|
|
|
+ 领取任务接口
|
|
|
+ :return: 指令json串
|
|
|
+ """
|
|
|
+
|
|
|
+ data = request.json
|
|
|
+ loggerKit.info('请求信息:{0}', data)
|
|
|
+
|
|
|
+ device_id = data.get("deviceID")
|
|
|
+ perform_action_id = data.get("performActionId")
|
|
|
+ result = data.get("result")
|
|
|
+
|
|
|
+ if device_id is None:
|
|
|
+ loggerKit.info('请求信息:{0}', data)
|
|
|
+
|
|
|
+ return_dict = {
|
|
|
+ "data": "",
|
|
|
+ "code": -1,
|
|
|
+ "message": "fail, request device_id is null"
|
|
|
+ }
|
|
|
+
|
|
|
+ return return_dict
|
|
|
+
|
|
|
+ # action0_id = int(round(time.time() * 1000))
|
|
|
+ if result is not None:
|
|
|
+ """
|
|
|
+ 非首个指令
|
|
|
+ """
|
|
|
+ perform_action_result = result.get("performActionResult")
|
|
|
+ if perform_action_result is None:
|
|
|
+ return_dict = {
|
|
|
+ "data": "",
|
|
|
+ "code": -2,
|
|
|
+ "message": "fail, performActionResult is null"
|
|
|
+ }
|
|
|
+
|
|
|
+ return return_dict
|
|
|
+
|
|
|
+ action0_id_mem = redis_client.get(device_id)
|
|
|
+ step0 = redis_client.get(f"{device_id}_step0")
|
|
|
+ if step0 is not None and int(step0) == 1 and action0_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action0_id_mem) and perform_action_result == "success":
|
|
|
+ action1_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第1条指令
|
|
|
+ 懂车帝APP首页点击搜索框
|
|
|
+ """
|
|
|
+
|
|
|
+ action1_dict = single_click_by_control(action1_id, target_version="7.9.0",
|
|
|
+ control_id="com.ss.android.auto:id/c9c")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action1_id)
|
|
|
+ redis_client.set(f"{device_id}_{action1_id}_step1", "1")
|
|
|
+ redis_client.delete(f"{device_id}_step0")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action1_id:{1}", device_id, action1_id)
|
|
|
+
|
|
|
+ return action1_dict
|
|
|
+
|
|
|
+ action1_id_mem = redis_client.get(device_id)
|
|
|
+ step1 = redis_client.get(f"{device_id}_{perform_action_id}_step1")
|
|
|
+ if step1 is not None and int(step1) == 1 and action1_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action1_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action1_id_mem:{1}", device_id, int(action1_id_mem))
|
|
|
+
|
|
|
+ action2_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第2条指令
|
|
|
+ 在搜索框输入关键词
|
|
|
+ """
|
|
|
+ action2_dict = send_text_by_control(action2_id, control_id="com.ss.android.auto:id/h5q", content="飞凡F7")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action2_id)
|
|
|
+ redis_client.set(f"{device_id}_{action2_id}_step2", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action2_id}_step1")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action2_id:{1}", device_id, action2_id)
|
|
|
+
|
|
|
+ return action2_dict
|
|
|
+
|
|
|
+ action2_id_mem = redis_client.get(device_id)
|
|
|
+ step2 = redis_client.get(f"{device_id}_{perform_action_id}_step2")
|
|
|
+ if step2 is not None and int(step2) == 1 and action2_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action2_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action2_id_mem:{1}", device_id, int(action2_id_mem))
|
|
|
+
|
|
|
+ action3_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第3条指令
|
|
|
+ 点击搜索
|
|
|
+ """
|
|
|
+ action3_dict = single_click_by_control(action3_id, control_id="com.ss.android.auto:id/g9e")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action3_id)
|
|
|
+ redis_client.set(f"{device_id}_{action3_id}_step3", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action3_id}_step2")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action3_id:{1}", device_id, action3_id)
|
|
|
+
|
|
|
+ return action3_dict
|
|
|
+
|
|
|
+ action3_id_mem = redis_client.get(device_id)
|
|
|
+ step3 = redis_client.get(f"{device_id}_{perform_action_id}_step3")
|
|
|
+ if step3 is not None and int(step3) == 1 and action3_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action3_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action3_id_mem:{1}", device_id, int(action3_id_mem))
|
|
|
+
|
|
|
+ action4_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第4条指令
|
|
|
+ 点击tab->口碑
|
|
|
+ """
|
|
|
+ action4_dict = single_click_by_text(action4_id, text="口碑")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action4_id)
|
|
|
+ redis_client.set(f"{device_id}_{action4_id}_step4", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action4_id}_step3")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action3_id:{1}", device_id, action4_id)
|
|
|
+
|
|
|
+ return action4_dict
|
|
|
+
|
|
|
+ action4_id_mem = redis_client.get(device_id)
|
|
|
+ step4 = redis_client.get(f"{device_id}_{perform_action_id}_step4")
|
|
|
+
|
|
|
+ if step4 is not None and int(step4) == 1 and action4_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action4_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action4_id_mem:{1}", device_id, int(action4_id_mem))
|
|
|
+
|
|
|
+ action5_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第5条指令
|
|
|
+ 点击tab->车友圈
|
|
|
+ """
|
|
|
+ action5_dict = single_click_by_text(action5_id, text="车友圈")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action5_id)
|
|
|
+ redis_client.set(f"{device_id}_{action5_id}_step5", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action5_id}_step4")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action3_id:{1}", device_id, action5_id)
|
|
|
+
|
|
|
+ return action5_dict
|
|
|
+
|
|
|
+ action5_id_mem = redis_client.get(device_id)
|
|
|
+ step5 = redis_client.get(f"{device_id}_{perform_action_id}_step5")
|
|
|
+
|
|
|
+ if step5 is not None and int(step5) == 1 and action5_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action5_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action5_id_mem:{1}", device_id, int(action5_id_mem))
|
|
|
+
|
|
|
+ action6_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第6条指令
|
|
|
+ 点击tab->用户
|
|
|
+ """
|
|
|
+ action6_dict = single_click_by_text(action6_id, text="用户")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action6_id)
|
|
|
+ redis_client.set(f"{device_id}_{action6_id}_step6", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action6_id}_step5")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action3_id:{1}", device_id, action6_id)
|
|
|
+
|
|
|
+ return action6_dict
|
|
|
+
|
|
|
+ # 判断是否有搜索结果
|
|
|
+ action6_id_mem = redis_client.get(device_id)
|
|
|
+ step6 = redis_client.get(f"{device_id}_{perform_action_id}_step6")
|
|
|
+
|
|
|
+ if step6 is not None and int(step6) == 1 and action6_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action6_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action6_id_mem:{1}", device_id, int(action6_id_mem))
|
|
|
+
|
|
|
+ action7_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 点击搜素出来的博主
|
|
|
+ """
|
|
|
+ action7_dict = single_click_by_text(action7_id, text="飞凡F7")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action7_id)
|
|
|
+ redis_client.set(f"{device_id}_{action7_id}_step7", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action7_id}_step6")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action7_id:{1}", device_id, action7_id)
|
|
|
+
|
|
|
+ return action7_dict
|
|
|
+
|
|
|
+ # 存在搜索结果
|
|
|
+ action7_id_mem = redis_client.get(device_id)
|
|
|
+ step7 = redis_client.get(f"{device_id}_{perform_action_id}_step7")
|
|
|
+
|
|
|
+ if step7 is not None and int(step7) == 1 and action7_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action7_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action7_id_mem:{1}", device_id, int(action7_id_mem))
|
|
|
+
|
|
|
+ action8_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 存在搜索结果,已经跳转到了用户中心首页
|
|
|
+ 开始匹配文章
|
|
|
+ """
|
|
|
+ action8_dict = get_content_by_control(action8_id, control_id="android.widget.TextView",
|
|
|
+ title="北京福7飞凡车队正式成立啦")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action8_id)
|
|
|
+ redis_client.set(f"{device_id}_{action8_id}_step8", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action8_id}_step7")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action8_id:{1}", device_id, action8_id)
|
|
|
+
|
|
|
+ return action8_dict
|
|
|
+
|
|
|
+ # 文章匹配,点击评论
|
|
|
+ action8_id_mem = redis_client.get(device_id)
|
|
|
+ step8 = redis_client.get(f"{device_id}_{perform_action_id}_step8")
|
|
|
+ if step8 is not None and int(step8) == 1 and action8_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action8_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action8_id_mem:{1}", device_id, int(action8_id_mem))
|
|
|
+
|
|
|
+ action9_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 文章匹配,点击评论
|
|
|
+ """
|
|
|
+ loggerKit.info("action9_id:{0}, 文章匹配,点击评论", action9_id)
|
|
|
+ action9_dict = single_click_by_control(action9_id, control_id="com.ss.android.auto:id/ini")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action9_id)
|
|
|
+ redis_client.set(f"{device_id}_{action9_id}_step9", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action9_id}_step8")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action9_id:{1}", device_id, action9_id)
|
|
|
+
|
|
|
+ return action9_dict
|
|
|
+
|
|
|
+ # 文章匹配,点击输入框
|
|
|
+ action9_id_mem = redis_client.get(device_id)
|
|
|
+ step9 = redis_client.get(f"{device_id}_{perform_action_id}_step9")
|
|
|
+ if step9 is not None and int(step9) == 1 and action9_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action9_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action8_id_mem:{1}", device_id, int(action9_id_mem))
|
|
|
+
|
|
|
+ action10_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 文章匹配,点击输入框
|
|
|
+ """
|
|
|
+ loggerKit.info("action10_id:{0}, 文章匹配,点击输入框", action10_id)
|
|
|
+ action10_dict = single_click_by_control(action10_id, control_id="com.ss.android.auto:id/inv")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action10_id)
|
|
|
+ redis_client.set(f"{device_id}_{action10_id}_step10", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action10_id}_step9")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action10_id:{1}", device_id, action10_id)
|
|
|
+
|
|
|
+ return action10_dict
|
|
|
+
|
|
|
+ # 文章匹配,点击输入框,返回回复内容
|
|
|
+ action10_id_mem = redis_client.get(device_id)
|
|
|
+ step10 = redis_client.get(f"{device_id}_{perform_action_id}_step10")
|
|
|
+ if step10 is not None and int(step10) == 1 and action10_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action10_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action10_id_mem:{1}", device_id, int(action10_id_mem))
|
|
|
+
|
|
|
+ action11_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 文章匹配,点击输入框,返回回复内容
|
|
|
+ """
|
|
|
+ loggerKit.info("action11_id:{0}, 文章title:{1}, 回复内容:{2}")
|
|
|
+ action11_dict = send_text_by_control(action11_id, control_id="com.ss.android.auto:id/dcz", content="不错👍")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action11_id)
|
|
|
+ redis_client.set(f"{device_id}_{action11_id}_step11", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action11_id}_step10")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action11_id:{1}", device_id, action11_id)
|
|
|
+ return action11_dict
|
|
|
+
|
|
|
+ # 停止app
|
|
|
+ action11_id_mem = redis_client.get(device_id)
|
|
|
+ step11 = redis_client.get(f"{device_id}_{perform_action_id}_step11")
|
|
|
+ if step11 is not None and int(step11) == 1 and action11_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action11_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action11_id_mem:{1}", device_id, int(action11_id_mem))
|
|
|
+
|
|
|
+ action12_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 停止指令
|
|
|
+ 停止app
|
|
|
+ """
|
|
|
+
|
|
|
+ action12_dict = stop_app(action12_id, target_version="7.9.0")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action12_id)
|
|
|
+ redis_client.set(f"{device_id}_{action12_id}_step12", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action12_id}_step11")
|
|
|
+
|
|
|
+ # 批量模糊删除keys
|
|
|
+ keys = redis_client.match_pattern_prefix(device_id)
|
|
|
+ if len(keys) > 0:
|
|
|
+ # 需要判断是否有匹配的值, 没有的话会报错
|
|
|
+ for key in keys:
|
|
|
+ redis_client.delete(key)
|
|
|
+ loggerKit.info(f"clear {device_id} keys success...")
|
|
|
+ else:
|
|
|
+ loggerKit.info(f"{device_id} keys none ...")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action12_id:{1}", device_id, action12_id)
|
|
|
+
|
|
|
+ return action12_dict
|
|
|
+
|
|
|
+ else:
|
|
|
+
|
|
|
+ action0_id = int(round(time.time() * 1000))
|
|
|
+
|
|
|
+ """
|
|
|
+ 启动指令
|
|
|
+ 启动app
|
|
|
+ """
|
|
|
+
|
|
|
+ action0_dict = start_app(action0_id, target_version="7.9.0")
|
|
|
+
|
|
|
+ redis_client.set(device_id + "operate", action0_id)
|
|
|
+ redis_client.set(f"{device_id}_step0", "1")
|
|
|
+ redis_client.delete(f"{device_id}_step9")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action0_id:{1}", device_id, action0_id)
|
|
|
+
|
|
|
+ return action0_dict
|
|
|
+
|
|
|
+
|
|
|
+# 领取任务接口
|
|
|
+# @route(app, '/api/action_V2', methods=['POST'])
|
|
|
+def do_action_v2():
|
|
|
+ """
|
|
|
+ :param deviceID [必填]设备的ID
|
|
|
+ :param performActionId [非必填]前一条指令的ID
|
|
|
+ :param performActionResult success(指令成功) or failure(指令失败) or picNotFound(针对查找图片场景 图片未识别到) or stop(指令终止) or eleNotFound(针对元素 未获取到)
|
|
|
+ :param recognizedResult 你好,我是你根据控件Id查到的text内容
|
|
|
+ 领取任务接口
|
|
|
+ :return: 指令json串
|
|
|
+ """
|
|
|
+
|
|
|
+ request_data = request.json
|
|
|
+ loggerKit.info('请求信息:{0}'.format(request_data))
|
|
|
+
|
|
|
+ device_id = request_data.get("deviceID")
|
|
|
+
|
|
|
+ if device_id is None:
|
|
|
+ loggerKit.info('请求信息异常:{0}'.format(request_data))
|
|
|
+
|
|
|
+ return_dict = {
|
|
|
+ "data": "",
|
|
|
+ "code": -1,
|
|
|
+ "message": "fail, request device_id is null"
|
|
|
+ }
|
|
|
+
|
|
|
+ return return_dict
|
|
|
+
|
|
|
+ # 缓存中获取到对应的任务信息
|
|
|
+ task_response = redis_client.get(device_id + "_task_json")
|
|
|
+
|
|
|
+ if task_response is not None:
|
|
|
+ data = json.loads(task_response)
|
|
|
+
|
|
|
+ task = task_dict(str(data.get('taskId')), data.get('mediaChannel'), data.get('taskType'), data.get('taskDesc'),
|
|
|
+ data.get('actionType'),
|
|
|
+ data.get('resourceName'), data.get('subResourceName'), data.get('executeRobotAccount'),
|
|
|
+ data.get('executeRobotName'), data.get('deviceId'), data.get('content'),
|
|
|
+ data.get('answerType'),
|
|
|
+ data.get('materialUri'),
|
|
|
+ data.get('taskSubType'), data.get('taskSequenceId'), None, None, None, request_data,
|
|
|
+ data.get('taskKey'))
|
|
|
+ handler = rpa_handler().set_processor(task)
|
|
|
+
|
|
|
+ return handler.process_rpa(task)
|
|
|
+
|
|
|
+
|
|
|
+# 领取任务接口
|
|
|
+# @route(app, '/api/action', methods=['POST'])
|
|
|
+def do_action_():
|
|
|
+ """
|
|
|
+ :param deviceID [必填]设备的ID
|
|
|
+ :param performActionId [非必填]前一条指令的ID
|
|
|
+ :param performActionResult success or failure
|
|
|
+ :param recognizedResult 你好,我是你根据控件Id查到的text内容
|
|
|
+ 领取任务接口
|
|
|
+ :return: 指令json串
|
|
|
+ """
|
|
|
+
|
|
|
+ data = request.json
|
|
|
+ loggerKit.info('请求信息:{0}'.format(data))
|
|
|
+
|
|
|
+ device_id = data.get("deviceID")
|
|
|
+ perform_action_id = data.get("performActionId")
|
|
|
+ result = data.get("result")
|
|
|
+
|
|
|
+ if device_id is None:
|
|
|
+ loggerKit.info('请求信息异常:{0}'.format(data))
|
|
|
+
|
|
|
+ return_dict = {
|
|
|
+ "data": "",
|
|
|
+ "code": -1,
|
|
|
+ "message": "fail, request device_id is null"
|
|
|
+ }
|
|
|
+
|
|
|
+ return return_dict
|
|
|
+
|
|
|
+ # 获取到对应策略
|
|
|
+ action0_id_mem = redis_client.get(device_id)
|
|
|
+
|
|
|
+ # action0_id = int(round(time.time() * 1000))
|
|
|
+ if result is not None:
|
|
|
+ """
|
|
|
+ 非首个指令
|
|
|
+ """
|
|
|
+ perform_action_result = result.get("performActionResult")
|
|
|
+ if perform_action_result is None:
|
|
|
+ return_dict = {
|
|
|
+ "data": "",
|
|
|
+ "code": -2,
|
|
|
+ "message": "fail, performActionResult is null"
|
|
|
+ }
|
|
|
+
|
|
|
+ return return_dict
|
|
|
+
|
|
|
+ action0_id_mem = redis_client.get(device_id)
|
|
|
+ step0 = redis_client.get(f"{device_id}_step0")
|
|
|
+ if step0 is not None and int(step0) == 1 and action0_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action0_id_mem) and perform_action_result == "success":
|
|
|
+ action1_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第1条指令
|
|
|
+ 懂车帝APP首页点击搜索框
|
|
|
+ """
|
|
|
+
|
|
|
+ action1_dict = single_click_by_control(action1_id, target_version="7.9.0",
|
|
|
+ control_id="com.ss.android.auto:id/c9c")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action1_id)
|
|
|
+ redis_client.set(f"{device_id}_{action1_id}_step1", "1")
|
|
|
+ redis_client.delete(f"{device_id}_step0")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action1_id:{1}", device_id, action1_id)
|
|
|
+
|
|
|
+ return action1_dict
|
|
|
+
|
|
|
+ action1_id_mem = redis_client.get(device_id)
|
|
|
+ step1 = redis_client.get(f"{device_id}_{perform_action_id}_step1")
|
|
|
+ if step1 is not None and int(step1) == 1 and action1_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action1_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action1_id_mem:{1}", device_id, int(action1_id_mem))
|
|
|
+
|
|
|
+ action2_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第2条指令
|
|
|
+ 在搜索框输入关键词
|
|
|
+ """
|
|
|
+ action2_dict = send_text_by_control(action2_id, control_id="com.ss.android.auto:id/h5q", content="飞凡F7")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action2_id)
|
|
|
+ redis_client.set(f"{device_id}_{action2_id}_step2", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action2_id}_step1")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action2_id:{1}", device_id, action2_id)
|
|
|
+
|
|
|
+ return action2_dict
|
|
|
+
|
|
|
+ action2_id_mem = redis_client.get(device_id)
|
|
|
+ step2 = redis_client.get(f"{device_id}_{perform_action_id}_step2")
|
|
|
+ if step2 is not None and int(step2) == 1 and action2_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action2_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action2_id_mem:{1}", device_id, int(action2_id_mem))
|
|
|
+
|
|
|
+ action3_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第3条指令
|
|
|
+ 点击搜索
|
|
|
+ """
|
|
|
+ action3_dict = single_click_by_control(action3_id, control_id="com.ss.android.auto:id/g9e")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action3_id)
|
|
|
+ redis_client.set(f"{device_id}_{action3_id}_step3", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action3_id}_step2")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action3_id:{1}", device_id, action3_id)
|
|
|
+
|
|
|
+ return action3_dict
|
|
|
+
|
|
|
+ action3_id_mem = redis_client.get(device_id)
|
|
|
+ step3 = redis_client.get(f"{device_id}_{perform_action_id}_step3")
|
|
|
+ if step3 is not None and int(step3) == 1 and action3_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action3_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action3_id_mem:{1}", device_id, int(action3_id_mem))
|
|
|
+
|
|
|
+ action4_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第4条指令
|
|
|
+ 点击tab->口碑
|
|
|
+ """
|
|
|
+ action4_dict = single_click_by_text(action4_id, text="二手车")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action4_id)
|
|
|
+ redis_client.set(f"{device_id}_{action4_id}_step4", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action4_id}_step3")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action3_id:{1}", device_id, action4_id)
|
|
|
+
|
|
|
+ return action4_dict
|
|
|
+
|
|
|
+ action4_id_mem = redis_client.get(device_id)
|
|
|
+ step4 = redis_client.get(f"{device_id}_{perform_action_id}_step4")
|
|
|
+
|
|
|
+ if step4 is not None and int(step4) == 1 and action4_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action4_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action4_id_mem:{1}", device_id, int(action4_id_mem))
|
|
|
+
|
|
|
+ action5_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第5条指令
|
|
|
+ 点击tab->车友圈
|
|
|
+ """
|
|
|
+ action5_dict = single_click_by_text(action5_id, text="车友圈")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action5_id)
|
|
|
+ redis_client.set(f"{device_id}_{action5_id}_step5", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action5_id}_step4")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action3_id:{1}", device_id, action5_id)
|
|
|
+
|
|
|
+ return action5_dict
|
|
|
+
|
|
|
+ action5_id_mem = redis_client.get(device_id)
|
|
|
+ step5 = redis_client.get(f"{device_id}_{perform_action_id}_step5")
|
|
|
+
|
|
|
+ if step5 is not None and int(step5) == 1 and action5_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action5_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action5_id_mem:{1}", device_id, int(action5_id_mem))
|
|
|
+
|
|
|
+ action6_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 发送第6条指令
|
|
|
+ 点击tab->用户
|
|
|
+ """
|
|
|
+ action6_dict = single_click_by_text(action6_id, text="用户")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action6_id)
|
|
|
+ redis_client.set(f"{device_id}_{action6_id}_step6", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action6_id}_step5")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action3_id:{1}", device_id, action6_id)
|
|
|
+
|
|
|
+ return action6_dict
|
|
|
+
|
|
|
+ # 判断是否有搜索结果
|
|
|
+ action6_id_mem = redis_client.get(device_id)
|
|
|
+ step6 = redis_client.get(f"{device_id}_{perform_action_id}_step6")
|
|
|
+
|
|
|
+ if step6 is not None and int(step6) == 1 and action6_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action6_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action6_id_mem:{1}", device_id, int(action6_id_mem))
|
|
|
+
|
|
|
+ action7_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 点击搜素出来的博主
|
|
|
+ """
|
|
|
+ action7_dict = single_click_by_text(action7_id, text="飞凡F7")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action7_id)
|
|
|
+ redis_client.set(f"{device_id}_{action7_id}_step7", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action7_id}_step6")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action7_id:{1}", device_id, action7_id)
|
|
|
+
|
|
|
+ return action7_dict
|
|
|
+
|
|
|
+ # 存在搜索结果
|
|
|
+ action7_id_mem = redis_client.get(device_id)
|
|
|
+ step7 = redis_client.get(f"{device_id}_{perform_action_id}_step7")
|
|
|
+
|
|
|
+ if step7 is not None and int(step7) == 1 and action7_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action7_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action7_id_mem:{1}", device_id, int(action7_id_mem))
|
|
|
+
|
|
|
+ action8_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 存在搜索结果,已经跳转到了用户中心首页
|
|
|
+ 开始匹配文章
|
|
|
+ """
|
|
|
+ action8_dict = get_content_by_control(action8_id, control_id="android.widget.TextView",
|
|
|
+ title="北京福7飞凡车队正式成立啦")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action8_id)
|
|
|
+ redis_client.set(f"{device_id}_{action8_id}_step8", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action8_id}_step7")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action8_id:{1}", device_id, action8_id)
|
|
|
+
|
|
|
+ return action8_dict
|
|
|
+
|
|
|
+ # 文章评论,点击铅笔父节点
|
|
|
+ action8_id_mem = redis_client.get(device_id)
|
|
|
+ step8 = redis_client.get(f"{device_id}_{perform_action_id}_step8")
|
|
|
+ if step8 is not None and int(step8) == 1 and action8_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action8_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action8_id_mem:{1}", device_id, int(action8_id_mem))
|
|
|
+
|
|
|
+ action9_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 文章匹配,点击评论
|
|
|
+ """
|
|
|
+ loggerKit.info("action9_id:{0}, 文章评论,点击铅笔父节点", action9_id)
|
|
|
+ action9_dict = single_click_by_control(action9_id, control_id="com.ss.android.auto:id/d98")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action9_id)
|
|
|
+ redis_client.set(f"{device_id}_{action9_id}_step9", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action9_id}_step8")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action9_id:{1}", device_id, action9_id)
|
|
|
+
|
|
|
+ return action9_dict
|
|
|
+
|
|
|
+ """
|
|
|
+ 文章匹配,点击输入框,返回回复内容
|
|
|
+ """
|
|
|
+ action9_id_mem = redis_client.get(device_id)
|
|
|
+ step9 = redis_client.get(f"{device_id}_{perform_action_id}_step9")
|
|
|
+ if step9 is not None and int(step9) == 1 and action9_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action9_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action9_id_mem:{1}", device_id, int(action9_id_mem))
|
|
|
+
|
|
|
+ action10_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 文章匹配,点击输入框,返回回复内容
|
|
|
+ """
|
|
|
+ loggerKit.info("action10_id:{0}, 文章title:{1}, 回复内容:{2}")
|
|
|
+ action11_dict = send_text_by_control(action10_id, control_id="com.ss.android.auto:id/byd", content="不错👍")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action10_id)
|
|
|
+ redis_client.set(f"{device_id}_{action10_id}_step10", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action10_id}_step9")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action10_id:{1}", device_id, action10_id)
|
|
|
+ return action11_dict
|
|
|
+
|
|
|
+ """
|
|
|
+ 点击发送按钮
|
|
|
+ """
|
|
|
+ action10_id_mem = redis_client.get(device_id)
|
|
|
+ step10 = redis_client.get(f"{device_id}_{perform_action_id}_step10")
|
|
|
+ if step10 is not None and int(step10) == 1 and action10_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action10_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action9_id_mem:{1}", device_id, int(action10_id_mem))
|
|
|
+
|
|
|
+ action11_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 文章匹配,点击输入框,返回回复内容
|
|
|
+ """
|
|
|
+ action11_dict = single_click_by_control(action11_id, control_id="com.ss.android.auto:id/jxq")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action11_id)
|
|
|
+ redis_client.set(f"{device_id}_{action11_id}_step11", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action11_id}_step10")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action11_id:{1}", device_id, action11_id)
|
|
|
+ return action11_dict
|
|
|
+
|
|
|
+ """
|
|
|
+ 停止app
|
|
|
+ """
|
|
|
+ action11_id_mem = redis_client.get(device_id)
|
|
|
+ step11 = redis_client.get(f"{device_id}_{perform_action_id}_step11")
|
|
|
+ if step11 is not None and int(step11) == 1 and action11_id_mem is not None and int(perform_action_id) == int(
|
|
|
+ action11_id_mem) and perform_action_result == "success":
|
|
|
+ loggerKit.info("设备:{0}, action10_id_mem:{1}", device_id, int(action11_id_mem))
|
|
|
+
|
|
|
+ action12_id = int(round(time.time() * 1000))
|
|
|
+ """
|
|
|
+ 停止指令
|
|
|
+ 停止app
|
|
|
+ """
|
|
|
+
|
|
|
+ action12_dict = stop_app(action12_id, target_version="7.9.0")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action12_id)
|
|
|
+ redis_client.set(f"{device_id}_{action12_id}_step12", "1")
|
|
|
+ redis_client.delete(f"{device_id}_{action12_id}_step11")
|
|
|
+
|
|
|
+ # 批量模糊删除keys
|
|
|
+ keys = redis_client.match_pattern_prefix(device_id)
|
|
|
+ if len(keys) > 0:
|
|
|
+ # 需要判断是否有匹配的值, 没有的话会报错
|
|
|
+ for key in keys:
|
|
|
+ redis_client.delete(key)
|
|
|
+ loggerKit.info(f"clear {device_id} keys success...")
|
|
|
+ else:
|
|
|
+ loggerKit.info(f"{device_id} keys none ...")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action12_id:{1}", device_id, action12_dict)
|
|
|
+
|
|
|
+ return action12_dict
|
|
|
+
|
|
|
+ else:
|
|
|
+
|
|
|
+ action0_id = int(round(time.time() * 1000))
|
|
|
+
|
|
|
+ """
|
|
|
+ 启动指令
|
|
|
+ 启动app
|
|
|
+ """
|
|
|
+
|
|
|
+ action0_dict = start_app(action0_id, target_version="7.9.0")
|
|
|
+
|
|
|
+ redis_client.set(device_id, action0_id)
|
|
|
+ redis_client.set(f"{device_id}_step0", "1")
|
|
|
+ redis_client.delete(f"{device_id}_step9")
|
|
|
+
|
|
|
+ loggerKit.info("设备:{0}, action0_id:{1}", device_id, action0_id)
|
|
|
+
|
|
|
+ return action0_dict
|
|
|
+
|
|
|
+
|
|
|
+# 定时任务
|
|
|
+def scheduler_start():
|
|
|
+ rpa_scheduler = BackgroundScheduler()
|
|
|
+
|
|
|
+ # 定时拉取任务
|
|
|
+ rpa_scheduler.add_job(auto_pull_task, 'interval', seconds=1, max_instances=60)
|
|
|
+ # 定时上报设备状态
|
|
|
+ # rpa_scheduler.add_job(auto_synchronization_devices_status_func, 'interval', seconds=60, max_instances=2)
|
|
|
+ rpa_scheduler.start()
|
|
|
+
|
|
|
+
|
|
|
+@route(app, '/api/action', methods=['POST'])
|
|
|
+def do_action():
|
|
|
+ """
|
|
|
+ 入参:
|
|
|
+ :param taskId
|
|
|
+ :param taskType
|
|
|
+ :param subTaskType
|
|
|
+ :param requestId
|
|
|
+ :param scriptName
|
|
|
+ :param deviceID [必填]设备的ID
|
|
|
+ :param performActionId [非必填]前一条指令的ID
|
|
|
+ :param performActionResult success(指令成功) or failure(指令失败) or picNotFound(针对查找图片场景 图片未识别到) or stop(指令终止) or eleNotFound(针对元素 未获取到)
|
|
|
+ :param recognizedResult 你好,我是你根据控件Id查到的text内容
|
|
|
+ 领取任务接口
|
|
|
+ :return: 指令json串
|
|
|
+ """
|
|
|
+
|
|
|
+ request_data = request.json
|
|
|
+ loggerKit.info('请求信息:{0}'.format(request_data))
|
|
|
+
|
|
|
+ # device_work(device_id)
|
|
|
+
|
|
|
+ # 缓存中获取到对应的任务信息
|
|
|
+ # task_response = redis_client.get(device_id + "_task_json")
|
|
|
+
|
|
|
+ """
|
|
|
+ 根据任务类型、子任务类型匹配不同的执行脚本
|
|
|
+ """
|
|
|
+ if request_data is not None:
|
|
|
+
|
|
|
+ device_id = request_data.get("deviceID")
|
|
|
+ # task_id = request_data.get("taskID")
|
|
|
+ # task_type = request_data.get("taskType")
|
|
|
+ # sub_task_type = request_data.get("subTaskType")
|
|
|
+ data = request_data.get("data")
|
|
|
+
|
|
|
+ if device_id is None or data is None:
|
|
|
+ loggerKit.info('请求信息异常:{0}'.format(request_data))
|
|
|
+
|
|
|
+ return_dict = {
|
|
|
+ "data": "",
|
|
|
+ "code": -1,
|
|
|
+ "message": "fail, request device_id or task_pull_data is none"
|
|
|
+ }
|
|
|
+
|
|
|
+ return return_dict
|
|
|
+
|
|
|
+ task = task_dict(int(data.get('taskId')), data.get('mediaChannel'), data.get('taskType'), data.get('taskDesc'),
|
|
|
+ data.get('actionType'),
|
|
|
+ data.get('resourceName'), data.get('subResourceName'), data.get('executeRobotAccount'),
|
|
|
+ data.get('executeRobotName'), data.get('deviceId'), data.get('content'),
|
|
|
+ data.get('answerType'),
|
|
|
+ data.get('materialUri'),
|
|
|
+ data.get('taskSubType'), data.get('taskSequenceId'), None, None, None, request_data,data.get('taskKey'))
|
|
|
+ handler = rpa_atom_handler().set_processor(task)
|
|
|
+
|
|
|
+ return handler.process_rpa(task)
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ app.json_encoder = JSONEncoder
|
|
|
+ # scheduler_start()
|
|
|
+
|
|
|
+ app.run(debug=True, host='0.0.0.0', port=80)
|
|
|
+ print(f'API服务启动成功')
|