fix(ops): 修复业务日志 title 显示英文常量,改为中文映射
/business-logs 接口 title 回退取 eventType 时,通过 LogType.getByCode() 映射中文 description 作为标题。同步调整 @BusinessLog 注解 type 属性 改用 LogType 枚举。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,14 +16,14 @@ import java.lang.annotation.*;
|
||||
* <pre>
|
||||
* {@code
|
||||
* // 基础用法(使用 LogType/LogScope)
|
||||
* @BusinessLog(type = LogType.DISPATCH, scope = LogScope.ORDER,
|
||||
* @BusinessLog(type = LogType.ORDER_DISPATCHED, scope = LogScope.ORDER,
|
||||
* description = "自动派单", includeParams = true)
|
||||
* public DispatchResult dispatch(OrderDispatchContext context) {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
* // 新用法(直接指定 EventDomain 和 Module)
|
||||
* @BusinessLog(module = "clean", domain = EventDomain.DEVICE,
|
||||
* @BusinessLog(module = LogModule.CLEAN, domain = EventDomain.DEVICE,
|
||||
* eventType = "TTS_SENT", description = "语音播报",
|
||||
* deviceId = "#deviceId", personId = "#context.cleanerId")
|
||||
* public void broadcast(String text, Long deviceId) {
|
||||
@@ -46,7 +46,7 @@ public @interface BusinessLog {
|
||||
* <p>
|
||||
* 当指定了 domain 和 eventType 时,此字段可忽略
|
||||
*/
|
||||
LogType type() default LogType.SYSTEM;
|
||||
LogType type() default LogType.SYSTEM_EVENT;
|
||||
|
||||
/**
|
||||
* 日志作用域(旧版,保持兼容)
|
||||
|
||||
@@ -330,21 +330,20 @@ public class BusinessLogAspect {
|
||||
return EventDomain.SYSTEM;
|
||||
}
|
||||
|
||||
switch (logType) {
|
||||
case DISPATCH:
|
||||
return EventDomain.DISPATCH;
|
||||
case DEVICE:
|
||||
return EventDomain.DEVICE;
|
||||
case NOTIFICATION:
|
||||
return EventDomain.DEVICE;
|
||||
case CLEANER:
|
||||
case SYSTEM:
|
||||
case QUEUE:
|
||||
case LIFECYCLE:
|
||||
case TRANSITION:
|
||||
default:
|
||||
return EventDomain.SYSTEM;
|
||||
}
|
||||
return switch (logType) {
|
||||
case ORDER_DISPATCHED, ORDER_INTERRUPTED, ORDER_PAUSED, ORDER_RESUMED ->
|
||||
EventDomain.DISPATCH;
|
||||
case ORDER_ARRIVED, ORDER_COMPLETED ->
|
||||
EventDomain.BEACON;
|
||||
case ORDER_CONFIRM ->
|
||||
EventDomain.DEVICE;
|
||||
case PRIORITY_UPGRADE, PRIORITY_CEILING, ARRIVED_SILENT_IGNORE ->
|
||||
EventDomain.TRAFFIC;
|
||||
case TTS_SENT, TTS_FAILED ->
|
||||
EventDomain.DEVICE;
|
||||
default ->
|
||||
EventDomain.SYSTEM;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.viewsh.module.ops.dal.mysql.workorder.OpsOrderMapper;
|
||||
import com.viewsh.module.ops.enums.OperatorTypeEnum;
|
||||
import com.viewsh.module.ops.enums.PriorityEnum;
|
||||
import com.viewsh.module.ops.enums.WorkOrderStatusEnum;
|
||||
import com.viewsh.module.ops.infrastructure.log.enumeration.LogType;
|
||||
import com.viewsh.module.ops.service.fsm.OrderStateMachine;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -364,10 +365,12 @@ public class OpsOrderServiceImpl implements OpsOrderService {
|
||||
}
|
||||
dto.setType(type);
|
||||
|
||||
// title: 优先使用 eventSummary,否则使用 eventType
|
||||
// title: 优先使用 eventSummary,否则通过 LogType 枚举取中文描述
|
||||
String title = logDO.getEventSummary();
|
||||
if (title == null || title.isEmpty()) {
|
||||
title = logDO.getEventType() != null ? logDO.getEventType() : "工单操作";
|
||||
LogType logType = LogType.getByCode(logDO.getEventType());
|
||||
title = logType != null ? logType.getDescription()
|
||||
: (logDO.getEventType() != null ? logDO.getEventType() : "工单操作");
|
||||
}
|
||||
dto.setTitle(title);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user