fix(ops): 修复 TTS 队列 Redisson 事务不兼容和客流统计租户上下文缺失
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled

1. TtsQueueConsumer: 用 SETNX+TTL 替代 watch/multi/exec 事务模式,
   解决 Redisson 不支持 WATCH 导致 exec() 抛出异常的问题
2. TrafficStatisticsPersistJob: 用 TenantUtils.executeIgnore() 包裹
   设备区域查询,解决 xxl-job 线程无租户上下文导致查询失败的问题

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
lzh
2026-02-04 10:13:41 +08:00
parent a18d1a7d8d
commit 117ad2c405
2 changed files with 23 additions and 54 deletions

View File

@@ -1,5 +1,6 @@
package com.viewsh.module.ops.service.job;
import com.viewsh.framework.tenant.core.util.TenantUtils;
import com.viewsh.module.ops.dal.dataobject.statistics.OpsTrafficStatisticsDO;
import com.viewsh.module.ops.dal.mysql.statistics.OpsTrafficStatisticsMapper;
import com.viewsh.module.ops.service.area.OpsBusAreaService;
@@ -243,7 +244,8 @@ public class TrafficStatisticsPersistJob {
private Long getAreaIdForDevice(Long deviceId) {
try {
// 通过 OpsBusAreaService 查询设备关联的区域
return areaService.getAreaIdByDeviceId(deviceId);
// 使用 executeIgnore 忽略租户过滤,因为 xxl-job 线程无租户上下文
return TenantUtils.executeIgnore(() -> areaService.getAreaIdByDeviceId(deviceId));
} catch (Exception e) {
log.error("[TrafficStatisticsPersistJob] 查询设备区域失败deviceId={}", deviceId, e);
return null;