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>
|
* <pre>
|
||||||
* {@code
|
* {@code
|
||||||
* // 基础用法(使用 LogType/LogScope)
|
* // 基础用法(使用 LogType/LogScope)
|
||||||
* @BusinessLog(type = LogType.DISPATCH, scope = LogScope.ORDER,
|
* @BusinessLog(type = LogType.ORDER_DISPATCHED, scope = LogScope.ORDER,
|
||||||
* description = "自动派单", includeParams = true)
|
* description = "自动派单", includeParams = true)
|
||||||
* public DispatchResult dispatch(OrderDispatchContext context) {
|
* public DispatchResult dispatch(OrderDispatchContext context) {
|
||||||
* // ...
|
* // ...
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* // 新用法(直接指定 EventDomain 和 Module)
|
* // 新用法(直接指定 EventDomain 和 Module)
|
||||||
* @BusinessLog(module = "clean", domain = EventDomain.DEVICE,
|
* @BusinessLog(module = LogModule.CLEAN, domain = EventDomain.DEVICE,
|
||||||
* eventType = "TTS_SENT", description = "语音播报",
|
* eventType = "TTS_SENT", description = "语音播报",
|
||||||
* deviceId = "#deviceId", personId = "#context.cleanerId")
|
* deviceId = "#deviceId", personId = "#context.cleanerId")
|
||||||
* public void broadcast(String text, Long deviceId) {
|
* public void broadcast(String text, Long deviceId) {
|
||||||
@@ -46,7 +46,7 @@ public @interface BusinessLog {
|
|||||||
* <p>
|
* <p>
|
||||||
* 当指定了 domain 和 eventType 时,此字段可忽略
|
* 当指定了 domain 和 eventType 时,此字段可忽略
|
||||||
*/
|
*/
|
||||||
LogType type() default LogType.SYSTEM;
|
LogType type() default LogType.SYSTEM_EVENT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志作用域(旧版,保持兼容)
|
* 日志作用域(旧版,保持兼容)
|
||||||
|
|||||||
@@ -330,21 +330,20 @@ public class BusinessLogAspect {
|
|||||||
return EventDomain.SYSTEM;
|
return EventDomain.SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (logType) {
|
return switch (logType) {
|
||||||
case DISPATCH:
|
case ORDER_DISPATCHED, ORDER_INTERRUPTED, ORDER_PAUSED, ORDER_RESUMED ->
|
||||||
return EventDomain.DISPATCH;
|
EventDomain.DISPATCH;
|
||||||
case DEVICE:
|
case ORDER_ARRIVED, ORDER_COMPLETED ->
|
||||||
return EventDomain.DEVICE;
|
EventDomain.BEACON;
|
||||||
case NOTIFICATION:
|
case ORDER_CONFIRM ->
|
||||||
return EventDomain.DEVICE;
|
EventDomain.DEVICE;
|
||||||
case CLEANER:
|
case PRIORITY_UPGRADE, PRIORITY_CEILING, ARRIVED_SILENT_IGNORE ->
|
||||||
case SYSTEM:
|
EventDomain.TRAFFIC;
|
||||||
case QUEUE:
|
case TTS_SENT, TTS_FAILED ->
|
||||||
case LIFECYCLE:
|
EventDomain.DEVICE;
|
||||||
case TRANSITION:
|
default ->
|
||||||
default:
|
EventDomain.SYSTEM;
|
||||||
return 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.OperatorTypeEnum;
|
||||||
import com.viewsh.module.ops.enums.PriorityEnum;
|
import com.viewsh.module.ops.enums.PriorityEnum;
|
||||||
import com.viewsh.module.ops.enums.WorkOrderStatusEnum;
|
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 com.viewsh.module.ops.service.fsm.OrderStateMachine;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -364,10 +365,12 @@ public class OpsOrderServiceImpl implements OpsOrderService {
|
|||||||
}
|
}
|
||||||
dto.setType(type);
|
dto.setType(type);
|
||||||
|
|
||||||
// title: 优先使用 eventSummary,否则使用 eventType
|
// title: 优先使用 eventSummary,否则通过 LogType 枚举取中文描述
|
||||||
String title = logDO.getEventSummary();
|
String title = logDO.getEventSummary();
|
||||||
if (title == null || title.isEmpty()) {
|
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);
|
dto.setTitle(title);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user