调整可用率
This commit is contained in:
@@ -1688,12 +1688,14 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
FROM device_data
|
FROM device_data
|
||||||
WHERE device_name = %s
|
WHERE device_name = %s
|
||||||
AND power_on_time IS NOT NULL
|
AND power_on_time IS NOT NULL
|
||||||
AND time::date = CURRENT_DATE -- ✅ 更高效的写法
|
AND time >= CURRENT_DATE
|
||||||
|
AND time < CURRENT_DATE + INTERVAL '1 day'
|
||||||
ORDER BY time ASC
|
ORDER BY time ASC
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
);
|
);
|
||||||
""", (item, item, item))
|
""", (item, item, item))
|
||||||
results = cur.fetchall()
|
results = cur.fetchall()
|
||||||
|
logging.info('====================%s' % results)
|
||||||
if len(results) >= 1:
|
if len(results) >= 1:
|
||||||
total_power_on_time += convert_to_seconds(results[0][0])
|
total_power_on_time += convert_to_seconds(results[0][0])
|
||||||
else:
|
else:
|
||||||
@@ -1704,10 +1706,16 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
month_power_on_time += 0
|
month_power_on_time += 0
|
||||||
if len(results) >= 3:
|
if len(results) >= 3:
|
||||||
today_power_on_time += convert_to_seconds(results[2][0])
|
today_power_on_time += convert_to_seconds(results[2][0])
|
||||||
today_power_on_dict[item] = today_power_on_time
|
# today_power_on_dict[item] = today_power_on_time
|
||||||
else:
|
else:
|
||||||
today_power_on_time += 0
|
today_power_on_time += convert_to_seconds(results[0][0])
|
||||||
today_power_on_dict[item] = 0
|
# today_power_on_dict[item] = 0
|
||||||
|
|
||||||
|
if results[0][0] == '0H0M':
|
||||||
|
logging.info('=woshide=%s' % results[0][0])
|
||||||
|
logging.info(type(results[0][0]))
|
||||||
|
total_power_on_time += convert_to_seconds(results[1][0])
|
||||||
|
today_power_on_time += convert_to_seconds(results[1][0])
|
||||||
|
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
cur.execute("""
|
cur.execute("""
|
||||||
@@ -1722,9 +1730,9 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
|
|
||||||
for record in results:
|
for record in results:
|
||||||
if record[0]:
|
if record[0]:
|
||||||
if float(record[0]) >= 28800:
|
if float(record[0]) >= 86400:
|
||||||
continue
|
continue
|
||||||
total_alarm_time += float(record[0])
|
total_alarm_time += abs(float(record[0]))
|
||||||
else:
|
else:
|
||||||
total_alarm_time += 0.0
|
total_alarm_time += 0.0
|
||||||
alarm_start = datetime.strptime(record[1], "%Y-%m-%d %H:%M:%S")
|
alarm_start = datetime.strptime(record[1], "%Y-%m-%d %H:%M:%S")
|
||||||
@@ -1737,7 +1745,7 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
if today[0]:
|
if today[0]:
|
||||||
if float(today[0]) >= 28800:
|
if float(today[0]) >= 28800:
|
||||||
continue
|
continue
|
||||||
today_alarm_time += float(today[0])
|
today_alarm_time += abs(float(today[0]))
|
||||||
today_alarm_dict[item] = today_alarm_time
|
today_alarm_dict[item] = today_alarm_time
|
||||||
else:
|
else:
|
||||||
today_alarm_time += 0.0
|
today_alarm_time += 0.0
|
||||||
@@ -1748,12 +1756,14 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
if month[0]:
|
if month[0]:
|
||||||
if float(month[0]) >= 28800:
|
if float(month[0]) >= 28800:
|
||||||
continue
|
continue
|
||||||
month_alarm_time += float(month[0])
|
month_alarm_time += abs(float(month[0]))
|
||||||
else:
|
else:
|
||||||
month_alarm_time += 0.0
|
month_alarm_time += 0.0
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
logging.info('在线时间总月日=============%s, %s, %s' % (total_power_on_time, month_power_on_time, today_power_on_time))
|
||||||
|
|
||||||
logging.info('报警时间总月日=============%s, %s, %s' % (total_alarm_time, month_alarm_time, today_alarm_time))
|
logging.info('报警时间总月日=============%s, %s, %s' % (total_alarm_time, month_alarm_time, today_alarm_time))
|
||||||
# 计算时间开动率(累计、月、日)
|
# 计算时间开动率(累计、月、日)
|
||||||
if total_power_on_time:
|
if total_power_on_time:
|
||||||
|
|||||||
Reference in New Issue
Block a user