1
This commit is contained in:
1 parent
6cd62db8aa
commit
1a41ca6b03
2 files changed
+35
-10
No files matched your search
@@ -75,10 +75,32 @@ def down_obj_from_oss(workdir, pid, action):
|
||||
return obj_filename
|
||||
|
||||
#加载obj文件
|
||||
def reload_obj(pid):
|
||||
def reload_obj(pid,order_ids):
|
||||
|
||||
#下载obj文件
|
||||
down_obj_from_oss(config.workdir, pid, "print")
|
||||
for order_id in order_ids:
|
||||
print(order_id)
|
||||
#url 请求
|
||||
url = f"https://mp.api.suwa3d.com/api/printOrder/infoByOrderId?id={order_id}"
|
||||
response = requests.get(url)
|
||||
response = response.json()
|
||||
if response['code'] != 1000:
|
||||
continue
|
||||
|
||||
#获取打印尺寸
|
||||
printdata = response['data']['data']
|
||||
for key,value in printdata.items():
|
||||
#去掉cm
|
||||
key = key.replace('cm','')
|
||||
key = float(key)*10
|
||||
print(key)
|
||||
print(f'执行脚本--- "python D:/make2/tools/cal_weight.py print {pid} {key} {order_id}"')
|
||||
#发起计算请求
|
||||
os.system(f"python D:/make2/tools/cal_weight.py print {pid} {key} {order_id}")
|
||||
#计算克重信息
|
||||
|
||||
|
||||
obj_filename = os.path.join(config.workdir,'print',pid,f'{pid}.obj')
|
||||
bpy.ops.wm.read_homefile()
|
||||
bpy.ops.object.delete(use_global=False, confirm=False)
|
||||
@@ -108,9 +130,9 @@ def get_p3d_info(pid):
|
||||
return 0
|
||||
|
||||
|
||||
def base_fix(pid):
|
||||
def base_fix(pid,order_ids):
|
||||
# 统一blender环境
|
||||
reload_obj(pid)
|
||||
reload_obj(pid,order_ids)
|
||||
# 统一模型方向、位置、大小...
|
||||
pid_objname = find_pid_objname(pid)
|
||||
obj = bpy.data.objects[pid_objname]
|
||||
@@ -209,10 +231,10 @@ def export_and_update_glbs(pid):
|
||||
#更新该笔订单的状态为 3000
|
||||
requests.post("https://shop.api.suwa3d.com/api/printOrder/updateExternalOrderStatus", data={'pid': pid})
|
||||
|
||||
def createGlb(pid):
|
||||
def createGlb(pid,order_ids):
|
||||
|
||||
|
||||
base_fix(pid)
|
||||
base_fix(pid,order_ids)
|
||||
export_and_update_glbs(pid)
|
||||
#移除文件夹
|
||||
# try:
|
||||
@@ -247,21 +269,25 @@ if __name__ == '__main__':
|
||||
r = create_redis_connection()
|
||||
while True:
|
||||
try:
|
||||
if r.llen('model:3dglb') == 0:
|
||||
if r.llen('model:3dglbV2') == 0:
|
||||
print('队列为空,等待10秒')
|
||||
time.sleep(10)
|
||||
continue
|
||||
|
||||
info = r.lpop('model:3dglb')
|
||||
info = r.lpop('model:3dglbV2')
|
||||
if info is None:
|
||||
print('队列为空,等待10秒')
|
||||
time.sleep(10)
|
||||
pid = info.decode('utf-8')
|
||||
|
||||
|
||||
info = json.loads(info)
|
||||
pid = info['pid']
|
||||
order_ids = info['order_id']
|
||||
|
||||
if not pid.isdigit():
|
||||
continue
|
||||
|
||||
createGlb(pid)
|
||||
createGlb(pid,order_ids)
|
||||
except Exception as e:
|
||||
print(f'错误:{e}')
|
||||
time.sleep(10)
|
||||
|
||||
@@ -5,7 +5,6 @@ r = redis.Redis(host="172.31.1.253",password="",port=6379,db=6)
|
||||
# info 是json字符串 {"order_id":[858344,858345],"pid":271916}
|
||||
info = r.lpop('model:3dglb')
|
||||
info = json.loads('{"order_id":[858344,858345],"pid":271916}')
|
||||
print(info)
|
||||
#获取 order_id 列表
|
||||
order_id_list = info['order_id']
|
||||
#获取 pid
|
||||
|
||||
Reference in new issue
Block a user