# -*- coding: utf-8 -*-
"""현황판 갱신: python _update_status.py {num} {행수} ["비고추가"]"""
import sys, io, openpyxl, glob, os, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
num=int(sys.argv[1]); rows=sys.argv[2] if len(sys.argv)>2 else ''
extra=sys.argv[3] if len(sys.argv)>3 else ''
wb=openpyxl.load_workbook('공공기관3_작업현황.xlsx')
sh=wb['현황']
for r in range(2,sh.max_row+1):
    if sh.cell(r,2).value==num:
        sh.cell(r,5).value='✅ 수집완료'   # 상태
        sh.cell(r,6).value='미검수'          # 검수
        if rows: sh.cell(r,7).value=int(rows) # 행수
        if extra:
            cur=sh.cell(r,11).value or ''
            if extra not in cur: sh.cell(r,11).value=cur+' · '+extra
        print(f'{num}.{sh.cell(r,3).value} → 수집완료 {rows}행')
        break
wb.save('공공기관3_작업현황.xlsx')
