cross_doctor/app/monitor_views.py

85 lines
2.4 KiB
Python

# -*- coding: utf-8 -*-
# @Author: Owl
# @Date: 2025/11/18 9:50
# @Description: 巡检相关接口入口类
import gzip
from flask import request, jsonify, Response
from app.cross_monitor_worker import *
from app.cross_eva_views import app
@app.route('/api/monitor_usable_dates', methods=['GET'])
def get_monitor_usable_dates():
return query_monitor_task_usable_date_list(dict(request.args))
@app.route('/api/query_monitor_data', methods=['POST'])
def query_monitor_data_api():
res = query_monitor_data(request.json)
# 手动gzip压缩
compressed_data = gzip.compress(res.encode('utf-8'), compresslevel=6)
return Response(
compressed_data,
headers={
'Content-Encoding': 'gzip',
'Content-Type': 'application/json',
'Content-Length': str(len(compressed_data))
}
)
@app.route('/api/query_monitor_data_trend', methods=['POST'])
def query_monitor_data_trend_api():
res = query_monitor_data_trend(request.json)
# 手动gzip压缩
compressed_data = gzip.compress(res.encode('utf-8'), compresslevel=6)
return Response(
compressed_data,
headers={
'Content-Encoding': 'gzip',
'Content-Type': 'application/json',
'Content-Length': str(len(compressed_data))
}
)
@app.route('/api/query_cross_tp_data_trend', methods=['POST'])
def query_cross_tp_data_trend_api():
res = query_cross_tp_data_trend(request.json)
# 手动gzip压缩
compressed_data = gzip.compress(res.encode('utf-8'), compresslevel=6)
return Response(
compressed_data,
headers={
'Content-Encoding': 'gzip',
'Content-Type': 'application/json',
'Content-Length': str(len(compressed_data))
}
)
@app.route('/api/query_monitor_problems', methods=['POST'])
def query_monitor_problems_api():
res = query_monitor_problems(request.json)
# 手动gzip压缩
compressed_data = gzip.compress(res.encode('utf-8'), compresslevel=6)
return Response(
compressed_data,
headers={
'Content-Encoding': 'gzip',
'Content-Type': 'application/json',
'Content-Length': str(len(compressed_data))
}
)
@app.route('/api/update_cross_problem_shield_state', methods=['POST'])
def update_cross_shield_state_api():
return update_cross_problem_shield_state(request.json)