提交小修改!
This commit is contained in:
parent
24cdc66b7d
commit
2d1d4dea66
@ -2,7 +2,7 @@
|
||||
* @Author: Kane
|
||||
* @Date: 2022-04-22 10:53:49
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2022-04-27 17:35:06
|
||||
* @LastEditTime: 2022-04-27 22:55:44
|
||||
* @FilePath: \DisasterWarning\src\main\java\com\cpic\xim\wechat\officalAccount\sendMessage.java
|
||||
* @Description: 用来推送公众号消息的程序库。
|
||||
*
|
||||
@ -39,7 +39,7 @@ public class sendMessage
|
||||
|
||||
/**
|
||||
* 推送天气灾害预警!接口文档参考 彭奕洁 编写《消息发送接口调用文档》
|
||||
*
|
||||
* 使用 post 方式,请求体内容以最基础的 post 格式。
|
||||
* @param officalAccountURL 产险厦门分公司公众号接口网址
|
||||
* @param warning 灾害预警对象
|
||||
*/
|
||||
@ -84,9 +84,11 @@ public class sendMessage
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param warningID
|
||||
* @return
|
||||
* 检查预警是否已经推送过,通过 QWeatherDisasterWarningItem 对象的 id 属性。
|
||||
* 查询 oracle xmcx1 数据库 wechat 表空间下 weather_disaster_notify 表,
|
||||
* 统计 warningID 的数量,如果不为0,说明该预警已经保存过,视为已经推送过。
|
||||
* @param warningID 预警的id
|
||||
* @return 如果推送过,返回false,否则返回 true。
|
||||
*/
|
||||
public static boolean checkWarningHasSended( String warningID )
|
||||
throws ClassNotFoundException, SQLException, IOException
|
||||
@ -123,25 +125,108 @@ public class sendMessage
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( rs != null)
|
||||
try
|
||||
{
|
||||
rs.close();
|
||||
if ( rs != null)
|
||||
{
|
||||
rs.close();
|
||||
}
|
||||
}
|
||||
catch ( Exception error )
|
||||
{
|
||||
error.printStackTrace();
|
||||
}
|
||||
|
||||
if ( stmt != null)
|
||||
try
|
||||
{
|
||||
stmt.close();
|
||||
if ( stmt != null)
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
}
|
||||
catch ( Exception error )
|
||||
{
|
||||
error.printStackTrace();
|
||||
}
|
||||
|
||||
if ( conn != null)
|
||||
try
|
||||
{
|
||||
conn.close();
|
||||
if ( conn != null)
|
||||
{
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
catch ( Exception error )
|
||||
{
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存天气预警警报数据。
|
||||
* 保存至 oracle xmcx1 数据库 wechat 表空间下 weather_disaster_notify 表。
|
||||
* 保存的数据用来判断预警是否已经推送过,以防止反复推送数据。
|
||||
* @param city 城市名称
|
||||
* @param warning 预警数据,为 QWeatherDisasterWarningItem 对象。
|
||||
* @throws SQLException 执行sql时可能抛出的异常。
|
||||
* @throws IOException 读取数据库配置文件时可能抛出的异常。
|
||||
* @throws ClassNotFoundException 加载oracle jdbc驱动时可能抛出的异常。
|
||||
*/
|
||||
public static void saveWeatherDisasterWarning( String city,
|
||||
QWeatherDisasterWarningItem warning )
|
||||
throws SQLException, IOException, ClassNotFoundException
|
||||
{
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
String sql = "";
|
||||
|
||||
OracleConfig dbConfig = OracleConfigLoader.getOracleConfig();
|
||||
|
||||
String jdbcURL = dbConfig.getJdbcURL();
|
||||
String userName = dbConfig.getUserName();
|
||||
String password = dbConfig.getPassword();
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName( "oracle.jdbc.driver.OracleDriver" );
|
||||
|
||||
conn = DriverManager.getConnection( jdbcURL, userName, password );
|
||||
stmt = conn.prepareStatement( sql );
|
||||
stmt.execute();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( stmt != null)
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
}
|
||||
catch ( Exception error )
|
||||
{
|
||||
error.printStackTrace();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( conn != null)
|
||||
{
|
||||
conn.close();
|
||||
}
|
||||
}
|
||||
catch ( Exception error )
|
||||
{
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
{
|
||||
// 预警级别色彩
|
||||
|
Loading…
x
Reference in New Issue
Block a user