fix(manual): 手工导出骨架与导入边界修复,单位按目录自然序排列

- 上传口骨架收集改为空操作,骨架仅经升级入库(决策 231/补记十四)
- s_lme_lib 价格快照垫底,修手工会话组成子行价格落 0
- 导出编辑相交消解:删除块与闭合前插入冲突时重映射,防采纳定额丢失/碎 XML
- _span 识别自闭合标签,防容器配对失败留孤儿闭合
- 手工导入放开空名/同名/深层级校验
- 单位顺序改按左侧目录树序(单项入库序+组内编号自然序)
- 补齐手工导出/导入/MCP 切换相关测试
This commit is contained in:
lianjianwei2024
2026-10-28 16:20:34 +08:00
parent 34b14e74ec
commit 8250a265fb
29 changed files with 4033 additions and 1128 deletions

View File

@@ -258,6 +258,16 @@ def _dyn_rows(sc, sid, uw_id=None):
uwp = _uw_price_rows(sc, sid) # 决策 219:主取价源=单位级(每单位每码认第一行)
away = _recode_away(sc, sid) # 决策 219:合并换码的旧码不显示
uwp = {c: lst for c, lst in uwp.items() if c not in away}
# 组成子码价格快照(s_lme_lib:采纳时从来源批次 lme_lib 带入)——手工会话没有源文件,
# 单位级/项目级三步链全空,组成子行(折旧费/检修费…)价会落 0(2026-10-28 主人实测
# 易达映射源里组成子行编制价全空);库快照垫在链条末尾
lbm = {}
try:
for r in sc.execute("SELECT code, name, spec, unit, kind, ntp, taxp "
"FROM s_lme_lib WHERE session_id=?", (sid,)):
lbm[r["code"]] = (r["name"], r["spec"], r["unit"], r["kind"], r["ntp"], r["taxp"])
except Exception:
lbm = {}
# 决策 219 兜底:单位级行三价缺 → 项目级快照补(主人定「编号或单价实在没有的去项目级取」)
for _c, _lst in uwp.items():
@@ -272,7 +282,7 @@ def _dyn_rows(sc, sid, uw_id=None):
_r["taxp"] = _p["taxp"]
def child_px(code, uw=None):
"""子级三价(母行Σ用,决策 219):本单位行 → 第一行 → 项目级快照兜底。"""
"""子级三价(母行Σ用,决策 219):本单位行 → 第一行 → 项目级快照 → s_lme_lib 快照兜底。"""
lst = uwp.get(code) or []
r = None
if uw is not None:
@@ -281,9 +291,10 @@ def _dyn_rows(sc, sid, uw_id=None):
r = lst[0]
p = pm.get(code) or {}
_pk = lambda a, b: (a if a is not None else b)
return (_pk(r and r["ntp"], p.get("ntp")),
lb = lbm.get(code) or (None, None)
return (_pk(_pk(r and r["ntp"], p.get("ntp")), lb[0]),
_pk(r and r["taxrate"], p.get("taxrate")),
_pk(r and r["taxp"], p.get("taxp")))
_pk(_pk(r and r["taxp"], p.get("taxp")), lb[1]))
def computed_mother(code, uw=None):
"""带子级母行 Σ 单价(除税,含税);任一子级无价→None(算不齐退行值)。"""
@@ -305,6 +316,19 @@ def _dyn_rows(sc, sid, uw_id=None):
"""11 列行。r=认下的单位级行(或快照 dict);带子级母行 Σ 现算(除非覆盖)。"""
p = pm.get(code) or {}
ntp, rate, taxp = r.get("ntp"), r.get("taxrate"), r.get("taxp")
# s_lme_lib 快照兜底(手工会话没有源文件:单位级/项目级行都没有,组成子行
# 折旧费/检修费等的名称/单位/单价从这里来——2026-10-28 主人实测映射源价全空)
lb = lbm.get(code)
if lb is not None:
_nm2, _sp2, _un2, _kd2, _ln, _lt = lb
if not (r.get("name") or "") and _nm2:
r = dict(r, name=_nm2, spec=(r.get("spec") or _sp2 or ""),
unit=(r.get("unit") or _un2 or ""),
kind=(r.get("kind") if r.get("kind") is not None else _kd2))
if ntp is None:
ntp = _ln
if taxp is None:
taxp = _lt
if kids.get(code) and not ov.get(code):
cn, ct = computed_mother(code, r.get("uw_id"))
if cn is not None: