|
@@ -451,6 +451,62 @@ def get_water_management_projects():
|
|
# 关闭数据库连接
|
|
# 关闭数据库连接
|
|
conn.close()
|
|
conn.close()
|
|
|
|
|
|
|
|
+@app.route('/get-hot-point-data', methods=['GET'])
|
|
|
|
+def get_hot_point_data():
|
|
|
|
+ # 建立MySQL连接
|
|
|
|
+ conn = mysql.connector.connect(
|
|
|
|
+ host="localhost",
|
|
|
|
+ user="root",
|
|
|
|
+ password="HelloWorld123",
|
|
|
|
+ database="water"
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+ # 设置MySQL连接的字符集
|
|
|
|
+ conn.set_charset_collation('utf8')
|
|
|
|
+
|
|
|
|
+ try:
|
|
|
|
+ cursor = conn.cursor()
|
|
|
|
+
|
|
|
|
+ # 查询Move_Plans表中的所有数据
|
|
|
|
+ query = """
|
|
|
|
+ SELECT * FROM WaterHotPoints
|
|
|
|
+ """
|
|
|
|
+ cursor.execute(query)
|
|
|
|
+ hotPoints = cursor.fetchall()
|
|
|
|
+
|
|
|
|
+ # 将查询结果转换为字典列表
|
|
|
|
+ hps_json = []
|
|
|
|
+ for hp in hotPoints:
|
|
|
|
+ hp_json = {
|
|
|
|
+ 'type': hp[1],
|
|
|
|
+ 'longitude': hp[2],
|
|
|
|
+ 'latitude': hp[3],
|
|
|
|
+ 'name': hp[4],
|
|
|
|
+ 'name_pri': hp[5]
|
|
|
|
+ }
|
|
|
|
+ hps_json.append(hp_json)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ # 返回JSON响应,包含msg, code和data
|
|
|
|
+ response = {
|
|
|
|
+ "msg": None,
|
|
|
|
+ "code": 200,
|
|
|
|
+ "data": hps_json
|
|
|
|
+ }
|
|
|
|
+ return jsonify(response), 200
|
|
|
|
+ except mysql.connector.Error as e:
|
|
|
|
+ # 捕获MySQL错误并返回错误信息和状态码 500
|
|
|
|
+ response = {
|
|
|
|
+ "msg": str(e),
|
|
|
|
+ "code": 500,
|
|
|
|
+ "data": []
|
|
|
|
+ }
|
|
|
|
+ return jsonify(response), 500
|
|
|
|
+ finally:
|
|
|
|
+ # 关闭数据库连接
|
|
|
|
+ conn.close()
|
|
|
|
+
|
|
@app.route('/get-project-milestones', methods=['GET'])
|
|
@app.route('/get-project-milestones', methods=['GET'])
|
|
def get_project_milestones():
|
|
def get_project_milestones():
|
|
# 建立MySQL连接
|
|
# 建立MySQL连接
|
|
@@ -622,6 +678,8 @@ def get_rkzy_base_data():
|
|
# 关闭数据库连接
|
|
# 关闭数据库连接
|
|
conn.close()
|
|
conn.close()
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@app.route('/get-swyj-base-data', methods=['GET'])
|
|
@app.route('/get-swyj-base-data', methods=['GET'])
|
|
def get_swyj_base_data():
|
|
def get_swyj_base_data():
|
|
# 建立MySQL连接
|
|
# 建立MySQL连接
|
|
@@ -923,6 +981,24 @@ def get_sw_height_data():
|
|
swDataDic[izc["STCD"]] = index
|
|
swDataDic[izc["STCD"]] = index
|
|
index += 1
|
|
index += 1
|
|
|
|
|
|
|
|
+ # 连接数据库
|
|
|
|
+ conn = pymysql.connect(host='localhost', user='root', password='HelloWorld123', db='water', charset='utf8mb4')
|
|
|
|
+ # 连接数据库并开始操作
|
|
|
|
+ with conn.cursor() as cursor:
|
|
|
|
+ for swhData in swHeightData:
|
|
|
|
+ # 检查数据库中是否已有该记录
|
|
|
|
+ cursor.execute("SELECT id FROM WaterHotPoints WHERE name=%s",
|
|
|
|
+ (swhData["STNM"]))
|
|
|
|
+ result = cursor.fetchone()
|
|
|
|
+
|
|
|
|
+ if result:
|
|
|
|
+ pass
|
|
|
|
+ else:
|
|
|
|
+ # 如果记录不存在,执行插入操作
|
|
|
|
+ cursor.execute("INSERT INTO WaterHotPoints (type, longitude, latitude, name, name_pri) VALUES (%s, %s, %s, %s, %s)",
|
|
|
|
+ (4, swhData['LGTD'], swhData['LTTD'], swhData['STNM'], ""))
|
|
|
|
+ conn.commit()
|
|
|
|
+
|
|
# 准备第二个 API 请求的数据
|
|
# 准备第二个 API 请求的数据
|
|
etm, stm = GetStartEndTime(0)
|
|
etm, stm = GetStartEndTime(0)
|
|
requestData = {
|
|
requestData = {
|