feat(adopt): 决策273 单价行 Total 采纳逻辑迁回 API 侧并调整 x_side 读取

This commit is contained in:
lianjianwei2024
2026-11-05 08:24:06 +08:00
parent e113eb0264
commit 0dcdddc4a1
19 changed files with 196 additions and 216 deletions

View File

@@ -270,17 +270,6 @@ def _child_block_html(txt, rows):
return "".join(sep_e + _child_node(ktmpl, c, q) for (c, q) in rows)
def _adopt_totals(frag, sm):
"""决策 273:单价行 Total 按 Name 匹配回填——一致=外部该行 Total;不一致=空串(留空)。
只动骨架已有的 UnitPriceCalculationOfItem 自闭合行(卡槽在才写)。"""
def _f(m):
a = dict(re.findall(r'(\w+)="([^"]*)"', m.group(1)))
nm = (a.get("Name") or "").strip()
v = sm.get(nm)
return _attr_set(m.group(0), "Total", "" if v is None else v)
return re.sub(r'<UnitPriceCalculationOfItem\b([^>]*?)/>', _f, frag)
def _zero_results(frag):
"""决策 106:克隆模板 innards 时把「结果值」属性清零——金额/数量是别人清单算出来的,
带过来就是脏数据;公式(QtyFormula/Express 文本)、费率(Rate)、结构属性原样保留,
@@ -387,21 +376,6 @@ def _norm_xml(n, lres, template=None, bill_qty=None):
pre, post = _zero_results(pre), _zero_results(post)
pre = re.sub(r'<ExpressElement\b[^>]*/>', '', pre)
post = re.sub(r'<ExpressElement\b[^>]*/>', '', post)
# 决策 273(2026-11-04 主人定):采纳定额的单价行 Total 按 Name 匹配外部——
# x_side(采纳时构造:同区模板行组+Total 按 Name 匹配外部,一致=外部值/不一致留空)
# 有值时回填 Total 覆盖清零;无 x_side 维持清零现状(106 口径不动)。
_sm = {}
if n.get("x_side"):
try:
for _rec in json.loads(n["x_side"]):
if _rec.get("tag") == "UnitPriceCalculationOfItem":
_a = _rec.get("attrs") or {}
_sm[(_a.get("Name") or "").strip()] = _a.get("Total")
except Exception:
_sm = {}
if _sm:
pre = _adopt_totals(pre, _sm)
post = _adopt_totals(post, _sm)
# 换算调整记录(补记十三):先剥掉模板的记录(那是模板定额的历史),再按本定额
# 会话携带的 x_adjust 重写——采纳定额的调整工艺(GConvInfo 标准换算/R*2,J*2/送桩
# 材料含量…)跟历史项目走,主人定「有信息就要搬」。行形态照模板首行克隆。