1
This commit is contained in:
1 parent
071e95f9ce
commit
789b785377
1 file changed
+21
-16
+21
-16
@@ -24,13 +24,15 @@ def down_obj_fromoss(pid,order_id):
|
|||||||
# print_type:// 打印状态 1:正常打印 2:重打 3:加打,4: 样品
|
# print_type:// 打印状态 1:正常打印 2:重打 3:加打,4: 样品
|
||||||
print('开始下载obj文件...' , pid)
|
print('开始下载obj文件...' , pid)
|
||||||
#请求接口 获取 对应的 oss 地址
|
#请求接口 获取 对应的 oss 地址
|
||||||
tempUrl = f'https://mp.gray.api.suwa3d.com/api/order/getOssSuffixByOrderId?order_id={order_id}'
|
tempUrl = f'https://mp.api.suwa3d.com/api/order/getOssSuffixByOrderId?order_id={order_id}'
|
||||||
|
print(tempUrl)
|
||||||
#发起请求
|
#发起请求
|
||||||
res = requests.get(tempUrl)
|
res = requests.get(tempUrl)
|
||||||
ossPath = ""
|
ossPath = ""
|
||||||
if res.json()['code'] == 1000:
|
if res.json()['code'] == 1000:
|
||||||
ossPath = res.json()['data']
|
ossPath = res.json()['data']
|
||||||
ossPath = ossPath.replace("\\","/")
|
ossPath = ossPath.replace("\\","/")
|
||||||
|
print("AAAAAAAAA",ossPath)
|
||||||
|
|
||||||
|
|
||||||
path = os.path.join(workdir, 'print', pid)
|
path = os.path.join(workdir, 'print', pid)
|
||||||
@@ -43,7 +45,6 @@ def down_obj_fromoss(pid,order_id):
|
|||||||
prefix = prefix.replace("\\","/")
|
prefix = prefix.replace("\\","/")
|
||||||
|
|
||||||
print(f'prefix:{prefix}')
|
print(f'prefix:{prefix}')
|
||||||
print(f'实际有用的地址:objs/print/253312/model/standard_size/88942')
|
|
||||||
filelist = oss2.ObjectIteratorV2(oss_client, prefix=prefix)
|
filelist = oss2.ObjectIteratorV2(oss_client, prefix=prefix)
|
||||||
|
|
||||||
if len(list(filelist)) == 0:
|
if len(list(filelist)) == 0:
|
||||||
@@ -81,7 +82,7 @@ def down_obj_fromoss(pid,order_id):
|
|||||||
# time.sleep(10)
|
# time.sleep(10)
|
||||||
|
|
||||||
def getPidFromOrderId(orderId):
|
def getPidFromOrderId(orderId):
|
||||||
getPidFromOrderId_url = 'https://mp.gray.api.suwa3d.com/api/printOrder/info'
|
getPidFromOrderId_url = 'https://mp.api.suwa3d.com/api/printOrder/info'
|
||||||
print(f'{getPidFromOrderId_url}?id={orderId}')
|
print(f'{getPidFromOrderId_url}?id={orderId}')
|
||||||
res = requests.get(f'{getPidFromOrderId_url}?id={orderId}')
|
res = requests.get(f'{getPidFromOrderId_url}?id={orderId}')
|
||||||
resCode = res.json()['code']
|
resCode = res.json()['code']
|
||||||
@@ -118,9 +119,9 @@ def team_check(r):
|
|||||||
|
|
||||||
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} repair_id:{repair_id} 生成团队审核模型 start model:IndependentRepairTeamcheckGLBQueue', )
|
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} repair_id:{repair_id} 生成团队审核模型 start model:IndependentRepairTeamcheckGLBQueue', )
|
||||||
ossPath = down_obj_fromoss(pid,orderId)
|
ossPath = down_obj_fromoss(pid,orderId)
|
||||||
if ossPath == "":
|
# if ossPath == "":
|
||||||
print("ossPath is null")
|
# print("ossPath is null")
|
||||||
return
|
# return
|
||||||
obj_filename = f'{pid}.obj'
|
obj_filename = f'{pid}.obj'
|
||||||
glb_filename = f'{orderId}.glb'
|
glb_filename = f'{orderId}.glb'
|
||||||
print('开始转换obj文件为glb文件...')
|
print('开始转换obj文件为glb文件...')
|
||||||
@@ -140,10 +141,14 @@ def team_check(r):
|
|||||||
config.oss_bucket_3d_view.put_object_from_file(f'{uuid}/3d_view.png', f'D://print/{pid}/{pid}_pic.png')
|
config.oss_bucket_3d_view.put_object_from_file(f'{uuid}/3d_view.png', f'D://print/{pid}/{pid}_pic.png')
|
||||||
|
|
||||||
|
|
||||||
|
if ossPath == "model/smsize":
|
||||||
|
ossPath = "smsize"
|
||||||
|
|
||||||
|
if ossPath == "model/standard_size":
|
||||||
|
ossPath = "normal"
|
||||||
|
|
||||||
|
|
||||||
|
print('上传glb文件到oss...',f'glbs/print/{ossPath}/{glb_filename}',os.path.join(workdir, "print", pid, glb_filename))
|
||||||
print('上传glb文件到oss...')
|
|
||||||
oss_client.put_object_from_file(f'glbs/print/{ossPath}/{glb_filename}', os.path.join(workdir, "print", pid, glb_filename))
|
oss_client.put_object_from_file(f'glbs/print/{ossPath}/{glb_filename}', os.path.join(workdir, "print", pid, glb_filename))
|
||||||
|
|
||||||
print(f'{update_repair_status_url}?id={repair_id}')
|
print(f'{update_repair_status_url}?id={repair_id}')
|
||||||
@@ -153,7 +158,7 @@ def team_check(r):
|
|||||||
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} 生成团队审核模型 end')
|
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} 生成团队审核模型 end')
|
||||||
|
|
||||||
def get_p3d_info(pid):
|
def get_p3d_info(pid):
|
||||||
url = "https://mp.gray.api.suwa3d.com/api/customerP3dLog/info?id="+pid
|
url = "https://mp.api.suwa3d.com/api/customerP3dLog/info?id="+pid
|
||||||
res = requests.get(url)
|
res = requests.get(url)
|
||||||
res = res.json()
|
res = res.json()
|
||||||
if res["code"] == 1000:
|
if res["code"] == 1000:
|
||||||
@@ -165,7 +170,7 @@ def create_redis_connection():
|
|||||||
"""创建 Redis 连接,若连接失败则重试"""
|
"""创建 Redis 连接,若连接失败则重试"""
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
r = redis.Redis(host='mark.api.suwa3d.com', password='kcV2000', port=6379, db=6)
|
r = redis.Redis(host='106.14.158.208', password='kcV2000', port=6379, db=6)
|
||||||
# 尝试进行一次操作,检查连接是否有效
|
# 尝试进行一次操作,检查连接是否有效
|
||||||
r.ping() # ping 操作是一个简单的连接测试
|
r.ping() # ping 操作是一个简单的连接测试
|
||||||
print("Redis连接成功!")
|
print("Redis连接成功!")
|
||||||
@@ -193,12 +198,12 @@ if __name__ == '__main__':
|
|||||||
Endpoint = 'oss-cn-shanghai.aliyuncs.com'
|
Endpoint = 'oss-cn-shanghai.aliyuncs.com'
|
||||||
Bucket = 'suwa3d-securedata'
|
Bucket = 'suwa3d-securedata'
|
||||||
oss_client = oss2.Bucket(oss2.Auth(AccessKeyId, AccessKeySecret), Endpoint, Bucket)
|
oss_client = oss2.Bucket(oss2.Auth(AccessKeyId, AccessKeySecret), Endpoint, Bucket)
|
||||||
update_check_url = 'https://mp.gray.api.suwa3d.com/api/customerP3dLog/updateStatusToWaitingPlatformCheckingStatus'
|
update_check_url = 'https://mp.api.suwa3d.com/api/customerP3dLog/updateStatusToWaitingPlatformCheckingStatus'
|
||||||
update_team_check_url = 'https://mp.gray.api.suwa3d.com/api/customerP3dLog/updateStatusToWaitingTeamCheckingStatus'
|
update_team_check_url = 'https://mp.api.suwa3d.com/api/customerP3dLog/updateStatusToWaitingTeamCheckingStatus'
|
||||||
update_status_printstatus_url = 'https://mp.gray.api.suwa3d.com/api/customerP3dLog/updateBuildPrintModelStatus'
|
update_status_printstatus_url = 'https://mp.api.suwa3d.com/api/customerP3dLog/updateBuildPrintModelStatus'
|
||||||
update_makeprintobj_status_url = 'https://mp.gray.api.suwa3d.com/api/printOrder/updateMakePrintObjSucceed'
|
update_makeprintobj_status_url = 'https://mp.api.suwa3d.com/api/printOrder/updateMakePrintObjSucceed'
|
||||||
getRepairInfo_url = 'https://repair.gray.api.suwa3d.com/api/modelRepairOrder/teamCheckGLBInfo'
|
getRepairInfo_url = 'https://repair.api.suwa3d.com/api/modelRepairOrder/teamCheckGLBInfo'
|
||||||
update_repair_status_url = 'https://repair.gray.api.suwa3d.com/api/modelRepairOrder/updateStatusToWaitingTeamCheckingStatus'
|
update_repair_status_url = 'https://repair.api.suwa3d.com/api/modelRepairOrder/updateStatusToWaitingTeamCheckingStatus'
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
workdir = 'D:\\'
|
workdir = 'D:\\'
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in new issue
Block a user