123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 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)}")
|