feat: 月度模式全面参数化 - 移除硬编码日期,前后端按月动态查询
This commit is contained in:
@@ -43,7 +43,7 @@ def to_text(val):
|
||||
s = str(val).strip()
|
||||
return s if s else None
|
||||
|
||||
def import_salary(conn):
|
||||
def import_salary(conn, report_month='2026-04-01'):
|
||||
print(f'导入薪资拆分明细表: {SALARY_FILE}')
|
||||
sha = file_sha256(SALARY_FILE)
|
||||
wb = openpyxl.load_workbook(SALARY_FILE, read_only=True, data_only=True)
|
||||
@@ -54,7 +54,7 @@ def import_salary(conn):
|
||||
data_rows = [r for r in rows if r[0] is not None and r[9] is not None and str(r[9]).strip()]
|
||||
print(f' 数据行数: {len(data_rows)}')
|
||||
|
||||
report_month = '2026-04-01'
|
||||
report_month = report_month
|
||||
source_file = os.path.basename(SALARY_FILE)
|
||||
|
||||
cur = conn.cursor()
|
||||
@@ -145,7 +145,7 @@ def import_salary(conn):
|
||||
wb.close()
|
||||
print(f' 薪资明细导入完成: {len(data_rows)} 行')
|
||||
|
||||
def import_attendance(conn):
|
||||
def import_attendance(conn, report_month='2026-04-01'):
|
||||
print(f'\n导入考勤数据表: {ATTENDANCE_FILE}')
|
||||
sha = file_sha256(ATTENDANCE_FILE)
|
||||
wb = openpyxl.load_workbook(ATTENDANCE_FILE, read_only=True, data_only=True)
|
||||
@@ -156,7 +156,7 @@ def import_attendance(conn):
|
||||
data_rows = [r for r in rows if r[0] is not None]
|
||||
print(f' 数据行数: {len(data_rows)}')
|
||||
|
||||
report_month = '2026-04-01'
|
||||
report_month = report_month
|
||||
source_file = os.path.basename(ATTENDANCE_FILE)
|
||||
|
||||
cur = conn.cursor()
|
||||
@@ -209,11 +209,13 @@ def import_attendance(conn):
|
||||
print(f' 考勤数据导入完成: {len(data_rows)} 行')
|
||||
|
||||
def main():
|
||||
report_month = sys.argv[1] if len(sys.argv) > 1 else '2026-04-01'
|
||||
print(f'导入月份: {report_month}')
|
||||
conn = psycopg2.connect(**DB_CONFIG)
|
||||
conn.autocommit = False
|
||||
try:
|
||||
import_salary(conn)
|
||||
import_attendance(conn)
|
||||
import_salary(conn, report_month)
|
||||
import_attendance(conn, report_month)
|
||||
print('\n=== 导入完成 ===')
|
||||
except Exception as e:
|
||||
conn.rollback()
|
||||
|
||||
Reference in New Issue
Block a user