feat(lme): 决策184 导出A清洗每码留一条,自闭合归并行登记即重建子级

This commit is contained in:
lianjianwei2024
2026-10-23 17:41:04 +08:00
parent 30de80cf32
commit 582e3870e1
4 changed files with 51 additions and 23 deletions

View File

@@ -29,13 +29,13 @@ def _two_nodes(code, price="6.99", qty1="64.1300", qty2="47.8060"):
def test_recode_all_hits_same_code_multi_nodes():
"""换码通道:同码两条节点全部换成保留码,一条都不留。"""
"""换码通道 + 决策 184 A 清洗:同码两条节点归并后**每码只留一条**(保留最后一条
47.806,前一条被吸收删除——条目数=显示端,2026-10-23 主人定)。"""
out = xcos.transform_unit_summaries(_two_nodes("A3"), {}, None, recode_map={"A3": "A1"})
assert out.count('Number="A1"') == 2
assert out.count('Number="A1"') == 1
assert 'Number="A3"' not in out
# 数量各随各节点(64.13 / 47.806),不串位
qs = re.findall(r'Quantity="([0-9.]+)"', out)
assert qs == ["64.1300", "47.8060"]
assert qs == ["47.8060"]
def test_price_updates_all_hits():
@@ -63,10 +63,10 @@ def test_recode_with_children_all_hits():
out = xcos.transform_unit_summaries(txt, {}, None,
recode_map={"B3": "C1"},
recode_children={"B3": [["000002", 9.0]]})
assert out.count('Number="C1"') == 2 and 'Number="B3"' not in out
assert out.count('Number="C1"') == 1 and 'Number="B3"' not in out # 决策 184 A 清洗:每码一条
kids = re.findall(r'<LabourMaterialsEquipmentsMachinesElement Number="([^"]+)"[^>]*Quantity="([^"]+)"', out)
assert kids == [("000002", "9.0000"), ("000002", "9.0000")]
assert out.count(f"</{S}>") == 2 # 两个成对块结构完好
assert kids == [("000002", "9.0000")] # 保留最全成对块,子级照常重建
assert out.count(f"</{S}>") == 1 # 成对块结构完好
def test_project_hidden_deletes_all_hits():
@@ -125,10 +125,10 @@ def test_bare_open_tag_rows_all_recode():
recode_children={"A3": [["000002", 9.0]]})
out = xcos._recode_norm_lme_rows(out, {"A3": "A1", "B9": "B1"})
assert 'Number="A3"' not in out and 'Number="B9"' not in out
assert out.count('Number="A1"') == 4 # 两条裸行 + 块外元素行 + 成对块
assert out.count('Number="A1"') == 2 # 决策 184 A 清洗:三处 A3 留最全成对块一条 + 块外元素行
assert 'Number="B1"' in out
assert 'Number="000002"' in out and 'Number="000001"' not in out # 真块子级照常重建
assert out.count(f"</{S}>") == 1 # 只真块有闭标签:裸行只换码,不发明闭块结构
assert 'Number="000002"' in out and 'Number="000001"' not in out # 最全成对块的子级照常重建
assert out.count(f"</{S}>") == 1 # 只保留的真块有闭标签:裸行被清洗,不发明闭块结构
def test_recode_norm_lme_rows_all_element_rows():
@@ -156,7 +156,7 @@ def test_recode_chain_flattened_to_tail():
+ '</r>')
out = xcos.transform_unit_summaries(txt, {}, None, recode_map={"A3": "A1", "A1": "A9"})
assert 'Number="A3"' not in out and 'Number="A1"' not in out
assert out.count('Number="A9"') == 2 # 链上两码全部落到链尾
assert out.count('Number="A9"') == 1 # 链上两码全部落到链尾 + 决策 184 A 清洗:每码一条
def test_recode_chain_resolve_helper():