Accept Merge Request #2250: (feature/6711 -> develop)
Merge Request: 修改大屏获取订单详情接口 Created By: @胡尧 Accepted By: @胡尧 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2250
This commit is contained in:
@@ -862,6 +862,8 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
"""
|
||||
# res = {'status': 1, 'message': '成功', 'not_done_data': [], 'done_data': []}
|
||||
res = {'status': 1, 'message': '成功', 'data': {}}
|
||||
# 解决产品名称取到英文的问题
|
||||
request.update_context(lang='zh_CN')
|
||||
plan_obj = request.env['sf.production.plan'].sudo()
|
||||
work_order_obj = request.env['mrp.workorder'].sudo()
|
||||
line_list = ast.literal_eval(kw['line_list'])
|
||||
@@ -870,11 +872,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S')
|
||||
end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S')
|
||||
# print('line_list: %s' % line_list)
|
||||
not_done_data = []
|
||||
done_data = []
|
||||
final_data = {}
|
||||
not_done_index = 1
|
||||
done_index = 1
|
||||
|
||||
# 获取当前时间,并计算24小时前的时间
|
||||
current_time = datetime.now()
|
||||
@@ -889,6 +887,10 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
])
|
||||
|
||||
for line in line_list:
|
||||
not_done_data = []
|
||||
done_data = []
|
||||
not_done_index = 1
|
||||
done_index = 1
|
||||
|
||||
if line == '业绩总览':
|
||||
work_order_domain = [('routing_type', 'in', ['人工线下加工', 'CNC加工'])]
|
||||
@@ -922,11 +924,11 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
# time_24_hours_ago = current_time - timedelta(hours=24)
|
||||
|
||||
finish_orders = work_order_obj.search(work_order_domain + [
|
||||
('state', 'in', ['finished']),
|
||||
('state', 'in', ['done']),
|
||||
('production_id.state', 'not in', ['cancel']),
|
||||
('date_finished', '>=', time_48_hours_ago)
|
||||
], order='id asc')
|
||||
# print(finish_orders)
|
||||
# logging.info('完成订单: %s' % finish_orders)
|
||||
|
||||
# 获取所有未完成订单的ID列表
|
||||
order_ids = [order.id for order in not_done_orders]
|
||||
@@ -985,8 +987,6 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
not_done_index += 1
|
||||
|
||||
for finish_order in finish_orders:
|
||||
if not finish_order.actual_end_time:
|
||||
continue
|
||||
blank_name = ''
|
||||
try:
|
||||
blank_name = finish_order.production_id.move_raw_ids[0].product_id.name
|
||||
@@ -1007,8 +1007,8 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
'material': material,
|
||||
'dimensions': dimensions,
|
||||
'order_qty': order.qty_produced,
|
||||
'finish_time': finish_order.actual_end_time.strftime(
|
||||
'%Y-%m-%d %H:%M:%S') if finish_order.actual_end_time else ' '
|
||||
'finish_time': finish_order.date_finished.strftime(
|
||||
'%Y-%m-%d %H:%M:%S') if finish_order.date_finished else ' '
|
||||
|
||||
}
|
||||
done_data.append(line_dict)
|
||||
|
||||
Reference in New Issue
Block a user