This commit is contained in:
DingZQ
2025-02-24 20:49:16 +08:00
parent 4bfbf3ac34
commit f7f905fdf4

View File

@@ -1352,14 +1352,15 @@ def query_all_record_by_date(query_date: str, bucket: str="realtime_simulation_r
datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
query_api = client.query_api()
# 将 start_date 的北京时间转换为 UTC 时间
start_time = (datetime.strptime(query_date, "%Y-%m-%d") - timedelta(days=1)).replace(hour=16, minute=0, second=0, tzinfo=timezone.utc).isoformat()
utc_time = time_api.to_utc_time(query_date + "T00:00:00+08:00")
start_time = time_api.get_utc_beginning(utc_time).isoformat()
print(start_time)
stop_time = (datetime.strptime(query_date, "%Y-%m-%d") - timedelta(days=1)).replace(hour=17, minute=0, second=0, tzinfo=timezone.utc).isoformat()
stop_time = time_api.get_utc_after(start_time, hours=1)
print(stop_time)
# 构建 Flux 查询语句
flux_query = f'''
from(bucket: "{bucket}")
|> range(start: {start_time}, stop: {stop_time})
|> range(start: {str(start_time)}, stop: {str(stop_time)})
|> filter(fn: (r) => r["_measurement"] == "node" or r["_measurement"] == "link")
|> filter(fn: (r) => r["date"] == "{query_date}")
|> pivot(