1
This commit is contained in:
1 parent
babcc0baa4
commit
7c37ee63e9
1 file changed
+12
-22
@@ -87,7 +87,6 @@ def down_obj_from_oss(workdir, pid, action):
|
||||
|
||||
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")
|
||||
|
||||
# 读取文件内容(自动检测编码)
|
||||
def read_file_auto_encoding(path):
|
||||
@@ -263,11 +262,11 @@ def export_and_update_glbs(pid,order_ids):
|
||||
bpy.ops.object.modifier_apply(modifier="Decimate")
|
||||
|
||||
glb_filename = os.path.join(config.workdir,'print',pid,f'{pid}-3d.glb')
|
||||
bpy.ops.export_scene.gltf(filepath=glb_filename, export_format='GLB', export_apply=True, export_jpeg_quality=100, export_draco_mesh_compression_enable=False)
|
||||
bpy.ops.export_scene.gltf(filepath=glb_filename, export_format='GLB', export_apply=True, export_jpeg_quality=75, export_draco_mesh_compression_enable=False)
|
||||
|
||||
# os.system(f'gltfpack -c -i {os.path.join(config.workdir, "print",pid, f"{pid}.glb")} -o {os.path.join(config.workdir, "print",pid, f"{pid}-pack.glb")}')
|
||||
config.oss_bucket.put_object_from_file(f'glbs/auto/{pid}.glb', os.path.join(config.workdir, 'print',pid, f'{pid}-3d.glb'))
|
||||
config.oss_bucket.put_object_from_file(f'glbs/print/{pid}.glb', os.path.join(config.workdir, 'print',pid, f'{pid}-3d.glb'))
|
||||
os.system(f'gltfpack -c -i {os.path.join(config.workdir, "print",pid, f"{pid}.glb")} -o {os.path.join(config.workdir, "print",pid, f"{pid}-pack.glb")}')
|
||||
config.oss_bucket.put_object_from_file(f'glbs/auto/{pid}.glb', os.path.join(config.workdir, 'print',pid, f'{pid}-pack.glb'))
|
||||
config.oss_bucket.put_object_from_file(f'glbs/print/{pid}.glb', os.path.join(config.workdir, 'print',pid, f'{pid}-pack.glb'))
|
||||
config.oss_bucket.put_object_from_file(f'glbs/3d/{pid}.glb', os.path.join(config.workdir,'print',pid, f'{pid}-3d.glb'))
|
||||
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} glb文件导出并上传完成,共费时{libs.diff_time(start_time)}')
|
||||
@@ -283,17 +282,7 @@ def export_and_update_glbs(pid,order_ids):
|
||||
print(strRequest)
|
||||
res = requests.post("https://shop.api.suwa3d.com/api/printOrder/updateExternalOrderStatusV2", data={'pid': pid,"order_ids":order_ids})
|
||||
print(res.text)
|
||||
# # 记录日志文件
|
||||
# logPath = os.path.join(config.workdir,"log",'external_order_glbV2',pid,f'{order_ids}.log')
|
||||
# os.makedirs(logPath, exist_ok=True)
|
||||
# # 创建并且写入日志
|
||||
# with open(logPath, 'w+') as f:
|
||||
# f.write(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 订单状态更新完成,共费时{libs.diff_time(start_time)}\n')
|
||||
# f.write(f'{res.text}\n')
|
||||
# f.write(f'{strRequest}\n')
|
||||
|
||||
|
||||
|
||||
#执行获取obj缩略图
|
||||
print("执行获取obj全身缩略图脚本")
|
||||
os.system(f'python d:\\make2\\tools\pic_for_obj\image_rander_small.py -pid {pid} -i D://print/{pid} -o D://print/{pid}')
|
||||
@@ -316,7 +305,8 @@ def export_and_update_glbs(pid,order_ids):
|
||||
f.write(str(info))
|
||||
|
||||
def createGlb(pid,order_ids):
|
||||
|
||||
config.workdir = "D://print"
|
||||
config.workdir += "/" + str(order_ids[0])
|
||||
#下载obj文件
|
||||
down_obj_from_oss(config.workdir, pid, "print")
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 下载obj文件完成...')
|
||||
@@ -336,11 +326,7 @@ def createGlb(pid,order_ids):
|
||||
|
||||
base_fix(pid,order_ids)
|
||||
export_and_update_glbs(pid,order_ids)
|
||||
#移除文件夹
|
||||
# try:
|
||||
# shutil.rmtree(os.path.join(config.workdir,'print',pid))
|
||||
# except:
|
||||
# pass
|
||||
|
||||
|
||||
|
||||
def create_redis_connection():
|
||||
@@ -390,8 +376,12 @@ if __name__ == '__main__':
|
||||
|
||||
# if not pid.isdigit():
|
||||
# continue
|
||||
|
||||
#遍历处理
|
||||
for order_id in order_ids:
|
||||
createGlb(str(pid),[order_id])
|
||||
|
||||
createGlb(str(pid),order_ids)
|
||||
# createGlb(str(pid),order_ids)
|
||||
except Exception as e:
|
||||
print(f'错误:{e}')
|
||||
time.sleep(10)
|
||||
|
||||
Reference in new issue
Block a user