统一:DSH 智能分析、Top100 与图表静默恢复

接入 DSH 专用运行时和对话界面,保留模型原始回答,支持会话分页、连续追问与显式报告。
补齐组合筛选、各维度 Top100、分组查询到排名图的转换,图表故障静默省略并基于保存数据自动恢复。
优化报告风格、图表顺序和表格换行,更新接入说明及构建输入。

验证:独立目录前后端构建通过;118 项 Java、102 项前端、102 项图表、14 项 DSH 应用和 13 项组合筛选检查通过。
仅提交相关源码、锁定依赖与测试;不包含凭据、会话、业务数据或本地产物。
This commit is contained in:
2026-11-12 11:57:41 +08:00
parent cc8832c8e5
commit f1a2fbd494
166 changed files with 26281 additions and 2248 deletions
+56
View File
@@ -1636,6 +1636,62 @@ class HistoryReportExecutionTest(unittest.TestCase):
wrong_collective = _bind_literal_measures(wrong_collective, ranked_tokens, {}, facts=ranked)
self.assertIn('1155.48340000、1106.25、1060.75', wrong_collective['blocks'][0]['text'])
def test_unknown_unit_rank_mass_requires_exact_local_metric_and_never_invents_unit(self):
from nao_native_answer import (NativeCompositionError, _bind_exact_identifiers,
_bind_exact_periods, _bind_exact_year_literals, _bind_literal_measures,
_binding_inventory, _validate_blocks)
def ranked_fact(fact_id='R1', *, rank_group='history-rank:verified', source_turn='turn-1', value='36.00'):
return {'id': fact_id, 'kind': 'product', 'label': '规格一',
'text': f'2026年8月:规格一综合报废重量 = {value}。',
'evidenceRef': 'history:' + fact_id,
'sourceTurnId': source_turn, 'sectionIndex': 2, 'rank': 1,
'rankGroupKey': rank_group,
'scope': {'period': {'year': 2026, 'month': 8}, 'filters': {},
'dimension': 'product', 'stage': 'overall'},
'validity': {'verified': True, 'basis': 'protocol_history_snapshot'},
'verifiedIdentifiers': [{'value': '规格一'}],
'verifiedDisplayValues': [{'metricCode': 'scrapWeight', 'rawValue': value,
'rawUnit': 'source_weight', 'unit': 'source_weight', 'displayValue': value}]}
fact = ranked_fact()
facts = [fact]
tokens = _binding_inventory(facts)
def bind(text, cited=None):
draft = {'blocks': [{'text': text, 'factIds': cited or ['R1'], 'role': 'core'}]}
for binder in (_bind_exact_identifiers, _bind_exact_periods, _bind_exact_year_literals):
draft = binder(draft, tokens, {})
return _bind_literal_measures(draft, tokens, {}, facts=facts)
accepted = bind('2026年8月规格一综合报废重量为36.000。')
self.assertRegex(accepted['blocks'][0]['text'], r'\{\{N[1-9][0-9]*\}\}')
rendered, _ = _validate_blocks(accepted, facts, tokens)
self.assertIn('36.00', rendered[0]['text'])
self.assertNotIn('kg', rendered[0]['text'])
self.assertNotIn('source_weight', rendered[0]['text'])
for invalid in (
'2026年8月规格一综合报废重量为36.000 kg。',
'2026年8月规格一综合合格率97.19%,29。',
):
with self.subTest(invalid=invalid):
draft = bind(invalid)
self.assertNotIn('{{N', draft['blocks'][0]['text'])
with self.assertRaises(NativeCompositionError):
_validate_blocks(draft, facts, tokens)
same_value_other_provenance = ranked_fact('R2', rank_group='history-rank:other',
source_turn='turn-2')
ambiguous_facts = [fact, same_value_other_provenance]
ambiguous_tokens = _binding_inventory(ambiguous_facts)
ambiguous = {'blocks': [{'text': '2026年8月规格一综合报废重量为36.00。',
'factIds': ['R1', 'R2'], 'role': 'core'}]}
for binder in (_bind_exact_identifiers, _bind_exact_periods, _bind_exact_year_literals):
ambiguous = binder(ambiguous, ambiguous_tokens, {})
ambiguous = _bind_literal_measures(ambiguous, ambiguous_tokens, {}, facts=ambiguous_facts)
self.assertNotIn('{{N', ambiguous['blocks'][0]['text'])
def test_history_parent_predicate_mass_inheritance_uses_family_stage_and_exact_fact(self):
from nao_native_answer import (NativeCompositionError, _bind_exact_identifiers,
_bind_exact_periods, _bind_exact_year_literals, _binding_inventory, _validate_blocks)