调整检测量、合格量
This commit is contained in:
@@ -333,7 +333,8 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
('active', '=', False)])
|
||||
|
||||
# 计算符合条件的记录数量
|
||||
plan_data_fault_counts = len(faulty_plans) + cancel_order_count
|
||||
# plan_data_fault_counts = len(faulty_plans) + cancel_order_count
|
||||
plan_data_fault_counts = len(faulty_plans)
|
||||
|
||||
# 工单返工数量
|
||||
|
||||
@@ -347,10 +348,36 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
# 工单进度偏差
|
||||
plan_data_progress_deviation = plan_data_total_counts - plan_data_finish_counts - plan_data_fault_counts
|
||||
|
||||
# 交付准时率
|
||||
# 完成记录
|
||||
plan_data_finish_orders = plan_obj.search(
|
||||
[('production_line_id.name', '=', line), ('state', 'in', ['finished'])])
|
||||
|
||||
# # 检测量
|
||||
# detection_nums = 0
|
||||
# for i in plan_data_finish_orders:
|
||||
# print('i: %s' % i)
|
||||
# if i.production_id.detection_result_ids:
|
||||
# detection_nums += 1
|
||||
#
|
||||
# print('detection_nums: %s' % detection_nums)
|
||||
|
||||
# 检测量
|
||||
detection_data = len(plan_data_finish_orders.mapped('production_id.detection_result_ids').filtered(lambda r: r))
|
||||
|
||||
# 检测合格量
|
||||
pass_nums = plan_data_finish_orders.filtered(lambda p: any(
|
||||
result.test_results in ['合格'] for result in p.production_id.detection_result_ids
|
||||
))
|
||||
|
||||
# 质量合格率
|
||||
pass_rate = 1
|
||||
if pass_nums:
|
||||
pass_rate = round((len(pass_nums) / len(plan_data_finish_orders) if len(plan_data_finish_orders) > 0 else 0), 3)
|
||||
|
||||
# 返工率
|
||||
rework_rate = round((plan_data_rework_counts / plan_data_finish_counts if plan_data_finish_counts > 0 else 0), 3)
|
||||
|
||||
# 交付准时率
|
||||
delay_num = 0
|
||||
for plan in plan_data_finish_orders:
|
||||
sale_obj = request.env['sale.order'].sudo().search([('name', '=', plan.origin)])
|
||||
@@ -382,7 +409,9 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
'finishe_rate': finishe_rate,
|
||||
'plan_data_progress_deviation': plan_data_progress_deviation,
|
||||
'plan_data_rework_counts': plan_data_rework_counts,
|
||||
'on_time_rate': on_time_rate
|
||||
'on_time_rate': on_time_rate,
|
||||
'detection_data': detection_data,
|
||||
'pass_rate': pass_rate
|
||||
}
|
||||
res['data'][line] = data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user