...
This commit is contained in:
parent
9c1f141a00
commit
1e8e58d3de
|
@ -2,7 +2,7 @@
|
|||
* @Author: Kane
|
||||
* @Date: 2022-04-22 10:53:49
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2022-04-22 23:04:58
|
||||
* @LastEditTime: 2022-04-22 23:48:28
|
||||
* @FilePath: \DisasterWarning\src\main\java\com\cpic\xim\wechat\officalAccount\sendMessage.java
|
||||
* @Description: 用来推送公众号消息的程序库。
|
||||
*
|
||||
|
@ -27,7 +27,7 @@ import com.cpic.xim.notify.disaster.*;
|
|||
|
||||
/**
|
||||
* 推送微信公众号消息。
|
||||
*
|
||||
* @Description
|
||||
* @author Kane
|
||||
*/
|
||||
public class sendMessage
|
||||
|
@ -64,14 +64,14 @@ public class sendMessage
|
|||
|
||||
json = mapper.writeValueAsString( param );
|
||||
|
||||
if ( json.isEmpty() )
|
||||
if ( json.isEmpty())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
System.out.println( json );
|
||||
}
|
||||
catch ( JsonProcessingException error )
|
||||
catch (JsonProcessingException error)
|
||||
{
|
||||
error.printStackTrace();
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class sendMessage
|
|||
}
|
||||
|
||||
// 推送数据
|
||||
URL url;
|
||||
URL url = null;
|
||||
HttpURLConnection connection = null;
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
@ -107,14 +107,14 @@ public class sendMessage
|
|||
|
||||
String line = in.readLine();
|
||||
|
||||
while ( line != null )
|
||||
while (line != null)
|
||||
{
|
||||
result.append( line );
|
||||
|
||||
line = in.readLine();
|
||||
}
|
||||
}
|
||||
catch ( Exception error )
|
||||
catch (Exception error)
|
||||
{
|
||||
error.printStackTrace();
|
||||
}
|
||||
|
@ -122,22 +122,22 @@ public class sendMessage
|
|||
{
|
||||
try
|
||||
{
|
||||
if ( in != null )
|
||||
if ( in != null)
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
|
||||
if ( out != null )
|
||||
if ( out != null)
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
|
||||
if ( connection != null )
|
||||
if ( connection != null)
|
||||
{
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
catch ( Exception error )
|
||||
catch (Exception error)
|
||||
{
|
||||
error.printStackTrace();
|
||||
}
|
||||
|
@ -147,7 +147,6 @@ public class sendMessage
|
|||
|
||||
/**
|
||||
* 推送天气灾害预警!接口文档参考 彭奕洁 编写《消息发送接口调用文档》
|
||||
*
|
||||
* @param officalAccountURL 产险厦门分公司公众号接口网址
|
||||
* @param warning 灾害警报对象
|
||||
*/
|
||||
|
@ -164,7 +163,7 @@ public class sendMessage
|
|||
headers.put( "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8" );
|
||||
|
||||
// 遍历消息,将消息推送出去。
|
||||
for ( QWeatherDisasterWarningItem item : warningItems )
|
||||
for ( QWeatherDisasterWarningItem item : warningItems)
|
||||
{
|
||||
// 拼接消息内容
|
||||
String title = item.getTitle();
|
||||
|
@ -195,40 +194,40 @@ class WechatOfficalAccountMessageParameter
|
|||
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…
Reference in New Issue