refactor(iot): 重构客流计数器为增量累加模式,支持 people_out

- 删除旧 TrafficCounterBaseRedisDAO(基准值模式),新增 TrafficCounterRedisDAO
  支持阈值计数器(达标后重置)和当日累积统计(用于报表)
- TrafficThresholdRuleProcessor 改为增量原子累加,消除基准值校准逻辑
- CleanRuleProcessorManager 路由增加 people_out 支持
- TrafficCounterBaseResetJob 改为每日清除阈值计数器,持久化职责移交 Ops 模块
- 使用 SCAN 替代 KEYS 避免阻塞 Redis

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
lzh
2026-02-03 15:34:03 +08:00
parent 6a109954d3
commit 46024fd043
13 changed files with 915 additions and 175 deletions

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.viewsh.module.ops.dal.mysql.statistics.OpsTrafficStatisticsMapper">
<insert id="upsert">
INSERT INTO ops_traffic_statistics (device_id, area_id, stat_hour, people_in, people_out, tenant_id)
VALUES (#{record.deviceId}, #{record.areaId}, #{record.statHour}, #{record.peopleIn}, #{record.peopleOut}, #{record.tenantId})
ON DUPLICATE KEY UPDATE
people_in = people_in + VALUES(people_in),
people_out = people_out + VALUES(people_out),
update_time = NOW()
</insert>
<delete id="deleteByStatHourBefore">
DELETE FROM ops_traffic_statistics
WHERE stat_hour &lt; #{beforeTime}
AND deleted = 0
</delete>
</mapper>