from fastapi import APIRouter, Request, Depends, Query, HTTPException, status from common.security import valid_access_token from sqlalchemy.orm import Session from sqlalchemy.sql import func from common.auth_user import * from sqlalchemy import text from pydantic import BaseModel from common.BigDataCenterAPI import * from database import get_db from typing import List from utils import * from utils.risk import * import json import traceback router = APIRouter() @router.post('/temperature') async def mine(request: Request,db: Session = Depends(get_db)): try: body = await request.json() args = body.get("args") print(args) result = [] if args == "6h_precipitation": result.append( {"create_time":"", "pic_url":"https://soc.gd121.cn/sk6hrain/2024/10/MSP1_AGD_MANOBS_PRCPV_L88_AGD_202410071400_00600-00000.PNG" } ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk6hrain/2024/10/MSP1_AGD_MANOBS_PRCPV_L88_AGD_202410071500_00600-00000.PNG" } ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk6hrain/2024/10/MSP1_AGD_MANOBS_PRCPV_L88_AGD_202410071600_00600-00000.PNG" } ) elif args == "24h_precipitation": result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk24hrain/2024/10/MSP1_AGD_MANOBS_PRCPV_L88_AGD_202410071400_02400-00000.PNG"} ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk24hrain/2024/10/MSP1_AGD_MANOBS_PRCPV_L88_AGD_202410071500_02400-00000.PNG"} ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk24hrain/2024/10/MSP1_AGD_MANOBS_PRCPV_L88_AGD_202410071600_02400-00000.PNG"} ) elif args == "hourly_temperature": result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/skt/2024/10/MSP1_AGD_MANOBS_T_L88_AGD_202410071300_00000-00000.PNG"} ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/skt/2024/10/MSP1_AGD_MANOBS_T_L88_AGD_202410071400_00000-00000.PNG"} ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/skt/2024/10/MSP1_AGD_MANOBS_T_L88_AGD_202410071500_00000-00000.PNG"} ) elif args == "24h_max_temperature": result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk24htmax/2024/10/MSP1_AGD_MANOBS_TMA_L88_AGD_202410071300_02400-00000.PNG" } ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk24htmax/2024/10/MSP1_AGD_MANOBS_TMA_L88_AGD_202410071400_02400-00000.PNG" } ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk24htmax/2024/10/MSP1_AGD_MANOBS_TMA_L88_AGD_202410071500_02400-00000.PNG" } ) elif args == "24h_min_temperature": result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk24htmin/2024/10/MSP1_AGD_MANOBS_TMI_L88_AGD_202410071300_02400-00000.PNG"} ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk24htmin/2024/10/MSP1_AGD_MANOBS_TMI_L88_AGD_202410071400_02400-00000.PNG"} ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/sk24htmin/2024/10/MSP1_AGD_MANOBS_TMI_L88_AGD_202410071500_02400-00000.PNG"} ) elif args == "24h_variable_temperature": result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/skt24hdt/2024/10/MSP1_AGD_MANOBS_TD_L88_AGD_202410071300_02400-00000.PNG"} ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/skt24hdt/2024/10/MSP1_AGD_MANOBS_TD_L88_AGD_202410071400_02400-00000.PNG"} ) result.append( {"create_time": "", "pic_url": "https://soc.gd121.cn/skt24hdt/2024/10/MSP1_AGD_MANOBS_TD_L88_AGD_202410071500_02400-00000.PNG"} ) print(result) return { "code": 200, "msg": "成功", "data": {"max_level":result} } except Exception as e: db.rollback() traceback.print_exc() raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")