c8cd75cf6c
接管另一路会话的 Phase 5 在飞件收口(5A/5C 主体由那一路落码,本笔补齐 P1-B7 与两处台账并整量验证)。 - 5A/B60:撞款 console 的行窗口在服务端真分页(响应 dup 行数 ≤ pageSize,total_dup 仍是未分页 总数)、dupGroup 判据收归服务端单一出处(前端 dupWithinGroup 删掉,两套同名规则不再分叉)、 排序先于切窗;后管矩阵改预聚合+列窗 40。读数(200 列 × 50 行):每行 3 店 8.4 → 5.3 → 0.7ms (12.4×),每行 40 店 83.7 → 18.4 → 1.8ms(45.3×)。服务端不设列窗是判断不是漏做:shops 每行 只有 5 个标量,而矩阵的列来自已分页的行——给 shops 再加分页会把"全局指标读全集"和"列窗读本页" 两套语义搅在一起。浏览器首屏/交互耗时本机拿不到,登记为 Phase 6 现网复量。 - P1-B6:claim 循环的父任务终态判定折成一次批量 IN(TaskFileJobBatchQueries+Mapper XML, 铁律 1 收口在 Mapper),逐行 CAS 认领一字不动。 - P1-B5:V187 只建 idx_biz_file_task_resume_of;审计给的候选集索引**有意不建**(V184 前缀已覆盖, OR/IS-NULL 与 COALESCE 不可索引),判据把这条负判定钉住。真库 EXPLAIN 本机无 MySQL,顺延现网。 - P1-B8:结果载荷的对象存储删除移到 afterCommit,事务里不再做 120s 超时的网络调用。 - P1-B7:结果集读取按窗提交+收割(窗口=线程池队列容量的一半)。审计把它记成"无 limit",但截断 是正确性错误不是性能取舍,真能收的是"整份结果集被读两遍"——一次性提交时每支 Future 把解好的 载荷扣在自己身上直到全部收割完,峰值=结果集+另一份整副本;分窗后副本只驻留一窗。流式组装 契约要改 4 个模块的调用方,本 Phase 未做,别读成 P1-B7 已闭环。 - SourceScanTest 台账随之登记:裸名 25 → 26、调用方 18 → 19(P1-B7 的窗口判据只能打在源码上—— 线程池只有 8 个线程,"同时开始读几行"改前改后读数相同,差异只体现在堆上,mock 数不出来)。
138 lines
9.9 KiB
TypeScript
138 lines
9.9 KiB
TypeScript
import test from 'node:test'
|
||
import assert from 'node:assert/strict'
|
||
import { readSource } from './helpers.ts'
|
||
import { aggregateDrawerRows, drawerSummaryOf } from '../src/pages/tasks/duplicate-console-logic.ts'
|
||
|
||
// 验收反馈:店铺重复检测对齐 reference —— 本轮补齐 P0 缺口:
|
||
// 分组筛选生效、抽屉聚合+汇总徽章、台账计数打开即显示、撞款计数走后端 total_dup、矩阵表头吸顶。
|
||
|
||
test('align_dup_console_group_filter_wired', () => {
|
||
const api = readSource('src/pages/tasks/duplicate-console-api.ts')
|
||
assert.match(api, /query\.group = group/, 'console 查询携带 group 参数')
|
||
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
|
||
assert.match(page, /group: filter\.group\.trim\(\)/, '页面筛选把 group 传给查询')
|
||
})
|
||
|
||
test('align_dup_console_group_filter_backend', () => {
|
||
const ctrl = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/shopduplicatecheck/controller/AdminShopDataDuplicateCheckController.java')
|
||
assert.match(ctrl, /@RequestParam\(name = "group"/, '后端 console/ledger 接收 group 参数')
|
||
assert.match(ctrl, /withGroupFilter\(visibleKeys, scan, group\)/, '端点按分组裁剪可见店铺')
|
||
const service = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/shopduplicatecheck/service/ShopDataDuplicateCheckQueryService.java')
|
||
assert.match(service, /withGroupFilter/, 'service 提供分组裁剪方法')
|
||
assert.match(service, /分组筛选/, '分组筛选留中文排查日志')
|
||
})
|
||
|
||
test('align_dup_console_drawer_aggregation', () => {
|
||
const rows = aggregateDrawerRows([
|
||
{ asin: 'A', date: '2026-09-02 10:00', price: '1', brand: 'B', shopName: '店1', groupName: '组1', countryCodes: [], country: 'DE' },
|
||
{ asin: 'A', date: '2026-09-01 10:00', price: '1', brand: 'B', shopName: '店1', groupName: '组1', countryCodes: [], country: 'DE' },
|
||
{ asin: 'A', date: '2026-09-03 10:00', price: '1', brand: 'B', shopName: '店2', groupName: '组1', countryCodes: [], country: 'UK' },
|
||
])
|
||
assert.equal(rows.length, 2, '按店铺×站点聚合')
|
||
assert.equal(rows[0].count, 2, '同店同站次数累加')
|
||
assert.deepEqual(rows[0].times, ['2026-09-01 10:00', '2026-09-02 10:00'], '时间升序')
|
||
const summary = drawerSummaryOf(rows.flatMap((row) => row.times.map((time) => ({ asin: 'A', date: time, price: '1', brand: 'B', shopName: row.shopName, groupName: '组1', countryCodes: [], country: row.country }))))
|
||
assert.equal(summary.shopCount, 2)
|
||
assert.equal(summary.totalRecords, 3)
|
||
assert.equal(summary.earliest, '2026-09-01 10:00')
|
||
})
|
||
|
||
test('align_dup_console_drawer_template', () => {
|
||
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
|
||
assert.match(page, /drawerAggRows/, '抽屉渲染聚合行')
|
||
assert.match(page, /drawerSummary/, '抽屉渲染汇总徽章')
|
||
assert.match(page, /次上架/, '汇总含 N 次上架')
|
||
assert.match(page, /<th[^>]*>次数<\/th>/, '聚合表含次数列')
|
||
assert.match(page, /v-for="row in drawerRows"/, '抽屉聚合表绑定分页切片')
|
||
assert.match(page, /:total="drawerAggRows\.length"/, '抽屉聚合表有分页器')
|
||
})
|
||
|
||
test('align_dup_console_pagination_all_lists', () => {
|
||
// 全站统一收官:撞款页四处列表(分布/矩阵/撞款详情卡片/抽屉明细)均挂共享 OldPagination,
|
||
// 且分布/矩阵/详情常显(不足一页也显示分页器,反馈:数据少时看不到分页)。
|
||
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
|
||
assert.match(page, /:total="distCount"/, '店铺上架分布有分页器(常显)')
|
||
// B60:撞款行改由服务端切窗口,矩阵与详情卡片读同一窗 ⇒ 两个分页器必须共用同一个游标
|
||
// (各自独立翻页在"一窗"的形状下已经不可表示,留着就是界面说一套、请求发另一套)。
|
||
assert.match(page, /:total="totalDupCount"[\s\S]*:page="matrixPage"/, '撞款覆盖矩阵分页器绑服务端总数与行窗口游标')
|
||
assert.match(page, /v-for="item in dupItems"/, '撞款详情卡片绑这一窗行集')
|
||
assert.match(page, /:total="totalDupCount"[\s\S]*:page-size="matrixPageSize"/, '撞款详情卡片分页器与矩阵同游标')
|
||
assert.doesNotMatch(page, /dupCardPage/, '卡片不再自持一个分页游标(同窗就是同游标)')
|
||
assert.doesNotMatch(page, /matrixRows/, '矩阵不再客户端切片(行窗口是服务端切的)')
|
||
assert.match(page, /<OldPagination[^>]*:total="distCount"/, '分布分页器无 v-if 条件')
|
||
assert.match(page, /<OldPagination[^>]*:total="totalDupCount"/, '矩阵/详情分页器无 v-if 条件')
|
||
assert.match(page, /v-for="group in pagedGroupStats"/, '分组说明抽屉表绑定分页切片')
|
||
assert.match(page, /:total="groupStats\.length"/, '分组说明抽屉表有分页器')
|
||
})
|
||
|
||
/**
|
||
* B60 的前后两处出口:行窗口三键要真发出去,矩阵格子要一次算完。
|
||
* 反向自证:把 api 改回不带 page/page_size、或把模板改回逐格 filter,即红。
|
||
*/
|
||
test('align_dup_console_b60_row_window_and_precomputed_cells', () => {
|
||
const api = readSource('src/pages/tasks/duplicate-console-api.ts')
|
||
assert.match(api, /page, page_size: pageSize/, 'console 请求带行窗口参数')
|
||
assert.match(api, /query\.dup_group = group/, 'console 请求带分组裁行参数')
|
||
assert.doesNotMatch(api, /多余分页参数后端忽略/, '旧注释说分页参数被后端忽略,现在后端认了')
|
||
|
||
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
|
||
// 矩阵窗口那一层已从页面拆进 `duplicate-matrix-window.ts`(B60 之后本页顶在可读性基线的
|
||
// 超长文件名单上,只许减)。绊线跟着搬,判据一字不松:改回逐格 filter 照样红。
|
||
const matrix = readSource('src/pages/tasks/duplicate-matrix-window.ts')
|
||
assert.match(page, /useDuplicateMatrix\(/, '页面接的是矩阵窗口组合式')
|
||
assert.match(matrix, /buildMatrixCells\(/, '矩阵格子一次预聚合')
|
||
assert.match(matrix, /MATRIX_COLUMN_WINDOW = 40/, '列数有窗口上限(按列切窗)')
|
||
assert.match(page, /v-for="\(cell, index\) in row\.cells"/, '模板只读预聚合好的格子')
|
||
assert.doesNotMatch(page, /function cellCount\(/, '逐格 filter 那套函数已收掉')
|
||
assert.doesNotMatch(matrix, /function cellCount\(/, '窗口组合式里也不许再长出逐格 filter')
|
||
|
||
const service = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/shopduplicatecheck/service/ShopDataDuplicateCheckQueryService.java')
|
||
assert.match(service, /consoleData\(DuplicateScanView view, Set<String> visibleKeys, Filters filters,\s*\n?\s*int page, int pageSize, String dupGroup\)/,
|
||
'服务端 console 收行窗口与分组参数')
|
||
assert.match(service, /"total_dup", total,/, 'total_dup 是未分页总数,不是本页行数')
|
||
})
|
||
|
||
test('align_dup_console_ledger_total_preload', () => {
|
||
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
|
||
assert.match(page, /onMounted\(\(\) => \{\s*loadConsole\(\).*loadLedger\(1\)/s, '挂载即预取台账计数')
|
||
assert.match(page, /totalDup/, '撞款计数走后端 total_dup 字段')
|
||
})
|
||
|
||
test('align_dup_console_matrix_sticky', () => {
|
||
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
|
||
assert.match(page, /table\.matrix th\s*\{[^}]*position:\s*sticky/, '矩阵表头吸顶')
|
||
assert.match(page, /\.matrix-wrap\s*\{[^}]*max-height/, '矩阵容器限高滚动')
|
||
})
|
||
|
||
test('align_dup_console_role_scope_group_filter_only_super', () => {
|
||
// 角色范围:分组筛选下拉仅超管需要;管理员数据由后端裁到本组。
|
||
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
|
||
assert.match(page, /useAdminSessionStore/, '页面读取登录会话取角色')
|
||
assert.match(page, /const isSuper = computed\(\(\) => session\.isSuperAdmin\)/, 'isSuper 由会话角色推导')
|
||
assert.match(page, /<div v-if="isSuper" class="f-group">\s*<label>分组<\/label>/s, '分组筛选仅超管可见')
|
||
assert.match(page, /group: filter\.group\.trim\(\)/, '分组筛选仍参与查询参数')
|
||
})
|
||
|
||
test('align_dup_console_role_scope_group_controls_only_super', () => {
|
||
// 分组撞款/分组说明为超管专属交互;后端超管全量、管理员所管分组店铺。
|
||
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
|
||
assert.match(page, /<div v-if="isSuper" class="scope-bar">/, '分组撞款分段仅超管可见')
|
||
assert.match(page, /v-if="isSuper" class="btn btn-ghost btn-sm" type="button" @click="groupInfoVisible = true"/, '分组说明按钮仅超管可见')
|
||
const service = readSource('../backend-java/src/main/java/com/nanri/aiimage/modules/shopduplicatecheck/service/ShopDataDuplicateCheckQueryService.java')
|
||
// 2026-10-05 批次 3 之后「超管全量」不再是 `if (superAdmin) return null`,而是"超管且没切公司 tab(成员集为 null)"。
|
||
// 逐字判据 + 空成员集那支一起钉:后者一旦退化成 null,第二家公司会看到全部店铺(语义由
|
||
// ShopDataDuplicateCheckCompanyScopeTest 用真调用验,这里只保证源码形状没被顺手改回去)。
|
||
assert.match(service, /if \(companyMemberIds == null\) \{\s*return null;/, '超管未切公司 tab=全量(null)')
|
||
assert.match(service, /companyMemberIds\.isEmpty\(\)\s*\?\s*new LinkedHashSet<>\(\)/,
|
||
'公司一个账号都没有=空可见集,不许退化成 null')
|
||
assert.match(service, /selectManagedShopNames\(operatorId\)/, '管理员可见范围=所管分组店铺')
|
||
})
|
||
|
||
test('align_dup_console_country_labels_chinese', () => {
|
||
// 反馈:国家显示一定要用中文——站点/国家一律经 asinCountryLabel 映射,禁止裸国家码直出。
|
||
const page = readSource('src/pages/tasks/DuplicateCheckPage.vue')
|
||
assert.match(page, /asinCountryLabel\(/, '站点显示走中文映射函数')
|
||
assert.doesNotMatch(page, /\{\{\s*(row|item)\.country\s*\}\}/, '表格/抽屉无裸国家码直出')
|
||
assert.match(page, /asinCountryLabel\(code\)/, '筛选下拉站点显示中文')
|
||
})
|