Compare commits
	
		
			8 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3b1844c994 | |||
| db8f9e9c05 | |||
| 4c0cb3c76e | |||
| 65431a0f0e | |||
| cd8bcb8ba0 | |||
| e800558a32 | |||
| b993638e5b | |||
| 6671cb69c9 | 
@@ -8,6 +8,14 @@
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            "city_name": "厦门",
 | 
					            "city_name": "厦门",
 | 
				
			||||||
            "city_code": "101230201"
 | 
					            "city_code": "101230201"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "city_name": "同安",
 | 
				
			||||||
 | 
					            "city_code": "101230202"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "city_name": "翔安",
 | 
				
			||||||
 | 
					            "city_code": "101230207"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "notify_stuffs": [
 | 
					    "notify_stuffs": [
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,17 +21,13 @@
 | 
				
			|||||||
        <SOURCES />
 | 
					        <SOURCES />
 | 
				
			||||||
      </library>
 | 
					      </library>
 | 
				
			||||||
    </orderEntry>
 | 
					    </orderEntry>
 | 
				
			||||||
 | 
					    <orderEntry type="library" name="Maven: com.oracle:ojdbc8:19.3.0.0.0" level="project" />
 | 
				
			||||||
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.13" level="project" />
 | 
					    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.13" level="project" />
 | 
				
			||||||
    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.13" level="project" />
 | 
					    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.13" level="project" />
 | 
				
			||||||
 | 
					    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
 | 
				
			||||||
    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
 | 
					    <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
 | 
				
			||||||
    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.13.2" level="project" />
 | 
					    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.13.2" level="project" />
 | 
				
			||||||
    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
 | 
					    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
 | 
				
			||||||
    <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.4" level="project" />
 | 
					 | 
				
			||||||
    <orderEntry type="library" name="Maven: commons-collections:commons-collections:20040616" level="project" />
 | 
					 | 
				
			||||||
    <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
 | 
					 | 
				
			||||||
    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
 | 
					 | 
				
			||||||
    <orderEntry type="library" name="Maven: net.sf.ezmorph:ezmorph:1.0.6" level="project" />
 | 
					 | 
				
			||||||
    <orderEntry type="library" name="Maven: net.sf.json-lib:json-lib:jdk15:2.4" level="project" />
 | 
					 | 
				
			||||||
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
 | 
					    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
 | 
				
			||||||
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
 | 
					    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
 | 
				
			||||||
    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.8" level="project" />
 | 
					    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.8" level="project" />
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -267,15 +267,15 @@
 | 
				
			|||||||
        <root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.9.8/jackson-databind-2.9.8-sources.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.9.8/jackson-databind-2.9.8-sources.jar!/" />
 | 
				
			||||||
      </SOURCES>
 | 
					      </SOURCES>
 | 
				
			||||||
    </library>
 | 
					    </library>
 | 
				
			||||||
    <library name="Maven: commons-beanutils:commons-beanutils:1.9.4">
 | 
					    <library name="Maven: com.oracle:ojdbc8:19.3.0.0.0">
 | 
				
			||||||
      <CLASSES>
 | 
					      <CLASSES>
 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/com/oracle/ojdbc8/19.3.0.0.0/ojdbc8-19.3.0.0.0.jar!/" />
 | 
				
			||||||
      </CLASSES>
 | 
					      </CLASSES>
 | 
				
			||||||
      <JAVADOC>
 | 
					      <JAVADOC>
 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4-javadoc.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/com/oracle/ojdbc8/19.3.0.0.0/ojdbc8-19.3.0.0.0-javadoc.jar!/" />
 | 
				
			||||||
      </JAVADOC>
 | 
					      </JAVADOC>
 | 
				
			||||||
      <SOURCES>
 | 
					      <SOURCES>
 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4-sources.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/com/oracle/ojdbc8/19.3.0.0.0/ojdbc8-19.3.0.0.0-sources.jar!/" />
 | 
				
			||||||
      </SOURCES>
 | 
					      </SOURCES>
 | 
				
			||||||
    </library>
 | 
					    </library>
 | 
				
			||||||
    <library name="Maven: commons-codec:commons-codec:1.11">
 | 
					    <library name="Maven: commons-codec:commons-codec:1.11">
 | 
				
			||||||
@@ -289,37 +289,15 @@
 | 
				
			|||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.11/commons-codec-1.11-sources.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.11/commons-codec-1.11-sources.jar!/" />
 | 
				
			||||||
      </SOURCES>
 | 
					      </SOURCES>
 | 
				
			||||||
    </library>
 | 
					    </library>
 | 
				
			||||||
    <library name="Maven: commons-collections:commons-collections:20040616">
 | 
					    <library name="Maven: commons-logging:commons-logging:1.2">
 | 
				
			||||||
      <CLASSES>
 | 
					      <CLASSES>
 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/20040616/commons-collections-20040616.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2.jar!/" />
 | 
				
			||||||
      </CLASSES>
 | 
					      </CLASSES>
 | 
				
			||||||
      <JAVADOC>
 | 
					      <JAVADOC>
 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/20040616/commons-collections-20040616-javadoc.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2-javadoc.jar!/" />
 | 
				
			||||||
      </JAVADOC>
 | 
					      </JAVADOC>
 | 
				
			||||||
      <SOURCES>
 | 
					      <SOURCES>
 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/20040616/commons-collections-20040616-sources.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2-sources.jar!/" />
 | 
				
			||||||
      </SOURCES>
 | 
					 | 
				
			||||||
    </library>
 | 
					 | 
				
			||||||
    <library name="Maven: commons-lang:commons-lang:2.6">
 | 
					 | 
				
			||||||
      <CLASSES>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-lang/commons-lang/2.6/commons-lang-2.6.jar!/" />
 | 
					 | 
				
			||||||
      </CLASSES>
 | 
					 | 
				
			||||||
      <JAVADOC>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-lang/commons-lang/2.6/commons-lang-2.6-javadoc.jar!/" />
 | 
					 | 
				
			||||||
      </JAVADOC>
 | 
					 | 
				
			||||||
      <SOURCES>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-lang/commons-lang/2.6/commons-lang-2.6-sources.jar!/" />
 | 
					 | 
				
			||||||
      </SOURCES>
 | 
					 | 
				
			||||||
    </library>
 | 
					 | 
				
			||||||
    <library name="Maven: commons-logging:commons-logging:1.1.1">
 | 
					 | 
				
			||||||
      <CLASSES>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar!/" />
 | 
					 | 
				
			||||||
      </CLASSES>
 | 
					 | 
				
			||||||
      <JAVADOC>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-javadoc.jar!/" />
 | 
					 | 
				
			||||||
      </JAVADOC>
 | 
					 | 
				
			||||||
      <SOURCES>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-sources.jar!/" />
 | 
					 | 
				
			||||||
      </SOURCES>
 | 
					      </SOURCES>
 | 
				
			||||||
    </library>
 | 
					    </library>
 | 
				
			||||||
    <library name="Maven: junit:junit:4.13.2">
 | 
					    <library name="Maven: junit:junit:4.13.2">
 | 
				
			||||||
@@ -333,28 +311,6 @@
 | 
				
			|||||||
        <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.2/junit-4.13.2-sources.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.2/junit-4.13.2-sources.jar!/" />
 | 
				
			||||||
      </SOURCES>
 | 
					      </SOURCES>
 | 
				
			||||||
    </library>
 | 
					    </library>
 | 
				
			||||||
    <library name="Maven: net.sf.ezmorph:ezmorph:1.0.6">
 | 
					 | 
				
			||||||
      <CLASSES>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar!/" />
 | 
					 | 
				
			||||||
      </CLASSES>
 | 
					 | 
				
			||||||
      <JAVADOC>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6-javadoc.jar!/" />
 | 
					 | 
				
			||||||
      </JAVADOC>
 | 
					 | 
				
			||||||
      <SOURCES>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6-sources.jar!/" />
 | 
					 | 
				
			||||||
      </SOURCES>
 | 
					 | 
				
			||||||
    </library>
 | 
					 | 
				
			||||||
    <library name="Maven: net.sf.json-lib:json-lib:jdk15:2.4">
 | 
					 | 
				
			||||||
      <CLASSES>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/net/sf/json-lib/json-lib/2.4/json-lib-2.4-jdk15.jar!/" />
 | 
					 | 
				
			||||||
      </CLASSES>
 | 
					 | 
				
			||||||
      <JAVADOC>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/net/sf/json-lib/json-lib/2.4/json-lib-2.4-javadoc.jar!/" />
 | 
					 | 
				
			||||||
      </JAVADOC>
 | 
					 | 
				
			||||||
      <SOURCES>
 | 
					 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/net/sf/json-lib/json-lib/2.4/json-lib-2.4-sources.jar!/" />
 | 
					 | 
				
			||||||
      </SOURCES>
 | 
					 | 
				
			||||||
    </library>
 | 
					 | 
				
			||||||
    <library name="Maven: org.apache.httpcomponents:httpclient:4.5.13">
 | 
					    <library name="Maven: org.apache.httpcomponents:httpclient:4.5.13">
 | 
				
			||||||
      <CLASSES>
 | 
					      <CLASSES>
 | 
				
			||||||
        <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar!/" />
 | 
					        <root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar!/" />
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,4 +7,4 @@ java.util.logging.FileHandler.pattern = ./logs/log_%u.log
 | 
				
			|||||||
java.util.logging.FileHandler.limit = 50000
 | 
					java.util.logging.FileHandler.limit = 50000
 | 
				
			||||||
java.util.logging.FileHandler.count = 1
 | 
					java.util.logging.FileHandler.count = 1
 | 
				
			||||||
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
 | 
					java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
 | 
				
			||||||
java.util.logging.FileHandler.append = true;
 | 
					java.util.logging.FileHandler.append = true
 | 
				
			||||||
@@ -8,9 +8,9 @@
 | 
				
			|||||||
        <dependency>
 | 
					        <dependency>
 | 
				
			||||||
            <groupId>com.oracle</groupId>
 | 
					            <groupId>com.oracle</groupId>
 | 
				
			||||||
            <artifactId>ojdbc8</artifactId>
 | 
					            <artifactId>ojdbc8</artifactId>
 | 
				
			||||||
            <version>1.0</version>
 | 
					            <version>19.3.0.0.0</version>
 | 
				
			||||||
            <scope>system</scope>
 | 
					            <!-- <scope>system</scope>
 | 
				
			||||||
            <systemPath>${project.basedir}/lib/ojdbc8.jar</systemPath>
 | 
					            <systemPath>${project.basedir}/lib/ojdbc8.jar</systemPath> -->
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
        <dependency>
 | 
					        <dependency>
 | 
				
			||||||
            <groupId>org.apache.httpcomponents</groupId>
 | 
					            <groupId>org.apache.httpcomponents</groupId>
 | 
				
			||||||
@@ -23,37 +23,6 @@
 | 
				
			|||||||
            <version>4.13.2</version>
 | 
					            <version>4.13.2</version>
 | 
				
			||||||
            <scope>test</scope>
 | 
					            <scope>test</scope>
 | 
				
			||||||
        </dependency>
 | 
					        </dependency>
 | 
				
			||||||
        <!-- <dependency>
 | 
					 | 
				
			||||||
            <groupId>commons-beanutils</groupId>
 | 
					 | 
				
			||||||
            <artifactId>commons-beanutils</artifactId>
 | 
					 | 
				
			||||||
            <version>1.9.4</version>
 | 
					 | 
				
			||||||
        </dependency>
 | 
					 | 
				
			||||||
        <dependency>
 | 
					 | 
				
			||||||
            <groupId>commons-collections</groupId>
 | 
					 | 
				
			||||||
            <artifactId>commons-collections</artifactId>
 | 
					 | 
				
			||||||
            <version>20040616</version>
 | 
					 | 
				
			||||||
        </dependency>
 | 
					 | 
				
			||||||
        <dependency>
 | 
					 | 
				
			||||||
            <groupId>commons-lang</groupId>
 | 
					 | 
				
			||||||
            <artifactId>commons-lang</artifactId>
 | 
					 | 
				
			||||||
            <version>2.6</version>
 | 
					 | 
				
			||||||
        </dependency>
 | 
					 | 
				
			||||||
        <dependency>
 | 
					 | 
				
			||||||
            <groupId>commons-logging</groupId>
 | 
					 | 
				
			||||||
            <artifactId>commons-logging</artifactId>
 | 
					 | 
				
			||||||
            <version>1.1.1</version>
 | 
					 | 
				
			||||||
        </dependency>
 | 
					 | 
				
			||||||
        <dependency>
 | 
					 | 
				
			||||||
            <groupId>net.sf.ezmorph</groupId>
 | 
					 | 
				
			||||||
            <artifactId>ezmorph</artifactId>
 | 
					 | 
				
			||||||
            <version>1.0.6</version>
 | 
					 | 
				
			||||||
        </dependency>
 | 
					 | 
				
			||||||
        <dependency>
 | 
					 | 
				
			||||||
            <groupId>net.sf.json-lib</groupId>
 | 
					 | 
				
			||||||
            <artifactId>json-lib</artifactId>
 | 
					 | 
				
			||||||
            <version>2.4</version>
 | 
					 | 
				
			||||||
            <classifier>jdk15</classifier>
 | 
					 | 
				
			||||||
        </dependency> -->
 | 
					 | 
				
			||||||
        <dependency>
 | 
					        <dependency>
 | 
				
			||||||
            <groupId>com.fasterxml.jackson.core</groupId>
 | 
					            <groupId>com.fasterxml.jackson.core</groupId>
 | 
				
			||||||
            <artifactId>jackson-core</artifactId>
 | 
					            <artifactId>jackson-core</artifactId>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * @Author: Kane
 | 
					 * @Author: Kane
 | 
				
			||||||
 * @Date: 2022-04-22 10:53:49
 | 
					 * @Date: 2022-04-22 10:53:49
 | 
				
			||||||
 * @LastEditors: Kane
 | 
					 * @LastEditors: Kane
 | 
				
			||||||
 * @LastEditTime: 2022-05-10 16:28:07
 | 
					 * @LastEditTime: 2022-06-07 13:16:35
 | 
				
			||||||
 * @FilePath: \DisasterWarning\src\main\java\AppMain.java
 | 
					 * @FilePath: \DisasterWarning\src\main\java\AppMain.java
 | 
				
			||||||
 * @Description: 和风天气预警推送厦门太保公众号主程序!
 | 
					 * @Description: 和风天气预警推送厦门太保公众号主程序!
 | 
				
			||||||
 * 
 | 
					 * 
 | 
				
			||||||
@@ -11,6 +12,7 @@
 | 
				
			|||||||
import com.cpic.xim.config.AppConfigManager;
 | 
					import com.cpic.xim.config.AppConfigManager;
 | 
				
			||||||
import com.cpic.xim.config.City;
 | 
					import com.cpic.xim.config.City;
 | 
				
			||||||
import com.cpic.xim.notify.disaster.QWeatherDisasterWarning;
 | 
					import com.cpic.xim.notify.disaster.QWeatherDisasterWarning;
 | 
				
			||||||
 | 
					import com.cpic.xim.notify.disaster.QWeatherDisasterWarningItem;
 | 
				
			||||||
import com.cpic.xim.notify.disaster.WeatherDisasterWarningGrabber;
 | 
					import com.cpic.xim.notify.disaster.WeatherDisasterWarningGrabber;
 | 
				
			||||||
import com.cpic.xim.wechat.officalAccount.sendMessage;
 | 
					import com.cpic.xim.wechat.officalAccount.sendMessage;
 | 
				
			||||||
import com.cpic.xim.config.WeatherDisasterNotifyConfig;
 | 
					import com.cpic.xim.config.WeatherDisasterNotifyConfig;
 | 
				
			||||||
@@ -20,43 +22,34 @@ import java.sql.SQLException;
 | 
				
			|||||||
import java.util.Vector;
 | 
					import java.util.Vector;
 | 
				
			||||||
import java.util.logging.*;
 | 
					import java.util.logging.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class AppMain {
 | 
				
			||||||
public class AppMain
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    // private final static String LOG_FILE_PATH = "./logs/app%u.log";
 | 
					    // private final static String LOG_FILE_PATH = "./logs/app%u.log";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void main( String[] args )
 | 
					    public static void main(String[] args) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        String json;
 | 
					        String json;
 | 
				
			||||||
        WeatherDisasterNotifyConfig config = null;
 | 
					        WeatherDisasterNotifyConfig config = null;
 | 
				
			||||||
        QWeatherDisasterWarning warning = null;
 | 
					        QWeatherDisasterWarning warning = null;
 | 
				
			||||||
        Logger logger = null;
 | 
					        Logger logger = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 配置logger
 | 
					        // 配置logger
 | 
				
			||||||
        try
 | 
					        try {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            setRootLogger();
 | 
					            setRootLogger();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logger = Logger.getLogger( "com.cpicxim" );
 | 
					            logger = Logger.getLogger("com.cpicxim");
 | 
				
			||||||
        }
 | 
					        } catch (IOException error) {
 | 
				
			||||||
        catch ( IOException error )
 | 
					            System.out.println("配置logger失败,原因:" + error.getMessage());
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            System.out.println( "配置logger失败,原因:" + error.getMessage() );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 读取配置
 | 
					        // 读取配置
 | 
				
			||||||
        try
 | 
					        try {
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            config = AppConfigManager.getConfig();
 | 
					            config = AppConfigManager.getConfig();
 | 
				
			||||||
        }
 | 
					        } catch (IOException error) {
 | 
				
			||||||
        catch ( IOException error )
 | 
					            System.out.println("读取配置文件失败!");
 | 
				
			||||||
        {
 | 
					            System.out.println(error.getMessage());
 | 
				
			||||||
            System.out.println( "读取配置文件失败!" );
 | 
					 | 
				
			||||||
            System.out.println( error.getMessage() );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            logger.log( Level.SEVERE, "读取配置文件失败:{0}", error.getMessage() );
 | 
					            logger.log(Level.SEVERE, "读取配置文件失败:{0}", error.getMessage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -66,73 +59,68 @@ public class AppMain
 | 
				
			|||||||
        String userKey = config.getKey();
 | 
					        String userKey = config.getKey();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 遍历所有城市,查询是否有警报,有则推送。
 | 
					        // 遍历所有城市,查询是否有警报,有则推送。
 | 
				
			||||||
        while (true)
 | 
					        while (true) {
 | 
				
			||||||
        {
 | 
					            for (City city : cities) {
 | 
				
			||||||
            for ( City city : cities )
 | 
					                try {
 | 
				
			||||||
            {
 | 
					                    json = WeatherDisasterWarningGrabber.getWeatherDisasterWarningJSON(queryURL,
 | 
				
			||||||
                try
 | 
					                            userKey, city.getCityCode());
 | 
				
			||||||
                {
 | 
					                    warning = WeatherDisasterWarningGrabber.convertWeatherDisasterWarning(json);
 | 
				
			||||||
                    json = WeatherDisasterWarningGrabber.getWeatherDisasterWarningJSON( queryURL,
 | 
					 | 
				
			||||||
                            userKey, city.getCityCode() );
 | 
					 | 
				
			||||||
                    warning = WeatherDisasterWarningGrabber.convertWeatherDisasterWarning( json );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    logger.log( Level.INFO, "查询{0}天气预警,结果:{1}。", new Object[]
 | 
					                    logger.log(Level.INFO, "查询{0}天气预警,结果:{1}。", new Object[] { city.getCityName(), json });
 | 
				
			||||||
                    { city.getCityName(), json} );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // 判断是否有警报
 | 
					                    Vector<QWeatherDisasterWarningItem> warningItems = warning.getWarning();
 | 
				
			||||||
                    if ( warning.getWarning().isEmpty() == true)
 | 
					
 | 
				
			||||||
                    {
 | 
					                    // 判断是否有警报,没有警报就结束当前城市的处理
 | 
				
			||||||
                        logger.log( Level.INFO, "查询{0}天气预警,无警报!。", new Object[]
 | 
					                    if (warningItems.isEmpty() == true) {
 | 
				
			||||||
                        { city.getCityName()} );
 | 
					                        logger.log(Level.INFO, "查询{0}天气预警,无警报!。", new Object[] { city.getCityName() });
 | 
				
			||||||
                        continue;
 | 
					                        continue;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    logger.log( Level.INFO, "查询{0}天气预警,发送日志。", new Object[]
 | 
					                    // 有警报,就遍历警报数组
 | 
				
			||||||
                    { city.getCityName()} );
 | 
					                    for (QWeatherDisasterWarningItem item : warningItems) {
 | 
				
			||||||
 | 
					                        // 先检查是否已经发送过
 | 
				
			||||||
 | 
					                        if (sendMessage.checkWarningHasSended(item.getId()) == false) {
 | 
				
			||||||
 | 
					                            logger.log(Level.INFO, "查询{0}天气预警,ID:{1},已有发送记录,跳过。",
 | 
				
			||||||
 | 
					                                    new Object[] { city.getCityName(), item.getId() });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    sendMessage.sendWeatherDisasterWarning( config.getWechatOfficalAccountURL(),
 | 
					                            continue;
 | 
				
			||||||
                            warning );
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    logger.log( Level.INFO, "{0}天气预警,日志发送成功。", new Object[]
 | 
					                        // 没有发送过
 | 
				
			||||||
                    { city.getCityName()} );
 | 
					                        logger.log(Level.INFO, "查询{0}天气预警,发送日志。", new Object[] { city.getCityName() });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    sendMessage.saveWeatherDisasterWarning( city.getCityName(), warning );
 | 
					                        sendMessage.sendWeatherDisasterWarning(config.getWechatOfficalAccountURL(),
 | 
				
			||||||
                }
 | 
					                                item);
 | 
				
			||||||
                catch ( IOException error )
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    System.out.println( "查询" + city.getCityName() + "出现异常!" );
 | 
					 | 
				
			||||||
                    System.out.println( error.getMessage() );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    logger.log( Level.SEVERE, "查询 {0} 出现异常:{1}。", new Object[]
 | 
					                        logger.log(Level.INFO, "{0}天气预警,日志发送成功。", new Object[] { city.getCityName() });
 | 
				
			||||||
                    { city.getCityName(), error.getMessage()} );
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                catch ( SQLException error )
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    logger.log( Level.SEVERE, "查询 {0} 写入数据库失败:{1}。", new Object[]
 | 
					 | 
				
			||||||
                    { city.getCityName(), error.getMessage()} );
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
                catch ( ClassNotFoundException error )
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    logger.log( Level.SEVERE, "查询 {0} 加载oracle驱动失败:{1}。", new Object[]
 | 
					 | 
				
			||||||
                    { city.getCityName(), error.getMessage()} );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                }
 | 
					                        // 将发送的警报,保存起来
 | 
				
			||||||
                catch ( Exception error )
 | 
					                        sendMessage.saveWeatherDisasterWarning(city.getCityName(), item);
 | 
				
			||||||
                {
 | 
					                    }
 | 
				
			||||||
                    logger.log( Level.SEVERE, "查询 {0} 出现未知错误:{1}。", new Object[]
 | 
					                } catch (IOException error) {
 | 
				
			||||||
                    { city.getCityName(), error.getMessage()} );
 | 
					                    System.out.println("查询" + city.getCityName() + "出现异常!");
 | 
				
			||||||
 | 
					                    System.out.println(error.getMessage());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    logger.log(Level.SEVERE, "查询 {0} 出现异常:{1}。",
 | 
				
			||||||
 | 
					                            new Object[] { city.getCityName(), error.getMessage() });
 | 
				
			||||||
 | 
					                } catch (SQLException error) {
 | 
				
			||||||
 | 
					                    logger.log(Level.SEVERE, "查询 {0} 写入数据库失败:{1}。",
 | 
				
			||||||
 | 
					                            new Object[] { city.getCityName(), error.getMessage() });
 | 
				
			||||||
 | 
					                } catch (ClassNotFoundException error) {
 | 
				
			||||||
 | 
					                    logger.log(Level.SEVERE, "查询 {0} 加载oracle驱动失败:{1}。",
 | 
				
			||||||
 | 
					                            new Object[] { city.getCityName(), error.getMessage() });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                } catch (Exception error) {
 | 
				
			||||||
 | 
					                    logger.log(Level.SEVERE, "查询 {0} 出现未知错误:{1}。",
 | 
				
			||||||
 | 
					                            new Object[] { city.getCityName(), error.getMessage() });
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            try
 | 
					            try {
 | 
				
			||||||
            {
 | 
					                logger.log(Level.INFO, "查询结束,休眠{0}分钟。", config.getQueryInterval());
 | 
				
			||||||
                logger.log( Level.INFO, "查询结束,休眠{0}分钟。", config.getQueryInterval() );
 | 
					                Thread.sleep(config.getQueryInterval() * 1000 * 60);
 | 
				
			||||||
                Thread.sleep( config.getQueryInterval() * 1000 * 60 );
 | 
					            } catch (InterruptedException error) {
 | 
				
			||||||
            }
 | 
					                logger.log(Level.SEVERE, "线程休眠异常,错误信息:{0}", new Object[] { error.getMessage() });
 | 
				
			||||||
            catch ( InterruptedException error )
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                logger.log( Level.SEVERE, "线程休眠异常,错误信息:{0}", new Object[]
 | 
					 | 
				
			||||||
                { error.getMessage()} );
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -140,17 +128,16 @@ public class AppMain
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 设置JUL的logger。
 | 
					     * 设置JUL的logger。
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private static void setRootLogger() throws IOException
 | 
					    private static void setRootLogger() throws IOException {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        LogManager logManager = LogManager.getLogManager();
 | 
					        LogManager logManager = LogManager.getLogManager();
 | 
				
			||||||
        // 使用外部的配置文件。
 | 
					        // 使用外部的配置文件。
 | 
				
			||||||
        FileInputStream configFile = new FileInputStream( "./logging.properties" );
 | 
					        FileInputStream configFile = new FileInputStream("./logging.properties");
 | 
				
			||||||
        // 使用jar中的配置文件。
 | 
					        // 使用jar中的配置文件。
 | 
				
			||||||
        // InputStream configFile =
 | 
					        // InputStream configFile =
 | 
				
			||||||
        // AppMain.class.getClassLoader().getResourceAsStream( "logging.properties" );
 | 
					        // AppMain.class.getClassLoader().getResourceAsStream( "logging.properties" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        logManager.readConfiguration( configFile );
 | 
					        logManager.readConfiguration(configFile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Logger.getLogger( "com.cpicxim" );
 | 
					        Logger.getLogger("com.cpicxim");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -74,7 +74,7 @@ public class QWeatherDisasterWarning
 | 
				
			|||||||
    private String code;
 | 
					    private String code;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "updateTime")
 | 
					    @JsonProperty( "updateTime")
 | 
				
			||||||
    @JsonFormat( pattern = "yyyy-MM-dd\'T\'HH:mmXXX")
 | 
					    @JsonFormat( pattern = "yyyy-MM-dd'T'HH:mmXXX")
 | 
				
			||||||
    private Date updateTime;
 | 
					    private Date updateTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "fxLink")
 | 
					    @JsonProperty( "fxLink")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,21 +7,21 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 | 
				
			|||||||
import com.fasterxml.jackson.annotation.JsonProperty;
 | 
					import com.fasterxml.jackson.annotation.JsonProperty;
 | 
				
			||||||
//import com.fasterxml.jackson.annotation.JsonIgnore;
 | 
					//import com.fasterxml.jackson.annotation.JsonIgnore;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class QWeatherDisasterWarningItem
 | 
					public class QWeatherDisasterWarningItem {
 | 
				
			||||||
{
 | 
					    public QWeatherDisasterWarningItem() {
 | 
				
			||||||
    public QWeatherDisasterWarningItem()
 | 
					    }
 | 
				
			||||||
    {}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public QWeatherDisasterWarningItem( String id, String sender, Date pubTime, String title,
 | 
					    public QWeatherDisasterWarningItem(String id, String sender, Date pubTime, String title, String status,
 | 
				
			||||||
            String status, String level, String type, String typeName, String text, String related,
 | 
					            String level, String severity, String severityColor, String type, String typeName, String text,
 | 
				
			||||||
            String urgency, String certainty)
 | 
					            String related, String urgency, String certainty) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.id = id;
 | 
					        this.id = id;
 | 
				
			||||||
        this.sender = sender;
 | 
					        this.sender = sender;
 | 
				
			||||||
        this.pubTime = pubTime;
 | 
					        this.pubTime = pubTime;
 | 
				
			||||||
        this.title = title;
 | 
					        this.title = title;
 | 
				
			||||||
        this.status = status;
 | 
					        this.status = status;
 | 
				
			||||||
        this.level = level;
 | 
					        this.level = level;
 | 
				
			||||||
 | 
					        this.severity = severity;
 | 
				
			||||||
 | 
					        this.severityColor = severityColor;
 | 
				
			||||||
        this.type = type;
 | 
					        this.type = type;
 | 
				
			||||||
        this.typeName = typeName;
 | 
					        this.typeName = typeName;
 | 
				
			||||||
        this.text = text;
 | 
					        this.text = text;
 | 
				
			||||||
@@ -31,163 +31,233 @@ public class QWeatherDisasterWarningItem
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public boolean equals( Object o )
 | 
					    public int hashCode() {
 | 
				
			||||||
    {
 | 
					        final int prime = 31;
 | 
				
			||||||
        if ( this == o)
 | 
					        int result = 1;
 | 
				
			||||||
        {
 | 
					        result = prime * result + ((certainty == null) ? 0 : certainty.hashCode());
 | 
				
			||||||
            return true;
 | 
					        result = prime * result + ((id == null) ? 0 : id.hashCode());
 | 
				
			||||||
        }
 | 
					        result = prime * result + ((level == null) ? 0 : level.hashCode());
 | 
				
			||||||
        if ( o == null || getClass() != o.getClass())
 | 
					        result = prime * result + ((pubTime == null) ? 0 : pubTime.hashCode());
 | 
				
			||||||
        {
 | 
					        result = prime * result + ((related == null) ? 0 : related.hashCode());
 | 
				
			||||||
            return false;
 | 
					        result = prime * result + ((sender == null) ? 0 : sender.hashCode());
 | 
				
			||||||
        }
 | 
					        result = prime * result + ((severity == null) ? 0 : severity.hashCode());
 | 
				
			||||||
        QWeatherDisasterWarningItem that = (QWeatherDisasterWarningItem) o;
 | 
					        result = prime * result + ((severityColor == null) ? 0 : severityColor.hashCode());
 | 
				
			||||||
        return id.equals( that.id ) && Objects.equals( sender, that.sender )
 | 
					        result = prime * result + ((status == null) ? 0 : status.hashCode());
 | 
				
			||||||
                && Objects.equals( pubTime, that.pubTime ) && Objects.equals( title, that.title )
 | 
					        result = prime * result + ((text == null) ? 0 : text.hashCode());
 | 
				
			||||||
                && Objects.equals( status, that.status ) && Objects.equals( level, that.level )
 | 
					        result = prime * result + ((title == null) ? 0 : title.hashCode());
 | 
				
			||||||
                && Objects.equals( type, that.type ) && Objects.equals( typeName, that.typeName )
 | 
					        result = prime * result + ((type == null) ? 0 : type.hashCode());
 | 
				
			||||||
                && Objects.equals( text, that.text ) && Objects.equals( related, that.related )
 | 
					        result = prime * result + ((typeName == null) ? 0 : typeName.hashCode());
 | 
				
			||||||
                && Objects.equals( urgency, that.urgency )
 | 
					        result = prime * result + ((urgency == null) ? 0 : urgency.hashCode());
 | 
				
			||||||
                && Objects.equals( certainty, that.certainty );
 | 
					        return result;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public int hashCode()
 | 
					    public boolean equals(Object obj) {
 | 
				
			||||||
    {
 | 
					        if (this == obj)
 | 
				
			||||||
        return Objects.hash( id, sender, pubTime, title, status, level, type, typeName, text,
 | 
					            return true;
 | 
				
			||||||
                related, urgency, certainty );
 | 
					        if (obj == null)
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (getClass() != obj.getClass())
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        QWeatherDisasterWarningItem other = (QWeatherDisasterWarningItem) obj;
 | 
				
			||||||
 | 
					        if (certainty == null) {
 | 
				
			||||||
 | 
					            if (other.certainty != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!certainty.equals(other.certainty))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (id == null) {
 | 
				
			||||||
 | 
					            if (other.id != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!id.equals(other.id))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (level == null) {
 | 
				
			||||||
 | 
					            if (other.level != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!level.equals(other.level))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (pubTime == null) {
 | 
				
			||||||
 | 
					            if (other.pubTime != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!pubTime.equals(other.pubTime))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (related == null) {
 | 
				
			||||||
 | 
					            if (other.related != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!related.equals(other.related))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (sender == null) {
 | 
				
			||||||
 | 
					            if (other.sender != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!sender.equals(other.sender))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (severity == null) {
 | 
				
			||||||
 | 
					            if (other.severity != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!severity.equals(other.severity))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (severityColor == null) {
 | 
				
			||||||
 | 
					            if (other.severityColor != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!severityColor.equals(other.severityColor))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (status == null) {
 | 
				
			||||||
 | 
					            if (other.status != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!status.equals(other.status))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (text == null) {
 | 
				
			||||||
 | 
					            if (other.text != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!text.equals(other.text))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (title == null) {
 | 
				
			||||||
 | 
					            if (other.title != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!title.equals(other.title))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (type == null) {
 | 
				
			||||||
 | 
					            if (other.type != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!type.equals(other.type))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (typeName == null) {
 | 
				
			||||||
 | 
					            if (other.typeName != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!typeName.equals(other.typeName))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        if (urgency == null) {
 | 
				
			||||||
 | 
					            if (other.urgency != null)
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					        } else if (!urgency.equals(other.urgency))
 | 
				
			||||||
 | 
					            return false;
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getId()
 | 
					    public String getId() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return id;
 | 
					        return id;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setId( String id )
 | 
					    public void setId(String id) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.id = id;
 | 
					        this.id = id;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getSender()
 | 
					    public String getSender() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return sender;
 | 
					        return sender;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setSender( String sender )
 | 
					    public void setSender(String sender) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.sender = sender;
 | 
					        this.sender = sender;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Date getPubTime()
 | 
					    public Date getPubTime() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return pubTime;
 | 
					        return pubTime;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setPubTime( Date pubTime )
 | 
					    public void setPubTime(Date pubTime) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.pubTime = pubTime;
 | 
					        this.pubTime = pubTime;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getTitle()
 | 
					    public String getTitle() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return title;
 | 
					        return title;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setTitle( String title )
 | 
					    public void setTitle(String title) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.title = title;
 | 
					        this.title = title;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getStatus()
 | 
					    public String getStatus() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return status;
 | 
					        return status;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setStatus( String status )
 | 
					    public void setStatus(String status) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.status = status;
 | 
					        this.status = status;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getLevel()
 | 
					    public String getLevel() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return level;
 | 
					        return level;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setLevel( String level )
 | 
					    public void setLevel(String level) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.level = level;
 | 
					        this.level = level;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getType()
 | 
					    public String getSeverity() {
 | 
				
			||||||
    {
 | 
					        return severity;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSeverity(String severity) {
 | 
				
			||||||
 | 
					        this.severity = severity;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getSeverityColor() {
 | 
				
			||||||
 | 
					        return severityColor;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setSeverityColor(String severityColor) {
 | 
				
			||||||
 | 
					        this.severityColor = severityColor;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getType() {
 | 
				
			||||||
        return type;
 | 
					        return type;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setType( String type )
 | 
					    public void setType(String type) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.type = type;
 | 
					        this.type = type;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getTypeName()
 | 
					    public String getTypeName() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return typeName;
 | 
					        return typeName;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setTypeName( String typeName )
 | 
					    public void setTypeName(String typeName) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.typeName = typeName;
 | 
					        this.typeName = typeName;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getText()
 | 
					    public String getText() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return text;
 | 
					        return text;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setText( String text )
 | 
					    public void setText(String text) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.text = text;
 | 
					        this.text = text;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getRelated()
 | 
					    public String getRelated() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return related;
 | 
					        return related;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setRelated( String related )
 | 
					    public void setRelated(String related) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.related = related;
 | 
					        this.related = related;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getUrgency()
 | 
					    public String getUrgency() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return urgency;
 | 
					        return urgency;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setUrgency( String urgency )
 | 
					    public void setUrgency(String urgency) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.urgency = urgency;
 | 
					        this.urgency = urgency;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public String getCertainty()
 | 
					    public String getCertainty() {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        return certainty;
 | 
					        return certainty;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setCertainty( String certainty )
 | 
					    public void setCertainty(String certainty) {
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        this.certainty = certainty;
 | 
					        this.certainty = certainty;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String id;
 | 
					    private String id;
 | 
				
			||||||
    private String sender;
 | 
					    private String sender;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "pubTime")
 | 
					    @JsonProperty("pubTime")
 | 
				
			||||||
    @JsonFormat( shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd\'T\'HH:mmXXX")
 | 
					    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd\'T\'HH:mmXXX")
 | 
				
			||||||
    private Date pubTime;
 | 
					    private Date pubTime;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String title;
 | 
					    private String title;
 | 
				
			||||||
    private String status;
 | 
					    private String status;
 | 
				
			||||||
    private String level;
 | 
					    private String level;
 | 
				
			||||||
 | 
					    private String severity;
 | 
				
			||||||
 | 
					    private String severityColor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private String type;
 | 
					    private String type;
 | 
				
			||||||
    private String typeName;
 | 
					    private String typeName;
 | 
				
			||||||
    private String text;
 | 
					    private String text;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 * @Author: Kane
 | 
					 * @Author: Kane
 | 
				
			||||||
 * @Date: 2022-04-22 10:53:49
 | 
					 * @Date: 2022-04-22 10:53:49
 | 
				
			||||||
 * @LastEditors: Kane
 | 
					 * @LastEditors: Kane
 | 
				
			||||||
 * @LastEditTime: 2022-05-06 11:14:32
 | 
					 * @LastEditTime: 2022-05-12 09:51:13
 | 
				
			||||||
 * @FilePath: \DisasterWarning\src\main\java\com\cpic\xim\wechat\officalAccount\sendMessage.java
 | 
					 * @FilePath: \DisasterWarning\src\main\java\com\cpic\xim\wechat\officalAccount\sendMessage.java
 | 
				
			||||||
 * @Description: 用来推送公众号消息的程序库。
 | 
					 * @Description: 用来推送公众号消息的程序库。
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -14,16 +14,17 @@ import com.cpic.xim.config.db.OracleConfigManager;
 | 
				
			|||||||
import com.cpic.xim.config.db.OracleConfig;
 | 
					import com.cpic.xim.config.db.OracleConfig;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.fasterxml.jackson.annotation.JsonProperty;
 | 
					import com.fasterxml.jackson.annotation.JsonProperty;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.net.MalformedURLException;
 | 
					import java.net.MalformedURLException;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.Vector;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.sql.Connection;
 | 
					import java.sql.Connection;
 | 
				
			||||||
import java.sql.DriverManager;
 | 
					import java.sql.DriverManager;
 | 
				
			||||||
import java.sql.PreparedStatement;
 | 
					import java.sql.PreparedStatement;
 | 
				
			||||||
import java.sql.ResultSet;
 | 
					import java.sql.ResultSet;
 | 
				
			||||||
import java.sql.SQLException;
 | 
					import java.sql.SQLException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.cpic.xim.notify.disaster.*;
 | 
					import com.cpic.xim.notify.disaster.*;
 | 
				
			||||||
import com.cpic.xim.httpUtil.HttpUtils;
 | 
					import com.cpic.xim.httpUtil.HttpUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -39,13 +40,14 @@ public class sendMessage
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 推送天气灾害预警!接口文档参考 彭奕洁 编写《消息发送接口调用文档》
 | 
					     * 推送天气灾害预警!接口文档参考 彭奕洁 编写《消息发送接口调用文档》
 | 
				
			||||||
     * 使用 post 方式,请求体内容以最基础的 post 格式。
 | 
					     * 使用 post 方式,请求体内容以最基础的 post 格式。
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param officalAccountURL 产险厦门分公司公众号接口网址
 | 
					     * @param officalAccountURL 产险厦门分公司公众号接口网址
 | 
				
			||||||
     * @param warning           灾害预警对象
 | 
					     * @param warningItem       灾害预警对象
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void sendWeatherDisasterWarning( String officalAccountURL,
 | 
					    public static void sendWeatherDisasterWarning( String officalAccountURL,
 | 
				
			||||||
            QWeatherDisasterWarning warning )
 | 
					                                                   QWeatherDisasterWarningItem warningItem )
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Vector<QWeatherDisasterWarningItem> warningItems = warning.getWarning();
 | 
					        // Vector<QWeatherDisasterWarningItem> warningItems = warningItem.getWarning();
 | 
				
			||||||
        StringBuilder requestBody = null;
 | 
					        StringBuilder requestBody = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 设置请求头参数
 | 
					        // 设置请求头参数
 | 
				
			||||||
@@ -56,36 +58,36 @@ public class sendMessage
 | 
				
			|||||||
        headers.put( "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8" );
 | 
					        headers.put( "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 遍历消息,将消息推送出去。
 | 
					        // 遍历消息,将消息推送出去。
 | 
				
			||||||
        for ( QWeatherDisasterWarningItem item : warningItems )
 | 
					
 | 
				
			||||||
 | 
					        // 拼接消息内容
 | 
				
			||||||
 | 
					        String title = warningItem.getTitle();
 | 
				
			||||||
 | 
					        String text  = warningItem.getText();
 | 
				
			||||||
 | 
					        String color = warningLevel.containsKey( warningItem.getLevel() )
 | 
				
			||||||
 | 
					                ? warningLevel.get( warningItem.getLevel() )
 | 
				
			||||||
 | 
					                : "#000000";
 | 
				
			||||||
 | 
					        requestBody = new StringBuilder();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        requestBody.append( "tplid=57&groupid=1&first=尊敬的#realname#,您好!&" );
 | 
				
			||||||
 | 
					        requestBody.append( "keyword1=" ).append( title ).append( "&" );
 | 
				
			||||||
 | 
					        requestBody.append( "keyword1color=" ).append( color ).append( "&" );
 | 
				
			||||||
 | 
					        requestBody.append( "keyword2=" ).append( text );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // 拼接消息内容
 | 
					            HttpUtils.postHttpRequest( officalAccountURL, headers, requestBody.toString() );
 | 
				
			||||||
            String title = item.getTitle();
 | 
					 | 
				
			||||||
            String text = item.getText();
 | 
					 | 
				
			||||||
            String color = warningLevel.keySet().contains( item.getLevel() )
 | 
					 | 
				
			||||||
                    ? warningLevel.get( item.getLevel() )
 | 
					 | 
				
			||||||
                    : "#000000";
 | 
					 | 
				
			||||||
            requestBody = new StringBuilder();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            requestBody.append( "tplid=57&groupid=1&first=尊敬的#realname#,您好!&" );
 | 
					 | 
				
			||||||
            requestBody.append( "keyword1=" ).append( title ).append( "&" );
 | 
					 | 
				
			||||||
            requestBody.append( "keyword1color=" ).append( color ).append( "&" );
 | 
					 | 
				
			||||||
            requestBody.append( "keyword2=" ).append( text );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            try
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                HttpUtils.postHttpRequest( officalAccountURL, headers, requestBody.toString() );
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            catch ( MalformedURLException error )
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                error.printStackTrace();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        catch ( MalformedURLException error )
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            error.printStackTrace();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 检查预警是否已经推送过,通过 QWeatherDisasterWarningItem 对象的 id 属性。
 | 
					     * 检查预警是否已经推送过,通过 QWeatherDisasterWarningItem 对象的 id 属性。
 | 
				
			||||||
     * 查询 oracle xmcx1 数据库 wechat 表空间下 weather_disaster_notify 表,
 | 
					     * 查询 oracle xmcx1 数据库 wechat 表空间下 weather_disaster_notify 表,
 | 
				
			||||||
     * 统计 warningID 的数量,如果不为0,说明该预警已经保存过,视为已经推送过。
 | 
					     * 统计 warningID 的数量,如果不为0,说明该预警已经保存过,视为已经推送过。
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
     * @param warningID 预警的id
 | 
					     * @param warningID 预警的id
 | 
				
			||||||
     * @return 如果推送过,返回false,否则返回 true。
 | 
					     * @return 如果推送过,返回false,否则返回 true。
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@@ -94,16 +96,16 @@ public class sendMessage
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        boolean result = false;
 | 
					        boolean result = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        OracleConfig dbConfig = OracleConfigManager.getOracleConfig();;
 | 
					        OracleConfig dbConfig = OracleConfigManager.getOracleConfig();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Connection conn = null;
 | 
					        Connection        conn = null;
 | 
				
			||||||
        PreparedStatement stmt = null;
 | 
					        PreparedStatement stmt = null;
 | 
				
			||||||
        ResultSet rs = null;
 | 
					        ResultSet         rs   = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String jdbcURL = dbConfig.getJdbcURL();
 | 
					        String jdbcURL  = dbConfig.getJdbcURL();
 | 
				
			||||||
        String userName = dbConfig.getUserName();
 | 
					        String userName = dbConfig.getUserName();
 | 
				
			||||||
        String password = dbConfig.getPassword();
 | 
					        String password = dbConfig.getPassword();
 | 
				
			||||||
        String sql = "select count(*) from weather_disaster_notify where notify_id = ?";
 | 
					        String sql      = "select count(*) from weather_disaster_notify where notify_id = ?";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Logger logger = Logger.getLogger( "com.cpicxim.wechat.officalAccount.sendMessage" );
 | 
					        // Logger logger = Logger.getLogger( "com.cpicxim.wechat.officalAccount.sendMessage" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -117,7 +119,7 @@ public class sendMessage
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            rs = stmt.executeQuery();
 | 
					            rs = stmt.executeQuery();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ( rs.next() && rs.getInt( 1 ) == 0)
 | 
					            if ( rs.next() && rs.getInt( 1 ) == 0 )
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                result = true;
 | 
					                result = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -126,7 +128,7 @@ public class sendMessage
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if ( rs != null)
 | 
					                if ( rs != null )
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    rs.close();
 | 
					                    rs.close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -138,7 +140,7 @@ public class sendMessage
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if ( stmt != null)
 | 
					                if ( stmt != null )
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    stmt.close();
 | 
					                    stmt.close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -150,7 +152,7 @@ public class sendMessage
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if ( conn != null)
 | 
					                if ( conn != null )
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    conn.close();
 | 
					                    conn.close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -168,25 +170,28 @@ public class sendMessage
 | 
				
			|||||||
     * 保存天气预警警报数据。
 | 
					     * 保存天气预警警报数据。
 | 
				
			||||||
     * 保存至 oracle xmcx1 数据库 wechat 表空间下 weather_disaster_notify 表。
 | 
					     * 保存至 oracle xmcx1 数据库 wechat 表空间下 weather_disaster_notify 表。
 | 
				
			||||||
     * 保存的数据用来判断预警是否已经推送过,以防止反复推送数据。
 | 
					     * 保存的数据用来判断预警是否已经推送过,以防止反复推送数据。
 | 
				
			||||||
     * @param city 城市名称
 | 
					     *
 | 
				
			||||||
 | 
					     * @param city     城市名称
 | 
				
			||||||
     * @param warning 预警数据,为 QWeatherDisasterWarningItem 对象。
 | 
					     * @param warning 预警数据,为 QWeatherDisasterWarningItem 对象。
 | 
				
			||||||
     * @throws SQLException 执行sql时可能抛出的异常。出现sql异常,就回滚事务。
 | 
					     * @throws SQLException           执行sql时可能抛出的异常。出现sql异常,就回滚事务。
 | 
				
			||||||
     * @throws IOException 读取数据库配置文件时可能抛出的异常。
 | 
					     * @throws IOException            读取数据库配置文件时可能抛出的异常。
 | 
				
			||||||
     * @throws ClassNotFoundException 加载oracle jdbc驱动时可能抛出的异常。
 | 
					     * @throws ClassNotFoundException 加载oracle jdbc驱动时可能抛出的异常。
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static void saveWeatherDisasterWarning( String city, QWeatherDisasterWarning warnings )
 | 
					    public static void saveWeatherDisasterWarning( String city,
 | 
				
			||||||
 | 
					                                                   QWeatherDisasterWarningItem warning )
 | 
				
			||||||
            throws SQLException, IOException, ClassNotFoundException
 | 
					            throws SQLException, IOException, ClassNotFoundException
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        Connection conn = null;
 | 
					        Connection        conn = null;
 | 
				
			||||||
        PreparedStatement stmt = null;
 | 
					        PreparedStatement stmt = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String sql = "insert into weather_disaster_notify(notify_id, sender, city,"
 | 
					        String sql = new StringBuilder().append( "insert into weather_disaster_notify(notify_id, sender, city," )
 | 
				
			||||||
                + "warning_level, warning_type_code, warning_type_name, title,"
 | 
					                                        .append( "warning_level, warning_type_code, warning_type_name, title," )
 | 
				
			||||||
                + "text, pub_time) values( ?,?,?,?,?,?,?,?,?)";
 | 
					                                        .append( "text, pub_time) values( ?,?,?,?,?,?,?,?,?)" )
 | 
				
			||||||
 | 
					                                        .toString();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        OracleConfig dbConfig = OracleConfigManager.getOracleConfig();
 | 
					        OracleConfig dbConfig = OracleConfigManager.getOracleConfig();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        String jdbcURL = dbConfig.getJdbcURL();
 | 
					        String jdbcURL  = dbConfig.getJdbcURL();
 | 
				
			||||||
        String userName = dbConfig.getUserName();
 | 
					        String userName = dbConfig.getUserName();
 | 
				
			||||||
        String password = dbConfig.getPassword();
 | 
					        String password = dbConfig.getPassword();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -197,23 +202,21 @@ public class sendMessage
 | 
				
			|||||||
            conn = DriverManager.getConnection( jdbcURL, userName, password );
 | 
					            conn = DriverManager.getConnection( jdbcURL, userName, password );
 | 
				
			||||||
            stmt = conn.prepareStatement( sql );
 | 
					            stmt = conn.prepareStatement( sql );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for ( QWeatherDisasterWarningItem warning : warnings.getWarning() )
 | 
					            conn.setAutoCommit( false );
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                java.sql.Timestamp pubTime =
 | 
					 | 
				
			||||||
                        new java.sql.Timestamp( warning.getPubTime().getTime() );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                stmt.setString( 1, warning.getId() );
 | 
					            java.sql.Timestamp pubTime = new java.sql.Timestamp( warning.getPubTime().getTime() );
 | 
				
			||||||
                stmt.setString( 2, warning.getSender() );
 | 
					 | 
				
			||||||
                stmt.setString( 3, city );
 | 
					 | 
				
			||||||
                stmt.setString( 4, warning.getLevel() );
 | 
					 | 
				
			||||||
                stmt.setString( 5, warning.getType() );
 | 
					 | 
				
			||||||
                stmt.setString( 6, warning.getTypeName() );
 | 
					 | 
				
			||||||
                stmt.setString( 7, warning.getTitle() );
 | 
					 | 
				
			||||||
                stmt.setString( 8, warning.getText() );
 | 
					 | 
				
			||||||
                stmt.setTimestamp( 9, pubTime );
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                stmt.execute();
 | 
					            stmt.setString( 1, warning.getId() );
 | 
				
			||||||
            }
 | 
					            stmt.setString( 2, warning.getSender() );
 | 
				
			||||||
 | 
					            stmt.setString( 3, city );
 | 
				
			||||||
 | 
					            stmt.setString( 4, warning.getLevel() );
 | 
				
			||||||
 | 
					            stmt.setString( 5, warning.getType() );
 | 
				
			||||||
 | 
					            stmt.setString( 6, warning.getTypeName() );
 | 
				
			||||||
 | 
					            stmt.setString( 7, warning.getTitle() );
 | 
				
			||||||
 | 
					            stmt.setString( 8, warning.getText() );
 | 
				
			||||||
 | 
					            stmt.setTimestamp( 9, pubTime );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            stmt.execute();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 没有问题就提交
 | 
					            // 没有问题就提交
 | 
				
			||||||
            conn.commit();
 | 
					            conn.commit();
 | 
				
			||||||
@@ -221,7 +224,7 @@ public class sendMessage
 | 
				
			|||||||
        catch ( SQLException error )
 | 
					        catch ( SQLException error )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // 出现sql错误,就回滚!
 | 
					            // 出现sql错误,就回滚!
 | 
				
			||||||
            if ( conn != null)
 | 
					            if ( conn != null )
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                conn.rollback();
 | 
					                conn.rollback();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -232,7 +235,7 @@ public class sendMessage
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if ( stmt != null)
 | 
					                if ( stmt != null )
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    stmt.close();
 | 
					                    stmt.close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -244,7 +247,7 @@ public class sendMessage
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if ( conn != null)
 | 
					                if ( conn != null )
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    conn.close();
 | 
					                    conn.close();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -256,7 +259,6 @@ public class sendMessage
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    static
 | 
					    static
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // 预警级别色彩
 | 
					        // 预警级别色彩
 | 
				
			||||||
@@ -269,50 +271,49 @@ public class sendMessage
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
class WechatOfficalAccountMessageParameter
 | 
					class WechatOfficalAccountMessageParameter
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    WechatOfficalAccountMessageParameter()
 | 
					    WechatOfficalAccountMessageParameter()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        tplID = 57;
 | 
					        tplID   = 57;
 | 
				
			||||||
        groupID = 1;
 | 
					        groupID = 1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "tplid")
 | 
					    @JsonProperty("tplid")
 | 
				
			||||||
    private int tplID;
 | 
					    private int tplID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "groupid")
 | 
					    @JsonProperty("groupid")
 | 
				
			||||||
    private int groupID;
 | 
					    private int groupID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "first")
 | 
					    @JsonProperty("first")
 | 
				
			||||||
    private String first;
 | 
					    private String first;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "keyword1")
 | 
					    @JsonProperty("keyword1")
 | 
				
			||||||
    private String keyword1;
 | 
					    private String keyword1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "keyword1color")
 | 
					    @JsonProperty("keyword1color")
 | 
				
			||||||
    private String keyword1Color;
 | 
					    private String keyword1Color;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "keyword2")
 | 
					    @JsonProperty("keyword2")
 | 
				
			||||||
    private String keyword2;
 | 
					    private String keyword2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "keyword2color")
 | 
					    @JsonProperty("keyword2color")
 | 
				
			||||||
    private String keyword2Color;
 | 
					    private String keyword2Color;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "remark")
 | 
					    @JsonProperty("remark")
 | 
				
			||||||
    private String remark;
 | 
					    private String remark;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "remarkcolor")
 | 
					    @JsonProperty("remarkcolor")
 | 
				
			||||||
    private String remarkColor;
 | 
					    private String remarkColor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "url")
 | 
					    @JsonProperty("url")
 | 
				
			||||||
    private String url;
 | 
					    private String url;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "appid")
 | 
					    @JsonProperty("appid")
 | 
				
			||||||
    private String appid;
 | 
					    private String appid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @JsonProperty( "pagepath")
 | 
					    @JsonProperty("pagepath")
 | 
				
			||||||
    private String pagePath;
 | 
					    private String pagePath;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public int getTplID()
 | 
					    public int getTplID()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
 * @Author: Kane
 | 
					 * @Author: Kane
 | 
				
			||||||
 * @Date: 2022-04-22 10:53:49
 | 
					 * @Date: 2022-04-22 10:53:49
 | 
				
			||||||
 * @LastEditors: Kane
 | 
					 * @LastEditors: Kane
 | 
				
			||||||
 * @LastEditTime: 2022-05-10 11:33:41
 | 
					 * @LastEditTime: 2022-05-12 09:54:36
 | 
				
			||||||
 * @FilePath: \DisasterWarning\src\test\java\com\cpic\xim\wechat\officalAccount\sendMessageTest.java
 | 
					 * @FilePath: \DisasterWarning\src\test\java\com\cpic\xim\wechat\officalAccount\sendMessageTest.java
 | 
				
			||||||
 * @Description:
 | 
					 * @Description:
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
@@ -75,7 +75,7 @@ public class sendMessageTest
 | 
				
			|||||||
            String city = "东山县";
 | 
					            String city = "东山县";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            sendMessage.saveWeatherDisasterWarning( city, warning );
 | 
					            // sendMessage.saveWeatherDisasterWarning( city, warning );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        catch ( Exception error )
 | 
					        catch ( Exception error )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,6 +8,14 @@
 | 
				
			|||||||
        {
 | 
					        {
 | 
				
			||||||
            "city_name": "厦门",
 | 
					            "city_name": "厦门",
 | 
				
			||||||
            "city_code": "101230201"
 | 
					            "city_code": "101230201"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "city_name": "同安",
 | 
				
			||||||
 | 
					            "city_code": "101230202"
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "city_name": "翔安",
 | 
				
			||||||
 | 
					            "city_code": "101230207"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "notify_stuffs": [
 | 
					    "notify_stuffs": [
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								应用/1.0/run.bat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								应用/1.0/run.bat
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					java -jar disaster_warning-1.0-SNAPSHOT-jar-with-dependencies.jar
 | 
				
			||||||
 | 
					pause
 | 
				
			||||||
@@ -19,5 +19,5 @@
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "refer": { "sources": ["12379"], "license": ["no commercial use"] },
 | 
					    "refer": { "sources": ["12379"], "license": ["no commercial use"] },
 | 
				
			||||||
    "testURL": "https://devapi.qweather.com/v7/warning/now?key=fe9fa8eeeb6f4301a92541eed565dd15&location=101230608"
 | 
					    "testURL": "https://devapi.qweather.com/v7/warning/now?key=fe9fa8eeeb6f4301a92541eed565dd15&location=101230201"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user