From cea1ff78f71b89061df7a822ebf75de82cf20b4c Mon Sep 17 00:00:00 2001 From: Kane Wang Date: Wed, 16 Mar 2022 17:51:25 +0800 Subject: [PATCH] ... --- code/java/天气灾害预警/pom.xml | 16 ++ .../QWeatherDisasterWarning.java | 11 + .../QWeatherDisasterWarningItem.java | 207 ++++++++++++++++++ .../WeatherDisasterWarningGrabber.java | 3 +- 4 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/QWeatherDisasterWarning.java create mode 100644 code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/QWeatherDisasterWarningItem.java diff --git a/code/java/天气灾害预警/pom.xml b/code/java/天气灾害预警/pom.xml index 6e0a068..fbbc87e 100644 --- a/code/java/天气灾害预警/pom.xml +++ b/code/java/天气灾害预警/pom.xml @@ -42,6 +42,22 @@ 2.4 jdk15 + + + com.fasterxml.jackson.core + jackson-core + 2.9.8 + + + com.fasterxml.jackson.core + jackson-databind + 2.9.8 + + + com.fasterxml.jackson.core + jackson-annotations + 2.9.8 + 1.8 diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/QWeatherDisasterWarning.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/QWeatherDisasterWarning.java new file mode 100644 index 0000000..c83ec94 --- /dev/null +++ b/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/QWeatherDisasterWarning.java @@ -0,0 +1,11 @@ +package com.cpic.xim.disaster_warning; + +import java.util.Vector; + +public class QWeatherDisasterWarning +{ + private String code; + private String updateTime; + private String flLink; + private Vector warningItems; +} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/QWeatherDisasterWarningItem.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/QWeatherDisasterWarningItem.java new file mode 100644 index 0000000..203ddba --- /dev/null +++ b/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/QWeatherDisasterWarningItem.java @@ -0,0 +1,207 @@ +package com.cpic.xim.disaster_warning; + +import java.util.Objects; + +public class QWeatherDisasterWarningItem +{ + public QWeatherDisasterWarningItem( String id, + String sender, + String pubTime, + String title, + String status, + String level, + String type, + String typeName, + String text, + String related, + String urgency, String centainy ) + { + this.id = id; + this.sender = sender; + this.pubTime = pubTime; + this.title = title; + this.status = status; + this.level = level; + this.type = type; + this.typeName = typeName; + this.text = text; + this.related = related; + this.urgency = urgency; + this.centainy = centainy; + } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( o == null || getClass() != o.getClass() ) + { + return false; + } + QWeatherDisasterWarningItem that = (QWeatherDisasterWarningItem) o; + return id.equals( that.id ) && Objects.equals( sender, that.sender ) && Objects.equals( pubTime, + that.pubTime ) && Objects.equals( + title, + that.title ) && Objects.equals( status, that.status ) && Objects.equals( level, + that.level ) && Objects.equals( + type, + that.type ) && Objects.equals( typeName, that.typeName ) && Objects.equals( text, + that.text ) && Objects.equals( + related, + that.related ) && Objects.equals( urgency, that.urgency ) && Objects.equals( centainy, + that.centainy ); + } + + @Override + public int hashCode() + { + return Objects.hash( id, + sender, + pubTime, + title, + status, + level, + type, + typeName, + text, + related, + urgency, + centainy ); + } + + public String getId() + { + return id; + } + + public void setId( String id ) + { + this.id = id; + } + + public String getSender() + { + return sender; + } + + public void setSender( String sender ) + { + this.sender = sender; + } + + public String getPubTime() + { + return pubTime; + } + + public void setPubTime( String pubTime ) + { + this.pubTime = pubTime; + } + + public String getTitle() + { + return title; + } + + public void setTitle( String title ) + { + this.title = title; + } + + public String getStatus() + { + return status; + } + + public void setStatus( String status ) + { + this.status = status; + } + + public String getLevel() + { + return level; + } + + public void setLevel( String level ) + { + this.level = level; + } + + public String getType() + { + return type; + } + + public void setType( String type ) + { + this.type = type; + } + + public String getTypeName() + { + return typeName; + } + + public void setTypeName( String typeName ) + { + this.typeName = typeName; + } + + public String getText() + { + return text; + } + + public void setText( String text ) + { + this.text = text; + } + + public String getRelated() + { + return related; + } + + public void setRelated( String related ) + { + this.related = related; + } + + public String getUrgency() + { + return urgency; + } + + public void setUrgency( String urgency ) + { + this.urgency = urgency; + } + + public String getCentainy() + { + return centainy; + } + + public void setCentainy( String centainy ) + { + this.centainy = centainy; + } + + private String id; + private String sender; + private String pubTime; + private String title; + private String status; + private String level; + private String type; + private String typeName; + private String text; + private String related; + private String urgency; + private String centainy; +} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/WeatherDisasterWarningGrabber.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/WeatherDisasterWarningGrabber.java index 9f2d925..bc42e7b 100644 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/WeatherDisasterWarningGrabber.java +++ b/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/WeatherDisasterWarningGrabber.java @@ -10,11 +10,11 @@ import java.net.URL; import java.net.HttpURLConnection; import java.util.zip.GZIPInputStream; - public class WeatherDisasterWarningGrabber { private static String QUERY_URL = "https://devapi.qweather.com/v7/warning/now?"; private static String USER_KEY = "fe9fa8eeeb6f4301a92541eed565dd15"; + private static QWeatherDisasterWarningItem item = null; /*** * 从和风天气获取天气警报json字符串 @@ -105,4 +105,5 @@ public class WeatherDisasterWarningGrabber return json; } + }