Files
ONE-OS/scripts/image_to_excel_cylinder_log.py
王冕 a27e3b8e43 feat: sync full workspace including web modules, docs, and configurations to Gitea
Optimized the root .gitignore to exclude virtual environments, node modules,
and temp folders to ensure clean and lightweight version tracking.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 18:12:25 +08:00

110 lines
5.4 KiB
Python

#!/usr/bin/env python3
"""Generate Excel from transcribed 车用气瓶充装记录表 data (OCR/image description)."""
from pathlib import Path
from openpyxl import Workbook
from openpyxl.styles import Alignment, Font
from openpyxl.utils import get_column_letter
TITLE = (
"广东顺兴石油燃料有限公司2024年车用气瓶充装前、后检查和充装记录表-跨年"
)
HEADERS = [
"日期/班次",
"时间",
"车牌号",
"气瓶编号",
"是否持气瓶使用登记证",
"气瓶下次检验日期",
"充装介质",
"车辆外观、气瓶附件是否完好",
"气瓶附件是否正常",
"车辆电源是否关闭、清漏",
"充装前气瓶余压(MPa)",
"充装量(kg)",
"充装金额(元)",
"充装后压力(MPa)",
"充装后检查封条是否良好",
"公里数",
"驾驶员签名",
"检查员",
"充装员",
]
# Transcribed from image; empty cells where illegible/blank in source
ROWS = [
["5.9", "9:10", "粤A RT078", "2400718", "", "2029.6", "H2", "", "", "", 9, 7.94, 277.9, 35, "", 4215, "李建辉", "", ""],
["5.9", "9:34", "粤A GP722", "2400886", "", "2029.7", "H2", "", "", "", 17, 5.06, 177.22, 35, "", 4207, "", "", ""],
["5.9", "9:49", "粤A GP708", "2400681", "", "2029.7", "H2", "", "", "", 18, 4.79, 177.03, 35, "", 10122, "罗继荣", "", ""],
["5.9", "14:06", "粤A GW1936", "2401145", "", "2029.6", "H2", "", "", "", 12, 7.42, 259.38, 35, "", 5243, "曾庆平", "", ""],
["5.9", "16:02", "粤A GP518", "2400849", "", "2029.7", "H2", "", "", "", 13, 6.86, 240.10, 35, "", 2008, "马庆军", "", ""],
["5.9", "16:32", "粤A P9719", "2400666", "", "2029.7", "H2", "", "", "", 15, 7.82, 304.98, 35, "", 10960, "孙红兵", "", ""],
["5.9", "17:50", "粤A V7749", "2400572", "", "2029.6", "H2", "", "", "", 16, 4.05, 149.85, 35, "", 61928, "王建波", "", ""],
["5.9", "18:11", "粤A FH492", "2300493", "", "2029.9", "H2", "", "", "", 12, 4.87, 169.45, 35, "", 1981, "纪晓", "", ""],
["5.9", "19:55", "粤A H9878", "", "", "", "H2", "", "", "", 12, 8.77, 302.03, 35, "", 9172, "王晓", "", ""],
["5.9", "20:12", "粤A Q0826", "", "", "", "H2", "", "", "", 13, 8.36, 326.04, 35, "", 19414, "", "", ""],
["5.10", "6:28", "粤A R1586", "2400749", "", "2029.6", "H2", "", "", "", 6, 9.86, 384.54, 35, "", 4221, "", "", ""],
["5.10", "8:25", "粤A R5058", "2400768", "", "2029.6", "H2", "", "", "", 17, 3.08, 107.96, 35, "", 5218, "李建辉", "", ""],
["5.10", "8:44", "粤A GP367", "2400754", "", "2029.6", "H2", "", "", "", 6, 8.75, 323.75, 35, "", 1227, "曾庆平", "", ""],
["5.10", "9:58", "粤A GP217", "2400764", "", "2029.6", "H2", "", "", "", 8, 7.85, 306.15, 35, "", 4833, "马庆军", "", ""],
["5.10", "14:44", "粤A 02239F", "250082", "", "", "H2", "", "", "", 8, 19.21, 710.77, 35, "", 1371, "纪晓", "", ""],
["5.10", "14:19", "粤A H30131", "2501164", "", "2029.6", "H2", "", "", "", 5, 9.23, 359.97, 35, "", 3740, "王晓", "", ""],
]
FOOTNOTES = [
"1. 符合的打\"\",不符合的打\"X\"",
"2. 充装前必须逐项内容进行逐项检查,检查员在填表后签字确认。",
"3. 检查中发现有不符合的,不予充装。",
"4. (原表底部关于车辆外观、后车顶高度、气瓶登记证等可通过公交公司网络终端核对的说明,以纸质原件为准。)",
]
def main() -> None:
out = Path(__file__).resolve().parent.parent / "车用气瓶充装记录_手写表转录.xlsx"
wb = Workbook()
ws = wb.active
ws.title = "充装记录"
ws.merge_cells(start_row=1, start_column=1, end_row=1, end_column=len(HEADERS))
c = ws.cell(row=1, column=1, value=TITLE)
c.font = Font(bold=True, size=11)
c.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
for col, h in enumerate(HEADERS, start=1):
cell = ws.cell(row=2, column=col, value=h)
cell.font = Font(bold=True, size=10)
cell.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
for r_idx, row in enumerate(ROWS, start=3):
for c_idx, val in enumerate(row, start=1):
ws.cell(row=r_idx, column=c_idx, value=val)
note_row = 3 + len(ROWS) + 1
ws.cell(row=note_row, column=1, value="备注说明:")
ws.cell(row=note_row, column=1).font = Font(bold=True)
for i, line in enumerate(FOOTNOTES, start=1):
ws.cell(row=note_row + i, column=1, value=line)
ws.merge_cells(
start_row=note_row + i,
start_column=1,
end_row=note_row + i,
end_column=len(HEADERS),
)
ws.cell(row=note_row + i, column=1).alignment = Alignment(wrap_text=True, vertical="top")
# Column widths (readable for Chinese)
widths = [10, 8, 14, 12, 14, 14, 8, 18, 14, 18, 14, 10, 12, 12, 18, 8, 10, 8, 8]
for i, w in enumerate(widths, start=1):
ws.column_dimensions[get_column_letter(i)].width = w
ws.row_dimensions[1].height = 36
ws.row_dimensions[2].height = 36
wb.save(out)
print(out)
if __name__ == "__main__":
main()