diff --git a/CostReview/app/core/export_cos.py b/CostReview/app/core/export_cos.py index 2760015..13700e3 100644 --- a/CostReview/app/core/export_cos.py +++ b/CostReview/app/core/export_cos.py @@ -1586,6 +1586,11 @@ def _summary_node(fields, template=None, children_html="", org=None): for k in ("PriceSource", "Delivery", "Location", "ProducingArea", "Supplier", "Character", "Remark"): tag = _attr_set_has(tag, k, "") + # 决策 316 补记十一:调价式两槽(NoTaxPriceExpress/TaxPriceExpress)同属六价、按本行 + # 数据——added 行 9 列不带调价式 → 模板残留的算式(实测串成别码 3.70/4.35)必须清空, + # 不得吃模板残留(2026-10-23「残留清空」同口径)。 + for k in ("NoTaxPriceExpress", "TaxPriceExpress"): + tag = _attr_set_has(tag, k, "") # 决策 204 补:模板残留的**合计结果值**不背给采纳行(四 Total 槽位照保、占位 0); # 现算写回通道(_apply_qty_updates)随后按真锚价回填 NoTaxOrgTotal/TaxOrgTotal。 for k in ("NoTaxOrgTotal", "NoTaxTotal", "TaxOrgTotal", "TaxTotal"): diff --git a/CostReview/app/server/adopt_api.py b/CostReview/app/server/adopt_api.py index 32713d8..cf4ba49 100644 --- a/CostReview/app/server/adopt_api.py +++ b/CostReview/app/server/adopt_api.py @@ -1578,8 +1578,19 @@ def _chain_survey_repair(sc, sid, hc=None): (sid,)): problems.append({"kind": "same_code_diff_lme", "code": r["code"]}) _scope = "session:%d" % sid + # 决策 321(2026-11-13 覆盖矩阵实测抓到):勘察清单**重建时保留非勘察条目**——拆码不猜登记 + # (code_identity._migrate_pack 写的「拆码 XX→XX:N 条源件上级边无单位归属」字符串条目) + # 写在前、勘察重建在后,直接覆盖=登记被抹(不猜失去留痕)。勘察只 OWN 两类结构化条目, + # 其余条目原样保留排在最前。 + _old_row = sc.execute("SELECT v FROM s_settings WHERE scope=? AND k='chain_problems'", + (_scope,)).fetchone() + try: + _kept = [e for e in (json.loads(_old_row[0] or "[]") if _old_row else []) + if not (isinstance(e, dict) and e.get("kind") in ("missing_source", "same_code_diff_lme"))] + except Exception: + _kept = [] sc.execute("INSERT INTO s_settings(scope,k,v) VALUES(?,?,?) ON CONFLICT(scope,k) DO UPDATE SET v=excluded.v", - (_scope, "chain_problems", json.dumps(problems, ensure_ascii=False))) + (_scope, "chain_problems", json.dumps(_kept + problems, ensure_ascii=False))) sc.execute("INSERT INTO s_settings(scope,k,v) VALUES(?,?,?) ON CONFLICT(scope,k) DO UPDATE SET v=excluded.v", (_scope, "chain_repair_log", json.dumps(repaired, ensure_ascii=False))) return {"repaired": len(repaired), "problems": len(problems)} diff --git a/CostReview/app/server/api_server.py b/CostReview/app/server/api_server.py index c84f622..db43be6 100644 --- a/CostReview/app/server/api_server.py +++ b/CostReview/app/server/api_server.py @@ -4078,6 +4078,10 @@ def _export_session(sc, sid, fmt="", progress=None): # 决策 244 补记三:现算链故障的单位标记 _live_ok=False → 导出 0 量判定退老行为(不误删全部) for plan in unit_plans.values(): plan["added_lme"] = [] + # 决策 321:拆码登记簿提前装载(映射源注入的改印防重判定要在建计划期间用; + # 4286 处的正式装载不动,两处读同一份 s_settings) + _ri_early = _setting_get("session:%d" % sid, "recode_ident") + recode_ident_early = json.loads(_ri_early) if _ri_early else {} for uw_id, uwkey in uwmap.items(): plan = unit_plans.get(uwkey) if not plan: @@ -4120,8 +4124,16 @@ def _export_session(sc, sid, fmt="", progress=None): # 决策 288 补记二(导出指纹轮间漂移根因):set 迭代序随进程哈希种子逐轮变 → # 映射源注入行 append 序漂 → 汇总再生区行序漂。固定按码升序(注入行源本无序, # 只取确定序、不动行集);.sorted 保证跨进程稳定。 - _refs = sorted({r[0] for r in sc.execute("""SELECT DISTINCT res_code FROM s_lme_res - WHERE session_id=? AND res_code IS NOT NULL""", (sid,))}) + _refs = {r[0] for r in sc.execute("""SELECT DISTINCT res_code FROM s_lme_res + WHERE session_id=? AND res_code IS NOT NULL""", (sid,))} + # 决策 316 补记十一(2026-11-13 主人拍板「原地补全→导出放行」):**定额耗引用码一并纳入** + # ——补全/勘察补的源行引用地=定额耗(s_norm_res),此前只扫组成引用(s_lme_res)会漏; + # 注入判据照 186 不变(源文本没有该节点且库 uw/proj 有行→注入),无源的仍不造占位(304补七)。 + _refs |= {r[0] for r in sc.execute( + """SELECT DISTINCT nr.res_code FROM s_norm_res nr + JOIN s_norms n ON n.id=nr.norm_id JOIN s_bills b ON b.id=n.bill_id + WHERE b.session_id=? AND b.uw_id=? AND nr.res_code IS NOT NULL AND nr.res_code<>''""", + (sid, uw_id))} _src_txt = _uw_src_text.get(uwkey) if _lme_untouched: _refs = () # 决策 274 补记四:无动作会话映射源不注入(源件缺失行保持缺失=源样) @@ -4131,12 +4143,28 @@ def _export_session(sc, sid, fmt="", progress=None): _u = sc.execute("""SELECT code, name, spec, unit, qty, taxrate, ntp, taxp, kind FROM s_lme_uw WHERE session_id=? AND uw_id=? AND code=?""", (sid, uw_id, rc)).fetchone() - _p = sc.execute("""SELECT code, name, spec, unit, qty, taxrate, ntp, taxp, kind - FROM s_lme_proj WHERE session_id=? AND code=?""", (sid, rc)).fetchone() _src_has = (_src_txt is not None and (' - + + +