题目:在BlossimView系统中实时显示全国各省会的天气

发布于:2023-01-04 ⋅ 阅读:(336) ⋅ 点赞:(0)

1、天气数据来源

通过访问下面网址获取数据

http://t.weather.sojson.com/api/weather/city/101040100

 该网址返回数据格式如下:

{
    "message": "success感谢又拍云(upyun.com)提供CDN赞助",
    "status": 200,
    "date": "20220829",
    "time": "2022-08-29 12:57:12",
    "cityInfo": {
        "city": "重庆市",
        "citykey": "101040100",
        "parent": "重庆",
        "updateTime": "11:01"
    },
    "data": {
        "shidu": "56%",
        "pm25": 5.0,
        "pm10": 16.0,
        "quality": "优",
        "wendu": "30",
        "ganmao": "各类人群可自由活动",
        "forecast": [
            {
                "date": "29",
                "high": "高温 36℃",
                "low": "低温 27℃",
                "ymd": "2022-08-29",
                "week": "星期一",
                "sunrise": "06:29",
                "sunset": "19:19",
                "aqi": 17,
                "fx": "西风",
                "fl": "2级",
                "type": "小雨",
                "notice": "雨虽小,注意保暖别感冒"
            },
            {
                "date": "30",
                "high": "高温 28℃",
                "low": "低温 21℃",
                "ymd": "2022-08-30",
                "week": "星期二",
                "sunrise": "06:30",
                "sunset": "19:18",
                "aqi": 17,
                "fx": "西南风",
                "fl": "2级",
                "type": "阴",
                "notice": "不要被阴云遮挡住好心情"
            },
            {
                "date": "31",
                "high": "高温 28℃",
                "low": "低温 20℃",
                "ymd": "2022-08-31",
                "week": "星期三",
                "sunrise": "06:31",
                "sunset": "19:17",
                "aqi": 16,
                "fx": "西风",
                "fl": "1级",
                "type": "小雨",
                "notice": "雨虽小,注意保暖别感冒"
            },
            {
                "date": "01",
                "high": "高温 28℃",
                "low": "低温 21℃",
                "ymd": "2022-09-01",
                "week": "星期四",
                "sunrise": "06:31",
                "sunset": "19:16",
                "aqi": 22,
                "fx": "北风",
                "fl": "1级",
                "type": "阴",
                "notice": "不要被阴云遮挡住好心情"
            },
            {
                "date": "02",
                "high": "高温 26℃",
                "low": "低温 20℃",
                "ymd": "2022-09-02",
                "week": "星期五",
                "sunrise": "06:32",
                "sunset": "19:15",
                "aqi": 25,
                "fx": "东北风",
                "fl": "1级",
                "type": "小雨",
                "notice": "雨虽小,注意保暖别感冒"
            },
            {
                "date": "03",
                "high": "高温 25℃",
                "low": "低温 20℃",
                "ymd": "2022-09-03",
                "week": "星期六",
                "sunrise": "06:32",
                "sunset": "19:14",
                "aqi": 20,
                "fx": "东北风",
                "fl": "1级",
                "type": "中雨",
                "notice": "记得随身携带雨伞哦"
            },
            {
                "date": "04",
                "high": "高温 28℃",
                "low": "低温 20℃",
                "ymd": "2022-09-04",
                "week": "星期日",
                "sunrise": "06:33",
                "sunset": "19:12",
                "aqi": 21,
                "fx": "西北风",
                "fl": "1级",
                "type": "多云",
                "notice": "阴晴之间,谨防紫外线侵扰"
            },
            {
                "date": "05",
                "high": "高温 31℃",
                "low": "低温 21℃",
                "ymd": "2022-09-05",
                "week": "星期一",
                "sunrise": "06:33",
                "sunset": "19:11",
                "aqi": 26,
                "fx": "东南风",
                "fl": "1级",
                "type": "多云",
                "notice": "阴晴之间,谨防紫外线侵扰"
            },
            {
                "date": "06",
                "high": "高温 34℃",
                "low": "低温 25℃",
                "ymd": "2022-09-06",
                "week": "星期二",
                "sunrise": "06:34",
                "sunset": "19:10",
                "aqi": 27,
                "fx": "南风",
                "fl": "1级",
                "type": "晴",
                "notice": "愿你拥有比阳光明媚的心情"
            },
            {
                "date": "07",
                "high": "高温 34℃",
                "low": "低温 25℃",
                "ymd": "2022-09-07",
                "week": "星期三",
                "sunrise": "06:34",
                "sunset": "19:09",
                "aqi": 27,
                "fx": "东南风",
                "fl": "1级",
                "type": "小雨",
                "notice": "雨虽小,注意保暖别感冒"
            },
            {
                "date": "08",
                "high": "高温 37℃",
                "low": "低温 27℃",
                "ymd": "2022-09-08",
                "week": "星期四",
                "sunrise": "06:35",
                "sunset": "19:08",
                "aqi": 29,
                "fx": "东风",
                "fl": "1级",
                "type": "晴",
                "notice": "愿你拥有比阳光明媚的心情"
            },
            {
                "date": "09",
                "high": "高温 37℃",
                "low": "低温 26℃",
                "ymd": "2022-09-09",
                "week": "星期五",
                "sunrise": "06:35",
                "sunset": "19:06",
                "aqi": 26,
                "fx": "东南风",
                "fl": "2级",
                "type": "多云",
                "notice": "阴晴之间,谨防紫外线侵扰"
            },
            {
                "date": "10",
                "high": "高温 30℃",
                "low": "低温 23℃",
                "ymd": "2022-09-10",
                "week": "星期六",
                "sunrise": "06:36",
                "sunset": "19:05",
                "aqi": 35,
                "fx": "东北风",
                "fl": "2级",
                "type": "阴",
                "notice": "不要被阴云遮挡住好心情"
            },
            {
                "date": "11",
                "high": "高温 28℃",
                "low": "低温 23℃",
                "ymd": "2022-09-11",
                "week": "星期日",
                "sunrise": "06:36",
                "sunset": "19:04",
                "aqi": 13,
                "fx": "东北风",
                "fl": "2级",
                "type": "小雨",
                "notice": "雨虽小,注意保暖别感冒"
            },
            {
                "date": "12",
                "high": "高温 28℃",
                "low": "低温 23℃",
                "ymd": "2022-09-12",
                "week": "星期一",
                "sunrise": "06:37",
                "sunset": "19:03",
                "aqi": 14,
                "fx": "东风",
                "fl": "1级",
                "type": "中雨",
                "notice": "记得随身携带雨伞哦"
            }
        ],
        "yesterday": {
            "date": "28",
            "high": "高温 40℃",
            "low": "低温 29℃",
            "ymd": "2022-08-28",
            "week": "星期日",
            "sunrise": "06:29",
            "sunset": "19:21",
            "aqi": 24,
            "fx": "东南风",
            "fl": "3级",
            "type": "阴",
            "notice": "不要被阴云遮挡住好心情"
        }
    }
}

 根据上面JSON格式生成数据类

 public class Cityinfo
    {
        public string city { get; set; }
        public string citykey { get; set; }
        public string parent { get; set; }
        public string updateTime { get; set; }
    }
 public class Data
    {
        public string shidu { get; set; }
        public float pm25 { get; set; }
        public float pm10 { get; set; }
        public string quality { get; set; }
        public string wendu { get; set; }
        public string ganmao { get; set; }
        public Forecast[] forecast { get; set; }
        public Yesterday yesterday { get; set; }
    }
 public class Forecast
    {
        public string date { get; set; }
        public string high { get; set; }
        public string low { get; set; }
        public string ymd { get; set; }
        public string week { get; set; }
        public string sunrise { get; set; }
        public string sunset { get; set; }
        public int aqi { get; set; }
        public string fx { get; set; }
        public string fl { get; set; }
        public string type { get; set; }
        public string notice { get; set; }
    }
 public class Yesterday
    {
        public string date { get; set; }
        public string high { get; set; }
        public string low { get; set; }
        public string ymd { get; set; }
        public string week { get; set; }
        public string sunrise { get; set; }
        public string sunset { get; set; }
        public int aqi { get; set; }
        public string fx { get; set; }
        public string fl { get; set; }
        public string type { get; set; }
        public string notice { get; set; }
    }

 

  public class RootData
    {
        public string message { get; set; }
        public int status { get; set; }
        public string date { get; set; }
        public string time { get; set; }
        public Cityinfo cityInfo { get; set; }
        public Data data { get; set; }
    }

、数据库存储要求

  1.  省会城市数据表
  2. 各城市天气数据表
  3. 各城市天气报警表

3、与BlossimView 数据交互要求

  1. 各城市天气数据可在BlossimView画面展示
  2. 天气温度报警值上限和下限可在BlossimView设置
  3. 各城市数据更新间隔可在BlossimView设置
  4. 城市天气温度历史曲线可在BlossimView画面展示

4、提供一个获取天气数据的WebService接口

  • 可提供输入城市名获取最近一个月的天气数据(不仅是温度)
  • 可按时间段提供指定一个或者多个城市的天气数据

网站公告

今日签到

点亮在社区的每一天
去签到