同步:完善质量分析工作台并更新主题字体
同步已上线的智能分析执行协议、来源查询、图表报告与管理页面配套代码。 补齐数据库迁移、运行依赖和回归测试,保留原有指标计算口径。 统一午夜黑及其他主题的控件细节、中文和业务数字字体。 排除本地业务数据、凭据、预览、发布与验收产物。 验证:生产构建通过,320项前端回归通过;本轮仅同步Git,不再次部署。
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import { conclusionMarkdown, conclusionDisplayText, type AnalysisReadingSummary } from './analysisReadingModel.ts';
|
||||
import { analysisTextEvidenceRefs } from './analysisEvidenceRefs.ts';
|
||||
import type { AnalysisVisual } from './analysisVisualsModel.ts';
|
||||
|
||||
export interface ConclusionComparison {
|
||||
metric: string; previousLabel: string; currentLabel: string;
|
||||
previous: string; current: string; direction: string; change: string; unit: string;
|
||||
original: string;
|
||||
}
|
||||
export interface ConclusionSection {
|
||||
id: string; title: string; markdown: string; note: string; visuals: AnalysisVisual[];
|
||||
}
|
||||
|
||||
/** Read only an explicit, checked comparison sentence. No KPI or difference is calculated. */
|
||||
export function checkedConclusionComparison(sentence: string): ConclusionComparison | null {
|
||||
const value = sentence.replace(/\*\*/g, '').trim();
|
||||
const match = value.match(/^([^。;\n]{1,50}?)(综合合格率|黑片合格率|亮片合格率|合格率)(?:为|是|[::])?\s*(\d+(?:\.\d+)?%)\s*[,,]\s*(?:较|相比|对比|比)\s*([^,,。;\n]{1,30}?)的?\s*(\d+(?:\.\d+)?%)\s*(下降|上升|提高|降低)\s*(\d+(?:\.\d+)?)(个百分点|pp)[。.]?$/);
|
||||
if (!match || [match[3], match[5]].some(rate => Number.parseFloat(rate) > 100)) return null;
|
||||
return { metric: match[2], currentLabel: match[1], current: match[3], previousLabel: match[4].replace(/的$/, ''), previous: match[5], direction: match[6], change: match[7], unit: match[8], original: value };
|
||||
}
|
||||
|
||||
function topicMatches(title: string, visual: AnalysisVisual): boolean {
|
||||
if (/黑片/.test(title) && !/亮片/.test(title) && visual.stage === 'bright'
|
||||
|| /亮片/.test(title) && !/黑片/.test(title) && visual.stage === 'black') return false;
|
||||
if (visual.dimension === 'product') return /产品|规格/.test(title);
|
||||
if (visual.dimension === 'department') return /产业部|部门/.test(title);
|
||||
if (visual.dimension === 'group') return /业务分组|分组|区域/.test(title);
|
||||
if (visual.dimension === 'defect' || visual.metric.startsWith('source_defect')) return /缺陷|源字段|缺角|磕边|隐裂/.test(title);
|
||||
if (visual.sectionKey?.startsWith('category')) return /报废大类|报废类别|正式报废/.test(title);
|
||||
if (visual.type === 'waterfall' || visual.metric === 'composite_impact_pp') return /结论|总体|阶段/.test(title);
|
||||
if (visual.type === 'line' || visual.type === 'area') return /趋势|逐月|期间/.test(title);
|
||||
return /结论|总体|阶段/.test(title) && /^(?:composite|black|bright)_rate$/.test(visual.metric);
|
||||
}
|
||||
|
||||
/** Chapters preserve the model's checked words/order; figures must also share its actual reference. */
|
||||
export function buildConclusionDocument(reading: AnalysisReadingSummary, visuals: AnalysisVisual[]) {
|
||||
const raw = conclusionMarkdown(reading, true);
|
||||
const chunks: Array<{ title: string; lines: string[]; note: string }> = [{ title: '核心结论', lines: [], note: '' }];
|
||||
const lines = raw.split('\n');
|
||||
let fenced = false;
|
||||
for (let index = 0; index < lines.length; index += 1) {
|
||||
const line = lines[index];
|
||||
if (/^\s*```/.test(line)) { fenced = !fenced; chunks.at(-1)!.lines.push(line); continue; }
|
||||
const heading = !fenced ? line.match(/^#{1,6}\s+(.+?)\s*#*\s*$/) : null;
|
||||
const bold = !fenced ? line.match(/^\*\*([^*\n]{1,45})\*\*\s*(?:([((][^\n]*[))])\s*[::]?\s*$|[::]\s*([^\n]*)$|$)/) : null;
|
||||
// These are explicit topic introductions in saved prose, not inferred causes.
|
||||
const topic = !fenced ? line.match(/^(报废重量方面|黑片报废大类中|亮片报废大类中)[,,]\s*(.+)$/) : null;
|
||||
if (heading || bold && /[\p{L}]/u.test(bold[1]) || topic) {
|
||||
const category = topic && /报废大类中$/.test(topic[1]);
|
||||
const title = heading?.[1] || bold?.[1] || (category ? '报废类别变化' : topic![1].replace(/方面$/, ''));
|
||||
chunks.push({ title, lines: bold?.[3] ? [bold[3]] : topic ? [category ? line : topic[2]] : [], note: bold?.[2] || '' });
|
||||
} else chunks.at(-1)!.lines.push(line);
|
||||
}
|
||||
const clean = (value: string) => conclusionDisplayText(value, reading.evidenceRefs);
|
||||
const sections = chunks.filter(chunk => chunk.lines.join('').trim() || chunk.note).map((chunk, index) => {
|
||||
const cited = chunk.lines.join('\n').trim();
|
||||
return { id: `conclusion-${index + 1}`, title: clean(chunk.title), markdown: clean(cited), note: clean(chunk.note), visuals: [] as AnalysisVisual[], refs: analysisTextEvidenceRefs(cited) };
|
||||
});
|
||||
// The card replaces exactly one explicit comparison sentence. Other words,
|
||||
// such as scope, mechanisms and limitations, remain in their original section.
|
||||
const first = sections[0];
|
||||
const sentence = first?.markdown.match(/^[^\n]*?[。](?:\s*|$)/)?.[0].trim();
|
||||
const comparison = sentence ? checkedConclusionComparison(sentence) : null;
|
||||
if (comparison) first.markdown = first.markdown.slice(sentence!.length).trimStart();
|
||||
|
||||
for (const visual of visuals) {
|
||||
const candidates = sections.filter(section => topicMatches(section.title, visual) && visual.evidenceRefs.some(ref => section.refs.includes(ref)));
|
||||
if (candidates.length === 1) candidates[0].visuals.push(visual);
|
||||
else sections.push({ id: `conclusion-chart-${sections.length + 1}`, title: visual.title, markdown: '', note: '', visuals: [visual], refs: [] });
|
||||
}
|
||||
return { comparison, sections: sections.map(({ refs: _refs, ...section }) => section) as ConclusionSection[] };
|
||||
}
|
||||
Reference in New Issue
Block a user