Merge branch 'develop' of http://cppdisciple.f3322.org:3000/CPICXIM/disaster_warrning into develop
This commit is contained in:
commit
cd8bcb8ba0
@ -21,17 +21,13 @@
|
||||
<SOURCES />
|
||||
</library>
|
||||
</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: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" 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" 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-databind: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!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Maven: commons-beanutils:commons-beanutils:1.9.4">
|
||||
<library name="Maven: com.oracle:ojdbc8:19.3.0.0.0">
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
</library>
|
||||
<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!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Maven: commons-collections:commons-collections:20040616">
|
||||
<library name="Maven: commons-logging:commons-logging:1.2">
|
||||
<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>
|
||||
<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>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/20040616/commons-collections-20040616-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!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<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!/" />
|
||||
</SOURCES>
|
||||
</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">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar!/" />
|
||||
|
@ -14,6 +14,7 @@ import com.cpic.xim.config.db.OracleConfigManager;
|
||||
import com.cpic.xim.config.db.OracleConfig;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.HashMap;
|
||||
@ -23,12 +24,13 @@ import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.cpic.xim.notify.disaster.*;
|
||||
import com.cpic.xim.httpUtil.HttpUtils;
|
||||
|
||||
/**
|
||||
* 推送微信公众号消息。
|
||||
*
|
||||
*
|
||||
* @author Kane
|
||||
*/
|
||||
public class sendMessage
|
||||
@ -38,11 +40,12 @@ public class sendMessage
|
||||
/**
|
||||
* 推送天气灾害预警!接口文档参考 彭奕洁 编写《消息发送接口调用文档》
|
||||
* 使用 post 方式,请求体内容以最基础的 post 格式。
|
||||
*
|
||||
* @param officalAccountURL 产险厦门分公司公众号接口网址
|
||||
* @param warningItem 灾害预警对象
|
||||
* @param warningItem 灾害预警对象
|
||||
*/
|
||||
public static void sendWeatherDisasterWarning( String officalAccountURL,
|
||||
QWeatherDisasterWarningItem warningItem )
|
||||
QWeatherDisasterWarningItem warningItem )
|
||||
{
|
||||
// Vector<QWeatherDisasterWarningItem> warningItems = warningItem.getWarning();
|
||||
StringBuilder requestBody = null;
|
||||
@ -58,7 +61,7 @@ public class sendMessage
|
||||
|
||||
// 拼接消息内容
|
||||
String title = warningItem.getTitle();
|
||||
String text = warningItem.getText();
|
||||
String text = warningItem.getText();
|
||||
String color = warningLevel.keySet().contains( warningItem.getLevel() )
|
||||
? warningLevel.get( warningItem.getLevel() )
|
||||
: "#000000";
|
||||
@ -84,6 +87,7 @@ public class sendMessage
|
||||
* 检查预警是否已经推送过,通过 QWeatherDisasterWarningItem 对象的 id 属性。
|
||||
* 查询 oracle xmcx1 数据库 wechat 表空间下 weather_disaster_notify 表,
|
||||
* 统计 warningID 的数量,如果不为0,说明该预警已经保存过,视为已经推送过。
|
||||
*
|
||||
* @param warningID 预警的id
|
||||
* @return 如果推送过,返回false,否则返回 true。
|
||||
*/
|
||||
@ -92,16 +96,17 @@ public class sendMessage
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
OracleConfig dbConfig = OracleConfigManager.getOracleConfig();;
|
||||
OracleConfig dbConfig = OracleConfigManager.getOracleConfig();
|
||||
;
|
||||
|
||||
Connection conn = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
String jdbcURL = dbConfig.getJdbcURL();
|
||||
String jdbcURL = dbConfig.getJdbcURL();
|
||||
String userName = dbConfig.getUserName();
|
||||
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" );
|
||||
|
||||
@ -115,7 +120,7 @@ public class sendMessage
|
||||
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
if ( rs.next() && rs.getInt( 1 ) == 0)
|
||||
if ( rs.next() && rs.getInt( 1 ) == 0 )
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
@ -124,7 +129,7 @@ public class sendMessage
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( rs != null)
|
||||
if ( rs != null )
|
||||
{
|
||||
rs.close();
|
||||
}
|
||||
@ -136,7 +141,7 @@ public class sendMessage
|
||||
|
||||
try
|
||||
{
|
||||
if ( stmt != null)
|
||||
if ( stmt != null )
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
@ -148,7 +153,7 @@ public class sendMessage
|
||||
|
||||
try
|
||||
{
|
||||
if ( conn != null)
|
||||
if ( conn != null )
|
||||
{
|
||||
conn.close();
|
||||
}
|
||||
@ -166,17 +171,18 @@ public class sendMessage
|
||||
* 保存天气预警警报数据。
|
||||
* 保存至 oracle xmcx1 数据库 wechat 表空间下 weather_disaster_notify 表。
|
||||
* 保存的数据用来判断预警是否已经推送过,以防止反复推送数据。
|
||||
* @param city 城市名称
|
||||
* @param warning 预警数据,为 QWeatherDisasterWarningItem 对象。
|
||||
* @throws SQLException 执行sql时可能抛出的异常。出现sql异常,就回滚事务。
|
||||
* @throws IOException 读取数据库配置文件时可能抛出的异常。
|
||||
*
|
||||
* @param city 城市名称
|
||||
* @param warnings 预警数据,为 QWeatherDisasterWarningItem 对象。
|
||||
* @throws SQLException 执行sql时可能抛出的异常。出现sql异常,就回滚事务。
|
||||
* @throws IOException 读取数据库配置文件时可能抛出的异常。
|
||||
* @throws ClassNotFoundException 加载oracle jdbc驱动时可能抛出的异常。
|
||||
*/
|
||||
public static void saveWeatherDisasterWarning( String city,
|
||||
QWeatherDisasterWarningItem warning )
|
||||
throws SQLException, IOException, ClassNotFoundException
|
||||
{
|
||||
Connection conn = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
String sql = "insert into weather_disaster_notify(notify_id, sender, city,"
|
||||
@ -185,7 +191,7 @@ public class sendMessage
|
||||
|
||||
OracleConfig dbConfig = OracleConfigManager.getOracleConfig();
|
||||
|
||||
String jdbcURL = dbConfig.getJdbcURL();
|
||||
String jdbcURL = dbConfig.getJdbcURL();
|
||||
String userName = dbConfig.getUserName();
|
||||
String password = dbConfig.getPassword();
|
||||
|
||||
@ -218,7 +224,7 @@ public class sendMessage
|
||||
catch ( SQLException error )
|
||||
{
|
||||
// 出现sql错误,就回滚!
|
||||
if ( conn != null)
|
||||
if ( conn != null )
|
||||
{
|
||||
conn.rollback();
|
||||
}
|
||||
@ -229,7 +235,7 @@ public class sendMessage
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( stmt != null)
|
||||
if ( stmt != null )
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
@ -241,7 +247,7 @@ public class sendMessage
|
||||
|
||||
try
|
||||
{
|
||||
if ( conn != null)
|
||||
if ( conn != null )
|
||||
{
|
||||
conn.close();
|
||||
}
|
||||
@ -272,44 +278,44 @@ class WechatOfficalAccountMessageParameter
|
||||
|
||||
WechatOfficalAccountMessageParameter()
|
||||
{
|
||||
tplID = 57;
|
||||
tplID = 57;
|
||||
groupID = 1;
|
||||
}
|
||||
|
||||
@JsonProperty( "tplid")
|
||||
@JsonProperty("tplid")
|
||||
private int tplID;
|
||||
|
||||
@JsonProperty( "groupid")
|
||||
@JsonProperty("groupid")
|
||||
private int groupID;
|
||||
|
||||
@JsonProperty( "first")
|
||||
@JsonProperty("first")
|
||||
private String first;
|
||||
|
||||
@JsonProperty( "keyword1")
|
||||
@JsonProperty("keyword1")
|
||||
private String keyword1;
|
||||
|
||||
@JsonProperty( "keyword1color")
|
||||
@JsonProperty("keyword1color")
|
||||
private String keyword1Color;
|
||||
|
||||
@JsonProperty( "keyword2")
|
||||
@JsonProperty("keyword2")
|
||||
private String keyword2;
|
||||
|
||||
@JsonProperty( "keyword2color")
|
||||
@JsonProperty("keyword2color")
|
||||
private String keyword2Color;
|
||||
|
||||
@JsonProperty( "remark")
|
||||
@JsonProperty("remark")
|
||||
private String remark;
|
||||
|
||||
@JsonProperty( "remarkcolor")
|
||||
@JsonProperty("remarkcolor")
|
||||
private String remarkColor;
|
||||
|
||||
@JsonProperty( "url")
|
||||
@JsonProperty("url")
|
||||
private String url;
|
||||
|
||||
@JsonProperty( "appid")
|
||||
@JsonProperty("appid")
|
||||
private String appid;
|
||||
|
||||
@JsonProperty( "pagepath")
|
||||
@JsonProperty("pagepath")
|
||||
private String pagePath;
|
||||
|
||||
public int getTplID()
|
||||
|
Loading…
x
Reference in New Issue
Block a user