Files
IT狗 eafc1c33fc Add full AARS system - Attendance & Accident Record System
- FastAPI backend with SQLite database
- React + TailwindCSS frontend
- JWT authentication
- Excel upload/download for attendance and accident records
- Shift roster management with S7a/S7b split
- Lateness/OT calculation based on shift times
- Roster info API endpoints
- Export API with token query parameter support
- Docker compose deployment
2026-07-16 03:16:33 +08:00

2.6 KiB

AARS - Attendance & Accident Record System

出勤及意外記錄系統

🚀 快速開始

方式一:Docker 部署(推薦)

# 复制到 VPS
scp -r ~/aars root@187.127.116.15:/root/

# SSH 到 VPS
ssh root@187.127.116.15

# 進入目录并运行
cd /root/aars
chmod +x setup.sh
./setup.sh

访问:http://187.127.116.15:18775

方式二:本地开发

# Backend
cd backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python test_backend.py  # 测试
uvicorn main:app --reload --port 8000

# Frontend (另一个terminal)
cd frontend
npm install
npm run dev

🔐 默认账户

⚠️ 首次登录后请立即修改密码!

📋 功能

出勤 Attendance

  • 列表视图 (Filter/Sort/分页)
  • 新增/编辑/删除记录
  • Excel 批量导入(自动去重)
  • 导出 Excel / PDF
  • 自定义字段

意外 Accident

  • 列表视图 (Filter/Sort/分页)
  • 新增/编辑/删除记录
  • Excel 批量导入(自动去重)
  • 导出 Excel / PDF
  • 自定义字段

Dashboard

  • 📊 统计卡片(总计/今日/本月)
  • 📈 趋势图表
  • ⚠️ 最近意外列表

🏗️ 技术栈

Layer Technology
Frontend React 18 + Vite + TailwindCSS
Backend FastAPI + SQLAlchemy
Database SQLite
Charts Recharts
Excel openpyxl + xlsxwriter
PDF ReportLab

📁 项目结构

aars/
├── backend/
│   ├── main.py          # FastAPI app
│   ├── models.py        # Database models
│   ├── schemas.py       # Pydantic schemas
│   ├── auth.py          # JWT auth
│   ├── database.py      # SQLite setup
│   └── requirements.txt
├── frontend/
│   ├── src/
│   │   ├── pages/       # React pages
│   │   ├── components/  # Reusable components
│   │   └── context/     # Auth context
│   └── ...
├── docker-compose.yml
├── Dockerfile
└── SPEC.md

🔧 配置

端口

  • 默认: 18775
  • 修改: 编辑 docker-compose.yml

JWT Secret

  • 开发: 自动生成
  • 生产: 修改 backend/secret.py

📝 API 文档

启动后访问:http://localhost:8000/docs (Swagger UI)

🐛 常见问题

Q: Docker build 失败?

docker compose down
docker compose build --no-cache
docker compose up -d

Q: 无法登录? 检查浏览器 console 的 CORS 错误,或确认 JWT secret 未变更。

Q: Excel 导入失败? 确保 Excel 文件第一行是表头,且日期格式为 YYYY-MM-DD