diff --git a/code/java/.idea/.gitignore b/code/java/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/code/java/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# 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 deleted file mode 100644 index 15902b2..0000000 --- a/code/java/.idea/compiler.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/java/.idea/disaster_warning.iml b/code/java/.idea/disaster_warning.iml deleted file mode 100644 index 6b8502e..0000000 --- a/code/java/.idea/disaster_warning.iml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/java/.idea/encodings.xml b/code/java/.idea/encodings.xml deleted file mode 100644 index 860a155..0000000 --- a/code/java/.idea/encodings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/code/java/.idea/jarRepositories.xml b/code/java/.idea/jarRepositories.xml deleted file mode 100644 index c7ea920..0000000 --- a/code/java/.idea/jarRepositories.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/java/.idea/misc.xml b/code/java/.idea/misc.xml deleted file mode 100644 index 132404b..0000000 --- a/code/java/.idea/misc.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/code/java/.idea/runConfigurations/compile.xml b/code/java/.idea/runConfigurations/compile.xml deleted file mode 100644 index 780c17d..0000000 --- a/code/java/.idea/runConfigurations/compile.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/code/java/.idea/uiDesigner.xml b/code/java/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/code/java/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/java/.idea/vcs.xml b/code/java/.idea/vcs.xml deleted file mode 100644 index c2365ab..0000000 --- a/code/java/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/code/java/.idea/workspace.xml b/code/java/.idea/workspace.xml deleted file mode 100644 index b4d2259..0000000 --- a/code/java/.idea/workspace.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1647326463353 - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/java/天气灾害预警/.gitignore b/code/java/天气灾害预警/.gitignore deleted file mode 100644 index bda35c7..0000000 --- a/code/java/天气灾害预警/.gitignore +++ /dev/null @@ -1,135 +0,0 @@ -### Java template -# Compiled class file -*.class - -# Log file -*.log - -# BlueJ files -*.ctxt - -# Mobile Tools for Java (J2ME) -.mtj.tmp/ - -# Package Files # -*.jar -*.war -*.nar -*.ear -*.zip -*.tar.gz -*.rar - -# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml -hs_err_pid* - -### VisualStudioCode template -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ - -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf - -# Generated files -.idea/**/contentModel.xml - -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml - -# Gradle -.idea/**/gradle.xml -.idea/**/libraries - -# Gradle and Maven with auto-import -# When using Gradle or Maven with auto-import, you should exclude module files, -# since they will be recreated, and may cause churn. Uncomment if using -# auto-import. -# .idea/artifacts -# .idea/compiler.xml -# .idea/jarRepositories.xml -# .idea/modules.xml -# .idea/*.iml -# .idea/modules -# *.iml -# *.ipr - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser - -### Windows template -# Windows thumbnail cache files -Thumbs.db -Thumbs.db:encryptable -ehthumbs.db -ehthumbs_vista.db - -# Dump file -*.stackdump - -# Folder config file -[Dd]esktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msix -*.msm -*.msp - -# Windows shortcuts -*.lnk - diff --git a/code/java/天气灾害预警/config.json b/code/java/天气灾害预警/config.json deleted file mode 100644 index 72c0ecd..0000000 --- a/code/java/天气灾害预警/config.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "title": "天气灾害预警配置文件", - "key": "fe9fa8eeeb6f4301a92541eed565dd15", - "query_url": "https://devapi.qweather.com/v7/warning/now?", - "wechat_officalaccount_url": "https://cxxmwx.cpic.com.cn/app/index.php?i=2&c=entry&do=send_group_tpl_api&m=ok_tplmessage", - "cities": [ - { - "city_name": "厦门", - "city_code": "101230201" - }, - { - "city_name": "同安", - "city_code": "101230202" - }, - { - "city_name": "思明", - "city_code": "101230203" - }, - { - "city_name": "海沧", - "city_code": "101230204" - }, - { - "city_name": "湖里", - "city_code": "101230205" - }, - { - "city_name": "集美", - "city_code": "101230206" - }, - { - "city_name": "翔安", - "city_code": "101230207" - } - ], - "notify_stuffs": [ - { - "stuff_name": "王炜", - "mobile_phone": "15959215339" - } - ] -} diff --git a/code/java/天气灾害预警/db.json b/code/java/天气灾害预警/db.json deleted file mode 100644 index 7d27945..0000000 --- a/code/java/天气灾害预警/db.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "tns_name": "xmcx1", - "ip_addr": "10.39.0.86", - "user_name": "", - "password": "", - "tables": [ - { - "table_name": "", - "table_description": "" - } - ] -} \ No newline at end of file diff --git a/code/java/天气灾害预警/disaster_warning.iml b/code/java/天气灾害预警/disaster_warning.iml deleted file mode 100644 index 1862bd3..0000000 --- a/code/java/天气灾害预警/disaster_warning.iml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/java/天气灾害预警/disaster_warning.ipr b/code/java/天气灾害预警/disaster_warning.ipr deleted file mode 100644 index 6c063bb..0000000 --- a/code/java/天气灾害预警/disaster_warning.ipr +++ /dev/null @@ -1,381 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/java/天气灾害预警/lib/ojdbc8.jar b/code/java/天气灾害预警/lib/ojdbc8.jar deleted file mode 100644 index b46608c..0000000 Binary files a/code/java/天气灾害预警/lib/ojdbc8.jar and /dev/null differ diff --git a/code/java/天气灾害预警/out/production/天气灾害预警/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/code/java/天气灾害预警/out/production/天气灾害预警/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index ae8c739..0000000 --- a/code/java/天气灾害预警/out/production/天气灾害预警/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1,2 +0,0 @@ -AppMain.class -com\cpic\xim\disaster_warning\WeatherDisasterWarningGrabber.class diff --git a/code/java/天气灾害预警/out/production/天气灾害预警/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/code/java/天气灾害预警/out/production/天气灾害预警/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 0ede8f7..0000000 --- a/code/java/天气灾害预警/out/production/天气灾害预警/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,2 +0,0 @@ -D:\develop\产险厦门分公司项目\天气灾害预警\code\java\天气灾害预警\src\main\java\AppMain.java -D:\develop\产险厦门分公司项目\天气灾害预警\code\java\天气灾害预警\src\main\java\com\cpic\xim\disaster_warning\WeatherDisasterWarningGrabber.java diff --git a/code/java/天气灾害预警/pom.xml b/code/java/天气灾害预警/pom.xml deleted file mode 100644 index 76c2a4e..0000000 --- a/code/java/天气灾害预警/pom.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - 4.0.0 - com.cpic.xim - disaster_warning - 1.0-SNAPSHOT - - - org.apache.httpcomponents - httpclient - 4.5.2 - - - junit - junit - 4.4 - test - - - 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 - - - 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 - 1.8 - UTF-8 - UTF-8 - UTF-8 - - - compile - - - - dev - - - true - - - - test - - - false - - - - \ No newline at end of file diff --git a/code/java/天气灾害预警/src/main/java/AppMain.java b/code/java/天气灾害预警/src/main/java/AppMain.java deleted file mode 100644 index 77e1407..0000000 --- a/code/java/天气灾害预警/src/main/java/AppMain.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * @Author: Kane - * @Date: 2022-03-16 18:10:58 - * @LastEditors: Kane - * @LastEditTime: 2022-03-18 00:37:56 - * @FilePath: \天气灾害预警\src\main\java\AppMain.java - * @Description: - * - * Copyright (c) ${2022} by Kane, All Rights Reserved. - */ - -import com.cpic.xim.config.City; -import com.cpic.xim.notify.disaster.QWeatherDisasterWarning; -import com.cpic.xim.notify.disaster.WeatherDisasterWarningGrabber; -import com.cpic.xim.config.WeatherDisasterNotifyConfig; - -import java.io.IOException; -import java.util.Vector; - -public class AppMain -{ - private static final String CONFIG_FILE_PATH = "./config.json"; - - public static void main( String[] args ) - { - String cityCode = "101230201"; - String json; - QWeatherDisasterWarning warning = null; - WeatherDisasterNotifyConfig config = null; - - //读取配置 - try - { - config = WeatherDisasterNotifyConfig.load( CONFIG_FILE_PATH ); - } - catch ( IOException error ) - { - System.out.println( "读取配置文件失败!" ); - System.out.println( error.getMessage() ); - - return; - } - - Vector cities = config.getCities(); - String queryURL = config.getQueryUrl(); - String userKey = config.getKey(); - - //遍历所有城市,查询是否有警报,有则推送。 - for ( City city : cities ) - { - try - { - json = WeatherDisasterWarningGrabber.getWeatherDisasterWarningJSON( queryURL, - userKey, - city.getCityCode() ); - warning = WeatherDisasterWarningGrabber.convertWeatherDisasterWarning( json ); - - } - catch ( IOException error ) - { - System.out.println( "查询" + city.getCityName() + "出现异常!"); - System.out.println( error.getMessage() ); - - continue; - } - } - } -} \ No newline at end of file diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/City.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/City.java deleted file mode 100644 index 9efeaeb..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/City.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.cpic.xim.config; - -import java.util.Objects; - -public class City -{ - public City() {} - - public String getCityName() - { - return cityName; - } - - public void setCityName( String cityName ) - { - this.cityName = cityName; - } - - public String getCityCode() - { - return cityCode; - } - - public void setCityCode( String cityCode ) - { - this.cityCode = cityCode; - } - - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( o == null || getClass() != o.getClass() ) - { - return false; - } - City city = (City) o; - return cityName.equals( city.cityName ) && cityCode.equals( city.cityCode ); - } - - @Override - public int hashCode() - { - return Objects.hash( cityName, cityCode ); - } - - private String cityName; - private String cityCode; -} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/CpicxmStuff.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/CpicxmStuff.java deleted file mode 100644 index 643dbfb..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/CpicxmStuff.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.cpic.xim.config; - -import java.util.Objects; - -public class CpicxmStuff -{ - public CpicxmStuff() {}; - - public String getStuffName() - { - return stuffName; - } - - public void setStuffName( String stuffName ) - { - this.stuffName = stuffName; - } - - public String getMobilePhone() - { - return mobilePhone; - } - - public void setMobilePhone( String mobilePhone ) - { - this.mobilePhone = mobilePhone; - } - - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( !( o instanceof CpicxmStuff ) ) - { - return false; - } - CpicxmStuff that = (CpicxmStuff) o; - return stuffName.equals( that.stuffName ) && mobilePhone.equals( that.mobilePhone ); - } - - @Override - public int hashCode() - { - return Objects.hash( stuffName, mobilePhone ); - } - - private String stuffName; - private String mobilePhone; -} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/WeatherDisasterNotifyConfig.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/WeatherDisasterNotifyConfig.java deleted file mode 100644 index d88d0f8..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/WeatherDisasterNotifyConfig.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.cpic.xim.config; - -import java.io.FileReader; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Vector; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.PropertyNamingStrategy; - -public class WeatherDisasterNotifyConfig -{ - private static final int BUFFER_SIZE = 1024; - - public static WeatherDisasterNotifyConfig load( String filePath ) - throws IOException - - { - WeatherDisasterNotifyConfig config = null; - ObjectMapper mapper = new ObjectMapper(); - FileReader configFile = null; - StringBuffer json = null; - char[] buffer = new char[BUFFER_SIZE]; - - //设置json属性 - mapper.setPropertyNamingStrategy( PropertyNamingStrategy.SNAKE_CASE ); - - try{ - configFile = new FileReader( filePath ); - json = new StringBuffer(); - - int length = configFile.read( buffer ); - - while ( length != -1 ) - { - json.append( buffer ); - - length = configFile.read( buffer ); - } - - config = mapper.readValue( json.toString(), WeatherDisasterNotifyConfig.class ); - } - finally - { - if ( configFile != null ) - { - try - { - configFile.close(); - } - catch ( IOException e ) - { - e.printStackTrace(); - } - } - } - - return config; - } - - public WeatherDisasterNotifyConfig() {}; - - public String getTitle() - { - return title; - } - - public void setTitle( String title ) - { - this.title = title; - } - - public String getKey() - { - return key; - } - - public void setKey( String key ) - { - this.key = key; - } - - public String getQueryUrl() - { - return queryUrl; - } - - public void setQueryUrl( String queryUrl ) - { - this.queryUrl = queryUrl; - } - - public Vector getCities() - { - return cities; - } - - public void setCities( Vector cities ) - { - this.cities = cities; - } - - public Vector getNotifyStuffs() - { - return notifyStuffs; - } - - public void setNotifyStuffs( Vector notifyStuffs ) - { - this.notifyStuffs = notifyStuffs; - } - - public String getWechatOfficalAccountURL() - { - return wechatOfficalAccountURL; - } - - public void setWechatOfficalAccountURL( String wechatOfficalAccountURL ) - { - this.wechatOfficalAccountURL = wechatOfficalAccountURL; - } - - private String title; - private String key; - private String queryUrl; - - @JsonProperty("wechat_officalaccount_url") - private String wechatOfficalAccountURL; - private Vector cities; - private Vector notifyStuffs; - - -} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/db/DBTable.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/db/DBTable.java deleted file mode 100644 index 9843d27..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/db/DBTable.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.cpic.xim.config.db; - -import java.util.Objects; - -public class DBTable -{ - public DBTable() {} - - public String getTableName() - { - return tableName; - } - - public void setTableName( String tableName ) - { - this.tableName = tableName; - } - - public String getTableDescription() - { - return tableDescription; - } - - public void setTableDescription( String tableDescription ) - { - this.tableDescription = tableDescription; - } - - @Override - public boolean equals( Object o ) - { - if ( this == o ) - { - return true; - } - if ( !( o instanceof DBTable ) ) - { - return false; - } - DBTable dbTable = (DBTable) o; - return tableName.equals( dbTable.tableName ) && tableDescription.equals( dbTable.tableDescription ); - } - - @Override - public int hashCode() - { - return Objects.hash( tableName, tableDescription ); - } - - private String tableName; - private String tableDescription; -} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/db/OracleConfig.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/db/OracleConfig.java deleted file mode 100644 index 868ae8c..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/config/db/OracleConfig.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.cpic.xim.config.db; - -import java.util.Vector; - -public class OracleConfig -{ - private String tnsName; - private String ipAddr; - private String jdbcURL; - private String userName; - private String password; - private Vector tables; -} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/QWeatherDisasterWarning.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/QWeatherDisasterWarning.java deleted file mode 100644 index e527a88..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/QWeatherDisasterWarning.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.cpic.xim.notify.disaster; - -import java.util.Vector; - -public class QWeatherDisasterWarning -{ - public QWeatherDisasterWarning( String code, - String updateTime, - String fxLink, - Vector warning, - QWeatherDisasterWarningRefer refer ) - { - this.code = code; - this.updateTime = updateTime; - this.fxLink = fxLink; - this.warning = warning; - this.refer = refer; - } - - public QWeatherDisasterWarning() {} - - public String getCode() - { - return code; - } - - public void setCode( String code ) - { - this.code = code; - } - - public String getUpdateTime() - { - return updateTime; - } - - public void setUpdateTime( String updateTime ) - { - this.updateTime = updateTime; - } - - public String getFxLink() - { - return fxLink; - } - - public void setFxLink( String fxLink ) - { - this.fxLink = fxLink; - } - - public Vector getWarning() - { - return warning; - } - - public void setWarning( Vector warning ) - { - this.warning = warning; - } - - public QWeatherDisasterWarningRefer getRefer() - { - return refer; - } - - public void setRefer( QWeatherDisasterWarningRefer refer ) - { - this.refer = refer; - } - - private String code; - private String updateTime; - private String fxLink; - private Vector warning; - private QWeatherDisasterWarningRefer refer; -} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/QWeatherDisasterWarningItem.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/QWeatherDisasterWarningItem.java deleted file mode 100644 index ad4ba37..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/QWeatherDisasterWarningItem.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.cpic.xim.notify.disaster; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonFormat; -//import com.fasterxml.jackson.annotation.JsonIgnore; - -public class QWeatherDisasterWarningItem -{ - public 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 certainty ) - { - 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.certainty = certainty; - } - - @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( certainty, - that.certainty ); - } - - @Override - public int hashCode() - { - return Objects.hash( id, - sender, - pubTime, - title, - status, - level, - type, - typeName, - text, - related, - urgency, - certainty ); - } - - 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 getCertainty() - { - return certainty; - } - - public void setCertainty( String certainty ) - { - this.certainty = certainty; - } - - private String id; - private String sender; - @JsonFormat(pattern="yyyy-MM-dd'T'HH:mm") - 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 certainty; -} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/QWeatherDisasterWarningRefer.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/QWeatherDisasterWarningRefer.java deleted file mode 100644 index 39d2581..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/QWeatherDisasterWarningRefer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * @Author: Kane - * @Date: 2022-03-17 21:08:09 - * @LastEditors: Kane - * @LastEditTime: 2022-03-18 00:30:53 - * @FilePath: \天气灾害预警\src\main\java\com\cpic\xim\disaster_warning\QWeatherDisasterWarningRefer.java - * @Description: - * - * Copyright (c) ${2022} by Kane, All Rights Reserved. - */ -package com.cpic.xim.notify.disaster; - -//import java.util.Objects; - -public class QWeatherDisasterWarningRefer -{ - public QWeatherDisasterWarningRefer() {} - - public String[] getSources() - { - return sources; - } - - public void setSources( String[] sources ) - { - this.sources = sources; - } - - public String[] getLicense() - { - return license; - } - - public void setLicense( String[] license ) - { - this.license = license; - } - - private String[] sources; - private String[] license; -} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/WeatherDisasterWarningGrabber.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/WeatherDisasterWarningGrabber.java deleted file mode 100644 index ea144cf..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/notify/disaster/WeatherDisasterWarningGrabber.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * @author 王炜 - * @version 1.0 - */ -package com.cpic.xim.notify.disaster; - -import com.fasterxml.jackson.databind.ObjectMapper; - -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 -{ - /*** - * 从和风天气获取天气警报json字符串 - * @param cityCode 城市或区域代码 - * @return 返回警报的json字符串 - */ - public static String getWeatherDisasterWarningJSON( String queryURL, - String userKey, - String cityCode ) - { - //拼接url字符串 - String json = ""; - String requestURL = queryURL + "key=" + userKey + "&location=" + cityCode; - - //链接用 - 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(); - - //如果responseCode为200,说明访问成功! - if ( connection.getResponseCode() == 200 ) - { - //注意,和风使用了gzip压缩响应体 - 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(); - } - } - - if ( connection != null ) - { - connection.disconnect(); - } - } - - return json; - } - - /** - * 将天气警告的json字符串转换成java对象。 - * @param json json字符串 - * @return 返回 QWeatherDisasterWarning 对象。 - * @throws IOException - */ - public static QWeatherDisasterWarning convertWeatherDisasterWarning( String json ) - throws IOException - { - ObjectMapper mapper = new ObjectMapper(); - QWeatherDisasterWarning warning = mapper.readValue( json, QWeatherDisasterWarning.class ); - - return warning; - } -} diff --git a/code/java/天气灾害预警/src/main/java/com/cpic/xim/wechat/officalAccount/sendMessage.java b/code/java/天气灾害预警/src/main/java/com/cpic/xim/wechat/officalAccount/sendMessage.java deleted file mode 100644 index 096a9c9..0000000 --- a/code/java/天气灾害预警/src/main/java/com/cpic/xim/wechat/officalAccount/sendMessage.java +++ /dev/null @@ -1,299 +0,0 @@ - -package com.cpic.xim.wechat.officalAccount; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import java.io.*; - - -import java.net.URL; -import java.net.HttpURLConnection; -import java.nio.charset.StandardCharsets; - - -public class sendMessage -{ - - /** - * 向公众号推送通知消息。接口文档参考 彭奕洁 编写《消息发送接口调用文档》 - * - * @param wechatOfficalAccountURL 公众号接口网址。 - * @param title 通知的标题。 - * @param notifyType 通知类型。 - * @param notifyMessage 通知文本内容。 - */ - public static void sendNotifyMessage( String wechatOfficalAccountURL, - String title, - String notifyType, - String notifyMessage ) - - { - //设置推送内容 - WechatOfficalAccountMessageParameter param = new WechatOfficalAccountMessageParameter(); - - param.setFirst( title ); - param.setKeyword1( notifyType ); - param.setKeyword1Color( "#ff0000" ); - param.setKeyword2( notifyMessage ); - - //转换成json - ObjectMapper mapper; - String json = null; - - try - { - mapper = new ObjectMapper(); - mapper.setSerializationInclusion( JsonInclude.Include.NON_NULL ); - - json = mapper.writeValueAsString( param ); - - if ( json.isEmpty() ) - { - - } - - System.out.println( json ); - } - catch ( JsonProcessingException error ) - { - error.printStackTrace(); - - return; - } - - //推送数据 - URL url; - HttpURLConnection connection = null; - - StringBuilder result = new StringBuilder(); - OutputStreamWriter out = null; - BufferedReader in = null; - - try - { - url = new URL( wechatOfficalAccountURL ); - connection = (HttpURLConnection) url.openConnection(); - - connection.setRequestMethod( "POST" ); - connection.setRequestProperty( "accept", "*/*" ); - connection.setRequestProperty( "Connection", "Keep-Alive" ); - connection.setRequestProperty( "Content-Type", "application/json" ); - connection.setDoInput( true ); - connection.setDoOutput( true ); - connection.connect(); - - out = new OutputStreamWriter( connection.getOutputStream(), StandardCharsets.UTF_8 ); - out.write( json ); - out.flush(); - - in = new BufferedReader( new InputStreamReader( connection.getInputStream() ) ); - - String line = in.readLine(); - - while ( line != null ) - { - result.append( line ); - - line = in.readLine(); - } - } - catch ( Exception error ) - { - error.printStackTrace(); - } - finally - { - try - { - if ( in != null ) - { - in.close(); - } - - if ( out != null ) - { - out.close(); - } - - if ( connection != null ) - { - connection.disconnect(); - } - } - catch ( Exception error ) - { - error.printStackTrace(); - } - } - - } -} - -class WechatOfficalAccountMessageParameter -{ - - WechatOfficalAccountMessageParameter() - { - tplID = 57; - groupID = 1; - } - - @JsonProperty("tplid") - private int tplID; - - @JsonProperty("groupid") - private int groupID; - - @JsonProperty("first") - private String first; - - @JsonProperty("keyword1") - private String keyword1; - - @JsonProperty("keyword1color") - private String keyword1Color; - - @JsonProperty("keyword2") - private String keyword2; - - @JsonProperty("keyword2color") - private String keyword2Color; - - @JsonProperty("remark") - private String remark; - - @JsonProperty("remarkcolor") - private String remarkColor; - - @JsonProperty("url") - private String url; - - @JsonProperty("appid") - private String appid; - - @JsonProperty("pagepath") - private String pagePath; - - public int getTplID() - { - return tplID; - } - - public void setTplID( int tplID ) - { - this.tplID = tplID; - } - - public int getGroupID() - { - return groupID; - } - - public void setGroupID( int groupID ) - { - this.groupID = groupID; - } - - public String getFirst() - { - return first; - } - - public void setFirst( String first ) - { - this.first = first; - } - - public String getKeyword1() - { - return keyword1; - } - - public void setKeyword1( String keyword1 ) - { - this.keyword1 = keyword1; - } - - public String getKeyword1Color() - { - return keyword1Color; - } - - public void setKeyword1Color( String keyword1Color ) - { - this.keyword1Color = keyword1Color; - } - - public String getKeyword2() - { - return keyword2; - } - - public void setKeyword2( String keyword2 ) - { - this.keyword2 = keyword2; - } - - public String getKeyword2Color() - { - return keyword2Color; - } - - public void setKeyword2Color( String keyword2Color ) - { - this.keyword2Color = keyword2Color; - } - - public String getRemark() - { - return remark; - } - - public void setRemark( String remark ) - { - this.remark = remark; - } - - public String getRemarkColor() - { - return remarkColor; - } - - public void setRemarkColor( String remarkColor ) - { - this.remarkColor = remarkColor; - } - - public String getUrl() - { - return url; - } - - public void setUrl( String url ) - { - this.url = url; - } - - public String getAppid() - { - return appid; - } - - public void setAppid( String appid ) - { - this.appid = appid; - } - - public String getPagePath() - { - return pagePath; - } - - public void setPagePath( String pagePath ) - { - this.pagePath = pagePath; - } -} \ No newline at end of file diff --git a/code/java/天气灾害预警/src/test/java/com/cpic/xim/wechat/officalAccount/sendMessageTest.java b/code/java/天气灾害预警/src/test/java/com/cpic/xim/wechat/officalAccount/sendMessageTest.java deleted file mode 100644 index f90db0e..0000000 --- a/code/java/天气灾害预警/src/test/java/com/cpic/xim/wechat/officalAccount/sendMessageTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.cpic.xim.wechat.officalAccount; - -import org.junit.Test; - -import static org.junit.Assert.*; - -public class sendMessageTest -{ - @Test - public void pushNotifyMessage() - { - String url = "https://cxxmwx.cpic.com.cn/app/index.php?i=2&c=entry&do=send_group_tpl_api&m=ok_tplmessage"; - - try - { - //sendMessage.sendNotifyMessage( url, "警报", "警报标题", "警报内容!" ); - sendMessage.sendNotifyMessage( url, "警报", "警报标题", "警报内容!" ); - } - catch ( Exception error ) - { - fail("测试失败!"); - } - } -} \ No newline at end of file