抓取生产工单,抓取发料异常
This commit is contained in:
@@ -100,10 +100,13 @@ def fetch_bom_cost_tree():
|
||||
data = body if isinstance(body, (dict, list)) else json.loads(body)
|
||||
|
||||
if isinstance(data, dict) and "result" in data:
|
||||
items = data["result"].get("items", [])
|
||||
total_records = data["result"].get("totalCount", 0)
|
||||
result_data = data.get("result") or {}
|
||||
items = result_data.get("items", [])
|
||||
total_records = result_data.get("totalCount", 0)
|
||||
|
||||
for item in items:
|
||||
if not item:
|
||||
continue
|
||||
# 注意:我们要拿的是 parentMaterialId,因为这是传给 BOM 成本 API 的关键参数 materialId
|
||||
clean_parent = {
|
||||
"_id": item.get("id"), # 这个是 partBomCostAccountingId
|
||||
@@ -237,7 +240,12 @@ def fetch_bom_cost_tree():
|
||||
log("ERR", f"❌ 自动触发入库脚本失败: {db_err}")
|
||||
|
||||
except Exception as e:
|
||||
log("ERR", f"发生异常: {e}")
|
||||
import traceback
|
||||
err_msg = f"发生异常: {e}\n{traceback.format_exc()}"
|
||||
with open("error.log", "w") as f:
|
||||
f.write(err_msg)
|
||||
print(err_msg, flush=True)
|
||||
log("ERR", err_msg)
|
||||
|
||||
if __name__ == "__main__":
|
||||
fetch_bom_cost_tree()
|
||||
Reference in New Issue
Block a user