feat(ops): 新增客流统计持久化和清理任务
- 新增 OpsTrafficStatisticsDO 和 OpsTrafficStatisticsMapper(upsert + 过期清理) - 新增 TrafficStatisticsPersistJob: 每小时从 Redis 增量持久化到 MySQL, 支持分布式锁、负增量校准、缺失区域处理 - 新增 TrafficStatisticsCleanupJob: 每月清理 30 天前的统计记录 - 新增 SQL 建表脚本 ops_traffic_statistics - OpsBusAreaService 新增 getAreaIdByDeviceId 方法 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,4 +54,14 @@ public interface OpsBusAreaService {
|
|||||||
*/
|
*/
|
||||||
Boolean deleteArea(Long id);
|
Boolean deleteArea(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据设备ID获取关联的区域ID
|
||||||
|
* <p>
|
||||||
|
* 用于客流统计等场景,通过设备查询其所属区域
|
||||||
|
*
|
||||||
|
* @param deviceId 设备ID
|
||||||
|
* @return 区域ID,如果未找到返回 null
|
||||||
|
*/
|
||||||
|
Long getAreaIdByDeviceId(Long deviceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,4 +192,10 @@ public class OpsBusAreaServiceImpl implements OpsBusAreaService {
|
|||||||
|| target.getParentPath().endsWith("/" + sourceId);
|
|| target.getParentPath().endsWith("/" + sourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getAreaIdByDeviceId(Long deviceId) {
|
||||||
|
var relation = opsAreaDeviceRelationMapper.selectByDeviceId(deviceId);
|
||||||
|
return relation != null ? relation.getAreaId() : null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user