feat(qaops): 完成区域统计与部门绑定六项联动
build / build (push) Successful in 1m20s

新增北京时间自然周校验与缓存隔离,默认展开到业务二级部门。
选中部门在统计页就地绑定;区域名称列表原位增删改,双版本锁、自动预览、独立读回及删除确认。
筛选和两张区域看板使用同一已保存目录,删除失效筛选回全部。

验证:完整 make verify、全 mirror 隔离 PostgreSQL race、自然周边界与缓存键负例通过;真实恢复库327部门逐行对拍及六项浏览器验收通过。
schema57无迁移,不改真实公司区域绑定或原始问答,不连接DobotAI生产源库;PNG导出本轮不冒充已验证。
This commit is contained in:
姚章浩
2026-10-19 23:41:01 +08:00
parent 9470a127f7
commit 154b0b62ad
18 changed files with 933 additions and 560 deletions
+23 -2
View File
@@ -1,11 +1,13 @@
import { qaWeek } from './qaWeeks'
import type { QAOrganizationVersion } from './qaOps'
import { parseQAOrganizationVersion } from './qaOps'
import { parseRegionDefinitions } from './qaOrg'
import { departmentTree } from './qaRegionSelection'
import type { RegionDefinition } from './qaOrg'
export interface DepartmentStatisticsQuery {
period: 'all' | 'month'
period: 'all' | 'month' | 'week'
month?: string
week?: string
}
export interface DepartmentStatistic {
id: string
@@ -25,8 +27,9 @@ export interface DepartmentStatisticsSnapshot {
total_people: number
organization: QAOrganizationVersion
regions: RegionDefinition[]
period: 'all' | 'month'
period: 'all' | 'month' | 'week'
month: string
week: string
start: string | null
end: string
generated_at: string
@@ -68,7 +71,9 @@ export function parseDepartmentStatistics(raw: unknown, query: DepartmentStatist
const regions = parseRegionDefinitions(d.regions),
regionIDs = new Set(regions.map((r) => r.id))
if (
!['all', 'month', 'week'].includes(query.period) ||
d.period !== query.period ||
(d.week === undefined ? '' : text(d.week)) !== (query.week ?? '') ||
d.month !== (query.month ?? '') ||
!Array.isArray(d.rows) ||
!d.rows.length ||
@@ -85,6 +90,21 @@ export function parseDepartmentStatistics(raw: unknown, query: DepartmentStatist
(start !== null && Date.parse(start) >= Date.parse(end))
)
return bad()
if (query.period === 'week') {
if (!query.week || !/^\d{4}-W\d{2}$/.test(query.week) || query.month) return bad()
let range
try {
range = qaWeek(Number(query.week.slice(0, 4)), Number(query.week.slice(6)))
} catch {
return bad()
}
if (
start === null ||
Date.parse(start) !== Date.parse(range.start + ':00+08:00') ||
Date.parse(end) > Date.parse(range.end + ':00+08:00')
)
return bad()
}
const total_people = count(d.total_people),
total_visits = count(d.total_visits),
unmapped_visits = count(d.unmapped_visits)
@@ -161,6 +181,7 @@ export function parseDepartmentStatistics(raw: unknown, query: DepartmentStatist
regions,
period: query.period,
month: query.month ?? '',
week: query.week ?? '',
start,
end,
generated_at: generated,