add bi
This commit is contained in:
parent
61d5a31b03
commit
edbfdc25f7
|
@ -1,3 +1,5 @@
|
|||
import time
|
||||
|
||||
from lib.all import *
|
||||
import datetime
|
||||
|
||||
|
@ -34,9 +36,24 @@ class S:
|
|||
|
||||
def insert_flow(self, ptime, flow):
|
||||
sql = '''insert into vas_yoy_flow (ptime, flow) values (%s,%s)'''
|
||||
print(sql)
|
||||
return self.mysql_db_bi.exec(sql, (ptime, flow))
|
||||
|
||||
def update_day_flow(self, flow):
|
||||
t = get_today_zero_time()
|
||||
dt = datetime.datetime.fromtimestamp(t)
|
||||
formatted_dt = dt.strftime('%Y-%m-%d 00:00:00')
|
||||
|
||||
sql_q = "select ptime from vas_day_flow where ptime='{}'".format(get_time_str_by_ts(t))
|
||||
print(sql_q)
|
||||
return
|
||||
rows = self.mysql_db_vas.query(sql_q)
|
||||
if len(rows) > 0:
|
||||
return safe_get_int(rows[0], "flow")
|
||||
|
||||
sql = '''update vas_day_flow set flow=%s where ptime=%s'''
|
||||
|
||||
return self.mysql_db_bi.exec(sql, (flow, formatted_dt))
|
||||
|
||||
def proc(self):
|
||||
zero_time = get_today_zero_time()
|
||||
last_time = self.get_last_ptime()
|
||||
|
@ -51,6 +68,7 @@ class S:
|
|||
formatted_dt = dt.strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
self.insert_flow(formatted_dt, flow)
|
||||
self.update_day_flow(flow)
|
||||
print(get_time_str_by_ts(next_time), flow)
|
||||
|
||||
last_time += 300
|
||||
|
|
Loading…
Reference in New Issue