|
767
|
24
|
1
|
4
|
|
0
|
[后台管理] 按省市统计设备月度新增上线数量报表
|
## 关联 Issue
Close #4 — [后台] 按省市统计设备月度新增上线数量报表
(I ## 关联 Issue
Close #4 — [后台] 按省市统计设备月度新增上线数量报表
(Issue 位于另一仓库 laiqiaojie/jh-project,Gitea 跨仓库 `Close #N` 不会自动关联,merge 后需手动去 jh-project 更新 Issue 状态)
## 变更说明
- 新增 `DeviceOnlineStats` 控制器,暴露 `getProvinceStats`(按月+省份汇总新增上线设备数)、`getCityStats`(指定省份后按城市下钻)两个接口
- `Ahead_authenticate_log_model` 新增对应查询方法:联表 `ahead_authenticate_log` → `ahead_family_servers` → `ahead_yc_shop`,权限过滤复用现有 `Ahead_manage_user_model::check_is_agent()`(超管看全国,运营商强制按 `shop._agent_id` 过滤)
- 与 plan.md 的偏差:实现与计划一致;另外在 `/code-review` 中发现并修复了两个问题(均已回归验证):
- `month` 参数只校验格式未校验取值范围,如 `2026-00` 会被 `strtotime` 静默接受为上一年 12 月而不报错 → 正则改为 `(0[1-9]|1[0-2])` 严格校验月份范围
- 未绑定门店的设备(`room._shop_id` 为 0/未匹配)会被计入 `total` 但在 `GROUP BY shop._province` 时产生一个 province 为 null 的脏分组 → 加 `room._shop_id > 0` 过滤
## 测试说明
- 本地起 PHPStudy,登录后手动调用两个接口验证:正常月份返回 `{code:0, result:{total, list}}`;缺 `month`/非法月份(`2026-00`、`2026-13`、`0000-00`)均正确返回 400
- 用只读 SQL 直接查了云端开发库确认 JOIN 链路正确——本地测试库 `ahead_authenticate_log` 表只有 1 条 2021 年的历史数据,所以当月查询返回空列表是预期行为,不是 bug
- `tests/api/smoke.mjs` 里补充了对应的自动化用例,但该冒烟测试框架整体依赖另一个尚未推送到 `admin` 分支的提交(`694e34c`,属于另一项未提交的工作,不在本 Issue 范围内),为保持本 PR 改动范围干净,本次未包含测试框架文件,仅代码改动
- 需要 Tech Lead 重点看:`check_is_agent()` 权限过滤范围是否符合预期;`room._shop_id > 0` 过滤是否会误伤合法数据
## 产物归档
- Plan:[plan/device-online-stats-by-region-admin.md](https://gitea.g-hi.com/laiqiaojie/jh-project/src/branch/design/device-online-stats-by-region/plan/device-online-stats-by-region-admin.md)(位于 laiqiaojie/jh-project 仓库)
...
|
0
|
0
|
1
|
1
|
1
|
|
0
|
1788244598
|
1788246926
|
1788245236
|
0
|
0
|
0
|
Edit
Delete
|
|
790
|
116
|
1
|
5
|
|
0
|
fix(contracts): 注册中心规则补失败关闭与摘要规范化——三个入口此前抛 TypeErr fix(contracts): 注册中心规则补失败关闭与摘要规范化——三个入口此前抛 TypeError,同一摘要的两种写法此前分叉成两个复核键...
|
蓝图 docs/domain/registry-snapshot-blueprint.md 从迁入起 蓝图 docs/domain/registry-snapshot-blueprint.md 从迁入起就写着「失败关闭」与
「review key 仅用于人工复核幂等」两条不变量,实测三处不成立。本次按蓝图自己的口径补齐,
改动只在 contracts/src/domain/application-contract-registry/:不新增写入点、不新增宿主、
不动 Catalog 与 Schema,每条输出仍固定 activationAllowed=false / registryWriteAllowed=false /
humanApprovalRequired=true。
1. 失败关闭:assessRegistrySnapshot / assessRegistryTransition /
reviewCandidateSnapshotUpgrade 对畸形输入抛 TypeError(快照缺字段、now 不是 Date、
decisions 整个缺失都会抛),四个入口里只有 LocalManifestAdmissionPlanner.plan 是
失败关闭的。现四个入口一致返回 REJECT + 原因码。这不是洁癖:check-fixtures 把抛出当
配置错误处理,实测一次 TypeError 会让整套 15 例逐例判定塌成一条 configuration 失败。
2. 十六进制引用规范化:digest / commit 的正则带 /i 收大小写两种写法,比较与入键却
大小写敏感——同一摘要写成大写会得到另一个 reviewIdempotencyKey,同版本大小写翻转被判成
SAME_VERSION_DIGEST_CHANGED,大写回滚 pin 被判成 ROLLBACK_PIN_MUST_MATCH_CURRENT。
现一律规范化为小写后再比较、再入键,ACCEPT 回吐规范化后的值。
3. 版本文法收敛:一个模块三套(快照流与清单准入用 \d+\.\d+\.\d+,升级复核用严格 SemVer),
新增 registry-primitives.ts 作单一来源,含预发布序;DEC-009—012 此前在两份文件各写一份,
一并收敛。snapshot-upgrade-review.ts 因此净减约 60 行重复实现。
两处语义变化(蓝图新增一节已如实登记):
- 收紧:1.02.0 这类前导零版本此前被放行,现在拒;assessRegistrySnapshot 另开始拒 latest
这类可变标签——此前它能过体检却必然过不了迁移规则。
- 放宽:1.0.0-rc.1 这类预发布版本此前被快照流整条挡在外面,现在按 SemVer 序参与迁移。
平台自己发的就是 1.0.0-rc.N,升级复核那一侧本来就这么判。风险面有限:本模块所有出口
都不激活、不写 Registry,多进人工复核队列不等于多放行制品。
证据(本分支隔离工作树,clean):注册中心单测 44/44(原 34 + 加固 10);
contracts check:local 302/302;check:fixtures 九个契约域套件 100 例 0 失败,
其中本套件 15 例(正 4 / 反 11,原 8 例)。篡改必红实测两次:sameHexRef 退回大小写敏感
→ 单测 1 红 + 夹具 P03 红;去掉快照入口守卫 → 整套塌成 0 例 1 配置失败。
仍为仓内候选 sdk_e2,不代表正式 Registry、Snapshot 发布或跨仓 Required Check 已上线。
清单登记的 C01.04 / C01.06 是「接线」型缺口且前置 Q01 运行宿主未裁,本次未动。
reports/fixtures.latest.json 未回绑:它是 17 套件的聚合报告,只跑 9 个套件去覆盖会缩小结论面,
应在整批(含并行会话的 public-file / IM / 跨域流程改动)落定后统一重跑回绑。
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>...
|
0
|
0
|
1
|
1
|
0
|
|
0
|
1789742918
|
1790248458
|
1789742925
|
0
|
0
|
0
|
Edit
Delete
|
|
803
|
121
|
1
|
5
|
|
0
|
wip(K3.3): PolicyDefinition — preserved snapshot o wip(K3.3): PolicyDefinition — preserved snapshot of uncommitted work (base 0.71, not for merge)...
|
Preservation snapshot (R0, 2026-09-29) of work tha Preservation snapshot (R0, 2026-09-29) of work that only existed as uncommitted changes in a /tmp worktree.
Nothing here was verified by this commit: no tests were ever written for it and it was not run against a database.
What the snapshot contains:
- sql/072_policy_definition.sql: governance.policy_definition_version (EXECUTION_AUTHORIZATION with maxTtlSeconds),
a ten-state lifecycle, immutable content, one ACTIVE version per tenant and type, FORCE RLS; also replaces the
authority_assignment action CHECK with governance.manage_policy / governance.approve_policy added. The file header
is a copy of the K3.2 header.
- src/contexts/policy-definition.js: the PolicyDefinition commands (create, validate, request review, approve,
reject, publish, activate, deprecate, retire, revoke) with self-approval denial and authority checks.
- registrations in commands.js, owner-roles.js, rejection-target.js, kernel.js, catalog and the payload / event
contracts.
Known state when preserved:
- Based on 0490b8e (0.71). Main is 0.103.x with migrations up to 095; 072 already exists there
(072_task_case_correlation_immutable), so the migration must be renumbered, and kernel.js / catalog / contracts
will need a real rebase.
- Missing for the slice: tests, contract document, smoke, and the binding of a GovernanceDecision to the active
policy version with drift rejection (K3.3b).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>...
|
0
|
0
|
0
|
1
|
0
|
|
0
|
1790675308
|
1790675308
|
0
|
0
|
0
|
0
|
Edit
Delete
|
|
807
|
124
|
1
|
5
|
|
0
|
feat: add store manager cockpit prototype (tasks, feat: add store manager cockpit prototype (tasks, board, leaderboard)...
|
|
0
|
0
|
1
|
1
|
0
|
|
0
|
1791453499
|
1791453507
|
1791453507
|
0
|
0
|
0
|
Edit
Delete
|
|
843
|
146
|
1
|
1
|
|
0
|
php8.3
|
|
0
|
0
|
1
|
1
|
0
|
|
0
|
1793066913
|
1793066921
|
1793066921
|
0
|
0
|
0
|
Edit
Delete
|
|
844
|
83
|
1
|
5
|
|
0
|
docs(governance): sync dynamic baseline with curre docs(governance): sync dynamic baseline with current D3 reports...
|
Refresh the GOVERNANCE-BASELINE section of CLAUDE. Refresh the GOVERNANCE-BASELINE section of CLAUDE.md from
reports/governance.latest.json, reports/baseline-d3.json and the
2026-10-25 runtime/UI/RLS reports plus the 2026-09-23 OS audits:
static governance now passes, runtime 452, UI 46, RLS 116 tables,
own tests 69/471, single-host outbox/health scenarios, OS product
0.19.4 upgrade ready and release blocked only by remote CI and
target sign-off. Retire the native Fastify UI row and keep earlier
dual-host figures labelled as history.
Verified with check:governance-docs, check:docs-truth and
check:dual-backend (all exit 0); regenerated gate reports were not
committed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
<!--
PR 治理模板。提交前请逐项确认,确保符合 docs/standards 下的工程规范。
CI 会执行:pnpm check(命名 + 单源漂移 + 治理棘轮 + lint + typecheck);
有测试 DB 的流水线另执行 DATABASE_URL=... pnpm check:runtime。
-->
## 变更内容
<!-- 简述这次改了什么、为什么改(聚焦 why) -->
-
## 涉及业务概念
<!-- 列出涉及的业务词典英文名,例如 store / order / verification。参见 docs/domain-glossary.md -->
-
## 检查清单
### 命名一致性
- [ ] 业务概念使用了词典中的标准英文名(未出现 shop/branch/seller/voucher/writeOff 等禁用词)
- [ ] 数据库 snake_case + 复数表名;API/JSON 字段 camelCase;类型 PascalCase;常量 SCREAMING_SNAKE_CASE
- [ ] `pnpm check:naming` 通过
- [ ] `pnpm check:schema` 通过,未新增第二份状态/契约真源
### API / 契约
- [ ] 不涉及 API 变更
- [ ] 新增/修改了 API,路由符合当前生命周期规范:既有 Personnel Core 保持 `/api/personnel/*`,HR v2 领域使用 `/api/v2/{domain}/*`,身份协议使用标准 OIDC 端点
- [ ] 已更新 `packages/contracts` 中的 Zod schema / DTO / 类型(前后端共用同一份)
- [ ] 无破坏前端兼容的字段删除/重命名(如有,已在描述中说明迁移方案)
### 数据库
- [ ] 不涉及数据库变更
- [ ] 新增/修改了表或字段,已通过 migration review(表名复数、字段 snake_case、外键 xxx_id、时间 _at、状态 status)
- [ ] 高增长表已考虑分区;涉及多租户的表带 tenant_id
- [ ] 写链显式带 tenant_id;跨租户读写按 404/隔离口径处理
### 数据库迁移(迁移即代码:版本/顺序/内容/环境/发布/回滚一致)
- [ ] 改 schema.prisma 的同时**已生成并提交 migration**(`pnpm db:migrate:dev --name <change>`),未只改 schema 不落迁移
- [ ] **未修改已发布过的历史 migration 文件**(内容一致:历史不可变,新变更走新迁移)
- [ ] `pnpm check:migrations` 通过(迁移历史在位 / 无未豁免高危 DDL / schema 表、enum、`@map` 列均已落迁移)
- [ ] 破坏性变更(删表/删列/改名/改类型/加 NOT NULL/加唯一约束)走 **expand→migrate→contract** 三阶段,不一次切
- [ ] 大表加索引用 `CREATE INDEX CONCURRENTLY`;大批量回填走 BullMQ 分批任务,不塞进 migration
- [ ] 高危但确需的 DDL 已加 `-- migration-allow:<原因>` 留痕,并在下方回滚方案说明
- [ ] 非开发环境只用 `migrate deploy`(禁止 `db push` / 线上手动 ALTER);发布前 `pnpm db:migrate:status` 无 drift
### 实时 / 队列
- [ ] 不涉及
- [ ] 关键业务事件进入 BullMQ 或持久化事件表(未仅依赖 Redis Pub/Sub)
- [ ] 写库事件与真实写操作在同一 tx 写入 outbox,未在 commit 后旁路 publish
- [ ] 实时通道选型符合规范(订单/看板/通知用 SSE;设备在线/包间控制/IM 用 WebSocket)
### 质量与发布
- [ ] 通过 `pnpm lint` 与 `pnpm typecheck`
- [ ] 通过 `pnpm check:governance`,`reports/*.latest.json` 已刷新且无棘轮回退
- [ ] 涉及写链 / DB / 租户 / 状态机时,通过 `DATABASE_URL=... pnpm check:runtime`,`reports/runtime-acceptance.latest.json` 已刷新
- [ ] 涉及页面或浏览器行为时,`pnpm check:ui` 与 `pnpm check:ui:fastify` 均通过,未只验证一个后端
- [ ] 已补充/更新必要的测试
- [ ] 不需要回滚方案
- [ ] 需要回滚方案,已在下方说明
## 回滚方案 / 其他说明
-
...
|
0
|
0
|
1
|
1
|
0
|
|
0
|
1793092331
|
1793092337
|
1793092337
|
0
|
0
|
0
|
Edit
Delete
|
|
889
|
144
|
1
|
1
|
|
0
|
1
|
|
0
|
0
|
1
|
1
|
0
|
|
0
|
1793673556
|
1793673561
|
1793673561
|
0
|
0
|
0
|
Edit
Delete
|
|
893
|
143
|
1
|
1
|
|
0
|
0915版本
|
|
0
|
0
|
1
|
1
|
0
|
|
0
|
1793695768
|
1793695782
|
1793695782
|
0
|
0
|
0
|
Edit
Delete
|