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