dongchangxi 11 months ago
parent
commit
d370cac01d
  1. 52
      tools/cal_weight_excel.py

52
tools/cal_weight_excel.py

@ -78,19 +78,27 @@ def main(action, pid, sizes,orderId=0): @@ -78,19 +78,27 @@ def main(action, pid, sizes,orderId=0):
df = pd.read_excel(excel_file)
new_data = {
'pid': [pid], # 假设新的 pid 是 '002'
'6cm': [0], # 新的 6cm 数据
'7cm': [0], # 新的 7cm 数据
'8cm': [0], # 新的 8cm 数据
'1/4': [0], # 新的 6cm 数据
'1/6': [0], # 新的 7cm 数据
'1/10': [0], # 新的 8cm 数据
'1/12': [0], # 新的 8cm 数据
'1/16': [0], # 新的 8cm 数据
'1/18': [0], # 新的 8cm 数据
'1/24': [0], # 新的 8cm 数据
'1/32': [0], # 新的 8cm 数据
'1/43': [0], # 新的 8cm 数据
'1/64': [0], # 新的 8cm 数据
}
for size in sizes:
size = float(size)
for sizeV in sizes:
arrSize = sizeV.split("_")
size = float(arrSize[0])
weight = cal_weight(obj, size)
size = str(size/10)+"cm"
arrData[size] = str(weight)+"g"
# size = str(size/10)+"cm"
arrData[arrSize[1]] = str(weight)+"g"
if size+"cm" in df.columns:
new_data[size+"cm"] = [weight]
if arrSize[1] in df.columns:
new_data[arrSize[1]] = [weight]
# 更新数据
# 将新数据转换为 DataFrame
@ -100,19 +108,19 @@ def main(action, pid, sizes,orderId=0): @@ -100,19 +108,19 @@ def main(action, pid, sizes,orderId=0):
# 保存更新后的 Excel 文件
df.to_excel(excel_file, index=False)
#请求接口进行更新数据
arrParams = {"pid":pid,"order_id":orderId}
if action == "auto":
arrParams["auto_weight"] = json.dumps(arrData)
# #请求接口进行更新数据
# arrParams = {"pid":pid,"order_id":orderId}
# if action == "auto":
# arrParams["auto_weight"] = json.dumps(arrData)
if action == "print":
arrParams["print_weight"] = json.dumps(arrData)
# if action == "print":
# arrParams["print_weight"] = json.dumps(arrData)
#发起请求
print(f"请求的参数-{arrParams}")
url = "https://mp.api.suwa3d.com/api/physical/addPhysicalWeight"
res = requests.post(url,data=arrParams)
print('res:', res.text)
# #发起请求
# print(f"请求的参数-{arrParams}")
# url = "https://mp.api.suwa3d.com/api/physical/addPhysicalWeight"
# res = requests.post(url,data=arrParams)
# print('res:', res.text)
#获取真实身高
@ -161,5 +169,5 @@ if __name__ == '__main__': @@ -161,5 +169,5 @@ if __name__ == '__main__':
sizes.append(tempHeight)
print(sizes)
break
#main("print", pid, sizes)
# break
main("print", pid, sizes)
Loading…
Cancel
Save