성별 컬럼 처리 추가 (파싱/템플릿/export)

This commit is contained in:
user01
2026-05-25 01:11:35 +09:00
parent 1114aa908c
commit 310885ed8a
2 changed files with 14 additions and 8 deletions

22
app.py
View File

@@ -482,6 +482,7 @@ def process_excel_file(wb, filename, force_type=None):
name_idx = name_idx if name_idx is not None else 0
dob_idx = find_header_idx(headers, ['생년월일', '생일']) or 3
phone_idx = find_header_idx(headers, ['연락처', '전화', '휴대폰']) or 4
gender_idx = find_header_idx(headers, ['성별'])
if addr_idx is None:
addr_idx = 2
logger.warning(f' [주의] 주소 컬럼을 찾을 수 없어 기본 인덱스 {addr_idx} 사용')
@@ -571,6 +572,7 @@ def process_excel_file(wb, filename, force_type=None):
name_idx = name_idx if name_idx is not None else 0
dob_idx = find_header_idx(headers, ['생년월일', '생일']) or 3
phone_idx = find_header_idx(headers, ['연락처', '전화', '휴대폰']) or 4
gender_idx = find_header_idx(headers, ['성별'])
if addr_idx is None:
addr_idx = 2
@@ -587,6 +589,7 @@ def process_excel_file(wb, filename, force_type=None):
'address': addr,
'dob': str(row[dob_idx] or '').strip(),
'phone': str(row[phone_idx] or '').strip(),
'gender': str(row[gender_idx] or '').strip() if gender_idx is not None else '',
'lat': lat, 'lng': lng,
})
else:
@@ -821,10 +824,10 @@ def export():
if export_type == 'unassigned':
ws = wb.active
ws.title = '미배치 근로자'
ws.append(['이름', '희망사항', '주소', '생년월일', '연락처'])
ws.append(['이름', '희망사항', '주소', '생년월일', '연락처', '성별'])
for w in t['workers']:
if w['id'] not in t['assignments']:
ws.append([w['name'], w['hope'], w['address'], w['dob'], w['phone']])
ws.append([w['name'], w['hope'], w['address'], w['dob'], w['phone'], w['gender']])
elif export_type == 'assigned':
wp_filename = t.get('workplace_filename', '')
@@ -844,6 +847,7 @@ def export():
name_col = find_header_idx(headers, ['성명', '이름'])
dob_col = find_header_idx(headers, ['생년월일', '생일'])
phone_col = find_header_idx(headers, ['연락처', '전화', '휴대폰'])
gender_col = find_header_idx(headers, ['성별'])
addr_col = find_header_idx(headers, ['주소', '위치', '소재지'])
wp_name_col = find_header_idx(headers, ['투표소'])
if wp_name_col is None:
@@ -865,6 +869,8 @@ def export():
cells[dob_col].value = w['dob']
if phone_col is not None and cells[phone_col].value is None:
cells[phone_col].value = w['phone']
if gender_col is not None and cells[gender_col].value is None:
cells[gender_col].value = w['gender']
if addr_col is not None and cells[addr_col].value is None:
cells[addr_col].value = w['address']
used_names.add(w['id'])
@@ -873,25 +879,25 @@ def export():
remaining = all_assigned - used_names
if remaining:
ws_extra = wb.create_sheet('추가 배치')
ws_extra.append(['이름', '연락처', '생년월일', '희망사항', '주소', '배치근무지', '근무지주소'])
ws_extra.append(['이름', '연락처', '생년월일', '희망사항', '주소', '성별', '배치근무지', '근무지주소'])
for w in t['workers']:
if w['id'] in remaining:
a_id = t['assignments'].get(w['id'])
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])
ws_extra.append([w['name'], w['phone'], w['dob'], w['hope'], w['address'], w['gender'], wn, wa])
else:
# 템플릿 없으면 배치된 근로자만 기본 리스트 출력
ws1 = wb.active
ws1.title = '배치 현황'
ws1.append(['이름', '연락처', '생년월일', '희망사항', '주소', '배치근무지', '근무지주소'])
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])
ws1.append([w['name'], w['phone'], w['dob'], w['hope'], w['address'], w['gender'], wn, wa])
ws2 = wb.create_sheet('근무지별 배치')
ws2.append(['근무지명', '주소', '배치인원', '배치된근무자'])
addr_groups = {}
@@ -909,12 +915,12 @@ def export():
else: # all (전체)
ws1 = wb.active
ws1.title = '배치 현황'
ws1.append(['이름', '연락처', '생년월일', '희망사항', '주소', '배치근무지', '근무지주소'])
ws1.append(['이름', '연락처', '생년월일', '희망사항', '주소', '성별', '배치근무지', '근무지주소'])
for w in t['workers']:
a_id = t['assignments'].get(w['id'])
wn = wp_lookup[a_id]['name'] if a_id and a_id in wp_lookup else ''
wa = wp_lookup[a_id]['address'] if a_id and a_id in wp_lookup else ''
ws1.append([w['name'], w['phone'], w['dob'], w['hope'], w['address'], wn, wa])
ws1.append([w['name'], w['phone'], w['dob'], w['hope'], w['address'], w['gender'], wn, wa])
ws2 = wb.create_sheet('근무지별 배치')
ws2.append(['근무지명', '주소', '배치인원', '배치된근무자'])
addr_groups = {}

Binary file not shown.