feat(costreview): 升级导出克隆完整块、GCL 前缀公式与导入换行保留,并配套界面与规格更新
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
2026-10-15 起插入节点克隆源文件同类节点的**完整属性集**再覆盖会话值——
|
||||
广联达导入按属性取数,属性残缺(缺 Quantity/NormIdentity/IsNorm 等)整包被拒
|
||||
(样本实测:最小形态导不进广联达,易达补全属性后能进);
|
||||
2026-10-17 决策 106 起升级为克隆**完整块**:开标签全属性之外,原生 innards
|
||||
(清单级费用构成汇总/工程量表达式行、定额内表达式/管理费/单价计算公式行、
|
||||
WorkContent 壳与清单级工料机尾表)一并保留,结果值清零——只克隆属性仍旧残缺:
|
||||
易达按结构取数看不到新增清单(cos 与 cos4 同样实测),广联达整包报「不是有效标书」;
|
||||
· 字段编辑 → 只改开标签的对应属性(与文件现值不同才写);
|
||||
· 汇总:采纳补的品类行追加进 Project.xml;合并隐藏的汇总行省略;
|
||||
· 其余字节原样保留。
|
||||
@@ -18,6 +22,7 @@
|
||||
|
||||
import io
|
||||
import re
|
||||
import struct
|
||||
import zipfile
|
||||
|
||||
BILL_TAGS = ("WorkElement", "UnitWorksPreliminaryWorkElement")
|
||||
@@ -168,16 +173,81 @@ def _clone_open_tag(template):
|
||||
return template[:-2] + ">" if template.endswith("/>") else template
|
||||
|
||||
|
||||
_LME = "LabourMaterialsEquipmentsMachinesElement"
|
||||
|
||||
|
||||
def _zero_results(frag):
|
||||
"""决策 106:克隆模板 innards 时把「结果值」属性清零——金额/数量是别人清单算出来的,
|
||||
带过来就是脏数据;公式(QtyFormula/Express 文本)、费率(Rate)、结构属性原样保留,
|
||||
易达/广联达打开后按公式重算即可补上。SummaryOfBasicCost 的属性全是金额结果 → 整体清零。
|
||||
例外:QtyFormula 是**纯数字字面量**的(有的文件清单级公式列直接存数值)也清空——
|
||||
那是模板清单自己的单价/合价(220kV 件实测背着邻居的 189006.16),留着会被按公式求值显示。"""
|
||||
def _zero_open(m):
|
||||
tag, name = m.group(0), m.group(1)
|
||||
if name == "SummaryOfBasicCost":
|
||||
return re.sub(r'(\w+)="(-?[\d.]+)"', lambda mm: mm.group(1) + '="0"', tag)
|
||||
rules = {"ExpressElement": (("Express", ""), ("Quantity", "0")),
|
||||
"ManageFees": tuple([("Fee%d" % i, "0") for i in (1, 2, 3, 4)] +
|
||||
[("AddFee%d" % i, "0") for i in (1, 2, 3, 4)]),
|
||||
"WorkContent": (("Total", "0"),)}.get(name)
|
||||
if name == "UnitPriceCalculationOfItem":
|
||||
rules = (("Total", "0"),)
|
||||
if not rules:
|
||||
return tag
|
||||
for k, v in rules:
|
||||
if re.search(r'\b' + k + r'="', tag):
|
||||
tag = re.sub(r'\b' + k + r'="[^"]*"', lambda _m: k + '="' + v + '"', tag, count=1)
|
||||
if name == "UnitPriceCalculationOfItem":
|
||||
qf = re.search(r'QtyFormula="([^"]*)"', tag)
|
||||
if qf and re.fullmatch(r'-?[\d,]+(?:\.\d+)?', (qf.group(1) or "").strip()):
|
||||
tag = _attr_set(tag, "QtyFormula", "")
|
||||
return tag
|
||||
return re.sub(r'<(\w+)\b[^>]*?/?>', _zero_open, frag)
|
||||
|
||||
|
||||
def _lme_spans(frag):
|
||||
return list(re.finditer(r'<%s\b[^>]*>' % _LME, frag))
|
||||
|
||||
|
||||
def _norm_parts(tmpl):
|
||||
"""完整 Norm 块 → (opentag, pre, 行模板, post)。pre/post = 工料机行之外的原生结构
|
||||
(表达式行/管理费/单价计算公式行);没有工料机行或模板只是开标签 → (opentag, inner, None, "")。"""
|
||||
e = _open_tag_end(tmpl, 0)
|
||||
if e < 0:
|
||||
return tmpl, "", None, ""
|
||||
opentag = tmpl[:e]
|
||||
tail = tmpl[e:]
|
||||
close = "</Norm>"
|
||||
if not tail.endswith(close):
|
||||
return opentag, "", None, ""
|
||||
inner = tail[:-len(close)]
|
||||
spans = _lme_spans(inner)
|
||||
if not spans or not spans[0].group(0).endswith("/>"):
|
||||
return opentag, inner, None, ""
|
||||
return opentag, inner[:spans[0].start()], spans[0].group(0), inner[spans[-1].end():]
|
||||
|
||||
|
||||
def _norm_xml(n, lres, template=None):
|
||||
"""定额行:优先克隆源文件同类 Norm 的完整属性集(值除会话字段外原样保留,
|
||||
与易达的已知可行解一致);没有模板时退回最小形态。会话没算出的数值写 0
|
||||
(易达同款处理)——占位属性可以在位为 0,但不能缺席。"""
|
||||
if template:
|
||||
tag = _clone_open_tag(template)
|
||||
(易达同款处理)——占位属性可以在位为 0,但不能缺席。
|
||||
决策 106:template 可以是**完整块**——块内原生 innards(表达式行/管理费/单价计算
|
||||
公式行)一并保留(结果值清零、工料机行按模板首行形态重写为会话资源)。此前只克隆
|
||||
开标签,插出的定额缺单价计算公式行:易达看不到新增清单、广联达整包报「不是有效标书」
|
||||
(前山河 cos / 屏西五路 cos4 同因实测)。传开标签时行为与旧版一致。"""
|
||||
opentag, pre, row_tmpl, post = _norm_parts(template or "")
|
||||
if opentag:
|
||||
tag = _clone_open_tag(opentag)
|
||||
for k, v in (("Number", n["Number"]), ("Name", n["Name"]), ("Unit", n["Unit"])):
|
||||
tag = _attr_set(tag, k, v)
|
||||
for k, v in (("Quantity", _fmt_qty(n["Quantity"], 6)), ("Price", n["Price"]), ("Total", n["Total"])):
|
||||
tag = _attr_set(tag, k, "0" if v is None else v)
|
||||
# 决策 101:模板定额可能带着**它自己的换算备注**(Remark=" GConvInfo…//人材机含量改为…")——
|
||||
# 克隆属性集会把这段备注背给每条采纳定额,易达备注列出现大量别人的换算信息
|
||||
# (三溪华宇路 E1-2-7/E1-3-9 同背一段乔木苗换算,实测)。会话侧没有定额备注数据 → 恒清空。
|
||||
tag = _attr_set(tag, "Remark", "")
|
||||
if ' Conversion="' in tag:
|
||||
tag = _attr_set(tag, "Conversion", "")
|
||||
else:
|
||||
a = ' Number="%s" Name="%s" Unit="%s"' % (_esc(n["Number"]), _esc(n["Name"]), _esc(n["Unit"]))
|
||||
if n["Quantity"] is not None:
|
||||
@@ -187,26 +257,70 @@ def _norm_xml(n, lres, template=None):
|
||||
if n["Total"] is not None:
|
||||
a += ' Total="%s"' % n["Total"]
|
||||
tag = "<Norm" + a + ">"
|
||||
kids = "".join('<LabourMaterialsEquipmentsMachinesElement Number="%s" Express="%s" Quantity="%s" Remark=""/>'
|
||||
% (_esc(c), _esc(q), _esc(q))
|
||||
for c, q in lres if c)
|
||||
if row_tmpl is None:
|
||||
kids = "".join('<%s Number="%s" Quantity="%s" NOCost="false" Remark=""/>' % (_LME, _esc(c), _esc(q))
|
||||
for c, q in lres if c)
|
||||
else:
|
||||
kids = "".join(_lme_row(row_tmpl, c, q, express=_esc(q)) for c, q in lres if c)
|
||||
if pre or row_tmpl is not None or post:
|
||||
pre, post = _zero_results(pre), _zero_results(post)
|
||||
# 换算记录是模板定额自己的操作历史(换机/改价…,决策 101 同类)——新定额没有历史,整行不落
|
||||
post = re.sub(r'<NormAdjustmentList\b[^>]*/>', '', post)
|
||||
post = re.sub(r'<NormAdjustmentList\b[^>]*>.*?</NormAdjustmentList>', '', post)
|
||||
return tag + pre + kids + post + "</Norm>"
|
||||
return tag + kids + "</Norm>"
|
||||
|
||||
|
||||
def _bill_xml(b, tag, norms_xml, template=None):
|
||||
"""新增清单:优先克隆锚点清单的开标签(完整 27 属性,易达同款——
|
||||
新增清单同样因属性残缺导不进广联达);没有模板时退回最小形态。"""
|
||||
if template:
|
||||
t = _clone_open_tag(template)
|
||||
def _lme_row(row_tmpl, code, qty, express=""):
|
||||
"""按模板行形态写一条工料机行(保留各格式自己的属性集:cos 带 NOCost、cos4 带 Express)。
|
||||
Express(含量式/数值)是模板行的数据,换成本行资源后不成立 → 默认清空(值可以不填);
|
||||
尾表重建传入 express=计算值时按真值填(广联达/易达原生尾表 Express=数量,实测同款)。"""
|
||||
t = _attr_set(_clone_open_tag(row_tmpl) if not row_tmpl.endswith("/>") else row_tmpl, "Number", code)
|
||||
t = re.sub(r'\bQuantity="[^"]*"', 'Quantity="%s"' % _esc(qty), t, count=1) \
|
||||
if re.search(r'\bQuantity="', t) else t[:-1] + ' Quantity="%s">' % _esc(qty)
|
||||
if ' Express="' in t:
|
||||
t = _attr_set(t, "Express", express)
|
||||
return t
|
||||
|
||||
|
||||
def _full_norm_block(blk):
|
||||
"""块内第一条属性齐全的 **Norm 完整块**(作克隆模板,决策 106 要 innards)。"""
|
||||
for nsp in _norm_spans(blk):
|
||||
if ' NormIdentity="' in nsp["opentag"] and ' Quantity="' in nsp["opentag"]:
|
||||
return blk[nsp["s"]:nsp["end"]]
|
||||
return None
|
||||
|
||||
|
||||
def _eligible_bill_block(blk):
|
||||
"""能当新增清单**整块模板**的清单块:带费用构成汇总(原生 44/44 都有、我们旧版插的
|
||||
0/6 没有——易达按它认清单,缺了整条不显示)且至少一条属性齐全的定额可借 innards。"""
|
||||
return '<SummaryOfBasicCost' in blk and _full_norm_block(blk) is not None
|
||||
|
||||
|
||||
def _bill_xml(b, tag, norms_xml, template=None, txt=None):
|
||||
"""新增清单:优先克隆锚点清单的**完整块**——开标签全属性 + innards(费用构成汇总、
|
||||
工程量表达式行、定额区的 WorkContent 包装、清单级工料机尾表)原样保留,结果值清零、
|
||||
定额区换成会话采纳的定额(决策 106)。此前只克隆开标签(决策 64 时代的「已知可行解」
|
||||
其实是易达整存整取的完整块),插出的清单两种格式易达都不显示、广联达整包拒收。
|
||||
模板只是开标签(旧调用/块不合格)→ 退回仅克隆开标签的旧形态;无模板 → 最小形态。
|
||||
txt 给出时,项目特征按易达惯例恢复换行(决策 100 同款——库里的特征在解析时被
|
||||
XML 规范成了空格,主人实测:新增清单的特征不换行)。"""
|
||||
tmpl_blk = template or ""
|
||||
opentag = tmpl_blk[:_open_tag_end(tmpl_blk, 0)] if tmpl_blk else None
|
||||
if opentag:
|
||||
t = _clone_open_tag(opentag)
|
||||
for k, v in (("Number", b["Number"]), ("Name", b["Name"]),
|
||||
("Quantity", _fmt_qty(b["Quantity"], 3)), ("Price", b["Price"]), ("Total", b["Total"])):
|
||||
t = _attr_set(t, k, "0" if v is None else v)
|
||||
if b["Unit"]:
|
||||
t = _attr_set(t, "Unit", b["Unit"])
|
||||
if b["Attr"]:
|
||||
t = _attr_set(t, "Attr", b["Attr"])
|
||||
want = _restore_attr_breaks(txt, b["Attr"]) if txt else b["Attr"]
|
||||
t = _attr_set(t, "Attr", want)
|
||||
if b["src_remark"]:
|
||||
t = _attr_set(t, "Remark", b["src_remark"])
|
||||
elif ' Remark="' in t:
|
||||
t = _attr_set(t, "Remark", "") # 新增清单没有源备注:模板的备注是别人的,不能带(决策 106)
|
||||
else:
|
||||
a = ' Number="%s" Name="%s"' % (_esc(b["Number"]), _esc(b["Name"]))
|
||||
if b["Attr"]:
|
||||
@@ -220,7 +334,83 @@ def _bill_xml(b, tag, norms_xml, template=None):
|
||||
if b["src_remark"]:
|
||||
a += ' Remark="%s"' % _esc(b["src_remark"])
|
||||
t = "<" + tag + a + ">"
|
||||
return t + "".join(norms_xml) + "</" + tag + ">"
|
||||
close = "</" + tag + ">"
|
||||
if not tmpl_blk.endswith(close):
|
||||
return t + "".join(norms_xml) + close
|
||||
inner = tmpl_blk[len(opentag):-len(close)]
|
||||
m0 = re.search(r'<(Norm|WorkContent)\b', inner)
|
||||
if not m0:
|
||||
return t + "".join(norms_xml) + close
|
||||
# 定额区:模板里第一处定额/WorkContent 起到最后一处闭标签止——整段换成会话定额;
|
||||
# WorkContent 画像(cos4)按决策 98 同款逐条包壳(名/合价照本清单)。
|
||||
mend = None
|
||||
for mend in re.finditer(r'</(?:Norm|WorkContent)>', inner):
|
||||
pass
|
||||
if mend is not None: # 模板只有自闭合空壳(无实体定额)时按单元素替换
|
||||
pre, post = inner[:m0.start()], inner[mend.end():]
|
||||
else:
|
||||
pre, post = inner[:m0.start()], inner[m0.end():]
|
||||
if m0.group(1) == "WorkContent":
|
||||
wc = '<WorkContent Name="%s" Total="%s" Remark="">' % (
|
||||
_esc(b.get("Name") or ""),
|
||||
("%.2f" % b["Total"]) if b.get("Total") is not None else "0")
|
||||
region = "".join(wc + nx + "</WorkContent>" for nx in norms_xml)
|
||||
else:
|
||||
region = "".join(norms_xml)
|
||||
# 清单级工料机尾表(决策 98 画像):模板尾表有行 → 按会话定额的资源编码重建——
|
||||
# 决策 106 补记(主人定「按你的方法实行」):数量按 **每单位清单工程量的消耗量** 真值填
|
||||
# = Σ(定额含量×定额量)÷清单量(主人广联达/易达样本实测:90.5224、66.1282 同款算法),
|
||||
# 同码跨定额合并一行、Express 照原生填同值;清单量缺失/为 0 时退 0(架子在值留空)。
|
||||
# 模板没有尾表就不造(与既有清单的追加同步同口径)。
|
||||
lspans = _lme_spans(post)
|
||||
if lspans and lspans[0].group(0).endswith("/>"):
|
||||
agg, order = {}, []
|
||||
for nx in norms_xml:
|
||||
mq = re.search(r'\bQuantity="([^"]*)"', nx)
|
||||
try:
|
||||
nq = float(mq.group(1))
|
||||
except (ValueError, AttributeError):
|
||||
nq = None
|
||||
for m2 in re.finditer(r'<%s\b[^>]*?Number="([^"]*)"[^>]*?Quantity="([^"]*)"' % _LME, nx):
|
||||
c = m2.group(1)
|
||||
if c not in agg:
|
||||
order.append(c)
|
||||
agg[c] = 0.0
|
||||
if nq is not None:
|
||||
try:
|
||||
agg[c] += float(m2.group(2)) * nq
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
bq = float(b.get("Quantity")) if b.get("Quantity") is not None else 0.0
|
||||
except (TypeError, ValueError):
|
||||
bq = 0.0
|
||||
rows = []
|
||||
for c in order:
|
||||
vs = "%.4f" % round((agg[c] / bq if bq else 0.0), 4)
|
||||
rows.append(_lme_row(lspans[0].group(0), c, vs, express=vs))
|
||||
post = post[:lspans[0].start()] + "".join(rows) + post[lspans[-1].end():]
|
||||
return t + _zero_results(pre) + region + _zero_results(post) + close
|
||||
|
||||
|
||||
def _attr_sep_of(txt):
|
||||
"""本文件特征换行用什么分隔符(易达不同版本有 \\r 有 \\n):取其他特征里的实际写法,没有则 \\r。"""
|
||||
for m in re.finditer(r'Attr="([^"]*)"', txt):
|
||||
v = m.group(1)
|
||||
if "\r" in v:
|
||||
return "\r"
|
||||
if "\n" in v:
|
||||
return "\n"
|
||||
return "\r"
|
||||
|
||||
|
||||
def _restore_attr_breaks(txt, s):
|
||||
"""决策 100:库里特征换行在**解析时**就被 XML 规范归一成空格(属性值归一化)——
|
||||
编辑过的清单导出重写 Attr 时按易达特征惯例(「数字、」分行)恢复换行,
|
||||
分隔符取本文件其他特征的实际写法。未编辑清单不动(原字节里换行还在)。"""
|
||||
if not s or "\r" in s or "\n" in s:
|
||||
return s
|
||||
return re.sub(r"[ \t]+(?=\d{1,3}、)", _attr_sep_of(txt), s)
|
||||
|
||||
|
||||
def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
|
||||
@@ -259,31 +449,25 @@ def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
|
||||
else:
|
||||
left[kind] = list(pairs_k)
|
||||
|
||||
# ---- ② 编码兜底(决策 97):两种标签的块合并在文档序里按 (Number,Name) 认领 ----
|
||||
# ---- ② 编码兜底(决策 97)→ 文档序整体对位(决策 104 升级)----
|
||||
# .cos 里措施清单嵌在章节节点、且清单可能被改名——按 (Number,Name) 认领会失败而整组跳过
|
||||
# (前山河/金湾区实测:新增清单、采纳定额全部没写)。升级:把该 uw 的**全部文件块**
|
||||
# (两种标签、文档序)与**全部源清单**(两种 kind、按 id 序=解析文档序)一一对位——
|
||||
# 解析按文档序入库,两边顺序天然一致,改名/同编码复用/章节嵌套都不影响。
|
||||
# 数量不一致(解析真丢块)才放弃:已配平的 kind 保留主路径配对,left kinds 整组不动(护栏)。
|
||||
if left:
|
||||
want = {}
|
||||
for kind, ks in left.items():
|
||||
for sp, b in ks:
|
||||
want.setdefault(((b.get("Number") or ""), (b.get("Name") or "")), []).append((kind, sp, b))
|
||||
claimed = {id(mk) for lst in paired.values() for (_sp, _b, mk) in lst}
|
||||
ok = True
|
||||
for mk in [mk for mk in blocks if uv(mk) == uwkey]:
|
||||
if id(mk) in claimed:
|
||||
continue
|
||||
k2 = ((_attr(mk["opentag"], "Number") or ""), (_attr(mk["opentag"], "Name") or ""))
|
||||
q = want.get(k2)
|
||||
if not q:
|
||||
continue # 文件有、会话没有的块:不在改动范围,跳过
|
||||
kind, sp, b = q.pop(0)
|
||||
if not q:
|
||||
del want[k2]
|
||||
claimed.add(id(mk))
|
||||
paired.setdefault(kind, []).append((sp, b, mk))
|
||||
if any(want.values()):
|
||||
ok = False # 有会话清单没在文件里找到:宁可不改,回滚兜底
|
||||
if not ok:
|
||||
for kind in left:
|
||||
paired.pop(kind, None)
|
||||
bills_all = []
|
||||
for kind in ("item", "prelim"):
|
||||
src = left.get(kind) or paired.get(kind) or []
|
||||
for it in src:
|
||||
bills_all.append((kind, it[0], it[1])) # left=2元组 / paired=3元组 兼容
|
||||
bills_all.sort(key=lambda t: t[2]["id"]) # id 序 = 解析(文档)序
|
||||
pool = [mk for mk in blocks if uv(mk) == uwkey] # 文档序
|
||||
if bills_all and len(pool) == len(bills_all):
|
||||
paired = {} # 全量重排(含原已配平的 kind)
|
||||
for mk, (kind, sp, b) in zip(pool, bills_all):
|
||||
paired.setdefault(kind, []).append((sp, b, mk))
|
||||
# 数量对不上:保留原配对(主路径 kind 照常;left kinds 整组跳过)
|
||||
|
||||
# ---- 动刀(主路径与兜底共用同一套编辑体)----
|
||||
for kind, tag, close in (("item", "WorkElement", _CLOSE_WE),
|
||||
@@ -311,6 +495,9 @@ def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
|
||||
continue # 会话没值的字段不回写(写 "None" 反而是破坏)
|
||||
if attr == "Quantity":
|
||||
want = _fmt_qty(want, 3) # 清单工程量按源文件规律 3 位小数导出
|
||||
elif attr == "Attr":
|
||||
# 决策 100:特征换行恢复(库里的 \r 已在解析时被归一成空格)
|
||||
want = _restore_attr_breaks(txt, want)
|
||||
cur = _attr(newtag, attr)
|
||||
if cur is None:
|
||||
if want:
|
||||
@@ -325,15 +512,39 @@ def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
|
||||
newtag = _attr_set(newtag, attr, want)
|
||||
if newtag != mk["opentag"]:
|
||||
edits.append((mk["s"], mk["e"], newtag))
|
||||
# 定额:源定额 ↔ 块内 Norm 一一对应;追加定额插块尾
|
||||
# 定额:源定额 ↔ 块内 Norm 一一对应;追加定额插在 WorkContent 组末尾
|
||||
nb = norms_by_bill.get(b["id"], {})
|
||||
nsrc, napp = nb.get("source") or [], nb.get("append") or []
|
||||
nspans = _norm_spans(txt[mk["s"]:mk["end"]])
|
||||
# 决策 98:易达原生结构 = 每条定额包在 <WorkContent> 里;清单级另有一张
|
||||
# **去重工料机汇总表**平铺在所有 WorkContent 之后。识别本清单有没有这种结构。
|
||||
wc_open = txt.rfind("<WorkContent", mk["s"], mk["end"])
|
||||
wc_close = txt.rfind("</WorkContent>", mk["s"], mk["end"])
|
||||
has_wc = wc_open != -1
|
||||
nrm_changed = False
|
||||
if len(nspans) == len(nsrc):
|
||||
for nsp, nn in zip(nspans, nsrc):
|
||||
s0, e0 = nsp["s"] + mk["s"], nsp["end"] + mk["s"]
|
||||
if nn["x_tdel"]:
|
||||
edits.append((s0, e0, ""))
|
||||
# 删临删定额:
|
||||
# a) WorkContent 结构 → 连**包装壳**一起删(只删 Norm 会留下空壳;
|
||||
# 原生易达自己删定额也会留空壳,广联达容忍空壳,但保持干净)
|
||||
# b) 平铺结构(定额后跟散装工料机)→ 连工料机一起删,
|
||||
# 否则孤儿工料机外溢到定额层(屏西五路 040301004001 实测)
|
||||
ws = txt.rfind("<WorkContent", mk["s"], s0)
|
||||
we = txt.find("</WorkContent>", s0, mk["end"])
|
||||
n_in = len(re.findall(r"<Norm\b", txt[ws:we + len("</WorkContent>")])) if (ws != -1 and we != -1) else 0
|
||||
if ws != -1 and we != -1 and n_in == 1:
|
||||
edits.append((ws, we + len("</WorkContent>"), ""))
|
||||
nrm_changed = True
|
||||
continue
|
||||
e_del = e0
|
||||
mm = re.match(r'\s*(?:<LabourMaterialsEquipmentsMachinesElement\b[^>]*/>\s*)*',
|
||||
txt[e_del:mk["end"]])
|
||||
if mm:
|
||||
e_del += mm.end()
|
||||
edits.append((s0, e_del, ""))
|
||||
nrm_changed = True
|
||||
continue
|
||||
newn = nsp["opentag"]
|
||||
for attr in ("Name", "Quantity"):
|
||||
@@ -345,29 +556,93 @@ def transform_unit(txt, uwkey, pairs, news, norms_by_bill, res_by_norm):
|
||||
if newn != nsp["opentag"]:
|
||||
edits.append((s0, nsp["e"] + mk["s"], newn))
|
||||
if napp:
|
||||
# 决策 106:模板取同清单**属性齐全定额的完整块**(innards 一起克隆),
|
||||
# 没有再退回全文件模板开标签(旧形态)。
|
||||
tmpl = norm_tmpl
|
||||
for nsp in nspans: # 同清单自己的定额优先(上下文最贴近)
|
||||
if ' NormIdentity="' in nsp["opentag"]:
|
||||
tmpl = nsp["opentag"]
|
||||
tmpl = txt[nsp["s"] + mk["s"]: nsp["end"] + mk["s"]]
|
||||
break
|
||||
ci = mk["end"] - len(CLOSE[mk["tag"]])
|
||||
edits.append((ci, ci, "".join(_norm_xml(nn, res_by_norm.get(nn["id"], []), tmpl)
|
||||
for nn in napp)))
|
||||
# 新增清单:锚点块之后插入(锚点=源序位;同锚点按传入序依次跟随)
|
||||
# 决策 98:采纳定额按原生结构写入——**包 WorkContent**、插在最后一个
|
||||
# WorkContent 之后(工料机汇总平铺表之前)。此前裸 Norm 插在块尾
|
||||
# (汇总表和单价计算节点之后),广联达按 schema 解析错位 →
|
||||
# 采纳定额的工料机外溢到定额层(屏西五路 040301004001 实测)。
|
||||
body = "".join(_norm_xml(nn, res_by_norm.get(nn["id"], []), tmpl) for nn in napp)
|
||||
if has_wc and wc_close != -1:
|
||||
ins = wc_close + len("</WorkContent>")
|
||||
# 决策 99:原生 WorkContent 恒带 Name/Total/Remark 三属性(清单名/清单合价 2 位/空)
|
||||
wc_tag = '<WorkContent Name="%s" Total="%s" Remark="">' % (
|
||||
_esc(b.get("Name") or ""),
|
||||
("%.2f" % b["Total"]) if b.get("Total") is not None else "0")
|
||||
edits.append((ins, ins, wc_tag + body + "</WorkContent>"))
|
||||
else:
|
||||
ci = mk["end"] - len(CLOSE[mk["tag"]])
|
||||
edits.append((ci, ci, body))
|
||||
# 决策 98:清单级工料机汇总(去重平铺表)随定额增删同步——
|
||||
# 被删定额独用的编码撤下、采纳定额新引入的编码补上(属性照定额自带子元素克隆)。
|
||||
if has_wc and wc_close != -1 and (nrm_changed or napp):
|
||||
tail_start = wc_close + len("</WorkContent>")
|
||||
tail = txt[tail_start:mk["end"]]
|
||||
dspans = []
|
||||
for m2 in re.finditer(r'<LabourMaterialsEquipmentsMachinesElement\b[^>]*/>', tail):
|
||||
c2 = re.search(r'Number="([^"]*)"', m2.group(0))
|
||||
dspans.append((m2.start() + tail_start, m2.end() + tail_start, c2.group(1) if c2 else ""))
|
||||
keep = set()
|
||||
for nsp, nn in zip(nspans, nsrc):
|
||||
if nn["x_tdel"]:
|
||||
continue
|
||||
inner = txt[nsp["e"] + mk["s"]: nsp["end"] + mk["s"]]
|
||||
keep |= set(re.findall(r'<LabourMaterialsEquipmentsMachinesElement\b[^>]*?Number="([^"]*)"', inner))
|
||||
for nn in napp:
|
||||
keep |= {c for c, _q in res_by_norm.get(nn["id"], []) if c}
|
||||
have = {c for _s, _e, c in dspans}
|
||||
for _s, _e, c in dspans:
|
||||
if c not in keep:
|
||||
edits.append((_s, _e, "")) # 已不被任何在册定额使用:撤下
|
||||
add = [c for c in sorted(keep) if c not in have]
|
||||
if add:
|
||||
ins_at = dspans[-1][1] if dspans else tail_start
|
||||
kid = "".join('<LabourMaterialsEquipmentsMachinesElement Number="%s" Express="0" Quantity="0" Remark=""/>'
|
||||
% _esc(c) for c in add)
|
||||
edits.append((ins_at, ins_at, kid))
|
||||
# 新增清单落位:锚点 = 「第 N 条源清单之后」;**锚点 0 = 插在第一条源清单之前**
|
||||
# (主人在工作台把新增行插到最上面时 x_seq 排最前——此前 0 被当成「无锚点」甩到组尾,
|
||||
# 220kV 电力通道实测:易达里按添加位置找不到,报「压根没导出」)。
|
||||
# 同一插入点的多条新增按传入序拼成一段、一次落位(底向上应用,同点后应用的排前 →
|
||||
# 拼成一段才能保传入序=文件序)。克隆模板:锚点块合格先用锚点,否则取本组任一合格块
|
||||
# (带费用构成汇总 + 属性齐全定额);全组都不合格退回旧的开标签形态。
|
||||
srcpos_of = {sp: mk for sp, _b, mk in plist}
|
||||
ins_at = {} # (插入位置, 是否块前) → [(bill, 锚点块)...] 传入序
|
||||
for b in news.get(kind) or []:
|
||||
tgt = srcpos_of.get(b.get("_anchor")) or (plist[-1][2] if plist else None)
|
||||
if tgt is None:
|
||||
continue
|
||||
tmpl = norm_tmpl
|
||||
for nsp in _norm_spans(txt[tgt["s"]:tgt["end"]]):
|
||||
if ' NormIdentity="' in nsp["opentag"]:
|
||||
tmpl = nsp["opentag"]
|
||||
break
|
||||
norms_xml = [_norm_xml(nn, res_by_norm.get(nn["id"], []), tmpl)
|
||||
for nn in norms_by_bill.get(b["id"], {}).get("append") or []]
|
||||
edits.append((tgt["end"], tgt["end"],
|
||||
_bill_xml(b, tgt["tag"], norms_xml, tgt["opentag"])))
|
||||
anc = b.get("_anchor")
|
||||
if anc == 0 and plist:
|
||||
mk = plist[0][2]
|
||||
key = (mk["s"], True)
|
||||
else:
|
||||
mk = srcpos_of.get(anc) or (plist[-1][2] if plist else None)
|
||||
if mk is None:
|
||||
continue
|
||||
key = (mk["end"], False)
|
||||
ins_at.setdefault(key, []).append((b, mk))
|
||||
for (pos, _before), group in ins_at.items():
|
||||
parts = []
|
||||
for b, tgt in group:
|
||||
tmpl_blk = None
|
||||
for mk2 in [tgt] + [x[2] for x in plist]:
|
||||
blk2 = txt[mk2["s"]:mk2["end"]]
|
||||
if _eligible_bill_block(blk2):
|
||||
tmpl_blk = blk2
|
||||
break
|
||||
nn_tmpl = _full_norm_block(tmpl_blk) if tmpl_blk else None
|
||||
if nn_tmpl is None:
|
||||
for nsp in _norm_spans(txt[tgt["s"]:tgt["end"]]):
|
||||
if ' NormIdentity="' in nsp["opentag"]:
|
||||
nn_tmpl = nsp["opentag"]
|
||||
break
|
||||
norms_xml = [_norm_xml(nn, res_by_norm.get(nn["id"], []), nn_tmpl or norm_tmpl)
|
||||
for nn in norms_by_bill.get(b["id"], {}).get("append") or []]
|
||||
parts.append(_bill_xml(b, tgt["tag"], norms_xml, tmpl_blk or tgt["opentag"], txt=txt))
|
||||
edits.append((pos, pos, "".join(parts)))
|
||||
# 自底向上应用(span 互不重叠:开标签补丁/定额块删除/闭合前插入各占各的区间)
|
||||
for s, e, rep in sorted(edits, key=lambda x: (x[0], x[1]), reverse=True):
|
||||
txt = txt[:s] + rep + txt[e:]
|
||||
@@ -457,7 +732,7 @@ def transform_unit_summaries(txt, price_updates, added_rows, recode_map=None, re
|
||||
if rows:
|
||||
kids = re.findall(r'<LabourMaterialsEquipmentsMachinesElement\b[^>]*/>', txt[e0:bend])
|
||||
ktmpl = kids[0] if kids else \
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="" Express="1.0000" Quantity="0.0000" Remark=""/>'
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="" Quantity="0.0000" NOCost="false" Remark=""/>'
|
||||
newkids = "".join(_child_node(ktmpl, c, q) for (c, q) in rows)
|
||||
blocks[s0] = (s0, bend, newtag + newkids + "</" + _SUM_TAG + ">")
|
||||
else:
|
||||
@@ -601,6 +876,20 @@ class _RawNameZipInfo(zipfile.ZipInfo):
|
||||
return self.filename.encode("utf-8"), 0x800
|
||||
|
||||
|
||||
def _safe_extra(extra):
|
||||
"""原样保留 zip 条目的附加块(NTFS 时间戳 0x000a 等,2026-10-18 零修改碾压实测:
|
||||
原文件每条目带 36 字节,重打包被丢——内容虽无损,容器能少一处差异就少一处),
|
||||
但剔除 ZIP64 尺寸块(0x0001):里面写的是原条目的压缩/原始尺寸,与重打包后的
|
||||
实际值不一致会坑按它读尺寸的解析器。"""
|
||||
out, pos = b"", 0
|
||||
while pos + 4 <= len(extra):
|
||||
sid, ln = struct.unpack("<HH", extra[pos:pos + 4])
|
||||
if sid != 0x0001:
|
||||
out += extra[pos:pos + 4 + ln]
|
||||
pos += 4 + ln
|
||||
return out
|
||||
|
||||
|
||||
def _source_ext(src_name):
|
||||
"""按源文件名取**原后缀**(保留原大小写)——约定「按原格式导出」:
|
||||
.cos4 进 .cos4 出;今后新格式(.cos5 / 任何 .xxx)只要能导入,导出就跟原格式,
|
||||
@@ -667,6 +956,7 @@ def export_zip(src_bytes, proj_name, src_name, unit_plans, added_summaries, hidd
|
||||
zi.compress_type = zipfile.ZIP_DEFLATED
|
||||
zi.external_attr = item.external_attr
|
||||
zi.create_system = item.create_system
|
||||
zi.extra = _safe_extra(item.extra) # 附加块保真(NTFS 时间戳等,见 _safe_extra)
|
||||
zo.writestr(zi, raw)
|
||||
if progress:
|
||||
progress(_ei, len(entries))
|
||||
|
||||
@@ -50,6 +50,15 @@ def f(x):
|
||||
return None
|
||||
|
||||
|
||||
def unit_prefix(unit):
|
||||
"""定额单位的**数字前缀**('10m'→10.0、'1000m3天然密实方'→1000.0、't'→1.0)——
|
||||
GCL(清单量÷前缀)与工程量系数(定额量÷历史GCL)共用的同一把尺
|
||||
(规格 2026-10-16 工具栏节同款算法;收口到核心层,api_server._gcl_of 复用)。"""
|
||||
m = re.match(r"\s*(\d+(?:\.\d+)?)", unit or "")
|
||||
div = float(m.group(1)) if m else 1.0
|
||||
return div if div > 0 else 1.0
|
||||
|
||||
|
||||
# ---------- 特征清洗(提高"精确"命中率的关键)----------
|
||||
STOPWORDS = [
|
||||
"另以上工作内容及未提及部分详见相关规范", "招标文件及图纸", "详见图纸", "详见设计图纸",
|
||||
@@ -126,6 +135,27 @@ def proj_total(root):
|
||||
|
||||
|
||||
# ---------- 解析:2025 标准(ZIP 内 ConstructionProject / UnitWorks)----------
|
||||
def _encode_attr_newlines(txt):
|
||||
"""XML 规范会把属性值里的裸回车/换行归一化成**空格**——易达项目特征的分行(\\r 或 \\n)
|
||||
就这么在入库时丢成空格,导出重写后易达里特征不再自动换行(2026-10-17 主人实测)。
|
||||
解析前把**属性值内部**的 \\r/\\n 预编码成字符引用(
/
),ET 就原样保留。
|
||||
判位:引号逐个翻转进出状态,状态在内时遇到的 \\r/\\n 即属性值内部;标签之间的结构性
|
||||
换行在引号外,原样保留(O(N) 单趟,大文件无压力)。"""
|
||||
if "\r" not in txt and "\n" not in txt:
|
||||
return txt
|
||||
out, last, in_q = [], 0, False
|
||||
for m in re.finditer(r'"|\r\n|\r|\n', txt):
|
||||
ch = m.group(0)
|
||||
if ch == '"':
|
||||
in_q = not in_q
|
||||
elif in_q:
|
||||
out.append(txt[last:m.start()])
|
||||
out.append("
" if ch == "\r\n" else ("
" if ch == "\r" else "
"))
|
||||
last = m.end()
|
||||
out.append(txt[last:])
|
||||
return "".join(out)
|
||||
|
||||
|
||||
def parse_std(path, out):
|
||||
out.setdefault("lme_res", {}) # 机械台班 / 配合比的**下一级组成**:编码 → [(子编码, 含量)]
|
||||
z = zipfile.ZipFile(path)
|
||||
@@ -137,7 +167,7 @@ def parse_std(path, out):
|
||||
proj = n
|
||||
break
|
||||
if proj:
|
||||
r = ET.fromstring(z.read(proj).decode("utf-8", errors="replace"))
|
||||
r = ET.fromstring(_encode_attr_newlines(z.read(proj).decode("utf-8", errors="replace")))
|
||||
out["proj_name"] = r.attrib.get("Name", "")
|
||||
out["file_kind"] = f(r.attrib.get("FileKind"))
|
||||
out["bulid_unit"] = r.attrib.get("BulidUnit", "")
|
||||
@@ -236,7 +266,7 @@ def parse_std(path, out):
|
||||
# 项目信息上面已单独解析过,这里跳过它;只有包内**只剩** Project.xml 时才退化回去解析。
|
||||
unit_files = [n for n in names if n != proj] or names
|
||||
for n in unit_files:
|
||||
txt = z.read(n).decode("utf-8", errors="replace")
|
||||
txt = _encode_attr_newlines(z.read(n).decode("utf-8", errors="replace"))
|
||||
# 每个 xml 文件彼此独立:本文件里没有单位工程的,不许继承上一个文件的归属
|
||||
out["cur_uw"] = -1
|
||||
out["cur_bill"] = -1
|
||||
@@ -551,12 +581,19 @@ def save(con, kind, out, fn, sha, mtime, meta=None, bid=None):
|
||||
seen_bill.add(h)
|
||||
|
||||
# 定额(补 Quantity / Total,与 s_norms 对齐)
|
||||
# 规格 19:顺手算好定额工程量系数(**GCL 口径**:定额量÷历史GCL=GCL×系数还原原比例,
|
||||
# 6 位)——一次乘除随批写入,无感知;采纳时直接取用生成 GCL*系数 公式(主人 2026-10-17 定)。
|
||||
# 2026-10-17 修正:系数必须先除掉定额单位的数字前缀(10m/100m…),否则 GCL 求值时
|
||||
# 单位换算双算两遍(前山河 040501004001:10m 定额导出量少 10 倍实测)。
|
||||
norm_ids = []
|
||||
for idx, num, name, unit, qty, price, total in out["norms"]:
|
||||
bid2 = bill_ids[idx] if 0 <= idx < len(bill_ids) else None
|
||||
cur.execute("""INSERT INTO norms(bill_id, Number, Name, Unit, Quantity, Price, Total)
|
||||
VALUES(?,?,?,?,?,?,?)""",
|
||||
(bid2, num, name, unit, qty, price, total))
|
||||
bqty = out["bills"][idx][4] if 0 <= idx < len(out["bills"]) else None
|
||||
coef = (round(qty * unit_prefix(unit) / bqty, 6)
|
||||
if (qty is not None and bqty not in (None, 0)) else None)
|
||||
cur.execute("""INSERT INTO norms(bill_id, Number, Name, Unit, Quantity, Price, Total, x_qty_coef)
|
||||
VALUES(?,?,?,?,?,?,?,?)""",
|
||||
(bid2, num, name, unit, qty, price, total, coef))
|
||||
norm_ids.append(cur.lastrowid)
|
||||
|
||||
# 定额消耗工料机(对应 s_norm_res)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
M3-1 后端服务:零依赖(Python 标准库 http.server)
|
||||
提供后台管理界面需要的接口,并托管前端页面。
|
||||
"""
|
||||
import io, os, re, json, sqlite3, urllib.parse, mimetypes, hashlib, time, threading, base64, sys
|
||||
import io, os, re, json, sqlite3, urllib.parse, mimetypes, hashlib, time, threading, base64, sys, zipfile
|
||||
from decimal import Decimal, ROUND_HALF_UP
|
||||
from itertools import combinations
|
||||
from collections import Counter, OrderedDict
|
||||
@@ -1690,13 +1690,13 @@ TBL = {
|
||||
# lme_proj=项目级工料机汇总(决策 40,2026-10-11):「项目工料机」标签两侧统一改读**项目级汇总**
|
||||
# (工作台 s_lme_proj / 后台 lme_proj),过滤规则不变(LME_LIST_WHERE);会话侧备注列
|
||||
# lme_remark=s_lme_proj.x_remark(采纳落点随之平移,见 _migrate_lme_adoption),批次侧恒 NULL。
|
||||
"session": {"proj": "sessions", "pname": "name", "sections": "s_sections",
|
||||
"session": {"proj": "sessions", "pname": "name", "sections": "s_sections", "src": "src_name",
|
||||
"uworks": "s_unit_works", "divides": "s_divides", "bills": "s_bills",
|
||||
"norms": "s_norms", "lmes": "s_lmes", "norm_res": "s_norm_res", "lme_res": "s_lme_res",
|
||||
"lme_lib": "s_lme_lib", "lme_proj": "s_lme_proj", "lme_uw": "s_lme_uw",
|
||||
"idcol": "session_id", "remark": "b.x_remark", "lme_remark": "x_remark",
|
||||
"normstate": 1, "lmemerge": 1},
|
||||
"batch": {"proj": "batches", "pname": "Name", "sections": "sections",
|
||||
"batch": {"proj": "batches", "pname": "Name", "sections": "sections", "src": "x_src_hash",
|
||||
"uworks": "unit_works", "divides": "divides", "bills": "bills",
|
||||
"norms": "norms", "lmes": "lmes", "norm_res": "norm_res", "lme_res": "lme_res",
|
||||
"lme_lib": "lme_lib", "lme_proj": "lme_proj", "lme_uw": "lme_uw",
|
||||
@@ -1712,7 +1712,35 @@ def _raw_tree(con, T, oid):
|
||||
% (T["sections"], T["idcol"]), (oid,)).fetchall()
|
||||
uws = con.execute("SELECT id, section_id, Number, Name, Total, Specialty FROM %s WHERE %s=?"
|
||||
% (T["uworks"], T["idcol"]), (oid,)).fetchall()
|
||||
uws = sorted(uws, key=lambda r: _natkey(r["Number"])) # 原文件顺序不靠谱,按编号自然序
|
||||
# 决策 103:单位工程顺序 = 源文件 Project.xml 的引用序(易达目录序)——
|
||||
# 编号自然序会打乱「A 系列 + 数字系列」混编工程的原有先后(前山河二期 81 栋实测:
|
||||
# 原生序 A1→A19/A20 → 数字 21→80 → 市政管网 0001→0004;自然序把数字排前、A10/A11 排 A2 前)。
|
||||
# 排序键:Project.xml 引用序(编号缺失的排最后、按自然序);源文件读不到/解析失败 → 退回自然序。
|
||||
nat = {r["id"]: _natkey(r["Number"]) for r in uws}
|
||||
key = {r["id"]: (0, nat[r["id"]]) for r in uws}
|
||||
try:
|
||||
srow = con.execute("SELECT %(src)s FROM %(pr)s WHERE id=?" %
|
||||
{"src": T["src"], "pr": T["proj"]}, (oid,)).fetchone()
|
||||
srcp = os.path.join(UPLOAD_DIR, (srow[0] or "").strip()) if srow and srow[0] else None
|
||||
if srcp and os.path.isfile(srcp):
|
||||
ptxt = None
|
||||
with zipfile.ZipFile(srcp) as zf:
|
||||
for i in zf.infolist():
|
||||
if i.filename.lower().endswith("project.xml"):
|
||||
ptxt = zf.read(i.filename).decode("utf-8", "replace")
|
||||
break
|
||||
if ptxt:
|
||||
seq = []
|
||||
for m in re.finditer(r"<UnitWorks\b[^>]*>", ptxt):
|
||||
c = re.search(r'Number="([^"]*)"', m.group(0))
|
||||
if c and c.group(1) not in seq:
|
||||
seq.append(c.group(1))
|
||||
for r in uws:
|
||||
key[r["id"]] = ((0, seq.index(r["Number"]), nat[r["id"]])
|
||||
if r["Number"] in seq else (1, 0, nat[r["id"]]))
|
||||
except Exception:
|
||||
pass # 源文件读不到/解析失败:退回编号自然序
|
||||
uws = sorted(uws, key=lambda r: key[r["id"]])
|
||||
by_sec, free = {}, []
|
||||
for u in uws:
|
||||
it = {"id": u["id"], "Number": u["Number"], "Name": u["Name"], "Total": u["Total"],
|
||||
@@ -2595,11 +2623,15 @@ def _cmp_bills(con, T, oid):
|
||||
"idc": T["idcol"], "remark": T.get("remark", "NULL")}, (oid,)).fetchall()
|
||||
|
||||
|
||||
def _inconsistent(rows, rowfn):
|
||||
def _inconsistent(rows, rowfn, sid=None):
|
||||
"""组价不一致:同名同规格(名称归一 + 特征归一)但单价不同的组(**两侧唯一实现**)。
|
||||
|
||||
⚠️ 必须在**已过滤**的 rows 上算(措施费、单价 0 已排除),否则 pmin/pmax 会被措施费拉高,
|
||||
得出虚高价差 —— 后台曾用 SQL 聚合值(含措施费),与工作台口径不一致。
|
||||
规格 20(2026-10-17 主人定):
|
||||
①组顺序在编辑过程**稳定不变**——顺序号存会话设置(incon_ord),新产生的组追加在最后;
|
||||
②全部组价一致后组**不消失**:组内清单数不变、consistent=1(前端目录组名变绿);
|
||||
编辑再产生价差 → 自动恢复原色。从未出现过价差的组不进目录。
|
||||
"""
|
||||
g = {}
|
||||
for r in rows:
|
||||
@@ -2607,16 +2639,37 @@ def _inconsistent(rows, rowfn):
|
||||
if not any(key):
|
||||
continue
|
||||
g.setdefault(key, []).append(r)
|
||||
ordmap = {}
|
||||
if sid:
|
||||
raw_o = _setting_get("session:%d" % sid, "incon_ord")
|
||||
if raw_o:
|
||||
try:
|
||||
ordmap = {tuple(k.split(chr(31))): int(v)
|
||||
for k, v in json.loads(raw_o).items()}
|
||||
except Exception:
|
||||
ordmap = {}
|
||||
nxt = (max(ordmap.values()) + 1) if ordmap else 1
|
||||
out = []
|
||||
for _key, rs in g.items():
|
||||
for key, rs in g.items():
|
||||
prices = {str(_col(x, "Price")) for x in rs}
|
||||
if len(prices) < 2:
|
||||
continue
|
||||
consistent = len(prices) < 2
|
||||
if key not in ordmap:
|
||||
if consistent:
|
||||
continue # 从未出现过价差的一致组:不进目录
|
||||
ordmap[key] = nxt
|
||||
nxt += 1
|
||||
out.append((ordmap[key], key, rs, consistent))
|
||||
if sid:
|
||||
_setting_set("session:%d" % sid, "incon_ord",
|
||||
json.dumps({chr(31).join(k): v for v, k, _r, _c in out}, ensure_ascii=False))
|
||||
out.sort(key=lambda t: t[0])
|
||||
groups = []
|
||||
for _o, key, rs, consistent in out:
|
||||
d = _grpstat(rs)
|
||||
d["rows"] = [rowfn(x) for x in rs]
|
||||
out.append(d)
|
||||
out.sort(key=lambda x: -(x.get("spread") or 0))
|
||||
return {"total": len(out), "groups": out, "extra": []}
|
||||
d["consistent"] = 1 if consistent else 0
|
||||
groups.append(d)
|
||||
return {"total": len(groups), "groups": groups, "extra": []}
|
||||
|
||||
|
||||
def api_session_groups(sid, kind):
|
||||
@@ -2632,7 +2685,7 @@ def api_session_groups(sid, kind):
|
||||
con.close()
|
||||
|
||||
if kind == "inconsistent":
|
||||
return _inconsistent(rows, BILLROW)
|
||||
return _inconsistent(rows, BILLROW, sid)
|
||||
|
||||
# ---- similar:v2 顺序管线(决策 29/30)——关键词层读「分组设置」表(global.grp_rules)----
|
||||
return _group_v2_output(rows)
|
||||
@@ -2794,11 +2847,9 @@ def api_norm_op(sc, body):
|
||||
def _gcl_of(bill_qty, unit):
|
||||
"""GCL 数值(规格 2026-10-16 工具栏节同款算法,采纳与行内编辑共用):
|
||||
清单工程量 ÷ 定额单位从左到右数字前缀(到字母处截断,如 10t→10);纯字母/无数字
|
||||
单位(t、m、空)则 GCL=清单工程量;清单工程量空按 0。round 6 位(源文件规律)。"""
|
||||
m = re.match(r"\s*(\d+(?:\.\d+)?)", unit or "")
|
||||
div = float(m.group(1)) if m else 1.0
|
||||
if div <= 0:
|
||||
div = 1.0
|
||||
单位(t、m、空)则 GCL=清单工程量;清单工程量空按 0。round 6 位(源文件规律)。
|
||||
单位前缀解析收口在核心层 job.unit_prefix(系数迁移同一把尺,口径不分叉)。"""
|
||||
div = job.unit_prefix(unit)
|
||||
return round((float(bill_qty) if bill_qty is not None else 0.0) / div, 6)
|
||||
|
||||
|
||||
@@ -3042,6 +3093,24 @@ def f_(x):
|
||||
return None
|
||||
|
||||
|
||||
def _gcl_coef_expr(norm_qty, bill_qty, coef=None, unit=None):
|
||||
"""规格 19(2026-10-17 主人定·采纳逻辑变化):采纳定额默认公式 = **GCL×系数**,
|
||||
系数 = 历史定额量 ÷ 历史GCL(GCL=历史清单量÷定额单位数字前缀;例:历史清单量 500、
|
||||
定额量 300 → GCL*0.6000)——采纳到本清单后定额量按比例跟随本清单工程量。
|
||||
系数**导入时已预存**(norms.x_qty_coef,主人定:导入算好、采纳直接用),优先取用;
|
||||
老数据缺失时现算兜底。历史清单量缺失/为 0/定额量缺失 → 退回裸 GCL(决策 90 口径)。
|
||||
2026-10-17 决策 106 修正:系数一律 **GCL 口径**(定额量÷历史GCL)。旧口径
|
||||
(定额量÷清单量)在定额单位带数字前缀(10m/100m…)时把单位换算双算两遍——
|
||||
GCL 求值已除过一次前缀,前山河 040501004001(10m 定额)导出量少 10 倍实测。
|
||||
现算兜底同样按 GCL 口径(传入单位)。"""
|
||||
if coef is None:
|
||||
nq, bq = f_(norm_qty), f_(bill_qty)
|
||||
if nq is None or bq in (None, 0):
|
||||
return "GCL"
|
||||
coef = nq / _gcl_of(bq, unit)
|
||||
return "GCL*%.4f" % coef
|
||||
|
||||
|
||||
def api_bill_adopt(sc, hc, body):
|
||||
"""采纳(数据落地)。body={session_id, bill_id, src_bill_id}
|
||||
9.1 新增清单(x_new=1):清单字段照入库项目覆盖、工程量0;定额整组替换(工程量=GCL公式/单价照带/合价0),
|
||||
@@ -3060,16 +3129,17 @@ def api_bill_adopt(sc, hc, body):
|
||||
return {"ok": False, "msg": "清单不存在(可能已被删除,请刷新)"}
|
||||
if sb["x_tdel"]:
|
||||
return {"ok": False, "msg": "临时删除状态不可以采纳(规格 9.2)——先取消临时删除"}
|
||||
bb = hc.execute("SELECT id, Number, Name, Attr, Unit, Price FROM bills WHERE id=?", (src_id,)).fetchone()
|
||||
bb = hc.execute("SELECT id, Number, Name, Attr, Unit, Price, Quantity FROM bills WHERE id=?", (src_id,)).fetchone()
|
||||
if not bb:
|
||||
return {"ok": False, "msg": "入库项目清单不存在(批次可能已删除)"}
|
||||
bnorms = hc.execute("""SELECT id, Number, Name, Unit, Quantity, Price, Total
|
||||
bnorms = hc.execute("""SELECT id, Number, Name, Unit, Quantity, Price, Total, x_qty_coef
|
||||
FROM norms WHERE bill_id=? ORDER BY id""", (src_id,)).fetchall()
|
||||
is_new = bool(sb["x_new"])
|
||||
# 决策 90(2026-10-17):新采纳的定额,工程量列默认挂公式 **GCL 原文**(=清单工程量÷单位数字前缀,
|
||||
# 纯字母单位=清单工程量;导出时按当时清单量求值——采纳后清单量再改,定额量跟着走)。
|
||||
# 库里 Quantity 留 NULL;9.1 新增清单清单量按 0 计 → GCL=0,导出侧批次回填口径不变。
|
||||
# 规格 19(2026-10-17 主人定·采纳逻辑变化):采纳定额工程量默认公式 = **GCL×系数**,
|
||||
# 系数 = 历史定额量 ÷ 历史清单量(例:历史清单量 500、定额量 300 → GCL*0.6000)——
|
||||
# 换本清单工程量后定额量按比例走。历史清单量缺失/为 0 / 定额量缺失 → 退回裸 GCL。
|
||||
new_price = bb["Price"]
|
||||
src_qty = f_(bb["Quantity"])
|
||||
if is_new:
|
||||
# 9.1 整体覆盖
|
||||
sc.execute("""UPDATE s_bills SET Number=?, Name=?, Attr=?, Unit=?, Price=?, Quantity=0,
|
||||
@@ -3079,8 +3149,9 @@ def api_bill_adopt(sc, hc, body):
|
||||
sc.execute("DELETE FROM s_norms WHERE bill_id=?", (bid,))
|
||||
for nn in bnorms:
|
||||
cur = sc.execute("""INSERT INTO s_norms(bill_id, Number, Name, Unit, Quantity, Price, Total,
|
||||
x_adopt, x_src_norm_id, qty_expr) VALUES(?,?,?,?,NULL,?,NULL,1,?,'GCL')""",
|
||||
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"], nn["id"]))
|
||||
x_adopt, x_src_norm_id, qty_expr) VALUES(?,?,?,?,NULL,?,NULL,1,?,?)""",
|
||||
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"], nn["id"],
|
||||
_gcl_coef_expr(nn["Quantity"], bb["Quantity"], nn["x_qty_coef"], nn["Unit"])))
|
||||
for rr in hc.execute("SELECT res_code, qty FROM norm_res WHERE norm_id=? ORDER BY id", (nn["id"],)):
|
||||
sc.execute("INSERT INTO s_norm_res(norm_id, res_code, qty) VALUES(?,?,?)",
|
||||
(cur.lastrowid, rr["res_code"], rr["qty"]))
|
||||
@@ -3091,8 +3162,9 @@ def api_bill_adopt(sc, hc, body):
|
||||
sc.execute("UPDATE s_norms SET x_tdel=1 WHERE bill_id=?", (bid,)) # 原有定额 → 临删
|
||||
for nn in bnorms:
|
||||
cur = sc.execute("""INSERT INTO s_norms(bill_id, Number, Name, Unit, Quantity, Price, Total,
|
||||
x_adopt, x_src_norm_id, qty_expr) VALUES(?,?,?,?,NULL,?,NULL,1,?,'GCL')""",
|
||||
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"], nn["id"]))
|
||||
x_adopt, x_src_norm_id, qty_expr) VALUES(?,?,?,?,NULL,?,NULL,1,?,?)""",
|
||||
(bid, nn["Number"], nn["Name"], nn["Unit"], nn["Price"], nn["id"],
|
||||
_gcl_coef_expr(nn["Quantity"], bb["Quantity"], nn["x_qty_coef"], nn["Unit"])))
|
||||
for rr in hc.execute("SELECT res_code, qty FROM norm_res WHERE norm_id=? ORDER BY id", (nn["id"],)):
|
||||
sc.execute("INSERT INTO s_norm_res(norm_id, res_code, qty) VALUES(?,?,?)",
|
||||
(cur.lastrowid, rr["res_code"], rr["qty"]))
|
||||
@@ -3654,9 +3726,27 @@ def api_search(body):
|
||||
row["x_hash_semi"] = job.md5(row["Name"], row["Unit"])
|
||||
else:
|
||||
row = sc.execute("SELECT * FROM %s WHERE id=?" % tbl, (rid,)).fetchone()
|
||||
# 规格 20(2026-10-17 主人定):组价不一致对比默认只显示**本组其他清单**的记录
|
||||
# (第 N 组 3 条 → 只显示另外 2 条)。本组 = 同名称集(x_name_norm/x_attr_norm)的
|
||||
# 其他会话清单;其历史记录 = 本批次里同编码同名的批次清单。
|
||||
scope_self = (body.get("scope") == "self_group") and typ == "bill"
|
||||
members = None # [(Number, Name), ...];None=非组价不一致对比
|
||||
batch_id = None
|
||||
if scope_self and typ == "bill" and row is not None and row["x_name_norm"] is not None:
|
||||
batch_id = s["x_batch_id"] if "x_batch_id" in s.keys() else None
|
||||
if batch_id:
|
||||
members = [(m["Number"] or "", m["Name"] or "", m["UWNum"] or "") for m in sc.execute(
|
||||
"""SELECT b.Number AS Number, b.Name AS Name, u.Number AS UWNum FROM s_bills b
|
||||
JOIN s_unit_works u ON u.id = b.uw_id
|
||||
WHERE b.session_id=? AND b.x_name_norm IS ? AND b.x_attr_norm IS ? AND b.id<>?""",
|
||||
(sid, row["x_name_norm"], row["x_attr_norm"], rid)).fetchall()]
|
||||
sc.close()
|
||||
if not row:
|
||||
return {"ok": False, "msg": "找不到这一行"}
|
||||
# 规格 18(2026-10-17 主人定):**组价不一致**清单的对比默认只看本项目——
|
||||
# 同源文件(本组各楼栋/部位)+ 同名项目;别的项目不展示;独立检索(工具栏查询)不受限。
|
||||
# 实现口令 scope=self_group:匹配时不再排除本项目(self_name/self_src 传空),
|
||||
# 拿到全量后按"本组其他清单"过滤(见 members/allowed)。
|
||||
# 历史匹配过滤词(全局设置):剥掉这些词后再算相似度
|
||||
sw = _setting_get("global", "match_stopwords")
|
||||
try:
|
||||
@@ -3690,8 +3780,18 @@ def api_search(body):
|
||||
else:
|
||||
res = match.match_bill(hist, row, base,
|
||||
body.get("file_kinds") or [], body.get("bulid_units") or [],
|
||||
body.get("classes") or [], limit, srcs, pf, pt, self_name, self_src,
|
||||
body.get("classes") or [], limit, srcs, pf, pt,
|
||||
None if scope_self else self_name,
|
||||
None if scope_self else self_src,
|
||||
area)
|
||||
# 规格 20:本组其他清单的批次记录(bill_id 集合)——组价不一致对比按它过滤
|
||||
allowed = None
|
||||
if scope_self and members is not None:
|
||||
allowed = set()
|
||||
for mnum, mname in members:
|
||||
for h in hist.execute("SELECT id FROM bills WHERE batch_id=? AND Number=? AND Name=?",
|
||||
(batch_id, mnum, mname)).fetchall():
|
||||
allowed.add(h[0])
|
||||
finally:
|
||||
hist.close()
|
||||
# 屏蔽词(2026-10-11 主人定):筛选栏输入,命中 名称/特征(规格)/单位 任一词的历史行不显示。
|
||||
@@ -3705,6 +3805,11 @@ def api_search(body):
|
||||
for r in res: # 单价类型码 → 名称(0/空=未标注 → 前端显示 —)
|
||||
fk = r.get("fkind")
|
||||
r["fkind_name"] = FILEKIND.get(fk) if fk not in (None, "", 0) else None
|
||||
if allowed is not None:
|
||||
# 规格 20(定稿):组价不一致对比默认只显示**本组其他清单**的历史记录
|
||||
# (第 N 组 3 条 → 只显示另外 2 条);别的项目/别的历史记录不展示。
|
||||
# 工具栏独立检索(/api/hist/search)不受限。被点清单自己的记录亦不在本组集合内。
|
||||
res = [r for r in res if r.get("bill_id") in allowed]
|
||||
return {"ok": True, "base_period": match.ym(pf) + ("~" + match.ym(pt) if pt != pf else ""),
|
||||
"rows": res, "total": len(res)}
|
||||
|
||||
@@ -4561,6 +4666,53 @@ def _ensure_cols(con, table, cols):
|
||||
print("补列失败 %s.%s:%s" % (table, name, e), flush=True)
|
||||
|
||||
|
||||
def _repair_session_exprs():
|
||||
"""决策 106 一次性修复:会话库存量采纳定额的 qty_expr 由**旧口径系数**(定额量÷清单量)
|
||||
生成,单位带数字前缀(10m/100m…)的定额导出量少 N 倍(前山河 040501004001 实测)。
|
||||
只重写**本软件自动生成形态**(GCL*±数字,恒 4 位小数)的公式——主人手改过的原文不动;
|
||||
系数取批次库 x_qty_coef(启动迁移已换算 GCL 口径),批次行缺失时按 GCL 口径现算兜底。
|
||||
幂等:修完的公式重算结果不变;s_settings 标记防每次启动空跑。"""
|
||||
pat = re.compile(r"^GCL\*-?\d+\.\d{4}$")
|
||||
try:
|
||||
if _setting_get("sys", "mig_session_expr_gcl"):
|
||||
return 0
|
||||
hc = conn()
|
||||
try:
|
||||
sc = sess.connect()
|
||||
try:
|
||||
rows = sc.execute("""SELECT id, x_src_norm_id, qty_expr FROM s_norms
|
||||
WHERE x_adopt=1 AND x_src_norm_id IS NOT NULL""").fetchall()
|
||||
fixes = []
|
||||
for r in rows:
|
||||
if not pat.match((r["qty_expr"] or "").strip()):
|
||||
continue
|
||||
n = hc.execute("SELECT Quantity, Unit, x_qty_coef, bill_id FROM norms WHERE id=?",
|
||||
(r["x_src_norm_id"],)).fetchone()
|
||||
if n is None:
|
||||
continue
|
||||
coef = n["x_qty_coef"]
|
||||
if coef is None:
|
||||
bq = hc.execute("SELECT Quantity FROM bills WHERE id=?",
|
||||
(n["bill_id"],)).fetchone()
|
||||
if n["Quantity"] is None or not bq or bq["Quantity"] in (None, 0):
|
||||
continue
|
||||
coef = n["Quantity"] / _gcl_of(bq["Quantity"], n["Unit"])
|
||||
fixes.append(("GCL*%.4f" % coef, r["id"]))
|
||||
if fixes:
|
||||
sc.executemany("UPDATE s_norms SET qty_expr=? WHERE id=?", fixes)
|
||||
sc.commit()
|
||||
finally:
|
||||
sc.close()
|
||||
finally:
|
||||
hc.close()
|
||||
_setting_set("sys", "mig_session_expr_gcl", "1")
|
||||
print("工程量公式口径修复:%d 条" % len(fixes), flush=True)
|
||||
return len(fixes)
|
||||
except Exception as e:
|
||||
print("!! 会话工程量公式口径修复失败:%s" % e, flush=True)
|
||||
return 0
|
||||
|
||||
|
||||
def _ensure_batch_schema():
|
||||
"""后台批次库的**唯一建表入口**(幂等,可安全重复执行)。
|
||||
|
||||
@@ -4582,7 +4734,17 @@ def _ensure_batch_schema():
|
||||
("Quantity", "REAL"), ("Total", "REAL"),
|
||||
# 源文件备注(清单节点 Remark 属性,2026-10-08;只显示在「原数据」)
|
||||
("src_remark", "TEXT")])
|
||||
_ensure_cols(c, "norms", [("Quantity", "REAL"), ("Total", "REAL")])
|
||||
_ensure_cols(c, "norms", [("Quantity", "REAL"), ("Total", "REAL"),
|
||||
# 规格 19:定额工程量系数(**GCL 口径** = 定额量÷历史GCL,
|
||||
# 导入时算好存库,采纳时直接取用生成 GCL*系数 公式;主人 2026-10-17 定)
|
||||
("x_qty_coef", "REAL")])
|
||||
# 存量批次一次性补算(幂等:只填 NULL;一条 SQL 集合运算,毫秒级无感)
|
||||
c.execute("""UPDATE norms SET x_qty_coef = ROUND(norms.Quantity /
|
||||
(SELECT b.Quantity FROM bills b WHERE b.id = norms.bill_id), 6)
|
||||
WHERE x_qty_coef IS NULL
|
||||
AND norms.Quantity IS NOT NULL
|
||||
AND EXISTS (SELECT 1 FROM bills b WHERE b.id = norms.bill_id
|
||||
AND b.Quantity IS NOT NULL AND b.Quantity != 0)""")
|
||||
_ensure_cols(c, "lmes", [("Quantity", "REAL"), ("Kind", "INTEGER")])
|
||||
# x_info / x_feat:项目级「基本信息」「项目特征信息」两张卡的数据(与 sessions 对齐)
|
||||
# x_parser_ver:导入时的解析器版本,用于启动比对「数据是否过期需重导」
|
||||
@@ -4596,9 +4758,23 @@ def _ensure_batch_schema():
|
||||
CASE WHEN kind='project' THEN ? ELSE ? END
|
||||
WHERE x_parser_ver IS NULL""",
|
||||
(job.PARSER_VER, price.PARSER_VER))
|
||||
# 决策 106(2026-10-17):x_qty_coef 旧口径(定额量÷清单量)→ **GCL 口径**
|
||||
# (定额量÷历史GCL,GCL=清单量÷定额单位数字前缀)一次性全量重算——旧值在
|
||||
# 10m/100m 类单位上把单位换算双算两遍(前山河 040501004001 导出量少 10 倍实测)。
|
||||
# 设置标记防重入(全表重算不该每次启动都跑);导入侧 import_job 已同口径写入。
|
||||
if not c.execute("SELECT 1 FROM settings WHERE k='mig_x_qty_coef_gcl'").fetchone():
|
||||
_rows = c.execute("""SELECT n.id, n.Quantity, n.Unit, b.Quantity
|
||||
FROM norms n JOIN bills b ON b.id = n.bill_id
|
||||
WHERE n.Quantity IS NOT NULL AND b.Quantity IS NOT NULL
|
||||
AND b.Quantity != 0""").fetchall()
|
||||
c.executemany("UPDATE norms SET x_qty_coef=? WHERE id=?",
|
||||
[(round(nq * job.unit_prefix(un) / bq, 6), _nid)
|
||||
for _nid, nq, un, bq in _rows])
|
||||
c.execute("INSERT OR REPLACE INTO settings(k,v,updated_at) VALUES('mig_x_qty_coef_gcl','1',datetime('now'))")
|
||||
c.commit()
|
||||
c.close()
|
||||
_BATCH_SCHEMA_ONCE = True
|
||||
_BATCH_SCHEMA_ONCE = True # 先落标志再跑会话修复——repair 里的 conn() 会重入本函数
|
||||
_repair_session_exprs()
|
||||
except Exception as e:
|
||||
# 2026-10-07:此前这里静默 pass —— 建表/补列失败会让后续所有接口莫名的报错,
|
||||
# 却查不到任何线索(overMaxMsg 同类教训)。至少要把失败喊出来。
|
||||
|
||||
300
CostReview/app/tests/test_export_structure.py
Normal file
300
CostReview/app/tests/test_export_structure.py
Normal file
@@ -0,0 +1,300 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""决策 106(2026-10-17)两件实测事故的回归:
|
||||
①插入节点整块克隆——此前新增清单/采纳定额只克隆开标签,缺原生 innards(费用构成汇总、
|
||||
单价计算公式行、WorkContent 壳…),易达按结构取数看不到新增清单(cos 与 cos4 同样
|
||||
实测),广联达整包报「不是有效标书」;
|
||||
②工程量系数 GCL 口径——旧口径(定额量÷清单量)在 10m/100m 类单位上把单位换算双算两遍
|
||||
(前山河 040501004001:10m 定额导出量少 10 倍实测)。
|
||||
"""
|
||||
import io
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import zipfile
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "core")))
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "server")))
|
||||
import export_cos as xcos # noqa: E402
|
||||
import api_harness as H # noqa: E402
|
||||
from api_harness import server # noqa: F401,E402 (夹具须经导入注册)
|
||||
from api_harness import get, post # noqa: E402
|
||||
|
||||
# 珠海 .cos 形态的原生清单块(费用构成 + 工程量表达式行 + 定额内 管理费/单价计算公式行)
|
||||
RICH_BILL = (
|
||||
'<WorkElement Number="040803004001" Name="管道封堵" Attr="1、封堵现状管" WorkContent="" Unit="个"'
|
||||
' Quantity="2.000" QtyFormula="" Price="1187.14" Total="2374.28" EquipmentPrice="0" Rate="0"'
|
||||
' PriceLow="0" PriceHigh="0" Major="false" CalcType="1" Code="" ListingIdentity="GB50857-2013 4 GD"'
|
||||
' Specialty="4" Kind="1" CalculationKind="15" CostKind="3" Remark="L:3平面图中只见2个">'
|
||||
'<SummaryOfBasicCost Labor="269.72" Material="880.90" MainMaterial="0" Equipment="0"'
|
||||
' MainMaterialEquipment="0" Appraisal="0" Machine="856.42" Overhead="198.32" Profit="168.92"'
|
||||
' StatutoryFees="0" Tax="0" ForeignCurrency="0" ConvertedIntoRMB="0"/>'
|
||||
'<ExpressElement OrderNumber="1" Express="2" Quantity="2" Kind="1" Remark=""/>'
|
||||
'<Norm Number="3-1-1" Name="管堵砌筑 直径(mm内) DN600//调:" Unit="只" Quantity="2.000000"'
|
||||
' Price="1187.14" EquipmentPrice="0" Total="2374.28" EfficiencyKind="2" IncFeeKind="2"'
|
||||
' Conversion="" Specialty="99" NormIdentity="GD 99 2019" Volume="0" Chapter="0"'
|
||||
' EquipmentTotal="0" ForeignCurrency="0" ConvertedIntoRMB="0" IsNorm="true" Kind="1"'
|
||||
' CalculationKind="15" CostKind="3" Remark="">'
|
||||
'<ExpressElement OrderNumber="1" Express="QGCL" Quantity="2" Kind="1" Remark=""/>'
|
||||
'<ManageFees Fee1="17.61" Fee2="17.61" Fee3="17.61" Fee4="17.61" Rate="1.00"'
|
||||
' AddFee1="0" AddFee2="0" AddFee3="0" AddFee4="0"/>'
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="00010010" Quantity="134.86" NOCost="false" Remark=""/>'
|
||||
'<UnitPriceCalculationOfItem Code="RGF" Name="人工费" Total="134.86" QtyFormula="_RGF" Rate="100.000" Remark="人工费"/>'
|
||||
'<UnitPriceCalculationOfItem Code="HJ" Name="子目合价" Total="2374.28" QtyFormula="_GCL*7" Rate="100.000" Remark="工程量*单价"/>'
|
||||
'</Norm></WorkElement>')
|
||||
|
||||
NEW_BILL = {"id": 901, "Number": "040101001002", "Name": "路基挖土方(可利用方)",
|
||||
"Attr": "1、土类别:综合", "Unit": "m3", "Quantity": 1000.0,
|
||||
"Price": 4.54, "Total": 4540.0, "src_remark": None}
|
||||
NEW_NORM = {"id": 902, "Number": "D1-1-29", "Name": "挖掘机挖一般土方 一、二类土",
|
||||
"Unit": "1000m3天然密实方", "Quantity": 1.0, "Price": 4540.91, "Total": 4540.91}
|
||||
|
||||
|
||||
def _parse(frag):
|
||||
return ET.fromstring("<r>%s</r>" % frag)[0]
|
||||
|
||||
|
||||
def test_new_bill_full_structure_cos():
|
||||
"""新增清单整块克隆:费用构成清零在位、公式保留、定额带单价计算公式行、备注不带模板的。"""
|
||||
out = xcos._bill_xml(NEW_BILL, "WorkElement",
|
||||
[xcos._norm_xml(NEW_NORM, [("00010010", 594.0)],
|
||||
xcos._full_norm_block(RICH_BILL))],
|
||||
RICH_BILL)
|
||||
we = _parse(out)
|
||||
assert [c.tag for c in we] == ["SummaryOfBasicCost", "ExpressElement", "Norm"]
|
||||
sbc = we.find("SummaryOfBasicCost")
|
||||
assert all(v == "0" for v in sbc.attrib.values()) # 别人的金额一个不带
|
||||
ee = we.find("ExpressElement")
|
||||
assert ee.get("Quantity") == "0" and ee.get("Express") == ""
|
||||
assert ee.get("OrderNumber") == "1" # 结构属性保留
|
||||
norm = we.find("Norm")
|
||||
assert norm.get("Number") == "D1-1-29" and norm.get("Quantity") == "1.000000"
|
||||
assert norm.get("NormIdentity") == "GD 99 2019" # 属性集照旧齐全(决策 64)
|
||||
upc = norm.findall("UnitPriceCalculationOfItem")
|
||||
assert len(upc) == 2 and all(c.get("Total") == "0" for c in upc)
|
||||
assert upc[0].get("QtyFormula") == "_RGF" # 公式保留,易达打开可重算
|
||||
assert norm.find("ManageFees").get("Rate") == "1.00"
|
||||
assert norm.find("ManageFees").get("Fee1") == "0"
|
||||
assert [c.get("Number") for c in norm.findall("LabourMaterialsEquipmentsMachinesElement")] == ["00010010"]
|
||||
assert we.get("Remark") == "" # 模板备注(别人的)不带
|
||||
|
||||
|
||||
def test_appended_norm_keeps_innards():
|
||||
"""采纳定额追加进原有清单:innards 一并克隆(此前裸 Norm 同样过不了结构关)。"""
|
||||
out = xcos._norm_xml(NEW_NORM, [("00010010", 594.0)], xcos._full_norm_block(RICH_BILL))
|
||||
norm = _parse(out)
|
||||
assert [c.tag for c in norm] == ["ExpressElement", "ManageFees",
|
||||
"LabourMaterialsEquipmentsMachinesElement",
|
||||
"UnitPriceCalculationOfItem", "UnitPriceCalculationOfItem"]
|
||||
assert all(c.get("Total") == "0" for c in norm.findall("UnitPriceCalculationOfItem"))
|
||||
assert norm.find("ExpressElement").get("Express") == "" # 表达式文本清空(别人的公式带 QGCL 但量是别人的)
|
||||
assert norm.get("Remark") == "" # 决策 101 口径不变
|
||||
|
||||
|
||||
def test_legacy_minimal_template_unchanged():
|
||||
"""模板只是开标签(旧调用形态/夹具最小清单)→ 输出与旧版一致,不造 innards。"""
|
||||
nb = xcos._full_norm_block(RICH_BILL)
|
||||
opentag = nb[:xcos._open_tag_end(nb, 0)]
|
||||
out = xcos._norm_xml(NEW_NORM, [("00010010", 594.0)], opentag)
|
||||
norm = _parse(out)
|
||||
assert [c.tag for c in norm] == ["LabourMaterialsEquipmentsMachinesElement"]
|
||||
bill_opentag = RICH_BILL[:xcos._open_tag_end(RICH_BILL, 0)]
|
||||
out_b = xcos._bill_xml(NEW_BILL, "WorkElement", [out], bill_opentag)
|
||||
we = _parse(out_b)
|
||||
assert [c.tag for c in we] == ["Norm"]
|
||||
assert we.get("Remark") == "" # 决策 106:新增清单没源备注时模板备注一律不带(旧版会泄漏锚点的备注)
|
||||
|
||||
|
||||
def test_yida_sample_template_leaks_fixed():
|
||||
"""主人 2026-10-17 提供的易达样本(锚杆 010302006002,LME 带 Express 值、定额带
|
||||
NormAdjustmentList 换算记录):克隆进新节点时这些「别人的值」一律不带——
|
||||
Express 清空、换算记录整行不落(架子可以有,别人的数据不能有)。"""
|
||||
yida_norm = (
|
||||
'<Norm Number="A1-2-48" Name="锚杆土钉机械成孔 土层 孔径≤150mm" Unit="100m" Quantity="19.010000"'
|
||||
' Price="6077.49" Total="115533.08" NormIdentity="440000 1 2018" IsNorm="true" Remark="">'
|
||||
'<ExpressElement OrderNumber="1" Area="" Express="QGCL" Explain="" Quantity="1901" Kind="1" Remark=""/>'
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="00010010" Express="1715.0700" Quantity="1715.0700" Remark=""/>'
|
||||
'<UnitPriceCalculationOfItem Name="人工费" QtyFormula="_RGF" Rate="100.00" Total="1852.28" Code="RGF" Remark="人工费"/>'
|
||||
'<NormAdjustmentList OrderNumber="1" Value="换:工程地质液压钻机 "/>'
|
||||
'<NormAdjustmentList OrderNumber="3" Value="修改990212120-0001单价:760.74"/>'
|
||||
'</Norm>')
|
||||
out = xcos._norm_xml(NEW_NORM, [("00010010", 594.0)], yida_norm)
|
||||
norm = _parse(out)
|
||||
lme = norm.find("LabourMaterialsEquipmentsMachinesElement")
|
||||
assert lme.get("Express") == "594.0" and lme.get("Quantity") == "594.0" # 模板的 1715.0700 不带,填本行含量
|
||||
assert norm.findall("NormAdjustmentList") == [] # 换算记录不背给新定额
|
||||
assert norm.find("UnitPriceCalculationOfItem").get("Total") == "0"
|
||||
assert norm.find("UnitPriceCalculationOfItem").get("QtyFormula") == "_RGF"
|
||||
# 清单级单价公式行的 QtyFormula 若是**纯数字字面量**(有的文件直接存数值)也清空——
|
||||
# 那是模板清单自己的单价/合价,留着会被按公式求值显示(220kV 件实测背 189006.16)
|
||||
assert xcos._zero_results('<UnitPriceCalculationOfItem Name="子目合价" QtyFormula="189006.16"'
|
||||
' Rate="100.00" Total="0" Code="HJ" Remark=""/>').count('QtyFormula=""') == 1
|
||||
assert '_GCL*7' in xcos._zero_results('<UnitPriceCalculationOfItem Name="子目合价" QtyFormula="_GCL*7"'
|
||||
' Rate="100.00" Total="0" Code="HJ" Remark=""/>') # 通用公式保留
|
||||
# 工料机行模板(bill 尾表重建)同样清 Express
|
||||
row = xcos._lme_row('<LabourMaterialsEquipmentsMachinesElement Number="00010010"'
|
||||
' Express="90.5224" Quantity="90.5224" Remark=""/>', "GLF", 0)
|
||||
assert 'Number="GLF"' in row and 'Express=""' in row and 'Quantity="0"' in row
|
||||
|
||||
|
||||
def test_new_bill_workcontent_profile_cos4():
|
||||
"""cos4(WorkContent 画像):新增清单的定额逐条包 WorkContent 壳(决策 98 同款),
|
||||
清单级工料机尾表按会话资源重建(0 量)、模板的金额清零。"""
|
||||
tmpl = ('<WorkElement Number="040101001001" Name="挖一般土方" Attr="1、土壤类别:综合" WorkContent=""'
|
||||
' Unit="m3" Quantity="1483.220" Price="4.29" Total="6363.01" Type="1" PriceType="1"'
|
||||
' ListingIdentity="GB/T 50857-2024 4 440000" Specialty="4" Kind="1" Remark="">'
|
||||
'<SummaryOfBasicCost Labor="951.52" Material="0" Machine="4034.54" Overhead="628.74"'
|
||||
' Profit="747.91" DivisionalAndElementalWorks="6363.01" Tax="0"/>'
|
||||
'<ExpressElement OrderNumber="1" Area="" Express="1483.22" Explain="" Quantity="1483.22" Kind="1" Remark=""/>'
|
||||
'<WorkContent Name="土方开挖" Total="6362.70" Remark="">'
|
||||
'<Norm Number="D1-1-29" Name="挖掘机挖一般土方 一、二类土" Unit="1000m3天然密实方" Quantity="1.483220"'
|
||||
' Price="4289.79" Total="6362.70" Specialty="4" NormIdentity="440000 4 2018" IsNorm="true" Type="1" Remark="">'
|
||||
'<ExpressElement OrderNumber="1" Area="" Express="QGCL" Explain="" Quantity="1483.22" Kind="1" Remark=""/>'
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="00010010" Express="" Quantity="594.0000" Remark=""/>'
|
||||
'<UnitPriceCalculationOfItem Name="人工费" QtyFormula="_RGF" Rate="100.00" Total="641.52" Code="RGF" Remark="人工费"/>'
|
||||
'</Norm></WorkContent>'
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="00010010" Express="" Quantity="881.00" Remark=""/>'
|
||||
'</WorkElement>')
|
||||
out = xcos._bill_xml(NEW_BILL, "WorkElement",
|
||||
[xcos._norm_xml(NEW_NORM, [("990101015", 0.117)],
|
||||
xcos._full_norm_block(tmpl))],
|
||||
tmpl)
|
||||
we = _parse(out)
|
||||
wcs = we.findall("WorkContent")
|
||||
assert len(wcs) == 1 and wcs[0].get("Name") == "路基挖土方(可利用方)" # 逐条包壳,名照本清单
|
||||
assert wcs[0].get("Total") == "4540.00"
|
||||
assert wcs[0].find("Norm").get("Number") == "D1-1-29"
|
||||
assert wcs[0].find("Norm").find("UnitPriceCalculationOfItem").get("Total") == "0"
|
||||
tail = [c for c in we.findall("LabourMaterialsEquipmentsMachinesElement")]
|
||||
assert [c.get("Number") for c in tail] == ["990101015"] # 尾表按会话资源重建
|
||||
assert tail[0].get("Quantity") == "0.0001" # 0.117×1÷1000 = 每单位消耗量
|
||||
assert we.find("SummaryOfBasicCost").get("DivisionalAndElementalWorks") == "0"
|
||||
assert we.find("ExpressElement").get("Quantity") == "0"
|
||||
|
||||
|
||||
def test_bill_tail_lme_real_values():
|
||||
"""清单级消耗量架子填真值(决策 106 补记,主人广联达样本同款算法):
|
||||
Σ(定额含量×定额量)÷清单量,跨定额同码合并一行、Express 照原生填同值;
|
||||
广联达样本实测数:人工 (1611.66×100+595.03×10)÷10000 = 16.7116。"""
|
||||
tmpl = ('<WorkElement Number="010101001001" Name="挖单独土方" WorkContent="" Unit="m3"'
|
||||
' Quantity="10000" Price="126.17" Total="1261700" NormIdentity="X" Kind="1" Remark="">'
|
||||
'<SummaryOfBasicCost Labor="1" Material="0" Tax="0"/>'
|
||||
'<WorkContent Name="开挖" Total="1" Remark="">'
|
||||
'<Norm Number="A1-1-5" Name="人工挖一般土方 一、二类土" Unit="100m3" Quantity="100"'
|
||||
' Price="2183.8" Total="218380" NormIdentity="440000 1 2018" IsNorm="true" Remark="">'
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="00010010" Quantity="1611.6600" Remark="" Express="1611.66*1"/>'
|
||||
'<UnitPriceCalculationOfItem Name="单价" QtyFormula="RGF" Rate="100" Total="0" Code="DJ" Remark=""/>'
|
||||
'</Norm>'
|
||||
'<Norm Number="A1-1-37" Name="挖掘机挖一般土方 一、二类土" Unit="1000m3" Quantity="10"'
|
||||
' Price="4323.21" Total="43232.1" NormIdentity="440000 1 2018" IsNorm="true" Remark="">'
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="00010010" Quantity="595.0300" Remark="" Express="595.03*1"/>'
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="990101015" Quantity="0.1700" Remark="" Express="0.17*1"/>'
|
||||
'<UnitPriceCalculationOfItem Name="单价" QtyFormula="RGF" Rate="100" Total="0" Code="DJ" Remark=""/>'
|
||||
'</Norm></WorkContent>'
|
||||
'<LabourMaterialsEquipmentsMachinesElement Number="00010010" Quantity="90.5224" Remark="" Express="90.5224"/>'
|
||||
'<UnitPriceCalculationOfItem Name="单价" QtyFormula="RGF" Rate="100" Total="0" Code="DJ" Remark=""/>'
|
||||
'</WorkElement>')
|
||||
bill = dict(NEW_BILL, Quantity=10000.0)
|
||||
n1 = dict(NEW_NORM, Number="A1-1-5", Unit="100m3", Quantity=100.0)
|
||||
n2 = dict(NEW_NORM, Number="A1-1-37", Unit="1000m3", Quantity=10.0)
|
||||
out = xcos._bill_xml(bill, "WorkElement",
|
||||
[xcos._norm_xml(n1, [("00010010", 1611.66)], xcos._full_norm_block(tmpl)),
|
||||
xcos._norm_xml(n2, [("00010010", 595.03), ("990101015", 0.17)],
|
||||
xcos._full_norm_block(tmpl))],
|
||||
tmpl)
|
||||
we = _parse(out)
|
||||
tail = we.findall("LabourMaterialsEquipmentsMachinesElement")
|
||||
assert [(c.get("Number"), c.get("Quantity"), c.get("Express")) for c in tail] == [
|
||||
("00010010", "16.7116", "16.7116"), # 同码合并:(1611.66×100+595.03×10)÷10000
|
||||
("990101015", "0.0002", "0.0002"), # 0.17×10÷10000
|
||||
], [(c.get("Number"), c.get("Quantity")) for c in tail]
|
||||
|
||||
|
||||
def test_new_bill_top_anchor_position(server):
|
||||
"""决策 106 补记四:工作台插在最上面(insert_above 第一条 → 锚点 0)的新增清单,
|
||||
导出落位 = 第一条源清单**之前**。此前锚点 0 被当「无锚点」甩到组尾
|
||||
(主人 2026-10-18 实测:软件里插序号 1,易达里跑到最后)。"""
|
||||
import hashlib
|
||||
import sqlite3
|
||||
import uuid
|
||||
proj = "顶部插入工程-" + uuid.uuid4().hex[:6]
|
||||
bills = [("B00%d" % i, "清单%d" % i, "1、x", "m3", 10 + i, 100.0) for i in (1, 2, 3)]
|
||||
p = H.make_cos4(str(server["src_dir"] / ("top_%s_raw.cos4" % proj[-6:])), proj, bills)
|
||||
raw = open(p, "rb").read()
|
||||
hp = os.path.join(str(server["root"]), "CostReview", "data", "source_files",
|
||||
"%s_top.cos4" % hashlib.sha256(raw).hexdigest())
|
||||
with open(hp, "w+b") as f:
|
||||
f.write(raw)
|
||||
imp = post(server, "/api/admin/import", dict(H.META, path=hp, name=proj))
|
||||
assert imp["ok"] is True, imp
|
||||
audit = {"name": proj, "province": H.META["province"], "city": H.META["city"],
|
||||
"district": H.META["district"], "period_from": H.PERIOD_202607,
|
||||
"period_to": H.PERIOD_202607, "file_kind": 1}
|
||||
sid = post(server, "/api/audit", dict(audit, path=hp))["session_id"]
|
||||
rows = get(server, "/api/session/rows", session_id=sid, type="bill")["rows"]
|
||||
first_id = [r[0] for r in rows if r[1] == "B001"][0]
|
||||
r = post(server, "/api/session/bill/op", {"session_id": sid, "op": "insert_above",
|
||||
"bill_id": first_id})
|
||||
assert r["ok"] is True, r
|
||||
new_id = r["id"]
|
||||
r = post(server, "/api/session/bill/op", {"session_id": sid, "op": "edit", "bill_id": new_id,
|
||||
"fields": {"Name": "顶部新增清单"}})
|
||||
assert r["ok"] is True, r
|
||||
zf = _export_zip(server, sid)
|
||||
txt = "".join(zf.read(n).decode("utf-8", errors="replace") for n in zf.namelist()
|
||||
if n.lower() != "project.xml")
|
||||
assert txt.index('Name="顶部新增清单"') < txt.index('Number="B001"'), "新增清单应在第一条源清单之前"
|
||||
|
||||
|
||||
def _export_zip(server, sid):
|
||||
resp = server["client"].get("/api/session/export", params={"session_id": sid})
|
||||
if not resp.headers["content-type"].startswith("application/zip"):
|
||||
raise AssertionError("导出失败: " + resp.text[:300])
|
||||
return zipfile.ZipFile(io.BytesIO(resp.content))
|
||||
|
||||
|
||||
def test_coef_unit_prefix_no_double_count(server):
|
||||
"""10m 定额:历史 清单1094.68 / 定额109.468 → 系数 GCL 口径 = 1.0,
|
||||
清单量改 90000000 后导出定额量 = 9000000(=GCL,单位换算只算一次)。"""
|
||||
import hashlib
|
||||
import sqlite3
|
||||
import uuid
|
||||
proj = "系数口径工程-" + uuid.uuid4().hex[:6]
|
||||
bill = ("040501004001", "高性能硬聚乙烯PVC-UH排水管DN200", "1、x", "m", 1094.68, 63.31)
|
||||
lme = ("000001", "网络摄像机", "400万", "台", "1200", "1356")
|
||||
p = H.make_cos4(str(server["src_dir"] / ("coef_%s_raw.cos4" % proj[-6:])), proj, [bill], [lme])
|
||||
raw = open(p, "rb").read()
|
||||
hp = os.path.join(str(server["root"]), "CostReview", "data", "source_files",
|
||||
"%s_coef.cos4" % hashlib.sha256(raw).hexdigest())
|
||||
with open(hp, "w+b") as f:
|
||||
f.write(raw)
|
||||
imp = post(server, "/api/admin/import", dict(H.META, path=hp, name=proj))
|
||||
assert imp["ok"] is True, imp
|
||||
# 把该批次定额改成 10m 口径的历史形态(清单 1094.68m、定额 109.468 每 10m),
|
||||
# 系数按 GCL 口径 = 定额量×前缀÷清单量 = 1.0
|
||||
hc = sqlite3.connect(server["db"])
|
||||
hc.execute("UPDATE norms SET Unit='10m', Quantity=109.468,"
|
||||
" x_qty_coef=ROUND(109.468*10/(SELECT Quantity FROM bills WHERE bills.id=norms.bill_id),6)")
|
||||
hc.commit(); hc.close()
|
||||
audit = {"name": proj, "province": H.META["province"], "city": H.META["city"],
|
||||
"district": H.META["district"], "period_from": H.PERIOD_202607,
|
||||
"period_to": H.PERIOD_202607, "file_kind": 1}
|
||||
sid = post(server, "/api/audit", dict(audit, path=hp))["session_id"]
|
||||
rows = get(server, "/api/session/rows", session_id=sid, type="bill")["rows"]
|
||||
bill_id = [r[0] for r in rows if r[1] == bill[0]][0]
|
||||
src_id = sqlite3.connect(server["db"]).execute(
|
||||
"SELECT id FROM bills WHERE Number=?", (bill[0],)).fetchone()[0]
|
||||
r = post(server, "/api/session/bill/adopt", {"session_id": sid, "bill_id": bill_id,
|
||||
"src_bill_id": src_id})
|
||||
assert r["ok"] is True, r
|
||||
expr = sqlite3.connect(server["sessdb"]).execute(
|
||||
"SELECT qty_expr FROM s_norms WHERE bill_id=? AND x_adopt=1", (bill_id,)).fetchone()[0]
|
||||
assert expr == "GCL*1.0000", expr # 旧口径这里会给 GCL*0.1000(双算单位)
|
||||
con = sqlite3.connect(server["sessdb"])
|
||||
con.execute("UPDATE s_bills SET Quantity=90000000 WHERE id=?", (bill_id,))
|
||||
con.commit(); con.close()
|
||||
zf = _export_zip(server, sid)
|
||||
hits = sum(zf.read(n).count(b'Quantity="9000000.000000"') for n in zf.namelist())
|
||||
assert hits == 1, hits # 90000000 ÷ 10m 前缀 = 9000000,不是 900000
|
||||
@@ -99,7 +99,8 @@ def test_adopt_gcl_default_and_price_overwrite(server):
|
||||
proj, sid, bill_id, norm_id = _setup(server, "adoptgcl")
|
||||
r = _q(server["sessdb"], "SELECT Quantity, qty_expr, Price, x_adopt FROM s_norms WHERE id=?",
|
||||
(norm_id,))[0]
|
||||
assert r[1] == "GCL" and r[0] is None and r[3] == 1, r # 默认公式原文,不是算死的数字
|
||||
# 规格 19:默认公式 = GCL×系数(历史定额量10 ÷ 历史清单量10 = 1.0000)
|
||||
assert r[1] == "GCL*1.0000" and r[0] is None and r[3] == 1, r # 默认公式原文,不是算死的数字
|
||||
# 决策90 9.3:清单单价按采纳价(入库清单价 500)覆盖,合价=工程量 10×500
|
||||
br = _q(server["sessdb"], "SELECT Price, Total, x_adopt FROM s_bills WHERE id=?", (bill_id,))[0]
|
||||
assert abs(br[0] - 500) < 1e-9 and abs(br[1] - 5000) < 1e-9 and br[2] == 1, br
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
两页各自的 th.l/th.r 覆盖规则已同步删除 —— 居中只允许这一条规则,别处再写会局部改回去。
|
||||
带 data-sumw 的定宽表有内联 width,本规则不覆盖宽度,仍按各自尺寸。 */
|
||||
thead th{text-align:center}
|
||||
/* 规格 16(主人定):全部字段名称居中(全局)——数字列头原本被 .r 右对齐盖住,
|
||||
这里用更高优先级压回居中;**只影响表头**,表体内容对齐(.r 右/.l 左)原样保留 */
|
||||
th,th.r,th.l{text-align:center}
|
||||
.rawmain > table, .rawmain .rawbody > table{width:100%}
|
||||
/* ---- 原数据加载无感(2026-10-07)----
|
||||
切标签不清空旧内容(那一下跳动最扎眼):旧内容压暗 + 右上角小角标,
|
||||
|
||||
@@ -790,12 +790,15 @@ function grpTreeRender(box, d, pick, opt) {
|
||||
// 组号跟主表对齐(2026-10-10 主人定「按现有目录排序」):一律按显示位置连续编第 1~N 组,
|
||||
// 不再用规则 seq —— 那套号与主表错位,还和系统组撞号(第19/20/24组在树里各出现两次)。
|
||||
// 关键词组名保留(主表组标题没有组名,左树是唯一能看到组名的地方)。
|
||||
// 规格 20:全部组价一致的组**不消失**,目录组名变绿(consistent=1);再出现价差恢复原色。
|
||||
const nm = (opt.kind === 'inconsistent' && g.name)
|
||||
? '第 ' + (i + 1) + ' 组 · ' + esc(g.name) + ' · ' + n + ' 条' // 规格 左目录区1
|
||||
: g.cat
|
||||
? '第 ' + (i + 1) + ' 组 · ' + esc(g.cat) + '(' + n + ' 条)'
|
||||
: '第 ' + (i + 1) + ' 组 · ' + n + ' 条';
|
||||
h += '<div class="rn lv1" data-pk="' + pfx + 'g' + i + '"><span class="nm">' + nm + '</span></div>';
|
||||
const grn = (opt.kind === 'inconsistent' && g.consistent)
|
||||
? ' style="color:#1a9e5c;font-weight:600" title="该组已组价一致"' : '';
|
||||
h += '<div class="rn lv1" data-pk="' + pfx + 'g' + i + '"><span class="nm"' + grn + '>' + nm + '</span></div>';
|
||||
});
|
||||
extra.forEach((g, i) => {
|
||||
// 2026-10-13 主人定:落单组标题颜色与其他组一致(原灰色 #8a97a8 内联取消)
|
||||
|
||||
@@ -1436,6 +1436,7 @@ async function search(){
|
||||
: { file_kinds:FLT.kinds, bulid_units:FLT.unit?[FLT.unit]:[] };
|
||||
const r=await J('/api/search',{method:'POST',headers:{'Content-Type':'application/json'},
|
||||
body:JSON.stringify({session_id:SID,type:CURTYPE,row_id:CUR.id,limit:50,
|
||||
scope:(CURTYPE==='bill' && curTab()==='p1') ? 'self_group' : '', // 规格 18:组价不一致对比默认只看本项目
|
||||
...flt,
|
||||
stop:(FLT.stop||'').trim(),
|
||||
area:FLT.area.map(k=>{const a=k.split('/');return{province:a[0]||'',city:a[1]||'',district:a[2]||''}}),
|
||||
|
||||
Reference in New Issue
Block a user