删除发版无关的文件
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
@echo off
|
||||
|
||||
:loop
|
||||
echo 正在执行 git pull...
|
||||
git pull
|
||||
echo 等待10分钟...
|
||||
timeout /t 600 /nobreak >nul
|
||||
|
||||
goto loop
|
||||
@@ -1,25 +0,0 @@
|
||||
import auto_realtime
|
||||
import auto_store_non_realtime_SCADA_data
|
||||
import asyncio
|
||||
import influxdb_api
|
||||
import influxdb_info
|
||||
import project_info
|
||||
|
||||
# 为了让多个任务并发运行,我们可以用 asyncio.to_thread 分别启动它们
|
||||
async def main():
|
||||
task1 = asyncio.to_thread(auto_realtime.realtime_task)
|
||||
task2 = asyncio.to_thread(auto_store_non_realtime_SCADA_data.store_non_realtime_SCADA_data_task)
|
||||
await asyncio.gather(task1, task2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
url = influxdb_info.url
|
||||
token = influxdb_info.token
|
||||
org_name = influxdb_info.org
|
||||
|
||||
influxdb_api.query_pg_scada_info_realtime(project_info.name)
|
||||
influxdb_api.query_pg_scada_info_non_realtime(project_info.name)
|
||||
|
||||
# 用 asyncio 并发启动两个任务
|
||||
asyncio.run(main())
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
import schedule
|
||||
import time
|
||||
import datetime
|
||||
import shutil
|
||||
import redis
|
||||
import urllib.request
|
||||
import influxdb_api
|
||||
import msgpack
|
||||
import datetime
|
||||
|
||||
# 将 Query的信息 序列号到 redis/json, 默认不支持datetime,需要自定义
|
||||
# 自定义序列化函数
|
||||
# 序列化处理器
|
||||
def encode_datetime(obj):
|
||||
"""将datetime转换为可序列化的字典结构"""
|
||||
if isinstance(obj, datetime.datetime):
|
||||
return {
|
||||
'__datetime__': True,
|
||||
'as_str': obj.strftime("%Y%m%dT%H:%M:%S.%f")
|
||||
}
|
||||
return obj
|
||||
|
||||
# 反序列化处理器
|
||||
def decode_datetime(obj):
|
||||
"""将字典还原为datetime对象"""
|
||||
if '__datetime__' in obj:
|
||||
return datetime.datetime.strptime(
|
||||
obj['as_str'], "%Y%m%dT%H:%M:%S.%f"
|
||||
)
|
||||
return obj
|
||||
|
||||
##########################
|
||||
# 需要用Python 3.12 来运行才能提高performance
|
||||
##########################
|
||||
|
||||
def queryallrecordsbydate(querydate: str, redis_client: redis.Redis):
|
||||
cache_key = f"queryallrecordsbydate_{querydate}"
|
||||
exists = redis_client.exists(cache_key)
|
||||
|
||||
if not exists:
|
||||
nodes_links: tuple = influxdb_api.query_all_records_by_date(query_date=querydate)
|
||||
redis_client.set(cache_key, msgpack.packb(nodes_links, default=encode_datetime))
|
||||
|
||||
def queryallrecordsbydate_by_url(querydate: str):
|
||||
print(f'queryallrecordsbydate: {querydate}')
|
||||
|
||||
try:
|
||||
response = urllib.request.urlopen(
|
||||
f"http://127.0.0.1/queryallrecordsbydate/?querydate={querydate}"
|
||||
)
|
||||
html = response.read().decode("utf-8")
|
||||
|
||||
except urllib.error.URLError as e:
|
||||
print("Error")
|
||||
|
||||
def queryallscadarecordsbydate(querydate: str, redis_client: redis.Redis):
|
||||
cache_key = f"queryallscadarecordsbydate_{querydate}"
|
||||
exists = redis_client.exists(cache_key)
|
||||
|
||||
if not exists:
|
||||
result_dict = influxdb_api.query_all_SCADA_records_by_date(query_date=querydate)
|
||||
redis_client.set(cache_key, msgpack.packb(result_dict, default=encode_datetime))
|
||||
|
||||
def queryallscadarecordsbydate_by_url(querydate: str):
|
||||
print(f'queryallscadarecordsbydate: {querydate}')
|
||||
|
||||
try:
|
||||
response = urllib.request.urlopen(
|
||||
f"http://127.0.0.1/queryallscadarecordsbydate/?querydate={querydate}"
|
||||
)
|
||||
html = response.read().decode("utf-8")
|
||||
|
||||
except urllib.error.URLError as e:
|
||||
print("Error")
|
||||
|
||||
|
||||
def auto_cache_data():
|
||||
# 初始化 Redis 连接
|
||||
# 用redis 限制并发访u
|
||||
redis_client = redis.Redis(host="127.0.0.1", port=6379, db=0)
|
||||
|
||||
# auto cache data for the last 3 days
|
||||
today = datetime.date.today()
|
||||
for i in range(1, 4):
|
||||
prev_day = today - datetime.timedelta(days=i)
|
||||
str_prev_day = prev_day.strftime('%Y-%m-%d')
|
||||
print(str_prev_day)
|
||||
|
||||
queryallrecordsbydate(str_prev_day, redis_client)
|
||||
queryallscadarecordsbydate(str_prev_day, redis_client)
|
||||
|
||||
redis_client.close()
|
||||
|
||||
def auto_cache_data_by_url():
|
||||
# auto cache data for the last 3 days
|
||||
today = datetime.date.today()
|
||||
for i in range(1, 4):
|
||||
prev_day = today - datetime.timedelta(days=i)
|
||||
str_prev_day = prev_day.strftime('%Y-%m-%d')
|
||||
print(str_prev_day)
|
||||
|
||||
queryallrecordsbydate_by_url(str_prev_day)
|
||||
queryallscadarecordsbydate_by_url(str_prev_day)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
auto_cache_data_by_url()
|
||||
|
||||
# auto run in the midnight
|
||||
schedule.every().day.at("03:00").do(auto_cache_data_by_url)
|
||||
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
time.sleep(1)
|
||||
@@ -1,156 +0,0 @@
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
import influxdb_api
|
||||
import os
|
||||
import logging
|
||||
import globals
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import schedule
|
||||
import time
|
||||
import shutil
|
||||
from influxdb_client import InfluxDBClient, BucketsApi, WriteApi, OrganizationsApi, Point, QueryApi
|
||||
import simulation
|
||||
import influxdb_info
|
||||
import project_info
|
||||
|
||||
def setup_logger():
|
||||
# 创建日志目录
|
||||
log_dir = "logs"
|
||||
os.makedirs(log_dir, exist_ok=True)
|
||||
|
||||
# 配置基础日志格式
|
||||
log_format = "%(asctime)s - %(levelname)s - %(message)s"
|
||||
formatter = logging.Formatter(log_format)
|
||||
|
||||
# 创建主 Logger
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.INFO) # 全局日志级别
|
||||
|
||||
# --- 1. 按日期分割的日志文件 Handler ---
|
||||
log_file = os.path.join(log_dir, "simulation.log")
|
||||
file_handler = TimedRotatingFileHandler(
|
||||
filename=log_file,
|
||||
when="midnight", # 每天午夜轮转
|
||||
interval=1,
|
||||
backupCount=7,
|
||||
encoding="utf-8"
|
||||
)
|
||||
file_handler.suffix = "simulation-%Y-%m-%d.log" # 文件名格式
|
||||
file_handler.setFormatter(formatter)
|
||||
file_handler.setLevel(logging.INFO) # 文件记录所有级别日志
|
||||
|
||||
# --- 2. 控制台实时输出 Handler ---
|
||||
console_handler = logging.StreamHandler() # 默认输出到 sys.stderr (控制台)
|
||||
console_handler.setFormatter(formatter)
|
||||
console_handler.setLevel(logging.INFO) # 控制台仅显示 INFO 及以上级别
|
||||
|
||||
# 将 Handler 添加到 Logger
|
||||
logger.addHandler(file_handler)
|
||||
#logger.addHandler(console_handler)
|
||||
|
||||
return logger
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
# 2025/02/01
|
||||
def get_next_time() -> str:
|
||||
"""
|
||||
获取下一个1分钟时间点,返回格式为字符串'YYYY-MM-DDTHH:MM:00+08:00'
|
||||
:return: 返回字符串格式的时间,表示下一个1分钟的时间点
|
||||
"""
|
||||
# 获取当前时间,并设定为北京时间
|
||||
now = datetime.now() # now 类型为 datetime,表示当前本地时间
|
||||
# 获取当前的分钟,并且将秒和微秒置为零
|
||||
current_time = now.replace(second=0, microsecond=0) # current_time 类型为 datetime,时间的秒和微秒部分被清除
|
||||
return current_time.strftime('%Y-%m-%dT%H:%M:%S+08:00')
|
||||
|
||||
|
||||
# 2025/02/06
|
||||
def store_realtime_SCADA_data_job() -> None:
|
||||
"""
|
||||
定义的任务1,每分钟执行1次,每次执行时,更新get_real_value_time并调用store_realtime_SCADA_data_to_influxdb函数
|
||||
:return: None
|
||||
"""
|
||||
# 获取当前时间并更新get_real_value_time,转换为字符串格式
|
||||
get_real_value_time: str = get_next_time() # get_real_value_time 类型为 str,格式为'2025-02-01T18:45:00+08:00'
|
||||
# 调用函数执行任务
|
||||
influxdb_api.store_realtime_SCADA_data_to_influxdb(get_real_value_time)
|
||||
logger.info('{} -- Successfully store realtime SCADA data.'.format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||
|
||||
|
||||
# 2025/02/06
|
||||
def get_next_15minute_time() -> str:
|
||||
"""
|
||||
获取下一个15分钟的时间点,返回格式为字符串'YYYY-MM-DDTHH:MM:00+08:00'
|
||||
:return: 返回字符串格式的时间,表示下一个15分钟执行时间点
|
||||
"""
|
||||
now = datetime.now()
|
||||
# 向上舍入到下一个15分钟
|
||||
next_15minute = (now.minute // 15 + 1) * 15 - 15
|
||||
if next_15minute == 60:
|
||||
next_15minute = 0
|
||||
now = now + timedelta(hours=1)
|
||||
next_time = now.replace(minute=next_15minute, second=0, microsecond=0)
|
||||
return next_time.strftime('%Y-%m-%dT%H:%M:%S+08:00')
|
||||
|
||||
|
||||
# 2025/02/07
|
||||
def run_simulation_job() -> None:
|
||||
"""
|
||||
定义的任务3,每15分钟执行一次在store_realtime_SCADA_data_to_influxdb之后执行run_simulation。
|
||||
:return: None
|
||||
"""
|
||||
# 获取当前时间,并检查是否是整点15分钟
|
||||
current_time = datetime.now()
|
||||
if current_time.minute % 15 == 0:
|
||||
print(f"{current_time.strftime('%Y-%m-%d %H:%M:%S')} -- Start simulation task.")
|
||||
# 计算前,获取scada_info中的信息,按照设定的方法修改pg数据库
|
||||
simulation.query_corresponding_element_id_and_query_id(project_info.name)
|
||||
simulation.query_corresponding_pattern_id_and_query_id(project_info.name)
|
||||
region_result = simulation.query_non_realtime_region(project_info.name)
|
||||
globals.source_outflow_region_id = simulation.get_source_outflow_region_id(project_info.name, region_result)
|
||||
globals.realtime_region_pipe_flow_and_demand_id = simulation.query_realtime_region_pipe_flow_and_demand_id(project_info.name, region_result)
|
||||
globals.pipe_flow_region_patterns = simulation.query_pipe_flow_region_patterns(project_info.name)
|
||||
globals.non_realtime_region_patterns = simulation.query_non_realtime_region_patterns(project_info.name, region_result)
|
||||
globals.source_outflow_region_patterns, realtime_region_pipe_flow_and_demand_patterns = simulation.get_realtime_region_patterns(project_info.name,
|
||||
globals.source_outflow_region_id,
|
||||
globals.realtime_region_pipe_flow_and_demand_id)
|
||||
modify_pattern_start_time: str = get_next_15minute_time() # 获取下一个15分钟时间点
|
||||
# print(modify_pattern_start_time)
|
||||
simulation.run_simulation(name=project_info.name, simulation_type="realtime", modify_pattern_start_time=modify_pattern_start_time)
|
||||
|
||||
logger.info('{} -- Successfully run simulation and store realtime simulation result.'.format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||
else:
|
||||
logger.info(f"{current_time.strftime('%Y-%m-%d %H:%M:%S')} -- Skipping the simulation task.")
|
||||
|
||||
|
||||
# 2025/02/06
|
||||
def realtime_task() -> None:
|
||||
"""
|
||||
定时执行任务1和,使用schedule库每1分钟执行一次store_realtime_SCADA_data_job函数。
|
||||
该任务会一直运行,定期调用store_realtime_SCADA_data_job获取SCADA数据。
|
||||
:return:
|
||||
"""
|
||||
# 等待到整分对齐
|
||||
now = datetime.now()
|
||||
wait_seconds = 60 - now.second
|
||||
time.sleep(wait_seconds)
|
||||
# 使用 .at(":00") 指定在每分钟的第0秒执行
|
||||
schedule.every(1).minute.at(":00").do(store_realtime_SCADA_data_job)
|
||||
# 每15分钟执行一次run_simulation_job
|
||||
schedule.every(1).minute.at(":00").do(run_simulation_job)
|
||||
# 持续执行任务,检查是否有待执行的任务
|
||||
while True:
|
||||
schedule.run_pending() # 执行所有待处理的定时任务
|
||||
time.sleep(1) # 暂停1秒,避免过于频繁的任务检查
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
url = influxdb_info.url
|
||||
token = influxdb_info.token
|
||||
org_name = influxdb_info.org
|
||||
|
||||
client = InfluxDBClient(url=url, token=token)
|
||||
# step2: 先查询pg数据库中scada_info的信息,然后存储SCADA数据到SCADA_data这个bucket里
|
||||
influxdb_api.query_pg_scada_info_realtime(project_info.name)
|
||||
# 自动执行
|
||||
realtime_task()
|
||||
@@ -1,139 +0,0 @@
|
||||
import influxdb_api
|
||||
import globals
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import schedule
|
||||
import os
|
||||
import logging
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
import time
|
||||
from influxdb_client import InfluxDBClient, BucketsApi, WriteApi, OrganizationsApi, Point, QueryApi
|
||||
import influxdb_info
|
||||
import project_info
|
||||
|
||||
def setup_logger():
|
||||
# 创建日志目录
|
||||
log_dir = "logs"
|
||||
os.makedirs(log_dir, exist_ok=True)
|
||||
|
||||
# 配置基础日志格式
|
||||
log_format = "%(asctime)s - %(levelname)s - %(message)s"
|
||||
formatter = logging.Formatter(log_format)
|
||||
|
||||
# 创建主 Logger
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.INFO) # 全局日志级别
|
||||
|
||||
# --- 1. 按日期分割的日志文件 Handler ---
|
||||
log_file = os.path.join(log_dir, "scada.log")
|
||||
file_handler = TimedRotatingFileHandler(
|
||||
filename=log_file,
|
||||
when="midnight", # 每天午夜轮转
|
||||
interval=1,
|
||||
backupCount=7,
|
||||
encoding="utf-8"
|
||||
)
|
||||
file_handler.suffix = "scada-%Y-%m-%d.log" # 文件名格式
|
||||
file_handler.setFormatter(formatter)
|
||||
file_handler.setLevel(logging.INFO) # 文件记录 INFO 及以上级别
|
||||
|
||||
# --- 2. 控制台实时输出 Handler ---
|
||||
console_handler = logging.StreamHandler() # 默认输出到 sys.stderr (控制台)
|
||||
console_handler.setFormatter(formatter)
|
||||
console_handler.setLevel(logging.INFO) # 控制台仅显示 INFO 及以上级别
|
||||
|
||||
# 将 Handler 添加到 Logger
|
||||
logger.addHandler(file_handler)
|
||||
# logger.addHandler(console_handler)
|
||||
|
||||
return logger
|
||||
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
# 2025/02/01
|
||||
def get_next_time() -> str:
|
||||
"""
|
||||
获取下一个1分钟时间点,返回格式为字符串'YYYY-MM-DDTHH:MM:00+08:00'
|
||||
:return: 返回字符串格式的时间,表示下一个1分钟的时间点
|
||||
"""
|
||||
# 获取当前时间,并设定为北京时间
|
||||
now = datetime.now() # now 类型为 datetime,表示当前本地时间
|
||||
# 获取当前的分钟,并且将秒和微秒置为零
|
||||
current_time = now.replace(second=0, microsecond=0) # current_time 类型为 datetime,时间的秒和微秒部分被清除
|
||||
return current_time.strftime('%Y-%m-%dT%H:%M:%S+08:00')
|
||||
|
||||
|
||||
# 2025/02/06
|
||||
def get_next_period_time() -> str:
|
||||
"""
|
||||
获取下一个6小时时间点,返回格式为字符串'YYYY-MM-DDTHH:00:00+08:00'
|
||||
:return: 返回字符串格式的时间,表示下一个6小时执行时间点
|
||||
"""
|
||||
# 获取当前时间,并设定为北京时间
|
||||
now = datetime.now() # now 类型为 datetime,表示当前本地时间
|
||||
# 获取当前的小时数并计算下一个6小时时间点
|
||||
next_period_hour = (now.hour // 6 + 1) * 6 - 6 # next_period_hour 类型为 int,表示下一个6小时时间点的小时部分
|
||||
# 如果计算的小时大于23,表示进入第二天,调整为00:00
|
||||
if next_period_hour >= 24:
|
||||
next_period_hour = 0
|
||||
now = now + timedelta(days=1) # 如果超过24小时,日期增加1天
|
||||
# 将秒和微秒部分清除,构建出下一个6小时点的datetime对象
|
||||
next_period_time = now.replace(hour=next_period_hour, minute=0, second=0, microsecond=0)
|
||||
return next_period_time.strftime('%Y-%m-%dT%H:%M:%S+08:00') # 格式化为指定的字符串格式并返回
|
||||
|
||||
|
||||
# 2025/02/06
|
||||
def store_non_realtime_SCADA_data_job() -> None:
|
||||
"""
|
||||
定义的任务2,每6小时执行一次,在0点、6点、12点、18点执行,执行时,更新get_history_data_end_time并调用store_non_realtime_SCADA_data_to_influxdb函数
|
||||
:return: None
|
||||
"""
|
||||
# 获取当前时间
|
||||
current_time = datetime.now()
|
||||
# 只在0点、6点、12点、18点执行任务
|
||||
# if current_time.hour % 6 == 0 and current_time.minute == 0:
|
||||
if current_time.minute % 10 == 0:
|
||||
logger.info(f"{current_time.strftime('%Y-%m-%d %H:%M:%S')} -- Start store non realtime SCADA data task.")
|
||||
# 获取下一个6小时的时间点,并更新get_history_data_end_time
|
||||
get_history_data_end_time: str = get_next_time() # get_history_data_end_time 类型为 str,格式为'2025-02-06T12:00:00+08:00'
|
||||
# print(get_next_time)
|
||||
# 调用函数执行任务
|
||||
influxdb_api.store_non_realtime_SCADA_data_to_influxdb(get_history_data_end_time)
|
||||
logger.info('{} -- Successfully store non realtime SCADA data.'.format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||
else:
|
||||
logger.info(f"{current_time.strftime('%Y-%m-%d %H:%M:%S')} -- Skipping store non realtime SCADA data task.")
|
||||
|
||||
|
||||
# 2025/02/06
|
||||
def store_non_realtime_SCADA_data_task() -> None:
|
||||
"""
|
||||
定时执行6小时的任务,使用schedule库每分钟执行一次store_non_realtime_SCADA_data_job函数。
|
||||
该任务会一直运行,定期调用store_non_realtime_SCADA_data_job获取SCADA数据。
|
||||
:return:
|
||||
"""
|
||||
# 等待到整分对齐
|
||||
now = datetime.now()
|
||||
wait_seconds = 60 - now.second
|
||||
time.sleep(wait_seconds)
|
||||
try:
|
||||
# 每分钟检查一次,执行store_non_realtime_SCADA_data_job
|
||||
schedule.every(1).minute.at(":00").do(store_non_realtime_SCADA_data_job)
|
||||
# 持续执行任务,检查是否有待执行的任务
|
||||
while True:
|
||||
schedule.run_pending() # 执行所有待处理的定时任务
|
||||
time.sleep(1) # 暂停1秒,避免过于频繁的任务检查
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"Error occurred in store_non_realtime_SCADA_data_task: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
url = influxdb_info.url
|
||||
token = influxdb_info.token
|
||||
org_name = influxdb_info.org
|
||||
|
||||
client = InfluxDBClient(url=url, token=token)
|
||||
# step2: 先查询pg数据库中scada_info的信息,然后存储SCADA数据到SCADA_data这个bucket里
|
||||
influxdb_api.query_pg_scada_info_non_realtime(project_info.name)
|
||||
# 自动执行
|
||||
store_non_realtime_SCADA_data_task()
|
||||
@@ -1 +0,0 @@
|
||||
python build_pyd.py build
|
||||
@@ -1,24 +0,0 @@
|
||||
from distutils.core import setup
|
||||
from Cython.Build import cythonize
|
||||
|
||||
setup(ext_modules=cythonize([
|
||||
"main.py",
|
||||
"auto_realtime.py",
|
||||
"auto_store_non_realtime_SCADA_data.py",
|
||||
"tjnetwork.py",
|
||||
"online_Analysis.py",
|
||||
"sensitivity.py",
|
||||
"run_simlation.py",
|
||||
"run_simulation.py",
|
||||
"get_hist_data.py",
|
||||
"get_realValue.py",
|
||||
"get_data.py",
|
||||
"get_current_total_Q.py",
|
||||
"get_current_status.py",
|
||||
"influxdb_api.py",
|
||||
"influxdb_query_SCADA_data.py",
|
||||
"simulation.py",
|
||||
"time_api.py",
|
||||
"api/*.py",
|
||||
"epanet/*.py"
|
||||
]))
|
||||
@@ -1,5 +0,0 @@
|
||||
from app.services.tjnetwork import clean_project, delete_project
|
||||
|
||||
if __name__ == '__main__':
|
||||
clean_project()
|
||||
delete_project('project')
|
||||
@@ -1,22 +0,0 @@
|
||||
import sys
|
||||
from app.services.tjnetwork import copy_project, have_project
|
||||
|
||||
def main():
|
||||
argc = len(sys.argv)
|
||||
if argc < 2 or argc > 4:
|
||||
print("copy_project source [count]")
|
||||
return
|
||||
|
||||
source = sys.argv[1]
|
||||
if not have_project(source):
|
||||
print(f"{source} is not available")
|
||||
|
||||
if argc == 2:
|
||||
copy_project(source, f"{source}_1")
|
||||
elif argc == 3:
|
||||
count = int(sys.argv[2])
|
||||
for i in range(1, 1 + count):
|
||||
copy_project(source, f"{source}_{i}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,13 +0,0 @@
|
||||
import sys
|
||||
from app.services.tjnetwork import read_inp
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("create_project which_inp")
|
||||
return
|
||||
|
||||
inp = sys.argv[1]
|
||||
read_inp(inp, f'./inp/{inp}.inp', '2')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,13 +0,0 @@
|
||||
import sys
|
||||
from app.services.tjnetwork import read_inp
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("create_project which_inp")
|
||||
return
|
||||
|
||||
inp = sys.argv[1]
|
||||
read_inp(inp, f'./inp/{inp}.inp', '3')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,136 +0,0 @@
|
||||
import psycopg as pg
|
||||
|
||||
sql_create = [
|
||||
"script/sql/create/0.base.sql",
|
||||
"script/sql/create/1.title.sql",
|
||||
"script/sql/create/2.junctions.sql",
|
||||
"script/sql/create/3.reservoirs.sql",
|
||||
"script/sql/create/4.tanks.sql",
|
||||
"script/sql/create/5.pipes.sql",
|
||||
"script/sql/create/6.pumps.sql",
|
||||
"script/sql/create/7.valves.sql",
|
||||
"script/sql/create/8.tags.sql",
|
||||
"script/sql/create/9.demands.sql",
|
||||
"script/sql/create/10.status.sql",
|
||||
"script/sql/create/11.patterns.sql",
|
||||
"script/sql/create/12.curves.sql",
|
||||
"script/sql/create/13.controls.sql",
|
||||
"script/sql/create/14.rules.sql",
|
||||
"script/sql/create/15.energy.sql",
|
||||
"script/sql/create/16.emitters.sql",
|
||||
"script/sql/create/17.quality.sql",
|
||||
"script/sql/create/18.sources.sql",
|
||||
"script/sql/create/19.reactions.sql",
|
||||
"script/sql/create/20.mixing.sql",
|
||||
"script/sql/create/21.times.sql",
|
||||
"script/sql/create/22.report.sql",
|
||||
"script/sql/create/23.options.sql",
|
||||
"script/sql/create/24.coordinates.sql",
|
||||
"script/sql/create/25.vertices.sql",
|
||||
"script/sql/create/26.labels.sql",
|
||||
"script/sql/create/27.backdrop.sql",
|
||||
"script/sql/create/28.end.sql",
|
||||
"script/sql/create/29.scada_device.sql",
|
||||
"script/sql/create/30.scada_device_data.sql",
|
||||
"script/sql/create/31.scada_element.sql",
|
||||
"script/sql/create/32.region.sql",
|
||||
"script/sql/create/33.dma.sql",
|
||||
"script/sql/create/34.sa.sql",
|
||||
"script/sql/create/35.vd.sql",
|
||||
"script/sql/create/36.wda.sql",
|
||||
"script/sql/create/37.history_patterns_flows.sql",
|
||||
"script/sql/create/38.scada_info.sql",
|
||||
"script/sql/create/39.users.sql",
|
||||
"script/sql/create/40.scheme_list.sql",
|
||||
"script/sql/create/41.pipe_risk_probability.sql",
|
||||
"script/sql/create/42.sensor_placement.sql",
|
||||
"script/sql/create/43.burst_locate_result.sql",
|
||||
"script/sql/create/extension_data.sql",
|
||||
"script/sql/create/operation.sql"
|
||||
]
|
||||
|
||||
sql_drop = [
|
||||
"script/sql/drop/operation.sql",
|
||||
"script/sql/drop/extension_data.sql",
|
||||
"script/sql/drop/43.burst_locate_result.sql",
|
||||
"script/sql/drop/42.sensor_placement.sql",
|
||||
"script/sql/drop/41.pipe_risk_probability.sql",
|
||||
"script/sql/drop/40.scheme_list.sql",
|
||||
"script/sql/drop/39.users.sql",
|
||||
"script/sql/drop/38.scada_info.sql",
|
||||
"script/sql/drop/37.history_patterns_flows.sql",
|
||||
"script/sql/drop/36.wda.sql",
|
||||
"script/sql/drop/35.vd.sql",
|
||||
"script/sql/drop/34.sa.sql",
|
||||
"script/sql/drop/33.dma.sql",
|
||||
"script/sql/drop/32.region.sql",
|
||||
"script/sql/drop/31.scada_element.sql",
|
||||
"script/sql/drop/30.scada_device_data.sql",
|
||||
"script/sql/drop/29.scada_device.sql",
|
||||
"script/sql/drop/28.end.sql",
|
||||
"script/sql/drop/27.backdrop.sql",
|
||||
"script/sql/drop/26.labels.sql",
|
||||
"script/sql/drop/25.vertices.sql",
|
||||
"script/sql/drop/24.coordinates.sql",
|
||||
"script/sql/drop/23.options.sql",
|
||||
"script/sql/drop/22.report.sql",
|
||||
"script/sql/drop/21.times.sql",
|
||||
"script/sql/drop/20.mixing.sql",
|
||||
"script/sql/drop/19.reactions.sql",
|
||||
"script/sql/drop/18.sources.sql",
|
||||
"script/sql/drop/17.quality.sql",
|
||||
"script/sql/drop/16.emitters.sql",
|
||||
"script/sql/drop/15.energy.sql",
|
||||
"script/sql/drop/14.rules.sql",
|
||||
"script/sql/drop/13.controls.sql",
|
||||
"script/sql/drop/12.curves.sql",
|
||||
"script/sql/drop/11.patterns.sql",
|
||||
"script/sql/drop/10.status.sql",
|
||||
"script/sql/drop/9.demands.sql",
|
||||
"script/sql/drop/8.tags.sql",
|
||||
"script/sql/drop/7.valves.sql",
|
||||
"script/sql/drop/6.pumps.sql",
|
||||
"script/sql/drop/5.pipes.sql",
|
||||
"script/sql/drop/4.tanks.sql",
|
||||
"script/sql/drop/3.reservoirs.sql",
|
||||
"script/sql/drop/2.junctions.sql",
|
||||
"script/sql/drop/1.title.sql",
|
||||
"script/sql/drop/0.base.sql"
|
||||
]
|
||||
|
||||
def create_template():
|
||||
with pg.connect(conninfo="dbname=postgres host=127.0.0.1", autocommit=True) as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("create database project")
|
||||
with pg.connect(conninfo="dbname=project host=127.0.0.1") as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute('create extension postgis cascade')
|
||||
cur.execute('create extension pgrouting cascade')
|
||||
for sql in sql_create:
|
||||
with open(sql, "r", encoding="utf-8") as f:
|
||||
cur.execute(f.read())
|
||||
print(f'executed {sql}')
|
||||
conn.commit()
|
||||
|
||||
def have_template():
|
||||
with pg.connect(conninfo="dbname=postgres host=127.0.0.1", autocommit=True) as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("select * from pg_database where datname = 'project'")
|
||||
return cur.rowcount > 0
|
||||
|
||||
def delete_template():
|
||||
with pg.connect(conninfo="dbname=project host=127.0.0.1") as conn:
|
||||
with conn.cursor() as cur:
|
||||
for sql in sql_drop:
|
||||
with open(sql, "r", encoding="utf-8") as f:
|
||||
cur.execute(f.read())
|
||||
print(f'executed {sql}')
|
||||
conn.commit()
|
||||
with pg.connect(conninfo="dbname=postgres host=127.0.0.1", autocommit=True) as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("drop database project")
|
||||
|
||||
if __name__ == "__main__":
|
||||
if (have_template()):
|
||||
delete_template()
|
||||
create_template()
|
||||
@@ -1,12 +0,0 @@
|
||||
import sys
|
||||
from app.services.tjnetwork import delete_project
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("delete_project name")
|
||||
return
|
||||
|
||||
delete_project(sys.argv[1])
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,7 +0,0 @@
|
||||
from app.services.tjnetwork import list_project, read_inp
|
||||
read_inp("beibeizone","beibeizone.inp")
|
||||
#open_project('beibeizone')
|
||||
#generate_service_area("beibeizone",0.00001)
|
||||
|
||||
print(list_project())
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
from app.services.tjnetwork import calculate_service_area, open_project, read_inp
|
||||
|
||||
p = 'dev'
|
||||
|
||||
read_inp(p, f'./inp/net3.inp', '3')
|
||||
open_project(p)
|
||||
|
||||
sass = calculate_service_area(p)
|
||||
assert len(sass) == 25
|
||||
|
||||
assert sass[0]['River'] == ['River', '60', '61', '123', '601']
|
||||
assert sass[0]['3'] == ['121', '120', '119', '117', '257', '151', '157', '115', '259', '261', '149', '159', '111', '113', '263', '147', '161', '197', '193', '105', '145', '163', '195', '191', '267', '107', '141', '164', '265', '187', '189', '143', '166', '169', '204', '15', '167', '171', '269', '173', '271', '199', '201', '203', '3', '20', '127', '125', '129', '153', '131', '139']
|
||||
assert sass[0]['1'] == ['185', '184', '205', '273', '1', '40', '179', '177', '183', '181', '35']
|
||||
assert sass[0]['2'] == ['207', '275', '2', '50', '255', '247', '253', '251', '241', '249', '239', '243', '237', '211', '229', '209', '213', '231', '208', '215', '206', '217', '219', '225']
|
||||
|
||||
print(sass[1])
|
||||
assert sass[0]['River'] == ['River', '60', '61', '123', '601']
|
||||
assert sass[0]['3'] == ['121', '120', '119', '117', '257', '151', '157', '115', '259', '261', '149', '159', '111', '113', '263', '147', '161', '197', '193', '145', '163', '195', '191', '141', '164', '265', '187', '143', '166', '169', '267', '204', '15', '167', '171', '269', '173', '199', '201', '203', '3', '20', '127', '125', '129', '153', '131', '139']
|
||||
assert sass[0]['Lake'] == ['105', '107', 'Lake', '10', '101', '103', '109']
|
||||
assert sass[0]['1'] == ['189', '185', '271', '184', '205', '273', '1', '40', '179', '177', '183', '181', '35']
|
||||
assert sass[0]['2'] == ['207', '275', '2', '50', '255', '247', '253', '251', '241', '249', '239', '243', '237', '211', '229', '209', '213', '231', '208', '215', '206', '217', '219', '225']
|
||||
@@ -1,23 +0,0 @@
|
||||
import json
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
def draw_pipe():
|
||||
# 读取json文件
|
||||
with open(r'C:\Users\dingsu\Desktop\links_coordinates.json', 'r') as f:
|
||||
pipe_data = json.load(f)
|
||||
|
||||
# 创建一个空列表来存储所有点的坐标
|
||||
|
||||
# 将两个点连接成一条线,然后每条线都绘制出来
|
||||
for item in pipe_data:
|
||||
x1 = item[0][0]
|
||||
y1 = item[0][1]
|
||||
x2 = item[1][0]
|
||||
y2 = item[1][1]
|
||||
|
||||
plt.plot([x1, x2], [y1, y2], 'r-')
|
||||
|
||||
plt.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
draw_pipe()
|
||||
@@ -1,12 +0,0 @@
|
||||
import sys
|
||||
from app.services.tjnetwork import dump_inp
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("dump_inp name")
|
||||
return
|
||||
|
||||
dump_inp(sys.argv[1], f'{sys.argv[1]}.inp', '2')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,33 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
# 将项目根目录添加到 python 路径
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
from app.core.encryption import get_database_encryptor
|
||||
|
||||
|
||||
def main() -> int:
|
||||
plaintext = None
|
||||
if not sys.stdin.isatty():
|
||||
stdin_text = sys.stdin.read()
|
||||
if stdin_text != "":
|
||||
plaintext = stdin_text.rstrip("\r\n")
|
||||
if plaintext is None and len(sys.argv) >= 2:
|
||||
plaintext = sys.argv[1]
|
||||
if plaintext is None:
|
||||
try:
|
||||
plaintext = input("请输入要加密的文本: ")
|
||||
except EOFError:
|
||||
plaintext = ""
|
||||
if not plaintext.strip():
|
||||
print("Error: plaintext string cannot be empty.", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
token = get_database_encryptor().encrypt(plaintext)
|
||||
print(token)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -1,66 +0,0 @@
|
||||
from app.services.tjnetwork import api, get_all_service_area_ids, open_project
|
||||
from get_realValue import *
|
||||
from get_hist_data import *
|
||||
import datetime
|
||||
from api.s36_wda_cal import *
|
||||
|
||||
|
||||
ids=['2498','3854','3853','2510','2514','4780','4854']
|
||||
cur_data=None
|
||||
|
||||
|
||||
def get_latest_cal_time()->datetime:
|
||||
current_time=datetime.datetime.now()
|
||||
return current_time
|
||||
|
||||
|
||||
def get_current_data(str_datetime: str=None)->bool:
|
||||
global cur_data
|
||||
if str_datetime==None:
|
||||
cur_data=get_realValue(ids)
|
||||
else:
|
||||
cur_date=get_hist_data(ids,str_datetime)
|
||||
if cur_data ==None:
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_current_total_Q(str_dt:str='')->float:
|
||||
q_ids=['2498','3854','3853']
|
||||
q_dn900=cur_data[q_ids[0]]
|
||||
q_dn500=cur_data[q_ids[1]]
|
||||
q_dn1000=cur_data[q_ids[2]]
|
||||
total_q=q_dn1000+q_dn500+q_dn900
|
||||
return total_q
|
||||
|
||||
def get_h_pressure()->float:
|
||||
head_id='2510'
|
||||
h_pressure=cur_data[head_id]
|
||||
return h_pressure
|
||||
|
||||
def get_l_pressure()->float:
|
||||
head_id='2514'
|
||||
l_pressure=cur_data[head_id]
|
||||
return l_pressure
|
||||
|
||||
def get_h_tank_leve()->float:
|
||||
h_tank_id='4780'
|
||||
h_tank_level=cur_data[h_tank_id]
|
||||
return h_tank_level
|
||||
|
||||
def get_l_tank_leve()->float:
|
||||
l_tank_id='4854'
|
||||
l_tank_level=cur_data[l_tank_id]
|
||||
return l_tank_level
|
||||
|
||||
|
||||
# test interface
|
||||
if __name__ == '__main__':
|
||||
# if get_current_data()==True:
|
||||
# tQ=get_current_total_Q()
|
||||
# print(f"the current tQ is {tQ}\n")
|
||||
# data=get_hist_data(ids,conver_beingtime_to_ucttime('2024-04-10 15:05:00'),conver_beingtime_to_ucttime('2024-04-10 15:10:00'))
|
||||
open_project("beibeizone")
|
||||
regions=get_all_service_area_ids("beibeizone")
|
||||
for region in regions:
|
||||
t_basedmds=api.s36_wda_cal.get_total_base_demand("beibeizone",region)
|
||||
print(f"{region}:{t_basedmds}")
|
||||
@@ -1,5 +0,0 @@
|
||||
from get_realValue import *
|
||||
def get_current_total_Q():
|
||||
ids=['3489']
|
||||
total_q=get_realValue(ids)
|
||||
return total_q
|
||||
@@ -1,172 +0,0 @@
|
||||
import requests
|
||||
from datetime import datetime
|
||||
import pytz
|
||||
from typing import List, Dict, Union, Optional
|
||||
import csv
|
||||
|
||||
# get_data 是用来获取 历史数据,也就是非实时数据的接口
|
||||
# get_realtime 是用来获取 实时数据
|
||||
|
||||
|
||||
def convert_timestamp_to_beijing_time(timestamp: Union[int, float]) -> datetime:
|
||||
# 将毫秒级时间戳转换为秒级时间戳
|
||||
timestamp_seconds = timestamp / 1000
|
||||
|
||||
# 将时间戳转换为datetime对象
|
||||
utc_time = datetime.fromtimestamp(timestamp_seconds)
|
||||
|
||||
# 设定UTC时区
|
||||
utc_timezone = pytz.timezone("UTC")
|
||||
|
||||
# 转换为北京时间
|
||||
beijing_timezone = pytz.timezone("Asia/Shanghai")
|
||||
beijing_time = utc_time.replace(tzinfo=utc_timezone).astimezone(beijing_timezone)
|
||||
|
||||
return beijing_time
|
||||
|
||||
|
||||
def beijing_time_to_utc(beijing_time_str: str) -> str:
|
||||
# 定义北京时区
|
||||
beijing_timezone = pytz.timezone("Asia/Shanghai")
|
||||
|
||||
# 将字符串转换为datetime对象
|
||||
beijing_time = datetime.strptime(beijing_time_str, "%Y-%m-%d %H:%M:%S")
|
||||
|
||||
# 本地化时间对象
|
||||
beijing_time = beijing_timezone.localize(beijing_time)
|
||||
|
||||
# 转换为UTC时间
|
||||
utc_time = beijing_time.astimezone(pytz.utc)
|
||||
|
||||
# 转换为ISO 8601格式的字符串
|
||||
return utc_time.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
|
||||
|
||||
def get_history_data(
|
||||
ids: str, begin_date: str, end_date: str, downsample: Optional[str]
|
||||
) -> List[Dict[str, Union[str, datetime, int, float]]]:
|
||||
# def get_history_data(ids: str, begin_date: str, end_date: str, downsample: Optional[str]) -> None:
|
||||
# 转换输入的北京时间为UTC时间
|
||||
begin_date_utc = beijing_time_to_utc(begin_date)
|
||||
end_date_utc = beijing_time_to_utc(end_date)
|
||||
|
||||
# 数据接口的地址
|
||||
url = "http://183.64.62.100:9057/loong/api/curves/data"
|
||||
# url = 'http://10.101.15.16:9000/loong/api/curves/data'
|
||||
# url_path = 'http://10.101.15.16:9000/loong' # 内网
|
||||
|
||||
# 设置 GET 请求的参数
|
||||
params = {
|
||||
"ids": ids,
|
||||
"beginDate": begin_date_utc,
|
||||
"endDate": end_date_utc,
|
||||
"downsample": downsample,
|
||||
}
|
||||
|
||||
history_data_list = []
|
||||
|
||||
try:
|
||||
# 发送 GET 请求获取数据
|
||||
response = requests.get(url, params=params)
|
||||
|
||||
# 检查响应状态码,200 表示请求成功
|
||||
if response.status_code == 200:
|
||||
# 解析响应的 JSON 数据
|
||||
data = response.json()
|
||||
# 这里可以对获取到的数据进行进一步处理
|
||||
|
||||
# 打印 'mpointId' 和 'mpointName'
|
||||
for item in data["items"]:
|
||||
mpoint_id = str(item["mpointId"])
|
||||
mpoint_name = item["mpointName"]
|
||||
# print("mpointId:", item['mpointId'])
|
||||
# print("mpointName:", item['mpointName'])
|
||||
|
||||
# 打印 'dataDate' 和 'dataValue'
|
||||
for item_data in item["data"]:
|
||||
# 将时间戳转换为北京时间
|
||||
beijing_time = convert_timestamp_to_beijing_time(
|
||||
item_data["dataDate"]
|
||||
)
|
||||
data_value = item_data["dataValue"]
|
||||
# 创建一个字典存储每条数据
|
||||
data_dict = {
|
||||
"time": beijing_time,
|
||||
"device_ID": str(mpoint_id),
|
||||
"description": mpoint_name,
|
||||
# 'dataDate (Beijing Time)': beijing_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
"monitored_value": data_value, # 保留原有类型
|
||||
}
|
||||
|
||||
history_data_list.append(data_dict)
|
||||
else:
|
||||
# 如果请求不成功,打印错误信息
|
||||
print("请求失败,状态码:", response.status_code)
|
||||
|
||||
except Exception as e:
|
||||
# 捕获异常
|
||||
print("发生异常:", e)
|
||||
|
||||
return history_data_list
|
||||
|
||||
|
||||
# 使用示例
|
||||
# data_list = get_history_data(ids='9572',
|
||||
# begin_date='2025-02-08 06:00:00',
|
||||
# end_date='2025-02-08 12:00:00',
|
||||
# downsample='1m')
|
||||
#
|
||||
# # 打印数据列表
|
||||
# for data in data_list:
|
||||
# print(data)
|
||||
|
||||
# # 定义 CSV 文件的路径
|
||||
# csv_file_path = './influxdb_data_4984.csv'
|
||||
# # 将数据写入 CSV 文件
|
||||
# # with open(csv_file_path, mode='w', newline='') as file:
|
||||
# # writer = csv.writer(file)
|
||||
# #
|
||||
# # # 写入表头
|
||||
# # writer.writerow(['measurement', 'mpointId', 'date', 'dataValue', 'datetime'])
|
||||
# #
|
||||
# # # 写入数据
|
||||
# # for data in data_list:
|
||||
# # measurement = data['mpointName']
|
||||
# # mpointId = data['mpointId']
|
||||
# # date = data['datetime'].strftime('%Y-%m-%d')
|
||||
# # dataValue = data['dataValue']
|
||||
# # datetime_str = data['datetime']
|
||||
# #
|
||||
# # # 写入一行
|
||||
# # writer.writerow([measurement, mpointId, date, dataValue, datetime_str])
|
||||
# #
|
||||
# #
|
||||
# # print(f"数据已保存到 {csv_file_path}")
|
||||
#
|
||||
# filtered_csv_file_path = './filtered_influxdb_data_4984.csv'
|
||||
# #
|
||||
# # # # 读取并筛选数据
|
||||
# data_list1 = []
|
||||
#
|
||||
# with open(csv_file_path, mode='r') as file:
|
||||
# csv_reader = csv.DictReader(file)
|
||||
# for row in csv_reader:
|
||||
# # 将 datetime 列解析为 datetime 对象
|
||||
# datetime_value = datetime.strptime(row['datetime'], '%Y-%m-%d %H:%M:%S%z')
|
||||
#
|
||||
# # 只保留时间为 15 分钟倍数的行
|
||||
# if datetime_value.minute % 15 == 0:
|
||||
# data_list1.append(row)
|
||||
#
|
||||
# # 将筛选后的数据写入新的 CSV 文件
|
||||
# with open(filtered_csv_file_path, mode='w', newline='') as file:
|
||||
# writer = csv.writer(file)
|
||||
#
|
||||
# # 写入表头
|
||||
# writer.writerow(['measurement', 'mpointId', 'date', 'dataValue', 'datetime'])
|
||||
#
|
||||
# # 写入筛选后的数据
|
||||
# for data in data_list1:
|
||||
# writer.writerow([data['measurement'], data['mpointId'], data['date'], data['dataValue'], data['datetime']])
|
||||
#
|
||||
# print(f"筛选后的数据已保存到 {filtered_csv_file_path}")
|
||||
@@ -1,83 +0,0 @@
|
||||
import requests
|
||||
from datetime import datetime
|
||||
import pytz
|
||||
|
||||
|
||||
def convert_timestamp_to_beijing_time(timestamp):
|
||||
# 将毫秒级时间戳转换为秒级时间戳
|
||||
timestamp_seconds = timestamp / 1000
|
||||
|
||||
# 将时间戳转换为datetime对象
|
||||
utc_time = datetime.fromtimestamp(timestamp_seconds)
|
||||
|
||||
# 设定UTC时区
|
||||
utc_timezone = pytz.timezone("UTC")
|
||||
|
||||
# 转换为北京时间
|
||||
beijing_timezone = pytz.timezone("Asia/Shanghai")
|
||||
beijing_time = utc_time.replace(tzinfo=utc_timezone).astimezone(beijing_timezone)
|
||||
|
||||
return beijing_time
|
||||
|
||||
|
||||
def conver_beingtime_to_ucttime(timestr: str):
|
||||
beijing_time = datetime.strptime(timestr, "%Y-%m-%d %H:%M:%S")
|
||||
utc_time = beijing_time.astimezone(pytz.utc)
|
||||
str_utc = utc_time.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
# print(str_utc)
|
||||
return str_utc
|
||||
|
||||
|
||||
def get_hist_data(ids, begin_date, end_date) -> dict[str, dict[datetime, float]]:
|
||||
# 数据接口的地址
|
||||
url = "http://183.64.62.100:9057/loong/api/curves/data"
|
||||
|
||||
# 设置 GET 请求的参数
|
||||
params = {"ids": ids, "beginDate": begin_date, "endDate": end_date}
|
||||
lst_data = {}
|
||||
try:
|
||||
# 发送 GET 请求获取数据
|
||||
response = requests.get(url, params=params)
|
||||
|
||||
# 检查响应状态码,200 表示请求成功
|
||||
if response.status_code == 200:
|
||||
# 解析响应的 JSON 数据
|
||||
data = response.json()
|
||||
# 这里可以对获取到的数据进行进一步处理
|
||||
|
||||
# 打印 'mpointId' 和 'mpointName'
|
||||
for item in data["items"]:
|
||||
# print("mpointId:", item['mpointId'])
|
||||
# print("mpointName:", item['mpointName'])
|
||||
|
||||
# 打印 'dataDate' 和 'dataValue'
|
||||
data_seriers = {}
|
||||
for item_data in item["data"]:
|
||||
# print("dataDate:", item_data['dataDate'])
|
||||
# 将时间戳转换为北京时间
|
||||
beijing_time = convert_timestamp_to_beijing_time(
|
||||
item_data["dataDate"]
|
||||
)
|
||||
print(
|
||||
"dataDate (Beijing Time):",
|
||||
beijing_time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
)
|
||||
print("dataValue:", item_data["dataValue"])
|
||||
print() # 打印空行分隔不同条目
|
||||
r = float(item_data["dataValue"])
|
||||
data_seriers[beijing_time] = r
|
||||
lst_data[item["mpointId"]] = data_seriers
|
||||
return lst_data
|
||||
else:
|
||||
# 如果请求不成功,打印错误信息
|
||||
print("请求失败,状态码:", response.status_code)
|
||||
|
||||
except Exception as e:
|
||||
# 捕获异常
|
||||
print("发生异常:", e)
|
||||
|
||||
|
||||
# 使用示例
|
||||
# get_hist_data(ids='2498,2500',
|
||||
# begin_date='2024-03-31T16:00:00Z',
|
||||
# end_date='2024-04-01T16:00:00Z')
|
||||
@@ -1,73 +0,0 @@
|
||||
import requests
|
||||
from datetime import datetime
|
||||
import pytz
|
||||
from typing import List, Dict, Union, Tuple
|
||||
|
||||
|
||||
def convert_to_beijing_time(utc_time_str):
|
||||
# 解析UTC时间字符串为datetime对象
|
||||
utc_time = datetime.strptime(utc_time_str, '%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
# 设定UTC时区
|
||||
utc_timezone = pytz.timezone('UTC')
|
||||
|
||||
# 转换为北京时间
|
||||
beijing_timezone = pytz.timezone('Asia/Shanghai')
|
||||
beijing_time = utc_time.replace(tzinfo=utc_timezone).astimezone(beijing_timezone)
|
||||
|
||||
return beijing_time
|
||||
|
||||
|
||||
def get_realValue(ids) -> List[Dict[str, Union[str, datetime, int, float]]]:
|
||||
# 数据接口的地址
|
||||
url = 'http://183.64.62.100:9057/loong/api/mpoints/realValue'
|
||||
# url = 'http://10.101.15.16:9000/loong/api/mpoints/realValue' # 内网
|
||||
|
||||
# 设置GET请求的参数
|
||||
params = {
|
||||
'ids': ids
|
||||
}
|
||||
# 创建一个字典来存储数据
|
||||
data_list = []
|
||||
|
||||
try:
|
||||
# 发送GET请求获取数据
|
||||
response = requests.get(url, params=params)
|
||||
|
||||
# 检查响应状态码,200表示请求成功
|
||||
if response.status_code == 200:
|
||||
# 解析响应的JSON数据
|
||||
data = response.json()
|
||||
|
||||
# 只打印'id'、'datadt'和'realValue'数据
|
||||
for realValue in data:
|
||||
# print("id:", realValue['id'])
|
||||
# print("mpointName:",realValue['mpointName'])
|
||||
# print("datadt:", realValue['datadt'])
|
||||
# 转换datadt字段为北京时间
|
||||
beijing_time = convert_to_beijing_time(realValue['datadt'])
|
||||
# print("datadt (Beijing Time):", beijing_time.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
# print("realValue:", realValue['realValue'])
|
||||
# print() # 打印空行分隔不同条目
|
||||
# 将数据添加到字典中,值为一个字典,包含其他需要的字段
|
||||
data_list.append({
|
||||
'device_ID': realValue['id'],
|
||||
'description': realValue['mpointName'],
|
||||
'time': beijing_time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'monitored_value': realValue['realValue']
|
||||
})
|
||||
|
||||
else:
|
||||
# 如果请求不成功,打印错误信息
|
||||
print("请求失败,状态码:", response.status_code)
|
||||
|
||||
except Exception as e:
|
||||
# 捕获异常
|
||||
print("发生异常:", e)
|
||||
|
||||
return data_list
|
||||
|
||||
|
||||
# 使用示例
|
||||
# data_list = get_realValue(ids='2498,2500')
|
||||
# print(data_list)
|
||||
@@ -1,72 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
def install():
|
||||
if sys.version_info.major != 3:
|
||||
print("Require install Python 3.x !")
|
||||
return
|
||||
|
||||
minor = sys.version_info.minor
|
||||
if minor < 4 or minor > 12:
|
||||
print("Require install Python 3.4 ~ Python 3.12 !")
|
||||
return
|
||||
|
||||
# upgrade pipe
|
||||
os.system('python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple')
|
||||
|
||||
# install package
|
||||
packages = [
|
||||
'"psycopg[binary]"',
|
||||
'pytest',
|
||||
'influxdb_client',
|
||||
'numpy',
|
||||
'fastapi',
|
||||
"msgpack",
|
||||
'schedule',
|
||||
'pandas',
|
||||
'openpyxl',
|
||||
'redis',
|
||||
'pydantic',
|
||||
'python-dateutil',
|
||||
'starlette',
|
||||
'requests',
|
||||
'uvicorn',
|
||||
'chardet',
|
||||
'py-linq',
|
||||
'python-multipart',
|
||||
'Cython',
|
||||
'geopandas',
|
||||
'sqlalchemy',
|
||||
'networkx',
|
||||
'wntr',
|
||||
'scipy',
|
||||
'scikit-learn',
|
||||
'scikit-fuzzy',
|
||||
'libpysal',
|
||||
'spopt',
|
||||
'shapely',
|
||||
'geopandas',
|
||||
'passlib',
|
||||
'jose'
|
||||
]
|
||||
|
||||
if minor == 4:
|
||||
packages.append('script/package/PyMetis-2018.1-cp34-cp34m-win_amd64.whl')
|
||||
elif minor == 5:
|
||||
packages.append('script/package/PyMetis-2019.1.1-cp35-cp35m-win_amd64.whl')
|
||||
elif minor == 6:
|
||||
packages.append('script/package/PyMetis-2019.1.1-cp36-cp36m-win_amd64.whl')
|
||||
elif minor == 7:
|
||||
packages.append('script/package/PyMetis-2020.1-cp37-cp37m-win_amd64.whl')
|
||||
elif minor == 8:
|
||||
packages.append('script/package/PyMetis-2020.1-cp38-cp38-win_amd64.whl')
|
||||
elif minor == 9:
|
||||
packages.append('script/package/PyMetis-2020.1-cp39-cp39-win_amd64.whl')
|
||||
elif minor == 10:
|
||||
packages.append('script/package/PyMetis-2020.1-cp310-cp310-win_amd64.whl')
|
||||
|
||||
for package in packages:
|
||||
os.system(f'pip install {package} -i https://pypi.tuna.tsinghua.edu.cn/simple')
|
||||
|
||||
if __name__ == '__main__':
|
||||
install()
|
||||
-4505
File diff suppressed because it is too large
Load Diff
@@ -1,398 +0,0 @@
|
||||
# API Endpoints (scripts/main.py)
|
||||
|
||||
Non-commented FastAPI routes defined in `scripts/main.py`.
|
||||
|
||||
- `POST /login/`
|
||||
- `GET /getallextensiondatakeys/`
|
||||
- `GET /getallextensiondata/`
|
||||
- `GET /getextensiondata/`
|
||||
- `POST /setextensiondata`
|
||||
- `GET /listprojects/`
|
||||
- `GET /haveproject/`
|
||||
- `POST /createproject/`
|
||||
- `POST /deleteproject/`
|
||||
- `GET /isprojectopen/`
|
||||
- `POST /openproject/`
|
||||
- `POST /closeproject/`
|
||||
- `POST /copyproject/`
|
||||
- `POST /importinp/`
|
||||
- `GET /exportinp/`
|
||||
- `POST /readinp/`
|
||||
- `GET /dumpinp/`
|
||||
- `GET /runproject/`
|
||||
- `GET /runprojectreturndict/`
|
||||
- `GET /runinp/`
|
||||
- `GET /dumpoutput/`
|
||||
- `GET /isprojectlocked/`
|
||||
- `GET /isprojectlockedbyme/`
|
||||
- `POST /lockproject/`
|
||||
- `POST /unlockproject/`
|
||||
- `GET /getcurrentoperationid/`
|
||||
- `POST /undo/`
|
||||
- `POST /redo/`
|
||||
- `GET /getsnapshots/`
|
||||
- `GET /havesnapshot/`
|
||||
- `GET /havesnapshotforoperation/`
|
||||
- `GET /havesnapshotforcurrentoperation/`
|
||||
- `POST /takesnapshotforoperation/`
|
||||
- `POST takenapshotforcurrentoperation`
|
||||
- `POST /takesnapshot/`
|
||||
- `POST /picksnapshot/`
|
||||
- `POST /pickoperation/`
|
||||
- `GET /syncwithserver/`
|
||||
- `POST /batch/`
|
||||
- `POST /compressedbatch/`
|
||||
- `GET /getrestoreoperation/`
|
||||
- `POST /setrestoreoperation/`
|
||||
- `GET /isnode/`
|
||||
- `GET /isjunction/`
|
||||
- `GET /isreservoir/`
|
||||
- `GET /istank/`
|
||||
- `GET /islink/`
|
||||
- `GET /ispipe/`
|
||||
- `GET /ispump/`
|
||||
- `GET /isvalve/`
|
||||
- `GET /getnodetype/`
|
||||
- `GET /getlinktype/`
|
||||
- `GET /getelementtype/`
|
||||
- `GET /getelementtypevalue/`
|
||||
- `GET /iscurve/`
|
||||
- `GET /ispattern/`
|
||||
- `GET /getnodes/`
|
||||
- `GET /getlinks/`
|
||||
- `GET /getcurves/`
|
||||
- `GET /getpatterns/`
|
||||
- `GET /getnodelinks/`
|
||||
- `GET /getnodeproperties/`
|
||||
- `GET /getlinkproperties/`
|
||||
- `GET /getscadaproperties/`
|
||||
- `GET /getallscadaproperties/`
|
||||
- `GET /getelementpropertieswithtype/`
|
||||
- `GET /getelementproperties/`
|
||||
- `GET /gettitleschema/`
|
||||
- `GET /gettitle/`
|
||||
- `GET /settitle/`
|
||||
- `GET /getjunctionschema`
|
||||
- `POST /addjunction/`
|
||||
- `POST /deletejunction/`
|
||||
- `GET /getjunctionelevation/`
|
||||
- `GET /getjunctionx/`
|
||||
- `GET /getjunctiony/`
|
||||
- `GET /getjunctioncoord/`
|
||||
- `GET /getjunctiondemand/`
|
||||
- `GET /getjunctionpattern/`
|
||||
- `POST /setjunctionelevation/`
|
||||
- `POST /setjunctionx/`
|
||||
- `POST /setjunctiony/`
|
||||
- `POST /setjunctioncoord/`
|
||||
- `POST /setjunctiondemand/`
|
||||
- `POST /setjunctionpattern/`
|
||||
- `GET /getjunctionproperties/`
|
||||
- `GET /getalljunctionproperties/`
|
||||
- `POST /setjunctionproperties/`
|
||||
- `GET /getreservoirschema`
|
||||
- `POST /addreservoir/`
|
||||
- `POST /deletereservoir/`
|
||||
- `GET /getreservoirhead/`
|
||||
- `GET /getreservoirpattern/`
|
||||
- `GET /getreservoirx/`
|
||||
- `GET /getreservoiry/`
|
||||
- `GET /getreservoircoord/`
|
||||
- `POST /setreservoirhead/`
|
||||
- `POST /setreservoirpattern/`
|
||||
- `POST /setreservoirx/`
|
||||
- `POST /setreservoirx/`
|
||||
- `POST /setreservoircoord/`
|
||||
- `GET /getreservoirproperties/`
|
||||
- `GET /getallreservoirproperties/`
|
||||
- `POST /setreservoirproperties/`
|
||||
- `GET /gettankschema`
|
||||
- `POST /addtank/`
|
||||
- `POST /deletetank/`
|
||||
- `GET /gettankelevation/`
|
||||
- `GET /gettankinitlevel/`
|
||||
- `GET /gettankminlevel/`
|
||||
- `GET /gettankmaxlevel/`
|
||||
- `GET /gettankdiameter/`
|
||||
- `GET /gettankminvol/`
|
||||
- `GET /gettankvolcurve/`
|
||||
- `GET /gettankoverflow/`
|
||||
- `GET /gettankx/`
|
||||
- `GET /gettanky/`
|
||||
- `GET /gettankcoord/`
|
||||
- `POST /settankelevation/`
|
||||
- `POST /settankinitlevel/`
|
||||
- `POST /settankminlevel/`
|
||||
- `POST /settankmaxlevel/`
|
||||
- `POST settankdiameter//`
|
||||
- `POST /settankminvol/`
|
||||
- `POST /settankvolcurve/`
|
||||
- `POST /settankoverflow/`
|
||||
- `POST /settankx/`
|
||||
- `POST /settanky/`
|
||||
- `POST /settankcoord/`
|
||||
- `GET /gettankproperties/`
|
||||
- `GET /getalltankproperties/`
|
||||
- `POST /settankproperties/`
|
||||
- `GET /getpipeschema`
|
||||
- `POST /addpipe/`
|
||||
- `POST /deletepipe/`
|
||||
- `GET /getpipenode1/`
|
||||
- `GET /getpipenode2/`
|
||||
- `GET /getpipelength/`
|
||||
- `GET /getpipediameter/`
|
||||
- `GET /getpiperoughness/`
|
||||
- `GET /getpipeminorloss/`
|
||||
- `GET /getpipestatus/`
|
||||
- `POST /setpipenode1/`
|
||||
- `POST /setpipenode2/`
|
||||
- `POST /setpipelength/`
|
||||
- `POST /setpipediameter/`
|
||||
- `POST /setpiperoughness/`
|
||||
- `POST /setpipeminorloss/`
|
||||
- `POST /setpipestatus/`
|
||||
- `GET /getpipeproperties/`
|
||||
- `GET /getallpipeproperties/`
|
||||
- `POST /setpipeproperties/`
|
||||
- `GET /getpumpschema`
|
||||
- `POST /addpump/`
|
||||
- `POST /deletepump/`
|
||||
- `GET /getpumpnode1/`
|
||||
- `GET /getpumpnode2/`
|
||||
- `POST /setpumpnode1/`
|
||||
- `POST /setpumpnode2/`
|
||||
- `GET /getpumpproperties/`
|
||||
- `GET /getallpumpproperties/`
|
||||
- `POST /setpumpproperties/`
|
||||
- `GET /getvalveschema`
|
||||
- `POST /addvalve/`
|
||||
- `POST /deletevalve/`
|
||||
- `GET /getvalvenode1/`
|
||||
- `GET /getvalvenode2/`
|
||||
- `GET /getvalvediameter/`
|
||||
- `GET /getvalvetype/`
|
||||
- `GET /getvalvesetting/`
|
||||
- `GET /getvalveminorloss/`
|
||||
- `POST /setvalvenode1/`
|
||||
- `POST /setvalvenode2/`
|
||||
- `POST /setvalvenodediameter/`
|
||||
- `POST /setvalvetype/`
|
||||
- `POST /setvalvesetting/`
|
||||
- `GET /getvalveproperties/`
|
||||
- `GET /getallvalveproperties/`
|
||||
- `POST /setvalveproperties/`
|
||||
- `POST /deletenode/`
|
||||
- `POST /deletelink/`
|
||||
- `GET /gettagschema/`
|
||||
- `GET /gettag/`
|
||||
- `GET /gettags/`
|
||||
- `POST /settag/`
|
||||
- `GET /getdemandschema`
|
||||
- `GET /getdemandproperties/`
|
||||
- `POST /setdemandproperties/`
|
||||
- `GET /getstatusschema`
|
||||
- `GET /getstatus/`
|
||||
- `POST /setstatus/`
|
||||
- `GET /getpatternschema`
|
||||
- `POST /addpattern/`
|
||||
- `POST /deletepattern/`
|
||||
- `GET /getpatternproperties/`
|
||||
- `POST /setpatternproperties/`
|
||||
- `GET /getcurveschema`
|
||||
- `POST /addcurve/`
|
||||
- `POST /deletecurve/`
|
||||
- `GET /getcurveproperties/`
|
||||
- `POST /setcurveproperties/`
|
||||
- `GET /getcontrolschema/`
|
||||
- `GET /getcontrolproperties/`
|
||||
- `POST /setcontrolproperties/`
|
||||
- `GET /getruleschema/`
|
||||
- `GET /getruleproperties/`
|
||||
- `POST /setruleproperties/`
|
||||
- `GET /getenergyschema/`
|
||||
- `GET /getenergyproperties/`
|
||||
- `POST /setenergyproperties/`
|
||||
- `GET /getpumpenergyschema/`
|
||||
- `GET /getpumpenergyproperties//`
|
||||
- `GET /setpumpenergyproperties//`
|
||||
- `GET /getemitterschema`
|
||||
- `GET /getemitterproperties/`
|
||||
- `POST /setemitterproperties/`
|
||||
- `GET /getqualityschema/`
|
||||
- `GET /getqualityproperties/`
|
||||
- `POST /setqualityproperties/`
|
||||
- `GET /getsourcechema/`
|
||||
- `GET /getsource/`
|
||||
- `POST /setsource/`
|
||||
- `POST /addsource/`
|
||||
- `POST /deletesource/`
|
||||
- `GET /getreactionschema/`
|
||||
- `GET /getreaction/`
|
||||
- `POST /setreaction/`
|
||||
- `GET /getpipereactionschema/`
|
||||
- `GET /getpipereaction/`
|
||||
- `POST /setpipereaction/`
|
||||
- `GET /gettankreactionschema/`
|
||||
- `GET /gettankreaction/`
|
||||
- `POST /settankreaction/`
|
||||
- `GET /getmixingschema/`
|
||||
- `GET /getmixing/`
|
||||
- `POST /setmixing/`
|
||||
- `POST /addmixing/`
|
||||
- `POST /deletemixing/`
|
||||
- `GET /gettimeschema`
|
||||
- `GET /gettimeproperties/`
|
||||
- `POST /settimeproperties/`
|
||||
- `GET /getoptionschema/`
|
||||
- `GET /getoptionproperties/`
|
||||
- `POST /setoptionproperties/`
|
||||
- `GET /getnodecoord/`
|
||||
- `GET /getnetworkgeometries/`
|
||||
- `GET /getmajornodecoords/`
|
||||
- `GET /getnetworkinextent/`
|
||||
- `GET /getnetworklinknodes/`
|
||||
- `GET /getmajorpipenodes/`
|
||||
- `GET /getvertexschema/`
|
||||
- `GET /getvertexproperties/`
|
||||
- `POST /setvertexproperties/`
|
||||
- `POST /addvertex/`
|
||||
- `POST /deletevertex/`
|
||||
- `GET /getallvertexlinks/`
|
||||
- `GET /getallvertices/`
|
||||
- `GET /getlabelschema/`
|
||||
- `GET /getlabelproperties/`
|
||||
- `POST /setlabelproperties/`
|
||||
- `POST /addlabel/`
|
||||
- `POST /deletelabel/`
|
||||
- `GET /getbackdropschema/`
|
||||
- `GET /getbackdropproperties/`
|
||||
- `POST /setbackdropproperties/`
|
||||
- `GET /getscadadeviceschema/`
|
||||
- `GET /getscadadevice/`
|
||||
- `POST /setscadadevice/`
|
||||
- `POST /addscadadevice/`
|
||||
- `POST /deletescadadevice/`
|
||||
- `POST /cleanscadadevice/`
|
||||
- `GET /getallscadadeviceids/`
|
||||
- `GET /getallscadadevices/`
|
||||
- `GET /getscadadevicedataschema/`
|
||||
- `GET /getscadadevicedata/`
|
||||
- `POST /setscadadevicedata/`
|
||||
- `POST /addscadadevicedata/`
|
||||
- `POST /deletescadadevicedata/`
|
||||
- `POST /cleanscadadevicedata/`
|
||||
- `GET /getscadaelementschema/`
|
||||
- `GET /getscadaelements/`
|
||||
- `GET /getscadaelement/`
|
||||
- `POST /setscadaelement/`
|
||||
- `POST /addscadaelement/`
|
||||
- `POST /deletescadaelement/`
|
||||
- `POST /cleanscadaelement/`
|
||||
- `GET /getregionschema/`
|
||||
- `GET /getregion/`
|
||||
- `POST /setregion/`
|
||||
- `POST /addregion/`
|
||||
- `POST /deleteregion/`
|
||||
- `GET /calculatedistrictmeteringareafornodes/`
|
||||
- `GET /calculatedistrictmeteringareaforregion/`
|
||||
- `GET /calculatedistrictmeteringareafornetwork/`
|
||||
- `GET /getdistrictmeteringareaschema/`
|
||||
- `GET /getdistrictmeteringarea/`
|
||||
- `POST /setdistrictmeteringarea/`
|
||||
- `POST /adddistrictmeteringarea/`
|
||||
- `POST /deletedistrictmeteringarea/`
|
||||
- `GET /getalldistrictmeteringareaids/`
|
||||
- `GET /getalldistrictmeteringareas/`
|
||||
- `POST /generatedistrictmeteringarea/`
|
||||
- `POST /generatesubdistrictmeteringarea/`
|
||||
- `GET /calculateservicearea/`
|
||||
- `GET /getserviceareaschema/`
|
||||
- `GET /getservicearea/`
|
||||
- `POST /setservicearea/`
|
||||
- `POST /addservicearea/`
|
||||
- `POST /deleteservicearea/`
|
||||
- `GET /getallserviceareas/`
|
||||
- `POST /generateservicearea/`
|
||||
- `GET /calculatevirtualdistrict/`
|
||||
- `GET /getvirtualdistrictschema/`
|
||||
- `GET /getvirtualdistrict/`
|
||||
- `POST /setvirtualdistrict/`
|
||||
- `POST /addvirtualdistrict/`
|
||||
- `POST /deletevirtualdistrict/`
|
||||
- `GET /getallvirtualdistrict/`
|
||||
- `POST /generatevirtualdistrict/`
|
||||
- `GET /calculatedemandtonodes/`
|
||||
- `GET /calculatedemandtoregion/`
|
||||
- `GET /calculatedemandtonetwork/`
|
||||
- `GET /getscadainfoschema/`
|
||||
- `GET /getscadainfo/`
|
||||
- `GET /getallscadainfo/`
|
||||
- `GET /getuserschema/`
|
||||
- `GET /getuser/`
|
||||
- `GET /getallusers/`
|
||||
- `GET /getschemeschema/`
|
||||
- `GET /getscheme/`
|
||||
- `GET /getallschemes/`
|
||||
- `GET /getpiperiskprobabilitynow/`
|
||||
- `GET /getpiperiskprobability/`
|
||||
- `GET /getpipesriskprobability/`
|
||||
- `GET /getnetworkpiperiskprobabilitynow/`
|
||||
- `GET /getpiperiskprobabilitygeometries/`
|
||||
- `GET /getallsensorplacements/`
|
||||
- `GET /getallburstlocateresults/`
|
||||
- `POST /uploadinp/`
|
||||
- `GET /downloadinp/`
|
||||
- `GET /convertv3tov2/`
|
||||
- `GET /getjson/`
|
||||
- `GET /getrealtimedata/`
|
||||
- `GET /getsimulationresult/`
|
||||
- `GET /querynodelatestrecordbyid/`
|
||||
- `GET /querylinklatestrecordbyid/`
|
||||
- `GET /queryscadalatestrecordbyid/`
|
||||
- `GET /queryallrecordsbytime/`
|
||||
- `GET /queryallrecordsbytimeproperty/`
|
||||
- `GET /queryallschemerecordsbytimeproperty/`
|
||||
- `GET /querysimulationrecordsbyidtime/`
|
||||
- `GET /queryschemesimulationrecordsbyidtime/`
|
||||
- `GET /queryallrecordsbydate/`
|
||||
- `GET /queryallrecordsbytimerange/`
|
||||
- `GET /queryallrecordsbydatewithtype/`
|
||||
- `GET /queryallrecordsbyidsdatetype/`
|
||||
- `GET /queryallrecordsbydateproperty/`
|
||||
- `GET /querynodecurvebyidpropertydaterange/`
|
||||
- `GET /querylinkcurvebyidpropertydaterange/`
|
||||
- `GET /queryscadadatabydeviceidandtime/`
|
||||
- `GET /queryscadadatabydeviceidandtimerange/`
|
||||
- `GET /queryfillingscadadatabydeviceidandtimerange/`
|
||||
- `GET /querycleaningscadadatabydeviceidandtimerange/`
|
||||
- `GET /querysimulationscadadatabydeviceidandtimerange/`
|
||||
- `GET /querycleanedscadadatabydeviceidandtimerange/`
|
||||
- `GET /queryscadadatabydeviceidanddate/`
|
||||
- `GET /queryallscadarecordsbydate/`
|
||||
- `GET /queryallschemeallrecords/`
|
||||
- `GET /queryschemeallrecordsproperty/`
|
||||
- `POST /clearrediskey/`
|
||||
- `POST /clearrediskeys/`
|
||||
- `POST /clearallredis/`
|
||||
- `GET /queryredis/`
|
||||
- `GET /queryinfluxdbbuckets/`
|
||||
- `GET /queryinfluxdbbucketmeasurements/`
|
||||
- `POST /download_history_data_manually/`
|
||||
- `POST /runsimulationmanuallybydate/`
|
||||
- `POST /burst_analysis/`
|
||||
- `GET /valve_close_analysis/`
|
||||
- `GET /flushing_analysis/`
|
||||
- `GET /contaminant_simulation/`
|
||||
- `GET /age_analysis/`
|
||||
- `POST /scheduling_analysis/`
|
||||
- `POST /pressure_regulation/`
|
||||
- `POST /project_management/`
|
||||
- `POST /network_project/`
|
||||
- `POST /daily_scheduling_analysis/`
|
||||
- `POST /network_update/`
|
||||
- `POST /pump_failure/`
|
||||
- `POST /pressure_sensor_placement_sensitivity/`
|
||||
- `POST /pressure_sensor_placement_kmeans/`
|
||||
- `POST /sensorplacementscheme/create`
|
||||
- `POST /scadadevicedatacleaning/`
|
||||
- `POST /test_dict/`
|
||||
@@ -1,26 +0,0 @@
|
||||
# Missing API Endpoints
|
||||
|
||||
- Legacy endpoints checked: 392
|
||||
- Current endpoints found: 401
|
||||
- Missing endpoints: 17
|
||||
|
||||
Note: Current endpoints are defined under app/api and are typically served with the /api/v1 prefix.
|
||||
|
||||
## Missing endpoints (legacy present, current missing)
|
||||
- `GET /age_analysis/`
|
||||
- `GET /contaminant_simulation/`
|
||||
- `GET /flushing_analysis/`
|
||||
- `GET /valve_close_analysis/`
|
||||
- `POST /burst_analysis/`
|
||||
- `POST /daily_scheduling_analysis/`
|
||||
- `POST /network_project/`
|
||||
- `POST /network_update/`
|
||||
- `POST /pressure_regulation/`
|
||||
- `POST /pressure_sensor_placement_kmeans/`
|
||||
- `POST /pressure_sensor_placement_sensitivity/`
|
||||
- `POST /project_management/`
|
||||
- `POST /pump_failure/`
|
||||
- `POST /runsimulationmanuallybydate/`
|
||||
- `POST /scadadevicedatacleaning/`
|
||||
- `POST /scheduling_analysis/`
|
||||
- `POST /sensorplacementscheme/create`
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
import sys
|
||||
from app.services.tjnetwork import open_project
|
||||
|
||||
def main():
|
||||
open_project('szh')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,5 +0,0 @@
|
||||
import redis
|
||||
|
||||
redis_client = redis.Redis(host="127.0.0.1", port=6379, db=0)
|
||||
matched_keys = redis_client.keys(f"**")
|
||||
redis_client.delete(*matched_keys)
|
||||
@@ -1,5 +0,0 @@
|
||||
C:
|
||||
cd "C:\pg-14.7\bin"
|
||||
pg_ctl -D ../data -l logfile stop
|
||||
pg_ctl -D ../data -l logfile start
|
||||
cd "c:\SourceCode\Server"
|
||||
@@ -1,15 +0,0 @@
|
||||
import sys
|
||||
from app.services.tjnetwork import close_project, open_project, restore
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("restore_project name")
|
||||
return
|
||||
|
||||
p = sys.argv[1]
|
||||
open_project(p)
|
||||
restore(p)
|
||||
close_project(p)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,11 +0,0 @@
|
||||
from app.services.tjnetwork import close_project, list_project, open_project, restore
|
||||
|
||||
def main():
|
||||
for p in list_project():
|
||||
print(f'restore {p}...')
|
||||
open_project(p)
|
||||
restore(p)
|
||||
close_project(p)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -1,8 +0,0 @@
|
||||
from app.services.tjnetwork import open_project
|
||||
from get_current_status import *
|
||||
|
||||
def run_simulation(cur_datetime:str=None)->str:
|
||||
|
||||
open_project('beibei_skeleton')
|
||||
|
||||
return
|
||||
@@ -1,9 +0,0 @@
|
||||
REM f:
|
||||
REM cd "f:\DEV\GitHub\TJWaterServer"
|
||||
|
||||
git pull
|
||||
|
||||
REM call startpg.bat
|
||||
cd C:\SourceCode\Server
|
||||
REM uvicorn main:app --host 0.0.0.0 --port 80 --reload
|
||||
uvicorn main:app --host 0.0.0.0 --port 80
|
||||
@@ -1,5 +0,0 @@
|
||||
C:
|
||||
cd "C:\pg-14.7\bin"
|
||||
REM pg_ctl -D ../data -l logfile stop
|
||||
pg_ctl -D ../data -l logfile start
|
||||
cd "c:\SourceCode\Server"
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user