|
@@ -53,4 +53,44 @@ async def get_pattern_info(
|
|
|
|
|
|
return {
|
|
|
"code": 200, "msg": "获取成功", "data":{"areaName":area_name,"updateTime":update_time_max,"rainfallHistory":rainfall_history,"rainfallFuture":rainfall_future,"cumulativeRainfall":cumulative_rainfall}
|
|
|
+ }
|
|
|
+
|
|
|
+@router.get("/gdyl/info/{code}")
|
|
|
+async def get_pattern_info(
|
|
|
+ code: str,
|
|
|
+ db: Session = Depends(get_db)
|
|
|
+):
|
|
|
+ rainfulldata = get_stcd_data(code,24)
|
|
|
+ update_time_list = []
|
|
|
+ rainfall_history = []
|
|
|
+ rainfall_future = []
|
|
|
+ # cumulative_rainfall = []
|
|
|
+ num = 24
|
|
|
+ for i in rainfulldata[::-1]:
|
|
|
+ area_name = i['F3070220000034_000018002']
|
|
|
+ update_time_list.append( datetime.strptime(i['F3070220000034_000018006'], "%Y-%m-%d %H:%M:%S"))
|
|
|
+ create_time = datetime.strptime(i['F3070220000034_000018004'], "%Y-%m-%d %H:%M:%S")
|
|
|
+ # hour = create_time.strftime("%H")
|
|
|
+ value = i['F3070220000034_000018005']
|
|
|
+ if num in [24,12,6,3,1,0]:
|
|
|
+ rainfall_history.append({"hour":-num,"value":value})
|
|
|
+ num-=1
|
|
|
+ update_time_max = max(update_time_list).strftime("%Y-%m-%d %H:%M:%S")
|
|
|
+ # for t in range(72):
|
|
|
+ # future_time = create_time+ timedelta(hours=t)
|
|
|
+ # hour = future_time.strftime("%H")
|
|
|
+ # value = 0
|
|
|
+ rainfall_future.append({"hour":1,"value":0})
|
|
|
+ rainfall_future.append({"hour":3,"value":0})
|
|
|
+ rainfall_future.append({"hour":24,"value":1})
|
|
|
+ rainfall_future.append({"hour":48,"value":4})
|
|
|
+ rainfall_future.append({"hour":72,"value":2})
|
|
|
+
|
|
|
+ rainfall = 0
|
|
|
+ # for cumulative in rainfall_history+rainfall_future:
|
|
|
+ # rainfall += cumulative['value']
|
|
|
+ # cumulative_rainfall.append({"hour":cumulative['hour'],"value":rainfall})
|
|
|
+
|
|
|
+ return {
|
|
|
+ "code": 200, "msg": "获取成功", "data":{"areaName":area_name,"updateTime":update_time_max,"rainfallHistory":rainfall_history,"rainfallFuture":rainfall_future}#,"cumulativeRainfall":cumulative_rainfall}
|
|
|
}
|