...
|
...
|
@@ -4,6 +4,7 @@ import com.sunyo.wlpt.message.bus.sdk.response.BusResult; |
|
|
import com.sunyo.wlpt.message.bus.sdk.response.ResultJson;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -12,8 +13,106 @@ import java.util.List; |
|
|
* 时间:2020/9/3 18:04
|
|
|
*/
|
|
|
public class MessageRequest {
|
|
|
private static final String SUCCESS_SEND_CODE = "10200";
|
|
|
private static final String SUCCESS_RECEIVE_CODE = "20200";
|
|
|
|
|
|
private static final String SUCCESS_ONE_CODE = "20200";
|
|
|
/**
|
|
|
* 发送消息,xml报文形式
|
|
|
*
|
|
|
* @param xmlMessage xml报文
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
public BusResult sendMessage(String url, String token, String xmlMessage)
|
|
|
{
|
|
|
MessageService messageService = new MessageService();
|
|
|
ResultJson resultJson = messageService.productOld(url, token, xmlMessage);
|
|
|
|
|
|
if (resultJson == null) {
|
|
|
BusResult result = new BusResult(false, "10400", "请检查url、token以及以及报文格式");
|
|
|
return result;
|
|
|
}
|
|
|
String code = resultJson.getCode();
|
|
|
String msg = resultJson.getMsg();
|
|
|
if (!SUCCESS_SEND_CODE.equals(resultJson.getCode())) {
|
|
|
String resultMessage = "错误代码:" + code + ";错误信息:" + msg;
|
|
|
BusResult errorResult = new BusResult(false, code, resultMessage);
|
|
|
return errorResult;
|
|
|
}
|
|
|
BusResult result = new BusResult(true, code, msg);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
/**
|
|
|
* 发送消息,根据参数
|
|
|
*
|
|
|
* @param SERV 服务器名称
|
|
|
* @param VSHT 虚拟主机名称
|
|
|
* @param TYPE 大类型(交换机名称)
|
|
|
* @param STYP 小类型(路由键名称)
|
|
|
* @param MSG 发送消息内容
|
|
|
* @param SNDR 发送者名称
|
|
|
* @param DDTM yyyyMMddHHmmss格式的发送时间
|
|
|
* @param TOKN token令牌
|
|
|
* @param SEQN 序列号
|
|
|
* @param RCVR 指定接收队列(非必须)
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
public BusResult sendMessage(String url, String SERV, String VSHT, String TYPE, String STYP, String MSG,
|
|
|
String SNDR, String DDTM, String TOKN, String SEQN, String RCVR)
|
|
|
{
|
|
|
ResultJson resultJson = MessageService.productNew(url, SERV, VSHT, TYPE, STYP, MSG, SNDR, DDTM, TOKN, SEQN, RCVR);
|
|
|
if (resultJson == null) {
|
|
|
BusResult result = new BusResult(false, "10400", "请检查url、token以及以及参数内容与位置");
|
|
|
return result;
|
|
|
}
|
|
|
String code = resultJson.getCode();
|
|
|
String msg = resultJson.getMsg();
|
|
|
if (!SUCCESS_SEND_CODE.equals(resultJson.getCode())) {
|
|
|
String resultMessage = "错误代码:" + code + ";错误信息:" + msg;
|
|
|
BusResult errorResult = new BusResult(false, code, resultMessage);
|
|
|
return errorResult;
|
|
|
}
|
|
|
BusResult result = new BusResult(true, code, msg);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发送消息,根据参数
|
|
|
*
|
|
|
* @param SERV 服务器名称
|
|
|
* @param VSHT 虚拟主机名称
|
|
|
* @param TYPE 大类型(交换机名称)
|
|
|
* @param STYP 小类型(路由键名称)
|
|
|
* @param MSG 发送消息内容
|
|
|
* @param SNDR 发送者名称
|
|
|
* @param DDTM yyyyMMddHHmmss格式的发送时间
|
|
|
* @param TOKN token令牌
|
|
|
* @param SEQN 序列号
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
public BusResult sendMessage(String url, String SERV, String VSHT, String TYPE, String STYP,
|
|
|
String MSG, String SNDR, String DDTM, String TOKN, String SEQN)
|
|
|
{
|
|
|
ResultJson resultJson = MessageService.productNew(url, SERV, VSHT, TYPE, STYP, MSG, SNDR, DDTM, TOKN, SEQN);
|
|
|
if (resultJson == null) {
|
|
|
BusResult result = new BusResult(false, "10400", "请检查url、token以及以及参数内容与位置");
|
|
|
return result;
|
|
|
}
|
|
|
String code = resultJson.getCode();
|
|
|
String msg = resultJson.getMsg();
|
|
|
if (!SUCCESS_SEND_CODE.equals(resultJson.getCode())) {
|
|
|
String resultMessage = "错误代码:" + code + ";错误信息:" + msg;
|
|
|
BusResult errorResult = new BusResult(false, code, resultMessage);
|
|
|
return errorResult;
|
|
|
}
|
|
|
BusResult result = new BusResult(true, code, msg);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 接收消息,一条
|
...
|
...
|
@@ -24,15 +123,16 @@ public class MessageRequest { |
|
|
* @param RCVR 接收队列名称
|
|
|
* @return
|
|
|
*/
|
|
|
public BusResult getMessageOne(String RUSR, String SERV, String VSHT, String RCVR) throws IOException
|
|
|
public BusResult getMessageOne(String url, String token, String RUSR, String SERV, String VSHT, String RCVR)
|
|
|
{
|
|
|
ResultJson resultJson = BusMessage.consumerOne(RUSR, SERV, VSHT, RCVR);
|
|
|
ResultJson resultJson = MessageService.consumerOne(url, token, RUSR, SERV, VSHT, RCVR);
|
|
|
if (resultJson == null) {
|
|
|
|
|
|
BusResult result = new BusResult(false, "20400", "请检查url、token以及以及参数内容与位置");
|
|
|
return result;
|
|
|
}
|
|
|
String code = resultJson.getCode();
|
|
|
String msg = resultJson.getMsg();
|
|
|
if (!SUCCESS_ONE_CODE.equals(resultJson.getCode())) {
|
|
|
if (!SUCCESS_RECEIVE_CODE.equals(resultJson.getCode())) {
|
|
|
String resultMessage = "错误代码:" + code + ";错误信息:" + msg;
|
|
|
BusResult errorResult = new BusResult(false, code, resultMessage);
|
|
|
return errorResult;
|
...
|
...
|
@@ -42,16 +142,27 @@ public class MessageRequest { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public BusResult getMessageMore(String RUSR, String SERV, String VSHT, String RCVR, Integer CUNT) throws IOException
|
|
|
/**
|
|
|
* 接收消息,多条
|
|
|
*
|
|
|
* @param RUSR 接收人名称
|
|
|
* @param SERV 服务器名称
|
|
|
* @param VSHT 虚拟主机名称
|
|
|
* @param RCVR 接收队列名称
|
|
|
* @param CUNT 消息的数量
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
public BusResult getMessageMore(String url, String token, String RUSR, String SERV, String VSHT, String RCVR, Integer CUNT)
|
|
|
{
|
|
|
ResultJson resultJson = BusMessage.consumerMore(RUSR, SERV, VSHT, RCVR, CUNT);
|
|
|
ResultJson resultJson = MessageService.consumerMore(url, token, RUSR, SERV, VSHT, RCVR, CUNT);
|
|
|
if (resultJson == null) {
|
|
|
|
|
|
BusResult result = new BusResult(false, "20400", "请检查url、token以及以及参数内容与位置");
|
|
|
return result;
|
|
|
}
|
|
|
String code = resultJson.getCode();
|
|
|
String msg = resultJson.getMsg();
|
|
|
if (!SUCCESS_ONE_CODE.equals(resultJson.getCode())) {
|
|
|
if (!SUCCESS_RECEIVE_CODE.equals(resultJson.getCode())) {
|
|
|
String resultMessage = "错误代码:" + code + ";错误信息:" + msg;
|
|
|
BusResult errorResult = new BusResult(false, code, resultMessage);
|
|
|
return errorResult;
|
...
|
...
|
@@ -60,4 +171,6 @@ public class MessageRequest { |
|
|
BusResult result = new BusResult(true, code, msg, dataList);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|