__init__.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. from fastapi import APIRouter, Request, Depends, Query, HTTPException, status
  2. from common.security import valid_access_token
  3. from sqlalchemy.orm import Session
  4. from sqlalchemy.sql import func
  5. from common.auth_user import *
  6. from sqlalchemy import text
  7. from pydantic import BaseModel
  8. from common.BigDataCenterAPI import *
  9. from database import get_db
  10. from typing import List
  11. from utils import *
  12. from utils.risk import *
  13. import json
  14. import traceback
  15. router = APIRouter()
  16. @router.post('/temperature')
  17. async def mine(request: Request,db: Session = Depends(get_db)):
  18. try:
  19. body = await request.json()
  20. args = body.get("args")
  21. print(args)
  22. result = []
  23. if args == "6h_precipitation":
  24. result.append(
  25. {"create_time":"",
  26. "pic_url":"https://soc.gd121.cn/sk6hrain/2024/10/MSP1_AGD_MANOBS_PRCPV_L88_AGD_202410070100_00600-00000.PNG"}
  27. )
  28. elif args == "24h_precipitation":
  29. result.append(
  30. {"create_time": "",
  31. "pic_url": "https://soc.gd121.cn/sk24hrain/2024/10/MSP1_AGD_MANOBS_PRCPV_L88_AGD_202410070100_02400-00000.PNG"}
  32. )
  33. elif args == "hourly_temperature":
  34. result.append(
  35. {"create_time": "",
  36. "pic_url": "https://soc.gd121.cn/skt/2024/10/MSP1_AGD_MANOBS_T_L88_AGD_202410062300_00000-00000.PNG"}
  37. )
  38. elif args == "24h_max_temperature":
  39. result.append(
  40. {"create_time": "",
  41. "pic_url": "https://soc.gd121.cn/sk24htmax/2024/10/MSP1_AGD_MANOBS_TMA_L88_AGD_202410062300_02400-00000.PNG"}
  42. )
  43. elif args == "24h_min_temperature":
  44. result.append(
  45. {"create_time": "",
  46. "pic_url": "https://soc.gd121.cn/sk24htmin/2024/10/MSP1_AGD_MANOBS_TMI_L88_AGD_202410070100_02400-00000.PNG"}
  47. )
  48. elif args == "24h_variable_temperature":
  49. result.append(
  50. {"create_time": "",
  51. "pic_url": "https://soc.gd121.cn/sk24htmin/2024/10/MSP1_AGD_MANOBS_TMI_L88_AGD_202410070100_02400-00000.PNG"}
  52. )
  53. print(result)
  54. return {
  55. "code": 200,
  56. "msg": "成功",
  57. "data":
  58. {"max_level":result}
  59. }
  60. except Exception as e:
  61. db.rollback()
  62. traceback.print_exc()
  63. raise HTTPException(status_code=500, detail=f"Internal server error: {str(e)}")