提交小修改!
This commit is contained in:
parent
f1c1d5a4a5
commit
9c1f141a00
@ -21,12 +21,13 @@
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" 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-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" />
|
||||
@ -34,14 +35,5 @@
|
||||
<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" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="Maven: com.oracle:ojdbc8:12.2.0.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/ojdbc8.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
@ -21,6 +21,8 @@
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
<component name="Encoding" native2AsciiForPropertiesFiles="true" defaultCharsetForPropertiesFiles="UTF-8">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
<component name="ExportToHTMLSettings">
|
||||
@ -265,37 +267,37 @@
|
||||
<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.3">
|
||||
<library name="Maven: commons-beanutils:commons-beanutils:1.9.4">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.3/commons-beanutils-1.9.3-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Maven: commons-codec:commons-codec:1.9">
|
||||
<library name="Maven: commons-codec:commons-codec:1.11">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.9/commons-codec-1.9.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.11/commons-codec-1.11.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.9/commons-codec-1.9-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.11/commons-codec-1.11-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.9/commons-codec-1.9-sources.jar!/" />
|
||||
<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:3.2.1">
|
||||
<library name="Maven: commons-collections:commons-collections:20040616">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/20040616/commons-collections-20040616.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/20040616/commons-collections-20040616-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-sources.jar!/" />
|
||||
<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">
|
||||
@ -320,15 +322,15 @@
|
||||
<root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Maven: junit:junit:4.4">
|
||||
<library name="Maven: junit:junit:4.13.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.4/junit-4.4.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.2/junit-4.13.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.4/junit-4.4-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.2/junit-4.13.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.4/junit-4.4-sources.jar!/" />
|
||||
<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">
|
||||
@ -353,26 +355,37 @@
|
||||
<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.2">
|
||||
<library name="Maven: org.apache.httpcomponents:httpclient:4.5.13">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.2/httpclient-4.5.2.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.2/httpclient-4.5.2-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.2/httpclient-4.5.2-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Maven: org.apache.httpcomponents:httpcore:4.4.4">
|
||||
<library name="Maven: org.apache.httpcomponents:httpcore:4.4.13">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4-javadoc.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.4/httpcore-4.4.4-sources.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Maven: org.hamcrest:hamcrest-core:1.3">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
|
@ -2,11 +2,11 @@
|
||||
* @Author: Kane
|
||||
* @Date: 2022-04-22 10:53:49
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2022-04-22 17:20:22
|
||||
* @LastEditTime: 2022-04-22 23:04:58
|
||||
* @FilePath: \DisasterWarning\src\main\java\com\cpic\xim\wechat\officalAccount\sendMessage.java
|
||||
* @Description: 用来推送公众号消息的程序库。
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
package com.cpic.xim.wechat.officalAccount;
|
||||
|
||||
@ -27,7 +27,7 @@ import com.cpic.xim.notify.disaster.*;
|
||||
|
||||
/**
|
||||
* 推送微信公众号消息。
|
||||
*
|
||||
*
|
||||
* @author Kane
|
||||
*/
|
||||
public class sendMessage
|
||||
@ -38,12 +38,12 @@ public class sendMessage
|
||||
* 向公众号推送通知消息。接口文档参考 彭奕洁 编写《消息发送接口调用文档》
|
||||
*
|
||||
* @param wechatOfficalAccountURL 公众号接口网址。
|
||||
* @param title 通知的标题。
|
||||
* @param notifyType 通知类型。
|
||||
* @param notifyMessage 通知文本内容。
|
||||
* @param title 通知的标题。
|
||||
* @param notifyType 通知类型。
|
||||
* @param notifyMessage 通知文本内容。
|
||||
*/
|
||||
public static void postNotifyMessageJSON( String wechatOfficalAccountURL, String title,
|
||||
String notifyType, String notifyMessage )
|
||||
String notifyType, String notifyMessage )
|
||||
{
|
||||
// 设置推送内容
|
||||
WechatOfficalAccountMessageParameter param = new WechatOfficalAccountMessageParameter();
|
||||
@ -55,7 +55,7 @@ public class sendMessage
|
||||
|
||||
// 转换成json
|
||||
ObjectMapper mapper;
|
||||
String json = null;
|
||||
String json = null;
|
||||
|
||||
try
|
||||
{
|
||||
@ -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,16 +79,16 @@ public class sendMessage
|
||||
}
|
||||
|
||||
// 推送数据
|
||||
URL url;
|
||||
URL url;
|
||||
HttpURLConnection connection = null;
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
OutputStreamWriter out = null;
|
||||
BufferedReader in = null;
|
||||
StringBuilder result = new StringBuilder();
|
||||
OutputStreamWriter out = null;
|
||||
BufferedReader in = null;
|
||||
|
||||
try
|
||||
{
|
||||
url = new URL( wechatOfficalAccountURL );
|
||||
url = new URL( wechatOfficalAccountURL );
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
connection.setRequestMethod( "POST" );
|
||||
@ -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,16 +147,31 @@ public class sendMessage
|
||||
|
||||
/**
|
||||
* 推送天气灾害预警!接口文档参考 彭奕洁 编写《消息发送接口调用文档》
|
||||
*
|
||||
* @param officalAccountURL 产险厦门分公司公众号接口网址
|
||||
* @param warning 灾害警报
|
||||
* @param warning 灾害警报对象
|
||||
*/
|
||||
public static void sendWeatherDisasterWarning( String officalAccountURL,
|
||||
QWeatherDisasterWarning warning )
|
||||
QWeatherDisasterWarning warning )
|
||||
{
|
||||
Vector<QWeatherDisasterWarningItem> warningItems = warning.getWarning();
|
||||
|
||||
// 遍历消息
|
||||
// 设置请求头参数
|
||||
HashMap<String, String> headers = new HashMap<String, String>();
|
||||
|
||||
headers.put( "accept", "*/*" );
|
||||
headers.put( "Connection", "Keep-Alive" );
|
||||
headers.put( "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8" );
|
||||
|
||||
// 遍历消息,将消息推送出去。
|
||||
for ( QWeatherDisasterWarningItem item : warningItems )
|
||||
{
|
||||
// 拼接消息内容
|
||||
String title = item.getTitle();
|
||||
String text = item.getText();
|
||||
String color = warningLevel.keySet().contains( item.getLevel() ) ? "#000000"
|
||||
: warningLevel.get( item.getLevel() );
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
@ -176,44 +191,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()
|
||||
|
@ -4,9 +4,9 @@
|
||||
* @LastEditors: Kane
|
||||
* @LastEditTime: 2022-04-22 16:02:05
|
||||
* @FilePath: \DisasterWarning\src\test\java\com\cpic\xim\wechat\officalAccount\sendMessageTest.java
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
* @Description:
|
||||
*
|
||||
* Copyright (c) ${2022} by Kane, All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.cpic.xim.wechat.officalAccount;
|
||||
@ -28,7 +28,7 @@ public class sendMessageTest
|
||||
{
|
||||
// sendMessage.postNotifyMessageJSON( url, "警报", "警报标题", "警报内容!" );
|
||||
}
|
||||
catch (Exception error)
|
||||
catch ( Exception error )
|
||||
{
|
||||
fail( "测试失败!" );
|
||||
}
|
||||
@ -42,15 +42,15 @@ public class sendMessageTest
|
||||
+ "keyword1=东山县气象台发布大雾黄色预警[Ⅲ级/较重]&" + "keyword1color=#ffff00&"
|
||||
+ "keyword2=东山县气象台2022年04月22日06时12分发布大雾黄色预警信号:预计未来12小时内,我县、闽南渔场和台湾浅滩渔场将出现能见度小于500米的雾。请注意防范!";
|
||||
|
||||
// headers.put( "accept", "*/*" );
|
||||
// headers.put( "Connection", "Keep-Alive" );
|
||||
headers.put( "accept", "*/*" );
|
||||
headers.put( "Connection", "Keep-Alive" );
|
||||
headers.put( "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8" );
|
||||
|
||||
try
|
||||
{
|
||||
HttpUtils.postHttpRequest( url, headers, param );
|
||||
}
|
||||
catch (Exception error)
|
||||
catch ( Exception error )
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user