feat(mcp): 新增 Excel 批量清单匹配工具并调整分页与采纳锚策略
This commit is contained in:
@@ -384,9 +384,11 @@ def _region3(p, c, d3):
|
||||
return "/".join(x for x in (p, c, d3) if x) or None
|
||||
|
||||
|
||||
def match_bill(hist, row, base, kinds, units, classes, limit=20, srcs=None, pfrom=None, pto=None, self_name=None, self_src=None, area=None, projs=None, pmin=None, pmax=None, att="all"):
|
||||
def match_bill(hist, row, base, kinds, units, classes, limit=20, srcs=None, pfrom=None, pto=None, self_name=None, self_src=None, area=None, projs=None, pmin=None, pmax=None, att="all", unit_free=False):
|
||||
bf, bt = span(base) # 基准期次:单月 int 或 (起, 止) 区间
|
||||
"""row: sqlite Row of s_bills"""
|
||||
"""row: sqlite Row of s_bills
|
||||
unit_free(2026-11-02 主人定,Excel 批量匹配专用):Excel 只有一列清单名称没有单位/编码 ——
|
||||
True=跳过字集档(键含单位对不齐)并放宽模糊档单位护栏,纯按名称相似度匹配;比对框不传(False)行为零变化。"""
|
||||
c = hist.cursor()
|
||||
w, args = _filters(kinds, units, [], self_src=self_src, area=area, projs=projs) # classes 只对价格库有意义,清单比对不筛目录
|
||||
# 决策 208(2026-10-26 主人定):价格范围/附件筛选清单侧同样生效(工具栏恒显最大集)——
|
||||
@@ -428,7 +430,8 @@ def match_bill(hist, row, base, kinds, units, classes, limit=20, srcs=None, pfro
|
||||
out.append(d); seen.add((d["Name"], d["Attr"])); seen_ids.add(d["id"])
|
||||
# L1.5 字集精确(2026-10-10 决策 27):名称字集+单位等价——「钢筋混凝土」=「混凝土钢筋」,
|
||||
# 不按排序的严格命中;键 = bills.x_setkey(导入落列,老库启动迁移回填)。
|
||||
if len(out) < limit:
|
||||
# unit_free(Excel 无单位)时键对不齐 → 整档跳过,交给下方模糊档纯名称相似度。
|
||||
if len(out) < limit and not unit_free:
|
||||
sqlk = """SELECT '字集' tier, b.id, b.Number, b.Name, b.Attr, b.Unit, b.Price, bt.Name proj,
|
||||
bt.x_period_start_m p1, bt.x_period_end_m p2, bt.FileKind, bt.BulidUnit, bt.x_src_hash src,
|
||||
bt.x_province, bt.x_city, bt.x_district
|
||||
@@ -451,7 +454,7 @@ def match_bill(hist, row, base, kinds, units, classes, limit=20, srcs=None, pfro
|
||||
FROM bills b JOIN batches bt ON bt.id=b.batch_id
|
||||
WHERE bt.kind='project' AND %s AND b.x_name_norm LIKE ? LIMIT 300""" % w
|
||||
for x in c.execute(sql3, args + ["%" + q + "%"]):
|
||||
if norm(x["Unit"]) != norm(row["Unit"]):
|
||||
if not unit_free and norm(x["Unit"]) != norm(row["Unit"]):
|
||||
continue
|
||||
if x["id"] in seen_ids:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user