feat(ops): 事件日志增强与空闲设备待办检查
- 实现空闲设备待办工单检查定时任务 - 修复事件日志 orderId 关联 (使用 targetId) - 增强语音播报和工单事件的日志完整性
This commit is contained in:
@@ -112,6 +112,11 @@ public class EventLogRecord {
|
||||
*/
|
||||
private String targetType;
|
||||
|
||||
/**
|
||||
* 工单ID(便于直接关联查询)
|
||||
*/
|
||||
private Long orderId;
|
||||
|
||||
// ==================== 扩展字段 ====================
|
||||
|
||||
/**
|
||||
@@ -181,7 +186,7 @@ public class EventLogRecord {
|
||||
* 创建设备事件日志
|
||||
*/
|
||||
public static EventLogRecord forDevice(String module, EventDomain domain, String eventType,
|
||||
String message, Long deviceId) {
|
||||
String message, Long deviceId) {
|
||||
return EventLogRecord.builder()
|
||||
.module(module)
|
||||
.domain(domain)
|
||||
@@ -195,7 +200,7 @@ public class EventLogRecord {
|
||||
* 创建工单事件日志
|
||||
*/
|
||||
public static EventLogRecord forOrder(String module, EventDomain domain, String eventType,
|
||||
String message, Long orderId, Long deviceId, Long personId) {
|
||||
String message, Long orderId, Long deviceId, Long personId) {
|
||||
return EventLogRecord.builder()
|
||||
.module(module)
|
||||
.domain(domain)
|
||||
@@ -212,7 +217,7 @@ public class EventLogRecord {
|
||||
* 创建系统事件日志
|
||||
*/
|
||||
public static EventLogRecord forSystem(String module, EventDomain domain, String eventType,
|
||||
String message) {
|
||||
String message) {
|
||||
return EventLogRecord.builder()
|
||||
.module(module)
|
||||
.domain(domain)
|
||||
|
||||
@@ -8,6 +8,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 事件日志记录器实现
|
||||
* <p>
|
||||
@@ -31,7 +33,6 @@ public class EventLogRecorderImpl implements EventLogRecorder {
|
||||
@Resource
|
||||
private EventLogPersister persister;
|
||||
|
||||
|
||||
/**
|
||||
* 异步记录日志(默认方式)
|
||||
* <p>
|
||||
@@ -110,7 +111,7 @@ public class EventLogRecorderImpl implements EventLogRecorder {
|
||||
|
||||
@Override
|
||||
public void info(String module, EventDomain domain, String eventType, String message,
|
||||
Long orderId, Long deviceId, Long personId) {
|
||||
Long orderId, Long deviceId, Long personId) {
|
||||
record(EventLogRecord.builder()
|
||||
.module(module)
|
||||
.domain(domain)
|
||||
@@ -165,7 +166,7 @@ public class EventLogRecorderImpl implements EventLogRecorder {
|
||||
|
||||
@Override
|
||||
public void error(String module, EventDomain domain, String eventType, String message,
|
||||
Long deviceId, Throwable throwable) {
|
||||
Long deviceId, Throwable throwable) {
|
||||
EventLogRecord record = EventLogRecord.builder()
|
||||
.module(module)
|
||||
.domain(domain)
|
||||
@@ -185,6 +186,12 @@ public class EventLogRecorderImpl implements EventLogRecorder {
|
||||
* 转换为 DO
|
||||
*/
|
||||
private OpsBusinessEventLogDO convertToDO(EventLogRecord record) {
|
||||
// payload 为空或空 Map 时设为 null,避免存储 {}
|
||||
Map<String, Object> payload = record.getPayload();
|
||||
if (payload != null && payload.isEmpty()) {
|
||||
payload = null;
|
||||
}
|
||||
|
||||
return OpsBusinessEventLogDO.builder()
|
||||
.eventTime(record.getEventTime())
|
||||
.eventLevel(record.getLevel() != null ? record.getLevel().getCode() : EventLevel.INFO.getCode())
|
||||
@@ -202,7 +209,7 @@ public class EventLogRecorderImpl implements EventLogRecorder {
|
||||
.targetType(record.getTargetType())
|
||||
.eventMessage(record.getMessage())
|
||||
.eventSummary(record.getSummary())
|
||||
.eventPayload(record.getPayload())
|
||||
.eventPayload(payload)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -228,10 +235,12 @@ public class EventLogRecorderImpl implements EventLogRecorder {
|
||||
*/
|
||||
private void logConsole(EventLogRecord record) {
|
||||
String deviceInfo = record.getDeviceId() != null
|
||||
? " [设备:" + record.getDeviceId() + (record.getDeviceName() != null ? "(" + record.getDeviceName() + ")" : "") + "]"
|
||||
? " [设备:" + record.getDeviceId()
|
||||
+ (record.getDeviceName() != null ? "(" + record.getDeviceName() + ")" : "") + "]"
|
||||
: "";
|
||||
String personInfo = record.getPersonId() != null
|
||||
? " [人员:" + record.getPersonId() + (record.getPersonName() != null ? "(" + record.getPersonName() + ")" : "") + "]"
|
||||
? " [人员:" + record.getPersonId()
|
||||
+ (record.getPersonName() != null ? "(" + record.getPersonName() + ")" : "") + "]"
|
||||
: "";
|
||||
String targetInfo = record.getTargetId() != null
|
||||
? " [" + record.getTargetType() + ":" + record.getTargetId() + "]"
|
||||
|
||||
Reference in New Issue
Block a user