From 1114aa908ce67aab95f37172287dc0b78020d87d Mon Sep 17 00:00:00 2001 From: user01 Date: Mon, 25 May 2026 00:55:26 +0900 Subject: [PATCH] =?UTF-8?q?Refactor:=20=ED=85=9C=ED=94=8C=EB=A6=BF=20?= =?UTF-8?q?=EC=97=86=EC=9C=BC=EB=A9=B4=20=EB=B0=B0=EC=B9=98=EB=90=9C=20?= =?UTF-8?q?=EA=B7=BC=EB=A1=9C=EC=9E=90=EB=A7=8C=20=EA=B8=B0=EB=B3=B8=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 33dedc0..a21cee5 100644 --- a/app.py +++ b/app.py @@ -830,9 +830,7 @@ def export(): wp_filename = t.get('workplace_filename', '') base = os.path.splitext(wp_filename)[0] template_path = f'{base}_template.xlsx' if base else '' - if not template_path or not os.path.exists(template_path): - template_path = '선거참관인_배치_와꾸_.xlsx' - if os.path.exists(template_path): + if template_path and os.path.exists(template_path): wb = openpyxl.load_workbook(template_path) wp_workers = {} for w in t['workers']: @@ -882,6 +880,31 @@ def export(): wn = wp_lookup[a_id]['name'] if a_id in wp_lookup else '' wa = wp_lookup[a_id]['address'] if a_id in wp_lookup else '' ws_extra.append([w['name'], w['phone'], w['dob'], w['hope'], w['address'], wn, wa]) + else: + # 템플릿 없으면 배치된 근로자만 기본 리스트 출력 + ws1 = wb.active + ws1.title = '배치 현황' + ws1.append(['이름', '연락처', '생년월일', '희망사항', '주소', '배치근무지', '근무지주소']) + for w in t['workers']: + a_id = t['assignments'].get(w['id']) + if not a_id: + continue + wn = wp_lookup[a_id]['name'] if a_id in wp_lookup else '' + wa = wp_lookup[a_id]['address'] if a_id in wp_lookup else '' + ws1.append([w['name'], w['phone'], w['dob'], w['hope'], w['address'], wn, wa]) + ws2 = wb.create_sheet('근무지별 배치') + ws2.append(['근무지명', '주소', '배치인원', '배치된근무자']) + addr_groups = {} + for wp in t['workplaces']: + key = wp['address'] + if key not in addr_groups: + addr_groups[key] = {'names': [], 'workplace_ids': []} + addr_groups[key]['names'].append(wp['name']) + addr_groups[key]['workplace_ids'].append(wp['id']) + for addr, g in addr_groups.items(): + combined_name = ', '.join(g['names']) + aw = [w['name'] for w in t['workers'] if t['assignments'].get(w['id']) in g['workplace_ids']] + ws2.append([combined_name, addr, len(aw), ', '.join(aw)]) else: # all (전체) ws1 = wb.active