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 数不出来)。
90 lines
3.7 KiB
TypeScript
90 lines
3.7 KiB
TypeScript
/** 撞款控制台/台账适配:/api/admin/shop-data-crawl/duplicate-check-console、-ledger、-export。 */
|
||
import { http } from '@/api/http'
|
||
import { toDuplicateItemsQuery, type DuplicateFilter } from './duplicate-filter.ts'
|
||
import {
|
||
parseDuplicateConsole,
|
||
parseLedgerPage,
|
||
type DuplicateConsole,
|
||
type LedgerPage,
|
||
} from './duplicate-console-model.ts'
|
||
|
||
export const DUPLICATE_CHECK_ENDPOINT = '/api/admin/shop-data-crawl'
|
||
|
||
/** console 端点吃 asin/shop_name/group/country/site/date_from/date_to(行窗口的 page/page_size/dup_group 由调用方另传)。 */
|
||
function toConsoleQuery(filter: DuplicateFilter): Record<string, string> {
|
||
const query: Record<string, string> = {}
|
||
const asin = (filter.asin || '').trim()
|
||
if (asin) query.asin = asin
|
||
const shopName = (filter.shopName || '').trim()
|
||
if (shopName) query.shop_name = shopName
|
||
const group = (filter.group || '').trim()
|
||
if (group) query.group = group
|
||
const country = (filter.country || '').trim()
|
||
if (country) query.country = country
|
||
const site = (filter.site || '').trim()
|
||
if (site) query.site = site
|
||
const dateFrom = (filter.dateFrom || '').trim()
|
||
if (dateFrom) query.date_from = dateFrom
|
||
const dateTo = (filter.dateTo || '').trim()
|
||
if (dateTo) query.date_to = dateTo
|
||
return query
|
||
}
|
||
|
||
export type LedgerSortKey = 'asin' | 'brand' | 'store_count' | 'record_count' | 'earliest' | 'latest'
|
||
|
||
/**
|
||
* 加载撞款控制台快照:GET /duplicate-check-console。
|
||
*
|
||
* 行窗口(B60):`page`/`pageSize` 决定返回的 `dup` 是这一窗,`dupGroup` 非空时行集先按
|
||
* 该分组成员裁剪(组内 ≥2 店才算撞款)。三者都是**服务端**口径——矩阵与详情卡片共用同一窗口,
|
||
* 页面不再自己从全集里切片(那需要后端把整份撞款数组发回来,正是 B60 要收掉的那件事)。
|
||
*/
|
||
export async function fetchDuplicateConsole(
|
||
filter: DuplicateFilter,
|
||
companyId?: number | null,
|
||
page = 1,
|
||
pageSize = 100,
|
||
dupGroup = '',
|
||
): Promise<DuplicateConsole> {
|
||
// toConsoleQuery 是白名单构造(只点名 asin/shop_name/group/country/site/date_*),
|
||
// 公司值只许落在本函数自己的 companyId 形参上。
|
||
const query: Record<string, string | number> = { ...toConsoleQuery(filter), page, page_size: pageSize }
|
||
const group = (dupGroup || '').trim()
|
||
if (group) query.dup_group = group
|
||
if (companyId != null) query.company_id = companyId
|
||
const { data } = await http.get<unknown>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-console`, { params: query })
|
||
return parseDuplicateConsole(data)
|
||
}
|
||
|
||
/** 加载全部 ASIN 台账分页(含未撞款):GET /duplicate-check-ledger。 */
|
||
export async function fetchDuplicateLedger(
|
||
filter: DuplicateFilter,
|
||
page: number,
|
||
pageSize: number,
|
||
sortKey: LedgerSortKey | '',
|
||
sortDir: 'asc' | 'desc',
|
||
companyId?: number | null,
|
||
): Promise<LedgerPage> {
|
||
const params: Record<string, string | number> = { ...toConsoleQuery(filter), page, page_size: pageSize }
|
||
if (sortKey) params.sort_key = sortKey
|
||
params.sort_dir = sortDir
|
||
if (companyId != null) params.company_id = companyId
|
||
const { data } = await http.get<unknown>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-ledger`, { params })
|
||
return parseLedgerPage(data)
|
||
}
|
||
|
||
/** 导出 Excel(撞款 view=monitor / 台账 view=all):GET /duplicate-check-export → xlsx Blob。 */
|
||
export async function requestDuplicateExportBlob(
|
||
filter: DuplicateFilter,
|
||
view: string,
|
||
companyId?: number | null,
|
||
): Promise<Blob> {
|
||
const itemsQuery = toDuplicateItemsQuery({ ...filter, view }, 1, 100)
|
||
if (companyId != null) itemsQuery.company_id = companyId
|
||
const { data } = await http.get<Blob>(`${DUPLICATE_CHECK_ENDPOINT}/duplicate-check-export`, {
|
||
params: itemsQuery,
|
||
responseType: 'blob',
|
||
})
|
||
return data
|
||
}
|