修改dashboard当日完成数据计算逻辑

This commit is contained in:
mgw
2025-03-27 10:42:20 +08:00
parent 2b082a0dd7
commit 55337815c7

View File

@@ -567,7 +567,7 @@ class Sf_Dashboard_Connect(http.Controller):
"""
res = {'status': 1, 'message': '成功', 'data': {}}
# plan_obj = request.env['sf.production.plan'].sudo()
plan_obj = request.env['mrp.production'].sudo()
plan_obj = request.env['mrp.workorder'].sudo().search([('routing_type', '=', 'CNC加工')])
line_list = ast.literal_eval(kw['line_list'])
begin_time_str = kw['begin_time'].strip('"')
end_time_str = kw['end_time'].strip('"')
@@ -618,7 +618,7 @@ class Sf_Dashboard_Connect(http.Controller):
start_time, end_time = time_interval
orders = plan_obj.search([
('production_line_id.name', '=', line),
('production_id.production_line_id.name', '=', line),
('state', 'in', ['done']),
(date_field_name, '>=', start_time.strftime('%Y-%m-%d %H:%M:%S')),
(date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')) # 包括结束时间
@@ -638,18 +638,18 @@ class Sf_Dashboard_Connect(http.Controller):
for date in date_list:
next_day = date + timedelta(days=1)
orders = plan_obj.search([('production_line_id.name', '=', line), ('state', 'in', ['done']),
orders = plan_obj.search([('production_id.production_line_id.name', '=', line), ('state', 'in', ['done']),
(date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')),
(date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00'))
])
rework_orders = plan_obj.search(
[('production_line_id.name', '=', line), ('state', 'in', ['rework']),
[('production_id.production_line_id.name', '=', line), ('state', 'in', ['rework']),
(date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')),
(date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00'))
])
not_passed_orders = plan_obj.search(
[('production_line_id.name', '=', line), ('state', 'in', ['scrap', 'cancel']),
[('production_id.production_line_id.name', '=', line), ('state', 'in', ['scrap', 'cancel']),
(date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')),
(date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00'))
])
@@ -942,7 +942,7 @@ class Sf_Dashboard_Connect(http.Controller):
# machine_list = ast.literal_eval(kw['machine_list'])
# for item in machine_list:
# machine_data = equipment_obj.search([('code', '=', item)])
for log in maintenance_logs_obj.search([]):
for log in maintenance_logs_obj.search([], order='id desc', limit=30):
res['data'].append({
'name': log.name,
'alarm_time': log.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),