Backfill site worksheet records from paymonth data

This commit is contained in:
2026-06-15 10:56:32 +09:00
parent aca94d175c
commit 6790991471

View File

@@ -2293,7 +2293,49 @@ def get_site_worksheet_records_by_days(conn, start_date, end_date, member_nos, r
progress['processedTargets'] = month_idx
if progress is not None:
progress['phase'] = '달력 테이블 정리'
progress['phase'] = '월별 근무현황 보강'
identity_rows = conn.execute(
f'''
SELECT m.MemberNo, IFNULL(m.korName, '') AS korName, IFNULL(i.juminno, '') AS juminno
FROM member m
JOIN member_site_identity i ON i.memberNo = m.MemberNo
WHERE m.MemberNo IN ({ph})
AND IFNULL(m.korName, '') <> ''
AND IFNULL(i.juminno, '') <> ''
''',
member_nos
).fetchall()
for idx, (identity_member_no, identity_name, juminno) in enumerate(identity_rows, start=1):
if progress is not None:
progress.update({
'phase': '월별 근무현황 보강',
'processedMembers': idx - 1,
'totalMembers': len(identity_rows),
'currentProjectCode': '',
'currentYearMonth': _as_text(end_date)[:7],
'currentWorkDate': end_date,
})
try:
added += insert_construct_paymonth_records(
conn,
s,
identity_member_no,
identity_name,
juminno,
end_date,
start_date,
end_date,
)
conn.commit()
except Exception:
# Project/day crawl is the primary source; paymonth is a best-effort gap filler.
pass
if progress is not None:
progress.update({
'phase': '달력 테이블 정리',
'processedMembers': len(identity_rows),
'added': added,
})
conn.commit()
cleanup_site_records_after_retire(conn)
rebuild_work_calendar_tables(conn)