统计美化
This commit is contained in:
@@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static cn.van.business.util.WXUtil.WX_BASE_URL;
|
||||
@@ -54,8 +55,12 @@ public class MessageConsumerService implements RocketMQListener<JSONObject> {
|
||||
|
||||
// 4. 发送请求(保持原有)
|
||||
String responseStr;
|
||||
responseStr = HttpRequest.post(WX_BASE_URL).body(message.toJSONString()).execute().charset("UTF-8").body();
|
||||
|
||||
// 修改onMessage方法中的HTTP请求部分
|
||||
responseStr = HttpRequest.post(WX_BASE_URL).header("Content-Type", "application/json; charset=UTF-8") // 明确指定编码
|
||||
.body(message.toJSONString().getBytes(StandardCharsets.UTF_8)) // 显式转为UTF-8字节
|
||||
.execute().charset("UTF-8") // 强制响应体使用UTF-8解码
|
||||
.body();
|
||||
// ... [保持原有响应处理逻辑]
|
||||
if (ObjectUtil.isNotEmpty(responseStr)) {
|
||||
JSONObject response = JSONObject.parseObject(responseStr);
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Service
|
||||
public class MessageProducerService {
|
||||
|
||||
@@ -44,7 +46,7 @@ public class MessageProducerService {
|
||||
}
|
||||
// 构建Spring Message
|
||||
Message<String> message = MessageBuilder
|
||||
.withPayload(data.toJSONString())
|
||||
.withPayload(new String(data.toJSONString().getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8))
|
||||
.setHeader(RocketMQHeaders.TAGS, "wx")
|
||||
.build();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user