From 1dc55c277010c5259cba3a5402c6c7ff10d95469 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 2 Sep 2024 09:04:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8D=E8=89=AF=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 35f4a257..5168173e 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -312,9 +312,22 @@ class Sf_Dashboard_Connect(http.Controller): # 工单计划量 plan_data_plan_counts = plan_obj.search_count( [('production_line_id.name', '=', line), ('state', 'not in', ['finished'])]) - # 工单不良累计 - plan_data_fault_counts = plan_obj.search_count( - [('production_line_id.name', '=', line), ('production_id.state', 'in', ['scrap', 'cancel'])]) + # # 工单不良累计 + # plan_data_fault_counts = plan_obj.search_count( + # [('production_line_id.name', '=', line), ('production_id.detection_result_ids.state', 'in', ['返工', '报废'])]) + + # 查找符合条件的生产计划记录 + plan_data = plan_obj.search([ + ('production_line_id.name', '=', line), + ]) + + # 过滤出那些检测结果状态为 '返工' 或 '报废' 的记录 + faulty_plans = plan_data.filtered(lambda p: any( + result.test_results in ['返工', '报废'] for result in p.production_id.detection_result_ids + )) + + # 计算符合条件的记录数量 + plan_data_fault_counts = len(faulty_plans) # 工单返工数量