feat(match): 工料机过滤统一到 lme_list_where 并用于检索口径

- 将「项目工料机」过滤规则唯一实现挪到 match.lme_list_where(),支持列前缀参数,工作台与后台统一引用
- 工料机检索(hist_search_lme 工程分支)同用该过滤,修复检索能搜出已被屏蔽单位(如台班)的问题
- 测试数据生成器支持独立参考库目录(REF_DIR),面板展示参考/测试库文件与存在状态
- 清理遗留的审查报告汇总与旧界面.html
This commit is contained in:
lianjianwei2024
2026-10-09 21:42:13 +08:00
parent 22acb0dfe2
commit eee1fe9029
10 changed files with 228 additions and 1626 deletions

View File

@@ -37,6 +37,15 @@ def log(msg):
pass
def _cfg():
"""读 config.json(找不到/坏档返回空 dict)。"""
try:
with open(G.CFG_PATH, encoding="utf-8") as f:
return json.load(f) or {}
except Exception:
return {}
def running():
p = _state["proc"]
return p is not None and p.poll() is None
@@ -111,6 +120,16 @@ class H(BaseHTTPRequestHandler):
s = G.stats_of(dd) if dd else {"data_dir": None}
except Exception as e:
s = {"data_dir": dd, "error": str(e)}
rd = _cfg().get("ref_dir", "")
G.REF_DIR = rd or None
if dd:
rh, th, rs, ts = G.db_paths(dd)
s["ref_dir"] = os.path.dirname(rh)
s["test_dir"] = dd
s["ref_names"] = [os.path.basename(rh), os.path.basename(rs)]
s["test_names"] = [os.path.basename(th), os.path.basename(ts)]
s["ref_ok"] = [os.path.exists(rh), os.path.exists(rs)]
s["test_ok"] = [os.path.exists(th), os.path.exists(ts)]
s["running"] = running()
s["mode"] = _state["mode"] if running() else None
self._send(200, s)
@@ -126,21 +145,35 @@ class H(BaseHTTPRequestHandler):
except Exception:
body = {}
if self.path == "/api/dir":
p = (body.get("data_dir") or "").strip()
if p and (os.path.exists(os.path.join(p, "history.db"))
or os.path.exists(os.path.join(p, G.TEST_H))):
G.set_data_dir(p)
self._send(200, {"ok": True, "data_dir": p})
def _normdir(v):
p = (v or "").strip()
if not p:
return ""
p = os.path.normpath(p)
if os.path.isfile(p): # 粘贴了 .db 文件路径 → 取其目录
p = os.path.dirname(p)
return p if os.path.isdir(p) else ""
c0 = _cfg()
t_raw, r_raw = body.get("test_dir"), body.get("ref_dir")
td = _normdir(t_raw) if t_raw is not None else c0.get("data_dir", "")
rd = (_normdir(r_raw) if r_raw else "") if r_raw is not None else c0.get("ref_dir", "")
if not td:
self._send(200, {"ok": False, "msg": "测试库目录无效(目录不存在)"})
elif rd and not (os.path.exists(os.path.join(rd, G.REAL_H))
or os.path.exists(os.path.join(rd, G.TEST_H))):
self._send(200, {"ok": False, "msg": "参考目录里没有 history.db"})
else:
self._send(200, {"ok": False,
"msg": "目录里没有 history.db / history-test.db"})
G.set_data_dir(td, rd or None)
self._send(200, {"ok": True, "test_dir": td, "ref_dir": rd})
elif self.path == "/api/run":
cfg = {k: G.DEFAULTS.get(k) for k in G.DEFAULTS}
cfg.update({k: v for k, v in body.items() if k in G.DEFAULTS})
cfg["data_dir"] = G.find_data_dir()
cfg["ref_dir"] = _cfg().get("ref_dir", "")
ok, msg = start_sub("run", cfg)
self._send(200, {"ok": ok, "msg": msg})
elif self.path == "/api/align":
G.REF_DIR = _cfg().get("ref_dir", "") or None
dd = G.find_data_dir()
if not dd:
self._send(200, {"ok": False, "msg": "找不到数据目录"})
@@ -198,6 +231,14 @@ height:300px;overflow-y:auto;padding:12px;border-radius:6px;white-space:pre-wrap
.chk{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--txt)}
.sec-h{font-size:12px;color:var(--sub);margin:10px 0 6px;font-weight:bold}
.err{color:var(--warn)}
.dblab{display:inline-block;width:84px;text-align:center;border-radius:4px;
padding:2px 0;font-size:12px;color:#fff;flex:none}
.dblab.ref{background:#646a73}.dblab.test{background:var(--pri)}
.dbin{flex:1;min-width:260px}
.dbname{font:12px Consolas,monospace}
.badge{font-size:12px;padding:1px 8px;border-radius:10px;flex:none}
.badge.ok{color:var(--ok);background:#eaf6e8}
.badge.no{color:var(--sub);background:#eef0f3}
@media(max-width:860px){.grid{grid-template-columns:repeat(2,1fr)}}
</style></head><body>
<h1>testdata · 测试数据生成器</h1>
@@ -205,11 +246,20 @@ height:300px;overflow-y:auto;padding:12px;border-radius:6px;white-space:pre-wrap
history-test.db / session-test.db(首次自动从真实库克隆底子),<b>真实库零污染</b>——
对接软件时把测试库改名换上即可;换到别的母体后点一次「版本对齐」,删除只是兜底手段。</div>
<div class="card"><h2>数据目录</h2>
<div class="card"><h2>数据库</h2>
<div class="row" style="margin-top:0">
<span class="dblab ref">参考数据库</span>
<input type="text" id="refdir" class="dbin" placeholder="留空 = 与测试库同目录">
<button class="gray" onclick="saveDir('ref')">保存</button>
<span id="refok" class="badge"></span><span id="refmsg" class="sub"></span></div>
<div class="row">
<input type="text" id="dd" placeholder="自动探测……">
<button class="gray" onclick="saveDir()">保存</button>
<span id="ddmsg" class="sub"></span></div></div>
<span class="dblab test">测试数据库</span>
<input type="text" id="testdir" class="dbin" placeholder="自动探测……">
<button class="gray" onclick="saveDir('test')">保存</button>
<span id="testok" class="badge"></span><span id="testmsg" class="sub"></span></div>
<div class="sub" style="margin-top:8px">生成只写<b>测试数据库</b>(history-test.db / session-test.db,
附件也落这个目录,对接软件时整个目录拿走换名即可);<b>参考数据库</b>(history.db / session.db)
只读,仅作克隆底子。两框均可直接粘贴目录或 .db 文件路径(自动取其目录)。</div></div>
<div class="card"><h2>一、后台数据(history-test.db)</h2>
<div class="sec-h">入库项目</div>
@@ -293,11 +343,25 @@ async function doStop(){await post("/api/stop",{});}
async function doDel(){if(!confirm("确认真删除全部「测试」前缀的模拟数据?此操作不可恢复!"))return;
await post("/api/delete",{});poll();}
async function doAlign(){const r=await post("/api/align",{});alert(r.msg||"完成");}
async function saveDir(){const r=await post("/api/dir",{data_dir:document.getElementById("dd").value});
document.getElementById("ddmsg").textContent=r.ok?"已保存":(r.msg||"失败");loadStats();}
async function saveDir(which){
const b={};
if(which==="ref")b.ref_dir=document.getElementById("refdir").value;
else b.test_dir=document.getElementById("testdir").value;
const r=await post("/api/dir",b);
const m=document.getElementById(which+"msg");
if(m)m.textContent=r.ok?"已保存":(r.msg||"失败");
loadStats();}
function kpi(t,v,cls){return '<div class="kpi">'+t+' <b'+(cls?' class="'+cls+'"':'')+'>'+v+'</b></div>';}
async function loadStats(){const s=await(await fetch("/api/stats")).json();
if(s.data_dir)document.getElementById("dd").value=s.data_dir;
const rf=document.getElementById("refdir"),tf=document.getElementById("testdir");
if(document.activeElement!==rf)rf.value=s.ref_dir||"";
if(document.activeElement!==tf)tf.value=s.test_dir||s.data_dir||"";
const ro=(s.ref_ok||[]).length?s.ref_ok.every(x=>x):false;
const re=document.getElementById("refok");
re.textContent=ro?"在":"缺";re.className="badge "+(ro?"ok":"no");
const to=(s.test_ok||[]).length?s.test_ok.every(x=>x):false;
const te=document.getElementById("testok");
te.textContent=to?"已生成":"尚未生成";te.className="badge "+(to?"ok":"no");
let h="";
h+=kpi("后台项目",s.b_project??0);h+=kpi("市场价",s.b_market??0);h+=kpi("信息价",s.b_info??0);
h+=kpi("清单",s.bills??0);h+=kpi("定额",s.norms??0);h+=kpi("定额消耗",s.norm_res??0);