This commit is contained in:
cc
2024-12-01 02:43:21 +08:00
parent 8011eaf9fd
commit 9cfbf2ae2d
3 changed files with 13 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ package cn.van.business.util;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import cn.van.business.enums.WXReqType;
import cn.van.business.mq.MessageProducerService;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
@@ -63,7 +64,8 @@ public class WXUtil {
public static String WX_BASE_URL;
private Environment env;
@Autowired
private RocketMQTemplate rocketMQTemplate;
private MessageProducerService messageProducerService;
@Autowired
public WXUtil(Environment env) {
this.env = env;
@@ -101,8 +103,8 @@ public class WXUtil {
List<String> strings = splitStringByLength(content, 3072);
int count = 1;
for (String string : strings) {
if (strings.size()>1) {
string = "---长消息---第:" + count + ""+ "\r" + string ;
if (strings.size() > 1) {
string = "---长消息---第:" + count + "" + "\r" + string;
}
count++;
// 如果是自己的微信,所有信息都加上少爷
@@ -140,14 +142,7 @@ public class WXUtil {
//wxReqDate.setData(jsonObject);
if (Util.isNotEmpty(wxid)) {
// 把消息发送到RocketMQ使用'wx-message'作为topicjsonObject作为消息内容。
rocketMQTemplate.convertAndSend("wx-message", jsonObject);
String responseStr = HttpRequest.post(WX_BASE_URL)
.body(JSON.toJSONString(jsonObject)).execute().body();
if (ObjectUtil.isNotEmpty(responseStr)) {
JSONObject response = JSON.parseObject(responseStr);
logger.info("消息响应:{}", response.toString());
//return response;
}
messageProducerService.sendMessage(jsonObject);
}
}