优化值为空时的逻辑
This commit is contained in:
@@ -873,7 +873,10 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
alarm_count = []
|
||||
for row in result2:
|
||||
alarm_count.append(row[1])
|
||||
total_alarm_time += abs(float(row[0]))
|
||||
if row[0]:
|
||||
total_alarm_time += abs(float(row[0]))
|
||||
else:
|
||||
total_alarm_time += 0.0
|
||||
if len(list(set(alarm_count))) == 1:
|
||||
if list(set(alarm_count))[0] is None:
|
||||
alarm_count_num = 0
|
||||
@@ -1245,7 +1248,12 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
columns = [desc[0] for desc in cursor.description]
|
||||
return dict(zip(columns, cursor.fetchone())) if cursor.rowcount != 0 else None
|
||||
|
||||
# 获取当前时间的时间戳
|
||||
current_timestamp = datetime.now().timestamp()
|
||||
for item in machine_list:
|
||||
euipment_obj = request.env['maintenance.equipment'].sudo().search([('code', '=', item)])
|
||||
# 机床上线时间段
|
||||
first_online_duration = current_timestamp - euipment_obj.first_online_time.timestamp()
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("""
|
||||
SELECT * FROM device_data
|
||||
@@ -1259,7 +1267,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
cur.execute("""
|
||||
SELECT * FROM device_data
|
||||
WHERE device_name = %s
|
||||
AND device_state != '离线' AND time >= %s
|
||||
AND device_state != '离线' AND time >= %s AND process_time IS NOT NULL
|
||||
ORDER BY time ASC
|
||||
LIMIT 1;
|
||||
""", (item, time_threshold))
|
||||
@@ -1274,7 +1282,12 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
""", (item, time_threshold))
|
||||
results = cur.fetchall()
|
||||
for result in results:
|
||||
alarm_last_24_time += float(result[0])
|
||||
if result[0]:
|
||||
if float(result[0]) >= 1000:
|
||||
continue
|
||||
alarm_last_24_time += float(result[0])
|
||||
else:
|
||||
alarm_last_24_time += 0.0
|
||||
# 返回数据
|
||||
res['data'][item] = {
|
||||
'wait_time': last_all_time['run_time'] if last_all_time['run_time'] is not None else 0,
|
||||
@@ -1282,7 +1295,8 @@ class Sf_Dashboard_Connect(http.Controller):
|
||||
'cut_24_time': last_24_time['process_time'] if last_24_time['process_time'] is not None else 0,
|
||||
'power_on_time': last_all_time['power_on_time'] if last_all_time['power_on_time'] is not None else 0,
|
||||
'power_on_24_time': last_24_time['power_on_time'] if last_24_time['power_on_time'] is not None else 0,
|
||||
'alarm_last_24_time': alarm_last_24_time
|
||||
'alarm_last_24_time': alarm_last_24_time,
|
||||
'first_online_time': first_online_duration,
|
||||
}
|
||||
|
||||
conn.close()
|
||||
|
||||
@@ -95,9 +95,9 @@
|
||||
<group>
|
||||
<button name="get_history_logs" type="object" string="查看历史日志" t-attf-style="white-space:nowrap;"/>
|
||||
</group>
|
||||
<group>
|
||||
<button name="download_history_logs" type="object" string="下载历史日志" t-attf-style="white-space:nowrap;"/>
|
||||
</group>
|
||||
<!-- <group> -->
|
||||
<!-- <button name="download_history_logs" type="object" string="下载历史日志" t-attf-style="white-space:nowrap;"/> -->
|
||||
<!-- </group> -->
|
||||
</group>
|
||||
|
||||
</group>
|
||||
|
||||
Reference in New Issue
Block a user