feat(testdata): 参考库/测试库目录分离+双输入框手动粘贴;修 lme_lib 同 code 撞唯一约束

This commit is contained in:
lianjianwei2024
2026-10-09 21:51:32 +08:00
parent eee1fe9029
commit 9cced06c19
2 changed files with 7 additions and 1 deletions

2
.gitignore vendored
View File

@@ -11,6 +11,8 @@ node_modules/
/release/*
# testdata 测试数据生成器是源码,必须入库(2026-10-09 差点因未跟踪丢失)
!/release/testdata/
# 运行时配置(存本机数据目录路径),不入库
/release/testdata/config.json
# ===== 数据 / 样本 / 生成物:不入库 =====

View File

@@ -761,7 +761,11 @@ def build_project_data(rng, cfg, words, m_idx, bid_local=True):
# 每条清单的定额 + 每条定额的工料机
nrm_lo, nrm_hi = int(cfg["norm_lo"]), max(int(cfg["norm_lo"]), int(cfg["norm_hi"]))
res_lo, res_hi = int(cfg["res_lo"]), max(int(cfg["res_lo"]), int(cfg["res_hi"]))
lme_pool = rng.sample(words.lmes, min(len(words.lmes), rng.randint(260, 520)))
_u = {} # 真实库同 code 跨批次重复,lme_lib 有
for it in words.lmes: # (batch_id, code) 唯一约束 → 先去重再抽样
_u.setdefault(it[0], it)
_uniq = list(_u.values())
lme_pool = rng.sample(_uniq, min(len(_uniq), rng.randint(260, 520)))
lme_by_kind = {1: [], 2: [], 3: []}
for it in lme_pool:
lme_by_kind.setdefault(it[4] or 2, []).append(it)