From 5467bbc23273409548c777b0bacf489113e2dd47 Mon Sep 17 00:00:00 2001 From: dongchangxi <458593490@qq.com> Date: Wed, 1 Nov 2023 14:49:37 +0800 Subject: [PATCH] =?UTF-8?q?bug=20=E4=BF=AE=E6=94=B9=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=20push=5Fcmd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main_service.py | 2 +- tools/push_cmd.py | 92 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 82 insertions(+), 12 deletions(-) diff --git a/main_service.py b/main_service.py index 1dfb636..94eae47 100644 --- a/main_service.py +++ b/main_service.py @@ -10,7 +10,7 @@ else: sys.path.append('/data/deploy/make3d/make2/libs/') import main_service_db,config if __name__ == '__main__': - if len(sys.argv) == 1: + if len(sys.argv) == 2: print(sys.argv[1]) os.system(f'python main_step1.py {sys.argv[1]}') else: diff --git a/tools/push_cmd.py b/tools/push_cmd.py index 1f5f48e..b694df1 100644 --- a/tools/push_cmd.py +++ b/tools/push_cmd.py @@ -1,17 +1,17 @@ -import redis, os, sys +import redis, os, sys,requests sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import config, libs def main(cmd, order_id): - if cmd == 'print': + if cmd == 'print': #order_id key = 'model:printOrder' - elif cmd == 'repair': + elif cmd == 'repair': #order_id key = 'model:IndependentRepairTeamcheckGLBQueue' - elif cmd == 'make3d': + elif cmd == 'make3d': #pid key = 'model:make' - elif cmd == 'make3d10': + elif cmd == 'make3d10': #pid key = 'model:make10' - elif cmd == 'foot': + elif cmd == 'foot': # print_id key = 'model:foot' if order_id == 'view': @@ -24,14 +24,84 @@ def main(cmd, order_id): r.lpush(key, order_id) print(f'已推送{order_id}到{key}, 当前队列长度:{r.llen(key)}') +def cmd(cmdName,pid): + res = requests.get(f'https://mp.api.suwa3d.com/api/infoQuery/infoByPid?pid={pid}&cmd={cmdName}') + #获取res 的数据 + res = res.json() + if res["code"] != 1000: + print("查询失败",res) + exit(1) + data = res["data"] + if cmdName == 'print' or cmdName == 'repair': + #需要去吃查询pid 对应的order_id + #遍历data + for i in data: + #获取 pid 对应的数据 + tempData = data[i] + if len(tempData) == 1: + #pid 只有对应的一笔数据就可以直接插入了 + main(cmdName, tempData[0]["order_id"]) + else: + while True: + try: + + tempDataStrings = listDataToStr(tempData,cmdName) + order_id = int(input("pid-"+i+"对应有多个数据,请从下列中选择正确的order_id填入\r\n"+tempDataStrings+"\r\n->")) + # 在这里处理用户输入的整数 + print("输入的是: ", order_id) + main(cmdName, order_id) + break + except ValueError: + print("输入不满足要求,请重新输入") + + elif cmdName == 'foot': + + #遍历data + for i in data: + #获取 pid 对应的数据 + tempData = data[i] + if len(tempData) == 1: + #pid 只有对应的一笔数据就可以直接插入了 + main(cmdName, tempData[0]["print_id"]) + else: + while True: + try: + #tempData 转字符串 + tempDataStrings = listDataToStr(tempData,cmdName) + printId = int(input("pid-"+i+"对应有多个数据,请从下列中选择正确的print_id填入\r\n"+tempDataStrings+"\r\n->")) + # 在这里处理用户输入的整数 + print("输入的是: ", printId) + main(cmdName, printId) + break + except ValueError: + print("输入不满足要求,请重新输入") + else: + print("不支持的命令",cmdName) + +def listDataToStr(data,cmdName): + strMessage = "" + for i in data: + if cmdName == "foot": + strMessage += i['createTime']+" print_id:"+str(i['print_id'])+"\r\n" + else: + strMessage += i['createTime']+" order_id:"+str(i['order_id'])+"\r\n" + return strMessage + + if __name__ == '__main__': if len(sys.argv) == 3: - cmd = sys.argv[1] - order_id = sys.argv[2] + cmdName = sys.argv[1] + pid = sys.argv[2] else: print('用法:python push_cmd.py ') exit(1) - r = config.redis_local - - main(cmd, order_id) \ No newline at end of file + + #pid 可能是多个的,用逗号分隔,查询的时候接口应该也要支持多个的 + if cmd == 'make3d' or cmd == 'make3d10': + main(cmdName, pid) + elif cmd != "": + cmd(cmdName,pid) + else: + print('用法:python push_cmd.py ') + exit(1) \ No newline at end of file