CNC自动生产线生产业绩看板优化需求
This commit is contained in:
@@ -402,20 +402,45 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
try:
|
try:
|
||||||
plan_obj = request.env['sf.production.plan'].sudo()
|
plan_obj = request.env['sf.production.plan'].sudo()
|
||||||
production_obj = request.env['mrp.production'].sudo()
|
production_obj = request.env['mrp.production'].sudo()
|
||||||
|
work_order_obj = request.env['mrp.workorder'].sudo()
|
||||||
line_list = ast.literal_eval(kw['line_list'])
|
line_list = ast.literal_eval(kw['line_list'])
|
||||||
# print('line_list: %s' % line_list)
|
# print('line_list: %s' % line_list)
|
||||||
for line in line_list:
|
for line in line_list:
|
||||||
|
|
||||||
# 工单计划量
|
|
||||||
plan_data_total_counts = production_obj.search_count(
|
|
||||||
[('production_line_id.name', '=', line), ('state', 'not in', ['cancel']),
|
|
||||||
('active', '=', True)])
|
|
||||||
# 工单完成量
|
|
||||||
plan_data_finish_counts = plan_obj.search_count(
|
|
||||||
[('production_line_id.name', '=', line), ('state', 'in', ['finished'])])
|
|
||||||
# # 工单计划量
|
# # 工单计划量
|
||||||
# plan_data_plan_counts = plan_obj.search_count(
|
# plan_data_total_counts = production_obj.search_count(
|
||||||
# [('production_line_id.name', '=', line), ('state', 'not in', ['finished'])])
|
# [('production_line_id.name', '=', line), ('state', 'not in', ['cancel']),
|
||||||
|
# ('active', '=', True)])
|
||||||
|
|
||||||
|
# 工单计划量切换为CNC工单
|
||||||
|
plan_data_total_counts = work_order_obj.search_count(
|
||||||
|
[('production_id.production_line_id.name', '=', line),
|
||||||
|
('state', 'in', ['ready', 'progress', 'done']), ('routing_type', '=', 'CNC加工')])
|
||||||
|
|
||||||
|
# # 工单完成量
|
||||||
|
# plan_data_finish_counts = plan_obj.search_count(
|
||||||
|
# [('production_line_id.name', '=', line), ('state', 'in', ['finished'])])
|
||||||
|
|
||||||
|
# 工单完成量切换为CNC工单
|
||||||
|
plan_data_finish_counts = work_order_obj.search_count(
|
||||||
|
[('production_id.production_line_id.name', '=', line),
|
||||||
|
('state', 'in', ['done']), ('routing_type', '=', 'CNC加工')])
|
||||||
|
|
||||||
|
# 超期完成量
|
||||||
|
# 搜索所有已经完成的工单
|
||||||
|
plan_data_overtime = work_order_obj.search([
|
||||||
|
('production_id.production_line_id.name', '=', line),
|
||||||
|
('state', 'in', ['done']),
|
||||||
|
('routing_type', '=', 'CNC加工')
|
||||||
|
])
|
||||||
|
|
||||||
|
# 使用 filtered 进行字段比较
|
||||||
|
plan_data_overtime_counts = plan_data_overtime.filtered(
|
||||||
|
lambda order: order.date_finished > order.date_planned_finished
|
||||||
|
)
|
||||||
|
|
||||||
|
# 获取数量
|
||||||
|
plan_data_overtime_counts = len(plan_data_overtime_counts)
|
||||||
|
|
||||||
# 查找符合条件的生产计划记录
|
# 查找符合条件的生产计划记录
|
||||||
plan_data = plan_obj.search([
|
plan_data = plan_obj.search([
|
||||||
@@ -517,7 +542,10 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
'on_time_rate': on_time_rate,
|
'on_time_rate': on_time_rate,
|
||||||
# 'detection_data': detection_data,
|
# 'detection_data': detection_data,
|
||||||
'detection_data': plan_data_finish_counts,
|
'detection_data': plan_data_finish_counts,
|
||||||
'pass_rate': (plan_data_finish_counts - plan_data_fault_counts) / plan_data_finish_counts
|
'pass_rate': (plan_data_finish_counts - plan_data_fault_counts) / plan_data_finish_counts,
|
||||||
|
'plan_data_overtime_counts': plan_data_overtime_counts,
|
||||||
|
'overtime_rate': plan_data_overtime_counts / plan_data_finish_counts
|
||||||
|
if plan_data_finish_counts > 0 else 0,
|
||||||
}
|
}
|
||||||
res['data'][line] = data
|
res['data'][line] = data
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user