refactor(ops): 收口散落的 eventType 硬编码为 LogType 枚举引用
替换 CleanOrderCreateEventHandler、OrderLifecycleManagerImpl、 DispatchEngineImpl 中的字符串常量为 LogType.XXX.getCode(), 同时将 DispatchEngine 的 @BusinessLog description 改为"工单自动派发"。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -77,9 +77,9 @@ public class DispatchEngineImpl implements DispatchEngine {
|
||||
|
||||
@Override
|
||||
@BusinessLog(
|
||||
type = LogType.DISPATCH,
|
||||
type = LogType.ORDER_DISPATCHED,
|
||||
scope = LogScope.ORDER,
|
||||
description = "工单调度",
|
||||
description = "工单自动派发",
|
||||
includeParams = true,
|
||||
includeResult = true,
|
||||
result = "#result.success",
|
||||
|
||||
@@ -13,6 +13,8 @@ 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.EventDomain;
|
||||
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.PostConstruct;
|
||||
@@ -180,7 +182,7 @@ public class OrderLifecycleManagerImpl implements OrderLifecycleManager {
|
||||
}
|
||||
|
||||
// 记录业务日志
|
||||
recordStatusChangeLog(orderId, result, "ORDER_PAUSED", "工单暂停");
|
||||
recordStatusChangeLog(orderId, result, LogType.ORDER_PAUSED.getCode(), "工单暂停");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,7 +207,7 @@ public class OrderLifecycleManagerImpl implements OrderLifecycleManager {
|
||||
}
|
||||
|
||||
// 记录业务日志
|
||||
recordStatusChangeLog(orderId, result, "ORDER_RESUMED", "工单恢复");
|
||||
recordStatusChangeLog(orderId, result, LogType.ORDER_RESUMED.getCode(), "工单恢复");
|
||||
}
|
||||
|
||||
// ==================== 打断/恢复 ====================
|
||||
@@ -240,9 +242,9 @@ public class OrderLifecycleManagerImpl implements OrderLifecycleManager {
|
||||
|
||||
OpsOrderDO order = opsOrderMapper.selectById(orderId);
|
||||
eventLogRecorder.record(EventLogRecord.builder()
|
||||
.module("clean")
|
||||
.module(LogModule.fromOrderType(order != null ? order.getOrderType() : null))
|
||||
.domain(EventDomain.DISPATCH)
|
||||
.eventType("ORDER_INTERRUPTED")
|
||||
.eventType(LogType.ORDER_INTERRUPTED.getCode())
|
||||
.message("工单被P0紧急任务打断")
|
||||
.targetId(orderId)
|
||||
.targetType("order")
|
||||
@@ -296,7 +298,7 @@ public class OrderLifecycleManagerImpl implements OrderLifecycleManager {
|
||||
// 注意:IoT 触发的自动完成在 CleanOrderCompleteEventHandler 中记录日志
|
||||
// 管理员手动完成时记录日志
|
||||
if (operatorType == OperatorTypeEnum.ADMIN) {
|
||||
recordStatusChangeLog(orderId, result, "ORDER_COMPLETED_MANUAL", "工单手动完成");
|
||||
recordStatusChangeLog(orderId, result, LogType.ORDER_COMPLETED.getCode(), "工单手动完成");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,9 +334,9 @@ public class OrderLifecycleManagerImpl implements OrderLifecycleManager {
|
||||
extra.put("operatorType", operatorType != null ? operatorType.getType() : "SYSTEM");
|
||||
|
||||
eventLogRecorder.record(EventLogRecord.builder()
|
||||
.module("clean")
|
||||
.module(LogModule.fromOrderType(order != null ? order.getOrderType() : null))
|
||||
.domain(EventDomain.SYSTEM)
|
||||
.eventType("ORDER_CANCELLED")
|
||||
.eventType(LogType.ORDER_CANCELLED.getCode())
|
||||
.message("工单已取消: " + reason)
|
||||
.targetId(orderId)
|
||||
.targetType("order")
|
||||
@@ -426,7 +428,7 @@ public class OrderLifecycleManagerImpl implements OrderLifecycleManager {
|
||||
extra.put("newStatus", result.getNewStatus() != null ? result.getNewStatus().getStatus() : null);
|
||||
|
||||
eventLogRecorder.record(EventLogRecord.builder()
|
||||
.module("clean")
|
||||
.module(LogModule.fromOrderType(order.getOrderType()))
|
||||
.domain(EventDomain.DISPATCH)
|
||||
.eventType(eventType)
|
||||
.message(message)
|
||||
|
||||
Reference in New Issue
Block a user