diff --git a/code/java/天气灾害预警/.idea/.gitignore b/code/java/天气灾害预警/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/code/java/天气灾害预警/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/code/java/天气灾害预警/.idea/compiler.xml b/code/java/天气灾害预警/.idea/compiler.xml
new file mode 100644
index 0000000..7ffa0fe
--- /dev/null
+++ b/code/java/天气灾害预警/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code/java/天气灾害预警/.idea/encodings.xml b/code/java/天气灾害预警/.idea/encodings.xml
new file mode 100644
index 0000000..78bf31c
--- /dev/null
+++ b/code/java/天气灾害预警/.idea/encodings.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code/java/天气灾害预警/.idea/jarRepositories.xml b/code/java/天气灾害预警/.idea/jarRepositories.xml
new file mode 100644
index 0000000..c7ea920
--- /dev/null
+++ b/code/java/天气灾害预警/.idea/jarRepositories.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code/java/天气灾害预警/.idea/misc.xml b/code/java/天气灾害预警/.idea/misc.xml
new file mode 100644
index 0000000..132404b
--- /dev/null
+++ b/code/java/天气灾害预警/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code/java/天气灾害预警/.idea/runConfigurations/compile.xml b/code/java/天气灾害预警/.idea/runConfigurations/compile.xml
new file mode 100644
index 0000000..780c17d
--- /dev/null
+++ b/code/java/天气灾害预警/.idea/runConfigurations/compile.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code/java/天气灾害预警/.idea/uiDesigner.xml b/code/java/天气灾害预警/.idea/uiDesigner.xml
new file mode 100644
index 0000000..e96534f
--- /dev/null
+++ b/code/java/天气灾害预警/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/code/java/天气灾害预警/.idea/vcs.xml b/code/java/天气灾害预警/.idea/vcs.xml
new file mode 100644
index 0000000..c2365ab
--- /dev/null
+++ b/code/java/天气灾害预警/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code/java/天气灾害预警/.idea/天气灾害预警.iml b/code/java/天气灾害预警/.idea/天气灾害预警.iml
new file mode 100644
index 0000000..13a38a8
--- /dev/null
+++ b/code/java/天气灾害预警/.idea/天气灾害预警.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code/java/天气灾害预警/pom.xml b/code/java/天气灾害预警/pom.xml
index aafea85..6e0a068 100644
--- a/code/java/天气灾害预警/pom.xml
+++ b/code/java/天气灾害预警/pom.xml
@@ -1,20 +1,55 @@
-
+
4.0.0
-
com.cpic.xim
disaster_warning
1.0-SNAPSHOT
-
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.2
+
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.3
+
+
+ commons-collections
+ commons-collections
+ 3.2.1
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+ commons-logging
+ commons-logging
+ 1.1.1
+
+
+ net.sf.ezmorph
+ ezmorph
+ 1.0.6
+
+
+ net.sf.json-lib
+ json-lib
+ 2.4
+ jdk15
+
+
- 17
- 17
+ 1.8
+ 1.8
-
compile
-
dev
@@ -39,6 +74,4 @@
-
-
\ No newline at end of file
diff --git a/code/java/天气灾害预警/src/main/java/AppMain.java b/code/java/天气灾害预警/src/main/java/AppMain.java
new file mode 100644
index 0000000..4cb78ef
--- /dev/null
+++ b/code/java/天气灾害预警/src/main/java/AppMain.java
@@ -0,0 +1,13 @@
+import com.cpic.xim.disaster_warning.WeatherDisasterWarningGrabber;
+
+public class AppMain
+{
+ public static void main( String[] args )
+ {
+ String cityCode = "101091103";
+
+ WeatherDisasterWarningGrabber.getWeatherDisasterWarningJSON( cityCode );
+
+ System.out.println( "1111" );
+ }
+}
\ No newline at end of file
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
new file mode 100644
index 0000000..2930890
--- /dev/null
+++ b/code/java/天气灾害预警/src/main/java/com/cpic/xim/disaster_warning/WeatherDisasterWarningGrabber.java
@@ -0,0 +1,104 @@
+package com.cpic.xim.disaster_warning;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+
+import java.net.MalformedURLException;
+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";
+
+ public static String getWeatherDisasterWarningJSON( String cityCode )
+ {
+ //拼接url字符串
+ String json = "";
+ String requestURL = QUERY_URL + "key=" + USER_KEY + "&location=" + cityCode;
+
+ //requestURL = "http://127.0.0.1:8000/ajax";
+
+ //链接用
+ HttpURLConnection connection = null;
+ URL url = null;
+ InputStream inputStream = null;
+ BufferedReader bufferedReader = null;
+ StringBuilder buffer = new StringBuilder();
+
+ try
+ {
+ url = new URL( requestURL );
+ connection = (HttpURLConnection) url.openConnection();
+
+ connection.setRequestMethod( "GET" );
+ connection.setConnectTimeout( 15000 );
+ connection.setReadTimeout( 60000 );
+ connection.connect();
+
+ int reponseCode = connection.getResponseCode();
+
+ //如果responseCode为200,说明访问成功!
+ if ( connection.getResponseCode() == 200 )
+ {
+ inputStream = new GZIPInputStream( connection.getInputStream() );
+ bufferedReader = new BufferedReader( new InputStreamReader( inputStream, "UTF-8" ) );
+
+ //读出数据
+ String temp = bufferedReader.readLine();
+
+ while ( temp != null )
+ {
+ buffer.append( temp );
+
+ temp = bufferedReader.readLine();
+ }
+
+ json = buffer.toString();
+ }
+ }
+ catch ( MalformedURLException error )
+ {
+ error.printStackTrace();
+ }
+ catch ( IOException error )
+ {
+ System.out.println( "读取失败!" );
+ }
+ finally
+ {
+ if ( bufferedReader != null )
+ {
+ try
+ {
+ bufferedReader.close();
+ }
+ catch ( IOException error )
+ {
+ error.printStackTrace();
+ }
+ }
+
+ if ( inputStream != null )
+ {
+ try
+ {
+ inputStream.close();
+ }
+ catch ( IOException error )
+ {
+ error.printStackTrace();
+ }
+ }
+
+ connection.disconnect();
+ }
+
+ return json;
+ }
+}