优化打印输出
This commit is contained in:
@@ -70,7 +70,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
|
|
||||||
# 获取当前时间的时间戳
|
# 获取当前时间的时间戳
|
||||||
current_timestamp = datetime.now().timestamp()
|
current_timestamp = datetime.now().timestamp()
|
||||||
print(current_timestamp)
|
# print(current_timestamp)
|
||||||
|
|
||||||
# tem_list = [
|
# tem_list = [
|
||||||
# "XT-GNJC-WZZX-X800-Y550-Z550-T24-A5-1", "XT-GNJC-LSZX-X800-Y550-Z550-T24-A3-3",
|
# "XT-GNJC-WZZX-X800-Y550-Z550-T24-A5-1", "XT-GNJC-LSZX-X800-Y550-Z550-T24-A3-3",
|
||||||
@@ -199,7 +199,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S')
|
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')
|
end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
print('begin_time: %s' % begin_time)
|
# print('begin_time: %s' % begin_time)
|
||||||
|
|
||||||
for item in machine_list:
|
for item in machine_list:
|
||||||
sql = '''
|
sql = '''
|
||||||
@@ -280,7 +280,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
res = {'Succeed': True}
|
res = {'Succeed': True}
|
||||||
line_list_obj = request.env['sf.production.line'].sudo().search([('name', 'ilike', 'CNC')])
|
line_list_obj = request.env['sf.production.line'].sudo().search([('name', 'ilike', 'CNC')])
|
||||||
line_list = list(map(lambda x: x.name, line_list_obj))
|
line_list = list(map(lambda x: x.name, line_list_obj))
|
||||||
print('line_list: %s' % line_list)
|
# print('line_list: %s' % line_list)
|
||||||
res['LineList'] = line_list
|
res['LineList'] = line_list
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -307,7 +307,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
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()
|
||||||
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:
|
||||||
|
|
||||||
# 工单计划量
|
# 工单计划量
|
||||||
@@ -446,7 +446,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
end_time_str = kw['end_time'].strip('"')
|
end_time_str = kw['end_time'].strip('"')
|
||||||
begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S')
|
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')
|
end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S')
|
||||||
print('line_list: %s' % line_list)
|
# print('line_list: %s' % line_list)
|
||||||
|
|
||||||
def get_date_list(start_date, end_date):
|
def get_date_list(start_date, end_date):
|
||||||
date_list = []
|
date_list = []
|
||||||
@@ -483,7 +483,9 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
'date': date.strftime('%Y-%m-%d'),
|
'date': date.strftime('%Y-%m-%d'),
|
||||||
'order_count': len(orders),
|
'order_count': len(orders),
|
||||||
'rework_orders': len(rework_orders),
|
'rework_orders': len(rework_orders),
|
||||||
'not_passed_orders': len(not_passed_orders)
|
'not_passed_orders': len(not_passed_orders),
|
||||||
|
'finish_order_nums': len(orders),
|
||||||
|
'plan_order_nums': 20,
|
||||||
})
|
})
|
||||||
# 外面包一层,没什么是包一层不能解决的,包一层就能区分了,类似于包一层div
|
# 外面包一层,没什么是包一层不能解决的,包一层就能区分了,类似于包一层div
|
||||||
# 外面包一层的好处是,可以把多个数据结构打包在一起,方便前端处理
|
# 外面包一层的好处是,可以把多个数据结构打包在一起,方便前端处理
|
||||||
@@ -570,7 +572,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
end_time_str = kw['end_time'].strip('"')
|
end_time_str = kw['end_time'].strip('"')
|
||||||
begin_time = datetime.strptime(begin_time_str, '%Y-%m-%d %H:%M:%S')
|
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')
|
end_time = datetime.strptime(end_time_str, '%Y-%m-%d %H:%M:%S')
|
||||||
print('line_list: %s' % line_list)
|
# print('line_list: %s' % line_list)
|
||||||
not_done_data = []
|
not_done_data = []
|
||||||
done_data = []
|
done_data = []
|
||||||
final_data = {}
|
final_data = {}
|
||||||
@@ -581,13 +583,13 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
[('production_line_id.name', '=', line), ('state', 'not in', ['finished']),
|
[('production_line_id.name', '=', line), ('state', 'not in', ['finished']),
|
||||||
('production_id.state', 'not in', ['cancel']), ('active', '=', True)
|
('production_id.state', 'not in', ['cancel']), ('active', '=', True)
|
||||||
])
|
])
|
||||||
print(not_done_orders)
|
# print(not_done_orders)
|
||||||
# 完成订单
|
# 完成订单
|
||||||
finish_orders = plan_obj.search([
|
finish_orders = plan_obj.search([
|
||||||
('production_line_id.name', '=', line), ('state', 'in', ['finished']),
|
('production_line_id.name', '=', line), ('state', 'in', ['finished']),
|
||||||
('production_id.state', 'not in', ['cancel']), ('active', '=', True)
|
('production_id.state', 'not in', ['cancel']), ('active', '=', True)
|
||||||
])
|
])
|
||||||
print(finish_orders)
|
# print(finish_orders)
|
||||||
|
|
||||||
# 获取所有未完成订单的ID列表
|
# 获取所有未完成订单的ID列表
|
||||||
order_ids = [order.id for order in not_done_orders]
|
order_ids = [order.id for order in not_done_orders]
|
||||||
@@ -710,11 +712,11 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
# 执行SQL命令
|
# 执行SQL命令
|
||||||
cur.execute(sql, (item,))
|
cur.execute(sql, (item,))
|
||||||
result = cur.fetchall()
|
result = cur.fetchall()
|
||||||
print('result========', result)
|
# print('result========', result)
|
||||||
|
|
||||||
cur.execute(sql2, (item,))
|
cur.execute(sql2, (item,))
|
||||||
result2 = cur.fetchall()
|
result2 = cur.fetchall()
|
||||||
print('result2========', result2)
|
# print('result2========', result2)
|
||||||
#
|
#
|
||||||
for row in result:
|
for row in result:
|
||||||
res['data'][item] = {'idle_count': row[0]}
|
res['data'][item] = {'idle_count': row[0]}
|
||||||
@@ -770,7 +772,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
# 执行SQL命令
|
# 执行SQL命令
|
||||||
cur.execute(sql)
|
cur.execute(sql)
|
||||||
result = cur.fetchall()
|
result = cur.fetchall()
|
||||||
print('result', result)
|
# print('result', result)
|
||||||
|
|
||||||
# 将查询结果转换为字典列表
|
# 将查询结果转换为字典列表
|
||||||
data = []
|
data = []
|
||||||
@@ -977,7 +979,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
""", (item,))
|
""", (item,))
|
||||||
first_today = fetch_result_as_dict(cur)
|
first_today = fetch_result_as_dict(cur)
|
||||||
print("当天第一条记录(非离线):", first_today)
|
# print("当天第一条记录(非离线):", first_today)
|
||||||
|
|
||||||
# 获取当天最新一条记录(排除device_state等于‘离线’的记录)
|
# 获取当天最新一条记录(排除device_state等于‘离线’的记录)
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
@@ -990,7 +992,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
""", (item,))
|
""", (item,))
|
||||||
last_today = fetch_result_as_dict(cur)
|
last_today = fetch_result_as_dict(cur)
|
||||||
print("当天最新一条记录(非离线):", last_today)
|
# print("当天最新一条记录(非离线):", last_today)
|
||||||
|
|
||||||
# 计算当天运行时长
|
# 计算当天运行时长
|
||||||
if first_today and last_today:
|
if first_today and last_today:
|
||||||
@@ -1012,7 +1014,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
""", (item,))
|
""", (item,))
|
||||||
first_month = fetch_result_as_dict(cur)
|
first_month = fetch_result_as_dict(cur)
|
||||||
print("当月第一条记录(非离线):", first_month)
|
# print("当月第一条记录(非离线):", first_month)
|
||||||
|
|
||||||
# 获取当月最新一条记录(排除device_state等于‘离线’的记录)
|
# 获取当月最新一条记录(排除device_state等于‘离线’的记录)
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
@@ -1026,7 +1028,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
""", (item,))
|
""", (item,))
|
||||||
last_month = fetch_result_as_dict(cur)
|
last_month = fetch_result_as_dict(cur)
|
||||||
print("当月最新一条记录(非离线):", last_month)
|
# print("当月最新一条记录(非离线):", last_month)
|
||||||
|
|
||||||
# 计算当月运行时长
|
# 计算当月运行时长
|
||||||
if first_month and last_month:
|
if first_month and last_month:
|
||||||
@@ -1047,7 +1049,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
""", (item,))
|
""", (item,))
|
||||||
first_all_time = fetch_result_as_dict(cur)
|
first_all_time = fetch_result_as_dict(cur)
|
||||||
print("有记录以来的第一条记录(非离线):", first_all_time)
|
# print("有记录以来的第一条记录(非离线):", first_all_time)
|
||||||
|
|
||||||
# 获取有记录以来的最新一条记录(排除device_state等于‘离线’的记录)
|
# 获取有记录以来的最新一条记录(排除device_state等于‘离线’的记录)
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
@@ -1059,7 +1061,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
LIMIT 1;
|
LIMIT 1;
|
||||||
""", (item,))
|
""", (item,))
|
||||||
last_all_time = fetch_result_as_dict(cur)
|
last_all_time = fetch_result_as_dict(cur)
|
||||||
print("有记录以来的最新一条记录(非离线):", last_all_time)
|
# print("有记录以来的最新一条记录(非离线):", last_all_time)
|
||||||
|
|
||||||
# 计算有记录以来的运行时长
|
# 计算有记录以来的运行时长
|
||||||
if first_all_time and last_all_time:
|
if first_all_time and last_all_time:
|
||||||
|
|||||||
Reference in New Issue
Block a user