|
|
|
@ -54,6 +54,10 @@ def down_obj_from_oss(workdir, pid, action): |
|
|
|
|
|
|
|
|
|
|
|
os.makedirs(os.path.join(workdir, action, pid)) |
|
|
|
os.makedirs(os.path.join(workdir, action, pid)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
jpgsTemp = f'objs/print/{pid}/base/model/{pid}Tex1.jpg' |
|
|
|
|
|
|
|
mtlTemp = f'objs/print/{pid}/base/model/{pid}.mtl' |
|
|
|
|
|
|
|
objTemp = f'objs/print/{pid}/base/model/{pid}.obj' |
|
|
|
|
|
|
|
|
|
|
|
# 根据前缀获取文件列表 |
|
|
|
# 根据前缀获取文件列表 |
|
|
|
prefix = f'objs/print/{pid}/base/model/' |
|
|
|
prefix = f'objs/print/{pid}/base/model/' |
|
|
|
filelist = oss2.ObjectIteratorV2(config.oss_bucket, prefix=prefix) |
|
|
|
filelist = oss2.ObjectIteratorV2(config.oss_bucket, prefix=prefix) |
|
|
|
@ -69,6 +73,10 @@ def down_obj_from_oss(workdir, pid, action): |
|
|
|
if filename.endswith("_1.jpg") or filename.endswith("_8.jpg"): |
|
|
|
if filename.endswith("_1.jpg") or filename.endswith("_8.jpg"): |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if filename != jpgsTemp and filename != mtlTemp and filename != objTemp: |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
if filename.endswith('.obj'): |
|
|
|
if filename.endswith('.obj'): |
|
|
|
obj_filename = filename |
|
|
|
obj_filename = filename |
|
|
|
# print('正在下载:', file.key) |
|
|
|
# print('正在下载:', file.key) |
|
|
|
@ -77,11 +85,61 @@ def down_obj_from_oss(workdir, pid, action): |
|
|
|
|
|
|
|
|
|
|
|
return obj_filename |
|
|
|
return obj_filename |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def checkDownloadFile(pid): |
|
|
|
|
|
|
|
mtlfilePath = os.path.join(config.workdir, "print", pid,f"{pid}.mtl") |
|
|
|
|
|
|
|
objfilePath = os.path.join(config.workdir, "print", pid,f"{pid}.obj") |
|
|
|
|
|
|
|
#读取该笔文件的mtl文件 |
|
|
|
|
|
|
|
with open(mtlfilePath, 'r') as file: |
|
|
|
|
|
|
|
mtlContent = file.read() |
|
|
|
|
|
|
|
#检测mtl文件是否正常 |
|
|
|
|
|
|
|
if mtlContent == "": |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
#判断mtl 包含几个 newmtl |
|
|
|
|
|
|
|
newmtlCount = mtlContent.count('newmtl') |
|
|
|
|
|
|
|
if newmtlCount > 1: |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#判断mtlContent是否包含 {pid}Tex1.jpg |
|
|
|
|
|
|
|
if f'{pid}Tex1.jpg' not in mtlContent: |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#检测obj文件 里 是否包含 o {pid}, |
|
|
|
|
|
|
|
isContain = False |
|
|
|
|
|
|
|
with open(objfilePath, 'r') as file: |
|
|
|
|
|
|
|
for line in file: |
|
|
|
|
|
|
|
if line.startswith(f'o {pid}'): |
|
|
|
|
|
|
|
isContain = True |
|
|
|
|
|
|
|
print(f'{pid}的obj文件检测没问题') |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if isContain == False: |
|
|
|
|
|
|
|
print(f'{pid}的obj文件检测出现问题了, 没有找到o {pid} 的行') |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return isContain |
|
|
|
|
|
|
|
|
|
|
|
#加载obj文件 |
|
|
|
#加载obj文件 |
|
|
|
def reload_obj(pid,order_ids): |
|
|
|
def reload_obj(pid,order_ids): |
|
|
|
|
|
|
|
|
|
|
|
#下载obj文件 |
|
|
|
#下载obj文件 |
|
|
|
down_obj_from_oss(config.workdir, pid, "print") |
|
|
|
down_obj_from_oss(config.workdir, pid, "print") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#检测mtl 文件是否正常, |
|
|
|
|
|
|
|
isNormal = checkDownloadFile(pid) |
|
|
|
|
|
|
|
if isNormal == False: |
|
|
|
|
|
|
|
print(f'{pid}的mtl文件检测出现问题,不执行该笔任务,调用取消的接口') |
|
|
|
|
|
|
|
for order_id in order_ids: |
|
|
|
|
|
|
|
url = f"https://mp.api.suwa3d.com/api/order/cancelExternalOrder?id={order_id}&typename=system" |
|
|
|
|
|
|
|
response = requests.get(url) |
|
|
|
|
|
|
|
response = response.json() |
|
|
|
|
|
|
|
if response['code'] != 1000: |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
print(f'取消订单{order_id}成功') |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for order_id in order_ids: |
|
|
|
for order_id in order_ids: |
|
|
|
print(order_id) |
|
|
|
print(order_id) |
|
|
|
#url 请求 |
|
|
|
#url 请求 |
|
|
|
|