51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
"""D04 예정노선 확정 메일 — 업체에 그 연도 노선 묶음(zip)을 첨부해 보낸다 (요구 349-9)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import html
|
|
|
|
from common_util.common_util_email import Attachment, send_email
|
|
|
|
|
|
def build_completion_mail(
|
|
*,
|
|
project_name: str,
|
|
region: str | None,
|
|
year: int,
|
|
length_m: float,
|
|
recipient: str,
|
|
attachment_names: list[str],
|
|
) -> tuple[str, str]:
|
|
"""(제목, HTML 본문) — 프로젝트명 · 연도 · 연장 · 첨부 목록."""
|
|
esc = html.escape
|
|
rows = [
|
|
("프로젝트", project_name),
|
|
("사업 지역", region or "-"),
|
|
("연도", f"{year}년"),
|
|
("연장", f"{length_m / 1000:,.3f} km ({length_m:,.1f} m)"),
|
|
]
|
|
table = "".join(
|
|
f"<tr><td style='padding:4px 12px 4px 0;color:#6b7280'>{esc(k)}</td>"
|
|
f"<td style='padding:4px 0'><strong>{esc(v)}</strong></td></tr>"
|
|
for k, v in rows
|
|
)
|
|
files = "".join(f"<li>{esc(name)}</li>" for name in attachment_names)
|
|
body = f"""<!doctype html>
|
|
<html lang="ko"><head><meta charset="utf-8"></head>
|
|
<body style="font-family:'Segoe UI',Arial,sans-serif;color:#111827;line-height:1.6">
|
|
<p>안녕하세요, <strong>{esc(recipient)}</strong> 담당자님.</p>
|
|
<p>예정노선이 확정되어 {year}년 노선 파일을 보내 드립니다.</p>
|
|
<table>{table}</table>
|
|
<p>첨부 파일</p>
|
|
<ul>{files}</ul>
|
|
<p>압축을 풀면 shapefile(.shp · .shx · .dbf · .prj · .cpg · 좌표계 UTM-K)이 들어 있으며,
|
|
임도 설계 프로그램의 노선 입력에 그대로 올릴 수 있습니다.</p>
|
|
</body></html>"""
|
|
return f"[예정노선 확정] {project_name} {year}년", body
|
|
|
|
|
|
async def send_completion_mail(
|
|
*, to_email: str, subject: str, body: str, attachments: list[Attachment]
|
|
) -> bool:
|
|
return await send_email(to_email=to_email, subject=subject, html=body, attachments=attachments)
|