import type { SearchReport } from '../lib/day2' /** 市场报告按已冻结的查询条件展示平台聚合。缺失月份保留为空,避免把未返回的数据当成零公告。 */ export function MarketReport({ report }: { report: SearchReport }) { const { conditions, market } = report const { beginDate, endDate, keywords, hardRegions } = conditions const aggregates = market?.platformAggregations ?? [] const monthly = aggregates.find(group => group.tool === 'aggregate_bids_advanced') const endMonth = new Date(`${endDate.slice(0, 7)}-01T00:00:00Z`) const months = Array.from({ length: 6 }, (_, index) => { const month = new Date(endMonth) month.setUTCMonth(month.getUTCMonth() - (5 - index)) const key = month.toISOString().slice(0, 7) month.setUTCMonth(month.getUTCMonth() + 1, 0) return { key, complete: `${key}-01` >= beginDate && month.toISOString().slice(0, 10) <= endDate, row: monthly?.rows.find(row => row.name === key) } }).filter(month => month.key >= beginDate.slice(0, 7)) const [prior, latest] = months.filter(month => month.complete).slice(-2) const priorCount = prior?.row?.count, latestCount = latest?.row?.count // 查询首尾可能仅覆盖部分月份,趋势仅比较相邻的完整月,且两个月都必须有平台计数。 const trend = priorCount == null || latestCount == null ? '当前统计范围内相邻完整月的数据不足,暂无法判断趋势。' : `${latest.key}公告数为 ${latestCount} 条,${prior.key}为 ${priorCount} 条,${latestCount === priorCount ? '环比持平' : `环比${latestCount > priorCount ? '增加' : '减少'} ${Math.abs(latestCount - priorCount)} 条`}。` return
统计范围:{hardRegions.join('、') || '全国'} · {beginDate} 至 {endDate} · {keywords.join('、')}
{trend}
| 月份 | 公告数 | 金额合计(万元) |
|---|---|---|
| {key}{complete ? '' : '(部分)'} | {row?.count ?? '—'} | {row?.amountWan?.toLocaleString('zh-CN') ?? '—'} |
平台月度聚合结果尚未取得。
}本次未返回排名记录。
}平台聚合按实际查询条件统计。月表仅展示所选时段末尾最多六个自然月,横线表示平台未返回数据。
}