Files
pricing_review/_inspect_real.py

64 lines
2.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""临时:真实件分部结构体检(决策 229 真实对拍前置,看完即删)。"""
import sys
sys.path.insert(0, r"D:\PricingReview\CostReview\app\core")
import import_job
FILES = [
r"D:\PricingReview\后台需要导入的项目\三溪科创小镇一期道路综合改造提升工程-华宇路汽车城段易达导出.COS",
r"D:\PricingReview\后台需要导入的项目\吉大街道园林花园老旧小区环境整治提升工程施工.cos4",
]
for fp in FILES:
out = {"uw": [], "bills": [], "norms": [], "lmes": [],
"cur_bill": -1, "cur_uw": -1, "bill_uw": [],
"bill_kind": [], "prelim_raw": 0,
"bill_raw": 0, "bill_skip": 0, "bill_skip_zero": 0,
"lme_raw": 0, "lme_skip": 0,
"proj_name": "", "file_kind": None, "bulid_unit": "", "total": None}
import_job.parse_file(fp, out)
divides = out.get("divides", [])
print("=" * 60)
print(fp.split("\\")[-1])
print("项目名:", out.get("proj_name"), "| 单位工程数:", len(out.get("uw", [])),
"| 清单数:", len(out.get("bills", [])), "| 分部数:", len(divides))
# 每单位工程:同名兄弟分部?同名不同深度?
from collections import Counter, defaultdict
name_depth = defaultdict(Counter)
sib_dup = 0
by_parent = defaultdict(Counter)
for d in divides:
nm = d.get("name") or ""
depth = 0
p = d.get("parent")
seen = set()
while p is not None and p not in seen:
seen.add(p)
pd = divides[p]
depth += 1
p = pd.get("parent")
name_depth[d.get("uw")][nm] += 1
by_parent[(d.get("uw"), d.get("parent"))][nm] += 1
for k, c in by_parent.items():
for nm, n in c.items():
if n > 1:
sib_dup += 1
print("同父同名分部组数:", sib_dup)
for uwi, c in enumerate(name_depth):
cc = name_depth.get(uwi)
multi = {k: v for k, v in (cc or {}).items() if v > 1}
if multi:
print(" uw%d 同名多处分部:" % uwi, dict(list(multi.items())[:5]))
kinds = Counter()
for d in divides:
kinds[d.get("kind")] += 1
print("分部 kind 分布:", dict(kinds))
# 清单归属:bill_div 为 None 的 item 清单数
orphan = sum(1 for i, k in enumerate(out.get("bill_kind", []))
if k != "prelim" and out["bill_div"][i] is None)
print("无分部归属的 item 清单:", orphan,
"| 措施清单:", sum(1 for k in out.get("bill_kind", []) if k == "prelim"))
# 分部字段样例
if divides:
print("分部字段样例:", {k: v for k, v in divides[0].items()})