xxx
This commit is contained in:
parent
c988bf4c91
commit
cba061e177
@ -2,7 +2,7 @@
|
||||
* @Author: Kane
|
||||
* @Date: 2022-04-22 10:53:49
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2022-05-12 09:51:13
|
||||
* @LastEditTime: 2022-12-16 15:51:36
|
||||
* @FilePath: \DisasterWarning\src\main\java\com\cpic\xim\wechat\officalAccount\sendMessage.java
|
||||
* @Description: 用来推送公众号消息的程序库。
|
||||
*
|
||||
@ -37,15 +37,15 @@ public class sendMessage
|
||||
{
|
||||
private static HashMap<String, String> warningLevel;
|
||||
|
||||
/**
|
||||
/*****************************************************
|
||||
* 推送天气灾害预警!接口文档参考 彭奕洁 编写《消息发送接口调用文档》
|
||||
* 使用 post 方式,请求体内容以最基础的 post 格式。
|
||||
*
|
||||
* @param officalAccountURL 产险厦门分公司公众号接口网址
|
||||
* @param warningItem 灾害预警对象
|
||||
*/
|
||||
*****************************************************/
|
||||
public static void sendWeatherDisasterWarning( String officalAccountURL,
|
||||
QWeatherDisasterWarningItem warningItem )
|
||||
QWeatherDisasterWarningItem warningItem )
|
||||
{
|
||||
// Vector<QWeatherDisasterWarningItem> warningItems = warningItem.getWarning();
|
||||
StringBuilder requestBody = null;
|
||||
@ -61,7 +61,7 @@ public class sendMessage
|
||||
|
||||
// 拼接消息内容
|
||||
String title = warningItem.getTitle();
|
||||
String text = warningItem.getText();
|
||||
String text = warningItem.getText();
|
||||
String color = warningLevel.containsKey( warningItem.getLevel() )
|
||||
? warningLevel.get( warningItem.getLevel() )
|
||||
: "#000000";
|
||||
@ -98,14 +98,14 @@ public class sendMessage
|
||||
|
||||
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" );
|
||||
|
||||
@ -119,7 +119,7 @@ public class sendMessage
|
||||
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
if ( rs.next() && rs.getInt( 1 ) == 0 )
|
||||
if ( rs.next() && rs.getInt( 1 ) == 0)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
@ -128,7 +128,7 @@ public class sendMessage
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( rs != null )
|
||||
if ( rs != null)
|
||||
{
|
||||
rs.close();
|
||||
}
|
||||
@ -140,7 +140,7 @@ public class sendMessage
|
||||
|
||||
try
|
||||
{
|
||||
if ( stmt != null )
|
||||
if ( stmt != null)
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
@ -152,7 +152,7 @@ public class sendMessage
|
||||
|
||||
try
|
||||
{
|
||||
if ( conn != null )
|
||||
if ( conn != null)
|
||||
{
|
||||
conn.close();
|
||||
}
|
||||
@ -178,20 +178,20 @@ public class sendMessage
|
||||
* @throws ClassNotFoundException 加载oracle jdbc驱动时可能抛出的异常。
|
||||
*/
|
||||
public static void saveWeatherDisasterWarning( String city,
|
||||
QWeatherDisasterWarningItem warning )
|
||||
QWeatherDisasterWarningItem warning )
|
||||
throws SQLException, IOException, ClassNotFoundException
|
||||
{
|
||||
Connection conn = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
|
||||
String sql = new StringBuilder().append( "insert into weather_disaster_notify(notify_id, sender, city," )
|
||||
.append( "warning_level, warning_type_code, warning_type_name, title," )
|
||||
.append( "text, pub_time) values( ?,?,?,?,?,?,?,?,?)" )
|
||||
.toString();
|
||||
String sql = new StringBuilder()
|
||||
.append( "insert into weather_disaster_notify(notify_id, sender, city," )
|
||||
.append( "warning_level, warning_type_code, warning_type_name, title," )
|
||||
.append( "text, pub_time) values( ?,?,?,?,?,?,?,?,?)" ).toString();
|
||||
|
||||
OracleConfig dbConfig = OracleConfigManager.getOracleConfig();
|
||||
|
||||
String jdbcURL = dbConfig.getJdbcURL();
|
||||
String jdbcURL = dbConfig.getJdbcURL();
|
||||
String userName = dbConfig.getUserName();
|
||||
String password = dbConfig.getPassword();
|
||||
|
||||
@ -224,7 +224,7 @@ public class sendMessage
|
||||
catch ( SQLException error )
|
||||
{
|
||||
// 出现sql错误,就回滚!
|
||||
if ( conn != null )
|
||||
if ( conn != null)
|
||||
{
|
||||
conn.rollback();
|
||||
}
|
||||
@ -235,7 +235,7 @@ public class sendMessage
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( stmt != null )
|
||||
if ( stmt != null)
|
||||
{
|
||||
stmt.close();
|
||||
}
|
||||
@ -247,7 +247,7 @@ public class sendMessage
|
||||
|
||||
try
|
||||
{
|
||||
if ( conn != null )
|
||||
if ( conn != null)
|
||||
{
|
||||
conn.close();
|
||||
}
|
||||
@ -271,49 +271,50 @@ public class sendMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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