Merge branch 'sub_laptop_2' of C:/Aislo_wt/sub_laptop_2 into main_laptop_1
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
위 층 고침(`수식.위덮음`)으로 — {단가 기호: {작업량: {식: 우리 작업량 식 키, 변수: {우리 열쇠: 경쟁사 값}}}}.
|
||||
방식은 싣지 않음(방식 없음 = 위 층 방식 → 처음은 경쟁사 식 그대로 「문서 식」 · 사용자가 「시간당 식」 을
|
||||
고르는 순간 경쟁사 값에서 시작 · [원래 값] = 경쟁사 값).
|
||||
짝 = 경쟁사 Q 식 모양 → 우리 식 변수(굴착기 8-2-3 `3600·q·K·f·E/Cm` · 덤프 8-2-8 단일 구간) ·
|
||||
짝 = 경쟁사 Q 식 모양 → 우리 식 변수(굴착기 8-2-3 `3600·q·K·f·E/Cm` · 덤프 8-2-8 구간 셋까지 · 851-2 = 불도저 8-2-1 ·
|
||||
로더 8-2-5 · 롤러 8-2-9 · 콘크리트 믹서 8-2-17 · 표 밖 값 = 851-1 「직접」 칸) ·
|
||||
실은 값으로 우리 식을 셈한 Q 가 경쟁사 Q 와 같은(끝자리 안) 줄만 실음 — 다르면 안 실음(`why` = 줄마다 까닭).
|
||||
경쟁사 자료(단가 · 품목)를 우리 마스터로 옮기지 않음(그 공사의 조건 값을 그 단가산출에만).
|
||||
"""
|
||||
@@ -22,6 +23,12 @@ from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
|
||||
md, mc, mw, mcv = dc.md, dc.mc, dc.mc.mw, dc.mc.mcv
|
||||
EXC, DUMP = "GC001147", "GC001155" # 굴착기 8-2-3 · 덤프트럭 8-2-8 작업량 식
|
||||
_SECT = (
|
||||
("운반거리", "도로상태", "V1입력", "V2입력"),
|
||||
("구간2거리", "구간2도로상태", "V3입력", "V4입력"),
|
||||
("구간3거리", "구간3도로상태", "V5입력", "V6입력"),
|
||||
) # 덤프 운반 구간 칸(851-1)
|
||||
_ALT = "_딴길" # 후보 속 둘째 길 — 첫 길로 Q 가 어긋날 때 덮어 볼 칸
|
||||
_EXC = {"q": "버킷용량", "qs": "버킷용량", "qo": "버킷용량", "k": "K입력", "f": "f", "e": "E입력",
|
||||
"es": "E입력", "cm": "싸이클입력", "cms": "싸이클입력"} # fmt: skip
|
||||
_RANGE = {
|
||||
@@ -91,15 +98,51 @@ def _excavator(d: _Doc, fs: list) -> dict:
|
||||
return out
|
||||
|
||||
|
||||
def _cut(d: _Doc, node) -> bool:
|
||||
"""변수 정의가 끝수(반올림 · 버림 · 올림 + 자리)로 싸였나."""
|
||||
text = d.defs.get(node[1]) if node[0] == "var" else None
|
||||
try:
|
||||
return text is not None and _inner(md.parse(text))[1] is not None
|
||||
except md.DocError:
|
||||
return False
|
||||
|
||||
|
||||
def _sum_terms(node) -> list:
|
||||
if node[0] == "bin" and node[1] == "+":
|
||||
return [*_sum_terms(node[2]), *_sum_terms(node[3])]
|
||||
return [node]
|
||||
|
||||
|
||||
def _legs(d: _Doc, tree) -> list[tuple]:
|
||||
"""t2 → 구간 [(거리 ㎞, 적재 속도, 공차 속도)] — (Σ l ÷ V) × 60 · × 2 = 같은 속도 왕복 · ÷ 1000 = m · 구간 셋까지."""
|
||||
k, rest = Decimal(1), []
|
||||
for s, n in mw._factors(tree) if tree is not None else []:
|
||||
if n[0] == "num":
|
||||
k = k * n[1] if s > 0 else k / n[1]
|
||||
else:
|
||||
rest.append((s, n))
|
||||
metre = k in (Decimal("0.06"), Decimal("0.12"))
|
||||
k = k * 1000 if metre else k
|
||||
if len(rest) != 1 or rest[0][0] < 0 or k not in (60, 120):
|
||||
raise _No("t2 = (Σ l ÷ V) × 60 꼴 아님")
|
||||
terms = [mw._factors(x) for x in _sum_terms(rest[0][1])]
|
||||
if any([s for s, _ in x] != [1, -1] for x in terms):
|
||||
raise _No("t2 항 l ÷ V 꼴 아님")
|
||||
if k == 120:
|
||||
legs = [(x[0][1], x[1][1], x[1][1]) for x in terms]
|
||||
elif len(terms) % 2 or any(a[0][1] != b[0][1] for a, b in zip(terms[::2], terms[1::2])):
|
||||
raise _No("t2 구간 거리 짝 안 맞음")
|
||||
else:
|
||||
legs = [(a[0][1], a[1][1], b[1][1]) for a, b in zip(terms[::2], terms[1::2])]
|
||||
if not 1 <= len(legs) <= len(_SECT):
|
||||
raise _No(f"t2 구간 {len(legs)} — 우리 칸 {len(_SECT)}")
|
||||
return [(d.value(x) / (1000 if metre else 1), d.value(a), d.value(b)) for x, a, b in legs]
|
||||
|
||||
|
||||
def _dump(d: _Doc, fs: list, tpl: dict) -> dict:
|
||||
"""60·q·f·E/Cm(덤프 8-2-8) — q = T ÷ rt × L(L 없음 = 1) · Cm = t1 + t2 + t3 + t4(+ t5 덮개 + t6 세륜) ·
|
||||
t1 = cms·n ÷ (60·Es) · n = q ÷ (버킷 × k) · t2 = (l ÷ V1 + l ÷ V2) × 60(단일 구간 · ÷ 1000 = m) → 우리 입력 · 고르기."""
|
||||
t1 = cms·n ÷ (60·Es) · n = q ÷ (버킷 × k) · t2 = 구간 셋까지(`_legs` · 표 밖 속도 = 속도 직접) · 못 읽는 t2 =
|
||||
왕복시간 직접 · t3 · t4 · t5 표 밖 = 직접 칸(851-1) → 우리 입력 · 고르기."""
|
||||
if [(s, n) for s, n in fs if n[0] == "num"] != [(1, ("num", Decimal(60)))]:
|
||||
raise _No("60 꼴 아님")
|
||||
up = [n for s, n in fs if s > 0 and n[0] == "var"]
|
||||
@@ -128,9 +171,12 @@ def _dump(d: _Doc, fs: list, tpl: dict) -> dict:
|
||||
if set(ts) - {"5", "6"} != {"1", "2", "3", "4"}:
|
||||
raise _No("Cm = t1 + t2 + t3 + t4 꼴 아님")
|
||||
if "5" in ts and (t5 := d.value(ts["5"])) != 0:
|
||||
out["덮개"] = _option(tpl, "덮개", lambda r: Decimal(str(r.get("시간"))) == t5, "t5")
|
||||
try:
|
||||
out["덮개"] = _option(tpl, "덮개", lambda r: Decimal(str(r.get("시간"))) == t5, "t5")
|
||||
except _No:
|
||||
out["t5입력"] = t5
|
||||
if "6" in ts and (t6 := d.value(ts["6"])) != 0:
|
||||
if not _row(tpl, "T_시간4^표", {}, t6):
|
||||
if not _row(tpl, "CC000058", {}, t6): # 세륜기 통과시간(t6)
|
||||
raise _No(f"t6 {t6} 표에 없음")
|
||||
out["세륜"] = "함"
|
||||
t1 = d.tree(ts["1"][1])
|
||||
@@ -147,26 +193,39 @@ def _dump(d: _Doc, fs: list, tpl: dict) -> dict:
|
||||
raise _No("n = q ÷ (버킷 × k) 꼴 아님")
|
||||
bk = sorted(nf[1:], key=lambda x: x[1][0] == "var" and _role(x[1][1]) == "k") # 버킷 › k
|
||||
out |= {"적재싸이클": d.value(cms), "적재효율": d.value(es), "적재버킷": d.value(bk[0][1]), "버킷계수": d.value(bk[1][1])} # fmt: skip
|
||||
t2 = d.tree(ts["2"][1])
|
||||
f2 = mw._factors(t2) if t2 is not None else []
|
||||
metre = (-1, ("num", Decimal(1000))) in f2 # 거리 m(÷ 1000)
|
||||
f2 = [x for x in f2 if x != (-1, ("num", Decimal(1000)))]
|
||||
legs = [mw._factors(x) for x in _sum_terms(f2[0][1])] if len(f2) == 2 and f2[1] == (1, ("num", Decimal(60))) else [] # fmt: skip
|
||||
if (
|
||||
len(legs) != 2
|
||||
or any([s for s, _ in x] != [1, -1] for x in legs)
|
||||
or legs[0][0][1] != legs[1][0][1]
|
||||
):
|
||||
raise _No("t2 단일 구간 (l ÷ V1 + l ÷ V2) × 60 꼴 아님")
|
||||
out["운반거리"] = d.value(legs[0][0][1]) / (1000 if metre else 1)
|
||||
speeds = sorted(d.value(x[1][1]) for x in legs)
|
||||
out["도로상태"] = _option(tpl, "도로상태", lambda r: sorted(Decimal(str(r[k])) for k in ("적재", "공차")) == speeds) # fmt: skip
|
||||
try: # t2 = 구간(거리 · 적재 · 공차 속도) — 표 속도 쌍이면 도로상태 · 아니면 속도 직접(851-1)
|
||||
for (dist, v1, v2), (kd, kr, k1, k2) in zip(_legs(d, d.tree(ts["2"][1])), _SECT):
|
||||
if dist == 0 and kd != _SECT[0][0]:
|
||||
continue # 거리 0 구간 = 안 씀(칸 안 채움)
|
||||
out[kd] = dist
|
||||
try:
|
||||
out[kr] = _option(tpl, "도로상태", lambda r: sorted(Decimal(str(r[k])) for k in ("적재", "공차")) == sorted((v1, v2))) # fmt: skip
|
||||
except _No:
|
||||
out[k1], out[k2] = v1, v2
|
||||
# t2 끝수(반올림 · 버림) = 딴길 t2 통째
|
||||
alt = {"t2입력": d.value(ts["2"])} if _cut(d, ts["2"]) else {}
|
||||
except _No:
|
||||
out["t2입력"] = d.value(ts["2"]) # t2 를 수로 적음 · 꼴 다름 = 왕복시간 직접
|
||||
alt = {}
|
||||
t3, t4 = d.value(ts["3"]), d.value(ts["4"])
|
||||
soil = next(((s, c) for s in _options(tpl, "적하토질") for c in _options(tpl, "적하조건") if _row(tpl, "t3", {"S_적하토질": s, "S_적하조건": c}, t3)), None) # fmt: skip
|
||||
if soil is None:
|
||||
raise _No(f"t3 {t3} 표에 없음")
|
||||
out["적하토질"], out["적하조건"] = soil
|
||||
out["적재장소"] = _option(tpl, "적재장소", lambda r: Decimal(str(r.get("시간"))) == t4, "t4")
|
||||
soil = next(((s, c) for s in _options(tpl, "적하토질") for c in _options(tpl, "적하조건") if _row(tpl, "CC000055", {"S_적하토질": s, "S_적하조건": c}, t3)), None) # fmt: skip
|
||||
if soil is not None:
|
||||
out["적하토질"], out["적하조건"] = soil
|
||||
else:
|
||||
out["t3입력"] = t3 # 표 밖 = 적하시간 직접
|
||||
try:
|
||||
out["적재장소"] = _option(
|
||||
tpl, "적재장소", lambda r: Decimal(str(r.get("시간"))) == t4, "t4"
|
||||
)
|
||||
except _No:
|
||||
out["t4입력"] = t4
|
||||
if _cut(d, ts["1"]): # t1 끝수 = 딴길 적재시간 직접(적재방법 「직접 입력」)
|
||||
alt |= {"적재방법": "직접 입력", "적재시간입력": d.value(ts["1"])}
|
||||
if alt: # 딴길 = 끝수 낸 t1 · t2 를 경쟁사 값 통째로(t2 통째면 구간 · 속도 칸 뺌)
|
||||
drop = "t2입력" in alt
|
||||
out[_ALT] = {
|
||||
k: v for k, v in out.items() if not (drop and any(k in x for x in _SECT))
|
||||
} | alt
|
||||
return out
|
||||
|
||||
|
||||
@@ -175,9 +234,9 @@ def _options(tpl: dict, key: str) -> list:
|
||||
return list((v.get("연결") or {}).get("목록") or [])
|
||||
|
||||
|
||||
def _table(tpl: dict, key: str) -> tuple[dict, dict]:
|
||||
"""표 변수 열쇠 → (표 연결, 그 표)."""
|
||||
v = next((x for x in tpl.get("변수") or [] if x.get("열쇠") == key), {})
|
||||
def _table(tpl: dict, ref: str) -> tuple[dict, dict]:
|
||||
"""표 번호(CC…) → (표 연결, 그 표) — 그 표를 찾는 첫 변수(직접 칸 막이로 변수 열쇠가 바뀌어도)."""
|
||||
v = next((x for x in tpl.get("변수") or [] if (x.get("연결") or {}).get("표") == ref), {})
|
||||
link = v.get("연결") or {}
|
||||
return link, dc.skc.whole_().get(str(link.get("표")))
|
||||
|
||||
@@ -207,17 +266,139 @@ def _option(tpl: dict, key: str, test, label: str = "") -> str:
|
||||
raise _No(f"{label or key} 표에 없음")
|
||||
|
||||
|
||||
MAP = {EXC: lambda d, fs, tpl: _excavator(d, fs), DUMP: _dump}
|
||||
def _top(fs: list, head: int, ups: int) -> tuple[list, list]:
|
||||
"""Q 인수 → (위 변수, 아래 변수) — 수는 머리 수(60 · 1000 · 3600) 하나 · 아래 변수 하나."""
|
||||
if [(s, n) for s, n in fs if n[0] == "num"] != [(1, ("num", Decimal(head)))]:
|
||||
raise _No(f"{head} 꼴 아님")
|
||||
up = [n for s, n in fs if s > 0 and n[0] == "var"]
|
||||
down = [n for s, n in fs if s < 0]
|
||||
if len(up) != ups or len(down) != 1 or down[0][0] != "var":
|
||||
raise _No("Q 꼴 아님")
|
||||
return up, down
|
||||
|
||||
|
||||
def _by_role(d: _Doc, nodes: list, roles: dict) -> dict:
|
||||
"""변수 마디 → {우리 열쇠: 값} — 이름 머리(밑줄 · 수 뗌 · 작은 글자)로 · 겹치거나 모르면 못 실음."""
|
||||
out: dict[str, Any] = {}
|
||||
for n in nodes:
|
||||
k = roles.get(_role(n[1]))
|
||||
if k is None or k in out:
|
||||
raise _No(f"변수 이름 낯섦({md.text_of(n)})")
|
||||
out[k] = d.value(n)
|
||||
return out
|
||||
|
||||
|
||||
def _const(ref: str, head: str) -> Decimal:
|
||||
"""산정식 상수 표(ref) 「항목」 이 head 로 시작하는 줄 값."""
|
||||
rows = (dc.skc.whole_().get(ref) or {}).get("줄") or []
|
||||
return next(Decimal(str(r["값"])) for r in rows if str(r.get("항목") or "").startswith(head))
|
||||
|
||||
|
||||
def _dozer(d: _Doc, fs: list, tpl: dict) -> dict:
|
||||
"""불도저 8-2-1 — 60·q·f·E/Cm · q = q° × e(수 하나 · 끝수 = q° 직접 · e 1) · Cm = L ÷ V1 + L ÷ V2 + t(표)."""
|
||||
up, down = _top(fs, 60, 3)
|
||||
load = next((n for n in up if _role(n[1]) not in ("f", "e", "es")), None)
|
||||
out = _by_role(d, [n for n in up if n is not load], {"f": "f", "e": "E입력", "es": "E입력"})
|
||||
if len(out) != 2 or load is None:
|
||||
raise _No("q · f · E 못 가림")
|
||||
text = d.defs.get(load[1])
|
||||
tree, places = _inner(md.parse(text)) if text else (None, None)
|
||||
qf = mw._factors(tree) if tree is not None else []
|
||||
if places is None and [s for s, _ in qf] == [1, 1]:
|
||||
out["q0입력"], out["e입력"] = d.value(qf[0][1]), d.value(qf[1][1])
|
||||
else:
|
||||
out["q0입력"], out["e입력"] = d.value(load), Decimal(1)
|
||||
cm = d.tree(down[0][1])
|
||||
legs, rest = [], []
|
||||
for x in _sum_terms(cm) if cm is not None else []:
|
||||
f2 = mw._factors(x)
|
||||
if [s for s, _ in f2] == [1, -1]:
|
||||
legs.append(f2)
|
||||
else:
|
||||
rest.append(x)
|
||||
if len(legs) != 2 or len(rest) != 1 or legs[0][0][1] != legs[1][0][1]:
|
||||
raise _No("Cm = L ÷ V1 + L ÷ V2 + t 꼴 아님")
|
||||
if (t := d.value(rest[0])) != _const("CC000039", "기어 변속시간"):
|
||||
raise _No(f"기어 변속시간 t {t} 표 밖")
|
||||
out |= {"운반거리": d.value(legs[0][0][1]), "V1입력": d.value(legs[0][1][1]), "V2입력": d.value(legs[1][1][1])} # fmt: skip
|
||||
return out
|
||||
|
||||
|
||||
def _loader(d: _Doc, fs: list, tpl: dict) -> dict:
|
||||
"""로더 8-2-5 — 3600·q·K·f·E/Cm · Cm = m × l + t1 + t2(표 14 초) → 버킷용량 · K · f · E · m · 주행거리 · t1 직접."""
|
||||
up, down = _top(fs, 3600, 4)
|
||||
roles = {"q": "버킷용량", "qs": "버킷용량", "qo": "버킷용량", "k": "K입력", "f": "f", "e": "E입력", "es": "E입력"} # fmt: skip
|
||||
out = _by_role(d, up, roles)
|
||||
cm = d.tree(down[0][1])
|
||||
terms = _sum_terms(cm) if cm is not None else []
|
||||
prod = [x for x in terms if [s for s, _ in mw._factors(x)] == [1, 1]]
|
||||
rest = [x for x in terms if not any(x is y for y in prod)]
|
||||
if len(out) != 4 or len(prod) != 1 or len(rest) != 2:
|
||||
raise _No("Cm = m × l + t1 + t2 꼴 아님")
|
||||
(_, m), (_, ln) = mw._factors(prod[0])
|
||||
t1, t2 = sorted(rest, key=lambda x: x[0] == "var" and x[1].lower().startswith("t2"))
|
||||
if (v := d.value(t2)) != _const("CC000052", "기본시간"):
|
||||
raise _No(f"기본시간 t2 {v} 표 밖")
|
||||
return out | {"m입력": d.value(m), "주행거리": d.value(ln), "t1입력": d.value(t1)}
|
||||
|
||||
|
||||
def _roller(volume: bool):
|
||||
"""롤러 8-2-9 — 1000·V·W(·D·f)·E/N → 다짐속도 · 유효폭 직접 · E · (두께 · f) · 다짐횟수."""
|
||||
|
||||
def parse(d: _Doc, fs: list, tpl: dict) -> dict:
|
||||
if not volume: # 면적 식에 f = 1 을 곱해 둔 꼴(값 같음) — f 뗌
|
||||
fs = [
|
||||
(s, n)
|
||||
for s, n in fs
|
||||
if not (n[0] == "var" and _role(n[1]) == "f" and d.value(n) == 1)
|
||||
]
|
||||
up, down = _top(fs, 1000, 5 if volume else 3)
|
||||
roles = {
|
||||
"v": "V입력",
|
||||
"w": "W입력",
|
||||
"e": "E입력",
|
||||
**({"d": "두께", "f": "f"} if volume else {}),
|
||||
}
|
||||
out = _by_role(d, up, roles)
|
||||
if _role(down[0][1]) != "n":
|
||||
raise _No("다짐횟수 N 아님")
|
||||
return out | {"다짐횟수": d.value(down[0])}
|
||||
|
||||
return parse
|
||||
|
||||
|
||||
def _mixer(d: _Doc, fs: list, tpl: dict) -> dict:
|
||||
"""콘크리트 믹서 8-2-17 — 60 ÷ t × q × E(t = 표 작업시간) → 믹서용량 · E."""
|
||||
if [(s, n) for s, n in fs if n[0] == "num" and s > 0] != [(1, ("num", Decimal(60)))]:
|
||||
raise _No("60 꼴 아님")
|
||||
up = [n for s, n in fs if s > 0 and n[0] == "var"]
|
||||
down = [n for s, n in fs if s < 0]
|
||||
if len(up) != 2 or len(down) != 1:
|
||||
raise _No("Q 꼴 아님")
|
||||
if (t := d.value(down[0])) != _const("CC000388", "재료투입"):
|
||||
raise _No(f"작업시간 t {t} 표 밖")
|
||||
return _by_role(d, up, {"q": "믹서용량", "e": "E입력"})
|
||||
|
||||
|
||||
MAP = {
|
||||
EXC: lambda d, fs, tpl: _excavator(d, fs),
|
||||
DUMP: _dump,
|
||||
"GC001144": _dozer,
|
||||
"GC001150": _loader,
|
||||
"GC001157": _roller(True),
|
||||
"GC001158": _roller(False),
|
||||
"GC001170": _mixer,
|
||||
} # 경쟁사 Q 식 모양 → 우리 작업량 식 변수(851-2 = 불도저 · 로더 · 롤러 · 믹서 · 덤프 구간 여럿)
|
||||
|
||||
|
||||
def _plain(v: Any) -> Any:
|
||||
return float(v) if isinstance(v, Decimal) else v
|
||||
|
||||
|
||||
def _candidates(doc: dict, ans: dict, links: Any) -> tuple[dict, dict, dict]:
|
||||
"""줄마다 (단가 기호 → 덮음 후보) · (기호 → 경쟁사 Q · 끝자리) · 까닭."""
|
||||
def _candidates(doc: dict, ans: dict, links: Any) -> tuple[dict, dict, dict, dict]:
|
||||
"""줄마다 (단가 기호 → 덮음 후보) · (기호 → 경쟁사 Q · 끝자리) · 까닭 · 딴길 변수."""
|
||||
d = _Doc(doc, ans.get("값") or {})
|
||||
cand, comp, why = {}, {}, {}
|
||||
cand, comp, why, alts = {}, {}, {}, {}
|
||||
for z in ans.get("줄") or []:
|
||||
w = z.get(mw.WORK) or {}
|
||||
sym = str(w.get("기호") or "")
|
||||
@@ -250,12 +431,34 @@ def _candidates(doc: dict, ans: dict, links: Any) -> tuple[dict, dict, dict]:
|
||||
why[sym] = f"{key} {k} {got[k]} 범위 밖"
|
||||
break
|
||||
else:
|
||||
if _ALT in got:
|
||||
alts[sym] = {k: _plain(v) for k, v in got.pop(_ALT).items()}
|
||||
cand[sym] = {mw.WORK: {"식": key, "변수": {k: _plain(v) for k, v in got.items()}}}
|
||||
tol = Decimal(1).scaleb(-int(places)) if places is not None else Decimal("0.001")
|
||||
comp[sym] = (w.get("값"), tol)
|
||||
why.pop(sym, None)
|
||||
break
|
||||
return cand, comp, why
|
||||
return cand, comp, why, alts
|
||||
|
||||
|
||||
def _check(mine: dict, links: Any, cand: dict, comp: dict, why: dict) -> tuple[dict, list]:
|
||||
"""후보를 시간당 식으로 켜 셈 — (Q 가 경쟁사 Q 끝자리 안인 줄, 어긋난 줄) · 까닭 고침."""
|
||||
on = {k: {mw.WORK: {"방식": mw.HOURLY}} for k in cand}
|
||||
test = mc.calc(mine, links, cover=mcv.merge_layers(cand, on)) if cand else {}
|
||||
got, miss = {}, []
|
||||
for z in test.get("줄") or []:
|
||||
w = z.get(mw.WORK) or {}
|
||||
sym = str(w.get("기호") or "")
|
||||
if sym not in cand or w.get(mw.FOLLOW):
|
||||
continue
|
||||
q, (want, tol) = w.get("값"), comp[sym]
|
||||
if isinstance(q, Decimal) and isinstance(want, Decimal) and abs(q - want) <= tol:
|
||||
got[sym] = cand[sym]
|
||||
why.pop(sym, None)
|
||||
else:
|
||||
miss.append(sym)
|
||||
why[sym] = f"우리 식 Q {q} ≠ 경쟁사 Q {want}" + (f" — {w.get('까닭')}" if w.get("까닭") else "") # fmt: skip
|
||||
return got, miss
|
||||
|
||||
|
||||
def carried(doc: dict, whole: Any = None) -> tuple[dict, dict]:
|
||||
@@ -270,24 +473,13 @@ def carried(doc: dict, whole: Any = None) -> tuple[dict, dict]:
|
||||
mine = dim.view(bare, "엑셀")
|
||||
try:
|
||||
ans = mc.calc(mine, links)
|
||||
cand, comp, why = _candidates(mine, ans, links)
|
||||
on = {k: {mw.WORK: {"방식": mw.HOURLY}} for k in cand}
|
||||
test = mc.calc(mine, links, cover=mcv.merge_layers(cand, on)) if cand else {}
|
||||
cand, comp, why, alts = _candidates(mine, ans, links)
|
||||
got, miss = _check(mine, links, cand, comp, why)
|
||||
retry = {k: {mw.WORK: {**cand[k][mw.WORK], "변수": alts[k]}} for k in miss if k in alts}
|
||||
if retry: # 딴길(덤프 t2 통째) — 경쟁사 t2 끝수로 첫 길 Q 가 어긋난 줄
|
||||
got |= _check(mine, links, retry, comp, why)[0]
|
||||
except Exception as e: # noqa: BLE001 — 못 셈 = 층 없음(가져온 식 셈은 그대로)
|
||||
return {}, {"*": f"셈 틀림 — {e}"}
|
||||
got = {}
|
||||
for z in test.get("줄") or []:
|
||||
w = z.get(mw.WORK) or {}
|
||||
sym = str(w.get("기호") or "")
|
||||
if sym not in cand or w.get(mw.FOLLOW):
|
||||
continue
|
||||
q, (want, tol) = w.get("값"), comp[sym]
|
||||
if isinstance(q, Decimal) and isinstance(want, Decimal) and abs(q - want) <= tol:
|
||||
got[sym] = cand[sym]
|
||||
else:
|
||||
why[sym] = f"우리 식 Q {q} ≠ 경쟁사 Q {want}" + (
|
||||
f" — {w.get('까닭')}" if w.get("까닭") else ""
|
||||
)
|
||||
if len(_MEMO) > 512:
|
||||
_MEMO.clear()
|
||||
_MEMO[key] = (got, why)
|
||||
|
||||
Reference in New Issue
Block a user