fix(ops): TTS 业务日志去除冗余"语音播报:"前缀

VoiceBroadcastService 和 TtsQueueConsumer 记录 TTS_SENT 日志时
直接使用播报文本内容,title 由 LogType.TTS_SENT 的 description
"语音播报"提供,避免 message 中重复出现。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
lzh
2026-03-11 17:34:53 +08:00
parent 6c8c57b932
commit 0345d0fe39
2 changed files with 15 additions and 11 deletions

View File

@@ -5,6 +5,8 @@ import com.viewsh.module.iot.api.device.IotDeviceControlApi;
import com.viewsh.module.iot.api.device.dto.IotDeviceServiceInvokeReqDTO;
import com.viewsh.module.ops.infrastructure.log.enumeration.EventDomain;
import com.viewsh.module.ops.infrastructure.log.enumeration.EventLevel;
import com.viewsh.module.ops.infrastructure.log.enumeration.LogModule;
import com.viewsh.module.ops.infrastructure.log.enumeration.LogType;
import com.viewsh.module.ops.infrastructure.log.recorder.EventLogRecord;
import com.viewsh.module.ops.infrastructure.log.recorder.EventLogRecorder;
import cn.hutool.core.map.MapUtil;
@@ -315,8 +317,8 @@ public class TtsQueueConsumer {
// 记录日志(循环消息只在启动时记录一次,重复播报不再写日志)
if (message.getOrderId() != null && !message.isLoopable()) {
eventLogRecorder.info("clean", EventDomain.DEVICE, "TTS_SENT",
"语音播报: " + message.getText(), message.getOrderId(), message.getDeviceId(), null);
eventLogRecorder.info(LogModule.CLEAN, EventDomain.DEVICE, LogType.TTS_SENT.getCode(),
message.getText(), message.getOrderId(), message.getDeviceId(), null);
}
return true;
@@ -327,9 +329,9 @@ public class TtsQueueConsumer {
// 记录错误日志
eventLogRecorder.record(EventLogRecord.builder()
.module("clean")
.module(LogModule.CLEAN)
.domain(EventDomain.DEVICE)
.eventType("TTS_FAILED")
.eventType(LogType.TTS_FAILED.getCode())
.message("语音播报失败: " + e.getMessage())
.targetId(message.getOrderId())
.targetType("order")

View File

@@ -5,6 +5,8 @@ import com.viewsh.module.iot.api.device.IotDeviceControlApi;
import com.viewsh.module.iot.api.device.dto.IotDeviceServiceInvokeReqDTO;
import com.viewsh.module.ops.infrastructure.log.enumeration.EventDomain;
import com.viewsh.module.ops.infrastructure.log.enumeration.EventLevel;
import com.viewsh.module.ops.infrastructure.log.enumeration.LogModule;
import com.viewsh.module.ops.infrastructure.log.enumeration.LogType;
import com.viewsh.module.ops.infrastructure.log.recorder.EventLogRecord;
import com.viewsh.module.ops.infrastructure.log.recorder.EventLogRecorder;
import jakarta.annotation.Resource;
@@ -221,18 +223,18 @@ public class VoiceBroadcastService {
private void recordLog(Long deviceId, String text, Long orderId, boolean success, Exception e) {
if (success) {
if (orderId != null) {
eventLogRecorder.info("clean", EventDomain.DEVICE, "TTS_SENT",
"语音播报: " + text, orderId, deviceId, null);
eventLogRecorder.info(LogModule.CLEAN, EventDomain.DEVICE, LogType.TTS_SENT.getCode(),
text, orderId, deviceId, null);
} else {
eventLogRecorder.info("clean", EventDomain.DEVICE, "TTS_SENT",
"语音播报: " + text, deviceId);
eventLogRecorder.info(LogModule.CLEAN, EventDomain.DEVICE, LogType.TTS_SENT.getCode(),
text, deviceId);
}
} else {
if (orderId != null) {
eventLogRecorder.record(EventLogRecord.builder()
.module("clean")
.module(LogModule.CLEAN)
.domain(EventDomain.DEVICE)
.eventType("TTS_FAILED")
.eventType(LogType.TTS_FAILED.getCode())
.message("语音播报失败: " + (e != null ? e.getMessage() : "unknown"))
.targetId(orderId)
.targetType("order")
@@ -240,7 +242,7 @@ public class VoiceBroadcastService {
.level(EventLevel.ERROR)
.build());
} else {
eventLogRecorder.error("clean", EventDomain.DEVICE, "TTS_FAILED",
eventLogRecorder.error(LogModule.CLEAN, EventDomain.DEVICE, LogType.TTS_FAILED.getCode(),
"语音播报失败: " + (e != null ? e.getMessage() : "unknown"), deviceId, e);
}
}