Compare commits
	
		
			4 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 1231fe3132 | |||
| fbe9f8e532 | |||
| 53849e4f74 | |||
| d1bcb3b956 | 
							
								
								
									
										3
									
								
								code/java/DisasterWarning/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								code/java/DisasterWarning/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -134,3 +134,6 @@ $RECYCLE.BIN/
 | 
			
		||||
*.lnk
 | 
			
		||||
 | 
			
		||||
target/*
 | 
			
		||||
 | 
			
		||||
logs/*
 | 
			
		||||
logs
 | 
			
		||||
							
								
								
									
										10
									
								
								code/java/DisasterWarning/logging.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								code/java/DisasterWarning/logging.properties
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
 | 
			
		||||
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
 | 
			
		||||
 | 
			
		||||
.level = INFO
 | 
			
		||||
 | 
			
		||||
java.util.logging.FileHandler.pattern = ./logs/log_%u.log
 | 
			
		||||
java.util.logging.FileHandler.limit = 50000
 | 
			
		||||
java.util.logging.FileHandler.count = 1
 | 
			
		||||
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
 | 
			
		||||
java.util.logging.FileHandler.append = true;
 | 
			
		||||
@@ -23,7 +23,7 @@
 | 
			
		||||
            <version>4.13.2</version>
 | 
			
		||||
            <scope>test</scope>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
        <!-- <dependency>
 | 
			
		||||
            <groupId>commons-beanutils</groupId>
 | 
			
		||||
            <artifactId>commons-beanutils</artifactId>
 | 
			
		||||
            <version>1.9.4</version>
 | 
			
		||||
@@ -53,7 +53,7 @@
 | 
			
		||||
            <artifactId>json-lib</artifactId>
 | 
			
		||||
            <version>2.4</version>
 | 
			
		||||
            <classifier>jdk15</classifier>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        </dependency> -->
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>com.fasterxml.jackson.core</groupId>
 | 
			
		||||
            <artifactId>jackson-core</artifactId>
 | 
			
		||||
@@ -79,10 +79,39 @@
 | 
			
		||||
    </properties>
 | 
			
		||||
    <build>
 | 
			
		||||
        <defaultGoal>compile</defaultGoal>
 | 
			
		||||
 | 
			
		||||
        <plugins>
 | 
			
		||||
            <!-- <plugin>
 | 
			
		||||
            <plugin>
 | 
			
		||||
                <groupId>org.apache.maven.plugins</groupId>
 | 
			
		||||
                <artifactId>maven-surefire-plugin</artifactId>
 | 
			
		||||
                <version>3.0.0-M6</version>
 | 
			
		||||
                <configuration>
 | 
			
		||||
                    <skipTests>true</skipTests>
 | 
			
		||||
                </configuration>
 | 
			
		||||
            </plugin>
 | 
			
		||||
            <plugin>
 | 
			
		||||
                <groupId>org.apache.maven.plugins</groupId>
 | 
			
		||||
                <artifactId>maven-assembly-plugin</artifactId>
 | 
			
		||||
            </plugin> -->
 | 
			
		||||
                <configuration>
 | 
			
		||||
                    <descriptorRefs>
 | 
			
		||||
                        <descriptorRef>jar-with-dependencies</descriptorRef>
 | 
			
		||||
                    </descriptorRefs>
 | 
			
		||||
                    <archive>
 | 
			
		||||
                        <manifest>
 | 
			
		||||
                            <mainClass>AppMain</mainClass>
 | 
			
		||||
                        </manifest>
 | 
			
		||||
                    </archive>
 | 
			
		||||
                </configuration>
 | 
			
		||||
                <executions>
 | 
			
		||||
                    <execution>
 | 
			
		||||
                        <id>make-assmenbly</id>
 | 
			
		||||
                        <phase>package</phase>
 | 
			
		||||
                        <goals>
 | 
			
		||||
                            <goal>single</goal>
 | 
			
		||||
                        </goals>
 | 
			
		||||
                    </execution>
 | 
			
		||||
                </executions>
 | 
			
		||||
            </plugin>
 | 
			
		||||
        </plugins>
 | 
			
		||||
    </build>
 | 
			
		||||
    <profiles>
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2022-04-22 10:53:49
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @LastEditTime: 2022-05-06 11:08:07
 | 
			
		||||
 * @LastEditTime: 2022-05-10 16:01:13
 | 
			
		||||
 * @FilePath: \DisasterWarning\src\main\java\AppMain.java
 | 
			
		||||
 * @Description: 和风天气预警推送厦门太保公众号主程序!
 | 
			
		||||
 * 
 | 
			
		||||
@@ -13,7 +13,7 @@ import com.cpic.xim.notify.disaster.QWeatherDisasterWarning;
 | 
			
		||||
import com.cpic.xim.notify.disaster.WeatherDisasterWarningGrabber;
 | 
			
		||||
import com.cpic.xim.wechat.officalAccount.sendMessage;
 | 
			
		||||
import com.cpic.xim.config.WeatherDisasterNotifyConfig;
 | 
			
		||||
 | 
			
		||||
import java.io.FileInputStream;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.sql.SQLException;
 | 
			
		||||
import java.util.Vector;
 | 
			
		||||
@@ -22,7 +22,7 @@ import java.util.logging.*;
 | 
			
		||||
 | 
			
		||||
public class AppMain
 | 
			
		||||
{
 | 
			
		||||
    private final static String LOG_FILE_PATH = "./app.log";
 | 
			
		||||
    // private final static String LOG_FILE_PATH = "./logs/app%u.log";
 | 
			
		||||
 | 
			
		||||
    public static void main( String[] args )
 | 
			
		||||
    {
 | 
			
		||||
@@ -45,7 +45,6 @@ public class AppMain
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // 读取配置
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
@@ -80,6 +79,8 @@ public class AppMain
 | 
			
		||||
                // 判断是否有警报
 | 
			
		||||
                if ( warning.getWarning().isEmpty() == true)
 | 
			
		||||
                {
 | 
			
		||||
                    logger.log( Level.INFO, "查询{0}天气预警,无警报!。", new Object[]
 | 
			
		||||
                    { city.getCityName()} );
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
@@ -126,17 +127,29 @@ public class AppMain
 | 
			
		||||
     */
 | 
			
		||||
    private static void setRootLogger() throws IOException
 | 
			
		||||
    {
 | 
			
		||||
        // Logger rootLogger = Logger.getLogger( "com.cpicxim" );
 | 
			
		||||
        // ConsoleHandler consoleHandler = new ConsoleHandler();
 | 
			
		||||
        // FileHandler fileHandler = new FileHandler( LOG_FILE_PATH );
 | 
			
		||||
        // SimpleFormatter formatter = new SimpleFormatter();
 | 
			
		||||
 | 
			
		||||
        // consoleHandler.setFormatter( formatter );
 | 
			
		||||
        // fileHandler.setFormatter( formatter );
 | 
			
		||||
 | 
			
		||||
        // rootLogger.addHandler( consoleHandler );
 | 
			
		||||
        // rootLogger.addHandler( fileHandler );
 | 
			
		||||
 | 
			
		||||
        // rootLogger.setUseParentHandlers( false );
 | 
			
		||||
        // rootLogger.setLevel( Level.ALL );
 | 
			
		||||
 | 
			
		||||
        LogManager logManager = LogManager.getLogManager();
 | 
			
		||||
        // 使用外部的配置文件。
 | 
			
		||||
        FileInputStream configFile = new FileInputStream( "./logging.properties" );
 | 
			
		||||
        // 使用jar中的配置文件。
 | 
			
		||||
        // InputStream configFile =
 | 
			
		||||
        // AppMain.class.getClassLoader().getResourceAsStream( "logging.properties" );
 | 
			
		||||
 | 
			
		||||
        logManager.readConfiguration( configFile );
 | 
			
		||||
 | 
			
		||||
        Logger rootLogger = Logger.getLogger( "com.cpicxim" );
 | 
			
		||||
        ConsoleHandler consoleHandler = new ConsoleHandler();
 | 
			
		||||
        FileHandler fileHandler = new FileHandler( LOG_FILE_PATH );
 | 
			
		||||
        SimpleFormatter formatter = new SimpleFormatter();
 | 
			
		||||
 | 
			
		||||
        consoleHandler.setFormatter( formatter );
 | 
			
		||||
        fileHandler.setFormatter( formatter );
 | 
			
		||||
        rootLogger.addHandler( consoleHandler );
 | 
			
		||||
        rootLogger.addHandler( fileHandler );
 | 
			
		||||
 | 
			
		||||
        rootLogger.setUseParentHandlers( false );
 | 
			
		||||
        rootLogger.setLevel( Level.ALL );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,10 @@
 | 
			
		||||
 | 
			
		||||
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
 | 
			
		||||
 | 
			
		||||
.level = INFO
 | 
			
		||||
 | 
			
		||||
java.util.logging.FileHandler.pattern = ./logs/log_%u.log
 | 
			
		||||
java.util.logging.FileHandler.limit = 50000
 | 
			
		||||
java.util.logging.FileHandler.count = 10
 | 
			
		||||
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
 | 
			
		||||
java.util.logging.FileHandler.append = true;
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
 * @Author: Kane
 | 
			
		||||
 * @Date: 2022-04-22 10:53:49
 | 
			
		||||
 * @LastEditors: Kane
 | 
			
		||||
 * @LastEditTime: 2022-05-06 11:14:35
 | 
			
		||||
 * @LastEditTime: 2022-05-10 11:33:41
 | 
			
		||||
 * @FilePath: \DisasterWarning\src\test\java\com\cpic\xim\wechat\officalAccount\sendMessageTest.java
 | 
			
		||||
 * @Description:
 | 
			
		||||
 *
 | 
			
		||||
@@ -12,7 +12,6 @@ package com.cpic.xim.wechat.officalAccount;
 | 
			
		||||
 | 
			
		||||
import com.cpic.xim.notify.disaster.QWeatherDisasterWarning;
 | 
			
		||||
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import static org.junit.Assert.*;
 | 
			
		||||
import com.cpic.xim.httpUtil.*;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
@@ -61,7 +60,7 @@ public class sendMessageTest
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    // @Test
 | 
			
		||||
    public void testSendWeatherDisasterWarning() throws IOException
 | 
			
		||||
    {
 | 
			
		||||
        String warningJSON =
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user