fix(ops): 修正工牌设备状态事件处理器配置
- 包名从 handler 改为 listener - 使用 TransactionalEventListener 替代 EventListener - 线程池名修正为 ops-task-executor - 状态从 ASSIGNED 改为 PENDING - 清理测试文件中的重复代码 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package com.viewsh.module.ops.environment.integration.handler;
|
||||
package com.viewsh.module.ops.environment.integration.listener;
|
||||
|
||||
import com.viewsh.module.ops.environment.service.badge.BadgeDeviceStatusService;
|
||||
import com.viewsh.module.ops.core.event.OrderStateChangedEvent;
|
||||
@@ -9,6 +9,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.event.TransactionPhase;
|
||||
import org.springframework.transaction.event.TransactionalEventListener;
|
||||
|
||||
/**
|
||||
* 工牌设备状态事件处理器
|
||||
@@ -42,8 +44,8 @@ public class BadgeDeviceStatusEventHandler {
|
||||
*
|
||||
* @param event 工单状态变更事件
|
||||
*/
|
||||
@EventListener
|
||||
@Async("opsExecutor")
|
||||
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
|
||||
@Async("ops-task-executor")
|
||||
public void onOrderStateChanged(OrderStateChangedEvent event) {
|
||||
try {
|
||||
// 只处理保洁类型的工单
|
||||
@@ -76,7 +78,7 @@ public class BadgeDeviceStatusEventHandler {
|
||||
WorkOrderStatusEnum newStatus = event.getNewStatus();
|
||||
|
||||
switch (newStatus) {
|
||||
case ASSIGNED:
|
||||
case PENDING:
|
||||
// 工单已分配,不影响设备状态(设备可能还在处理其他任务)
|
||||
// 设置设备当前工单
|
||||
badgeDeviceStatusService.setCurrentOrder(deviceId, event.getOrderId());
|
||||
@@ -171,9 +173,9 @@ public class BadgeDeviceStatusEventHandler {
|
||||
* 1. 将被打断的设备状态转为 PAUSED
|
||||
* 2. 记录被打断的工单ID
|
||||
*
|
||||
* @param deviceId 被打断的设备ID
|
||||
* @param deviceId 被打断的设备ID
|
||||
* @param interruptedOrderId 被打断的工单ID
|
||||
* @param urgentOrderId P0紧急工单ID
|
||||
* @param urgentOrderId P0紧急工单ID
|
||||
*/
|
||||
public void handleP0Interrupt(Long deviceId, Long interruptedOrderId, Long urgentOrderId) {
|
||||
log.info("[BadgeDeviceStatusEventHandler] P0紧急任务打断: deviceId={}, interruptedOrderId={}, urgentOrderId={}",
|
||||
|
||||
Reference in New Issue
Block a user