Merge branch 'master' of https://git.suwa3d.com/dongchangxi/make2
This commit is contained in:
commit
fa00daf91d
3 files changed
+5
-25
No files matched your search
@@ -60,7 +60,7 @@ def reload_obj(pid):
|
|||||||
print("imagePathT",imagePathT)
|
print("imagePathT",imagePathT)
|
||||||
config.oss_bucket_website.put_object_from_file(f'{imagePathT}', f'D://print/{pid}/{pid}_pic.png')
|
config.oss_bucket_website.put_object_from_file(f'{imagePathT}', f'D://print/{pid}/{pid}_pic.png')
|
||||||
#请求接口
|
#请求接口
|
||||||
res = requests.post("https://mp.api.suwa3d.com/api/printOrder/updateCoverByPidForExternalOrder", data={'pid': pid, 'image_path': 'https://www.suwa3d.com/external_order_cover/'+imagePathT})
|
res = requests.post("https://mp.api.suwa3d.com/api/printOrder/updateCoverByPidForExternalOrder", data={'pid': pid, 'image_path': 'https://www.suwa3d.com/'+imagePathT})
|
||||||
print("res",res)
|
print("res",res)
|
||||||
|
|
||||||
obj_filename = os.path.join(config.workdir,'print',pid,f'{pid}.obj')
|
obj_filename = os.path.join(config.workdir,'print',pid,f'{pid}.obj')
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ else:
|
|||||||
sys.path.append('/data/deploy/make3d/make2/libs/')
|
sys.path.append('/data/deploy/make3d/make2/libs/')
|
||||||
|
|
||||||
import config, libs, libs_db
|
import config, libs, libs_db
|
||||||
import pandas as pd
|
|
||||||
|
|
||||||
def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False):
|
def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False):
|
||||||
"""Returns a transformed, triangulated copy of the mesh"""
|
"""Returns a transformed, triangulated copy of the mesh"""
|
||||||
@@ -74,32 +73,12 @@ def main(action, pid, sizes,orderId=0):
|
|||||||
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
|
bpy.ops.object.transform_apply(location=True, rotation=True, scale=True)
|
||||||
print(f'模型{pid}的体积与克重估算信息:')
|
print(f'模型{pid}的体积与克重估算信息:')
|
||||||
arrData = {}
|
arrData = {}
|
||||||
excel_file = 'weights.xlsx' # 替换为你的文件路径
|
|
||||||
df = pd.read_excel(excel_file)
|
|
||||||
new_data = {
|
|
||||||
'pid': [pid], # 假设新的 pid 是 '002'
|
|
||||||
'6cm': [0], # 新的 6cm 数据
|
|
||||||
'7cm': [0], # 新的 7cm 数据
|
|
||||||
'8cm': [0], # 新的 8cm 数据
|
|
||||||
}
|
|
||||||
|
|
||||||
for size in sizes:
|
for size in sizes:
|
||||||
size = float(size)
|
size = float(size)
|
||||||
weight = cal_weight(obj, size)
|
weight = cal_weight(obj, size)
|
||||||
size = str(size/10)+"cm"
|
size = str(size/10)+"cm"
|
||||||
arrData[size] = str(weight)+"g"
|
arrData[size] = str(weight)+"g"
|
||||||
|
|
||||||
if size+"cm" in df.columns:
|
|
||||||
new_data[size+"cm"] = [weight]
|
|
||||||
|
|
||||||
# 更新数据
|
|
||||||
# 将新数据转换为 DataFrame
|
|
||||||
new_df = pd.DataFrame(new_data)
|
|
||||||
# 将新数据附加到原始 DataFrame 中
|
|
||||||
df = pd.concat([df, new_df], ignore_index=True)
|
|
||||||
# 保存更新后的 Excel 文件
|
|
||||||
df.to_excel(excel_file, index=False)
|
|
||||||
|
|
||||||
#请求接口进行更新数据
|
#请求接口进行更新数据
|
||||||
arrParams = {"pid":pid,"order_id":orderId}
|
arrParams = {"pid":pid,"order_id":orderId}
|
||||||
if action == "auto":
|
if action == "auto":
|
||||||
|
|||||||
@@ -64,9 +64,10 @@ def cal_weight(obj, size):
|
|||||||
model_info = {}
|
model_info = {}
|
||||||
bm = bmesh_copy_from_object(obj)
|
bm = bmesh_copy_from_object(obj)
|
||||||
# 计算体积 保留两位小数
|
# 计算体积 保留两位小数
|
||||||
model_info['volume'] = round(bm.calc_volume() / 1000,2)
|
print(f"{pid},尺寸={size} 计算出来的体积= {bm.calc_volume()}")
|
||||||
|
model_info['volume'] = round(bm.calc_volume(),2)
|
||||||
model_info['weight'] = round(model_info['volume'] * 1.226,2)
|
model_info['weight'] = round(model_info['volume'] * 1.226,2)
|
||||||
print(f'{size/10}cm:体积 {model_info["volume"]}cm³, 克重 {model_info["weight"]}g')
|
print(f'{size}cm:体积 {model_info["volume"]}cm³, 克重 {model_info["weight"]}g')
|
||||||
return model_info["weight"]
|
return model_info["weight"]
|
||||||
|
|
||||||
def main(action, pid, sizes,realHeight,orderId=0):
|
def main(action, pid, sizes,realHeight,orderId=0):
|
||||||
@@ -114,7 +115,7 @@ def main(action, pid, sizes,realHeight,orderId=0):
|
|||||||
arrData[arrSize[1]] = str(weight)+"g"
|
arrData[arrSize[1]] = str(weight)+"g"
|
||||||
|
|
||||||
if arrSize[1] in df.columns:
|
if arrSize[1] in df.columns:
|
||||||
new_data[arrSize[1]+"尺寸"] = [str(size/10)+"cm"]
|
new_data[arrSize[1]+"尺寸"] = [str(size)+"cm"]
|
||||||
new_data[arrSize[1]] = [str(weight)+'g']
|
new_data[arrSize[1]] = [str(weight)+'g']
|
||||||
|
|
||||||
# 更新数据
|
# 更新数据
|
||||||
|
|||||||
Reference in new issue
Block a user